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,139 @@
|
|
|
1
|
+
import { skeletonizeChunk } from "../context/skeletonizer.js";
|
|
2
|
+
import { normalizeUserPath } from "../utils/path.js";
|
|
3
|
+
const DEFAULT_BUDGET_CHARS = 4_000;
|
|
4
|
+
const FOCUS_WINDOW_LINES = 36;
|
|
5
|
+
export function expandNode(input) {
|
|
6
|
+
const budgetChars = input.budgetChars ?? DEFAULT_BUDGET_CHARS;
|
|
7
|
+
const parsed = parseNodeRef(input.nodeRef);
|
|
8
|
+
const symbol = selectSymbol(input.symbols, parsed.filePath, parsed.symbolName);
|
|
9
|
+
const filePath = symbol?.filePath ?? parsed.filePath;
|
|
10
|
+
const symbolName = symbol?.kind === "file" ? parsed.symbolName : symbol?.name ?? parsed.symbolName;
|
|
11
|
+
const chunk = selectChunk(input.chunks, filePath, symbolName, symbol);
|
|
12
|
+
const expansionLevel = input.expansionLevel ?? defaultExpansion(chunk);
|
|
13
|
+
const missingEvidence = [];
|
|
14
|
+
const snippets = [];
|
|
15
|
+
if (!chunk) {
|
|
16
|
+
missingEvidence.push(`No indexed chunk matched ${input.nodeRef}.`);
|
|
17
|
+
return {
|
|
18
|
+
nodeRef: input.nodeRef,
|
|
19
|
+
filePath,
|
|
20
|
+
symbolName,
|
|
21
|
+
expansionLevel,
|
|
22
|
+
snippets,
|
|
23
|
+
missingEvidence,
|
|
24
|
+
budgetChars,
|
|
25
|
+
usedChars: 0
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const content = renderChunk(chunk, expansionLevel, symbol);
|
|
29
|
+
const cost = chunk.filePath.length + content.length + 120;
|
|
30
|
+
if (cost > budgetChars && expansionLevel === "full_body") {
|
|
31
|
+
missingEvidence.push(`Full body for ${input.nodeRef} exceeds budget; request a larger budget or use skeleton/focused_body.`);
|
|
32
|
+
}
|
|
33
|
+
else if (cost > budgetChars) {
|
|
34
|
+
missingEvidence.push(`Expanded node ${input.nodeRef} was reduced to skeleton to fit budget.`);
|
|
35
|
+
}
|
|
36
|
+
const finalLevel = cost > budgetChars && expansionLevel !== "file_card" ? "skeleton" : expansionLevel;
|
|
37
|
+
const finalContent = finalLevel === expansionLevel ? content : renderChunk(chunk, finalLevel, symbol);
|
|
38
|
+
const usedChars = Math.min(budgetChars, chunk.filePath.length + finalContent.length + 120);
|
|
39
|
+
if (usedChars <= budgetChars) {
|
|
40
|
+
snippets.push(snippetFor(chunk, finalContent, finalLevel, input.nodeRef, symbol));
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
nodeRef: input.nodeRef,
|
|
44
|
+
filePath: chunk.filePath,
|
|
45
|
+
symbolName: chunk.symbolName ?? symbolName,
|
|
46
|
+
expansionLevel: finalLevel,
|
|
47
|
+
snippets,
|
|
48
|
+
missingEvidence,
|
|
49
|
+
budgetChars,
|
|
50
|
+
usedChars
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function parseNodeRef(nodeRef) {
|
|
54
|
+
const separator = nodeRef.lastIndexOf(":");
|
|
55
|
+
if (separator > 0 && !/^[a-zA-Z]:[\\/]/.test(nodeRef)) {
|
|
56
|
+
return {
|
|
57
|
+
filePath: normalizeUserPath(nodeRef.slice(0, separator)),
|
|
58
|
+
symbolName: nodeRef.slice(separator + 1).trim() || undefined
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return { filePath: normalizeUserPath(nodeRef) };
|
|
62
|
+
}
|
|
63
|
+
function selectSymbol(symbols, filePath, symbolName) {
|
|
64
|
+
if (symbolName) {
|
|
65
|
+
return symbols.find((symbol) => symbol.filePath === filePath && symbol.name === symbolName)
|
|
66
|
+
?? symbols.find((symbol) => symbol.filePath.endsWith(filePath) && symbol.name === symbolName);
|
|
67
|
+
}
|
|
68
|
+
return symbols.find((symbol) => symbol.filePath === filePath && symbol.kind === "file")
|
|
69
|
+
?? symbols.find((symbol) => symbol.filePath.endsWith(filePath) && symbol.kind === "file");
|
|
70
|
+
}
|
|
71
|
+
function selectChunk(chunks, filePath, symbolName, symbol) {
|
|
72
|
+
const sameFile = chunks.filter((chunk) => chunk.filePath === filePath || chunk.filePath.endsWith(filePath));
|
|
73
|
+
if (sameFile.length === 0)
|
|
74
|
+
return undefined;
|
|
75
|
+
if (symbolName) {
|
|
76
|
+
const exact = sameFile.find((chunk) => chunk.symbolName === symbolName);
|
|
77
|
+
if (exact)
|
|
78
|
+
return exact;
|
|
79
|
+
}
|
|
80
|
+
if (symbol) {
|
|
81
|
+
const containing = sameFile.find((chunk) => chunk.startLine <= symbol.startLine && chunk.endLine >= symbol.startLine);
|
|
82
|
+
if (containing)
|
|
83
|
+
return containing;
|
|
84
|
+
}
|
|
85
|
+
return sameFile[0];
|
|
86
|
+
}
|
|
87
|
+
function defaultExpansion(chunk) {
|
|
88
|
+
if (!chunk)
|
|
89
|
+
return "focused_body";
|
|
90
|
+
return lineCount(chunk.content) > 80 ? "skeleton" : "focused_body";
|
|
91
|
+
}
|
|
92
|
+
function renderChunk(chunk, expansionLevel, symbol) {
|
|
93
|
+
if (expansionLevel === "file_card") {
|
|
94
|
+
return [
|
|
95
|
+
`${chunk.kind}: ${chunk.symbolName ?? chunk.filePath}`,
|
|
96
|
+
`language: ${chunk.language}`,
|
|
97
|
+
`lines: ${chunk.startLine}-${chunk.endLine}`
|
|
98
|
+
].join("\n");
|
|
99
|
+
}
|
|
100
|
+
if (expansionLevel === "skeleton")
|
|
101
|
+
return skeletonizeChunk(chunk);
|
|
102
|
+
if (expansionLevel === "full_body")
|
|
103
|
+
return chunk.content;
|
|
104
|
+
return focusedBody(chunk.content, symbol ? Math.max(1, symbol.startLine - chunk.startLine + 1) : undefined);
|
|
105
|
+
}
|
|
106
|
+
function focusedBody(content, focusLine) {
|
|
107
|
+
const lines = content.split(/\r?\n/);
|
|
108
|
+
if (lines.length <= FOCUS_WINDOW_LINES)
|
|
109
|
+
return content;
|
|
110
|
+
const focus = focusLine ?? 1;
|
|
111
|
+
const half = Math.floor(FOCUS_WINDOW_LINES / 2);
|
|
112
|
+
const start = Math.max(0, focus - 1 - half);
|
|
113
|
+
const end = Math.min(lines.length, start + FOCUS_WINDOW_LINES);
|
|
114
|
+
return [
|
|
115
|
+
...(start > 0 ? ["..."] : []),
|
|
116
|
+
...lines.slice(start, end),
|
|
117
|
+
...(end < lines.length ? ["..."] : [])
|
|
118
|
+
].join("\n");
|
|
119
|
+
}
|
|
120
|
+
function snippetFor(chunk, content, expansionLevel, nodeRef, symbol) {
|
|
121
|
+
const returnedLineCount = lineCount(content);
|
|
122
|
+
const originalLineCount = lineCount(chunk.content);
|
|
123
|
+
return {
|
|
124
|
+
filePath: chunk.filePath,
|
|
125
|
+
startLine: symbol?.startLine ?? chunk.startLine,
|
|
126
|
+
endLine: (symbol?.startLine ?? chunk.startLine) + Math.max(0, returnedLineCount - 1),
|
|
127
|
+
content,
|
|
128
|
+
score: 1,
|
|
129
|
+
reason: `Expanded node ${nodeRef}`,
|
|
130
|
+
role: chunk.symbolName ? `${chunk.kind}: ${chunk.symbolName}` : `${chunk.kind} evidence`,
|
|
131
|
+
expansionLevel,
|
|
132
|
+
originalLineCount,
|
|
133
|
+
returnedLineCount,
|
|
134
|
+
elidedLineCount: Math.max(0, originalLineCount - returnedLineCount)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function lineCount(content) {
|
|
138
|
+
return content.length === 0 ? 0 : content.split(/\r?\n/).length;
|
|
139
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ExplainImpactReport, SubgraphOutputPreset, VerifiedCodeSubgraph } from "../core/types.js";
|
|
2
|
+
export declare function applySubgraphOutputPreset(subgraph: VerifiedCodeSubgraph, preset?: SubgraphOutputPreset): unknown;
|
|
3
|
+
export declare function applyExplainImpactOutputPreset(report: ExplainImpactReport, preset?: SubgraphOutputPreset): unknown;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export function applySubgraphOutputPreset(subgraph, preset = "agent_edit") {
|
|
2
|
+
if (preset === "agent_edit") {
|
|
3
|
+
return {
|
|
4
|
+
query: subgraph.query,
|
|
5
|
+
mode: subgraph.mode,
|
|
6
|
+
answerable: subgraph.answerable,
|
|
7
|
+
confidence: subgraph.confidence,
|
|
8
|
+
coverageSummary: subgraph.coverageSummary,
|
|
9
|
+
whyTheseFiles: subgraph.whyTheseFiles,
|
|
10
|
+
snippets: subgraph.snippets,
|
|
11
|
+
missingEvidence: subgraph.missingEvidence,
|
|
12
|
+
nextQueries: subgraph.nextQueries,
|
|
13
|
+
budgetChars: subgraph.budgetChars,
|
|
14
|
+
usedChars: subgraph.usedChars
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (preset === "debug_trace") {
|
|
18
|
+
return {
|
|
19
|
+
query: subgraph.query,
|
|
20
|
+
mode: subgraph.mode,
|
|
21
|
+
answerable: subgraph.answerable,
|
|
22
|
+
confidence: subgraph.confidence,
|
|
23
|
+
paths: subgraph.paths,
|
|
24
|
+
edges: subgraph.edges,
|
|
25
|
+
coverage: subgraph.coverage,
|
|
26
|
+
coverageSummary: subgraph.coverageSummary,
|
|
27
|
+
missingEvidence: subgraph.missingEvidence,
|
|
28
|
+
nextQueries: subgraph.nextQueries
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (preset === "review_risk") {
|
|
32
|
+
return {
|
|
33
|
+
query: subgraph.query,
|
|
34
|
+
mode: subgraph.mode,
|
|
35
|
+
answerable: subgraph.answerable,
|
|
36
|
+
confidence: subgraph.confidence,
|
|
37
|
+
coverageSummary: subgraph.coverageSummary,
|
|
38
|
+
whyTheseFiles: subgraph.whyTheseFiles,
|
|
39
|
+
riskEvidence: subgraph.edges.filter((edge) => edge.confidence !== "high" || edge.source === "heuristic"),
|
|
40
|
+
coverage: subgraph.coverage.filter((signal) => signal.status !== "pass"),
|
|
41
|
+
missingEvidence: subgraph.missingEvidence,
|
|
42
|
+
nextQueries: subgraph.nextQueries
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
query: subgraph.query,
|
|
47
|
+
repoRoot: subgraph.repoRoot,
|
|
48
|
+
projectId: subgraph.projectId,
|
|
49
|
+
mode: subgraph.mode,
|
|
50
|
+
answerable: subgraph.answerable,
|
|
51
|
+
confidence: subgraph.confidence,
|
|
52
|
+
coverageSummary: subgraph.coverageSummary,
|
|
53
|
+
whyTheseFiles: subgraph.whyTheseFiles,
|
|
54
|
+
nodes: subgraph.nodes.map((node) => ({
|
|
55
|
+
id: node.id,
|
|
56
|
+
filePath: node.filePath,
|
|
57
|
+
symbolName: node.symbolName,
|
|
58
|
+
kind: node.kind,
|
|
59
|
+
role: node.role,
|
|
60
|
+
confidence: node.confidence,
|
|
61
|
+
citation: node.citation
|
|
62
|
+
})),
|
|
63
|
+
edges: subgraph.edges.map((edge) => ({
|
|
64
|
+
fromNodeId: edge.fromNodeId,
|
|
65
|
+
toNodeId: edge.toNodeId,
|
|
66
|
+
kind: edge.kind,
|
|
67
|
+
confidence: edge.confidence,
|
|
68
|
+
source: edge.source,
|
|
69
|
+
sourceFile: edge.sourceFile,
|
|
70
|
+
targetFile: edge.targetFile,
|
|
71
|
+
line: edge.line,
|
|
72
|
+
targetName: edge.targetName,
|
|
73
|
+
metadata: edge.metadata
|
|
74
|
+
})),
|
|
75
|
+
paths: subgraph.paths,
|
|
76
|
+
coverage: subgraph.coverage,
|
|
77
|
+
missingEvidence: subgraph.missingEvidence,
|
|
78
|
+
nextQueries: subgraph.nextQueries,
|
|
79
|
+
budgetChars: subgraph.budgetChars,
|
|
80
|
+
usedChars: subgraph.usedChars
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export function applyExplainImpactOutputPreset(report, preset = "agent_edit") {
|
|
84
|
+
if (preset === "agent_edit" || preset === "debug_trace" || preset === "review_risk") {
|
|
85
|
+
return {
|
|
86
|
+
target: report.target,
|
|
87
|
+
riskLevel: report.riskLevel,
|
|
88
|
+
riskScore: report.riskScore,
|
|
89
|
+
riskReasons: report.riskReasons,
|
|
90
|
+
editReadiness: report.editReadiness,
|
|
91
|
+
subgraph: applySubgraphOutputPreset(report.subgraph, preset)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
target: report.target,
|
|
96
|
+
riskLevel: report.riskLevel,
|
|
97
|
+
riskScore: report.riskScore,
|
|
98
|
+
riskReasons: report.riskReasons,
|
|
99
|
+
editReadiness: report.editReadiness,
|
|
100
|
+
subgraph: applySubgraphOutputPreset(report.subgraph, preset)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CodeChunk, GraphEdge, SymbolNode, VerifiedCodeSubgraph, VerifiedSubgraphMode } from "../core/types.js";
|
|
2
|
+
export interface SubgraphBuildInput {
|
|
3
|
+
query: string;
|
|
4
|
+
repoRoot: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
mode: VerifiedSubgraphMode;
|
|
7
|
+
seedSymbols: SymbolNode[];
|
|
8
|
+
symbols: SymbolNode[];
|
|
9
|
+
edges: GraphEdge[];
|
|
10
|
+
chunks: CodeChunk[];
|
|
11
|
+
budgetChars?: number;
|
|
12
|
+
maxHops?: number;
|
|
13
|
+
missingEvidence?: string[];
|
|
14
|
+
}
|
|
15
|
+
export declare class SubgraphBuilder {
|
|
16
|
+
build(input: SubgraphBuildInput): VerifiedCodeSubgraph;
|
|
17
|
+
}
|