@vpxa/aikit 0.1.126 → 0.1.128

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.
@@ -1 +0,0 @@
1
- var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};export{t};
@@ -1,2 +0,0 @@
1
- import{t as e}from"./rolldown-runtime-BbypZo7q.js";import{existsSync as t,mkdirSync as n,readFileSync as r,rmSync as i,unlinkSync as a,writeFileSync as o}from"node:fs";import{dirname as s,resolve as c}from"node:path";import{pathToFileURL as l}from"node:url";import{createHash as u}from"node:crypto";function d(e){return u(`sha256`).update(e).digest(`hex`).slice(0,16)}function f(e){if(!t(e))return null;try{let t=r(e,`utf-8`),n=JSON.parse(t);return!n.version||!n.files?null:n}catch{return null}}function p(e,t){o(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function m(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`:`overwrite`}function h(e,t,n){if(!e)return`new`;let r=e.files[t];return r?r.sourceHash===d(n)?`current`:`outdated`:`new`}function g(e,t,n,r){e.files[t]={sourceHash:d(n),strategy:r??m(t),updatedAt:new Date().toISOString()}}function _(e){return{version:e,generatedAt:new Date().toISOString(),files:{}}}const v=[`inputs`,`outputs`,`requires`,`relatedSkills`],y=[`model`],b=[`category`,`domain`,`applicability`],x=new Set([`__proto__`,`constructor`,`prototype`]);function S(e,t){return e.metadata[t]??e.fields[t]}function C(e,t){let n=S(e,t);return n?T(n):[]}function w(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(x.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}x.has(a)||(t[a]=o,a===`tools`&&(r=T(o)))}return{fields:t,metadata:n,tools:r,body:i}}function T(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 E(e){return`[${e.join(`, `)}]`}function D(e,t){let n=w(e),r=w(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 y)r.fields[e]&&(i[e]=r.fields[e]);for(let e of b){let t=S(r,e);t&&(a[e]=t)}for(let e of[...b,...v])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=E(u));for(let e of v){let t=C(n,e),i=C(r,e),o=new Set(t),s=i.filter(e=>!o.has(e)),c=[...t,...s];c.length>0?a[e]=E(c):delete a[e]}let d=[`---`],f=[`name`,`description`,`argument-hint`,`tools`,`model`],p=[`category`,`domain`,`applicability`,`inputs`,`outputs`,`requires`,`relatedSkills`],m=new Set;for(let e of f)e in i&&(d.push(`${e}: ${i[e]}`),m.add(e));for(let[e,t]of Object.entries(i))m.has(e)||d.push(`${e}: ${t}`);let h=[],g=new Set;for(let e of p){let t=a[e];t&&(h.push(` ${e}: ${t}`),g.add(e))}for(let[e,t]of Object.entries(a))!g.has(e)&&t&&h.push(` ${e}: ${t}`);return h.length>0&&(d.push(`metadata:`),d.push(...h)),d.push(`---`),`${d.join(`
2
- `)}\n${n.body}`}var O=e({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(l(c(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(e,i,a,l,u=!1){n(i,{recursive:!0});for(let d of e){let e=l?`${l}/${d.path}`:d.path,f=c(i,d.path);if(u){n(s(f),{recursive:!0}),o(f,d.content,`utf-8`),g(a,e,d.content);continue}let p=h(a,e,d.content);if(p!==`current`){if(p===`new`&&!t(f)){n(s(f),{recursive:!0}),o(f,d.content,`utf-8`),g(a,e,d.content);continue}if(p===`new`&&t(f)){g(a,e,d.content);continue}if(m(e)===`merge-frontmatter`&&t(f)){let e=r(f,`utf-8`);o(f,D(d.content,e),`utf-8`)}else n(s(f),{recursive:!0}),o(f,d.content,`utf-8`);g(a,e,d.content)}}u&&j(i,a,l,new Set(e.map(e=>l?`${l}/${e.path}`:e.path)))}function j(e,n,r,i){let o=[];for(let s of Object.keys(n.files)){if(!s.startsWith(`${r}/`)||i.has(s))continue;let l=c(e,s.slice(r.length+1));t(l)&&(a(l),o.push(s)),delete n.files[s]}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(`.`)),s=o?e:c(e,`.github`),l=c(s,`.aikit-scaffold.json`),u=f(l)??_(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?c(s,e):s,u,o?`${n}/${e||`.`}`:e||`.`,i);p(l,u)}async function N(e,t,n,r,i=!1){let a=c(e,`.github`),o=c(a,`.aikit-scaffold.json`),s=f(o)??_(r);s.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,c(a,`skills`,e),s,`skills/${e}`,i);p(o,s)}async function P(e,n,i=`copilot`){let a=[],o=await k(n,i),s=o.some(e=>e.path.startsWith(`.`))?e:c(e,`.github`);for(let e of o){let n=c(s,e.path);if(!t(n))a.push({status:`new`,relativePath:e.path,sourcePath:``,content:e.content});else{let t=r(n,`utf-8`);e.content===t?a.push({status:`current`,relativePath:e.path,sourcePath:``}):a.push({status:`outdated`,relativePath:e.path,sourcePath:``,content:e.content})}}return a}async function F(e,n,i){let a=[],o=await k(n,`skills`),s=c(e,`.github`);for(let e of o){let n=`skills/${e.path}`,i=c(s,`skills`,e.path);if(!t(i))a.push({status:`new`,relativePath:n,sourcePath:``,content:e.content});else{let t=r(i,`utf-8`);e.content===t?a.push({status:`current`,relativePath:n,sourcePath:``}):a.push({status:`outdated`,relativePath:n,sourcePath:``,content:e.content})}}return a}async function I(e,n,r,a,o=!1){let s=c(e,`.github`),l=c(s,`.aikit-scaffold.json`),u=f(l)??_(a);u.version=a;let d=await k(n,`flows`),m=new Set,h=new Map;for(let e of d){let t=e.path.indexOf(`/`);if(t===-1)continue;let n=e.path.substring(0,t);m.add(n);let r=e.path.substring(t+1),i=h.get(n)??[];i.push({path:r,content:e.content}),h.set(n,i)}for(let e of m){let n=c(s,`flows`,e,`skills`);t(n)&&i(n,{recursive:!0,force:!0})}for(let[e,t]of h)A(t,c(s,`flows`,e),u,`flows/${e}`,o);p(l,u)}async function L(e,n,i){let a=[],o=await k(n,`flows`),s=c(e,`.github`);for(let e of o){let n=`flows/${e.path}`,i=c(s,`flows`,e.path);if(!t(i))a.push({status:`new`,relativePath:n,sourcePath:``,content:e.content});else{let t=r(i,`utf-8`);e.content===t?a.push({status:`current`,relativePath:n,sourcePath:``}):a.push({status:`outdated`,relativePath:n,sourcePath:``,content:e.content})}}return a}export{O as a,M as c,f as d,p as f,k as i,N as l,P as n,I as o,F as r,A as s,L as t,_ as u};
@@ -1,6 +0,0 @@
1
- import{t as e}from"./rolldown-runtime-BbypZo7q.js";import{a as t,i as n,n as r,s as i,t as a}from"./templates-CKn2AmTo.js";import{d as o,f as s,i as c,s as l,u}from"./scaffold--Z8D_CTu.js";import{existsSync as d,mkdirSync as f,readFileSync as p,readdirSync as m,rmSync as ee,unlinkSync as h,writeFileSync as g}from"node:fs";import{dirname as _,join as v,posix as y,resolve as b,win32 as x}from"node:path";import{fileURLToPath as S}from"node:url";import{mkdir as C,readFile as w,rename as T,unlink as E,writeFile as D}from"node:fs/promises";import{randomUUID as O}from"node:crypto";import{homedir as k}from"node:os";import{execFileSync as A}from"node:child_process";import{getGlobalDataDir as j,saveRegistry as M}from"../../core/dist/index.js";function N(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]!==`
2
- `;)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 P=class{isPlatformSupported(){return this.platforms.includes(process.platform)}async readConfig(e){let t=this.getConfigPath(e);if(!d(t))return{};let n=await w(t,`utf-8`);try{return JSON.parse(N(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=_(n),i=v(r,`.aikit-tmp-${O()}.json`);await C(r,{recursive:!0});try{await D(i,`${JSON.stringify(e,null,2)}\n`,`utf-8`),await T(i,n)}catch(e){try{await E(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}}buildInstructionContent(e,t){return`${e}\n---\n\n${t}`}},F=class extends P{id=`claude-code`;name=`Claude Code`;family=`claude`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`mcpServers`;async detect(){return this.isPlatformSupported()?d(this.getPathModule().resolve(k(),`.claude`)):!1}getConfigPath(){return this.getPathModule().resolve(k(),`.claude`,`mcp.json`)}getScaffoldRoot(){return this.getPathModule().resolve(k(),`.claude`)}getScaffoldPaths(){let e=this.getPathModule(),t=e.resolve(k(),`.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`)}}buildInstructionContent(e,t){return`${e}\n---\n\n${t}`}getPathModule(){return process.platform===`win32`?x:y}},I=class extends P{id=`codex-cli`;name=`Codex CLI`;family=`codex`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`mcpServers`;async detect(){return this.isPlatformSupported()?d(this.getPathModule().resolve(k(),`.codex`)):!1}getConfigPath(){return this.getPathModule().resolve(k(),`.codex`,`config.json`)}getScaffoldRoot(){return this.getPathModule().resolve(k(),`.codex`)}getScaffoldPaths(){let e=this.getPathModule(),t=e.resolve(k(),`.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`)}}getPathModule(){return process.platform===`win32`?x:y}},L=class extends P{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 d(e)||t!==null&&d(t)}return d(e)}getConfigPath(){return this.getPathModule().resolve(this.getConfigDir(),`mcp.json`)}getScaffoldRoot(){return this.getPathModule().resolve(k(),this.scaffoldBase)}getInstructionsRoot(){let e=this.getInstructionFilePath();return e?this.getPathModule().dirname(e):null}getScaffoldPaths(){let e=this.getPathModule(),t=e.resolve(k(),this.scaffoldBase);return{agents:e.resolve(t,`agents`),skills:e.resolve(t,`skills`),prompts:e.resolve(this.getConfigDir(),`prompts`),flows:e.resolve(t,`flows`),commands:null,instructions:this.getInstructionFilePath(),manifest:e.resolve(t,`.aikit-scaffold.json`)}}getConfigDir(){let e=this.getPathModule(),t=k();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`?x:y}},R=class extends P{id=`copilot-cli`;name=`Copilot CLI`;family=`copilot`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`mcpServers`;async detect(){return this.isPlatformSupported()?d(b(k(),`.copilot`)):!1}getConfigPath(){return b(k(),`.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 b(k(),`.copilot`)}getInstructionsRoot(){return null}getScaffoldPaths(){let e=b(k(),`.copilot`);return{agents:b(e,`agents`),skills:b(e,`skills`),prompts:null,flows:b(e,`flows`),commands:null,instructions:b(k(),`.github`,`copilot-instructions.md`),manifest:b(e,`.aikit-scaffold.json`)}}},z=class extends L{id=`cursor`;name=`Cursor`;configKey=`mcpServers`;configDirName=`Cursor`;scaffoldBase=`.cursor`;getMacAppPath(){return`/Applications/Cursor.app`}getInstructionFilePath(){return this.getPathModule().resolve(k(),this.scaffoldBase,`rules`,`aikit.mdc`)}},B=class extends L{id=`cursor-nightly`;name=`Cursor Nightly`;configKey=`mcpServers`;configDirName=`Cursor Nightly`;scaffoldBase=`.cursor`;getMacAppPath(){return`/Applications/Cursor Nightly.app`}getInstructionFilePath(){return this.getPathModule().resolve(k(),this.scaffoldBase,`rules`,`aikit.mdc`)}},V=class e extends P{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(d(this.getCopilotConfigDir()))return!0;let t=this.getJetBrainsBaseDir();if(!d(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 b(this.getCopilotConfigDir(),`mcp.json`)}async registerMcp(e,t,n){let r=this.getCopilotConfigDir();await C(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=b(r,`${e}-launcher.js`);await D(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}}buildInstructionContent(e,t){return t}getCopilotConfigDir(){let e=k();return process.platform===`win32`?b(process.env.LOCALAPPDATA??b(e,`AppData`,`Local`),`github-copilot`,`intellij`):process.platform===`darwin`?b(e,`Library`,`Application Support`,`github-copilot`,`intellij`):b(process.env.XDG_CONFIG_HOME??b(e,`.config`),`github-copilot`,`intellij`)}getJetBrainsBaseDir(){let e=k();return process.platform===`win32`?b(process.env.APPDATA??b(e,`AppData`,`Roaming`),`JetBrains`):process.platform===`darwin`?b(e,`Library`,`Application Support`,`JetBrains`):b(process.env.XDG_CONFIG_HOME??b(e,`.config`),`JetBrains`)}},H=class extends L{id=`trae`;name=`Trae`;configKey=`servers`;configDirName=`Trae`;scaffoldBase=`.trae`;getMacAppPath(){return`/Applications/Trae.app`}getInstructionFilePath(){return this.getPathModule().resolve(k(),this.scaffoldBase,`rules`,`aikit.md`)}},U=class extends L{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(k(),this.scaffoldBase,`instructions`,`copilot-instructions.md`):null}buildInstructionContent(e,t){return`---\napplyTo: "**"\n---\n\n${e}\n---\n\n${t}`}},W=class extends L{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(k(),this.scaffoldBase,`instructions`,`copilot-instructions.md`):null}buildInstructionContent(e,t){return`---\napplyTo: "**"\n---\n\n${e}\n---\n\n${t}`}},G=class extends L{id=`vscodium`;name=`VSCodium`;configKey=`servers`;configDirName=`VSCodium`;scaffoldBase=`.copilot`;hasInstructions=!0;getMacAppPath(){return`/Applications/VSCodium.app`}getInstructionFilePath(){return this.hasInstructions?this.getPathModule().resolve(k(),this.scaffoldBase,`instructions`,`copilot-instructions.md`):null}buildInstructionContent(e,t){return`---\napplyTo: "**"\n---\n\n${e}\n---\n\n${t}`}},K=class extends L{id=`windsurf`;name=`Windsurf`;configKey=`servers`;configDirName=`Windsurf`;scaffoldBase=`.windsurf`;getMacAppPath(){return`/Applications/Windsurf.app`}getInstructionFilePath(){return this.getPathModule().resolve(k(),this.scaffoldBase,`rules`,`aikit.md`)}},q=class extends P{id=`gemini-cli`;name=`Gemini CLI`;family=`gemini`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`mcpServers`;async detect(){return this.isPlatformSupported()?d(this.getPathModule().resolve(k(),`.gemini`)):!1}getConfigPath(){return this.getPathModule().resolve(k(),`.gemini`,`settings.json`)}getScaffoldRoot(){return this.getPathModule().resolve(k(),`.gemini`)}getScaffoldPaths(){let e=this.getPathModule(),t=e.resolve(k(),`.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`)}}getPathModule(){return process.platform===`win32`?x:y}},te=class extends P{id=`zed`;name=`Zed`;family=`zed`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`context_servers`;async detect(){return this.isPlatformSupported()?d(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`)}}getConfigDir(){let e=this.getPathModule();return process.platform===`win32`?e.resolve(process.env.APPDATA||k(),`Zed`):e.resolve(k(),`.config`,`zed`)}getPathModule(){return process.platform===`win32`?x:y}};const J=[new U,new W,new G,new z,new B,new K,new H,new R,new V,new F,new q,new I,new te];function ne(){return[...J]}async function Y(e){let t=e?.scope?J.filter(t=>t.scope===e.scope):J;return(await Promise.allSettled(t.map(async e=>await e.detect()?e:null))).flatMap(e=>e.status!==`fulfilled`||e.value===null?[]:[e.value])}var re=e({initUser:()=>oe,installGlobalScaffold:()=>$,resolveMcpServerEntry:()=>X,writeVscodeSettings:()=>Q});function ie(e){let t=e;for(let e=0;e<10;e++){try{let e=v(t,`package.json`);if(d(e)&&JSON.parse(p(e,`utf8`)).name===`@vpxa/aikit`)return t}catch{}let e=_(t);if(e===t)break;t=e}return b(e,`..`,`..`,`..`)}function X(){let e={command:n.command,args:n.args?[...n.args]:void 0,type:n.type};if(process.platform!==`win32`){let t=process.env.PATH;t&&(e.env={PATH:t});try{let t=A(`which`,[`node`],{encoding:`utf-8`,timeout:3e3}).trim();t&&d(t)&&(e.command=t)}catch{}}return e}const Z=new Set([`VS Code`,`VS Code Insiders`,`VSCodium`]);function Q(e,t=!1){if(!Z.has(e.name))return;let n=b(_(e.getConfigPath()),`settings.json`),r={};if(d(n))try{let e=p(n,`utf-8`);r=JSON.parse(e)}catch{console.log(` ${e.name}: skipped settings.json (invalid JSON)`);return}let a=!1;for(let[e,n]of Object.entries(i))if(typeof n==`object`&&n){let t=typeof r[e]==`object`&&r[e]!==null?r[e]:{},i={...t,...n};JSON.stringify(i)!==JSON.stringify(t)&&(r[e]=i,a=!0)}else (t||!(e in r))&&(r[e]=n,a=!0);a&&(g(n,`${JSON.stringify(r,null,2)}\n`,`utf-8`),console.log(` ${e.name}: updated settings.json`))}async function $(e,t,n,i,p=!1){let m=new Map;for(let e of t)e.getScaffoldRoot()!==null&&m.set(e.id,e);if(t.some(e=>Z.has(e.name))){let e=ne().find(e=>e.id===`copilot-cli`);e&&m.set(e.id,e)}if(m.size===0){console.log(` No IDEs with global scaffold support detected.`);return}let h=await c(e,`copilot`),v=new Map;for(let e of h){let t=e.path.indexOf(`/`);if(t===-1)continue;let n=e.path.substring(0,t);if(n!==`agents`&&n!==`prompts`)continue;let r=v.get(n)??[];r.push({path:e.path.substring(t+1),content:e.content}),v.set(n,r)}let y=await c(e,`skills`),x=new Set;for(let e of y){let t=e.path.indexOf(`/`);t!==-1&&x.add(e.path.substring(0,t))}let S=await c(e,`flows`),C=new Set;for(let e of S){let t=e.path.indexOf(`/`);t!==-1&&C.add(e.path.substring(0,t))}let w=await c(e,`claude-code`),T=new Set,E=new Set,D=new Set,O=(e,t,n)=>{let r=v.get(n);if(!e||!t||!r||r.length===0)return;let a=`${n}:${t}:${e}`;if(T.has(a))return;T.add(a);let c=o(t)??u(i);c.version=i,l(r,e,c,n,p),s(t,c),D.add(_(t))},k=(e,t,n,r)=>{if(!e||!t||r.length===0)return;let a=`${n}:${t}:${e}`;if(T.has(a))return;if(T.add(a),n===`flows`&&!E.has(e)){for(let n of C){let r=b(e,n,`skills`);d(r)&&(ee(r,{recursive:!0,force:!0}),console.log(` ${_(t)}: migrated ${n} flow to steps/ layout`))}E.add(e)}let c=o(t)??u(i);c.version=i,l(r,e,c,n,p),s(t,c),D.add(_(t))};for(let e of m.values()){let t=e.getScaffoldPaths();O(t.agents,t.manifest,`agents`),O(t.prompts,t.manifest,`prompts`),k(t.skills,t.manifest,`skills`,y),k(t.flows,t.manifest,`flows`,S),k(t.commands,t.manifest,`commands`,w)}for(let e of D)console.log(` ${e}: scaffold updated (${x.size} skills)`);let A=new Set,j=r(`aikit`,n),M=a(`aikit`,n);for(let e of m.values()){let t=e.getScaffoldPaths().instructions;!t||A.has(t)||(f(_(t),{recursive:!0}),g(t,e.buildInstructionContent(j,M),`utf-8`),A.add(t))}A.size>0&&console.log(` Instruction files: ${[...A].join(`, `)}`)}function ae(e){let t=[];for(let n of e){let e=n.getScaffoldRoot();if(e)if(Z.has(n.name)){let r=n.getInstructionsRoot()??e;t.push(b(r,`kb.instructions.md`)),t.push(b(r,`aikit.instructions.md`))}else n.name===`Cursor`||n.name===`Cursor Nightly`?t.push(b(e,`rules`,`kb.mdc`)):n.name===`Windsurf`&&t.push(b(e,`rules`,`kb.md`))}for(let e of t)d(e)&&(h(e),console.log(` Removed legacy file: ${e}`))}async function oe(e){let n=t,r=ie(_(S(import.meta.url))),i=JSON.parse(p(b(r,`package.json`),`utf-8`)).version;console.log(`Initializing @vpxa/aikit v${i}...\n`);let a=j();f(a,{recursive:!0}),console.log(` Global data store: ${a}`),M({version:1,workspaces:{}}),console.log(` Created registry.json`);let o=await Y({scope:`user`});if(o.length===0)console.log(`
3
- No supported IDEs detected. You can manually add the MCP server config.`);else{console.log(`\n Detected ${o.length} IDE(s):`);let t=X();for(let e of o)try{await e.registerMcp(n,t),console.log(` ${e.name}: configured ${n}`)}catch(t){console.log(` ${e.name}: failed to configure (${t.message})`)}for(let t of o)Q(t,e.force)}console.log(`
4
- Installing scaffold files:`),await $(r,o,n,i,e.force),ae(o),console.log(`
5
- User-level AI Kit installation complete!`),console.log(`
6
- Next steps:`),console.log(` 1. Open any workspace in your IDE`),console.log(` 2. The AI Kit server will auto-start and index the workspace`),console.log(` 3. Agents, prompts, skills & instructions are available globally`),console.log(` 4. No per-workspace init needed — just open a project and start coding`)}export{Y as a,Q as i,X as n,re as r,$ as t};
@@ -1,228 +0,0 @@
1
- # Scaffold System — Contributor Guide
2
-
3
- > **⚠️ GOLDEN RULE: Never edit files in `scaffold/general/` or `scaffold/claude-code/` directly.**
4
- > They are **generated output** and will be overwritten by `generate.mjs`.
5
- > Always edit the **source files** in `scaffold/definitions/`.
6
-
7
- ## Architecture
8
-
9
- ```
10
- scaffold/
11
- ├── definitions/ ← SOURCE OF TRUTH (edit here)
12
- │ ├── agents.mjs Agent metadata (name, description, model, tools, category)
13
- │ ├── bodies.mjs Agent body text (mode instructions per agent)
14
- │ ├── flows.mjs Flow step instruction content (step READMEs as JS strings)
15
- │ ├── skills.mjs Skill content (SKILL.md + reference files as JS strings)
16
- │ ├── models.mjs Available models per IDE
17
- │ ├── protocols.mjs Shared protocol files (_shared/*.md) + templates
18
- │ ├── tools.mjs Tool capability → IDE tool mappings
19
- │ ├── prompts.mjs Prompt file content
20
- │ ├── hooks.mjs Hook definitions
21
- │ └── plugins.mjs Plugin definitions
22
-
23
- ├── adapters/ ← IDE-specific generators
24
- │ ├── copilot.mjs GitHub Copilot adapter (active — generates ~32 files)
25
- │ ├── claude-code.mjs Claude Code adapter (stub — no output yet)
26
- │ ├── flows.mjs Flow step file generator (reads definitions/flows.mjs)
27
- │ └── skills.mjs Skill file generator (reads definitions/skills.mjs)
28
-
29
- ├── generate.mjs ← BUILD SCRIPT (run after any change)
30
-
31
- ├── general/ ← GENERATED OUTPUT for Copilot (DO NOT EDIT)
32
- │ ├── agents/
33
- │ │ ├── _shared/ Protocol files (from PROTOCOLS in protocols.mjs)
34
- │ │ ├── templates/ Template files (from TEMPLATES in protocols.mjs)
35
- │ │ └── *.agent.md Agent files (from AGENT_BODIES in bodies.mjs)
36
- │ └── prompts/ Prompt files (from PROMPTS in prompts.mjs)
37
-
38
- └── claude-code/ ← GENERATED OUTPUT for Claude Code (stub, DO NOT EDIT)
39
- ```
40
-
41
- ### Data Flow
42
-
43
- ```
44
- definitions/*.mjs → generate.mjs → scaffold/general/ → aikit init → .github/ (user project)
45
- (source) (build script) (generated output) (deploy) (user workspace)
46
- ```
47
-
48
- ## How to Make Changes
49
-
50
- ### Step 1: Edit Source Files
51
-
52
- | What you want to change | Edit this file |
53
- |--------------------------|---------------|
54
- | An agent's body/instructions | `definitions/bodies.mjs` → `AGENT_BODIES[agentName]` |
55
- | Shared rules for code agents | `definitions/protocols.mjs` → `PROTOCOLS['code-agent-base']` |
56
- | Shared rules for researchers | `definitions/protocols.mjs` → `PROTOCOLS['researcher-base']` |
57
- | Agent metadata (model, tools) | `definitions/agents.mjs` → `AGENTS[agentName]` |
58
- | Flow step instructions | `definitions/flows.mjs` → `FLOWS['<flow-name>']` find the step file entry |
59
- | Skill content | `definitions/skills.mjs` → `SKILLS['<skill-name>']` find the file entry |
60
- | Available models | `definitions/models.mjs` |
61
- | Tool mappings | `definitions/tools.mjs` |
62
- | Prompt files | `definitions/prompts.mjs` |
63
-
64
- ### Step 2: Regenerate Output
65
-
66
- ```bash
67
- node scaffold/generate.mjs
68
- ```
69
-
70
- This will:
71
- 1. Clean `general/agents/` and `general/prompts/` directories
72
- 2. Regenerate all files from definitions via the copilot adapter
73
- 3. Print every file written (expect ~32 files)
74
-
75
- To generate for a specific IDE only:
76
- ```bash
77
- node scaffold/generate.mjs --ide copilot
78
- node scaffold/generate.mjs --ide claude-code
79
- ```
80
-
81
- ### Step 3: Verify
82
-
83
- ```bash
84
- # Syntax check the source file you edited
85
- node -e "import('./scaffold/definitions/bodies.mjs')"
86
- node -e "import('./scaffold/definitions/flows.mjs')"
87
-
88
- # Verify your changes appear in generated output
89
- # (use grep/Select-String for key phrases)
90
- grep -r "your key phrase" scaffold/general/agents/
91
- ```
92
-
93
- ### Step 4: Commit Both Source AND Generated
94
-
95
- Always commit the definition source files AND the regenerated output together.
96
- The generated files are checked into git so `aikit init` can deploy them without
97
- running the generator.
98
-
99
- ## Source File Details
100
-
101
- ### bodies.mjs
102
-
103
- Contains `AGENT_BODIES` — an object mapping agent names to their body text.
104
-
105
- - Most values are **template literal strings** (`` `...` ``)
106
- - The **Orchestrator** body is a **function** `(agentTable) => string` because it
107
- dynamically includes the agent roster table
108
- - Backticks inside content must be escaped: `` \` ``
109
-
110
- ```js
111
- export const AGENT_BODIES = {
112
- Orchestrator: (agentTable) => `# Orchestrator\n${agentTable}\n...`,
113
- Implementer: `# Implementer\n...`,
114
- Debugger: `# Debugger\n...`,
115
- // ...
116
- };
117
- ```
118
-
119
- ### flows.mjs
120
-
121
- Contains `FLOWS` — flow step instruction content for all builtin flows.
122
-
123
- - Keys are flow names: `'aikit-advanced'`, `'aikit-basic'`, `'_epilogue'`
124
- - Each value is an array of `{ file, content }` objects — one per step README
125
- - `file` is the relative path (e.g. `'steps/plan/README.md'`)
126
- - `content` is the markdown string (escape backticks as `` \` ``)
127
-
128
- ```js
129
- export const FLOWS = {
130
- 'aikit-advanced': [
131
- { file: 'steps/plan/README.md', content: `# Planning\n...` },
132
- ...
133
- ],
134
- };
135
- ```
136
-
137
- ### skills.mjs
138
-
139
- Contains `SKILLS` — content for all builtin skills.
140
-
141
- - Keys are skill names: `'aikit'`, `'brainstorming'`, `'typescript'`, etc.
142
- - Each value is an array of `{ file, content }` objects — SKILL.md + reference files
143
- - Edit content inline; no markdown files to maintain separately
144
-
145
- ### protocols.mjs
146
-
147
- Contains `PROTOCOLS` and `TEMPLATES` — objects mapping names to markdown content.
148
-
149
- - Each `PROTOCOLS` key becomes a file in `_shared/`:
150
- - `'code-agent-base'` → `agents/_shared/code-agent-base.md`
151
- - `'researcher-base'` → `agents/_shared/researcher-base.md`
152
- - `'decision-protocol'` → `agents/_shared/decision-protocol.md`
153
- - etc.
154
- - Each `TEMPLATES` key becomes a file in `templates/`
155
- - All values are template literals — escape backticks as `` \` ``
156
-
157
- **Protocol → Agent mapping:**
158
-
159
- | Protocol | Used by |
160
- |----------|---------|
161
- | `code-agent-base` | Implementer, Frontend, Refactor, Debugger |
162
- | `researcher-base` | Researcher-Alpha/Beta/Gamma/Delta |
163
- | `code-reviewer-base` | Code-Reviewer-Alpha/Beta |
164
- | `architect-reviewer-base` | Architect-Reviewer-Alpha/Beta |
165
- | `decision-protocol` | Referenced by Orchestrator workflow |
166
- | `forge-protocol` | Referenced by code-agent-base |
167
-
168
- ### agents.mjs
169
-
170
- Defines every agent's metadata:
171
- - `description`, `argumentHint` — displayed in the agent picker
172
- - `model` — which LLM model to use
173
- - `tools` — abstract capability list (mapped to IDE-specific tools by the adapter)
174
- - `category` — orchestration, implementation, diagnostics, research, review, etc.
175
- - `sharedBase` — for variant agents (e.g., Researcher-Alpha uses `researcher-base`)
176
-
177
- ## How Users Receive Changes
178
-
179
- When users run `aikit init`, the scaffold files are deployed to their `.github/` directory.
180
-
181
- ### First Install (Legacy Path)
182
-
183
- `copyDirectoryRecursive()` — copies all scaffold files, **skips existing** files.
184
- No tracking, no merging.
185
-
186
- ### Updates (Smart Path)
187
-
188
- `smartCopyScaffold()` — manifest-based with `.aikit-scaffold.json`:
189
-
190
- | File Status | Strategy | Behavior |
191
- |-------------|----------|----------|
192
- | `new` (not in manifest, not on disk) | deploy | Copy file, record hash |
193
- | `new` (not in manifest, exists on disk) | record | Record hash only (preserve user edits) |
194
- | `outdated` (source hash changed) | `merge-frontmatter` | **Agent files**: update body, union tools, keep user's model choice |
195
- | `outdated` (source hash changed) | `overwrite` | **Protocol/shared files**: replace entirely |
196
- | `current` (unchanged) | skip | No action |
197
-
198
- The update strategy is determined by `getUpdateStrategy(relPath)` based on the file path.
199
-
200
- **Key implication**: When you update an agent body in `bodies.mjs`, existing users will
201
- get the updated body text while preserving their custom model choice and any extra tools
202
- they added. Protocol files (`_shared/*.md`) are fully replaced.
203
-
204
- ## Common Mistakes
205
-
206
- | Mistake | Why it's wrong | What to do instead |
207
- |---------|---------------|-------------------|
208
- | Editing deployed files directly (e.g. `~/.copilot/skills/`, `~/.github/agents/`) | These are **deploy targets**, not source. Changes will be overwritten on next `aikit init` or `generate.mjs` run | Always edit in `scaffold/definitions/` -> run `generate.mjs` -> then `aikit init` to deploy |
209
- | Editing `.agent.md` in `general/agents/` | Will be overwritten by `generate.mjs` | Edit `bodies.mjs` for agent bodies |
210
- | Editing `_shared/*.md` in `general/agents/` | Will be overwritten by `generate.mjs` | Edit `protocols.mjs` PROTOCOLS constant |
211
- | Editing flow step content in `_preview/flows/` | Will be overwritten by `generate.mjs` | Edit `definitions/flows.mjs` |
212
- | Editing skill content in `_preview/skills/` | Will be overwritten by `generate.mjs` | Edit `definitions/skills.mjs` |
213
- | Forgetting to run `generate.mjs` | Generated files will be stale, `aikit init` deploys stale files | Always run after editing definitions |
214
- | Committing only source OR only generated | Source and output will be out of sync | Commit both together |
215
- | Unescaped backticks in template literals | JS syntax error in definitions | Use `` \` `` inside template literal strings |
216
-
217
- ## PR Checklist
218
-
219
- - [ ] Changes made in `scaffold/definitions/*.mjs` (NOT in generated output)
220
- - [ ] `node scaffold/generate.mjs` runs without errors
221
- - [ ] Generated output contains expected changes (verified with grep)
222
- - [ ] Both source and generated files included in commit
223
- - [ ] If adding a new agent: entry in `agents.mjs` + body in `bodies.mjs`
224
- - [ ] If adding a new protocol: entry in `protocols.mjs` + reference in relevant agent bodies
225
- - [ ] If adding/updating a flow step: edit `definitions/flows.mjs` → correct `FLOWS` entry
226
- - [ ] If adding/updating a skill: edit `definitions/skills.mjs` → correct `SKILLS` entry
227
- - [ ] If adding a new file type: check `getUpdateStrategy()` returns correct merge strategy
228
- - [ ] Consider impact on existing user installations (will merge preserve their customizations?)