@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,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared repo-resolution + store-checkout helper for resource handlers.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the tool-side `withStore` but returns shape appropriate for
|
|
5
|
+
* resources: instead of `CallToolResult`, resource callbacks return
|
|
6
|
+
* `ReadResourceResult`, which carries a plain text body. Errors
|
|
7
|
+
* (missing pool, repo not found, DuckDB open failure) are surfaced as a
|
|
8
|
+
* YAML error envelope inside the resource body so the agent sees the
|
|
9
|
+
* problem inline rather than receiving a transport-level fault.
|
|
10
|
+
*/
|
|
11
|
+
import { RepoResolveError, resolveRepo } from "../repo-resolver.js";
|
|
12
|
+
/**
|
|
13
|
+
* Acquire a read-only store handle for `repoName`, invoke `fn`, and
|
|
14
|
+
* release. When resolution fails, return a YAML error envelope the
|
|
15
|
+
* caller should pass straight through. The callback is responsible for
|
|
16
|
+
* building the happy-path result.
|
|
17
|
+
*/
|
|
18
|
+
export async function withResourceStore(uriHref, repoName, opts, fn) {
|
|
19
|
+
if (!opts.pool) {
|
|
20
|
+
return yamlError(uriHref, "pool unavailable", "Server was built without a connection pool.");
|
|
21
|
+
}
|
|
22
|
+
const resolveOpts = opts.home !== undefined ? { home: opts.home } : {};
|
|
23
|
+
try {
|
|
24
|
+
const resolved = await resolveRepo(repoName, resolveOpts);
|
|
25
|
+
const store = await opts.pool.acquire(resolved.repoPath, resolved.dbPath);
|
|
26
|
+
try {
|
|
27
|
+
return await fn(store, resolved.name);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
await opts.pool.release(resolved.repoPath);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
if (err instanceof RepoResolveError) {
|
|
35
|
+
return yamlError(uriHref, err.code, err.hint);
|
|
36
|
+
}
|
|
37
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
38
|
+
return yamlError(uriHref, "internal error", msg);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function yamlError(uri, error, hint) {
|
|
42
|
+
const body = [`error: ${quote(error)}`, `hint: ${quote(hint)}`, ""].join("\n");
|
|
43
|
+
return {
|
|
44
|
+
contents: [
|
|
45
|
+
{
|
|
46
|
+
uri,
|
|
47
|
+
mimeType: "text/yaml",
|
|
48
|
+
text: body,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function quote(value) {
|
|
54
|
+
if (/^[A-Za-z0-9._\-/]+$/.test(value))
|
|
55
|
+
return value;
|
|
56
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=store-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-helper.js","sourceRoot":"","sources":["../../src/resources/store-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAWpE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,QAA4B,EAC5B,IAA0B,EAC1B,EAAmE;IAEnE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,SAAS,CAAC,OAAO,EAAE,kBAAkB,EAAE,6CAA6C,CAAC,CAAC;IAC/F,CAAC;IACD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1E,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxC,CAAC;gBAAS,CAAC;YACT,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,gBAAgB,EAAE,CAAC;YACpC,OAAO,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,KAAa,EAAE,IAAY;IACzD,MAAM,IAAI,GAAG,CAAC,UAAU,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/E,OAAO;QACL,QAAQ,EAAE;YACR;gBACE,GAAG;gBACH,QAAQ,EAAE,WAAW;gBACrB,IAAI,EAAE,IAAI;aACX;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,KAAa;IAC1B,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal YAML scalar quoter shared across resource handlers.
|
|
3
|
+
*
|
|
4
|
+
* Resources emit YAML for agent readability (see `repo-context.ts`). The
|
|
5
|
+
* quoter is intentionally conservative: plain identifiers pass through
|
|
6
|
+
* unquoted, anything else is wrapped in double quotes with embedded
|
|
7
|
+
* quotes escaped. A loose parser will round-trip either form.
|
|
8
|
+
*/
|
|
9
|
+
export declare function yamlScalar(value: string | number | boolean): string;
|
|
10
|
+
//# sourceMappingURL=yaml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../src/resources/yaml.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAInE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal YAML scalar quoter shared across resource handlers.
|
|
3
|
+
*
|
|
4
|
+
* Resources emit YAML for agent readability (see `repo-context.ts`). The
|
|
5
|
+
* quoter is intentionally conservative: plain identifiers pass through
|
|
6
|
+
* unquoted, anything else is wrapped in double quotes with embedded
|
|
7
|
+
* quotes escaped. A loose parser will round-trip either form.
|
|
8
|
+
*/
|
|
9
|
+
export function yamlScalar(value) {
|
|
10
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
11
|
+
return String(value);
|
|
12
|
+
if (/^[A-Za-z0-9._\-/]+$/.test(value))
|
|
13
|
+
return value;
|
|
14
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=yaml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../src/resources/yaml.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,UAAU,UAAU,CAAC,KAAgC;IACzD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IAClF,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC;AAClE,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stdio MCP server for OpenCodeHub.
|
|
3
|
+
*
|
|
4
|
+
* Wires together the tool and resource registrations against a single
|
|
5
|
+
* shared `ConnectionPool`. The stdio transport reads JSON-RPC from stdin
|
|
6
|
+
* and writes responses to stdout; anything else the process emits (the
|
|
7
|
+
* connection pool, tool handlers) should go to stderr so it does not
|
|
8
|
+
* corrupt the transport.
|
|
9
|
+
*
|
|
10
|
+
* The `instructions` field is prose the model sees at session start. We
|
|
11
|
+
* use it to nudge agents toward `list_repos` first, and we advertise the
|
|
12
|
+
* staleness envelope so clients are primed to surface it.
|
|
13
|
+
*/
|
|
14
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
15
|
+
import { ConnectionPool } from "./connection-pool.js";
|
|
16
|
+
export interface StartServerOptions {
|
|
17
|
+
/** Override the home directory used to locate ~/.codehub/registry.json. */
|
|
18
|
+
readonly home?: string;
|
|
19
|
+
/** Override the connection-pool cap (default 8). */
|
|
20
|
+
readonly poolMax?: number;
|
|
21
|
+
/** Override the connection-pool idle TTL (default 15 minutes). */
|
|
22
|
+
readonly poolTtlMs?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Suppress the one-time "embeddings weights not found" startup warning.
|
|
25
|
+
* Tests set this so stderr stays quiet; production callers should leave
|
|
26
|
+
* it unset.
|
|
27
|
+
*/
|
|
28
|
+
readonly silentEmbedderProbe?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface RunningServer {
|
|
31
|
+
readonly server: McpServer;
|
|
32
|
+
readonly pool: ConnectionPool;
|
|
33
|
+
shutdown(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build a fully-wired `McpServer` (without connecting a transport). The
|
|
37
|
+
* CLI wrapper uses this to embed the server in-process; the stdio entry
|
|
38
|
+
* point in `index.ts` connects a stdio transport on top.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildServer(opts?: StartServerOptions): RunningServer;
|
|
41
|
+
/**
|
|
42
|
+
* Entry point: build the server, connect stdio, and install a SIGINT /
|
|
43
|
+
* SIGTERM / stdin-close handler that drains the pool before exiting.
|
|
44
|
+
*/
|
|
45
|
+
export declare function startStdioServer(opts?: StartServerOptions): Promise<void>;
|
|
46
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAmDtD,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC;AAiCD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,GAAE,kBAAuB,GAAG,aAAa,CAuExE;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBnF"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stdio MCP server for OpenCodeHub.
|
|
3
|
+
*
|
|
4
|
+
* Wires together the tool and resource registrations against a single
|
|
5
|
+
* shared `ConnectionPool`. The stdio transport reads JSON-RPC from stdin
|
|
6
|
+
* and writes responses to stdout; anything else the process emits (the
|
|
7
|
+
* connection pool, tool handlers) should go to stderr so it does not
|
|
8
|
+
* corrupt the transport.
|
|
9
|
+
*
|
|
10
|
+
* The `instructions` field is prose the model sees at session start. We
|
|
11
|
+
* use it to nudge agents toward `list_repos` first, and we advertise the
|
|
12
|
+
* staleness envelope so clients are primed to surface it.
|
|
13
|
+
*/
|
|
14
|
+
import { access } from "node:fs/promises";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
17
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
18
|
+
import { getDefaultModelRoot, modelFileName, resolveModelDir } from "@opencodehub/embedder";
|
|
19
|
+
import { ConnectionPool } from "./connection-pool.js";
|
|
20
|
+
import { registerRepoClusterResource } from "./resources/repo-cluster.js";
|
|
21
|
+
import { registerRepoClustersResource } from "./resources/repo-clusters.js";
|
|
22
|
+
import { registerRepoContextResource } from "./resources/repo-context.js";
|
|
23
|
+
import { registerRepoProcessResource } from "./resources/repo-process.js";
|
|
24
|
+
import { registerRepoProcessesResource } from "./resources/repo-processes.js";
|
|
25
|
+
import { registerRepoSchemaResource } from "./resources/repo-schema.js";
|
|
26
|
+
import { registerReposResource } from "./resources/repos.js";
|
|
27
|
+
import { registerApiImpactTool } from "./tools/api-impact.js";
|
|
28
|
+
import { registerContextTool } from "./tools/context.js";
|
|
29
|
+
import { registerDependenciesTool } from "./tools/dependencies.js";
|
|
30
|
+
import { registerDetectChangesTool } from "./tools/detect-changes.js";
|
|
31
|
+
import { registerGroupContractsTool } from "./tools/group-contracts.js";
|
|
32
|
+
import { registerGroupCrossRepoLinksTool } from "./tools/group-cross-repo-links.js";
|
|
33
|
+
import { registerGroupListTool } from "./tools/group-list.js";
|
|
34
|
+
import { registerGroupQueryTool } from "./tools/group-query.js";
|
|
35
|
+
import { registerGroupStatusTool } from "./tools/group-status.js";
|
|
36
|
+
import { registerGroupSyncTool } from "./tools/group-sync.js";
|
|
37
|
+
import { registerImpactTool } from "./tools/impact.js";
|
|
38
|
+
import { registerLicenseAuditTool } from "./tools/license-audit.js";
|
|
39
|
+
import { registerListDeadCodeTool } from "./tools/list-dead-code.js";
|
|
40
|
+
import { registerListFindingsTool } from "./tools/list-findings.js";
|
|
41
|
+
import { registerListFindingsDeltaTool } from "./tools/list-findings-delta.js";
|
|
42
|
+
import { registerListReposTool } from "./tools/list-repos.js";
|
|
43
|
+
import { registerOwnersTool } from "./tools/owners.js";
|
|
44
|
+
import { registerPackCodebaseTool } from "./tools/pack-codebase.js";
|
|
45
|
+
import { registerProjectProfileTool } from "./tools/project-profile.js";
|
|
46
|
+
import { registerQueryTool } from "./tools/query.js";
|
|
47
|
+
import { registerRemoveDeadCodeTool } from "./tools/remove-dead-code.js";
|
|
48
|
+
import { registerRenameTool } from "./tools/rename.js";
|
|
49
|
+
import { registerRiskTrendsTool } from "./tools/risk-trends.js";
|
|
50
|
+
import { registerRouteMapTool } from "./tools/route-map.js";
|
|
51
|
+
import { registerScanTool } from "./tools/scan.js";
|
|
52
|
+
import { registerShapeCheckTool } from "./tools/shape-check.js";
|
|
53
|
+
import { registerSqlTool } from "./tools/sql.js";
|
|
54
|
+
import { registerToolMapTool } from "./tools/tool-map.js";
|
|
55
|
+
import { registerVerdictTool } from "./tools/verdict.js";
|
|
56
|
+
const SERVER_NAME = "opencodehub";
|
|
57
|
+
const SERVER_VERSION = "0.0.0";
|
|
58
|
+
const INSTRUCTIONS = [
|
|
59
|
+
"OpenCodeHub exposes indexed code graphs for MCP agents.",
|
|
60
|
+
"Typical flow: call `list_repos` first to discover indexed repos, then route subsequent calls through one of those repo names.",
|
|
61
|
+
"Every per-repo tool (`query`, `context`, `impact`, `detect_changes`, `rename`, `sql`, `scan`, `list_findings`, `list_findings_delta`, `list_dead_code`, `remove_dead_code`, `license_audit`, `project_profile`, `dependencies`, `owners`, `risk_trends`, `verdict`) accepts an optional `repo` argument (registry name) or a `repo_uri` alias (Sourcegraph-style URI like `github.com/org/repo`, or `local:<hash>` for unpublished repos; wins when both are provided). When exactly one repo is registered, both are optional and the tool defaults to that repo. When ≥ 2 repos are registered and neither is supplied, the tool returns `AMBIGUOUS_REPO` — the structured envelope carries `structuredContent.error.choices[]` (capped at 10, with `{repo_uri, default_branch, group}`) plus `total_matches`, so a caller can retry with one of `choices[].repo_uri`.",
|
|
62
|
+
"Every tool response includes a `next_steps` array under structuredContent and a `_meta.codehub/staleness` entry when the index may be behind HEAD.",
|
|
63
|
+
"Use `query` to locate symbols, `context` for a 360-degree view, `impact` for blast radius, `detect_changes` to map a diff to flows, `rename` for coordinated renames (dry-run by default), `dependencies` for the external package list, `license_audit` for a copyleft/unknown/proprietary tier check of dependencies, `list_findings` to browse SARIF findings, `list_findings_delta` to diff the latest scan against a frozen baseline (new/fixed/unchanged/updated buckets), `scan` to run Priority-1 scanners (openWorld — spawns processes), `verdict` for a 5-tier PR decision (exit codes 0/1/2), `risk_trends` for per-community trend lines and 30-day projections, and `sql` for bespoke queries.",
|
|
64
|
+
"For cross-repo work, call `group_list` to discover named repo groups, then `group_query`/`group_status` to fan out BM25 search and staleness across the group. `group_query` returns `{ group, query, results: [{ _repo, _rrf_score, ... }], per_repo, warnings }`; results are tagged with the source repo and per-repo errors surface in `per_repo[].error` + `warnings[]` (the fan-out never aborts on a single-repo failure). Use `group_sync` to materialize a cross-repo contract registry (HTTP / gRPC / topic) under `~/.codehub/groups/<name>/contracts.json`, then `group_contracts` to list the DuckDB-backed FETCHES↔Route edges together with the registry's signature-matched cross-links.",
|
|
65
|
+
].join(" ");
|
|
66
|
+
/**
|
|
67
|
+
* Probe for gte-modernbert-base weights on disk. Runs once at server startup
|
|
68
|
+
* and logs a single structured warning when the weights are absent so
|
|
69
|
+
* agents see the BM25-only fallback reason. Never throws: a missing or
|
|
70
|
+
* unreadable model directory is a supported deployment mode.
|
|
71
|
+
*/
|
|
72
|
+
async function probeEmbedderWeights(silent) {
|
|
73
|
+
if (silent)
|
|
74
|
+
return;
|
|
75
|
+
try {
|
|
76
|
+
for (const variant of ["fp32", "int8"]) {
|
|
77
|
+
const modelDir = resolveModelDir(undefined, variant);
|
|
78
|
+
const modelPath = join(modelDir, modelFileName(variant));
|
|
79
|
+
try {
|
|
80
|
+
await access(modelPath);
|
|
81
|
+
// At least one variant is installed — stay silent.
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// try the next variant
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const root = getDefaultModelRoot();
|
|
89
|
+
console.warn(`[mcp] hybrid: embeddings weights not found at ${root}/models/gte-modernbert-base/; run \`codehub setup --embeddings\`. Falling back to BM25-only.`);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
// Probe failure is non-fatal; surface the reason but keep going.
|
|
93
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
94
|
+
console.warn(`[mcp] hybrid: embedder probe failed: ${message}. Falling back to BM25-only.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build a fully-wired `McpServer` (without connecting a transport). The
|
|
99
|
+
* CLI wrapper uses this to embed the server in-process; the stdio entry
|
|
100
|
+
* point in `index.ts` connects a stdio transport on top.
|
|
101
|
+
*/
|
|
102
|
+
export function buildServer(opts = {}) {
|
|
103
|
+
const poolOpts = {};
|
|
104
|
+
if (opts.poolMax !== undefined)
|
|
105
|
+
poolOpts.max = opts.poolMax;
|
|
106
|
+
if (opts.poolTtlMs !== undefined)
|
|
107
|
+
poolOpts.ttlMs = opts.poolTtlMs;
|
|
108
|
+
const pool = new ConnectionPool(poolOpts);
|
|
109
|
+
const ctx = opts.home !== undefined ? { pool, home: opts.home } : { pool };
|
|
110
|
+
// Fire-and-forget embedder availability probe so the one-time warning is
|
|
111
|
+
// emitted before the first `query` call. Never blocks startup; never
|
|
112
|
+
// affects tool registration.
|
|
113
|
+
void probeEmbedderWeights(opts.silentEmbedderProbe === true);
|
|
114
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, {
|
|
115
|
+
capabilities: {
|
|
116
|
+
tools: { listChanged: false },
|
|
117
|
+
resources: { listChanged: false },
|
|
118
|
+
},
|
|
119
|
+
instructions: INSTRUCTIONS,
|
|
120
|
+
});
|
|
121
|
+
registerListReposTool(server, ctx);
|
|
122
|
+
registerPackCodebaseTool(server, ctx);
|
|
123
|
+
registerQueryTool(server, ctx);
|
|
124
|
+
registerContextTool(server, ctx);
|
|
125
|
+
registerImpactTool(server, ctx);
|
|
126
|
+
registerDetectChangesTool(server, ctx);
|
|
127
|
+
registerRenameTool(server, ctx);
|
|
128
|
+
registerSqlTool(server, ctx);
|
|
129
|
+
registerGroupListTool(server, ctx);
|
|
130
|
+
registerGroupQueryTool(server, ctx);
|
|
131
|
+
registerGroupStatusTool(server, ctx);
|
|
132
|
+
registerGroupContractsTool(server, ctx);
|
|
133
|
+
registerGroupCrossRepoLinksTool(server, ctx);
|
|
134
|
+
registerGroupSyncTool(server, ctx);
|
|
135
|
+
registerProjectProfileTool(server, ctx);
|
|
136
|
+
registerDependenciesTool(server, ctx);
|
|
137
|
+
registerLicenseAuditTool(server, ctx);
|
|
138
|
+
registerOwnersTool(server, ctx);
|
|
139
|
+
registerListFindingsTool(server, ctx);
|
|
140
|
+
registerListFindingsDeltaTool(server, ctx);
|
|
141
|
+
registerListDeadCodeTool(server, ctx);
|
|
142
|
+
registerRemoveDeadCodeTool(server, ctx);
|
|
143
|
+
registerScanTool(server, ctx);
|
|
144
|
+
registerVerdictTool(server, ctx);
|
|
145
|
+
registerRiskTrendsTool(server, ctx);
|
|
146
|
+
registerRouteMapTool(server, ctx);
|
|
147
|
+
registerApiImpactTool(server, ctx);
|
|
148
|
+
registerShapeCheckTool(server, ctx);
|
|
149
|
+
registerToolMapTool(server, ctx);
|
|
150
|
+
const resCtx = opts.home !== undefined ? { home: opts.home, pool } : { pool };
|
|
151
|
+
registerReposResource(server, resCtx);
|
|
152
|
+
registerRepoContextResource(server, resCtx);
|
|
153
|
+
registerRepoSchemaResource(server, resCtx);
|
|
154
|
+
registerRepoClustersResource(server, resCtx);
|
|
155
|
+
registerRepoClusterResource(server, resCtx);
|
|
156
|
+
registerRepoProcessesResource(server, resCtx);
|
|
157
|
+
registerRepoProcessResource(server, resCtx);
|
|
158
|
+
return {
|
|
159
|
+
server,
|
|
160
|
+
pool,
|
|
161
|
+
shutdown: async () => {
|
|
162
|
+
await server.close();
|
|
163
|
+
await pool.shutdown();
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Entry point: build the server, connect stdio, and install a SIGINT /
|
|
169
|
+
* SIGTERM / stdin-close handler that drains the pool before exiting.
|
|
170
|
+
*/
|
|
171
|
+
export async function startStdioServer(opts = {}) {
|
|
172
|
+
const running = buildServer(opts);
|
|
173
|
+
const transport = new StdioServerTransport();
|
|
174
|
+
await running.server.connect(transport);
|
|
175
|
+
const bail = async (code) => {
|
|
176
|
+
try {
|
|
177
|
+
await running.shutdown();
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
process.exit(code);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
process.on("SIGINT", () => {
|
|
184
|
+
void bail(130);
|
|
185
|
+
});
|
|
186
|
+
process.on("SIGTERM", () => {
|
|
187
|
+
void bail(143);
|
|
188
|
+
});
|
|
189
|
+
// Some clients signal disconnect via stdin close rather than a signal.
|
|
190
|
+
process.stdin.on("close", () => {
|
|
191
|
+
void bail(0);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceR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@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin wrappers around `@opencodehub/analysis.computeStaleness`.
|
|
3
|
+
*
|
|
4
|
+
* Tool handlers want a simple `Promise<StalenessEnvelope | undefined>`;
|
|
5
|
+
* the analysis package returns a slightly wider shape. We adapt and, as
|
|
6
|
+
* a cheap optimization, fall back to a meta-only envelope when the
|
|
7
|
+
* caller explicitly asks to skip the git probe (resources/read, for
|
|
8
|
+
* example, fires many times and should not shell out each time).
|
|
9
|
+
*/
|
|
10
|
+
import type { StalenessEnvelope } from "@opencodehub/core-types";
|
|
11
|
+
import type { StoreMeta } from "@opencodehub/storage";
|
|
12
|
+
export declare function stalenessFor(repoPath: string, meta: StoreMeta | undefined): Promise<StalenessEnvelope | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Non-async fallback used in hot paths where we want to skip the git
|
|
15
|
+
* probe. Emits a 0-behind envelope carrying just the last-indexed commit
|
|
16
|
+
* from the sidecar.
|
|
17
|
+
*/
|
|
18
|
+
export declare function stalenessFromMeta(meta: StoreMeta | undefined): StalenessEnvelope | undefined;
|
|
19
|
+
//# sourceMappingURL=staleness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staleness.d.ts","sourceRoot":"","sources":["../src/staleness.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,SAAS,GAAG,SAAS,GAC1B,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAaxC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAO5F"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin wrappers around `@opencodehub/analysis.computeStaleness`.
|
|
3
|
+
*
|
|
4
|
+
* Tool handlers want a simple `Promise<StalenessEnvelope | undefined>`;
|
|
5
|
+
* the analysis package returns a slightly wider shape. We adapt and, as
|
|
6
|
+
* a cheap optimization, fall back to a meta-only envelope when the
|
|
7
|
+
* caller explicitly asks to skip the git probe (resources/read, for
|
|
8
|
+
* example, fires many times and should not shell out each time).
|
|
9
|
+
*/
|
|
10
|
+
import { computeStaleness } from "@opencodehub/analysis";
|
|
11
|
+
export async function stalenessFor(repoPath, meta) {
|
|
12
|
+
if (!meta)
|
|
13
|
+
return undefined;
|
|
14
|
+
const result = await computeStaleness(repoPath, meta.lastCommit);
|
|
15
|
+
const envelope = {
|
|
16
|
+
isStale: result.isStale,
|
|
17
|
+
commitsBehind: result.commitsBehind,
|
|
18
|
+
...(result.hint !== undefined ? { hint: result.hint } : {}),
|
|
19
|
+
...(result.lastIndexedCommit !== undefined
|
|
20
|
+
? { lastIndexedCommit: result.lastIndexedCommit }
|
|
21
|
+
: {}),
|
|
22
|
+
...(result.currentCommit !== undefined ? { currentCommit: result.currentCommit } : {}),
|
|
23
|
+
};
|
|
24
|
+
return envelope;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Non-async fallback used in hot paths where we want to skip the git
|
|
28
|
+
* probe. Emits a 0-behind envelope carrying just the last-indexed commit
|
|
29
|
+
* from the sidecar.
|
|
30
|
+
*/
|
|
31
|
+
export function stalenessFromMeta(meta) {
|
|
32
|
+
if (!meta)
|
|
33
|
+
return undefined;
|
|
34
|
+
return {
|
|
35
|
+
isStale: false,
|
|
36
|
+
commitsBehind: 0,
|
|
37
|
+
...(meta.lastCommit !== undefined ? { lastIndexedCommit: meta.lastCommit } : {}),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=staleness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staleness.js","sourceRoot":"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|
|
1
|
+
/**
|
|
2
|
+
* Shared MCP test fixtures.
|
|
3
|
+
*
|
|
4
|
+
* The production tools/resources call typed finders on `IGraphStore`
|
|
5
|
+
* (`listNodes`, `listNodesByKind`, `listEdges`,
|
|
6
|
+
* `listEdgesByType`, `listFindings`, `listRoutes`, `getRepoNode`,
|
|
7
|
+
* `traverseAncestors`, `listEmbeddingHashes`, etc.) rather than raw
|
|
8
|
+
* `query(<sql>)`. This file gives every mcp test a small, composable
|
|
9
|
+
* in-memory backing store so each test only needs to seed the data it
|
|
10
|
+
* cares about — nodes, edges, findings, routes — and supply
|
|
11
|
+
* test-specific overrides as needed.
|
|
12
|
+
*
|
|
13
|
+
* The module is intentionally tolerant: every typed finder has a sane
|
|
14
|
+
* default that filters the seeded arrays exactly the way the real
|
|
15
|
+
* `DuckDbStore` does. Tests can override a single finder via the
|
|
16
|
+
* `overrides` parameter when they need bespoke behaviour (e.g. cochanges,
|
|
17
|
+
* BM25 search, traversal).
|
|
18
|
+
*/
|
|
19
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
20
|
+
import type { CallToolResult, ReadResourceResult } from "@modelcontextprotocol/sdk/types.js";
|
|
21
|
+
import type { DuckDbStore, IGraphStore, ITemporalStore, Store } from "@opencodehub/storage";
|
|
22
|
+
import { ConnectionPool } from "./connection-pool.js";
|
|
23
|
+
/**
|
|
24
|
+
* Wrap an in-memory IGraphStore-shaped fake as the composed `Store`
|
|
25
|
+
* (`OpenStoreResult`) that the connection pool returns. The same
|
|
26
|
+
* instance backs both `graph` and `temporal` because DuckDbStore
|
|
27
|
+
* implements both interfaces over a single connection in production.
|
|
28
|
+
*/
|
|
29
|
+
export declare function wrapAsStore(fake: unknown): Store;
|
|
30
|
+
export interface FakeNodeLike {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly kind: string;
|
|
33
|
+
readonly name?: string;
|
|
34
|
+
readonly filePath?: string;
|
|
35
|
+
readonly file_path?: string;
|
|
36
|
+
readonly [extra: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
export interface FakeEdgeLike {
|
|
39
|
+
readonly type: string;
|
|
40
|
+
readonly from?: string;
|
|
41
|
+
readonly to?: string;
|
|
42
|
+
readonly fromId?: string;
|
|
43
|
+
readonly toId?: string;
|
|
44
|
+
readonly from_id?: string;
|
|
45
|
+
readonly to_id?: string;
|
|
46
|
+
readonly confidence?: number;
|
|
47
|
+
readonly step?: number | null;
|
|
48
|
+
readonly reason?: string;
|
|
49
|
+
readonly [extra: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Findings/routes/dependencies/repos are typed loosely on input — tests
|
|
53
|
+
* pass plain records and the helper coerces to the typed `*Node` shape on
|
|
54
|
+
* the way out of each finder. This sidesteps `NodeId`-branded ids while
|
|
55
|
+
* keeping the keys discoverable.
|
|
56
|
+
*/
|
|
57
|
+
export type FakeFinding = {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly kind?: "Finding" | undefined;
|
|
60
|
+
readonly name?: string | undefined;
|
|
61
|
+
readonly filePath?: string | undefined;
|
|
62
|
+
readonly scannerId?: string | undefined;
|
|
63
|
+
readonly ruleId?: string | undefined;
|
|
64
|
+
readonly severity?: "note" | "warning" | "error" | "none" | undefined;
|
|
65
|
+
readonly message?: string | undefined;
|
|
66
|
+
readonly propertiesBag?: Record<string, unknown> | undefined;
|
|
67
|
+
readonly startLine?: number | undefined;
|
|
68
|
+
readonly endLine?: number | undefined;
|
|
69
|
+
readonly partialFingerprint?: string | undefined;
|
|
70
|
+
readonly baselineState?: "new" | "unchanged" | "updated" | "absent" | undefined;
|
|
71
|
+
readonly suppressedJson?: string | undefined;
|
|
72
|
+
};
|
|
73
|
+
export type FakeRoute = {
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly kind?: "Route" | undefined;
|
|
76
|
+
readonly name?: string | undefined;
|
|
77
|
+
readonly filePath?: string | undefined;
|
|
78
|
+
readonly url?: string | undefined;
|
|
79
|
+
readonly method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | string | undefined;
|
|
80
|
+
readonly responseKeys?: readonly string[] | undefined;
|
|
81
|
+
readonly httpMethod?: string | undefined;
|
|
82
|
+
readonly httpPath?: string | undefined;
|
|
83
|
+
readonly path?: string | undefined;
|
|
84
|
+
};
|
|
85
|
+
export type FakeDependency = {
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly kind?: "Dependency" | undefined;
|
|
88
|
+
readonly name?: string | undefined;
|
|
89
|
+
readonly filePath?: string | undefined;
|
|
90
|
+
readonly ecosystem?: string | undefined;
|
|
91
|
+
readonly version?: string | undefined;
|
|
92
|
+
readonly license?: string | undefined;
|
|
93
|
+
readonly licenseTier?: "permissive" | "weak-copyleft" | "strong-copyleft" | "proprietary" | "unknown" | undefined;
|
|
94
|
+
};
|
|
95
|
+
export type FakeRepo = {
|
|
96
|
+
readonly id: string;
|
|
97
|
+
readonly kind?: "Repo" | undefined;
|
|
98
|
+
readonly name?: string | undefined;
|
|
99
|
+
readonly filePath?: string | undefined;
|
|
100
|
+
readonly originUrl?: string | null | undefined;
|
|
101
|
+
readonly defaultBranch?: string | null | undefined;
|
|
102
|
+
readonly group?: string | null | undefined;
|
|
103
|
+
readonly repoUri?: string | undefined;
|
|
104
|
+
};
|
|
105
|
+
export interface FakeData {
|
|
106
|
+
readonly nodes?: readonly FakeNodeLike[];
|
|
107
|
+
readonly edges?: readonly FakeEdgeLike[];
|
|
108
|
+
readonly findings?: readonly FakeFinding[];
|
|
109
|
+
readonly routes?: readonly FakeRoute[];
|
|
110
|
+
readonly dependencies?: readonly FakeDependency[];
|
|
111
|
+
readonly repoNodes?: readonly FakeRepo[];
|
|
112
|
+
readonly embeddingHashes?: ReadonlyMap<string, string>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Per-finder override map. Any finder a test sets on this object replaces
|
|
116
|
+
* the default seed-filter implementation. Useful when a test needs custom
|
|
117
|
+
* BM25 results, cochange rows, or traversal output.
|
|
118
|
+
*/
|
|
119
|
+
export type StoreOverrides = Partial<{
|
|
120
|
+
[K in keyof IGraphStore]: IGraphStore[K];
|
|
121
|
+
}> & Partial<{
|
|
122
|
+
lookupCochangesForFile: ITemporalStore["lookupCochangesForFile"];
|
|
123
|
+
lookupCochangesBetween: ITemporalStore["lookupCochangesBetween"];
|
|
124
|
+
lookupSymbolSummary: ITemporalStore["lookupSymbolSummary"];
|
|
125
|
+
lookupSymbolSummariesByNode: ITemporalStore["lookupSymbolSummariesByNode"];
|
|
126
|
+
bulkLoadCochanges: ITemporalStore["bulkLoadCochanges"];
|
|
127
|
+
bulkLoadSymbolSummaries: ITemporalStore["bulkLoadSymbolSummaries"];
|
|
128
|
+
exec: ITemporalStore["exec"];
|
|
129
|
+
execCypher: NonNullable<IGraphStore["execCypher"]>;
|
|
130
|
+
query: (sql: string, params?: readonly unknown[], opts?: {
|
|
131
|
+
readonly timeoutMs?: number;
|
|
132
|
+
}) => Promise<readonly Record<string, unknown>[]>;
|
|
133
|
+
}>;
|
|
134
|
+
export declare function makeFakeGraphStore(data?: FakeData, overrides?: StoreOverrides): DuckDbStore;
|
|
135
|
+
export interface FakeRegistryEntry {
|
|
136
|
+
readonly name: string;
|
|
137
|
+
readonly path?: string;
|
|
138
|
+
readonly indexedAt?: string;
|
|
139
|
+
readonly nodeCount?: number;
|
|
140
|
+
readonly edgeCount?: number;
|
|
141
|
+
readonly lastCommit?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface McpHarness {
|
|
144
|
+
readonly home: string;
|
|
145
|
+
readonly pool: ConnectionPool;
|
|
146
|
+
readonly server: McpServer;
|
|
147
|
+
readonly repoPath: string;
|
|
148
|
+
readonly repoName: string;
|
|
149
|
+
}
|
|
150
|
+
export interface MakeHarnessOptions {
|
|
151
|
+
readonly repoName?: string;
|
|
152
|
+
readonly registry?: Readonly<Record<string, FakeRegistryEntry>>;
|
|
153
|
+
readonly storeFactory: () => DuckDbStore | Promise<DuckDbStore>;
|
|
154
|
+
readonly serverCapabilities?: {
|
|
155
|
+
tools?: object;
|
|
156
|
+
resources?: object;
|
|
157
|
+
};
|
|
158
|
+
readonly tmpPrefix?: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Spin up a temp `home/.codehub/registry.json`, a `ConnectionPool` whose
|
|
162
|
+
* factory returns the supplied fake store, and a fresh `McpServer`. Hands
|
|
163
|
+
* everything back to the caller's `fn` and tears down on exit.
|
|
164
|
+
*/
|
|
165
|
+
export declare function withMcpHarness(opts: MakeHarnessOptions, fn: (h: McpHarness) => Promise<void>): Promise<void>;
|
|
166
|
+
export type ToolHandler = (args: unknown, extra: unknown) => Promise<CallToolResult>;
|
|
167
|
+
export declare function getToolHandler(server: McpServer, name: string): ToolHandler;
|
|
168
|
+
export type ResourceReadHandler = (uri: URL, vars: Record<string, string | string[]>, extra: unknown) => Promise<ReadResourceResult>;
|
|
169
|
+
export declare function getResourceHandler(server: McpServer, name: string): ResourceReadHandler;
|
|
170
|
+
//# sourceMappingURL=test-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAY7F,OAAO,KAAK,EAKV,WAAW,EAEX,WAAW,EACX,cAAc,EAWd,KAAK,EAMN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAOtD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,KAAK,CAYhD;AAOD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,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