feat: add shared type definitions
This commit is contained in:
185
packages/shared/src/types.ts
Normal file
185
packages/shared/src/types.ts
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
// ── Repository Cloning ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
export interface CloneMetadata {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
defaultBranch: string;
|
||||||
|
languages: Record<string, number>;
|
||||||
|
stars: number;
|
||||||
|
lastCommit: string;
|
||||||
|
totalFiles: number;
|
||||||
|
totalLines: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CloneResult {
|
||||||
|
localPath: string;
|
||||||
|
metadata: CloneMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── AST Parsing ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export interface FunctionNode {
|
||||||
|
name: string;
|
||||||
|
params: string[];
|
||||||
|
returnType?: string;
|
||||||
|
lineStart: number;
|
||||||
|
lineEnd: number;
|
||||||
|
docstring?: string;
|
||||||
|
calls: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ClassProperty {
|
||||||
|
name: string;
|
||||||
|
type?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ClassNode {
|
||||||
|
name: string;
|
||||||
|
methods: FunctionNode[];
|
||||||
|
properties: ClassProperty[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ImportNode {
|
||||||
|
source: string;
|
||||||
|
specifiers: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ExportNode {
|
||||||
|
name: string;
|
||||||
|
isDefault: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FileNode {
|
||||||
|
path: string;
|
||||||
|
language: string;
|
||||||
|
size: number;
|
||||||
|
functions: FunctionNode[];
|
||||||
|
classes: ClassNode[];
|
||||||
|
imports: ImportNode[];
|
||||||
|
exports: ExportNode[];
|
||||||
|
complexity: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModuleNode {
|
||||||
|
name: string;
|
||||||
|
path: string;
|
||||||
|
files: string[];
|
||||||
|
summary?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DetectedPattern {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
examples: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DependencyEdge {
|
||||||
|
source: string;
|
||||||
|
target: string;
|
||||||
|
type: "import" | "call" | "extends";
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CodeStructure {
|
||||||
|
files: FileNode[];
|
||||||
|
modules: ModuleNode[];
|
||||||
|
entryPoints: string[];
|
||||||
|
exports: ExportNode[];
|
||||||
|
dependencies: DependencyEdge[];
|
||||||
|
patterns: DetectedPattern[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Generated Documentation ─────────────────────────────────────────
|
||||||
|
|
||||||
|
export interface DocsOverview {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
architectureDiagram: string;
|
||||||
|
techStack: string[];
|
||||||
|
keyMetrics: {
|
||||||
|
files: number;
|
||||||
|
modules: number;
|
||||||
|
languages: string[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DocsModule {
|
||||||
|
name: string;
|
||||||
|
path: string;
|
||||||
|
summary: string;
|
||||||
|
keyFiles: Array<{ path: string; purpose: string }>;
|
||||||
|
publicApi: string[];
|
||||||
|
dependsOn: string[];
|
||||||
|
dependedBy: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DocsPatterns {
|
||||||
|
conventions: string[];
|
||||||
|
designPatterns: string[];
|
||||||
|
architecturalDecisions: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DocsGettingStarted {
|
||||||
|
prerequisites: string[];
|
||||||
|
setupSteps: string[];
|
||||||
|
firstTask: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GeneratedDocs {
|
||||||
|
id: string;
|
||||||
|
repoUrl: string;
|
||||||
|
repoName: string;
|
||||||
|
generatedAt: string;
|
||||||
|
sections: {
|
||||||
|
overview: DocsOverview;
|
||||||
|
modules: DocsModule[];
|
||||||
|
patterns: DocsPatterns;
|
||||||
|
gettingStarted: DocsGettingStarted;
|
||||||
|
dependencyGraph: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Generation State ────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export type GenerationStatus =
|
||||||
|
| "QUEUED"
|
||||||
|
| "CLONING"
|
||||||
|
| "PARSING"
|
||||||
|
| "GENERATING"
|
||||||
|
| "RENDERING"
|
||||||
|
| "COMPLETED"
|
||||||
|
| "FAILED";
|
||||||
|
|
||||||
|
export interface Generation {
|
||||||
|
id: string;
|
||||||
|
repoUrl: string;
|
||||||
|
repoName: string;
|
||||||
|
commitHash: string;
|
||||||
|
status: GenerationStatus;
|
||||||
|
progress: number;
|
||||||
|
result: GeneratedDocs | null;
|
||||||
|
error: string | null;
|
||||||
|
costUsd: number | null;
|
||||||
|
duration: number | null;
|
||||||
|
createdAt: string;
|
||||||
|
viewCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── LLM Configuration ───────────────────────────────────────────────
|
||||||
|
|
||||||
|
export interface LLMMessage {
|
||||||
|
role: "system" | "user" | "assistant";
|
||||||
|
content: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LLMOptions {
|
||||||
|
temperature?: number;
|
||||||
|
maxTokens?: number;
|
||||||
|
model?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LLMProviderConfig {
|
||||||
|
provider: "openai" | "anthropic";
|
||||||
|
apiKey: string;
|
||||||
|
model?: string;
|
||||||
|
baseUrl?: string;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user