From 3cfc85bd90d362ee4515fd41c7bd70858a0eff5d Mon Sep 17 00:00:00 2001 From: repi Date: Mon, 1 Jan 2001 00:00:00 +0000 Subject: [PATCH] feat: add shared type definitions --- packages/shared/src/types.ts | 185 +++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 packages/shared/src/types.ts diff --git a/packages/shared/src/types.ts b/packages/shared/src/types.ts new file mode 100644 index 0000000..1987a4d --- /dev/null +++ b/packages/shared/src/types.ts @@ -0,0 +1,185 @@ +// ── Repository Cloning ────────────────────────────────────────────── + +export interface CloneMetadata { + name: string; + description: string; + defaultBranch: string; + languages: Record; + 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; +}