mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-27 23:06:54 +05:00
feat(ipuaro): implement v0.1.0 foundation
- Project setup with tsup, vitest, ESM support - Domain entities: Session, Project - Value objects: FileData, FileAST, FileMeta, ChatMessage, ToolCall, ToolResult, UndoEntry - Service interfaces: IStorage, ILLMClient, ITool, IIndexer, IToolRegistry - Shared: Config (zod), IpuaroError, utils (hash, tokens), Result type - CLI with placeholder commands (start, init, index) - 91 unit tests with 100% coverage - Fix package scope @puaros -> @samiyev in CLAUDE.md
This commit is contained in:
83
packages/ipuaro/src/domain/services/IIndexer.ts
Normal file
83
packages/ipuaro/src/domain/services/IIndexer.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import type { FileAST } from "../value-objects/FileAST.js"
|
||||
import type { FileData } from "../value-objects/FileData.js"
|
||||
import type { FileMeta } from "../value-objects/FileMeta.js"
|
||||
import type { DepsGraph, SymbolIndex } from "./IStorage.js"
|
||||
|
||||
/**
|
||||
* Progress callback for indexing operations.
|
||||
*/
|
||||
export interface IndexProgress {
|
||||
current: number
|
||||
total: number
|
||||
currentFile: string
|
||||
phase: "scanning" | "parsing" | "analyzing" | "indexing"
|
||||
}
|
||||
|
||||
/**
|
||||
* Result of scanning a single file.
|
||||
*/
|
||||
export interface ScanResult {
|
||||
path: string
|
||||
type: "file" | "directory" | "symlink"
|
||||
size: number
|
||||
lastModified: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Indexing result statistics.
|
||||
*/
|
||||
export interface IndexingStats {
|
||||
filesScanned: number
|
||||
filesParsed: number
|
||||
parseErrors: number
|
||||
timeMs: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Indexer service interface (port).
|
||||
* Handles project scanning, parsing, and indexing.
|
||||
*/
|
||||
export interface IIndexer {
|
||||
/**
|
||||
* Scan directory and yield file results.
|
||||
*/
|
||||
scan(root: string): AsyncGenerator<ScanResult>
|
||||
|
||||
/**
|
||||
* Parse file content into AST.
|
||||
*/
|
||||
parseFile(content: string, language: "ts" | "tsx" | "js" | "jsx"): FileAST
|
||||
|
||||
/**
|
||||
* Analyze file and compute metadata.
|
||||
*/
|
||||
analyzeFile(path: string, ast: FileAST, allASTs: Map<string, FileAST>): FileMeta
|
||||
|
||||
/**
|
||||
* Build symbol index from all ASTs.
|
||||
*/
|
||||
buildSymbolIndex(asts: Map<string, FileAST>): SymbolIndex
|
||||
|
||||
/**
|
||||
* Build dependency graph from all ASTs.
|
||||
*/
|
||||
buildDepsGraph(asts: Map<string, FileAST>): DepsGraph
|
||||
|
||||
/**
|
||||
* Full indexing pipeline.
|
||||
*/
|
||||
indexProject(
|
||||
root: string,
|
||||
onProgress?: (progress: IndexProgress) => void,
|
||||
): Promise<IndexingStats>
|
||||
|
||||
/**
|
||||
* Update single file (incremental indexing).
|
||||
*/
|
||||
updateFile(path: string, data: FileData): Promise<void>
|
||||
|
||||
/**
|
||||
* Remove file from index.
|
||||
*/
|
||||
removeFile(path: string): Promise<void>
|
||||
}
|
||||
Reference in New Issue
Block a user