@stacksjs/ai 0.74.27 → 0.74.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context.d.ts +1 -1
- package/dist/context.js +1 -1
- package/package.json +4 -4
package/dist/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare function representativeFiles(files: string[], maxFiles: number): string[];
|
|
2
2
|
export declare function buildProjectContext(repoPath: string, options?: ProjectContextOptions): ProjectContextResult;
|
|
3
|
-
export declare const STACKS_PROJECT_CONTEXT_SCHEMA: 'https://stacksjs.
|
|
3
|
+
export declare const STACKS_PROJECT_CONTEXT_SCHEMA: 'https://stacksjs.com/schemas/ai-project-context/v1';
|
|
4
4
|
export declare interface ProjectContextOptions {
|
|
5
5
|
maxChars?: number
|
|
6
6
|
maxFiles?: number
|
package/dist/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync,lstatSync,readFileSync,readdirSync}from"node:fs";import{basename,relative,resolve,sep}from"node:path";import{estimateTokens}from"./utils/tokens";export const STACKS_PROJECT_CONTEXT_SCHEMA="https://stacksjs.
|
|
1
|
+
import{existsSync,lstatSync,readFileSync,readdirSync}from"node:fs";import{basename,relative,resolve,sep}from"node:path";import{estimateTokens}from"./utils/tokens";export const STACKS_PROJECT_CONTEXT_SCHEMA="https://stacksjs.com/schemas/ai-project-context/v1";const DEFAULT_MAX_CHARS=4000,DEFAULT_MAX_FILES=30,excludedSegments=new Set([".git",".bun",".cache",".next",".output",".turbo",".vite","build","coverage","dist","node_modules","tmp","vendor"]),sensitiveNames=/^(?:\.env(?:\..*)?|\.npmrc|\.pypirc|credentials(?:\..*)?|id_(?:rsa|ed25519)(?:\.pub)?|secrets?(?:\..*)?)$/i,lockNames=/(?:^|\.)(?:bun|package-lock|pnpm-lock|yarn|pantry)\.?(?:lock|yaml)?$/i,surfaceDefinitions=[{id:"models",purpose:"Domain schema, validation, relationships, factories, and traits.",prefixes:["app/Models/","storage/framework/defaults/app/Models/"]},{id:"actions",purpose:"Transport-independent application behavior.",prefixes:["app/Actions/","storage/framework/defaults/app/Actions/"]},{id:"routes",purpose:"HTTP and API route registration.",prefixes:["routes/","app/Routes.ts"]},{id:"jobs",purpose:"Background and inline work.",prefixes:["app/Jobs/","storage/framework/defaults/app/Jobs/"]},{id:"configuration",purpose:"Typed application and provider configuration.",prefixes:["config/"]},{id:"views",purpose:"STX views, layouts, components, and client functions.",prefixes:["resources/"]},{id:"database",purpose:"Reviewable migrations and seed data.",prefixes:["database/"]},{id:"tests",purpose:"Unit, feature, contract, and end-to-end evidence.",prefixes:["tests/","storage/framework/core/"]}];function normalizePath(path){return path.split(sep).join("/")}function isExcluded(path){const segments=path.split("/"),name=basename(path);return segments.some((segment)=>excludedSegments.has(segment))||sensitiveNames.test(name)||lockNames.test(name)||name.endsWith(".lock")}function collectFiles(root){const files=[];function visit(directory){const entries=readdirSync(directory,{withFileTypes:!0}).sort((a,b)=>a.name.localeCompare(b.name));for(const entry of entries){const fullPath=resolve(directory,entry.name),projectPath=normalizePath(relative(root,fullPath));if(isExcluded(projectPath))continue;if(entry.isDirectory())visit(fullPath);else if(entry.isFile()&&!lstatSync(fullPath).isSymbolicLink())files.push(projectPath)}}visit(root);return files.sort((a,b)=>a.localeCompare(b))}function readPackageSummary(root){const packagePath=resolve(root,"package.json");if(!existsSync(packagePath))return{name:null,version:null,scripts:[],dependencies:[]};try{const manifest=JSON.parse(readFileSync(packagePath,"utf8")),dependencies=[...Object.keys(manifest.dependencies||{}),...Object.keys(manifest.devDependencies||{}),...Object.keys(manifest.peerDependencies||{})];return{name:typeof manifest.name==="string"?manifest.name:null,version:typeof manifest.version==="string"?manifest.version:null,scripts:Object.keys(manifest.scripts||{}).sort().slice(0,25),dependencies:[...new Set(dependencies)].sort().slice(0,30)}}catch{return{name:null,version:null,scripts:[],dependencies:[]}}}function filePriority(path){if(/^(?:AGENTS|CLAUDE)\.md$|^\.github\/copilot-instructions\.md$/.test(path))return 0;if(path==="package.json"||path==="app/Routes.ts"||path==="app/Commands.ts")return 1;if(/^(?:app|routes|config)\//.test(path))return 2;if(/^(?:resources|database|tests)\//.test(path))return 3;if(/^docs\//.test(path))return 4;if(/^storage\/framework\/defaults\//.test(path))return 5;return 6}function representativeFiles(files,maxFiles){return[...files].sort((a,b)=>filePriority(a)-filePriority(b)||a.localeCompare(b)).slice(0,maxFiles).sort((a,b)=>a.localeCompare(b))}function surfacePaths(files,prefixes){return files.filter((file)=>prefixes.some((prefix)=>prefix.endsWith("/")?file.startsWith(prefix):file===prefix)).slice(0,4)}function renderContext(context){return["Stacks AI Project Context v1","",`Project: ${context.project.name||"unnamed"}${context.project.version?`@${context.project.version}`:""}`,"Architecture: Model-View-Action",`Override rule: ${context.architecture.overrideRule}`,`Authoring order: ${context.architecture.authoringOrder.join(" -> ")}`,"","Authoring principles:",...context.architecture.principles.map((principle)=>`- ${principle}`),"","Instruction files:",...context.instructionFiles.length?context.instructionFiles.map((file)=>`- ${file}`):["- none detected"],"","Available surfaces:",...context.surfaces.flatMap((surface)=>[`- ${surface.id}: ${surface.purpose}`,...surface.paths.map((path)=>` - ${path}`)]),"",`Scripts: ${context.project.scripts.join(", ")||"none detected"}`,`Dependencies: ${context.project.dependencies.join(", ")||"none detected"}`,"","Representative files:",...context.representativeFiles.map((file)=>`- ${file}`)].join(`
|
|
2
2
|
`)}function fitToBudget(text,maxChars){if(text.length<=maxChars)return{text,truncated:!1};const marker=`
|
|
3
3
|
[context truncated by character budget]`;if(maxChars<=marker.length)return{text:marker.slice(0,maxChars),truncated:!0};const available=maxChars-marker.length,prefix=text.slice(0,available),lastLine=prefix.lastIndexOf(`
|
|
4
4
|
`);return{text:`${prefix.slice(0,lastLine>0?lastLine:available)}${marker}`,truncated:!0}}function unstructuredBaseline(root,files){const readmePath=resolve(root,"README.md"),packagePath=resolve(root,"package.json"),readme=existsSync(readmePath)?readFileSync(readmePath,"utf8").slice(0,2000):"",packageJson=existsSync(packagePath)?readFileSync(packagePath,"utf8"):"";return["Repository Structure:",files.slice(0,50).join(`
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/ai",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.28",
|
|
6
6
|
"description": "Stacks Artificial Intelligence.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"prepublishOnly": "bun run build"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@stacksjs/cli": "0.74.
|
|
69
|
-
"@stacksjs/config": "0.74.
|
|
70
|
-
"@stacksjs/ts-cloud": "^0.12.
|
|
68
|
+
"@stacksjs/cli": "0.74.28",
|
|
69
|
+
"@stacksjs/config": "0.74.28",
|
|
70
|
+
"@stacksjs/ts-cloud": "^0.12.15"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@anthropic-ai/claude-agent-sdk": "^0.2.79"
|