@wearesage/schema
Version:
A flexible schema definition and validation system for TypeScript with multi-database support
131 lines (118 loc) • 3.45 kB
text/typescript
/**
* Codebase Spaces Types
* Defines semantic labeling system for codebase directories
*/
/**
* Semantic labels that can be applied to codebase spaces
* These determine what affordances are available in each space
*/
export type SemanticLabel =
| 'component-library' // React/Vue components, UI elements
| 'api-layer' // Services, routes, middleware, API logic
| 'state-management' // Stores, reducers, context, state logic
| 'test-suite' // Unit tests, integration tests, e2e tests
| 'documentation' // README, guides, docs, comments
| 'configuration' // Config files, env vars, build scripts
| 'assets' // Images, fonts, static files, media
| 'utility-functions' // Helper functions, shared utilities
| 'data-models' // Types, schemas, database models
| 'styling' // CSS, SCSS, styled-components
| 'routing' // Route definitions, navigation logic
| 'build-system' // Webpack, Vite, build tools
| 'package-management' // package.json, lock files, dependencies
| 'source-code' // General source code (fallback)
| 'unknown'; // Unclassified directory
/**
* Framework detection for context-aware affordances
*/
export type FrameworkType =
| 'react'
| 'vue'
| 'angular'
| 'svelte'
| 'nodejs'
| 'express'
| 'nextjs'
| 'nuxt'
| 'vanilla'
| 'unknown';
/**
* Language detection for syntax-aware actions
*/
export type LanguageType =
| 'typescript'
| 'javascript'
| 'tsx'
| 'jsx'
| 'python'
| 'rust'
| 'go'
| 'unknown';
/**
* Extended metadata structure for codebase spaces
*/
export interface CodebaseSpaceMetadata {
// Semantic classification
semanticLabels: SemanticLabel[];
primaryLabel?: SemanticLabel;
// Framework and language context
framework?: FrameworkType;
language?: LanguageType;
// Filesystem information
absolutePath: string;
relativePath: string;
directoryDepth: number;
// Content analysis
fileCount: number;
primaryFileExtensions: string[];
hasTests: boolean;
hasDocumentation: boolean;
// Dependency information
hasPackageJson: boolean;
dependencies?: string[];
devDependencies?: string[];
// Build/tooling detection
buildTools: string[];
linters: string[];
testFrameworks: string[];
// Auto-detection metadata
detectionConfidence: number; // 0-1 score
detectionRules: string[]; // Which rules fired
lastAnalyzed: string; // ISO timestamp
// User overrides
userLabels?: SemanticLabel[]; // User-assigned labels
excludeFromAnalysis?: boolean; // Skip auto-detection
customAffordances?: string[]; // User-defined actions
}
/**
* Codebase ingestion result
*/
export interface CodebaseIngestion {
rootSpaceId: string;
totalSpaces: number;
detectedSpaces: {
spaceId: string;
path: string;
labels: SemanticLabel[];
confidence: number;
}[];
framework: FrameworkType;
language: LanguageType;
buildTools: string[];
ingestionTime: Date;
errors: string[];
}
/**
* Directory analysis result for semantic detection
*/
export interface DirectoryAnalysis {
path: string;
files: string[];
subdirectories: string[];
semanticLabels: SemanticLabel[];
confidence: number;
detectionRules: string[];
framework?: FrameworkType;
language?: LanguageType;
metadata: Partial<CodebaseSpaceMetadata>;
}