ragcode-context-engine 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +366 -0
- package/README.zh-CN.md +363 -0
- package/dist/src/cli/configure/app.d.ts +6 -0
- package/dist/src/cli/configure/app.js +81 -0
- package/dist/src/cli/configure/run.d.ts +5 -0
- package/dist/src/cli/configure/run.js +85 -0
- package/dist/src/cli/configure/state.d.ts +42 -0
- package/dist/src/cli/configure/state.js +174 -0
- package/dist/src/cli/configure.d.ts +31 -0
- package/dist/src/cli/configure.js +101 -0
- package/dist/src/cli/index.d.ts +2 -0
- package/dist/src/cli/index.js +503 -0
- package/dist/src/cli/tui/index-progress.d.ts +12 -0
- package/dist/src/cli/tui/index-progress.js +49 -0
- package/dist/src/cli/tui/watch-status.d.ts +10 -0
- package/dist/src/cli/tui/watch-status.js +27 -0
- package/dist/src/cli/update.d.ts +18 -0
- package/dist/src/cli/update.js +111 -0
- package/dist/src/config/dotenv.d.ts +1 -0
- package/dist/src/config/dotenv.js +14 -0
- package/dist/src/config/graph-runtime.d.ts +13 -0
- package/dist/src/config/graph-runtime.js +29 -0
- package/dist/src/config/runtime-config.d.ts +87 -0
- package/dist/src/config/runtime-config.js +215 -0
- package/dist/src/config/semantic-runtime.d.ts +24 -0
- package/dist/src/config/semantic-runtime.js +89 -0
- package/dist/src/context/context-builder.d.ts +20 -0
- package/dist/src/context/context-builder.js +277 -0
- package/dist/src/context/expansion-policy.d.ts +6 -0
- package/dist/src/context/expansion-policy.js +49 -0
- package/dist/src/context/skeletonizer.d.ts +2 -0
- package/dist/src/context/skeletonizer.js +79 -0
- package/dist/src/context/snippet-renderer.d.ts +2 -0
- package/dist/src/context/snippet-renderer.js +67 -0
- package/dist/src/core/contracts.d.ts +74 -0
- package/dist/src/core/contracts.js +1 -0
- package/dist/src/core/engine.d.ts +64 -0
- package/dist/src/core/engine.js +442 -0
- package/dist/src/core/types.d.ts +490 -0
- package/dist/src/core/types.js +1 -0
- package/dist/src/diagnostics/doctor.d.ts +66 -0
- package/dist/src/diagnostics/doctor.js +193 -0
- package/dist/src/diagnostics/embedding-test.d.ts +24 -0
- package/dist/src/diagnostics/embedding-test.js +83 -0
- package/dist/src/graph/diff-files.d.ts +1 -0
- package/dist/src/graph/diff-files.js +14 -0
- package/dist/src/graph/impact-report.d.ts +10 -0
- package/dist/src/graph/impact-report.js +173 -0
- package/dist/src/graph/in-memory-graph-store.d.ts +36 -0
- package/dist/src/graph/in-memory-graph-store.js +395 -0
- package/dist/src/graph/owner-ranking.d.ts +2 -0
- package/dist/src/graph/owner-ranking.js +41 -0
- package/dist/src/graph/sqlite-graph-store.d.ts +51 -0
- package/dist/src/graph/sqlite-graph-store.js +724 -0
- package/dist/src/graph/sqlite-statements.d.ts +36 -0
- package/dist/src/graph/sqlite-statements.js +105 -0
- package/dist/src/graph/target-matcher.d.ts +13 -0
- package/dist/src/graph/target-matcher.js +64 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/index.js +32 -0
- package/dist/src/indexing/analyzers/fallback-analyzer.d.ts +6 -0
- package/dist/src/indexing/analyzers/fallback-analyzer.js +45 -0
- package/dist/src/indexing/analyzers/go-treesitter-analyzer.d.ts +2 -0
- package/dist/src/indexing/analyzers/go-treesitter-analyzer.js +87 -0
- package/dist/src/indexing/analyzers/java-treesitter-analyzer.d.ts +2 -0
- package/dist/src/indexing/analyzers/java-treesitter-analyzer.js +88 -0
- package/dist/src/indexing/analyzers/python-treesitter-analyzer.d.ts +2 -0
- package/dist/src/indexing/analyzers/python-treesitter-analyzer.js +96 -0
- package/dist/src/indexing/analyzers/registry.d.ts +5 -0
- package/dist/src/indexing/analyzers/registry.js +23 -0
- package/dist/src/indexing/analyzers/rust-treesitter-analyzer.d.ts +2 -0
- package/dist/src/indexing/analyzers/rust-treesitter-analyzer.js +96 -0
- package/dist/src/indexing/analyzers/tree-sitter-base.d.ts +30 -0
- package/dist/src/indexing/analyzers/tree-sitter-base.js +163 -0
- package/dist/src/indexing/analyzers/types.d.ts +17 -0
- package/dist/src/indexing/analyzers/types.js +1 -0
- package/dist/src/indexing/analyzers/typescript-analyzer.d.ts +5 -0
- package/dist/src/indexing/analyzers/typescript-analyzer.js +199 -0
- package/dist/src/indexing/ast-analyzer.d.ts +11 -0
- package/dist/src/indexing/ast-analyzer.js +11 -0
- package/dist/src/indexing/chunker.d.ts +11 -0
- package/dist/src/indexing/chunker.js +157 -0
- package/dist/src/indexing/ignore-policy.d.ts +6 -0
- package/dist/src/indexing/ignore-policy.js +40 -0
- package/dist/src/indexing/indexer.d.ts +13 -0
- package/dist/src/indexing/indexer.js +189 -0
- package/dist/src/indexing/language.d.ts +3 -0
- package/dist/src/indexing/language.js +24 -0
- package/dist/src/indexing/scanner.d.ts +13 -0
- package/dist/src/indexing/scanner.js +87 -0
- package/dist/src/lsp/definition-resolver.d.ts +6 -0
- package/dist/src/lsp/definition-resolver.js +60 -0
- package/dist/src/lsp/typescript-language-service.d.ts +21 -0
- package/dist/src/lsp/typescript-language-service.js +82 -0
- package/dist/src/mcp/server.d.ts +11 -0
- package/dist/src/mcp/server.js +64 -0
- package/dist/src/mcp/tools.d.ts +266 -0
- package/dist/src/mcp/tools.js +309 -0
- package/dist/src/project/project-identity.d.ts +2 -0
- package/dist/src/project/project-identity.js +24 -0
- package/dist/src/project/project-registry.d.ts +12 -0
- package/dist/src/project/project-registry.js +49 -0
- package/dist/src/project/workspace-resolver.d.ts +20 -0
- package/dist/src/project/workspace-resolver.js +62 -0
- package/dist/src/retrieval/graph-reranker.d.ts +11 -0
- package/dist/src/retrieval/graph-reranker.js +0 -0
- package/dist/src/retrieval/hybrid-retriever.d.ts +31 -0
- package/dist/src/retrieval/hybrid-retriever.js +111 -0
- package/dist/src/retrieval/path-classification.d.ts +6 -0
- package/dist/src/retrieval/path-classification.js +22 -0
- package/dist/src/retrieval/query-matching.d.ts +22 -0
- package/dist/src/retrieval/query-matching.js +166 -0
- package/dist/src/retrieval/query-planner.d.ts +5 -0
- package/dist/src/retrieval/query-planner.js +77 -0
- package/dist/src/retrieval/ranking-signals.d.ts +19 -0
- package/dist/src/retrieval/ranking-signals.js +97 -0
- package/dist/src/retrieval/topology-distance.d.ts +21 -0
- package/dist/src/retrieval/topology-distance.js +116 -0
- package/dist/src/reuse/reuse-detector.d.ts +12 -0
- package/dist/src/reuse/reuse-detector.js +564 -0
- package/dist/src/semantic/deterministic-embedding.d.ts +7 -0
- package/dist/src/semantic/deterministic-embedding.js +31 -0
- package/dist/src/semantic/in-memory-semantic-store.d.ts +11 -0
- package/dist/src/semantic/in-memory-semantic-store.js +65 -0
- package/dist/src/semantic/lance-semantic-store.d.ts +131 -0
- package/dist/src/semantic/lance-semantic-store.js +623 -0
- package/dist/src/semantic/openai-compatible-embedding.d.ts +19 -0
- package/dist/src/semantic/openai-compatible-embedding.js +75 -0
- package/dist/src/service/service-identity.d.ts +13 -0
- package/dist/src/service/service-identity.js +48 -0
- package/dist/src/service/service-manager.d.ts +29 -0
- package/dist/src/service/service-manager.js +231 -0
- package/dist/src/service/service-templates.d.ts +22 -0
- package/dist/src/service/service-templates.js +101 -0
- package/dist/src/subgraph/impact-explainer.d.ts +2 -0
- package/dist/src/subgraph/impact-explainer.js +54 -0
- package/dist/src/subgraph/node-expander.d.ts +13 -0
- package/dist/src/subgraph/node-expander.js +139 -0
- package/dist/src/subgraph/output-preset.d.ts +3 -0
- package/dist/src/subgraph/output-preset.js +102 -0
- package/dist/src/subgraph/subgraph-builder.d.ts +17 -0
- package/dist/src/subgraph/subgraph-builder.js +688 -0
- package/dist/src/topology/export-index.d.ts +7 -0
- package/dist/src/topology/export-index.js +14 -0
- package/dist/src/topology/framework-topology.d.ts +3 -0
- package/dist/src/topology/framework-topology.js +460 -0
- package/dist/src/topology/import-resolver.d.ts +2 -0
- package/dist/src/topology/import-resolver.js +29 -0
- package/dist/src/topology/orm-topology.d.ts +3 -0
- package/dist/src/topology/orm-topology.js +200 -0
- package/dist/src/topology/runtime-topology.d.ts +3 -0
- package/dist/src/topology/runtime-topology.js +204 -0
- package/dist/src/topology/symbol-resolver.d.ts +6 -0
- package/dist/src/topology/symbol-resolver.js +74 -0
- package/dist/src/topology/test-topology.d.ts +2 -0
- package/dist/src/topology/test-topology.js +82 -0
- package/dist/src/utils/hash.d.ts +2 -0
- package/dist/src/utils/hash.js +7 -0
- package/dist/src/utils/path.d.ts +2 -0
- package/dist/src/utils/path.js +7 -0
- package/dist/src/watch/event-journal.d.ts +17 -0
- package/dist/src/watch/event-journal.js +81 -0
- package/dist/src/watch/file-event-coalescer.d.ts +9 -0
- package/dist/src/watch/file-event-coalescer.js +39 -0
- package/dist/src/watch/index-scheduler.d.ts +52 -0
- package/dist/src/watch/index-scheduler.js +190 -0
- package/dist/src/watch/watch-daemon.d.ts +73 -0
- package/dist/src/watch/watch-daemon.js +368 -0
- package/dist/src/watch/watcher-liveness.d.ts +47 -0
- package/dist/src/watch/watcher-liveness.js +168 -0
- package/dist/src/web/server.d.ts +1 -0
- package/dist/src/web/server.js +375 -0
- package/package.json +94 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
export type LanguageId = "typescript" | "javascript" | "python" | "rust" | "go" | "java" | "markdown" | "json" | "unknown";
|
|
2
|
+
export type ChunkKind = "file" | "function" | "class" | "method" | "type" | "variable" | "block";
|
|
3
|
+
export type ContextMode = "auto" | "debug" | "feature" | "refactor" | "review" | "explain";
|
|
4
|
+
export interface CodeFile {
|
|
5
|
+
projectId: string;
|
|
6
|
+
path: string;
|
|
7
|
+
absolutePath: string;
|
|
8
|
+
language: LanguageId;
|
|
9
|
+
sizeBytes: number;
|
|
10
|
+
contentHash: string;
|
|
11
|
+
modifiedAtMs: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CodeChunk {
|
|
14
|
+
id: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
repoRoot: string;
|
|
17
|
+
filePath: string;
|
|
18
|
+
language: LanguageId;
|
|
19
|
+
kind: ChunkKind;
|
|
20
|
+
symbolName?: string;
|
|
21
|
+
startLine: number;
|
|
22
|
+
endLine: number;
|
|
23
|
+
content: string;
|
|
24
|
+
contentHash: string;
|
|
25
|
+
}
|
|
26
|
+
export type SymbolKind = "file" | "function" | "class" | "method" | "type" | "variable" | "unknown";
|
|
27
|
+
export interface SymbolNode {
|
|
28
|
+
id: string;
|
|
29
|
+
projectId: string;
|
|
30
|
+
filePath: string;
|
|
31
|
+
name: string;
|
|
32
|
+
kind: SymbolKind;
|
|
33
|
+
language: LanguageId;
|
|
34
|
+
startLine: number;
|
|
35
|
+
endLine: number;
|
|
36
|
+
signature?: string;
|
|
37
|
+
exported?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export type EdgeKind = "contains" | "imports" | "exports" | "calls" | "references" | "tested_by" | "related" | "handles_event" | "calls_api" | "routes_to" | "uses_middleware" | "handles_webhook" | "reads_from" | "writes_to";
|
|
40
|
+
export interface GraphEdge {
|
|
41
|
+
projectId: string;
|
|
42
|
+
sourceId: string;
|
|
43
|
+
targetId: string;
|
|
44
|
+
kind: EdgeKind;
|
|
45
|
+
metadata?: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
export interface RepoIndex {
|
|
48
|
+
projectId: string;
|
|
49
|
+
project?: ProjectIdentity;
|
|
50
|
+
repoRoot: string;
|
|
51
|
+
indexedAtMs: number;
|
|
52
|
+
indexGeneration: number;
|
|
53
|
+
changedFiles: string[];
|
|
54
|
+
deletedFiles: string[];
|
|
55
|
+
affectedFiles?: string[];
|
|
56
|
+
scannedFiles?: string[];
|
|
57
|
+
refreshedFiles?: string[];
|
|
58
|
+
fullReindex: boolean;
|
|
59
|
+
files: CodeFile[];
|
|
60
|
+
chunks: CodeChunk[];
|
|
61
|
+
symbols: SymbolNode[];
|
|
62
|
+
edges: GraphEdge[];
|
|
63
|
+
skippedFiles: Array<{
|
|
64
|
+
filePath: string;
|
|
65
|
+
reason: string;
|
|
66
|
+
}>;
|
|
67
|
+
}
|
|
68
|
+
export type IndexProgressPhase = "loading_existing_index" | "scanning" | "analyzing" | "writing_graph" | "writing_semantic" | "complete";
|
|
69
|
+
export interface IndexProgressEvent {
|
|
70
|
+
phase: IndexProgressPhase;
|
|
71
|
+
message: string;
|
|
72
|
+
scannedFiles?: number;
|
|
73
|
+
changedFiles?: number;
|
|
74
|
+
deletedFiles?: number;
|
|
75
|
+
refreshedFiles?: number;
|
|
76
|
+
chunks?: number;
|
|
77
|
+
symbols?: number;
|
|
78
|
+
edges?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface IndexRefreshOptions {
|
|
81
|
+
affectedFiles?: string[];
|
|
82
|
+
reconcile?: boolean;
|
|
83
|
+
onProgress?: (event: IndexProgressEvent) => void;
|
|
84
|
+
}
|
|
85
|
+
export type DirtyFileStatus = "pending" | "indexing" | "dead_letter";
|
|
86
|
+
export interface DirtyFile {
|
|
87
|
+
projectId: string;
|
|
88
|
+
filePath: string;
|
|
89
|
+
status: DirtyFileStatus;
|
|
90
|
+
reason: string;
|
|
91
|
+
firstSeenAtMs: number;
|
|
92
|
+
lastSeenAtMs: number;
|
|
93
|
+
eventCount: number;
|
|
94
|
+
}
|
|
95
|
+
export interface WatcherState {
|
|
96
|
+
projectId: string;
|
|
97
|
+
dirtyFiles: DirtyFile[];
|
|
98
|
+
pendingFiles: string[];
|
|
99
|
+
indexingFiles: string[];
|
|
100
|
+
burstMode: boolean;
|
|
101
|
+
droppedEvents: number;
|
|
102
|
+
lastEventAtMs?: number;
|
|
103
|
+
updatedAtMs?: number;
|
|
104
|
+
}
|
|
105
|
+
export interface WatcherEventOptions {
|
|
106
|
+
burstThreshold?: number;
|
|
107
|
+
maxDirtyFiles?: number;
|
|
108
|
+
}
|
|
109
|
+
export interface SearchQuery {
|
|
110
|
+
projectId?: string;
|
|
111
|
+
repoRoot?: string;
|
|
112
|
+
workspace?: WorkspaceHint;
|
|
113
|
+
query: string;
|
|
114
|
+
limit?: number;
|
|
115
|
+
mode?: ContextMode;
|
|
116
|
+
}
|
|
117
|
+
export interface SearchHit {
|
|
118
|
+
chunk: CodeChunk;
|
|
119
|
+
score: number;
|
|
120
|
+
scoreBreakdown?: SearchScoreBreakdown;
|
|
121
|
+
source: "exact" | "graph" | "semantic" | "keyword";
|
|
122
|
+
reason: string;
|
|
123
|
+
}
|
|
124
|
+
export interface SearchScoreBreakdown {
|
|
125
|
+
keyword?: number;
|
|
126
|
+
semantic?: number;
|
|
127
|
+
sourceNormalized?: number;
|
|
128
|
+
modeBoost?: number;
|
|
129
|
+
graphAdjustment?: number;
|
|
130
|
+
final: number;
|
|
131
|
+
}
|
|
132
|
+
export interface ContextRequest extends SearchQuery {
|
|
133
|
+
budgetChars?: number;
|
|
134
|
+
diff?: string;
|
|
135
|
+
changedFiles?: string[];
|
|
136
|
+
}
|
|
137
|
+
export type VerifiedSubgraphMode = "impact" | "flow" | "review" | "debug";
|
|
138
|
+
export type SubgraphOutputPreset = "compact" | "agent_edit" | "debug_trace" | "review_risk";
|
|
139
|
+
export interface VerifiedSubgraphRequest {
|
|
140
|
+
projectId?: string;
|
|
141
|
+
repoRoot?: string;
|
|
142
|
+
workspace?: WorkspaceHint;
|
|
143
|
+
query: string;
|
|
144
|
+
seed?: string;
|
|
145
|
+
mode?: VerifiedSubgraphMode;
|
|
146
|
+
budgetChars?: number;
|
|
147
|
+
maxHops?: number;
|
|
148
|
+
preset?: SubgraphOutputPreset;
|
|
149
|
+
}
|
|
150
|
+
export interface TopologyMapRequest extends SearchQuery {
|
|
151
|
+
budgetChars?: number;
|
|
152
|
+
maxEdges?: number;
|
|
153
|
+
}
|
|
154
|
+
export interface ContextSnippet {
|
|
155
|
+
filePath: string;
|
|
156
|
+
startLine: number;
|
|
157
|
+
endLine: number;
|
|
158
|
+
content: string;
|
|
159
|
+
score: number;
|
|
160
|
+
reason: string;
|
|
161
|
+
role: string;
|
|
162
|
+
expansionLevel: ExpansionLevel;
|
|
163
|
+
originalLineCount: number;
|
|
164
|
+
returnedLineCount: number;
|
|
165
|
+
elidedLineCount: number;
|
|
166
|
+
}
|
|
167
|
+
export interface ContextPack {
|
|
168
|
+
query: string;
|
|
169
|
+
repoRoot: string;
|
|
170
|
+
projectId: string;
|
|
171
|
+
mode: Exclude<ContextMode, "auto">;
|
|
172
|
+
answerable: boolean;
|
|
173
|
+
confidence: "low" | "medium" | "high";
|
|
174
|
+
brief: string;
|
|
175
|
+
freshness: FreshnessReport;
|
|
176
|
+
ownerChain: OwnerNode[];
|
|
177
|
+
topology: TopologyEdge[];
|
|
178
|
+
snippets: ContextSnippet[];
|
|
179
|
+
relationships: RelationshipEvidence[];
|
|
180
|
+
nextQueries: string[];
|
|
181
|
+
missingEvidence: string[];
|
|
182
|
+
budgetChars: number;
|
|
183
|
+
usedChars: number;
|
|
184
|
+
}
|
|
185
|
+
export type ExpansionLevel = "file_card" | "skeleton" | "focused_body" | "full_body";
|
|
186
|
+
export interface WorkspaceHint {
|
|
187
|
+
root?: string;
|
|
188
|
+
filePath?: string;
|
|
189
|
+
}
|
|
190
|
+
export interface ProjectIdentity {
|
|
191
|
+
projectId: string;
|
|
192
|
+
repoRoot: string;
|
|
193
|
+
canonicalRoot: string;
|
|
194
|
+
displayName: string;
|
|
195
|
+
gitRemote?: string;
|
|
196
|
+
gitHead?: string;
|
|
197
|
+
createdAtMs: number;
|
|
198
|
+
lastIndexedAtMs?: number;
|
|
199
|
+
}
|
|
200
|
+
export interface WorkspaceSession {
|
|
201
|
+
activeProjectId: string;
|
|
202
|
+
activeRepoRoot: string;
|
|
203
|
+
knownProjects: ProjectIdentity[];
|
|
204
|
+
resolvedFrom: "filePath" | "root" | "repoRoot" | "mcp_roots" | "cwd" | "single_project" | "active_session";
|
|
205
|
+
}
|
|
206
|
+
export interface FreshnessReport {
|
|
207
|
+
projectId: string;
|
|
208
|
+
indexGeneration: number;
|
|
209
|
+
indexedAtMs: number;
|
|
210
|
+
staleFiles: string[];
|
|
211
|
+
pendingFiles: string[];
|
|
212
|
+
indexingFiles: string[];
|
|
213
|
+
skippedFiles: Array<{
|
|
214
|
+
filePath: string;
|
|
215
|
+
reason: string;
|
|
216
|
+
}>;
|
|
217
|
+
dirtyFiles: DirtyFile[];
|
|
218
|
+
burstMode: boolean;
|
|
219
|
+
droppedEvents: number;
|
|
220
|
+
}
|
|
221
|
+
export interface OwnerNode {
|
|
222
|
+
filePath: string;
|
|
223
|
+
role: string;
|
|
224
|
+
reason: string;
|
|
225
|
+
score: number;
|
|
226
|
+
symbols: Array<{
|
|
227
|
+
name: string;
|
|
228
|
+
kind: string;
|
|
229
|
+
startLine: number;
|
|
230
|
+
endLine: number;
|
|
231
|
+
}>;
|
|
232
|
+
}
|
|
233
|
+
export interface TopologyEdge {
|
|
234
|
+
from: string;
|
|
235
|
+
to: string;
|
|
236
|
+
edge: EdgeKind;
|
|
237
|
+
confidence: "low" | "medium" | "high";
|
|
238
|
+
reason: string;
|
|
239
|
+
sourceFile?: string;
|
|
240
|
+
targetFile?: string;
|
|
241
|
+
}
|
|
242
|
+
export interface TopologyMap {
|
|
243
|
+
query: string;
|
|
244
|
+
repoRoot: string;
|
|
245
|
+
projectId: string;
|
|
246
|
+
freshness: FreshnessReport;
|
|
247
|
+
owners: OwnerNode[];
|
|
248
|
+
edges: TopologyEdge[];
|
|
249
|
+
missingEvidence: string[];
|
|
250
|
+
nextQueries: string[];
|
|
251
|
+
}
|
|
252
|
+
export interface IndexStatus {
|
|
253
|
+
repoRoot: string;
|
|
254
|
+
projectId: string;
|
|
255
|
+
indexedAtMs: number;
|
|
256
|
+
fileCount: number;
|
|
257
|
+
chunkCount: number;
|
|
258
|
+
symbolCount: number;
|
|
259
|
+
edgeCount: number;
|
|
260
|
+
freshFileCount: number;
|
|
261
|
+
staleFileCount: number;
|
|
262
|
+
pendingFileCount: number;
|
|
263
|
+
indexingFileCount: number;
|
|
264
|
+
skippedFileCount: number;
|
|
265
|
+
burstMode: boolean;
|
|
266
|
+
droppedEventCount: number;
|
|
267
|
+
freshness: FreshnessReport;
|
|
268
|
+
}
|
|
269
|
+
export interface RelationshipEvidence {
|
|
270
|
+
source: string;
|
|
271
|
+
target: string;
|
|
272
|
+
kind: EdgeKind;
|
|
273
|
+
reason: string;
|
|
274
|
+
}
|
|
275
|
+
export type SubgraphNodeRole = "target" | "caller" | "callee" | "route" | "test" | "middleware" | "resource" | "event" | "external";
|
|
276
|
+
export interface SubgraphCitation {
|
|
277
|
+
filePath?: string;
|
|
278
|
+
line?: number;
|
|
279
|
+
symbol?: string;
|
|
280
|
+
source: VerifiedEdgeSource;
|
|
281
|
+
}
|
|
282
|
+
export interface SubgraphNode {
|
|
283
|
+
id: string;
|
|
284
|
+
filePath: string;
|
|
285
|
+
symbolName?: string;
|
|
286
|
+
kind: SymbolKind | "external";
|
|
287
|
+
role: SubgraphNodeRole;
|
|
288
|
+
startLine?: number;
|
|
289
|
+
endLine?: number;
|
|
290
|
+
exported?: boolean;
|
|
291
|
+
confidence: "low" | "medium" | "high";
|
|
292
|
+
reason: string;
|
|
293
|
+
citation?: SubgraphCitation;
|
|
294
|
+
}
|
|
295
|
+
export type VerifiedEdgeSource = "ast" | "lsp" | "framework_rule" | "test_import" | "resource_rule" | "event_rule" | "heuristic";
|
|
296
|
+
export interface VerifiedSubgraphEdge {
|
|
297
|
+
fromNodeId: string;
|
|
298
|
+
toNodeId: string;
|
|
299
|
+
kind: EdgeKind;
|
|
300
|
+
confidence: "low" | "medium" | "high";
|
|
301
|
+
source: VerifiedEdgeSource;
|
|
302
|
+
reason: string;
|
|
303
|
+
sourceFile?: string;
|
|
304
|
+
targetFile?: string;
|
|
305
|
+
line?: number;
|
|
306
|
+
targetName?: string;
|
|
307
|
+
metadata?: Record<string, unknown>;
|
|
308
|
+
}
|
|
309
|
+
export type CoverageSignalName = "primary_owner_found" | "inbound_callers_checked" | "outbound_flow_checked" | "tests_checked" | "unresolved_edges_present" | "budget_truncated";
|
|
310
|
+
export interface CoverageSignal {
|
|
311
|
+
name: CoverageSignalName;
|
|
312
|
+
status: "pass" | "partial" | "fail";
|
|
313
|
+
detail: string;
|
|
314
|
+
}
|
|
315
|
+
export type EditReadiness = "safe_to_edit_after_reading" | "investigate_only" | "not_enough_context";
|
|
316
|
+
export interface CoverageSummary {
|
|
317
|
+
verdict: EditReadiness;
|
|
318
|
+
summary: string;
|
|
319
|
+
passed: number;
|
|
320
|
+
partial: number;
|
|
321
|
+
failed: number;
|
|
322
|
+
}
|
|
323
|
+
export interface WhyThisFileEvidence {
|
|
324
|
+
kind: EdgeKind;
|
|
325
|
+
confidence: "low" | "medium" | "high";
|
|
326
|
+
source: VerifiedEdgeSource;
|
|
327
|
+
reason: string;
|
|
328
|
+
sourceFile?: string;
|
|
329
|
+
targetFile?: string;
|
|
330
|
+
line?: number;
|
|
331
|
+
targetName?: string;
|
|
332
|
+
metadata?: Record<string, unknown>;
|
|
333
|
+
}
|
|
334
|
+
export interface WhyThisFile {
|
|
335
|
+
filePath: string;
|
|
336
|
+
roles: SubgraphNodeRole[];
|
|
337
|
+
confidence: "low" | "medium" | "high";
|
|
338
|
+
reasons: string[];
|
|
339
|
+
evidence: WhyThisFileEvidence[];
|
|
340
|
+
}
|
|
341
|
+
export interface VerifiedCodeSubgraph {
|
|
342
|
+
query: string;
|
|
343
|
+
repoRoot: string;
|
|
344
|
+
projectId: string;
|
|
345
|
+
mode: VerifiedSubgraphMode;
|
|
346
|
+
answerable: boolean;
|
|
347
|
+
confidence: "low" | "medium" | "high";
|
|
348
|
+
coverageSummary: CoverageSummary;
|
|
349
|
+
whyTheseFiles: WhyThisFile[];
|
|
350
|
+
nodes: SubgraphNode[];
|
|
351
|
+
edges: VerifiedSubgraphEdge[];
|
|
352
|
+
paths: string[][];
|
|
353
|
+
snippets: ContextSnippet[];
|
|
354
|
+
coverage: CoverageSignal[];
|
|
355
|
+
missingEvidence: string[];
|
|
356
|
+
nextQueries: string[];
|
|
357
|
+
budgetChars: number;
|
|
358
|
+
usedChars: number;
|
|
359
|
+
}
|
|
360
|
+
export interface ExplainImpactReport {
|
|
361
|
+
target: string;
|
|
362
|
+
riskLevel: "low" | "medium" | "high";
|
|
363
|
+
riskScore: number;
|
|
364
|
+
riskReasons: string[];
|
|
365
|
+
editReadiness: EditReadiness;
|
|
366
|
+
subgraph: VerifiedCodeSubgraph;
|
|
367
|
+
}
|
|
368
|
+
export interface ExpandNodeResult {
|
|
369
|
+
nodeRef: string;
|
|
370
|
+
filePath: string;
|
|
371
|
+
symbolName?: string;
|
|
372
|
+
expansionLevel: ExpansionLevel;
|
|
373
|
+
snippets: ContextSnippet[];
|
|
374
|
+
missingEvidence: string[];
|
|
375
|
+
budgetChars: number;
|
|
376
|
+
usedChars: number;
|
|
377
|
+
}
|
|
378
|
+
export interface ReuseCandidateRequest {
|
|
379
|
+
projectId?: string;
|
|
380
|
+
repoRoot?: string;
|
|
381
|
+
workspace?: WorkspaceHint;
|
|
382
|
+
query: string;
|
|
383
|
+
limit?: number;
|
|
384
|
+
reuseGuard?: boolean;
|
|
385
|
+
}
|
|
386
|
+
export type ReuseDecision = "reuse" | "extend" | "wrap" | "implement_new" | "uncertain";
|
|
387
|
+
export type ReuseCandidateKind = "helper" | "service_method" | "react_hook" | "component" | "api_wrapper" | "type_or_schema" | "test_fixture" | "config_constant" | "unknown";
|
|
388
|
+
export interface ReuseCandidate {
|
|
389
|
+
filePath: string;
|
|
390
|
+
symbolName?: string;
|
|
391
|
+
kind: ReuseCandidateKind;
|
|
392
|
+
score: number;
|
|
393
|
+
confidence: "low" | "medium" | "high";
|
|
394
|
+
exported: boolean;
|
|
395
|
+
callerCount: number;
|
|
396
|
+
relatedTestCount: number;
|
|
397
|
+
structuralSignals: {
|
|
398
|
+
bodyFingerprint?: string;
|
|
399
|
+
bodyDuplicateCount: number;
|
|
400
|
+
signatureSimilarity: number;
|
|
401
|
+
importOverlap: number;
|
|
402
|
+
calleeOverlap: number;
|
|
403
|
+
};
|
|
404
|
+
reasons: string[];
|
|
405
|
+
whyReuse: string[];
|
|
406
|
+
snippet?: ContextSnippet;
|
|
407
|
+
}
|
|
408
|
+
export interface ReuseGuard {
|
|
409
|
+
status: "allow_new" | "block_new" | "review_required";
|
|
410
|
+
reason: string;
|
|
411
|
+
candidates: Array<{
|
|
412
|
+
filePath: string;
|
|
413
|
+
symbolName?: string;
|
|
414
|
+
score: number;
|
|
415
|
+
confidence: "low" | "medium" | "high";
|
|
416
|
+
}>;
|
|
417
|
+
}
|
|
418
|
+
export interface ReuseCandidateReport {
|
|
419
|
+
query: string;
|
|
420
|
+
decision: ReuseDecision;
|
|
421
|
+
confidence: "low" | "medium" | "high";
|
|
422
|
+
candidates: ReuseCandidate[];
|
|
423
|
+
duplicateRisk: "low" | "medium" | "high";
|
|
424
|
+
reuseGuard: ReuseGuard;
|
|
425
|
+
missingEvidence: string[];
|
|
426
|
+
nextQueries: string[];
|
|
427
|
+
}
|
|
428
|
+
export interface OwnerCandidate {
|
|
429
|
+
filePath: string;
|
|
430
|
+
score: number;
|
|
431
|
+
reasons: string[];
|
|
432
|
+
symbols: SymbolNode[];
|
|
433
|
+
}
|
|
434
|
+
export interface ImpactAnalysis {
|
|
435
|
+
target: string;
|
|
436
|
+
minimalPack: ImpactPackItem[];
|
|
437
|
+
references: ImpactReference[];
|
|
438
|
+
nextQueries: string[];
|
|
439
|
+
matchedSymbols: SymbolNode[];
|
|
440
|
+
impactedFiles: string[];
|
|
441
|
+
incomingEdges: GraphEdge[];
|
|
442
|
+
outgoingEdges: GraphEdge[];
|
|
443
|
+
riskLevel: "low" | "medium" | "high";
|
|
444
|
+
}
|
|
445
|
+
export interface ImpactPackItem {
|
|
446
|
+
filePath: string;
|
|
447
|
+
role: "target" | "caller" | "callee" | "test" | "route" | "middleware" | "resource_owner" | "event_owner";
|
|
448
|
+
reason: string;
|
|
449
|
+
symbols: Array<{
|
|
450
|
+
name: string;
|
|
451
|
+
kind: SymbolKind;
|
|
452
|
+
startLine: number;
|
|
453
|
+
endLine: number;
|
|
454
|
+
}>;
|
|
455
|
+
}
|
|
456
|
+
export interface ImpactReference {
|
|
457
|
+
edge: EdgeKind;
|
|
458
|
+
sourceFile?: string;
|
|
459
|
+
targetFile?: string;
|
|
460
|
+
sourceSymbol?: string;
|
|
461
|
+
targetSymbol?: string;
|
|
462
|
+
targetName?: string;
|
|
463
|
+
reason: string;
|
|
464
|
+
confidence: "low" | "medium" | "high";
|
|
465
|
+
}
|
|
466
|
+
export interface RelatedTests {
|
|
467
|
+
target: string;
|
|
468
|
+
tests: CodeFile[];
|
|
469
|
+
references: ImpactReference[];
|
|
470
|
+
missingLikelyTests: string[];
|
|
471
|
+
}
|
|
472
|
+
export interface TraceStep {
|
|
473
|
+
filePath: string;
|
|
474
|
+
symbolName: string;
|
|
475
|
+
kind: EdgeKind;
|
|
476
|
+
targetName?: string;
|
|
477
|
+
targetFile?: string;
|
|
478
|
+
line?: number;
|
|
479
|
+
}
|
|
480
|
+
export interface TraceFlow {
|
|
481
|
+
entry: string;
|
|
482
|
+
steps: TraceStep[];
|
|
483
|
+
truncated: boolean;
|
|
484
|
+
}
|
|
485
|
+
export interface DiffReview {
|
|
486
|
+
changedFiles: string[];
|
|
487
|
+
relatedTests: string[];
|
|
488
|
+
riskLevel: "low" | "medium" | "high";
|
|
489
|
+
findings: string[];
|
|
490
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { IndexStatus, RepoIndex, SearchHit } from "../core/types.js";
|
|
2
|
+
import { type WatcherLivenessState } from "../watch/watcher-liveness.js";
|
|
3
|
+
export interface DoctorOptions {
|
|
4
|
+
cwd?: string;
|
|
5
|
+
env?: NodeJS.ProcessEnv;
|
|
6
|
+
repoRoot?: string;
|
|
7
|
+
searchQuery?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DoctorCheck {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
message: string;
|
|
12
|
+
details?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface DoctorReport {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
cwd: string;
|
|
17
|
+
node: DoctorCheck;
|
|
18
|
+
runtime: {
|
|
19
|
+
graph: DoctorCheck & {
|
|
20
|
+
config?: unknown;
|
|
21
|
+
};
|
|
22
|
+
semantic: DoctorCheck & {
|
|
23
|
+
config?: unknown;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
dependencies: {
|
|
27
|
+
sqlite: DoctorCheck;
|
|
28
|
+
lancedb: DoctorCheck;
|
|
29
|
+
mcpSdk: DoctorCheck;
|
|
30
|
+
};
|
|
31
|
+
mcp: DoctorCheck & {
|
|
32
|
+
toolCount: number;
|
|
33
|
+
tools: string[];
|
|
34
|
+
};
|
|
35
|
+
watcher?: DoctorCheck & {
|
|
36
|
+
state: WatcherLivenessState;
|
|
37
|
+
processAlive: boolean;
|
|
38
|
+
heartbeatFresh: boolean;
|
|
39
|
+
heartbeatAgeMs?: number;
|
|
40
|
+
pendingFiles?: number;
|
|
41
|
+
indexingFiles?: number;
|
|
42
|
+
};
|
|
43
|
+
smoke?: DoctorCheck & {
|
|
44
|
+
repoRoot: string;
|
|
45
|
+
indexed?: Pick<RepoIndex, "projectId" | "repoRoot" | "indexedAtMs"> & {
|
|
46
|
+
files: number;
|
|
47
|
+
chunks: number;
|
|
48
|
+
symbols: number;
|
|
49
|
+
edges: number;
|
|
50
|
+
skippedFiles: number;
|
|
51
|
+
};
|
|
52
|
+
status?: Pick<IndexStatus, "fileCount" | "chunkCount" | "symbolCount" | "edgeCount" | "staleFileCount" | "pendingFileCount" | "skippedFileCount">;
|
|
53
|
+
search?: {
|
|
54
|
+
query: string;
|
|
55
|
+
hits: Array<{
|
|
56
|
+
filePath: string;
|
|
57
|
+
startLine: number;
|
|
58
|
+
endLine: number;
|
|
59
|
+
score: number;
|
|
60
|
+
source: SearchHit["source"];
|
|
61
|
+
reason: string;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export declare function runDoctor(options?: DoctorOptions): Promise<DoctorReport>;
|