@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,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sql` — raw read-only SQL / Cypher over the local graph store.
|
|
3
|
+
*
|
|
4
|
+
* The tool accepts either `sql` (DuckDB backend) or `cypher` (graph-db
|
|
5
|
+
* backend, `CODEHUB_STORE=lbug`) — exactly one per call. The read-only
|
|
6
|
+
* guards (`assertReadOnlySql` / `assertReadOnlyCypher`) reject any write
|
|
7
|
+
* verb before the statement reaches the underlying engine.
|
|
8
|
+
*
|
|
9
|
+
* - SQL path: `SqlGuardError` on violation → INVALID_INPUT envelope.
|
|
10
|
+
* - Cypher path: `CypherGuardError` on violation → INVALID_INPUT envelope.
|
|
11
|
+
* - Cypher path without `CODEHUB_STORE=lbug` → INVALID_INPUT with a
|
|
12
|
+
* "cypher unavailable" hint.
|
|
13
|
+
* - Both `sql` and `cypher` supplied → INVALID_INPUT "choose one".
|
|
14
|
+
*
|
|
15
|
+
* A default 5 s timeout caps runaway queries (DuckDB itself has no SQL
|
|
16
|
+
* timeout — the adapter interrupts via a JS timer; the graph-db adapter
|
|
17
|
+
* honours `timeoutMs` through its pool).
|
|
18
|
+
*
|
|
19
|
+
* The tool description embeds the node-kind and relation-type vocabulary
|
|
20
|
+
* so agents can author correct queries without a separate schema probe.
|
|
21
|
+
*/
|
|
22
|
+
import { NODE_KINDS, RELATION_TYPES } from "@opencodehub/core-types";
|
|
23
|
+
import { CypherGuardError, SqlGuardError } from "@opencodehub/storage";
|
|
24
|
+
import { z } from "zod";
|
|
25
|
+
import { toolError, toolErrorFromUnknown } from "../error-envelope.js";
|
|
26
|
+
import { withNextSteps } from "../next-step-hints.js";
|
|
27
|
+
import { stalenessFromMeta } from "../staleness.js";
|
|
28
|
+
import { fromToolResult, repoArgShape, toToolResult, withStore, } from "./shared.js";
|
|
29
|
+
const SqlInput = {
|
|
30
|
+
sql: z
|
|
31
|
+
.string()
|
|
32
|
+
.min(1)
|
|
33
|
+
.optional()
|
|
34
|
+
.describe("Read-only SQL statement (DuckDB backend). INSERT/UPDATE/DELETE/DDL are rejected by the guard. Provide exactly one of `sql` or `cypher`."),
|
|
35
|
+
cypher: z
|
|
36
|
+
.string()
|
|
37
|
+
.min(1)
|
|
38
|
+
.optional()
|
|
39
|
+
.describe("Read-only Cypher statement (graph-db backend; requires `CODEHUB_STORE=lbug`). CREATE/DELETE/SET/MERGE/REMOVE/DROP are rejected by the guard. Provide exactly one of `sql` or `cypher`."),
|
|
40
|
+
...repoArgShape,
|
|
41
|
+
timeout_ms: z
|
|
42
|
+
.number()
|
|
43
|
+
.int()
|
|
44
|
+
.min(100)
|
|
45
|
+
.max(60_000)
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("Per-statement timeout in milliseconds. Default 5000, max 60000."),
|
|
48
|
+
};
|
|
49
|
+
const SCHEMA_HINT = [
|
|
50
|
+
"Tables: nodes(id, kind, name, file_path, start_line, end_line, is_exported, signature, parameter_count, return_type, declared_type, owner, url, method, tool_name, content, content_hash, inferred_label, symbol_count, cohesion, keywords, entry_point_id, step_count, level, response_keys, description), relations(id, from_id, to_id, type, confidence, reason, step), embeddings(id, node_id, chunk_index, start_line, end_line, vector, content_hash), store_meta(id, schema_version, last_commit, indexed_at, node_count, edge_count, stats_json).",
|
|
51
|
+
`NodeKind values: ${NODE_KINDS.join(", ")}.`,
|
|
52
|
+
`RelationType values: ${RELATION_TYPES.join(", ")}.`,
|
|
53
|
+
].join("\n");
|
|
54
|
+
/**
|
|
55
|
+
* Determine the configured backend from the environment. Exposed as a
|
|
56
|
+
* thin indirection so tests can flip the env var mid-run without touching
|
|
57
|
+
* the tool surface.
|
|
58
|
+
*/
|
|
59
|
+
function isGraphDbBackend(env = process.env) {
|
|
60
|
+
return env["CODEHUB_STORE"] === "lbug";
|
|
61
|
+
}
|
|
62
|
+
export async function runSql(ctx, args) {
|
|
63
|
+
// Exactly-one-of input guard. The Zod schema marks both fields optional
|
|
64
|
+
// so we can emit a targeted error envelope rather than a schema-level
|
|
65
|
+
// rejection that might get aliased to a generic "invalid input" string.
|
|
66
|
+
const hasSql = typeof args.sql === "string" && args.sql.length > 0;
|
|
67
|
+
const hasCypher = typeof args.cypher === "string" && args.cypher.length > 0;
|
|
68
|
+
if (hasSql && hasCypher) {
|
|
69
|
+
return toToolResult(toolError("INVALID_INPUT", "provide exactly one of `sql` or `cypher`", "The sql tool accepts either a SQL statement (DuckDB backend) or a Cypher statement (graph-db backend), not both."));
|
|
70
|
+
}
|
|
71
|
+
if (!hasSql && !hasCypher) {
|
|
72
|
+
return toToolResult(toolError("INVALID_INPUT", "provide one of `sql` or `cypher`", "The sql tool requires exactly one of the two input fields."));
|
|
73
|
+
}
|
|
74
|
+
if (hasCypher && !isGraphDbBackend()) {
|
|
75
|
+
return toToolResult(toolError("INVALID_INPUT", "cypher unavailable without `CODEHUB_STORE=lbug`", "Set `CODEHUB_STORE=lbug` in the MCP server's environment to enable the graph-db backend. The default DuckDB backend only speaks SQL."));
|
|
76
|
+
}
|
|
77
|
+
const timeoutMs = args.timeout_ms ?? 5000;
|
|
78
|
+
// Exactly one of these is defined at this point; TypeScript cannot
|
|
79
|
+
// narrow the union through the `hasSql/hasCypher` booleans so we branch
|
|
80
|
+
// on `hasCypher` and assert the narrowed type locally.
|
|
81
|
+
const statement = hasCypher ? args.cypher : args.sql;
|
|
82
|
+
const isCypher = hasCypher;
|
|
83
|
+
const call = await withStore(ctx, args, async (store, resolved) => {
|
|
84
|
+
try {
|
|
85
|
+
// Apply the guard BEFORE the store call so the rejection message
|
|
86
|
+
// carries the guard's own context (SqlGuardError / CypherGuardError),
|
|
87
|
+
// and so the store never sees a write verb. The store's own readonly
|
|
88
|
+
// mode would also reject writes, but the guard produces a cleaner
|
|
89
|
+
// user-facing error.
|
|
90
|
+
//
|
|
91
|
+
// Routing: SQL → `temporal.exec()` (the `--sql` escape hatch on
|
|
92
|
+
// ITemporalStore); Cypher → `graph.execCypher` (the graph-only
|
|
93
|
+
// adapter's escape hatch). Tools that don't have the
|
|
94
|
+
// corresponding capability surface a clear error envelope.
|
|
95
|
+
let rawRows;
|
|
96
|
+
if (isCypher) {
|
|
97
|
+
const exec = store.graph.execCypher;
|
|
98
|
+
if (typeof exec !== "function") {
|
|
99
|
+
return toolError("INVALID_INPUT", "cypher unavailable: graph adapter does not expose execCypher", "Set `CODEHUB_STORE=lbug` to enable the graph-db backend that exposes the Cypher escape hatch.");
|
|
100
|
+
}
|
|
101
|
+
rawRows = await exec.call(store.graph, statement);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
rawRows = await store.temporal.exec(statement, [], { timeoutMs });
|
|
105
|
+
}
|
|
106
|
+
// MCP serialises structuredContent via JSON, which cannot handle
|
|
107
|
+
// bigint values (DuckDB returns COUNT(*) etc. as bigint). Coerce
|
|
108
|
+
// every bigint to a plain number or string before handing the
|
|
109
|
+
// rows up the transport.
|
|
110
|
+
const rows = rawRows.map(sanitizeRowForJson);
|
|
111
|
+
const table = renderMarkdownTable(rows);
|
|
112
|
+
const lines = [
|
|
113
|
+
`Query returned ${rows.length} row(s).`,
|
|
114
|
+
rows.length === 0 ? "(no rows)" : table,
|
|
115
|
+
];
|
|
116
|
+
return withNextSteps(lines.join("\n"), {
|
|
117
|
+
row_count: rows.length,
|
|
118
|
+
rows,
|
|
119
|
+
columns: rows.length > 0 ? Object.keys(rows[0]) : [],
|
|
120
|
+
dialect: isCypher ? "cypher" : "sql",
|
|
121
|
+
}, rows.length > 0
|
|
122
|
+
? ["call `context` on a row's id column to drill into the graph"]
|
|
123
|
+
: ["broaden the WHERE clause or verify the NodeKind/RelationType filters"], stalenessFromMeta(resolved.meta));
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
if (err instanceof SqlGuardError) {
|
|
127
|
+
return toolError("INVALID_INPUT", err.message, "Only SELECT-style queries are allowed. Remove DDL/DML keywords.");
|
|
128
|
+
}
|
|
129
|
+
if (err instanceof CypherGuardError) {
|
|
130
|
+
return toolError("INVALID_INPUT", err.message, "Only MATCH/RETURN/WITH/WHERE/ORDER BY/LIMIT/SKIP/UNWIND (and the QUERY_FTS_INDEX / QUERY_VECTOR_INDEX procedures) are allowed. Remove any CREATE/DELETE/SET/MERGE/REMOVE/DROP keywords.");
|
|
131
|
+
}
|
|
132
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
133
|
+
if (msg.includes("timeout")) {
|
|
134
|
+
return toolError("RATE_LIMITED", msg, "Add a tighter WHERE clause or raise timeout_ms (max 60000).");
|
|
135
|
+
}
|
|
136
|
+
return toolErrorFromUnknown(err);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return toToolResult(call);
|
|
140
|
+
}
|
|
141
|
+
export function registerSqlTool(server, ctx) {
|
|
142
|
+
server.registerTool("sql", {
|
|
143
|
+
title: "Read-only SQL / Cypher over the code graph",
|
|
144
|
+
description: [
|
|
145
|
+
"Execute a read-only query against the local graph store. Supply EXACTLY ONE of `sql` (DuckDB backend, default) or `cypher` (graph-db backend, requires `CODEHUB_STORE=lbug`). Results are returned as a markdown table plus raw row objects. Use this for one-off questions that the higher-level tools don't cover — e.g. 'find every exported function in src/auth/'.",
|
|
146
|
+
"",
|
|
147
|
+
SCHEMA_HINT,
|
|
148
|
+
].join("\n"),
|
|
149
|
+
inputSchema: SqlInput,
|
|
150
|
+
annotations: {
|
|
151
|
+
readOnlyHint: true,
|
|
152
|
+
destructiveHint: false,
|
|
153
|
+
idempotentHint: true,
|
|
154
|
+
openWorldHint: false,
|
|
155
|
+
},
|
|
156
|
+
}, async (args) => fromToolResult(await runSql(ctx, args)));
|
|
157
|
+
}
|
|
158
|
+
function renderMarkdownTable(rows) {
|
|
159
|
+
const first = rows[0];
|
|
160
|
+
if (!first)
|
|
161
|
+
return "";
|
|
162
|
+
const cols = Object.keys(first);
|
|
163
|
+
const header = `| ${cols.join(" | ")} |`;
|
|
164
|
+
const divider = `| ${cols.map(() => "---").join(" | ")} |`;
|
|
165
|
+
const body = rows
|
|
166
|
+
.slice(0, 100)
|
|
167
|
+
.map((row) => `| ${cols.map((c) => formatCell(row[c])).join(" | ")} |`)
|
|
168
|
+
.join("\n");
|
|
169
|
+
const footer = rows.length > 100 ? `\n_(truncated — showing first 100 of ${rows.length} rows)_` : "";
|
|
170
|
+
return `${header}\n${divider}\n${body}${footer}`;
|
|
171
|
+
}
|
|
172
|
+
function formatCell(v) {
|
|
173
|
+
if (v === null || v === undefined)
|
|
174
|
+
return "";
|
|
175
|
+
if (typeof v === "string") {
|
|
176
|
+
// Escape pipes so the markdown table renders. Escape `\` first so a
|
|
177
|
+
// pre-existing `\` in the value cannot pair with the appended `\|` to
|
|
178
|
+
// form `\\|` (which renders as `\` + literal pipe instead of an
|
|
179
|
+
// escaped pipe — js/incomplete-sanitization).
|
|
180
|
+
return v.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\n/g, " ");
|
|
181
|
+
}
|
|
182
|
+
if (typeof v === "number" || typeof v === "boolean" || typeof v === "bigint") {
|
|
183
|
+
return String(v);
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
return JSON.stringify(v);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return String(v);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Coerce BigInt values to numbers (when they fit) or decimal strings, so
|
|
194
|
+
* the row objects can round-trip through JSON for MCP transport.
|
|
195
|
+
*/
|
|
196
|
+
function sanitizeRowForJson(row) {
|
|
197
|
+
const out = {};
|
|
198
|
+
for (const [k, v] of Object.entries(row)) {
|
|
199
|
+
out[k] = sanitizeValueForJson(v);
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
function sanitizeValueForJson(v) {
|
|
204
|
+
if (typeof v === "bigint") {
|
|
205
|
+
// Safe number range → plain number; otherwise preserve as string.
|
|
206
|
+
if (v >= BigInt(Number.MIN_SAFE_INTEGER) && v <= BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
207
|
+
return Number(v);
|
|
208
|
+
}
|
|
209
|
+
return v.toString();
|
|
210
|
+
}
|
|
211
|
+
if (Array.isArray(v))
|
|
212
|
+
return v.map(sanitizeValueForJson);
|
|
213
|
+
if (v !== null && typeof v === "object") {
|
|
214
|
+
const out = {};
|
|
215
|
+
for (const [k, val] of Object.entries(v)) {
|
|
216
|
+
out[k] = sanitizeValueForJson(val);
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
return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,gBAAgB,CAAC,EAAE,CAAC;YACjF,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtB,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACzD,IAAI,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAA4B,CAAC,EAAE,CAAC;YACpE,GAAG,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tool_map` — enumerate `Tool` nodes (MCP-style tool definitions).
|
|
3
|
+
*
|
|
4
|
+
* Returns one row per Tool node matching the optional `tool` name
|
|
5
|
+
* substring. Each row carries the tool's file_path, description, and
|
|
6
|
+
* parsed inputSchema (when the ingestion phase populated one).
|
|
7
|
+
*
|
|
8
|
+
* The storage schema stores the tool's input schema as a JSON string in
|
|
9
|
+
* the `properties_bag` column under the key `inputSchemaJson` (written
|
|
10
|
+
* by the tools ingestion phase). When the column is absent or the JSON
|
|
11
|
+
* is malformed we fall back to the raw string so callers still see the
|
|
12
|
+
* data unredacted.
|
|
13
|
+
*/
|
|
14
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
15
|
+
import { type ToolContext, type ToolResult } from "./shared.js";
|
|
16
|
+
interface ToolMapArgs {
|
|
17
|
+
readonly repo?: string | undefined;
|
|
18
|
+
readonly repo_uri?: string | undefined;
|
|
19
|
+
readonly tool?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare function runToolMap(ctx: ToolContext, args: ToolMapArgs): Promise<ToolResult>;
|
|
22
|
+
export declare function registerToolMapTool(server: McpServer, ctx: ToolContext): void;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=tool-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-map.d.ts","sourceRoot":"","sources":["../../src/tools/tool-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EAGhB,MAAM,aAAa,CAAC;AAcrB,UAAU,WAAW;IACnB,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;CACpC;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAuDzF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAiB7E"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tool_map` — enumerate `Tool` nodes (MCP-style tool definitions).
|
|
3
|
+
*
|
|
4
|
+
* Returns one row per Tool node matching the optional `tool` name
|
|
5
|
+
* substring. Each row carries the tool's file_path, description, and
|
|
6
|
+
* parsed inputSchema (when the ingestion phase populated one).
|
|
7
|
+
*
|
|
8
|
+
* The storage schema stores the tool's input schema as a JSON string in
|
|
9
|
+
* the `properties_bag` column under the key `inputSchemaJson` (written
|
|
10
|
+
* by the tools ingestion phase). When the column is absent or the JSON
|
|
11
|
+
* is malformed we fall back to the raw string so callers still see the
|
|
12
|
+
* data unredacted.
|
|
13
|
+
*/
|
|
14
|
+
// biome-ignore-all lint/complexity/useLiteralKeys: dot-access disallowed on Record index signatures
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { toolErrorFromUnknown } from "../error-envelope.js";
|
|
17
|
+
import { withNextSteps } from "../next-step-hints.js";
|
|
18
|
+
import { stalenessFromMeta } from "../staleness.js";
|
|
19
|
+
import { fromToolResult, repoArgShape, toToolResult, withStore, } from "./shared.js";
|
|
20
|
+
const ToolMapInput = {
|
|
21
|
+
...repoArgShape,
|
|
22
|
+
tool: z.string().optional().describe("Substring match against tool name."),
|
|
23
|
+
};
|
|
24
|
+
export async function runToolMap(ctx, args) {
|
|
25
|
+
const call = await withStore(ctx, args, async (store, resolved) => {
|
|
26
|
+
try {
|
|
27
|
+
let listed = await store.graph.listNodesByKind("Tool", { limit: 500 });
|
|
28
|
+
if (args.tool !== undefined && args.tool.length > 0) {
|
|
29
|
+
const sub = args.tool;
|
|
30
|
+
listed = listed.filter((n) => n.name.includes(sub));
|
|
31
|
+
}
|
|
32
|
+
const sorted = [...listed].sort((a, b) => {
|
|
33
|
+
if (a.name !== b.name)
|
|
34
|
+
return a.name < b.name ? -1 : 1;
|
|
35
|
+
return a.filePath < b.filePath ? -1 : a.filePath > b.filePath ? 1 : 0;
|
|
36
|
+
});
|
|
37
|
+
const tools = sorted.map((t) => ({
|
|
38
|
+
name: t.name,
|
|
39
|
+
filePath: t.filePath,
|
|
40
|
+
description: t.description ?? "",
|
|
41
|
+
inputSchema: t.inputSchemaJson ? parseInputSchema(t.inputSchemaJson) : null,
|
|
42
|
+
}));
|
|
43
|
+
const header = `Tools (${tools.length}) for ${resolved.name}${args.tool ? ` · name~${args.tool}` : ""}:`;
|
|
44
|
+
const body = tools.length === 0
|
|
45
|
+
? "(no Tool nodes — the `tools` ingestion phase found no MCP tool literals)"
|
|
46
|
+
: tools
|
|
47
|
+
.map((t) => {
|
|
48
|
+
const desc = t.description.length > 0 ? ` — ${t.description}` : "";
|
|
49
|
+
const schema = t.inputSchema === null ? "" : " [schema]";
|
|
50
|
+
return `- ${t.name}${schema} @ ${t.filePath}${desc}`;
|
|
51
|
+
})
|
|
52
|
+
.join("\n");
|
|
53
|
+
const next = tools.length === 0
|
|
54
|
+
? [
|
|
55
|
+
"call `list_repos` to confirm the repo is indexed",
|
|
56
|
+
"re-index with `codehub analyze` to refresh Tool nodes",
|
|
57
|
+
]
|
|
58
|
+
: [
|
|
59
|
+
`call \`context\` with symbol="${tools[0]?.name ?? ""}" to see callers/callees`,
|
|
60
|
+
"call `query` with a tool concept to locate related symbols",
|
|
61
|
+
];
|
|
62
|
+
return withNextSteps(`${header}\n${body}`, { tools, total: tools.length }, next, stalenessFromMeta(resolved.meta));
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
return toolErrorFromUnknown(err);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return toToolResult(call);
|
|
69
|
+
}
|
|
70
|
+
export function registerToolMapTool(server, ctx) {
|
|
71
|
+
server.registerTool("tool_map", {
|
|
72
|
+
title: "Map MCP Tool definitions",
|
|
73
|
+
description: "Enumerate Tool nodes detected by the tools ingestion phase, optionally filtered by name substring. Returns name, file_path, description, and the parsed input schema (JSON-decoded when available, raw string when unparseable, null when unset). Read-only.",
|
|
74
|
+
inputSchema: ToolMapInput,
|
|
75
|
+
annotations: {
|
|
76
|
+
readOnlyHint: true,
|
|
77
|
+
destructiveHint: false,
|
|
78
|
+
idempotentHint: true,
|
|
79
|
+
openWorldHint: false,
|
|
80
|
+
},
|
|
81
|
+
}, async (args) => fromToolResult(await runToolMap(ctx, args)));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parse the embedded JSON string. Returns the parsed value on success,
|
|
85
|
+
* the raw string on parse failure, or null when no schema was present.
|
|
86
|
+
*/
|
|
87
|
+
function parseInputSchema(raw) {
|
|
88
|
+
if (raw === null)
|
|
89
|
+
return null;
|
|
90
|
+
try {
|
|
91
|
+
return JSON.parse(raw);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return raw;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=tool-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-map.js","sourceRoot":"","sources":["../../src/tools/tool-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,oGAAoG;AAGpG,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,EACL,cAAc,EACd,YAAY,EAGZ,YAAY,EACZ,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,MAAM,YAAY,GAAG;IACnB,GAAG,YAAY;IACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;CAC3E,CAAC;AAeF,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAgB,EAAE,IAAiB;IAClE,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;QAChE,IAAI,CAAC;YACH,IAAI,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACvE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAA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ACT,8PAA8P;QAChQ,WAAW,EAAE,YAAY;QACzB,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,KAAK;SACrB;KACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAC5D,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,GAAkB;IAC1C,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC9B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `verdict` — 5-tier verdict composition MCP tool.
|
|
3
|
+
*
|
|
4
|
+
* Inputs: base ref (default "main"), head ref (default "HEAD"), optional
|
|
5
|
+
* repo and config overrides. Annotations: readOnly (we do shell out to
|
|
6
|
+
* git for the diff; that remains read-only), closedWorld (all data comes
|
|
7
|
+
* from the indexed graph), NOT idempotent (git state can change between
|
|
8
|
+
* calls).
|
|
9
|
+
*
|
|
10
|
+
* Output: the full {@link VerdictResponse} under `structuredContent`, plus
|
|
11
|
+
* the rendered markdown comment in `content`.
|
|
12
|
+
*/
|
|
13
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
|
+
import { type ToolContext, type ToolResult } from "./shared.js";
|
|
15
|
+
interface VerdictConfigArgs {
|
|
16
|
+
readonly blockThreshold?: number | undefined;
|
|
17
|
+
readonly escalationThreshold?: number | undefined;
|
|
18
|
+
readonly warningThreshold?: number | undefined;
|
|
19
|
+
readonly communityBoundaryThreshold?: number | undefined;
|
|
20
|
+
readonly communityBoundaryEscalation?: boolean | undefined;
|
|
21
|
+
readonly fixFollowFeatThreshold?: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
interface VerdictArgs {
|
|
24
|
+
readonly repo?: string | undefined;
|
|
25
|
+
readonly repo_uri?: string | undefined;
|
|
26
|
+
readonly base?: string | undefined;
|
|
27
|
+
readonly head?: string | undefined;
|
|
28
|
+
readonly config?: VerdictConfigArgs | undefined;
|
|
29
|
+
}
|
|
30
|
+
export declare function runVerdict(ctx: ToolContext, args: VerdictArgs): Promise<ToolResult>;
|
|
31
|
+
export declare function registerVerdictTool(server: McpServer, ctx: ToolContext): void;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=verdict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict.d.ts","sourceRoot":"","sources":["../../src/tools/verdict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EAGhB,MAAM,aAAa,CAAC;AAqBrB,UAAU,iBAAiB;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,0BAA0B,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzD,QAAQ,CAAC,2BAA2B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3D,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtD;AAED,UAAU,WAAW;IACnB,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,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;CACjD;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAkEzF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAiB7E"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `verdict` — 5-tier verdict composition MCP tool.
|
|
3
|
+
*
|
|
4
|
+
* Inputs: base ref (default "main"), head ref (default "HEAD"), optional
|
|
5
|
+
* repo and config overrides. Annotations: readOnly (we do shell out to
|
|
6
|
+
* git for the diff; that remains read-only), closedWorld (all data comes
|
|
7
|
+
* from the indexed graph), NOT idempotent (git state can change between
|
|
8
|
+
* calls).
|
|
9
|
+
*
|
|
10
|
+
* Output: the full {@link VerdictResponse} under `structuredContent`, plus
|
|
11
|
+
* the rendered markdown comment in `content`.
|
|
12
|
+
*/
|
|
13
|
+
import { computeVerdict } from "@opencodehub/analysis";
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import { toolErrorFromUnknown } from "../error-envelope.js";
|
|
16
|
+
import { withNextSteps } from "../next-step-hints.js";
|
|
17
|
+
import { stalenessFromMeta } from "../staleness.js";
|
|
18
|
+
import { fromToolResult, repoArgShape, toToolResult, withStore, } from "./shared.js";
|
|
19
|
+
const VerdictInput = {
|
|
20
|
+
...repoArgShape,
|
|
21
|
+
base: z.string().optional().describe("Base git ref (default 'main')."),
|
|
22
|
+
head: z.string().optional().describe("Head git ref (default 'HEAD')."),
|
|
23
|
+
config: z
|
|
24
|
+
.object({
|
|
25
|
+
blockThreshold: z.number().int().nonnegative().optional(),
|
|
26
|
+
escalationThreshold: z.number().int().nonnegative().optional(),
|
|
27
|
+
warningThreshold: z.number().int().nonnegative().optional(),
|
|
28
|
+
communityBoundaryThreshold: z.number().int().nonnegative().optional(),
|
|
29
|
+
communityBoundaryEscalation: z.boolean().optional(),
|
|
30
|
+
fixFollowFeatThreshold: z.number().min(0).max(1).optional(),
|
|
31
|
+
})
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Override the verdict thresholds. Values not supplied fall back to .codehub/config.toml or the PRD defaults."),
|
|
34
|
+
};
|
|
35
|
+
export async function runVerdict(ctx, args) {
|
|
36
|
+
const call = await withStore(ctx, args, async (store, resolved) => {
|
|
37
|
+
try {
|
|
38
|
+
const config = {};
|
|
39
|
+
if (args.config) {
|
|
40
|
+
if (args.config.blockThreshold !== undefined)
|
|
41
|
+
config["blockThreshold"] = args.config.blockThreshold;
|
|
42
|
+
if (args.config.escalationThreshold !== undefined)
|
|
43
|
+
config["escalationThreshold"] = args.config.escalationThreshold;
|
|
44
|
+
if (args.config.warningThreshold !== undefined)
|
|
45
|
+
config["warningThreshold"] = args.config.warningThreshold;
|
|
46
|
+
if (args.config.communityBoundaryThreshold !== undefined)
|
|
47
|
+
config["communityBoundaryThreshold"] = args.config.communityBoundaryThreshold;
|
|
48
|
+
if (args.config.communityBoundaryEscalation !== undefined)
|
|
49
|
+
config["communityBoundaryEscalation"] = args.config.communityBoundaryEscalation;
|
|
50
|
+
if (args.config.fixFollowFeatThreshold !== undefined)
|
|
51
|
+
config["fixFollowFeatThreshold"] = args.config.fixFollowFeatThreshold;
|
|
52
|
+
}
|
|
53
|
+
const verdict = await computeVerdict(store.graph, {
|
|
54
|
+
repoPath: resolved.repoPath,
|
|
55
|
+
...(args.base !== undefined ? { base: args.base } : {}),
|
|
56
|
+
...(args.head !== undefined ? { head: args.head } : {}),
|
|
57
|
+
...(Object.keys(config).length > 0 ? { config } : {}),
|
|
58
|
+
});
|
|
59
|
+
const next = [];
|
|
60
|
+
if (verdict.verdict === "block" || verdict.verdict === "expert_review") {
|
|
61
|
+
next.push("call `impact` on each affected symbol to identify reducible scope", "call `owners` on the touched files to loop in the top contributor");
|
|
62
|
+
}
|
|
63
|
+
else if (verdict.verdict === "dual_review") {
|
|
64
|
+
next.push("call `detect_changes` to confirm the full set of affected processes", "call `list_findings` filtered by the changed files to spot latent warnings");
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
next.push("call `list_findings` to confirm the scanner run is clean", "commit with the suggested reviewer(s) to de-escalate");
|
|
68
|
+
}
|
|
69
|
+
return withNextSteps(verdict.reviewCommentMarkdown, {
|
|
70
|
+
verdict: verdict.verdict,
|
|
71
|
+
confidence: verdict.confidence,
|
|
72
|
+
exit_code: verdict.exitCode,
|
|
73
|
+
blast_radius: verdict.blastRadius,
|
|
74
|
+
changed_file_count: verdict.changedFileCount,
|
|
75
|
+
affected_symbol_count: verdict.affectedSymbolCount,
|
|
76
|
+
communities_touched: verdict.communitiesTouched,
|
|
77
|
+
decision_boundary: verdict.decisionBoundary,
|
|
78
|
+
reasoning_chain: verdict.reasoningChain,
|
|
79
|
+
recommended_reviewers: verdict.recommendedReviewers,
|
|
80
|
+
github_labels: verdict.githubLabels,
|
|
81
|
+
}, next, stalenessFromMeta(resolved.meta));
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
return toolErrorFromUnknown(err);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return toToolResult(call);
|
|
88
|
+
}
|
|
89
|
+
export function registerVerdictTool(server, ctx) {
|
|
90
|
+
server.registerTool("verdict", {
|
|
91
|
+
title: "5-tier PR verdict",
|
|
92
|
+
description: "Composite diff verdict: auto_merge | single_review | dual_review | expert_review | block. Aggregates blast radius, community boundaries, findings, orphan grade, fix-follow-feat density, and ownership into a single decision with confidence, reasoning chain, decision-boundary distance, recommended reviewers, GitHub labels, and a PR-comment markdown string. Exit codes: 0/1/2 mapped per PRD.",
|
|
93
|
+
inputSchema: VerdictInput,
|
|
94
|
+
annotations: {
|
|
95
|
+
readOnlyHint: true,
|
|
96
|
+
destructiveHint: false,
|
|
97
|
+
openWorldHint: false,
|
|
98
|
+
idempotentHint: false,
|
|
99
|
+
},
|
|
100
|
+
}, async (args) => fromToolResult(await runVerdict(ctx, args)));
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=verdict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict.js","sourceRoot":"","sources":["../../src/tools/verdict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,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,EACL,cAAc,EACd,YAAY,EAGZ,YAAY,EACZ,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,MAAM,YAAY,GAAG;IACnB,GAAG,YAAY;IACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;IACtE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;IACtE,MAAM,EAAE,CAAC;SACN,MAAM,CAAC;QACN,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;QACzD,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;QAC9D,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAA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1
|
+
{
|
|
2
|
+
"name": "@opencodehub/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OpenCodeHub — stdio MCP server exposing code-graph + group tools",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/theagenticguy/opencodehub.git",
|
|
9
|
+
"directory": "packages/mcp"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/theagenticguy/opencodehub#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/theagenticguy/opencodehub/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/**/*.js",
|
|
26
|
+
"!dist/**/*.test.js",
|
|
27
|
+
"dist/**/*.d.ts",
|
|
28
|
+
"!dist/**/*.test.d.ts",
|
|
29
|
+
"dist/**/*.js.map",
|
|
30
|
+
"!dist/**/*.test.js.map",
|
|
31
|
+
"dist/**/*.d.ts.map",
|
|
32
|
+
"!dist/**/*.test.d.ts.map"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
36
|
+
"lru-cache": "11.3.6",
|
|
37
|
+
"zod": "4.4.3",
|
|
38
|
+
"@opencodehub/core-types": "0.1.0",
|
|
39
|
+
"@opencodehub/analysis": "0.1.0",
|
|
40
|
+
"@opencodehub/pack": "0.1.0",
|
|
41
|
+
"@opencodehub/embedder": "0.1.0",
|
|
42
|
+
"@opencodehub/sarif": "0.1.0",
|
|
43
|
+
"@opencodehub/storage": "0.1.0",
|
|
44
|
+
"@opencodehub/scanners": "0.1.0",
|
|
45
|
+
"@opencodehub/search": "0.1.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "25.6.2",
|
|
49
|
+
"typescript": "6.0.3"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"opencodehub",
|
|
56
|
+
"code-intelligence",
|
|
57
|
+
"mcp",
|
|
58
|
+
"model-context-protocol",
|
|
59
|
+
"ai",
|
|
60
|
+
"code-graph",
|
|
61
|
+
"static-analysis",
|
|
62
|
+
"mcp-server",
|
|
63
|
+
"stdio",
|
|
64
|
+
"claude",
|
|
65
|
+
"cursor",
|
|
66
|
+
"coding-agent"
|
|
67
|
+
],
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=22.0.0"
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "tsc -b",
|
|
73
|
+
"test": "node --test ./dist/**/*.test.js",
|
|
74
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
75
|
+
}
|
|
76
|
+
}
|