Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

refactor(web): split api/types.ts into a per-domain types/ package (#249)

Raghav Chamadiya54a2c1dbc47c
diff --git a/packages/web/src/lib/api/types.ts b/packages/web/src/lib/api/types.ts
index 2f55a5a72..e3b7d202b 100644
--- a/packages/web/src/lib/api/types.ts
+++ b/packages/web/src/lib/api/types.ts
@@ -1,1014 +1,22 @@
/**
* TypeScript types mirroring the backend Pydantic schemas.
- * Source of truth: packages/server/src/repowise/server/schemas.py
+ * Source of truth: packages/server/src/repowise/server/schemas/
+ *
+ * This module was split into a per-domain `types/` package. It re-exports
+ * every type so existing `@/lib/api/types` imports keep working unchanged.
*/
-/**
- * Pagination envelope returned by list endpoints. Mirrors
- * ``repowise.server.schemas.Paginated[T]``.
- */
-export interface Paginated<T> {
- items: T[];
- total: number;
- has_more: boolean;
- next_offset: number | null;
-}
-
-// ---------------------------------------------------------------------------
-// Repository
-// ---------------------------------------------------------------------------
-
-export interface RepoCreate {
- name: string;
- local_path: string;
- url?: string;
- default_branch?: string;
- settings?: Record<string, unknown>;
-}
-
-export interface RepoUpdate {
- name?: string;
- url?: string;
- default_branch?: string;
- settings?: {
- exclude_patterns?: string[];
- [key: string]: unknown;
- };
-}
-
-export interface RepoResponse {
- id: string;
- name: string;
- url: string;
- local_path: string;
- default_branch: string;
- head_commit: string | null;
- settings: Record<string, unknown>;
- created_at: string;
- updated_at: string;
- // Workspace mode (optional — only populated when the server runs in
- // workspace mode). Unindexed repos appear as synthetic rows with
- // `id="ws:<alias>"` and `workspace_status === "needs_index"`.
- workspace_alias?: string | null;
- workspace_status?: "indexed" | "needs_index" | "missing_dir" | null;
- is_primary?: boolean | null;
- docs_enabled?: boolean | null;
- docs_skip_reason?: string | null;
-}
-
-// ---------------------------------------------------------------------------
-// Pages
-// ---------------------------------------------------------------------------
-
-export interface PageResponse {
- id: string;
- repository_id: string;
- page_type: string;
- title: string;
- content: string;
- target_path: string;
- source_hash: string;
- model_name: string;
- provider_name: string;
- input_tokens: number;
- output_tokens: number;
- cached_tokens: number;
- generation_level: number;
- version: number;
- confidence: number;
- freshness_status: string;
- metadata: Record<string, unknown>;
- human_notes: string | null;
- created_at: string;
- updated_at: string;
-}
-
-export interface PageVersionResponse {
- id: string;
- page_id: string;
- version: number;
- page_type: string;
- title: string;
- content: string;
- source_hash: string;
- model_name: string;
- provider_name: string;
- input_tokens: number;
- output_tokens: number;
- confidence: number;
- archived_at: string;
-}
-
-export interface PageListResponse {
- pages: PageResponse[];
- total: number;
-}
-
-// ---------------------------------------------------------------------------
-// Jobs
-// ---------------------------------------------------------------------------
-
-export interface JobResponse {
- id: string;
- repository_id: string;
- status: "pending" | "running" | "completed" | "failed" | "paused";
- provider_name: string;
- model_name: string;
- total_pages: number;
- completed_pages: number;
- failed_pages: number;
- current_level: number;
- error_message: string | null;
- config: Record<string, unknown>;
- created_at: string;
- updated_at: string;
- started_at: string | null;
- finished_at: string | null;
-}
-
-export interface JobProgressEvent {
- event: "progress" | "done" | "error";
- job_id: string;
- completed_pages: number;
- total_pages: number;
- current_page?: string;
- current_level?: number;
- tokens_input?: number;
- tokens_output?: number;
- estimated_cost?: number;
- actual_cost_usd?: number | null;
- error?: string;
-}
-
-// ---------------------------------------------------------------------------
-// Search
-// ---------------------------------------------------------------------------
-
-export interface SearchRequest {
- query: string;
- search_type?: "semantic" | "fulltext";
- limit?: number;
-}
-
-export interface SearchResultResponse {
- page_id: string;
- title: string;
- page_type: string;
- target_path: string;
- score: number;
- snippet: string;
- search_type: string;
-}
-
-// ---------------------------------------------------------------------------
-// Symbols
-// ---------------------------------------------------------------------------
-
-export interface SymbolImportanceComponents {
- file_pagerank: number;
- visibility_factor: number;
- complexity_norm: number;
- kind_boost: number;
- is_entry_point: boolean;
-}
-
-export interface SymbolResponse {
- id: string;
- repository_id: string;
- file_path: string;
- symbol_id: string;
- name: string;
- qualified_name: string;
- kind: string;
- signature: string;
- start_line: number;
- end_line: number;
- docstring: string | null;
- visibility: string;
- is_async: boolean;
- complexity_estimate: number;
- language: string;
- parent_name: string | null;
- importance_score?: number | null;
- importance_components?: SymbolImportanceComponents | null;
- file_pagerank?: number | null;
- is_entry_point?: boolean | null;
- file_churn_percentile?: number | null;
- file_is_hotspot?: boolean | null;
-}
-
-// ---------------------------------------------------------------------------
-// Graph
-// ---------------------------------------------------------------------------
-
-export interface GraphNodeResponse {
- node_id: string;
- node_type: string;
- language: string;
- symbol_count: number;
- pagerank: number;
- betweenness: number;
- community_id: number;
- is_test: boolean;
- is_entry_point: boolean;
- has_doc: boolean;
- // Phase A: cross-link signals (all optional for back-compat)
- is_hotspot?: boolean;
- churn_percentile?: number | null;
- is_dead?: boolean;
- dead_confidence?: number | null;
- has_decision?: boolean;
- primary_owner?: string | null;
-}
-
-export interface GraphEdgeResponse {
- source: string;
- target: string;
- imported_names: string[];
-}
-
-export interface GraphExportResponse {
- nodes: GraphNodeResponse[];
- links: GraphEdgeResponse[];
- /** Server set this true when the response was capped to top-N by PageRank. */
- truncated?: boolean;
- total_node_count?: number;
-}
-
-// Architecture super-node graph (Phase A)
-export interface ArchitectureNodeResponse {
- community_id: number;
- label: string;
- cohesion: number;
- member_count: number;
- top_file: string;
- avg_pagerank: number;
- hotspot_count: number;
- dead_count: number;
- has_decision: boolean;
- doc_coverage_pct: number;
- languages: string[];
-}
-
-export interface ArchitectureEdgeResponse {
- source: number;
- target: number;
- edge_count: number;
-}
-
-export interface ArchitectureGraphResponse {
- nodes: ArchitectureNodeResponse[];
- edges: ArchitectureEdgeResponse[];
-}
-
-export interface GraphPathResponse {
- path: string[];
- distance: number;
- explanation: string;
- visual_context?: unknown;
-}
-
-export interface ModuleNodeResponse {
- module_id: string;
- file_count: number;
- symbol_count: number;
- avg_pagerank: number;
- doc_coverage_pct: number;
-}
-
-export interface ModuleEdgeResponse {
- source: string;
- target: string;
- edge_count: number;
-}
-
-export interface ModuleGraphResponse {
- nodes: ModuleNodeResponse[];
- edges: ModuleEdgeResponse[];
-}
-
-export interface EgoGraphResponse {
- nodes: GraphNodeResponse[];
- links: GraphEdgeResponse[];
- center_node_id: string;
- center_git_meta: GitMetadataResponse | null;
- inbound_count: number;
- outbound_count: number;
-}
-
-export interface NodeSearchResult {
- node_id: string;
- language: string;
- symbol_count: number;
-}
-
-export interface DeadCodeGraphNodeResponse {
- node_id: string;
- node_type: string;
- language: string;
- symbol_count: number;
- pagerank: number;
- betweenness: number;
- community_id: number;
- is_test: boolean;
- is_entry_point: boolean;
- has_doc: boolean;
- confidence_group: string;
-}
-
-export interface DeadCodeGraphResponse {
- nodes: DeadCodeGraphNodeResponse[];
- links: GraphEdgeResponse[];
-}
-
-export interface HotFilesNodeResponse {
- node_id: string;
- node_type: string;
- language: string;
- symbol_count: number;
- pagerank: number;
- betweenness: number;
- community_id: number;
- is_test: boolean;
- is_entry_point: boolean;
- has_doc: boolean;
- commit_count: number;
-}
-
-export interface HotFilesGraphResponse {
- nodes: HotFilesNodeResponse[];
- links: GraphEdgeResponse[];
-}
-
-export interface RepoStatsResponse {
- file_count: number;
- symbol_count: number;
- entry_point_count: number;
- doc_coverage_pct: number;
- freshness_score: number;
- dead_export_count: number;
-}
-
-// ---------------------------------------------------------------------------
-// Graph Intelligence
-// ---------------------------------------------------------------------------
-
-export interface SymbolNodeSummary {
- symbol_id: string;
- name: string;
- kind: string;
- file: string;
- start_line?: number | null;
- signature?: string | null;
-}
-
-export interface CallerCalleeEntry {
- symbol_id: string;
- name: string;
- kind: string;
- file: string;
- start_line?: number | null;
- edge_type: string;
- confidence: number;
-}
-
-export interface CallersCalleesResponse {
- symbol_id: string;
- symbol: SymbolNodeSummary;
- callers: CallerCalleeEntry[];
- callees: CallerCalleeEntry[];
- caller_count: number;
- callee_count: number;
- truncated: boolean;
-}
-
-export interface CommunityMember {
- path: string;
- pagerank: number;
- is_entry_point: boolean;
-}
-
-export interface NeighboringCommunity {
- community_id: number;
- label: string;
- cross_edge_count: number;
-}
-
-export interface CommunityDetailResponse {
- community_id: number;
- label: string;
- cohesion: number;
- member_count: number;
- members: CommunityMember[];
- truncated: boolean;
- neighboring_communities: NeighboringCommunity[];
-}
-
-export interface CommunitySummaryItem {
- community_id: number;
- label: string;
- cohesion: number;
- member_count: number;
- top_file: string;
-}
-
-export interface GraphMetricsResponse {
- target: string;
- node_type: string;
- pagerank: number;
- pagerank_percentile: number;
- betweenness: number;
- betweenness_percentile: number;
- community_id: number;
- community_label: string | null;
- is_entry_point: boolean;
- in_degree: number;
- out_degree: number;
- entry_point_score?: number | null;
- kind?: string | null;
- file?: string | null;
-}
-
-export interface ExecutionFlowEntry {
- entry_point: string;
- entry_point_name: string;
- entry_point_score: number;
- trace: string[];
- depth: number;
- crosses_community: boolean;
- communities_visited: number[];
-}
-
-export interface ExecutionFlowsResponse {
- total_entry_points: number;
- flows: ExecutionFlowEntry[];
-}
-
-// ---------------------------------------------------------------------------
-// Git Intelligence
-// ---------------------------------------------------------------------------
-
-export interface GitMetadataResponse {
- file_path: string;
- commit_count_total: number;
- commit_count_90d: number;
- commit_count_30d: number;
- first_commit_at: string | null;
- last_commit_at: string | null;
- primary_owner_name: string | null;
- primary_owner_email: string | null;
- primary_owner_commit_pct: number | null;
- recent_owner_name: string | null;
- recent_owner_commit_pct: number | null;
- top_authors: Array<{ name: string; email: string; commit_count: number; pct: number }>;
- significant_commits: Array<{ sha: string; date: string; message: string; author: string }>;
- co_change_partners: Array<{ file_path: string; co_change_count: number }>;
- is_hotspot: boolean;
- is_stable: boolean;
- churn_percentile: number;
- age_days: number;
- bus_factor: number;
- contributor_count: number;
- lines_added_90d: number;
- lines_deleted_90d: number;
- avg_commit_size: number;
- commit_categories: Record<string, number>;
- merge_commit_count_90d: number;
- test_gap?: boolean | null;
-}
-
-export interface HotspotResponse {
- file_path: string;
- commit_count_total?: number;
- commit_count_90d: number;
- commit_count_30d: number;
- churn_percentile: number;
- temporal_hotspot_score?: number | null;
- primary_owner: string | null;
- primary_owner_commit_pct?: number | null;
- recent_owner_name?: string | null;
- recent_owner_commit_pct?: number | null;
- is_hotspot: boolean;
- is_stable: boolean;
- bus_factor: number;
- contributor_count: number;
- lines_added_90d: number;
- lines_deleted_90d: number;
- avg_commit_size: number;
- commit_categories: Record<string, number>;
- merge_commit_count_90d?: number;
- commit_count_capped?: boolean;
- age_days?: number;
- last_commit_at?: string | null;
-}
-
-export interface OwnershipEntry {
- module_path: string;
- primary_owner: string | null;
- owner_pct: number | null;
- file_count: number;
- is_silo: boolean;
-}
-
-export interface GitSummaryResponse {
- total_files: number;
- hotspot_count: number;
- stable_count: number;
- average_churn_percentile: number;
- top_owners: Array<{ name: string; email?: string; file_count: number; pct: number }>;
-}
-
-// ---------------------------------------------------------------------------
-// Dead Code
-// ---------------------------------------------------------------------------
-
-export interface DeadCodeFindingResponse {
- id: string;
- kind: string;
- file_path: string;
- symbol_name: string | null;
- symbol_kind: string | null;
- confidence: number;
- reason: string;
- lines: number;
- safe_to_delete: boolean;
- primary_owner: string | null;
- status: string;
- note: string | null;
-}
-
-export interface DeadCodePatchRequest {
- status: string;
- note?: string;
-}
-
-export interface DeadCodeSummaryResponse {
- total_findings: number;
- confidence_summary: Record<string, number>;
- deletable_lines: number;
- total_lines: number;
- by_kind: Record<string, number>;
-}
-
-// ---------------------------------------------------------------------------
-// Decisions
-// ---------------------------------------------------------------------------
-
-export interface DecisionRecordResponse {
- id: string;
- repository_id: string;
- title: string;
- status: "proposed" | "active" | "deprecated" | "superseded";
- context: string;
- decision: string;
- rationale: string;
- alternatives: string[];
- consequences: string[];
- affected_files: string[];
- affected_modules: string[];
- tags: string[];
- source: "git_archaeology" | "inline_marker" | "readme_mining" | "cli";
- evidence_commits: string[];
- evidence_file: string | null;
- evidence_line: number | null;
- confidence: number;
- staleness_score: number;
- superseded_by: string | null;
- last_code_change: string | null;
- /** Trust tier of the decision's primary supporting evidence. */
- verification?: DecisionVerification;
- created_at: string;
- updated_at: string;
-}
-
-export type DecisionVerification = "exact" | "fuzzy" | "unverified";
-
-export interface DecisionEvidence {
- id: string;
- source: string;
- source_rank: number;
- evidence_file: string | null;
- evidence_line: number | null;
- evidence_commit: string | null;
- source_quote: string;
- confidence: number;
- verification: DecisionVerification;
- created_at: string;
-}
-
-export interface DecisionEvidenceResponse {
- evidence: DecisionEvidence[];
-}
-
-export interface DecisionLineageEntry {
- id: string;
- title: string;
- status: "proposed" | "active" | "deprecated" | "superseded";
- source: string;
- relation: string | null;
-}
-
-export interface DecisionLineageResponse {
- lineage: DecisionLineageEntry[];
-}
-
-export interface DecisionGraphNode {
- id: string;
- title: string;
- status: "proposed" | "active" | "deprecated" | "superseded";
- source: string;
- confidence: number;
- staleness_score: number;
- verification: DecisionVerification;
-}
-
-export interface DecisionGraphEdge {
- src: string;
- dst: string;
- kind: "supersedes" | "refines" | "relates_to" | "conflicts_with";
- confidence: number;
- evidence: string;
-}
-
-export interface DecisionCodeEdge {
- decision_id: string;
- node_id: string;
- link_type: "file" | "module";
-}
-
-export interface DecisionGraph {
- nodes: DecisionGraphNode[];
- decision_edges: DecisionGraphEdge[];
- code_edges: DecisionCodeEdge[];
-}
-
-export interface DecisionCreate {
- title: string;
- context?: string;
- decision?: string;
- rationale?: string;
- alternatives?: string[];
- consequences?: string[];
- affected_files?: string[];
- affected_modules?: string[];
- tags?: string[];
-}
-
-export interface DecisionStatusUpdate {
- status?: string;
- superseded_by?: string;
- affected_modules?: string[];
- affected_files?: string[];
-}
-
-export interface DecisionHealthResponse {
- summary: {
- active: number;
- proposed: number;
- deprecated: number;
- superseded: number;
- stale: number;
- };
- stale_decisions: DecisionRecordResponse[];
- proposed_awaiting_review: DecisionRecordResponse[];
- ungoverned_hotspots: string[];
-}
-
-// ---------------------------------------------------------------------------
-// Health
-// ---------------------------------------------------------------------------
-
-export interface HealthResponse {
- status: string;
- db: string;
- version: string;
-}
-
-// ---------------------------------------------------------------------------
-// Webhooks
-// ---------------------------------------------------------------------------
-
-export interface WebhookResponse {
- event_id: string;
- status: string;
-}
-
-// ---------------------------------------------------------------------------
-// Chat
-// ---------------------------------------------------------------------------
-
-export interface ConversationResponse {
- id: string;
- repository_id: string;
- title: string;
- message_count: number;
- created_at: string;
- updated_at: string;
-}
-
-export interface ChatMessageResponse {
- id: string;
- conversation_id: string;
- role: "user" | "assistant";
- content: {
- text?: string;
- tool_calls?: Array<{
- id: string;
- name: string;
- arguments?: Record<string, unknown>;
- result?: Record<string, unknown>;
- }>;
- };
- created_at: string;
-}
-
-export type ChatSSEEvent =
- | { type: "text_delta"; text: string }
- | {
- type: "tool_start";
- tool_id: string;
- tool_name: string;
- input: Record<string, unknown>;
- }
- | {
- type: "tool_result";
- tool_id: string;
- tool_name: string;
- summary: string;
- artifact: { type: string; data: Record<string, unknown> };
- }
- | { type: "done"; conversation_id: string; message_id: string }
- | { type: "error"; message: string };
-
-// ---------------------------------------------------------------------------
-// Providers
-// ---------------------------------------------------------------------------
-
-export interface ProviderInfo {
- id: string;
- name: string;
- models: string[];
- default_model: string;
- configured: boolean;
-}
-
-export interface ProvidersResponse {
- active: {
- provider: string | null;
- model: string | null;
- };
- providers: ProviderInfo[];
-}
-
-// ---------------------------------------------------------------------------
-// API error
-// ---------------------------------------------------------------------------
-
-export interface ApiError {
- detail: string;
- status: number;
-}
-
-// ---------------------------------------------------------------------------
-// Workspace
-// ---------------------------------------------------------------------------
-
-export interface WorkspaceRepoEntry {
- alias: string;
- path: string;
- is_primary: boolean;
- indexed_at: string | null;
- last_commit_at_index: string | null;
- // Per-repo stats from each repo's wiki.db
- repo_id: string | null;
- file_count: number;
- symbol_count: number;
- page_count: number;
- doc_coverage_pct: number;
- hotspot_count: number;
- // Phase B server augmentation
- status?: "indexed" | "needs_index" | "missing_dir" | null;
- docs_enabled?: boolean | null;
- docs_skip_reason?: string | null;
-}
-
-export interface WorkspaceSyncResult {
- alias: string;
- repo_id: string | null;
- status: "accepted" | "skipped" | "error";
- job_id: string | null;
- reason: string | null;
-}
-
-export interface WorkspaceSyncResponse {
- results: WorkspaceSyncResult[];
-}
-
-export interface WorkspaceCrossRepoSummary {
- co_change_count: number;
- package_dep_count: number;
- top_connections: Array<{ repos: string[]; edge_count: number }>;
-}
-
-export interface WorkspaceContractSummary {
- total_contracts: number;
- total_links: number;
- by_type: Record<string, number>;
-}
-
-export interface WorkspaceResponse {
- is_workspace: boolean;
- workspace_root: string | null;
- workspace_name: string | null;
- repos: WorkspaceRepoEntry[];
- default_repo: string | null;
- cross_repo_summary: WorkspaceCrossRepoSummary | null;
- contract_summary: WorkspaceContractSummary | null;
-}
-
-export interface WorkspaceContractEntry {
- contract_id: string;
- contract_type: string;
- role: string;
- repo: string;
- file_path: string;
- symbol_name: string;
- confidence: number;
- service: string | null;
-}
-
-export interface WorkspaceContractLinkEntry {
- contract_id: string;
- contract_type: string;
- match_type: string;
- confidence: number;
- provider_repo: string;
- provider_file: string;
- provider_symbol: string;
- consumer_repo: string;
- consumer_file: string;
- consumer_symbol: string;
-}
-
-export interface WorkspaceContractsResponse {
- contracts: WorkspaceContractEntry[];
- links: WorkspaceContractLinkEntry[];
- total_contracts: number;
- total_links: number;
- by_type: Record<string, number>;
-}
-
-export interface WorkspaceCoChangeEntry {
- source_repo: string;
- source_file: string;
- target_repo: string;
- target_file: string;
- strength: number;
- frequency: number;
- last_date: string;
-}
-
-export interface WorkspaceCoChangesResponse {
- co_changes: WorkspaceCoChangeEntry[];
- total: number;
-}
-
-export interface WorkspaceGraphNode {
- repo_id: string;
- name: string;
- file_count: number;
- coverage_pct: number;
- health_score: number;
- top_language: string;
-}
-
-export interface WorkspaceGraphEdge {
- source: string;
- target: string;
- type: "contract" | "co_change";
- strength: number;
- label: string | null;
-}
-
-export interface WorkspaceGraphResponse {
- nodes: WorkspaceGraphNode[];
- edges: WorkspaceGraphEdge[];
-}
-
-// ---------------------------------------------------------------------------
-// Owner / contributor profile
-// ---------------------------------------------------------------------------
-
-export interface OwnerListEntry {
- key: string;
- name: string;
- email: string | null;
- files_owned: number;
- hotspots_owned: number;
- silo_modules: number;
- dead_code_files_owned: number;
- dead_code_lines_owned: number;
- commit_count_90d: number;
- last_commit_at: string | null;
- bus_factor_risk_files: number;
-}
-
-export interface OwnerModuleRollup {
- module_path: string;
- file_count: number;
- hotspot_count: number;
- dominant_pct: number;
-}
-
-export interface OwnerFileEntry {
- file_path: string;
- commit_count_90d: number;
- churn_percentile: number;
- bus_factor: number;
- is_hotspot: boolean;
- last_commit_at: string | null;
- primary_owner_commit_pct: number | null;
-}
-
-export interface OwnerCoAuthor {
- name: string;
- email: string | null;
- shared_files: number;
- co_change_strength: number;
-}
-
-export interface OwnerProfileResponse {
- key: string;
- name: string;
- email: string | null;
- files_owned: number;
- hotspots_owned: number;
- silo_modules: number;
- dead_code_files_owned: number;
- dead_code_lines_owned: number;
- commit_count_90d: number;
- last_commit_at: string | null;
- first_commit_at: string | null;
- bus_factor_risk_files: number;
- lines_added_90d_est: number;
- lines_deleted_90d_est: number;
- modules: OwnerModuleRollup[];
- top_files: OwnerFileEntry[];
- co_authors: OwnerCoAuthor[];
- commit_categories: Record<string, number>;
-}
-
-// ---------------------------------------------------------------------------
-// Module health
-// ---------------------------------------------------------------------------
-
-export interface ModuleHealthOwner {
- name: string;
- email: string | null;
- file_count: number;
- pct: number;
-}
-
-export interface ModuleHealthSummary {
- module_path: string;
- file_count: number;
- symbol_count: number;
- hotspot_count: number;
- dead_code_count: number;
- dead_code_lines: number;
- avg_churn_percentile: number;
- median_bus_factor: number;
- min_bus_factor: number;
- primary_owner: string | null;
- primary_owner_pct: number;
- is_silo: boolean;
- decision_count: number;
- doc_coverage_pct: number;
- health_score: number;
-}
-
-export interface ModuleHealthDetail extends ModuleHealthSummary {
- owners: ModuleHealthOwner[];
- top_hotspots: string[];
- governing_decisions: string[];
- contributor_count: number;
-}
-
-// ---------------------------------------------------------------------------
-// Reviewer suggestions
-// ---------------------------------------------------------------------------
-
-export interface ReviewerSuggestion {
- name: string;
- email: string | null;
- score: number;
- recent_commits: number;
- owned_paths: string[];
- co_change_paths: string[];
- reasons: string[];
-}
-
-export interface ReviewerSuggestionsResponse {
- paths: string[];
- suggestions: ReviewerSuggestion[];
-}
+export * from "./types/pagination";
+export * from "./types/repository";
+export * from "./types/pages";
+export * from "./types/search";
+export * from "./types/symbols";
+export * from "./types/graph";
+export * from "./types/intelligence";
+export * from "./types/git";
+export * from "./types/dead-code";
+export * from "./types/decisions";
+export * from "./types/chat";
+export * from "./types/workspace";
+export * from "./types/ownership";
+export * from "./types/misc";
diff --git a/packages/web/src/lib/api/types/chat.ts b/packages/web/src/lib/api/types/chat.ts
new file mode 100644
index 000000000..50357574b
--- /dev/null
+++ b/packages/web/src/lib/api/types/chat.ts
@@ -0,0 +1,46 @@
+// ---------------------------------------------------------------------------
+// Chat
+// ---------------------------------------------------------------------------
+
+export interface ConversationResponse {
+ id: string;
+ repository_id: string;
+ title: string;
+ message_count: number;
+ created_at: string;
+ updated_at: string;
+}
+
+export interface ChatMessageResponse {
+ id: string;
+ conversation_id: string;
+ role: "user" | "assistant";
+ content: {
+ text?: string;
+ tool_calls?: Array<{
+ id: string;
+ name: string;
+ arguments?: Record<string, unknown>;
+ result?: Record<string, unknown>;
+ }>;
+ };
+ created_at: string;
+}
+
+export type ChatSSEEvent =
+ | { type: "text_delta"; text: string }
+ | {
+ type: "tool_start";
+ tool_id: string;
+ tool_name: string;
+ input: Record<string, unknown>;
+ }
+ | {
+ type: "tool_result";
+ tool_id: string;
+ tool_name: string;
+ summary: string;
+ artifact: { type: string; data: Record<string, unknown> };
+ }
+ | { type: "done"; conversation_id: string; message_id: string }
+ | { type: "error"; message: string };
diff --git a/packages/web/src/lib/api/types/dead-code.ts b/packages/web/src/lib/api/types/dead-code.ts
new file mode 100644
index 000000000..d364a8ee9
--- /dev/null
+++ b/packages/web/src/lib/api/types/dead-code.ts
@@ -0,0 +1,31 @@
+// ---------------------------------------------------------------------------
+// Dead Code
+// ---------------------------------------------------------------------------
+
+export interface DeadCodeFindingResponse {
+ id: string;
+ kind: string;
+ file_path: string;
+ symbol_name: string | null;
+ symbol_kind: string | null;
+ confidence: number;
+ reason: string;
+ lines: number;
+ safe_to_delete: boolean;
+ primary_owner: string | null;
+ status: string;
+ note: string | null;
+}
+
+export interface DeadCodePatchRequest {
+ status: string;
+ note?: string;
+}
+
+export interface DeadCodeSummaryResponse {
+ total_findings: number;
+ confidence_summary: Record<string, number>;
+ deletable_lines: number;
+ total_lines: number;
+ by_kind: Record<string, number>;
+}
diff --git a/packages/web/src/lib/api/types/decisions.ts b/packages/web/src/lib/api/types/decisions.ts
new file mode 100644
index 000000000..05c4cf789
--- /dev/null
+++ b/packages/web/src/lib/api/types/decisions.ts
@@ -0,0 +1,123 @@
+// ---------------------------------------------------------------------------
+// Decisions
+// ---------------------------------------------------------------------------
+
+export interface DecisionRecordResponse {
+ id: string;
+ repository_id: string;
+ title: string;
+ status: "proposed" | "active" | "deprecated" | "superseded";
+ context: string;
+ decision: string;
+ rationale: string;
+ alternatives: string[];
+ consequences: string[];
+ affected_files: string[];
+ affected_modules: string[];
+ tags: string[];
+ source: "git_archaeology" | "inline_marker" | "readme_mining" | "cli";
+ evidence_commits: string[];
+ evidence_file: string | null;
+ evidence_line: number | null;
+ confidence: number;
+ staleness_score: number;
+ superseded_by: string | null;
+ last_code_change: string | null;
+ /** Trust tier of the decision's primary supporting evidence. */
+ verification?: DecisionVerification;
+ created_at: string;
+ updated_at: string;
+}
+
+export type DecisionVerification = "exact" | "fuzzy" | "unverified";
+
+export interface DecisionEvidence {
+ id: string;
+ source: string;
+ source_rank: number;
+ evidence_file: string | null;
+ evidence_line: number | null;
+ evidence_commit: string | null;
+ source_quote: string;
+ confidence: number;
+ verification: DecisionVerification;
+ created_at: string;
+}
+
+export interface DecisionEvidenceResponse {
+ evidence: DecisionEvidence[];
+}
+
+export interface DecisionLineageEntry {
+ id: string;
+ title: string;
+ status: "proposed" | "active" | "deprecated" | "superseded";
+ source: string;
+ relation: string | null;
+}
+
+export interface DecisionLineageResponse {
+ lineage: DecisionLineageEntry[];
+}
+
+export interface DecisionGraphNode {
+ id: string;
+ title: string;
+ status: "proposed" | "active" | "deprecated" | "superseded";
+ source: string;
+ confidence: number;
+ staleness_score: number;
+ verification: DecisionVerification;
+}
+
+export interface DecisionGraphEdge {
+ src: string;
+ dst: string;
+ kind: "supersedes" | "refines" | "relates_to" | "conflicts_with";
+ confidence: number;
+ evidence: string;
+}
+
+export interface DecisionCodeEdge {
+ decision_id: string;
+ node_id: string;
+ link_type: "file" | "module";
+}
+
+export interface DecisionGraph {
+ nodes: DecisionGraphNode[];
+ decision_edges: DecisionGraphEdge[];
+ code_edges: DecisionCodeEdge[];
+}
+
+export interface DecisionCreate {
+ title: string;
+ context?: string;
+ decision?: string;
+ rationale?: string;
+ alternatives?: string[];
+ consequences?: string[];
+ affected_files?: string[];
+ affected_modules?: string[];
+ tags?: string[];
+}
+
+export interface DecisionStatusUpdate {
+ status?: string;
+ superseded_by?: string;
+ affected_modules?: string[];
+ affected_files?: string[];
+}
+
+export interface DecisionHealthResponse {
+ summary: {
+ active: number;
+ proposed: number;
+ deprecated: number;
+ superseded: number;
+ stale: number;
+ };
+ stale_decisions: DecisionRecordResponse[];
+ proposed_awaiting_review: DecisionRecordResponse[];
+ ungoverned_hotspots: string[];
+}
diff --git a/packages/web/src/lib/api/types/git.ts b/packages/web/src/lib/api/types/git.ts
new file mode 100644
index 000000000..d01b0ce7c
--- /dev/null
+++ b/packages/web/src/lib/api/types/git.ts
@@ -0,0 +1,73 @@
+// ---------------------------------------------------------------------------
+// Git Intelligence
+// ---------------------------------------------------------------------------
+
+export interface GitMetadataResponse {
+ file_path: string;
+ commit_count_total: number;
+ commit_count_90d: number;
+ commit_count_30d: number;
+ first_commit_at: string | null;
+ last_commit_at: string | null;
+ primary_owner_name: string | null;
+ primary_owner_email: string | null;
+ primary_owner_commit_pct: number | null;
+ recent_owner_name: string | null;
+ recent_owner_commit_pct: number | null;
+ top_authors: Array<{ name: string; email: string; commit_count: number; pct: number }>;
+ significant_commits: Array<{ sha: string; date: string; message: string; author: string }>;
+ co_change_partners: Array<{ file_path: string; co_change_count: number }>;
+ is_hotspot: boolean;
+ is_stable: boolean;
+ churn_percentile: number;
+ age_days: number;
+ bus_factor: number;
+ contributor_count: number;
+ lines_added_90d: number;
+ lines_deleted_90d: number;
+ avg_commit_size: number;
+ commit_categories: Record<string, number>;
+ merge_commit_count_90d: number;
+ test_gap?: boolean | null;
+}
+
+export interface HotspotResponse {
+ file_path: string;
+ commit_count_total?: number;
+ commit_count_90d: number;
+ commit_count_30d: number;
+ churn_percentile: number;
+ temporal_hotspot_score?: number | null;
+ primary_owner: string | null;
+ primary_owner_commit_pct?: number | null;
+ recent_owner_name?: string | null;
+ recent_owner_commit_pct?: number | null;
+ is_hotspot: boolean;
+ is_stable: boolean;
+ bus_factor: number;
+ contributor_count: number;
+ lines_added_90d: number;
+ lines_deleted_90d: number;
+ avg_commit_size: number;
+ commit_categories: Record<string, number>;
+ merge_commit_count_90d?: number;
+ commit_count_capped?: boolean;
+ age_days?: number;
+ last_commit_at?: string | null;
+}
+
+export interface OwnershipEntry {
+ module_path: string;
+ primary_owner: string | null;
+ owner_pct: number | null;
+ file_count: number;
+ is_silo: boolean;
+}
+
+export interface GitSummaryResponse {
+ total_files: number;
+ hotspot_count: number;
+ stable_count: number;
+ average_churn_percentile: number;
+ top_owners: Array<{ name: string; email?: string; file_count: number; pct: number }>;
+}
diff --git a/packages/web/src/lib/api/types/graph.ts b/packages/web/src/lib/api/types/graph.ts
new file mode 100644
index 000000000..545b04ba8
--- /dev/null
+++ b/packages/web/src/lib/api/types/graph.ts
@@ -0,0 +1,153 @@
+import type { GitMetadataResponse } from "./git";
+
+// ---------------------------------------------------------------------------
+// Graph
+// ---------------------------------------------------------------------------
+
+export interface GraphNodeResponse {
+ node_id: string;
+ node_type: string;
+ language: string;
+ symbol_count: number;
+ pagerank: number;
+ betweenness: number;
+ community_id: number;
+ is_test: boolean;
+ is_entry_point: boolean;
+ has_doc: boolean;
+ // Phase A: cross-link signals (all optional for back-compat)
+ is_hotspot?: boolean;
+ churn_percentile?: number | null;
+ is_dead?: boolean;
+ dead_confidence?: number | null;
+ has_decision?: boolean;
+ primary_owner?: string | null;
+}
+
+export interface GraphEdgeResponse {
+ source: string;
+ target: string;
+ imported_names: string[];
+}
+
+/**
+ * Shared shape for the node/link graph-response envelopes. The concrete
+ * responses below differ only in their node type (and a few extra fields),
+ * so they extend this generic rather than repeat `nodes`/`links`.
+ */
+export interface GraphLike<N> {
+ nodes: N[];
+ links: GraphEdgeResponse[];
+}
+
+export interface GraphExportResponse extends GraphLike<GraphNodeResponse> {
+ /** Server set this true when the response was capped to top-N by PageRank. */
+ truncated?: boolean;
+ total_node_count?: number;
+}
+
+// Architecture super-node graph (Phase A)
+export interface ArchitectureNodeResponse {
+ community_id: number;
+ label: string;
+ cohesion: number;
+ member_count: number;
+ top_file: string;
+ avg_pagerank: number;
+ hotspot_count: number;
+ dead_count: number;
+ has_decision: boolean;
+ doc_coverage_pct: number;
+ languages: string[];
+}
+
+export interface ArchitectureEdgeResponse {
+ source: number;
+ target: number;
+ edge_count: number;
+}
+
+export interface ArchitectureGraphResponse {
+ nodes: ArchitectureNodeResponse[];
+ edges: ArchitectureEdgeResponse[];
+}
+
+export interface GraphPathResponse {
+ path: string[];
+ distance: number;
+ explanation: string;
+ visual_context?: unknown;
+}
+
+export interface ModuleNodeResponse {
+ module_id: string;
+ file_count: number;
+ symbol_count: number;
+ avg_pagerank: number;
+ doc_coverage_pct: number;
+}
+
+export interface ModuleEdgeResponse {
+ source: string;
+ target: string;
+ edge_count: number;
+}
+
+export interface ModuleGraphResponse {
+ nodes: ModuleNodeResponse[];
+ edges: ModuleEdgeResponse[];
+}
+
+export interface EgoGraphResponse extends GraphLike<GraphNodeResponse> {
+ center_node_id: string;
+ center_git_meta: GitMetadataResponse | null;
+ inbound_count: number;
+ outbound_count: number;
+}
+
+export interface NodeSearchResult {
+ node_id: string;
+ language: string;
+ symbol_count: number;
+}
+
+export interface DeadCodeGraphNodeResponse {
+ node_id: string;
+ node_type: string;
+ language: string;
+ symbol_count: number;
+ pagerank: number;
+ betweenness: number;
+ community_id: number;
+ is_test: boolean;
+ is_entry_point: boolean;
+ has_doc: boolean;
+ confidence_group: string;
+}
+
+export type DeadCodeGraphResponse = GraphLike<DeadCodeGraphNodeResponse>;
+
+export interface HotFilesNodeResponse {
+ node_id: string;
+ node_type: string;
+ language: string;
+ symbol_count: number;
+ pagerank: number;
+ betweenness: number;
+ community_id: number;
+ is_test: boolean;
+ is_entry_point: boolean;
+ has_doc: boolean;
+ commit_count: number;
+}
+
+export type HotFilesGraphResponse = GraphLike<HotFilesNodeResponse>;
+
+export interface RepoStatsResponse {
+ file_count: number;
+ symbol_count: number;
+ entry_point_count: number;
+ doc_coverage_pct: number;
+ freshness_score: number;
+ dead_export_count: number;
+}
diff --git a/packages/web/src/lib/api/types/intelligence.ts b/packages/web/src/lib/api/types/intelligence.ts
new file mode 100644
index 000000000..4caeb9931
--- /dev/null
+++ b/packages/web/src/lib/api/types/intelligence.ts
@@ -0,0 +1,94 @@
+// ---------------------------------------------------------------------------
+// Graph Intelligence
+// ---------------------------------------------------------------------------
+
+export interface SymbolNodeSummary {
+ symbol_id: string;
+ name: string;
+ kind: string;
+ file: string;
+ start_line?: number | null;
+ signature?: string | null;
+}
+
+export interface CallerCalleeEntry {
+ symbol_id: string;
+ name: string;
+ kind: string;
+ file: string;
+ start_line?: number | null;
+ edge_type: string;
+ confidence: number;
+}
+
+export interface CallersCalleesResponse {
+ symbol_id: string;
+ symbol: SymbolNodeSummary;
+ callers: CallerCalleeEntry[];
+ callees: CallerCalleeEntry[];
+ caller_count: number;
+ callee_count: number;
+ truncated: boolean;
+}
+
+export interface CommunityMember {
+ path: string;
+ pagerank: number;
+ is_entry_point: boolean;
+}
+
+export interface NeighboringCommunity {
+ community_id: number;
+ label: string;
+ cross_edge_count: number;
+}
+
+export interface CommunityDetailResponse {
+ community_id: number;
+ label: string;
+ cohesion: number;
+ member_count: number;
+ members: CommunityMember[];
+ truncated: boolean;
+ neighboring_communities: NeighboringCommunity[];
+}
+
+export interface CommunitySummaryItem {
+ community_id: number;
+ label: string;
+ cohesion: number;
+ member_count: number;
+ top_file: string;
+}
+
+export interface GraphMetricsResponse {
+ target: string;
+ node_type: string;
+ pagerank: number;
+ pagerank_percentile: number;
+ betweenness: number;
+ betweenness_percentile: number;
+ community_id: number;
+ community_label: string | null;
+ is_entry_point: boolean;
+ in_degree: number;
+ out_degree: number;
+ entry_point_score?: number | null;
+ kind?: string | null;
+ file?: string | null;
+}
+
+export interface ExecutionFlowEntry {
+ entry_point: string;
+ entry_point_name: string;
+ entry_point_score: number;
+ trace: string[];
+ depth: number;
+ crosses_community: boolean;
+ communities_visited: number[];
+}
+
+export interface ExecutionFlowsResponse {
+ total_entry_points: number;
+ flows: ExecutionFlowEntry[];
+}
diff --git a/packages/web/src/lib/api/types/misc.ts b/packages/web/src/lib/api/types/misc.ts
new file mode 100644
index 000000000..4ae4957a8
--- /dev/null
+++ b/packages/web/src/lib/api/types/misc.ts
@@ -0,0 +1,47 @@
+// ---------------------------------------------------------------------------
+// Health
+// ---------------------------------------------------------------------------
+
+export interface HealthResponse {
+ status: string;
+ db: string;
+ version: string;
+}
+
+// ---------------------------------------------------------------------------
+// Webhooks
+// ---------------------------------------------------------------------------
+
+export interface WebhookResponse {
+ event_id: string;
+ status: string;
+}
+
+// ---------------------------------------------------------------------------
+// Providers
+// ---------------------------------------------------------------------------
+
+export interface ProviderInfo {
+ id: string;
+ name: string;
+ models: string[];
+ default_model: string;
+ configured: boolean;
+}
+
+export interface ProvidersResponse {
+ active: {
+ provider: string | null;
+ model: string | null;
+ };
+ providers: ProviderInfo[];
+}
+
+// ---------------------------------------------------------------------------
+// API error
+// ---------------------------------------------------------------------------
+
+export interface ApiError {
+ detail: string;
+ status: number;
+}
diff --git a/packages/web/src/lib/api/types/ownership.ts b/packages/web/src/lib/api/types/ownership.ts
new file mode 100644
index 000000000..227ea6232
--- /dev/null
+++ b/packages/web/src/lib/api/types/ownership.ts
@@ -0,0 +1,117 @@
+// ---------------------------------------------------------------------------
+// Owner / contributor profile
+// ---------------------------------------------------------------------------
+
+export interface OwnerListEntry {
+ key: string;
+ name: string;
+ email: string | null;
+ files_owned: number;
+ hotspots_owned: number;
+ silo_modules: number;
+ dead_code_files_owned: number;
+ dead_code_lines_owned: number;
+ commit_count_90d: number;
+ last_commit_at: string | null;
+ bus_factor_risk_files: number;
+}
+
+export interface OwnerModuleRollup {
+ module_path: string;
+ file_count: number;
+ hotspot_count: number;
+ dominant_pct: number;
+}
+
+export interface OwnerFileEntry {
+ file_path: string;
+ commit_count_90d: number;
+ churn_percentile: number;
+ bus_factor: number;
+ is_hotspot: boolean;
+ last_commit_at: string | null;
+ primary_owner_commit_pct: number | null;
+}
+
+export interface OwnerCoAuthor {
+ name: string;
+ email: string | null;
+ shared_files: number;
+ co_change_strength: number;
+}
+
+export interface OwnerProfileResponse {
+ key: string;
+ name: string;
+ email: string | null;
+ files_owned: number;
+ hotspots_owned: number;
+ silo_modules: number;
+ dead_code_files_owned: number;
+ dead_code_lines_owned: number;
+ commit_count_90d: number;
+ last_commit_at: string | null;
+ first_commit_at: string | null;
+ bus_factor_risk_files: number;
+ lines_added_90d_est: number;
+ lines_deleted_90d_est: number;
+ modules: OwnerModuleRollup[];
+ top_files: OwnerFileEntry[];
+ co_authors: OwnerCoAuthor[];
+ commit_categories: Record<string, number>;
+}
+
+// ---------------------------------------------------------------------------
+// Module health
+// ---------------------------------------------------------------------------
+
+export interface ModuleHealthOwner {
+ name: string;
+ email: string | null;
+ file_count: number;
+ pct: number;
+}
+
+export interface ModuleHealthSummary {
+ module_path: string;
+ file_count: number;
+ symbol_count: number;
+ hotspot_count: number;
+ dead_code_count: number;
+ dead_code_lines: number;
+ avg_churn_percentile: number;
+ median_bus_factor: number;
+ min_bus_factor: number;
+ primary_owner: string | null;
+ primary_owner_pct: number;
+ is_silo: boolean;
+ decision_count: number;
+ doc_coverage_pct: number;
+ health_score: number;
+}
+
+export interface ModuleHealthDetail extends ModuleHealthSummary {
+ owners: ModuleHealthOwner[];
+ top_hotspots: string[];
+ governing_decisions: string[];
+ contributor_count: number;
+}
+
+// ---------------------------------------------------------------------------
+// Reviewer suggestions
+// ---------------------------------------------------------------------------
+
+export interface ReviewerSuggestion {
+ name: string;
+ email: string | null;
+ score: number;
+ recent_commits: number;
+ owned_paths: string[];
+ co_change_paths: string[];
+ reasons: string[];
+}
+
+export interface ReviewerSuggestionsResponse {
+ paths: string[];
+ suggestions: ReviewerSuggestion[];
+}
diff --git a/packages/web/src/lib/api/types/pages.ts b/packages/web/src/lib/api/types/pages.ts
new file mode 100644
index 000000000..dbca78256
--- /dev/null
+++ b/packages/web/src/lib/api/types/pages.ts
@@ -0,0 +1,83 @@
+// ---------------------------------------------------------------------------
+// Pages
+// ---------------------------------------------------------------------------
+
+export interface PageResponse {
+ id: string;
+ repository_id: string;
+ page_type: string;
+ title: string;
+ content: string;
+ target_path: string;
+ source_hash: string;
+ model_name: string;
+ provider_name: string;
+ input_tokens: number;
+ output_tokens: number;
+ cached_tokens: number;
+ generation_level: number;
+ version: number;
+ confidence: number;
+ freshness_status: string;
+ metadata: Record<string, unknown>;
+ human_notes: string | null;
+ created_at: string;
+ updated_at: string;
+}
+
+export interface PageVersionResponse {
+ id: string;
+ page_id: string;
+ version: number;
+ page_type: string;
+ title: string;
+ content: string;
+ source_hash: string;
+ model_name: string;
+ provider_name: string;
+ input_tokens: number;
+ output_tokens: number;
+ confidence: number;
+ archived_at: string;
+}
+
+export interface PageListResponse {
+ pages: PageResponse[];
+ total: number;
+}
+
+// ---------------------------------------------------------------------------
+// Jobs
+// ---------------------------------------------------------------------------
+
+export interface JobResponse {
+ id: string;
+ repository_id: string;
+ status: "pending" | "running" | "completed" | "failed" | "paused";
+ provider_name: string;
+ model_name: string;
+ total_pages: number;
+ completed_pages: number;
+ failed_pages: number;
+ current_level: number;
+ error_message: string | null;
+ config: Record<string, unknown>;
+ created_at: string;
+ updated_at: string;
+ started_at: string | null;
+ finished_at: string | null;
+}
+
+export interface JobProgressEvent {
+ event: "progress" | "done" | "error";
+ job_id: string;
+ completed_pages: number;
+ total_pages: number;
+ current_page?: string;
+ current_level?: number;
+ tokens_input?: number;
+ tokens_output?: number;
+ estimated_cost?: number;
+ actual_cost_usd?: number | null;
+ error?: string;
+}
diff --git a/packages/web/src/lib/api/types/pagination.ts b/packages/web/src/lib/api/types/pagination.ts
new file mode 100644
index 000000000..26bbb4821
--- /dev/null
+++ b/packages/web/src/lib/api/types/pagination.ts
@@ -0,0 +1,10 @@
+/**
+ * Pagination envelope returned by list endpoints. Mirrors
+ * ``repowise.server.schemas.Paginated[T]``.
+ */
+export interface Paginated<T> {
+ items: T[];
+ total: number;
+ has_more: boolean;
+ next_offset: number | null;
+}
diff --git a/packages/web/src/lib/api/types/repository.ts b/packages/web/src/lib/api/types/repository.ts
new file mode 100644
index 000000000..0ebf5a651
--- /dev/null
+++ b/packages/web/src/lib/api/types/repository.ts
@@ -0,0 +1,41 @@
+// ---------------------------------------------------------------------------
+// Repository
+// ---------------------------------------------------------------------------
+
+export interface RepoCreate {
+ name: string;
+ local_path: string;
+ url?: string;
+ default_branch?: string;
+ settings?: Record<string, unknown>;
+}
+
+export interface RepoUpdate {
+ name?: string;
+ url?: string;
+ default_branch?: string;
+ settings?: {
+ exclude_patterns?: string[];
+ [key: string]: unknown;
+ };
+}
+
+export interface RepoResponse {
+ id: string;
+ name: string;
+ url: string;
+ local_path: string;
+ default_branch: string;
+ head_commit: string | null;
+ settings: Record<string, unknown>;
+ created_at: string;
+ updated_at: string;
+ // Workspace mode (optional — only populated when the server runs in
+ // workspace mode). Unindexed repos appear as synthetic rows with
+ // `id="ws:<alias>"` and `workspace_status === "needs_index"`.
+ workspace_alias?: string | null;
+ workspace_status?: "indexed" | "needs_index" | "missing_dir" | null;
+ is_primary?: boolean | null;
+ docs_enabled?: boolean | null;
+ docs_skip_reason?: string | null;
+}
diff --git a/packages/web/src/lib/api/types/search.ts b/packages/web/src/lib/api/types/search.ts
new file mode 100644
index 000000000..4ae516e9b
--- /dev/null
+++ b/packages/web/src/lib/api/types/search.ts
@@ -0,0 +1,19 @@
+// ---------------------------------------------------------------------------
+// Search
+// ---------------------------------------------------------------------------
+
+export interface SearchRequest {
+ query: string;
+ search_type?: "semantic" | "fulltext";
+ limit?: number;
+}
+
+export interface SearchResultResponse {
+ page_id: string;
+ title: string;
+ page_type: string;
+ target_path: string;
+ score: number;
+ snippet: string;
+ search_type: string;
+}
diff --git a/packages/web/src/lib/api/types/symbols.ts b/packages/web/src/lib/api/types/symbols.ts
new file mode 100644
index 000000000..8001e23bc
--- /dev/null
+++ b/packages/web/src/lib/api/types/symbols.ts
@@ -0,0 +1,36 @@
+// ---------------------------------------------------------------------------
+// Symbols
+// ---------------------------------------------------------------------------
+
+export interface SymbolImportanceComponents {
+ file_pagerank: number;
+ visibility_factor: number;
+ complexity_norm: number;
+ kind_boost: number;
+ is_entry_point: boolean;
+}
+
+export interface SymbolResponse {
+ id: string;
+ repository_id: string;
+ file_path: string;
+ symbol_id: string;
+ name: string;
+ qualified_name: string;
+ kind: string;
+ signature: string;
+ start_line: number;
+ end_line: number;
+ docstring: string | null;
+ visibility: string;
+ is_async: boolean;
+ complexity_estimate: number;
+ language: string;
+ parent_name: string | null;
+ importance_score?: number | null;
+ importance_components?: SymbolImportanceComponents | null;
+ file_pagerank?: number | null;
+ is_entry_point?: boolean | null;
+ file_churn_percentile?: number | null;
+ file_is_hotspot?: boolean | null;
+}
diff --git a/packages/web/src/lib/api/types/workspace.ts b/packages/web/src/lib/api/types/workspace.ts
new file mode 100644
index 000000000..455ba9852
--- /dev/null
+++ b/packages/web/src/lib/api/types/workspace.ts
@@ -0,0 +1,125 @@
+// ---------------------------------------------------------------------------
+// Workspace
+// ---------------------------------------------------------------------------
+
+export interface WorkspaceRepoEntry {
+ alias: string;
+ path: string;
+ is_primary: boolean;
+ indexed_at: string | null;
+ last_commit_at_index: string | null;
+ // Per-repo stats from each repo's wiki.db
+ repo_id: string | null;
+ file_count: number;
+ symbol_count: number;
+ page_count: number;
+ doc_coverage_pct: number;
+ hotspot_count: number;
+ // Phase B server augmentation
+ status?: "indexed" | "needs_index" | "missing_dir" | null;
+ docs_enabled?: boolean | null;
+ docs_skip_reason?: string | null;
+}
+
+export interface WorkspaceSyncResult {
+ alias: string;
+ repo_id: string | null;
+ status: "accepted" | "skipped" | "error";
+ job_id: string | null;
+ reason: string | null;
+}
+
+export interface WorkspaceSyncResponse {
+ results: WorkspaceSyncResult[];
+}
+
+export interface WorkspaceCrossRepoSummary {
+ co_change_count: number;
+ package_dep_count: number;
+ top_connections: Array<{ repos: string[]; edge_count: number }>;
+}
+
+export interface WorkspaceContractSummary {
+ total_contracts: number;
+ total_links: number;
+ by_type: Record<string, number>;
+}
+
+export interface WorkspaceResponse {
+ is_workspace: boolean;
+ workspace_root: string | null;
+ workspace_name: string | null;
+ repos: WorkspaceRepoEntry[];
+ default_repo: string | null;
+ cross_repo_summary: WorkspaceCrossRepoSummary | null;
+ contract_summary: WorkspaceContractSummary | null;
+}
+
+export interface WorkspaceContractEntry {
+ contract_id: string;
+ contract_type: string;
+ role: string;
+ repo: string;
+ file_path: string;
+ symbol_name: string;
+ confidence: number;
+ service: string | null;
+}
+
+export interface WorkspaceContractLinkEntry {
+ contract_id: string;
+ contract_type: string;
+ match_type: string;
+ confidence: number;
+ provider_repo: string;
+ provider_file: string;
+ provider_symbol: string;
+ consumer_repo: string;
+ consumer_file: string;
+ consumer_symbol: string;
+}
+
+export interface WorkspaceContractsResponse {
+ contracts: WorkspaceContractEntry[];
+ links: WorkspaceContractLinkEntry[];
+ total_contracts: number;
+ total_links: number;
+ by_type: Record<string, number>;
+}
+
+export interface WorkspaceCoChangeEntry {
+ source_repo: string;
+ source_file: string;
+ target_repo: string;
+ target_file: string;
+ strength: number;
+ frequency: number;
+ last_date: string;
+}
+
+export interface WorkspaceCoChangesResponse {
+ co_changes: WorkspaceCoChangeEntry[];
+ total: number;
+}
+
+export interface WorkspaceGraphNode {
+ repo_id: string;
+ name: string;
+ file_count: number;
+ coverage_pct: number;
+ health_score: number;
+ top_language: string;
+}
+
+export interface WorkspaceGraphEdge {
+ source: string;
+ target: string;
+ type: "contract" | "co_change";
+ strength: number;
+ label: string | null;
+}
+
+export interface WorkspaceGraphResponse {
+ nodes: WorkspaceGraphNode[];
+ edges: WorkspaceGraphEdge[];
+}