knowledge-graph-preview / cli /analyzer /domain-context.d.ts
mr4's picture
Upload 136 files
fd8cdf5 verified
import type { FileEntry } from './scanner.js';
/**
* Represents a detected entry point in the codebase.
*/
export interface EntryPoint {
/** Relative file path */
file: string;
/** Line number where the entry point was found */
line: number;
/** Type of entry point */
type: 'http' | 'cli' | 'event' | 'cron' | 'manual';
/** Description of the entry point (e.g., "Express/Koa route") */
description: string;
/** The matched text (max 120 chars) */
match: string;
/** Code snippet around the match (max 300 chars) */
snippet: string;
}
/**
* Represents a file's structural signature.
*/
export interface FileSignature {
/** Relative file path */
file: string;
/** Exported names (max 20) */
exports: string[];
/** Import sources (max 20) */
imports: string[];
/** Total line count */
lines: number;
/** First 80 lines of code (max 500 chars) */
preview: string;
}
/**
* The complete domain context extracted from a project.
*/
export interface DomainContext {
projectRoot: string;
fileCount: number;
fileTree: string[];
entryPoints: EntryPoint[];
fileSignatures: FileSignature[];
metadata: Record<string, unknown>;
}
/**
* Detects entry points in the given files by scanning for known patterns.
*/
export declare function detectEntryPoints(targetPath: string, files: FileEntry[]): EntryPoint[];
/**
* Extracts file signatures from the top prioritized files.
*/
export declare function extractFileSignatures(targetPath: string, files: FileEntry[]): FileSignature[];
/**
* Reads project metadata from manifest files.
*/
export declare function extractMetadata(targetPath: string): Record<string, unknown>;
/**
* Progressively trims the domain context to fit within maxBytes.
*/
export declare function truncateToFit(context: DomainContext, maxBytes?: number): DomainContext;
/**
* Generates the domain context for a project.
*
* @param targetPath - Absolute path to the project root
* @param files - Already-scanned file entries from the analyzer
* @returns The generated DomainContext
*/
export declare function generateDomainContext(targetPath: string, files: FileEntry[]): DomainContext;