@opencodehub/mcp 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/README.md +62 -0
- package/dist/analysis-bridge.d.ts +23 -0
- package/dist/analysis-bridge.d.ts.map +1 -0
- package/dist/analysis-bridge.js +83 -0
- package/dist/analysis-bridge.js.map +1 -0
- package/dist/connection-pool.d.ts +76 -0
- package/dist/connection-pool.d.ts.map +1 -0
- package/dist/connection-pool.js +179 -0
- package/dist/connection-pool.js.map +1 -0
- package/dist/error-envelope.d.ts +97 -0
- package/dist/error-envelope.d.ts.map +1 -0
- package/dist/error-envelope.js +75 -0
- package/dist/error-envelope.js.map +1 -0
- package/dist/group-resolver.d.ts +29 -0
- package/dist/group-resolver.d.ts.map +1 -0
- package/dist/group-resolver.js +100 -0
- package/dist/group-resolver.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/next-step-hints.d.ts +24 -0
- package/dist/next-step-hints.d.ts.map +1 -0
- package/dist/next-step-hints.js +41 -0
- package/dist/next-step-hints.js.map +1 -0
- package/dist/repo-resolver.d.ts +88 -0
- package/dist/repo-resolver.d.ts.map +1 -0
- package/dist/repo-resolver.js +211 -0
- package/dist/repo-resolver.js.map +1 -0
- package/dist/repo-uri-for-entry.d.ts +25 -0
- package/dist/repo-uri-for-entry.d.ts.map +1 -0
- package/dist/repo-uri-for-entry.js +64 -0
- package/dist/repo-uri-for-entry.js.map +1 -0
- package/dist/resources/repo-cluster.d.ts +19 -0
- package/dist/resources/repo-cluster.d.ts.map +1 -0
- package/dist/resources/repo-cluster.js +203 -0
- package/dist/resources/repo-cluster.js.map +1 -0
- package/dist/resources/repo-clusters.d.ts +14 -0
- package/dist/resources/repo-clusters.d.ts.map +1 -0
- package/dist/resources/repo-clusters.js +97 -0
- package/dist/resources/repo-clusters.js.map +1 -0
- package/dist/resources/repo-context.d.ts +12 -0
- package/dist/resources/repo-context.d.ts.map +1 -0
- package/dist/resources/repo-context.js +84 -0
- package/dist/resources/repo-context.js.map +1 -0
- package/dist/resources/repo-process.d.ts +19 -0
- package/dist/resources/repo-process.d.ts.map +1 -0
- package/dist/resources/repo-process.js +220 -0
- package/dist/resources/repo-process.js.map +1 -0
- package/dist/resources/repo-processes.d.ts +13 -0
- package/dist/resources/repo-processes.d.ts.map +1 -0
- package/dist/resources/repo-processes.js +99 -0
- package/dist/resources/repo-processes.js.map +1 -0
- package/dist/resources/repo-schema.d.ts +13 -0
- package/dist/resources/repo-schema.d.ts.map +1 -0
- package/dist/resources/repo-schema.js +99 -0
- package/dist/resources/repo-schema.js.map +1 -0
- package/dist/resources/repos.d.ts +20 -0
- package/dist/resources/repos.d.ts.map +1 -0
- package/dist/resources/repos.js +58 -0
- package/dist/resources/repos.js.map +1 -0
- package/dist/resources/store-helper.d.ts +28 -0
- package/dist/resources/store-helper.d.ts.map +1 -0
- package/dist/resources/store-helper.js +58 -0
- package/dist/resources/store-helper.js.map +1 -0
- package/dist/resources/yaml.d.ts +10 -0
- package/dist/resources/yaml.d.ts.map +1 -0
- package/dist/resources/yaml.js +16 -0
- package/dist/resources/yaml.js.map +1 -0
- package/dist/server.d.ts +46 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +194 -0
- package/dist/server.js.map +1 -0
- package/dist/staleness.d.ts +19 -0
- package/dist/staleness.d.ts.map +1 -0
- package/dist/staleness.js +40 -0
- package/dist/staleness.js.map +1 -0
- package/dist/test-utils.d.ts +170 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +473 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/tools/api-impact.d.ts +47 -0
- package/dist/tools/api-impact.d.ts.map +1 -0
- package/dist/tools/api-impact.js +199 -0
- package/dist/tools/api-impact.js.map +1 -0
- package/dist/tools/confidence.d.ts +39 -0
- package/dist/tools/confidence.d.ts.map +1 -0
- package/dist/tools/confidence.js +58 -0
- package/dist/tools/confidence.js.map +1 -0
- package/dist/tools/context.d.ts +47 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +577 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/dependencies.d.ts +29 -0
- package/dist/tools/dependencies.d.ts.map +1 -0
- package/dist/tools/dependencies.js +110 -0
- package/dist/tools/dependencies.js.map +1 -0
- package/dist/tools/detect-changes.d.ts +15 -0
- package/dist/tools/detect-changes.d.ts.map +1 -0
- package/dist/tools/detect-changes.js +78 -0
- package/dist/tools/detect-changes.js.map +1 -0
- package/dist/tools/group-contracts.d.ts +26 -0
- package/dist/tools/group-contracts.d.ts.map +1 -0
- package/dist/tools/group-contracts.js +251 -0
- package/dist/tools/group-contracts.js.map +1 -0
- package/dist/tools/group-cross-repo-links.d.ts +28 -0
- package/dist/tools/group-cross-repo-links.d.ts.map +1 -0
- package/dist/tools/group-cross-repo-links.js +128 -0
- package/dist/tools/group-cross-repo-links.js.map +1 -0
- package/dist/tools/group-list.d.ts +10 -0
- package/dist/tools/group-list.d.ts.map +1 -0
- package/dist/tools/group-list.js +74 -0
- package/dist/tools/group-list.js.map +1 -0
- package/dist/tools/group-query.d.ts +40 -0
- package/dist/tools/group-query.d.ts.map +1 -0
- package/dist/tools/group-query.js +209 -0
- package/dist/tools/group-query.js.map +1 -0
- package/dist/tools/group-status.d.ts +21 -0
- package/dist/tools/group-status.d.ts.map +1 -0
- package/dist/tools/group-status.js +121 -0
- package/dist/tools/group-status.js.map +1 -0
- package/dist/tools/group-sync.d.ts +23 -0
- package/dist/tools/group-sync.d.ts.map +1 -0
- package/dist/tools/group-sync.js +112 -0
- package/dist/tools/group-sync.js.map +1 -0
- package/dist/tools/impact.d.ts +36 -0
- package/dist/tools/impact.d.ts.map +1 -0
- package/dist/tools/impact.js +232 -0
- package/dist/tools/impact.js.map +1 -0
- package/dist/tools/license-audit.d.ts +34 -0
- package/dist/tools/license-audit.d.ts.map +1 -0
- package/dist/tools/license-audit.js +108 -0
- package/dist/tools/license-audit.js.map +1 -0
- package/dist/tools/list-dead-code.d.ts +26 -0
- package/dist/tools/list-dead-code.d.ts.map +1 -0
- package/dist/tools/list-dead-code.js +110 -0
- package/dist/tools/list-dead-code.js.map +1 -0
- package/dist/tools/list-findings-delta.d.ts +36 -0
- package/dist/tools/list-findings-delta.d.ts.map +1 -0
- package/dist/tools/list-findings-delta.js +274 -0
- package/dist/tools/list-findings-delta.js.map +1 -0
- package/dist/tools/list-findings.d.ts +30 -0
- package/dist/tools/list-findings.d.ts.map +1 -0
- package/dist/tools/list-findings.js +129 -0
- package/dist/tools/list-findings.js.map +1 -0
- package/dist/tools/list-repos.d.ts +17 -0
- package/dist/tools/list-repos.d.ts.map +1 -0
- package/dist/tools/list-repos.js +63 -0
- package/dist/tools/list-repos.js.map +1 -0
- package/dist/tools/owners.d.ts +23 -0
- package/dist/tools/owners.d.ts.map +1 -0
- package/dist/tools/owners.js +103 -0
- package/dist/tools/owners.js.map +1 -0
- package/dist/tools/pack-codebase.d.ts +76 -0
- package/dist/tools/pack-codebase.d.ts.map +1 -0
- package/dist/tools/pack-codebase.js +289 -0
- package/dist/tools/pack-codebase.js.map +1 -0
- package/dist/tools/project-profile.d.ts +28 -0
- package/dist/tools/project-profile.d.ts.map +1 -0
- package/dist/tools/project-profile.js +109 -0
- package/dist/tools/project-profile.js.map +1 -0
- package/dist/tools/query.d.ts +63 -0
- package/dist/tools/query.d.ts.map +1 -0
- package/dist/tools/query.js +662 -0
- package/dist/tools/query.js.map +1 -0
- package/dist/tools/remove-dead-code.d.ts +47 -0
- package/dist/tools/remove-dead-code.d.ts.map +1 -0
- package/dist/tools/remove-dead-code.js +258 -0
- package/dist/tools/remove-dead-code.js.map +1 -0
- package/dist/tools/rename.d.ts +21 -0
- package/dist/tools/rename.d.ts.map +1 -0
- package/dist/tools/rename.js +116 -0
- package/dist/tools/rename.js.map +1 -0
- package/dist/tools/risk-trends.d.ts +19 -0
- package/dist/tools/risk-trends.d.ts.map +1 -0
- package/dist/tools/risk-trends.js +73 -0
- package/dist/tools/risk-trends.js.map +1 -0
- package/dist/tools/route-map.d.ts +27 -0
- package/dist/tools/route-map.d.ts.map +1 -0
- package/dist/tools/route-map.js +119 -0
- package/dist/tools/route-map.js.map +1 -0
- package/dist/tools/scan.d.ts +27 -0
- package/dist/tools/scan.d.ts.map +1 -0
- package/dist/tools/scan.js +136 -0
- package/dist/tools/scan.js.map +1 -0
- package/dist/tools/shape-check.d.ts +53 -0
- package/dist/tools/shape-check.d.ts.map +1 -0
- package/dist/tools/shape-check.js +161 -0
- package/dist/tools/shape-check.js.map +1 -0
- package/dist/tools/shared.d.ts +101 -0
- package/dist/tools/shared.d.ts.map +1 -0
- package/dist/tools/shared.js +114 -0
- package/dist/tools/shared.js.map +1 -0
- package/dist/tools/signature.d.ts +38 -0
- package/dist/tools/signature.d.ts.map +1 -0
- package/dist/tools/signature.js +332 -0
- package/dist/tools/signature.js.map +1 -0
- package/dist/tools/sql.d.ts +34 -0
- package/dist/tools/sql.d.ts.map +1 -0
- package/dist/tools/sql.js +222 -0
- package/dist/tools/sql.js.map +1 -0
- package/dist/tools/tool-map.d.ts +24 -0
- package/dist/tools/tool-map.d.ts.map +1 -0
- package/dist/tools/tool-map.js +97 -0
- package/dist/tools/tool-map.js.map +1 -0
- package/dist/tools/verdict.d.ts +33 -0
- package/dist/tools/verdict.d.ts.map +1 -0
- package/dist/tools/verdict.js +102 -0
- package/dist/tools/verdict.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `api_impact` — score the blast radius of changing a Route's contract.
|
|
3
|
+
*
|
|
4
|
+
* For every Route matching the filter (`route` substring, or `file`
|
|
5
|
+
* substring against Route.filePath) we compute:
|
|
6
|
+
* - consumers = files with outgoing FETCHES → this Route.
|
|
7
|
+
* - middleware = handlers reached via HANDLES_ROUTE (typically
|
|
8
|
+
* File ids; Operation ids when the OpenAPI
|
|
9
|
+
* phase linked a spec).
|
|
10
|
+
* - mismatches = consumer files whose accessed keys are not a
|
|
11
|
+
* subset of Route.responseKeys (delegated to
|
|
12
|
+
* `classifyShape` from shape-check).
|
|
13
|
+
* - affectedProcesses = Process nodes whose PROCESS_STEP edges walk
|
|
14
|
+
* through any of the consumer symbols.
|
|
15
|
+
*
|
|
16
|
+
* Risk banding (deterministic):
|
|
17
|
+
* LOW — 0 consumers and 0 mismatches.
|
|
18
|
+
* MEDIUM — 1-4 consumers, 0 mismatches.
|
|
19
|
+
* HIGH — 5-19 consumers OR any mismatch.
|
|
20
|
+
* CRITICAL — ≥ 20 consumers.
|
|
21
|
+
*/
|
|
22
|
+
// biome-ignore-all lint/complexity/useLiteralKeys: dot-access disallowed on Record index signatures
|
|
23
|
+
import { z } from "zod";
|
|
24
|
+
import { toolErrorFromUnknown } from "../error-envelope.js";
|
|
25
|
+
import { withNextSteps } from "../next-step-hints.js";
|
|
26
|
+
import { stalenessFromMeta } from "../staleness.js";
|
|
27
|
+
import { classifyShape } from "./shape-check.js";
|
|
28
|
+
import { fromToolResult, repoArgShape, toToolResult, withStore, } from "./shared.js";
|
|
29
|
+
const ApiImpactInput = {
|
|
30
|
+
...repoArgShape,
|
|
31
|
+
route: z.string().optional().describe("Substring match against Route.url."),
|
|
32
|
+
file: z.string().optional().describe("Substring match against Route.filePath."),
|
|
33
|
+
};
|
|
34
|
+
export async function runApiImpact(ctx, args) {
|
|
35
|
+
const call = await withStore(ctx, args, async (store, resolved) => {
|
|
36
|
+
try {
|
|
37
|
+
const rows = await analyzeApiImpact(store.graph, args.route, args.file);
|
|
38
|
+
const header = `api_impact — ${rows.length} route(s) for ${resolved.name}${args.route ? ` · url~${args.route}` : ""}${args.file ? ` · filePath~${args.file}` : ""}:`;
|
|
39
|
+
const body = rows.length === 0
|
|
40
|
+
? "(no routes matched — check the filter or re-index with `codehub analyze`)"
|
|
41
|
+
: rows
|
|
42
|
+
.map((r) => `- [${r.risk}] ${r.route.method} ${r.route.url} consumers=${r.consumers.length} mismatches=${r.mismatches.length} processes=${r.affectedProcesses.length}`)
|
|
43
|
+
.join("\n");
|
|
44
|
+
const highest = rows.reduce((acc, r) => worseRisk(acc, r.risk), "LOW");
|
|
45
|
+
const next = rows.length === 0
|
|
46
|
+
? ["call `route_map` to list available routes"]
|
|
47
|
+
: highest === "CRITICAL" || highest === "HIGH"
|
|
48
|
+
? [
|
|
49
|
+
`call \`shape_check\` with route="${rows[0]?.route.url ?? ""}" to see per-consumer mismatches`,
|
|
50
|
+
`call \`context\` on a consumer file to plan migration`,
|
|
51
|
+
]
|
|
52
|
+
: [
|
|
53
|
+
"low blast radius — route change should be safe",
|
|
54
|
+
"still verify with `shape_check` before merging",
|
|
55
|
+
];
|
|
56
|
+
return withNextSteps(`${header}\n${body}`, { routes: rows, highestRisk: highest }, next, stalenessFromMeta(resolved.meta));
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
return toolErrorFromUnknown(err);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return toToolResult(call);
|
|
63
|
+
}
|
|
64
|
+
export function registerApiImpactTool(server, ctx) {
|
|
65
|
+
server.registerTool("api_impact", {
|
|
66
|
+
title: "Route change blast radius",
|
|
67
|
+
description: "Score the blast radius of changing a Route's contract. Returns risk (LOW/MEDIUM/HIGH/CRITICAL) plus the consumer files, middleware handlers, shape mismatches, and affected Process flows for every matching Route. Read-only.",
|
|
68
|
+
inputSchema: ApiImpactInput,
|
|
69
|
+
annotations: {
|
|
70
|
+
readOnlyHint: true,
|
|
71
|
+
destructiveHint: false,
|
|
72
|
+
idempotentHint: true,
|
|
73
|
+
openWorldHint: false,
|
|
74
|
+
},
|
|
75
|
+
}, async (args) => fromToolResult(await runApiImpact(ctx, args)));
|
|
76
|
+
}
|
|
77
|
+
async function analyzeApiImpact(graph, routeFilter, fileFilter) {
|
|
78
|
+
const opts = { limit: 500 };
|
|
79
|
+
if (routeFilter !== undefined && routeFilter.length > 0)
|
|
80
|
+
opts.pathLike = routeFilter;
|
|
81
|
+
let routes = await graph.listRoutes(opts);
|
|
82
|
+
if (fileFilter !== undefined && fileFilter.length > 0) {
|
|
83
|
+
const sub = fileFilter;
|
|
84
|
+
routes = routes.filter((r) => r.filePath.includes(sub));
|
|
85
|
+
}
|
|
86
|
+
const sorted = [...routes].sort((a, b) => {
|
|
87
|
+
if (a.url !== b.url)
|
|
88
|
+
return a.url < b.url ? -1 : 1;
|
|
89
|
+
const am = a.method ?? "";
|
|
90
|
+
const bm = b.method ?? "";
|
|
91
|
+
return am < bm ? -1 : am > bm ? 1 : 0;
|
|
92
|
+
});
|
|
93
|
+
const out = [];
|
|
94
|
+
for (const r of sorted) {
|
|
95
|
+
const responseKeys = r.responseKeys ?? [];
|
|
96
|
+
const [consumerSymbolIds, handlers] = await Promise.all([
|
|
97
|
+
fetchFromIds(graph, r.id, "FETCHES"),
|
|
98
|
+
fetchFromIds(graph, r.id, "HANDLES_ROUTE"),
|
|
99
|
+
]);
|
|
100
|
+
const consumerFiles = await resolveFiles(graph, consumerSymbolIds);
|
|
101
|
+
const mismatches = [];
|
|
102
|
+
for (const file of consumerFiles) {
|
|
103
|
+
const accessedKeys = await collectAccessedKeys(graph, file);
|
|
104
|
+
const { status } = classifyShape(accessedKeys, responseKeys);
|
|
105
|
+
if (status === "MISMATCH")
|
|
106
|
+
mismatches.push(file);
|
|
107
|
+
}
|
|
108
|
+
const affectedProcesses = await fetchAffectedProcesses(graph, consumerSymbolIds);
|
|
109
|
+
const risk = scoreRisk(consumerFiles.length, mismatches.length);
|
|
110
|
+
out.push({
|
|
111
|
+
route: { id: r.id, url: r.url, method: r.method ?? "", filePath: r.filePath },
|
|
112
|
+
risk,
|
|
113
|
+
consumers: consumerFiles,
|
|
114
|
+
middleware: handlers,
|
|
115
|
+
mismatches,
|
|
116
|
+
affectedProcesses,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
function scoreRisk(consumers, mismatches) {
|
|
122
|
+
if (consumers >= 20)
|
|
123
|
+
return "CRITICAL";
|
|
124
|
+
if (consumers >= 5 || mismatches > 0)
|
|
125
|
+
return "HIGH";
|
|
126
|
+
if (consumers >= 1)
|
|
127
|
+
return "MEDIUM";
|
|
128
|
+
return "LOW";
|
|
129
|
+
}
|
|
130
|
+
function worseRisk(a, b) {
|
|
131
|
+
const order = { LOW: 0, MEDIUM: 1, HIGH: 2, CRITICAL: 3 };
|
|
132
|
+
return order[a] >= order[b] ? a : b;
|
|
133
|
+
}
|
|
134
|
+
async function fetchFromIds(graph, targetId, type) {
|
|
135
|
+
const edges = await graph.listEdgesByType(type, { toIds: [targetId] });
|
|
136
|
+
return edges
|
|
137
|
+
.map((e) => e.from)
|
|
138
|
+
.filter((s) => s.length > 0)
|
|
139
|
+
.sort();
|
|
140
|
+
}
|
|
141
|
+
async function resolveFiles(graph, nodeIds) {
|
|
142
|
+
if (nodeIds.length === 0)
|
|
143
|
+
return [];
|
|
144
|
+
const partners = await graph.listNodes({ ids: [...nodeIds] });
|
|
145
|
+
const set = new Set();
|
|
146
|
+
for (const n of partners) {
|
|
147
|
+
if (n.filePath && n.filePath.length > 0)
|
|
148
|
+
set.add(n.filePath);
|
|
149
|
+
}
|
|
150
|
+
return Array.from(set).sort();
|
|
151
|
+
}
|
|
152
|
+
async function collectAccessedKeys(graph, file) {
|
|
153
|
+
const edges = await graph.listEdgesByType("ACCESSES");
|
|
154
|
+
if (edges.length === 0)
|
|
155
|
+
return [];
|
|
156
|
+
const allIds = new Set();
|
|
157
|
+
for (const e of edges) {
|
|
158
|
+
allIds.add(e.from);
|
|
159
|
+
allIds.add(e.to);
|
|
160
|
+
}
|
|
161
|
+
const allNodes = await graph.listNodes({ ids: [...allIds] });
|
|
162
|
+
const byId = new Map();
|
|
163
|
+
for (const n of allNodes)
|
|
164
|
+
byId.set(n.id, n);
|
|
165
|
+
const names = new Set();
|
|
166
|
+
for (const e of edges) {
|
|
167
|
+
const src = byId.get(e.from);
|
|
168
|
+
if (!src || src.filePath !== file)
|
|
169
|
+
continue;
|
|
170
|
+
const target = byId.get(e.to);
|
|
171
|
+
if (!target || target.kind !== "Property")
|
|
172
|
+
continue;
|
|
173
|
+
if (target.name && target.name.length > 0)
|
|
174
|
+
names.add(target.name);
|
|
175
|
+
}
|
|
176
|
+
return Array.from(names).sort();
|
|
177
|
+
}
|
|
178
|
+
async function fetchAffectedProcesses(graph, consumerSymbolIds) {
|
|
179
|
+
if (consumerSymbolIds.length === 0)
|
|
180
|
+
return [];
|
|
181
|
+
const targetSet = new Set(consumerSymbolIds);
|
|
182
|
+
const edges = await graph.listEdgesByType("PROCESS_STEP");
|
|
183
|
+
const procIds = new Set();
|
|
184
|
+
for (const e of edges) {
|
|
185
|
+
if (!targetSet.has(e.to))
|
|
186
|
+
continue;
|
|
187
|
+
procIds.add(e.from);
|
|
188
|
+
}
|
|
189
|
+
if (procIds.size === 0)
|
|
190
|
+
return [];
|
|
191
|
+
const partners = await graph.listNodes({ ids: [...procIds] });
|
|
192
|
+
const out = [];
|
|
193
|
+
for (const n of partners) {
|
|
194
|
+
if (n.kind === "Process")
|
|
195
|
+
out.push(n.id);
|
|
196
|
+
}
|
|
197
|
+
return out.sort();
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=api-impact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-impact.js","sourceRoot":"","sources":["../../src/tools/api-impact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oGAAoG;AAKpG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBA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AAC,EAAE,CAAC,CAAC;IAC9D,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confidence-breakdown aggregation for MCP edge-based responses.
|
|
3
|
+
*
|
|
4
|
+
* Every `context` and `impact` response now carries a `confidenceBreakdown`
|
|
5
|
+
* summarising the provenance quality of the underlying edges. The three
|
|
6
|
+
* buckets map directly onto the confidence-demote phase:
|
|
7
|
+
*
|
|
8
|
+
* - `confirmed` — confidence >= 0.95 AND reason starts with a known LSP
|
|
9
|
+
* provenance prefix. These are oracle-confirmed by a compiler-grade
|
|
10
|
+
* language server (pyright, tsserver, gopls, rust-analyzer).
|
|
11
|
+
* - `heuristic` — 0.2 < confidence < 0.95. Tree-sitter / tier-1 / tier-2
|
|
12
|
+
* inference that the LSP oracle has not confirmed (either no coverage
|
|
13
|
+
* for the language, or the LSP was skipped).
|
|
14
|
+
* - `unknown` — confidence <= 0.2. Heuristic edges that the demote phase
|
|
15
|
+
* explicitly flagged as contradicted (`+scip-unconfirmed`) or placeholders
|
|
16
|
+
* from the parser.
|
|
17
|
+
*
|
|
18
|
+
* The breakdown is a pure read-side aggregation — callers feed in the edges
|
|
19
|
+
* already surfaced by the enclosing tool. It never mutates edges.
|
|
20
|
+
*/
|
|
21
|
+
import type { CodeRelation } from "@opencodehub/core-types";
|
|
22
|
+
export interface ConfidenceBreakdown {
|
|
23
|
+
readonly confirmed: number;
|
|
24
|
+
readonly heuristic: number;
|
|
25
|
+
readonly unknown: number;
|
|
26
|
+
}
|
|
27
|
+
/** Shape we accept from SQL rows without forcing full `CodeRelation` hydration. */
|
|
28
|
+
export interface EdgeConfidenceSource {
|
|
29
|
+
readonly confidence: number;
|
|
30
|
+
readonly reason?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
export declare function computeConfidenceBreakdown(edges: readonly EdgeConfidenceSource[]): ConfidenceBreakdown;
|
|
33
|
+
/**
|
|
34
|
+
* Convenience overload for callers that already have hydrated `CodeRelation`
|
|
35
|
+
* instances. Accepts the `CodeRelation` array and re-uses the same aggregation
|
|
36
|
+
* path by narrowing to the two fields we actually consume.
|
|
37
|
+
*/
|
|
38
|
+
export declare function computeConfidenceBreakdownFromRelations(relations: readonly CodeRelation[]): ConfidenceBreakdown;
|
|
39
|
+
//# sourceMappingURL=confidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confidence.d.ts","sourceRoot":"","sources":["../../src/tools/confidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,mFAAmF;AACnF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAKD,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,SAAS,oBAAoB,EAAE,GACrC,mBAAmB,CAcrB;AAED;;;;GAIG;AACH,wBAAgB,uCAAuC,CACrD,SAAS,EAAE,SAAS,YAAY,EAAE,GACjC,mBAAmB,CAIrB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confidence-breakdown aggregation for MCP edge-based responses.
|
|
3
|
+
*
|
|
4
|
+
* Every `context` and `impact` response now carries a `confidenceBreakdown`
|
|
5
|
+
* summarising the provenance quality of the underlying edges. The three
|
|
6
|
+
* buckets map directly onto the confidence-demote phase:
|
|
7
|
+
*
|
|
8
|
+
* - `confirmed` — confidence >= 0.95 AND reason starts with a known LSP
|
|
9
|
+
* provenance prefix. These are oracle-confirmed by a compiler-grade
|
|
10
|
+
* language server (pyright, tsserver, gopls, rust-analyzer).
|
|
11
|
+
* - `heuristic` — 0.2 < confidence < 0.95. Tree-sitter / tier-1 / tier-2
|
|
12
|
+
* inference that the LSP oracle has not confirmed (either no coverage
|
|
13
|
+
* for the language, or the LSP was skipped).
|
|
14
|
+
* - `unknown` — confidence <= 0.2. Heuristic edges that the demote phase
|
|
15
|
+
* explicitly flagged as contradicted (`+scip-unconfirmed`) or placeholders
|
|
16
|
+
* from the parser.
|
|
17
|
+
*
|
|
18
|
+
* The breakdown is a pure read-side aggregation — callers feed in the edges
|
|
19
|
+
* already surfaced by the enclosing tool. It never mutates edges.
|
|
20
|
+
*/
|
|
21
|
+
import { SCIP_PROVENANCE_PREFIXES } from "@opencodehub/core-types";
|
|
22
|
+
const CONFIRMED_FLOOR = 0.95;
|
|
23
|
+
const UNKNOWN_CEILING = 0.2;
|
|
24
|
+
export function computeConfidenceBreakdown(edges) {
|
|
25
|
+
let confirmed = 0;
|
|
26
|
+
let heuristic = 0;
|
|
27
|
+
let unknown = 0;
|
|
28
|
+
for (const e of edges) {
|
|
29
|
+
if (e.confidence >= CONFIRMED_FLOOR && hasLspProvenance(e.reason)) {
|
|
30
|
+
confirmed += 1;
|
|
31
|
+
}
|
|
32
|
+
else if (e.confidence > UNKNOWN_CEILING) {
|
|
33
|
+
heuristic += 1;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
unknown += 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { confirmed, heuristic, unknown };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Convenience overload for callers that already have hydrated `CodeRelation`
|
|
43
|
+
* instances. Accepts the `CodeRelation` array and re-uses the same aggregation
|
|
44
|
+
* path by narrowing to the two fields we actually consume.
|
|
45
|
+
*/
|
|
46
|
+
export function computeConfidenceBreakdownFromRelations(relations) {
|
|
47
|
+
return computeConfidenceBreakdown(relations.map((r) => ({ confidence: r.confidence, reason: r.reason })));
|
|
48
|
+
}
|
|
49
|
+
function hasLspProvenance(reason) {
|
|
50
|
+
if (reason === undefined)
|
|
51
|
+
return false;
|
|
52
|
+
for (const prefix of SCIP_PROVENANCE_PREFIXES) {
|
|
53
|
+
if (reason.startsWith(prefix))
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=confidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confidence.js","sourceRoot":"","sources":["../../src/tools/confidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAcnE,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,UAAU,0BAA0B,CACxC,KAAsC;IAEtC,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,CAAC,UAAU,IAAI,eAAe,IAAI,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YAClE,SAAS,IAAI,CAAC,CAAC;QACjB,CAAC;aAAM,IAAI,CAAC,CAAC,UAAU,GAAG,eAAe,EAAE,CAAC;YAC1C,SAAS,IAAI,CAAC,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uCAAuC,CACrD,SAAkC;IAElC,OAAO,0BAA0B,CAC/B,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CACvE,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAA0B;IAClD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACvC,KAAK,MAAM,MAAM,IAAI,wBAAwB,EAAE,CAAC;QAC9C,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `context` — 360-degree view of a single symbol.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order:
|
|
5
|
+
* 1. `uid` — direct node-id lookup; no disambiguation, no name match.
|
|
6
|
+
* 2. `symbol` (or `name` alias) — filtered by optional `kind` and
|
|
7
|
+
* `file_path` (snake_case, with `filePath` camelCase alias preserved
|
|
8
|
+
* for backward compat). Ambiguous names surface a ranked candidate
|
|
9
|
+
* list instead of silently picking one (EC-04 in the PRD).
|
|
10
|
+
*
|
|
11
|
+
* Once a single target is resolved we collect:
|
|
12
|
+
* - `incoming` — every edge where the target is the `to_id`, bucketed
|
|
13
|
+
* by edge type (calls, imports, accesses, has_method, has_property,
|
|
14
|
+
* extends, implements, method_overrides, method_implements).
|
|
15
|
+
* - `outgoing` — the same bucketing for edges where the target is
|
|
16
|
+
* the `from_id`.
|
|
17
|
+
* - `processes` — PROCESS_STEP participation (Process-kind partners).
|
|
18
|
+
* - `cochanges` — git-history partners for the target's enclosing file.
|
|
19
|
+
* - `operations` — OpenAPI `Operation` nodes linked to a Route target via
|
|
20
|
+
* `HANDLES_ROUTE` (cross-stack trace from the OpenAPI phase).
|
|
21
|
+
* - `confidenceBreakdown` — provenance tally over every edge surfaced.
|
|
22
|
+
* - `content` (optional) — the target's indexed source, capped at
|
|
23
|
+
* {@link CONTENT_CHAR_CAP} characters. Only returned when
|
|
24
|
+
* `include_content` is true.
|
|
25
|
+
* - `location` — `{ filePath, startLine, endLine }` for quick jump-to.
|
|
26
|
+
*
|
|
27
|
+
* The flat `callers`, `callees`, `members`, and `owner` fields are kept on
|
|
28
|
+
* the response for backward compat with pre-parity consumers; new callers
|
|
29
|
+
* should prefer the `incoming` / `outgoing` category buckets.
|
|
30
|
+
*/
|
|
31
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
32
|
+
import { type ToolContext, type ToolResult } from "./shared.js";
|
|
33
|
+
interface ContextArgs {
|
|
34
|
+
readonly symbol?: string | undefined;
|
|
35
|
+
readonly name?: string | undefined;
|
|
36
|
+
readonly uid?: string | undefined;
|
|
37
|
+
readonly repo?: string | undefined;
|
|
38
|
+
readonly repo_uri?: string | undefined;
|
|
39
|
+
readonly kind?: string | undefined;
|
|
40
|
+
readonly file_path?: string | undefined;
|
|
41
|
+
readonly filePath?: string | undefined;
|
|
42
|
+
readonly include_content?: boolean | undefined;
|
|
43
|
+
}
|
|
44
|
+
export declare function runContext(ctx: ToolContext, args: ContextArgs): Promise<ToolResult>;
|
|
45
|
+
export declare function registerContextTool(server: McpServer, ctx: ToolContext): void;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/tools/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQzE,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EAGhB,MAAM,aAAa,CAAC;AA8HrB,UAAU,WAAW;IACnB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChD;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA2KzF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAiB7E"}
|