@stacksjs/buddy 0.75.18 → 0.75.20

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.
@@ -94,7 +94,7 @@ export declare function copyFeatureFiles(feature: FeatureName, options?: CopyFea
94
94
  * features in the freshly-cloned project path before the user has cd'd
95
95
  * into it.
96
96
  */
97
- export declare function setFeatureEnabled(feature: FeatureName, enabled: boolean, options: { createIfMissing: boolean, root?: string }): Promise<SetFeatureEnabledOutcome>;
97
+ export declare function setFeatureEnabled(feature: FeatureName, enabled: boolean, options: { createIfMissing: boolean, root?: string, dryRun?: boolean }): Promise<SetFeatureEnabledOutcome>;
98
98
  /**
99
99
  * Disable every feature in `FEATURE_NAMES` at once — flips
100
100
  * `config/<feature>.ts` enabled flags to `false` and removes the
@@ -115,11 +115,13 @@ export declare function features(buddy: CLI): void;
115
115
  export declare interface DeleteFeatureFilesOptions {
116
116
  force?: boolean
117
117
  source?: string
118
+ dryRun?: boolean
118
119
  }
119
120
  export declare interface CopyFeatureFilesOptions {
120
121
  force?: boolean
121
122
  source?: string
122
123
  target?: string
124
+ dryRun?: boolean
123
125
  }
124
126
  export declare interface UninstallAllFeaturesResult {
125
127
  feature: FeatureName
@@ -1,4 +1,4 @@
1
- import{existsSync,readdirSync,readFileSync,rmdirSync,statSync}from"node:fs";import{cp,rm}from"node:fs/promises";import{join}from"node:path";import process from"node:process";import{frameworkPath,projectPath}from"@stacksjs/path";import{ExitCode}from"@stacksjs/types";export{appModelClaimsTable,FEATURE_FILES,FEATURE_NAMES,FEATURE_TABLES,migrationFeature,migrationTable}from"@stacksjs/features";import{FEATURE_FILES,FEATURE_NAMES}from"@stacksjs/features";export function featurePathsPresent(feature,root=projectPath()){return FEATURE_FILES[feature].filter((rel)=>existsSync(`${root}/${rel}`))}function filesUnder(dir,prefix=""){const out=[];for(const entry of readdirSync(dir,{withFileTypes:!0})){const rel=prefix?`${prefix}/${entry.name}`:entry.name;if(entry.isDirectory())out.push(...filesUnder(join(dir,entry.name),rel));else out.push(rel)}return out}function matchesTemplate(projectFile,templateFile){if(!existsSync(templateFile))return!1;try{return readFileSync(projectFile).equals(readFileSync(templateFile))}catch{return!1}}function pruneEmptyDirs(root,dir){let current=dir;while(current.startsWith(root)&&current!==root){try{if(readdirSync(current).length>0)return;rmdirSync(current)}catch{return}current=join(current,"..")}}export async function deleteFeatureFiles(feature,root=projectPath(),options={}){const source=options.source??frameworkPath("defaults"),force=options.force===!0,removed=[],preserved=[];for(const rel of FEATURE_FILES[feature]){const full=join(root,rel);if(!existsSync(full))continue;if(force){await rm(full,{recursive:!0,force:!0});removed.push(rel);continue}const template=join(source,rel);if(!statSync(full).isDirectory()){if(matchesTemplate(full,template)){await rm(full,{force:!0});removed.push(rel)}else preserved.push(rel);continue}let keptAny=!1;for(const child of filesUnder(full)){const projectFile=join(full,child);if(matchesTemplate(projectFile,join(template,child))){await rm(projectFile,{force:!0});removed.push(`${rel}${child}`)}else{keptAny=!0;preserved.push(`${rel}${child}`)}}pruneEmptyDirs(root,full);if(!keptAny&&existsSync(full))await rm(full,{recursive:!0,force:!0})}return{removed,preserved}}export async function copyFeatureFiles(feature,options={}){const source=options.source??frameworkPath("defaults"),target=options.target??projectPath(),force=options.force===!0,copied=[],skipped=[];for(const rel of FEATURE_FILES[feature]){const sourceFull=join(source,rel);if(!existsSync(sourceFull)){skipped.push(rel);continue}const targetFull=join(target,rel);if(existsSync(targetFull)&&!force){skipped.push(rel);continue}await cp(sourceFull,targetFull,{recursive:!0,force});copied.push(rel)}return{copied,skipped}}const FEATURE_DESCRIPTIONS={dashboard:"Admin SPA shell + Activity/Log/Request/Deployment/Notification dashboards.",commerce:"Order/Cart/Product/Customer/Coupon/GiftCard/Shipping + storefront API.",cms:"Post/Page/Author/Comment/Tag models + content edit dashboards.",forms:"User-defined forms: builder models, conditional fields, public submit + CSV export.",marketing:"/api/email/subscribe, /api/contact, Campaign/EmailList/SocialPost.",monitoring:"Error model + error-tracking views and actions.",realtime:"WebSocket broadcaster + Websocket model + realtime-stats actions.",queue:"Job + FailedJob models + queue dashboard pages."},STARTER_TEMPLATES={dashboard:`import type { DashboardConfig } from '@stacksjs/types'
1
+ import{existsSync,readdirSync,readFileSync,rmdirSync,statSync}from"node:fs";import{cp,rm}from"node:fs/promises";import{join}from"node:path";import process from"node:process";import{frameworkPath,projectPath}from"@stacksjs/path";import{ExitCode}from"@stacksjs/types";export{appModelClaimsTable,FEATURE_FILES,FEATURE_NAMES,FEATURE_TABLES,migrationFeature,migrationTable}from"@stacksjs/features";import{FEATURE_FILES,FEATURE_NAMES}from"@stacksjs/features";export function featurePathsPresent(feature,root=projectPath()){return FEATURE_FILES[feature].filter((rel)=>existsSync(`${root}/${rel}`))}function filesUnder(dir,prefix=""){const out=[];for(const entry of readdirSync(dir,{withFileTypes:!0})){const rel=prefix?`${prefix}/${entry.name}`:entry.name;if(entry.isDirectory())out.push(...filesUnder(join(dir,entry.name),rel));else out.push(rel)}return out}function matchesTemplate(projectFile,templateFile){if(!existsSync(templateFile))return!1;try{return readFileSync(projectFile).equals(readFileSync(templateFile))}catch{return!1}}function pruneEmptyDirs(root,dir){let current=dir;while(current.startsWith(root)&&current!==root){try{if(readdirSync(current).length>0)return;rmdirSync(current)}catch{return}current=join(current,"..")}}export async function deleteFeatureFiles(feature,root=projectPath(),options={}){const source=options.source??frameworkPath("defaults"),force=options.force===!0,dryRun=options.dryRun===!0,remove=async(path,recursive=!1)=>{if(!dryRun)await rm(path,{recursive,force:!0})},removed=[],preserved=[];for(const rel of FEATURE_FILES[feature]){const full=join(root,rel);if(!existsSync(full))continue;if(force){await remove(full,!0);removed.push(rel);continue}const template=join(source,rel);if(!statSync(full).isDirectory()){if(matchesTemplate(full,template)){await remove(full);removed.push(rel)}else preserved.push(rel);continue}let keptAny=!1;for(const child of filesUnder(full)){const projectFile=join(full,child);if(matchesTemplate(projectFile,join(template,child))){await remove(projectFile);removed.push(`${rel}${child}`)}else{keptAny=!0;preserved.push(`${rel}${child}`)}}if(dryRun)continue;pruneEmptyDirs(root,full);if(!keptAny&&existsSync(full))await rm(full,{recursive:!0,force:!0})}return{removed,preserved}}export async function copyFeatureFiles(feature,options={}){const source=options.source??frameworkPath("defaults"),target=options.target??projectPath(),force=options.force===!0,copied=[],skipped=[];for(const rel of FEATURE_FILES[feature]){const sourceFull=join(source,rel);if(!existsSync(sourceFull)){skipped.push(rel);continue}const targetFull=join(target,rel);if(existsSync(targetFull)&&!force){skipped.push(rel);continue}if(options.dryRun!==!0)await cp(sourceFull,targetFull,{recursive:!0,force});copied.push(rel)}return{copied,skipped}}const FEATURE_DESCRIPTIONS={dashboard:"Admin SPA shell + Activity/Log/Request/Deployment/Notification dashboards.",commerce:"Order/Cart/Product/Customer/Coupon/GiftCard/Shipping + storefront API.",cms:"Post/Page/Author/Comment/Tag models + content edit dashboards.",forms:"User-defined forms: builder models, conditional fields, public submit + CSV export.",marketing:"/api/email/subscribe, /api/contact, Campaign/EmailList/SocialPost.",monitoring:"Error model + error-tracking views and actions.",realtime:"WebSocket broadcaster + Websocket model + realtime-stats actions.",queue:"Job + FailedJob models + queue dashboard pages."},STARTER_TEMPLATES={dashboard:`import type { DashboardConfig } from '@stacksjs/types'
2
2
 
3
3
  /**
4
4
  * **Dashboard Configuration**
@@ -126,5 +126,5 @@ export default {
126
126
  table: 'failed_jobs',
127
127
  },
128
128
  } satisfies QueueConfig
129
- `};export async function setFeatureEnabled(feature,enabled,options){const path=options.root?join(options.root,`config/${feature}.ts`):projectPath(`config/${feature}.ts`),file=Bun.file(path);if(!await file.exists()){if(!options.createIfMissing)return"missing";await Bun.write(path,STARTER_TEMPLATES[feature]);return"created"}const src=await file.text(),enabledRegex=/(^|\{)(\s*)enabled\s*:\s*(true|false)(\s*,?)/m;if(enabledRegex.test(src)){const replaced=src.replace(enabledRegex,(_full,anchor,ws,current,trailing)=>{if(current===String(enabled))return`${anchor}${ws}enabled: ${current}${trailing}`;return`${anchor}${ws}enabled: ${enabled}${trailing}`});if(replaced===src)return"unchanged";await Bun.write(path,replaced);return"flipped"}const insertRegex=/(export default\s*\{)/;if(!insertRegex.test(src))throw Error(`Could not locate \`export default {\` in ${path} - please add \`enabled: ${enabled}\` manually.`);const next=src.replace(insertRegex,`$1
130
- enabled: ${enabled},`);await Bun.write(path,next);return"flipped"}export async function uninstallAllFeatures(options={}){const root=options.root??projectPath(),results=[];for(const feature of FEATURE_NAMES){const configOutcome=await setFeatureEnabled(feature,!1,{createIfMissing:!1,root}),{removed:filesRemoved}=await deleteFeatureFiles(feature,root,{force:!0});results.push({feature,configOutcome,filesRemoved})}return results}function registerInstallPair(buddy,feature){const desc=FEATURE_DESCRIPTIONS[feature],configRel=`config/${feature}.ts`;buddy.command(`${feature}:install`,`Activate the ${feature} feature bundle. ${desc}`).option("--force",`Overwrite any existing ${feature} files in the project (default skips existing paths so the install is idempotent).`).action(async(options)=>{try{switch(await setFeatureEnabled(feature,!0,{createIfMissing:!0})){case"created":console.log(`\u2713 Created ${configRel} with '${feature}' enabled.`);break;case"flipped":console.log(`\u2713 Enabled '${feature}' in ${configRel}.`);break;case"unchanged":console.log(`\u2713 '${feature}' is already enabled in ${configRel}.`);break}const{copied}=await copyFeatureFiles(feature,{force:options.force===!0});if(copied.length>0){console.log(`\u2713 Copied ${copied.length} stamped path(s) from framework defaults:`);for(const path of copied)console.log(` - ${path}`)}else if(featurePathsPresent(feature).length>0)console.log(` \u2192 ${feature} scaffolding already in place - use --force to overwrite.`);console.log(` \u2192 next ./buddy dev will boot with ${feature} loaded.`);process.exit(ExitCode.Success)}catch(err){console.error(`\u2717 Failed to install ${feature}:`,err);process.exit(ExitCode.FatalError)}});buddy.command(`${feature}:uninstall`,`Deactivate the ${feature} feature bundle.`).option("--keep-files",`Don't delete the ${feature} scaffolding (action/model/view files). Flip the flag only.`).option("--force",`Delete the ${feature} scaffolding even where you have edited it. Without this, changed files are kept.`).action(async(options)=>{try{switch(await setFeatureEnabled(feature,!1,{createIfMissing:!1})){case"missing":console.log(`\u2713 '${feature}' is already disabled (${configRel} is absent).`);break;case"flipped":console.log(`\u2713 Disabled '${feature}' in ${configRel}. Custom config preserved.`);break;case"unchanged":console.log(`\u2713 '${feature}' is already disabled in ${configRel}.`);break;case"created":console.log(`\u2717 Unexpected create on uninstall for ${feature}; please re-run with --force or report this bug.`);break}if(options.keepFiles){const stillPresent=featurePathsPresent(feature);if(stillPresent.length>0)console.log(` \u2192 ${stillPresent.length} stamped path(s) preserved (--keep-files).`)}else{const{removed,preserved}=await deleteFeatureFiles(feature,projectPath(),{force:options.force});if(removed.length>0){console.log(`\u2713 Removed ${removed.length} stamped path(s):`);for(const path of removed)console.log(` - ${path}`)}if(preserved.length>0){console.log(` \u2192 Kept ${preserved.length} path(s) you have edited (re-run with --force to remove):`);for(const path of preserved)console.log(` - ${path}`)}}console.log(` \u2192 next ./buddy dev will boot without ${feature}.`);process.exit(ExitCode.Success)}catch(err){console.error(`\u2717 Failed to uninstall ${feature}:`,err);process.exit(ExitCode.FatalError)}})}export function features(buddy){for(const feature of FEATURE_NAMES)registerInstallPair(buddy,feature)}
129
+ `};export async function setFeatureEnabled(feature,enabled,options){const write=async(target,contents)=>{if(options.dryRun!==!0)await Bun.write(target,contents)},path=options.root?join(options.root,`config/${feature}.ts`):projectPath(`config/${feature}.ts`),file=Bun.file(path);if(!await file.exists()){if(!options.createIfMissing)return"missing";await write(path,STARTER_TEMPLATES[feature]);return"created"}const src=await file.text(),enabledRegex=/(^|\{)(\s*)enabled\s*:\s*(true|false)(\s*,?)/m;if(enabledRegex.test(src)){const replaced=src.replace(enabledRegex,(_full,anchor,ws,current,trailing)=>{if(current===String(enabled))return`${anchor}${ws}enabled: ${current}${trailing}`;return`${anchor}${ws}enabled: ${enabled}${trailing}`});if(replaced===src)return"unchanged";await write(path,replaced);return"flipped"}const insertRegex=/(export default\s*\{)/;if(!insertRegex.test(src))throw Error(`Could not locate \`export default {\` in ${path} - please add \`enabled: ${enabled}\` manually.`);const next=src.replace(insertRegex,`$1
130
+ enabled: ${enabled},`);await write(path,next);return"flipped"}export async function uninstallAllFeatures(options={}){const root=options.root??projectPath(),results=[];for(const feature of FEATURE_NAMES){const configOutcome=await setFeatureEnabled(feature,!1,{createIfMissing:!1,root}),{removed:filesRemoved}=await deleteFeatureFiles(feature,root,{force:!0});results.push({feature,configOutcome,filesRemoved})}return results}function isDryRun(options){return options.dryRun===!0||process.argv.includes("--dry-run")}function registerInstallPair(buddy,feature){const desc=FEATURE_DESCRIPTIONS[feature],configRel=`config/${feature}.ts`;buddy.command(`${feature}:install`,`Activate the ${feature} feature bundle. ${desc}`).option("--force",`Overwrite any existing ${feature} files in the project (default skips existing paths so the install is idempotent).`).action(async(options)=>{try{const dryRun=isDryRun(options),mark=dryRun?"\xB7":"\u2713";switch(await setFeatureEnabled(feature,!0,{createIfMissing:!0,dryRun})){case"created":console.log(dryRun?`${mark} Would create ${configRel} with '${feature}' enabled.`:`${mark} Created ${configRel} with '${feature}' enabled.`);break;case"flipped":console.log(dryRun?`${mark} Would enable '${feature}' in ${configRel}.`:`${mark} Enabled '${feature}' in ${configRel}.`);break;case"unchanged":console.log(`${mark} '${feature}' is already enabled in ${configRel}.`);break}const{copied}=await copyFeatureFiles(feature,{force:options.force===!0,dryRun});if(copied.length>0){console.log(dryRun?`${mark} Would copy ${copied.length} stamped path(s) from framework defaults:`:`${mark} Copied ${copied.length} stamped path(s) from framework defaults:`);for(const path of copied)console.log(` - ${path}`)}else if(featurePathsPresent(feature).length>0)console.log(` \u2192 ${feature} scaffolding already in place - use --force to overwrite.`);console.log(dryRun?` \u2192 Dry run: nothing was written. Run it without --dry-run to install ${feature}.`:` \u2192 next ./buddy dev will boot with ${feature} loaded.`);process.exit(ExitCode.Success)}catch(err){console.error(`\u2717 Failed to install ${feature}:`,err);process.exit(ExitCode.FatalError)}});buddy.command(`${feature}:uninstall`,`Deactivate the ${feature} feature bundle.`).option("--keep-files",`Don't delete the ${feature} scaffolding (action/model/view files). Flip the flag only.`).option("--force",`Delete the ${feature} scaffolding even where you have edited it. Without this, changed files are kept.`).action(async(options)=>{try{const dryRun=isDryRun(options),mark=dryRun?"\xB7":"\u2713";switch(await setFeatureEnabled(feature,!1,{createIfMissing:!1,dryRun})){case"missing":console.log(`${mark} '${feature}' is already disabled (${configRel} is absent).`);break;case"flipped":console.log(dryRun?`${mark} Would disable '${feature}' in ${configRel}.`:`${mark} Disabled '${feature}' in ${configRel}. Custom config preserved.`);break;case"unchanged":console.log(`${mark} '${feature}' is already disabled in ${configRel}.`);break;case"created":console.log(`\u2717 Unexpected create on uninstall for ${feature}; please re-run with --force or report this bug.`);break}if(options.keepFiles){const stillPresent=featurePathsPresent(feature);if(stillPresent.length>0)console.log(` \u2192 ${stillPresent.length} stamped path(s) preserved (--keep-files).`)}else{const{removed,preserved}=await deleteFeatureFiles(feature,projectPath(),{force:options.force,dryRun});if(removed.length>0){console.log(dryRun?`${mark} Would remove ${removed.length} stamped path(s):`:`${mark} Removed ${removed.length} stamped path(s):`);for(const path of removed)console.log(` - ${path}`)}if(preserved.length>0){console.log(dryRun?` \u2192 Would keep ${preserved.length} path(s) you have edited (--force would remove them):`:` \u2192 Kept ${preserved.length} path(s) you have edited (re-run with --force to remove):`);for(const path of preserved)console.log(` - ${path}`)}}console.log(dryRun?` \u2192 Dry run: nothing was written or removed. Run it without --dry-run to uninstall ${feature}.`:` \u2192 next ./buddy dev will boot without ${feature}.`);process.exit(ExitCode.Success)}catch(err){console.error(`\u2717 Failed to uninstall ${feature}:`,err);process.exit(ExitCode.FatalError)}})}export function features(buddy){for(const feature of FEATURE_NAMES)registerInstallPair(buddy,feature)}
@@ -1,2 +1,2 @@
1
- import{cpSync,existsSync,lstatSync,mkdirSync,readdirSync,rmSync,symlinkSync,writeFileSync}from"node:fs";import process from"node:process";import{dim,green,log,yellow}from"@stacksjs/cli";import{frameworkPath,join,projectPath,relative}from"@stacksjs/path";import{listSkills,resolveSkillPath}from"@stacksjs/skills";export const AI_PROVIDERS=[{id:"claude",label:"Claude Code",reads:["AGENTS.md","CLAUDE.md",".claude/skills",".claude/launch.json"]},{id:"codex",label:"OpenAI Codex CLI",reads:["AGENTS.md"]},{id:"cursor",label:"Cursor",reads:["AGENTS.md",".cursor/rules"]},{id:"copilot",label:"GitHub Copilot",reads:["AGENTS.md",".github/copilot-instructions.md"]},{id:"gemini",label:"Gemini CLI",reads:["AGENTS.md","GEMINI.md"]}];export function isAiProvider(value){return AI_PROVIDERS.some((provider)=>provider.id===value)}export function materialize(target,path,options){const existing=lstatSync(path,{throwIfNoEntry:!1});if(existing){if(!existing.isSymbolicLink()&&!options.force)return!1;rmSync(path,{recursive:!0,force:!0})}mkdirSync(join(path,".."),{recursive:!0});if(options.copy)cpSync(target,path,{recursive:!0});else symlinkSync(relative(join(path,".."),target),path,process.platform==="win32"?"junction":"dir");return!0}function materializeFile(source,path,options){if(existsSync(path)&&!options.force)return!1;mkdirSync(join(path,".."),{recursive:!0});cpSync(source,path,{recursive:!0,force:!0});return!0}function installSkills(destination,options){const names=listSkills();let installed=0,skipped=0;mkdirSync(destination,{recursive:!0});for(const entry of readdirSync(destination)){const path=join(destination,entry);if(lstatSync(path,{throwIfNoEntry:!1})?.isSymbolicLink()&&!existsSync(path))rmSync(path,{force:!0})}for(const name of names){const source=resolveSkillPath(name);if(!source)continue;if(materialize(source,join(destination,name),options))installed++;else skipped++}return{installed,skipped}}export function setupAiProvider(provider,options={}){const created=[],skipped=[],defaults=frameworkPath("defaults/ai"),rel=(path)=>relative(projectPath(),path),record=(path,didCreate)=>{(didCreate?created:skipped).push(rel(path))},agents=projectPath("AGENTS.md");record(agents,materializeFile(join(defaults,"AGENTS.md"),agents,{...options,force:!1}));switch(provider){case"claude":{const claudeMd=projectPath("CLAUDE.md"),linked=materialize(agents,claudeMd,{...options,copy:!1,force:!1});record(claudeMd,linked);if(!linked&&existsSync(claudeMd)&&!lstatSync(claudeMd,{throwIfNoEntry:!1})?.isSymbolicLink())log.info(` \xB7 ${rel(claudeMd)} is a real file, so it is left as-is. Move its content into AGENTS.md and delete it to have both agents read one file.`);const launch=projectPath(".claude/launch.json");record(launch,materializeFile(join(defaults,"claude/launch.json"),launch,options));const skillsDir=projectPath(".claude/skills"),{installed,skipped:untouched}=installSkills(skillsDir,options);if(installed>0)created.push(`${rel(skillsDir)} (${installed} skills)`);if(untouched>0)skipped.push(`${rel(skillsDir)} (${untouched} skills)`);break}case"codex":break;case"cursor":{const rules=projectPath(".cursor/rules");record(rules,materialize(frameworkPath("defaults/ide/cursor/rules"),rules,options));break}case"copilot":{const instructions=projectPath(".github/copilot-instructions.md");if(existsSync(instructions)&&!options.force)skipped.push(rel(instructions));else{mkdirSync(projectPath(".github"),{recursive:!0});writeFileSync(instructions,pointerFile("AGENTS.md"),"utf8");created.push(rel(instructions))}break}case"gemini":{const geminiMd=projectPath("GEMINI.md");record(geminiMd,materialize(agents,geminiMd,{...options,copy:!1}));break}}return{created,skipped}}function pointerFile(target){return["# Project instructions","",`This project keeps its agent guidance in [\`${target}\`](../${target}), so every`,"agent works from the same rules. Read that file.","","Regenerate this pointer with `buddy setup:ai copilot --force`.",""].join(`
1
+ import{cpSync,existsSync,lstatSync,mkdirSync,readdirSync,rmSync,symlinkSync,writeFileSync}from"node:fs";import process from"node:process";import{dim,green,log,yellow}from"@stacksjs/cli";import{frameworkPath,join,projectPath,relative}from"@stacksjs/path";import{listSkills,resolveSkillPath}from"@stacksjs/skills";export const AI_PROVIDERS=[{id:"claude",label:"Claude Code",reads:["AGENTS.md","CLAUDE.md",".claude/skills",".claude/launch.json"]},{id:"codex",label:"OpenAI Codex CLI",reads:["AGENTS.md"]},{id:"cursor",label:"Cursor",reads:["AGENTS.md",".cursor/rules"]},{id:"copilot",label:"GitHub Copilot",reads:["AGENTS.md",".github/copilot-instructions.md"]},{id:"gemini",label:"Gemini CLI",reads:["AGENTS.md","GEMINI.md"]}];export function isAiProvider(value){return AI_PROVIDERS.some((provider)=>provider.id===value)}export function materialize(target,path,options){const existing=lstatSync(path,{throwIfNoEntry:!1});if(existing){if(!existing.isSymbolicLink()&&!options.force)return!1;rmSync(path,{recursive:!0,force:!0})}mkdirSync(join(path,".."),{recursive:!0});if(options.copy)cpSync(target,path,{recursive:!0});else symlinkSync(relative(join(path,".."),target),path,process.platform==="win32"?"junction":"dir");return!0}function materializeFile(source,path,options){if(existsSync(path)&&!options.force)return!1;mkdirSync(join(path,".."),{recursive:!0});cpSync(source,path,{recursive:!0,force:!0});return!0}function installSkills(destination,options){const names=listSkills();let installed=0,skipped=0;mkdirSync(destination,{recursive:!0});for(const entry of readdirSync(destination)){const path=join(destination,entry);if(lstatSync(path,{throwIfNoEntry:!1})?.isSymbolicLink()&&!existsSync(path))rmSync(path,{force:!0})}for(const name of names){const source=resolveSkillPath(name);if(!source)continue;if(materialize(source,join(destination,name),options))installed++;else skipped++}return{installed,skipped}}export function setupAiProvider(provider,options={}){const created=[],skipped=[],defaults=frameworkPath("defaults/ai"),rel=(path)=>relative(projectPath(),path),record=(path,didCreate)=>{(didCreate?created:skipped).push(rel(path))},agents=projectPath("AGENTS.md");record(agents,materializeFile(join(defaults,"AGENTS.md"),agents,{...options,force:!1}));switch(provider){case"claude":{const claudeMd=projectPath("CLAUDE.md"),linked=materialize(agents,claudeMd,{...options,copy:!1,force:!1});record(claudeMd,linked);if(!linked&&existsSync(claudeMd)&&!lstatSync(claudeMd,{throwIfNoEntry:!1})?.isSymbolicLink())log.info(` \xB7 ${rel(claudeMd)} is a real file, so it is left as-is. Move its content into AGENTS.md and delete it to have both agents read one file.`);const launch=projectPath(".claude/launch.json");record(launch,materializeFile(join(defaults,"claude/launch.json"),launch,{...options,force:!1}));const skillsDir=projectPath(".claude/skills"),{installed,skipped:untouched}=installSkills(skillsDir,options);if(installed>0)created.push(`${rel(skillsDir)} (${installed} skills)`);if(untouched>0)skipped.push(`${rel(skillsDir)} (${untouched} skills)`);break}case"codex":break;case"cursor":{const rules=projectPath(".cursor/rules");record(rules,materialize(frameworkPath("defaults/ide/cursor/rules"),rules,options));break}case"copilot":{const instructions=projectPath(".github/copilot-instructions.md");if(existsSync(instructions)&&!options.force)skipped.push(rel(instructions));else{mkdirSync(projectPath(".github"),{recursive:!0});writeFileSync(instructions,pointerFile("AGENTS.md"),"utf8");created.push(rel(instructions))}break}case"gemini":{const geminiMd=projectPath("GEMINI.md");record(geminiMd,materialize(agents,geminiMd,{...options,copy:!1}));break}}return{created,skipped}}function pointerFile(target){return["# Project instructions","",`This project keeps its agent guidance in [\`${target}\`](../${target}), so every`,"agent works from the same rules. Read that file.","","Regenerate this pointer with `buddy setup:ai copilot --force`.",""].join(`
2
2
  `)}export function reportAiSetup(provider,result){for(const path of result.created)log.info(` ${green("+")} ${path}`);for(const path of result.skipped)log.info(` ${yellow("\xB7")} ${path} ${dim("(already present, left alone)")}`);if(result.created.length===0)log.info(dim(" Nothing to do - re-run with --force to overwrite."));log.success(`${provider.label} is set up. It reads: ${provider.reads.join(", ")}`)}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/buddy",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.18",
5
+ "version": "0.75.20",
6
6
  "description": "Meet Buddy. The Stacks runtime.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -95,66 +95,66 @@
95
95
  "prepublishOnly": "bun run build"
96
96
  },
97
97
  "dependencies": {
98
- "@stacksjs/actions": "^0.75.18",
99
- "@stacksjs/ai": "^0.75.18",
100
- "@stacksjs/alias": "^0.75.18",
101
- "@stacksjs/analytics": "^0.75.18",
102
- "@stacksjs/api": "^0.75.18",
103
- "@stacksjs/arrays": "^0.75.18",
104
- "@stacksjs/auth": "^0.75.18",
105
- "@stacksjs/browser-extension": "^0.75.18",
106
- "@stacksjs/build": "^0.75.18",
107
- "@stacksjs/cache": "^0.75.18",
108
- "@stacksjs/chat": "^0.75.18",
98
+ "@stacksjs/actions": "^0.75.20",
99
+ "@stacksjs/ai": "^0.75.20",
100
+ "@stacksjs/alias": "^0.75.20",
101
+ "@stacksjs/analytics": "^0.75.20",
102
+ "@stacksjs/api": "^0.75.20",
103
+ "@stacksjs/arrays": "^0.75.20",
104
+ "@stacksjs/auth": "^0.75.20",
105
+ "@stacksjs/browser-extension": "^0.75.20",
106
+ "@stacksjs/build": "^0.75.20",
107
+ "@stacksjs/cache": "^0.75.20",
108
+ "@stacksjs/chat": "^0.75.20",
109
109
  "@stacksjs/clapp": "^0.2.12",
110
- "@stacksjs/cli": "^0.75.18",
111
- "@stacksjs/cloud": "^0.75.18",
112
- "@stacksjs/cms": "^0.75.18",
113
- "@stacksjs/collections": "^0.75.18",
114
- "@stacksjs/config": "^0.75.18",
115
- "@stacksjs/database": "^0.75.18",
116
- "@stacksjs/desktop-build": "^0.75.18",
117
- "@stacksjs/dns": "^0.75.18",
110
+ "@stacksjs/cli": "^0.75.20",
111
+ "@stacksjs/cloud": "^0.75.20",
112
+ "@stacksjs/cms": "^0.75.20",
113
+ "@stacksjs/collections": "^0.75.20",
114
+ "@stacksjs/config": "^0.75.20",
115
+ "@stacksjs/database": "^0.75.20",
116
+ "@stacksjs/desktop-build": "^0.75.20",
117
+ "@stacksjs/dns": "^0.75.20",
118
118
  "@stacksjs/dnsx": "^0.2.3",
119
- "@stacksjs/email": "^0.75.18",
120
- "@stacksjs/enums": "^0.75.18",
121
- "@stacksjs/env": "^0.75.18",
122
- "@stacksjs/error-handling": "^0.75.18",
123
- "@stacksjs/events": "^0.75.18",
124
- "@stacksjs/features": "^0.75.18",
125
- "@stacksjs/git": "^0.75.18",
119
+ "@stacksjs/email": "^0.75.20",
120
+ "@stacksjs/enums": "^0.75.20",
121
+ "@stacksjs/env": "^0.75.20",
122
+ "@stacksjs/error-handling": "^0.75.20",
123
+ "@stacksjs/events": "^0.75.20",
124
+ "@stacksjs/features": "^0.75.20",
125
+ "@stacksjs/git": "^0.75.20",
126
126
  "@stacksjs/gitit": "^0.2.5",
127
- "@stacksjs/health": "^0.75.18",
127
+ "@stacksjs/health": "^0.75.20",
128
128
  "@stacksjs/httx": "^0.1.10",
129
- "@stacksjs/image": "^0.75.18",
130
- "@stacksjs/lint": "^0.75.18",
131
- "@stacksjs/logging": "^0.75.18",
132
- "@stacksjs/notifications": "^0.75.18",
133
- "@stacksjs/objects": "^0.75.18",
134
- "@stacksjs/orm": "^0.75.18",
135
- "@stacksjs/path": "^0.75.18",
136
- "@stacksjs/payments": "^0.75.18",
137
- "@stacksjs/realtime": "^0.75.18",
138
- "@stacksjs/router": "^0.75.18",
129
+ "@stacksjs/image": "^0.75.20",
130
+ "@stacksjs/lint": "^0.75.20",
131
+ "@stacksjs/logging": "^0.75.20",
132
+ "@stacksjs/notifications": "^0.75.20",
133
+ "@stacksjs/objects": "^0.75.20",
134
+ "@stacksjs/orm": "^0.75.20",
135
+ "@stacksjs/path": "^0.75.20",
136
+ "@stacksjs/payments": "^0.75.20",
137
+ "@stacksjs/realtime": "^0.75.20",
138
+ "@stacksjs/router": "^0.75.20",
139
139
  "@stacksjs/rpx": "^0.11.54",
140
- "@stacksjs/scheduler": "^0.75.18",
141
- "@stacksjs/search-engine": "^0.75.18",
142
- "@stacksjs/security": "^0.75.18",
143
- "@stacksjs/server": "^0.75.18",
144
- "@stacksjs/sites": "^0.75.18",
145
- "@stacksjs/skills": "^0.75.18",
146
- "@stacksjs/storage": "^0.75.18",
147
- "@stacksjs/strings": "^0.75.18",
140
+ "@stacksjs/scheduler": "^0.75.20",
141
+ "@stacksjs/search-engine": "^0.75.20",
142
+ "@stacksjs/security": "^0.75.20",
143
+ "@stacksjs/server": "^0.75.20",
144
+ "@stacksjs/sites": "^0.75.20",
145
+ "@stacksjs/skills": "^0.75.20",
146
+ "@stacksjs/storage": "^0.75.20",
147
+ "@stacksjs/strings": "^0.75.20",
148
148
  "@stacksjs/stx": "^0.2.325",
149
- "@stacksjs/testing": "^0.75.18",
150
- "@stacksjs/tinker": "^0.75.18",
149
+ "@stacksjs/testing": "^0.75.20",
150
+ "@stacksjs/tinker": "^0.75.20",
151
151
  "@stacksjs/tlsx": "^0.13.19",
152
152
  "@stacksjs/ts-cloud": "^0.16.15",
153
- "@stacksjs/tunnel": "^0.75.18",
154
- "@stacksjs/types": "^0.75.18",
155
- "@stacksjs/ui": "^0.75.18",
156
- "@stacksjs/utils": "^0.75.18",
157
- "@stacksjs/validation": "^0.75.18",
153
+ "@stacksjs/tunnel": "^0.75.20",
154
+ "@stacksjs/types": "^0.75.20",
155
+ "@stacksjs/ui": "^0.75.20",
156
+ "@stacksjs/utils": "^0.75.20",
157
+ "@stacksjs/validation": "^0.75.20",
158
158
  "ajv": "^8.20.0",
159
159
  "ajv-formats": "^3.0.1",
160
160
  "bun-plugin-stx": "^0.2.324",