/** * Core layer type system * Minimal types needed for FileTypeLayerModule */ import type { LensReadinessExtended } from '../helpers/QualityMetricsCalculator'; export type { LensReadiness, LensRequirement, LensRequirements, RequirementCheckResult } from '@principal-ai/codebase-quality-lenses'; export type LensOperation = 'check' | 'coverage' | 'fix' | 'watch'; export interface QualityMetrics { tests: number; deadCode: number; linting: number; formatting: number; types: number; documentation: number; } export interface FilePattern { type: 'glob' | 'regex' | 'exact'; pattern: string; description?: string; } export interface FileSet { id: string; name: string; description?: string; patterns: FilePattern[]; matchedFiles?: string[]; fileCount?: number; } export interface BaseLayer { id: string; name: string; type: string; enabled: boolean; workspaceId?: string; workspaceRoot?: string; derivedFrom: { fileSets: FileSet[]; derivationType: 'presence' | 'content' | 'aggregation' | 'relationship' | 'content+pattern' | 'content+presence'; description: string; contentExtraction?: { method: 'parse' | 'grep' | 'ast' | 'custom'; parser?: { format: 'json' | 'yaml' | 'toml' | 'xml'; paths?: string[]; schema?: unknown; }; patterns?: { regex: string; captureGroups?: string[]; multiline?: boolean; }[]; ast?: { language: string; nodeTypes?: string[]; visitor?: string; }; }; }; dependsOn?: string[]; enhances?: string; color?: string; icon?: string; pillar?: 'validation' | 'dataFlow' | 'foundationHealth' | 'viewLayers'; } export interface PackageCommand { name: string; command: string; description?: string; type?: 'script' | 'standard'; workingDirectory?: string; isLensCommand?: boolean; lensId?: string; lensOperation?: LensOperation; } export interface ConfigFile { path: string; exists: boolean; type: 'json' | 'yaml' | 'toml' | 'js' | 'ts' | 'ini' | 'custom'; isInline?: boolean; inlineField?: string; isInherited?: boolean; inheritedFrom?: string; inheritanceType?: 'root' | 'parent' | 'explicit'; } /** * Environment variable definition in env.json */ export interface EnvVarDefinition { description: string; required?: boolean; secret?: boolean; default?: string | null; } /** * env.json file structure for documenting environment variables */ export interface EnvJsonConfig { variables: Record; } export type MonorepoOrchestrator = 'turbo' | 'nx' | 'lerna' | 'pnpm' | 'rush' | 'none'; /** * Role of the root package in a monorepo * - 'orchestrator': Root only contains configs and scripts, no application code * - 'application': Root is itself an application/library with source code * - 'hybrid': Root has some code (e.g., e2e tests, scripts) but main code is in packages */ export type MonorepoRootRole = 'orchestrator' | 'application' | 'hybrid'; export interface MonorepoMetadata { orchestrator: MonorepoOrchestrator; orchestratorConfigPath?: string; workspacePatterns?: string[]; definedTasks?: { name: string; tool?: string; filter?: string; }[]; rootConfigs?: { tool: string; configPath: string; isInline?: boolean; }[]; rootRole?: MonorepoRootRole; rootHasSourceCode?: boolean; rootSourceDirs?: string[]; } export interface FileSystemFilterLayer extends BaseLayer { type: 'filter'; filterData: { purpose: 'performance' | 'security' | 'relevance'; scope: 'directory' | 'workspace'; sourceDirectory: string; excludedPatterns: FilePattern[]; stats?: { totalFiltered: number; bytesExcluded: number; largestExcluded?: string; }; }; } export interface PackageLayer extends BaseLayer { type: 'package' | 'node' | 'python' | 'cargo' | 'go'; packageData: { name: string; version?: string; /** * Package URL (purl) identity derived from `type` + `name`, e.g. * `pkg:npm/@scope/pkg`. Stamped during discovery; absent only when the * package name is empty. See helpers/purl.ts. */ purl?: string; path: string; manifestPath: string; packageManager: 'npm' | 'yarn' | 'pnpm' | 'bun' | 'pip' | 'poetry' | 'pipenv' | 'cargo' | 'unknown'; dependencies: Record; devDependencies: Record; peerDependencies: Record; description?: string; license?: string; isPrivate?: boolean; author?: string; authors?: string[]; repository?: string; homepage?: string; keywords?: string[]; isMonorepoRoot: boolean; isWorkspace: boolean; parentPackage?: string; availableCommands?: PackageCommand[]; monorepoMetadata?: MonorepoMetadata; }; lockFiles?: FileSet; configFiles?: { knip?: ConfigFile; eslint?: ConfigFile; prettier?: ConfigFile; typescript?: ConfigFile; jest?: ConfigFile; vitest?: ConfigFile; webpack?: ConfigFile; vite?: ConfigFile; rollup?: ConfigFile; babel?: ConfigFile; pytest?: ConfigFile; flake8?: ConfigFile; mypy?: ConfigFile; black?: ConfigFile; ruff?: ConfigFile; pylint?: ConfigFile; rustfmt?: ConfigFile; clippy?: ConfigFile; dockerfile?: ConfigFile; gitignore?: ConfigFile; editorconfig?: ConfigFile; envExample?: ConfigFile; envJson?: ConfigFile; envSchema?: ConfigFile; envSample?: ConfigFile; envExpo?: ConfigFile; [key: string]: ConfigFile | undefined; }; docsFolder?: string; qualityMetrics?: { hexagon: Partial; availableLenses: string[]; missingLenses?: string[]; lensReadiness?: Record; }; } export interface DependencyLayer extends BaseLayer { type: 'dependency'; dependencyData: { name: string; version: string; isDev: boolean; isPeer: boolean; declaredIn: string[]; sourceFile: FileSet; }; } export interface FrameworkLayer extends BaseLayer { type: 'framework'; frameworkData: { name: string; category: 'ui' | 'backend' | 'testing' | 'build' | 'styling' | 'documentation'; usedBy: string[]; }; } export interface ExtractedType { name: string; kind: 'interface' | 'type' | 'class' | 'enum' | 'function'; text: string; fileName: string; isExported: boolean; jsDoc?: string; } export interface PackageTypes { packagePath: string; packageName: string; types: ExtractedType[]; exports: { named: string[]; default?: string; }; } export interface TypeExtractionOptions { includeTests?: boolean; includeInternal?: boolean; } export interface TypeExtractor { name: string; canHandle(packagePath: string, fileExtensions: string[]): boolean; extractTypes(packagePath: string, options?: TypeExtractionOptions): Promise; generateDefinitionFile?(packageTypes: PackageTypes): Promise; } export interface TypeDefinitionLayer extends BaseLayer { type: 'type-definitions'; typeData: { sourcePackageId: string; extractedTypes: ExtractedType[]; exports: { named: string[]; default?: string; }; hasTypeScript: boolean; definitionFile?: string; extractionOptions?: { includeTests: boolean; includeInternal: boolean; }; }; } export interface ImplementationFileLayer extends BaseLayer { type: 'implementation-files'; implementationData: { sourcePackageId: string; packagePath: string; packageName: string; implementationFiles: string[]; fileCount: number; filesByExtension?: Record; }; } //# sourceMappingURL=layer-types.d.ts.map