@opensip-cli/mcp 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +33 -0
- package/dist/__tests__/command-transport.test.d.ts +13 -0
- package/dist/__tests__/command-transport.test.d.ts.map +1 -0
- package/dist/__tests__/command-transport.test.js +63 -0
- package/dist/__tests__/command-transport.test.js.map +1 -0
- package/dist/__tests__/e2e-stdio.test.d.ts +16 -0
- package/dist/__tests__/e2e-stdio.test.d.ts.map +1 -0
- package/dist/__tests__/e2e-stdio.test.js +271 -0
- package/dist/__tests__/e2e-stdio.test.js.map +1 -0
- package/dist/__tests__/freshness.test.d.ts +9 -0
- package/dist/__tests__/freshness.test.d.ts.map +1 -0
- package/dist/__tests__/freshness.test.js +78 -0
- package/dist/__tests__/freshness.test.js.map +1 -0
- package/dist/__tests__/integration.test.d.ts +20 -0
- package/dist/__tests__/integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration.test.js +178 -0
- package/dist/__tests__/integration.test.js.map +1 -0
- package/dist/__tests__/register-mcp-graph-adapters.test.d.ts +12 -0
- package/dist/__tests__/register-mcp-graph-adapters.test.d.ts.map +1 -0
- package/dist/__tests__/register-mcp-graph-adapters.test.js +47 -0
- package/dist/__tests__/register-mcp-graph-adapters.test.js.map +1 -0
- package/dist/__tests__/session-results-read-port.test.d.ts +13 -0
- package/dist/__tests__/session-results-read-port.test.d.ts.map +1 -0
- package/dist/__tests__/session-results-read-port.test.js +151 -0
- package/dist/__tests__/session-results-read-port.test.js.map +1 -0
- package/dist/__tests__/sqlite-graph-read-port.test.d.ts +12 -0
- package/dist/__tests__/sqlite-graph-read-port.test.d.ts.map +1 -0
- package/dist/__tests__/sqlite-graph-read-port.test.js +322 -0
- package/dist/__tests__/sqlite-graph-read-port.test.js.map +1 -0
- package/dist/__tests__/tool-descriptor.test.d.ts +9 -0
- package/dist/__tests__/tool-descriptor.test.d.ts.map +1 -0
- package/dist/__tests__/tool-descriptor.test.js +55 -0
- package/dist/__tests__/tool-descriptor.test.js.map +1 -0
- package/dist/catalog-generation.d.ts +22 -0
- package/dist/catalog-generation.d.ts.map +1 -0
- package/dist/catalog-generation.js +21 -0
- package/dist/catalog-generation.js.map +1 -0
- package/dist/command.d.ts +3 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +111 -0
- package/dist/command.js.map +1 -0
- package/dist/freshness.d.ts +50 -0
- package/dist/freshness.d.ts.map +1 -0
- package/dist/freshness.js +96 -0
- package/dist/freshness.js.map +1 -0
- package/dist/graph-read-port.d.ts +111 -0
- package/dist/graph-read-port.d.ts.map +1 -0
- package/dist/graph-read-port.js +16 -0
- package/dist/graph-read-port.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-error.d.ts +15 -0
- package/dist/mcp-error.d.ts.map +1 -0
- package/dist/mcp-error.js +5 -0
- package/dist/mcp-error.js.map +1 -0
- package/dist/register-mcp-graph-adapters.d.ts +3 -0
- package/dist/register-mcp-graph-adapters.d.ts.map +1 -0
- package/dist/register-mcp-graph-adapters.js +21 -0
- package/dist/register-mcp-graph-adapters.js.map +1 -0
- package/dist/result-dto.d.ts +63 -0
- package/dist/result-dto.d.ts.map +1 -0
- package/dist/result-dto.js +11 -0
- package/dist/result-dto.js.map +1 -0
- package/dist/results-read-port.d.ts +43 -0
- package/dist/results-read-port.d.ts.map +1 -0
- package/dist/results-read-port.js +13 -0
- package/dist/results-read-port.js.map +1 -0
- package/dist/server.d.ts +84 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +153 -0
- package/dist/server.js.map +1 -0
- package/dist/session-results-read-port.d.ts +42 -0
- package/dist/session-results-read-port.d.ts.map +1 -0
- package/dist/session-results-read-port.js +147 -0
- package/dist/session-results-read-port.js.map +1 -0
- package/dist/sqlite-graph-read-port.d.ts +88 -0
- package/dist/sqlite-graph-read-port.d.ts.map +1 -0
- package/dist/sqlite-graph-read-port.js +304 -0
- package/dist/sqlite-graph-read-port.js.map +1 -0
- package/dist/symbol-dto.d.ts +58 -0
- package/dist/symbol-dto.d.ts.map +1 -0
- package/dist/symbol-dto.js +12 -0
- package/dist/symbol-dto.js.map +1 -0
- package/dist/tool.d.ts +6 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +33 -0
- package/dist/tool.js.map +1 -0
- package/dist/tools/__tests__/graph-handlers.test.d.ts +11 -0
- package/dist/tools/__tests__/graph-handlers.test.d.ts.map +1 -0
- package/dist/tools/__tests__/graph-handlers.test.js +415 -0
- package/dist/tools/__tests__/graph-handlers.test.js.map +1 -0
- package/dist/tools/__tests__/graph-walk.test.d.ts +9 -0
- package/dist/tools/__tests__/graph-walk.test.d.ts.map +1 -0
- package/dist/tools/__tests__/graph-walk.test.js +72 -0
- package/dist/tools/__tests__/graph-walk.test.js.map +1 -0
- package/dist/tools/__tests__/refresh-graph.test.d.ts +11 -0
- package/dist/tools/__tests__/refresh-graph.test.d.ts.map +1 -0
- package/dist/tools/__tests__/refresh-graph.test.js +100 -0
- package/dist/tools/__tests__/refresh-graph.test.js.map +1 -0
- package/dist/tools/__tests__/result-handlers.test.d.ts +9 -0
- package/dist/tools/__tests__/result-handlers.test.d.ts.map +1 -0
- package/dist/tools/__tests__/result-handlers.test.js +194 -0
- package/dist/tools/__tests__/result-handlers.test.js.map +1 -0
- package/dist/tools/__tests__/schemas.test.d.ts +10 -0
- package/dist/tools/__tests__/schemas.test.d.ts.map +1 -0
- package/dist/tools/__tests__/schemas.test.js +73 -0
- package/dist/tools/__tests__/schemas.test.js.map +1 -0
- package/dist/tools/blast-radius.d.ts +12 -0
- package/dist/tools/blast-radius.d.ts.map +1 -0
- package/dist/tools/blast-radius.js +33 -0
- package/dist/tools/blast-radius.js.map +1 -0
- package/dist/tools/call-walk-tool.d.ts +17 -0
- package/dist/tools/call-walk-tool.d.ts.map +1 -0
- package/dist/tools/call-walk-tool.js +46 -0
- package/dist/tools/call-walk-tool.js.map +1 -0
- package/dist/tools/callees-of.d.ts +12 -0
- package/dist/tools/callees-of.d.ts.map +1 -0
- package/dist/tools/callees-of.js +20 -0
- package/dist/tools/callees-of.js.map +1 -0
- package/dist/tools/find-dead-code.d.ts +11 -0
- package/dist/tools/find-dead-code.d.ts.map +1 -0
- package/dist/tools/find-dead-code.js +26 -0
- package/dist/tools/find-dead-code.js.map +1 -0
- package/dist/tools/get-agent-catalog.d.ts +12 -0
- package/dist/tools/get-agent-catalog.d.ts.map +1 -0
- package/dist/tools/get-agent-catalog.js +23 -0
- package/dist/tools/get-agent-catalog.js.map +1 -0
- package/dist/tools/get-architecture.d.ts +11 -0
- package/dist/tools/get-architecture.d.ts.map +1 -0
- package/dist/tools/get-architecture.js +26 -0
- package/dist/tools/get-architecture.js.map +1 -0
- package/dist/tools/get-latest-findings.d.ts +13 -0
- package/dist/tools/get-latest-findings.d.ts.map +1 -0
- package/dist/tools/get-latest-findings.js +38 -0
- package/dist/tools/get-latest-findings.js.map +1 -0
- package/dist/tools/get-symbol.d.ts +18 -0
- package/dist/tools/get-symbol.d.ts.map +1 -0
- package/dist/tools/get-symbol.js +44 -0
- package/dist/tools/get-symbol.js.map +1 -0
- package/dist/tools/graph-walk.d.ts +50 -0
- package/dist/tools/graph-walk.d.ts.map +1 -0
- package/dist/tools/graph-walk.js +89 -0
- package/dist/tools/graph-walk.js.map +1 -0
- package/dist/tools/list-runs.d.ts +11 -0
- package/dist/tools/list-runs.d.ts.map +1 -0
- package/dist/tools/list-runs.js +37 -0
- package/dist/tools/list-runs.js.map +1 -0
- package/dist/tools/refresh-graph.d.ts +22 -0
- package/dist/tools/refresh-graph.d.ts.map +1 -0
- package/dist/tools/refresh-graph.js +75 -0
- package/dist/tools/refresh-graph.js.map +1 -0
- package/dist/tools/register.d.ts +13 -0
- package/dist/tools/register.d.ts.map +1 -0
- package/dist/tools/register.js +40 -0
- package/dist/tools/register.js.map +1 -0
- package/dist/tools/schemas.d.ts +54 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +59 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools/search-symbols.d.ts +12 -0
- package/dist/tools/search-symbols.d.ts.map +1 -0
- package/dist/tools/search-symbols.js +37 -0
- package/dist/tools/search-symbols.js.map +1 -0
- package/dist/tools/show-run.d.ts +12 -0
- package/dist/tools/show-run.d.ts.map +1 -0
- package/dist/tools/show-run.js +40 -0
- package/dist/tools/show-run.js.map +1 -0
- package/dist/tools/tool-result.d.ts +29 -0
- package/dist/tools/tool-result.d.ts.map +1 -0
- package/dist/tools/tool-result.js +39 -0
- package/dist/tools/tool-result.js.map +1 -0
- package/dist/tools/trace-path.d.ts +12 -0
- package/dist/tools/trace-path.d.ts.map +1 -0
- package/dist/tools/trace-path.js +57 -0
- package/dist/tools/trace-path.js.map +1 -0
- package/dist/tools/types.d.ts +20 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +11 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/who-calls.d.ts +12 -0
- package/dist/tools/who-calls.d.ts.map +1 -0
- package/dist/tools/who-calls.js +21 -0
- package/dist/tools/who-calls.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount the MCP tool catalog onto the server (ADR-0084, Phase 4).
|
|
3
|
+
*
|
|
4
|
+
* One place that wires every graph + result tool through the server's
|
|
5
|
+
* scope-wrapping {@link McpStdioServer.register} seam. The host calls this once
|
|
6
|
+
* (in `command.ts`) after building the ports; each tool reads ONLY its injected
|
|
7
|
+
* port (never `currentScope()`, never a run-command entry point).
|
|
8
|
+
*/
|
|
9
|
+
import { registerBlastRadius } from './blast-radius.js';
|
|
10
|
+
import { registerCalleesOf } from './callees-of.js';
|
|
11
|
+
import { registerFindDeadCode } from './find-dead-code.js';
|
|
12
|
+
import { registerGetAgentCatalog } from './get-agent-catalog.js';
|
|
13
|
+
import { registerGetArchitecture } from './get-architecture.js';
|
|
14
|
+
import { registerGetLatestFindings } from './get-latest-findings.js';
|
|
15
|
+
import { registerGetSymbol } from './get-symbol.js';
|
|
16
|
+
import { registerListRuns } from './list-runs.js';
|
|
17
|
+
import { registerRefreshGraph } from './refresh-graph.js';
|
|
18
|
+
import { registerSearchSymbols } from './search-symbols.js';
|
|
19
|
+
import { registerShowRun } from './show-run.js';
|
|
20
|
+
import { registerTracePath } from './trace-path.js';
|
|
21
|
+
import { registerWhoCalls } from './who-calls.js';
|
|
22
|
+
/** Register all 13 MCP tools (9 graph + 4 result) on `server`. */
|
|
23
|
+
export function registerMcpTools(server, deps) {
|
|
24
|
+
// ── Graph tools (over GraphReadPort) ──────────────────────────────
|
|
25
|
+
registerSearchSymbols(server, deps);
|
|
26
|
+
registerGetSymbol(server, deps);
|
|
27
|
+
registerWhoCalls(server, deps);
|
|
28
|
+
registerCalleesOf(server, deps);
|
|
29
|
+
registerTracePath(server, deps);
|
|
30
|
+
registerBlastRadius(server, deps);
|
|
31
|
+
registerFindDeadCode(server, deps);
|
|
32
|
+
registerGetArchitecture(server, deps);
|
|
33
|
+
registerRefreshGraph(server, deps);
|
|
34
|
+
// ── Result/history tools (over ResultsReadPort — replay only) ─────
|
|
35
|
+
registerGetAgentCatalog(server, deps);
|
|
36
|
+
registerListRuns(server, deps);
|
|
37
|
+
registerShowRun(server, deps);
|
|
38
|
+
registerGetLatestFindings(server, deps);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/tools/register.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,oBAAoB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AAM,EAAE,IAAI,CAAC,CAAC;IAC9B,yBAAyB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-tool Zod input field schemas (ADR-0084 §Hardening, Phase 7).
|
|
3
|
+
*
|
|
4
|
+
* Every MCP tool declares a Zod **raw shape** as its `inputSchema`; the SDK
|
|
5
|
+
* validates arguments against it BEFORE the wrapped handler runs, so a malformed
|
|
6
|
+
* `symbolId`, an out-of-range `depth`, or a `..`-traversal `file` is rejected at
|
|
7
|
+
* the trust boundary and never reaches a port. These are the shared field
|
|
8
|
+
* builders each tool composes — validation lives here (the boundary), never in
|
|
9
|
+
* the ports.
|
|
10
|
+
*
|
|
11
|
+
* DTOs carry symbol METADATA only; none of these inputs accept raw file bodies.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
/** Hard depth cap on bounded adjacency walks (bounds memory). */
|
|
15
|
+
export declare const MAX_DEPTH = 5;
|
|
16
|
+
/** Default walk depth when the caller omits it. */
|
|
17
|
+
export declare const DEFAULT_DEPTH = 5;
|
|
18
|
+
/** Hard cap on a caller-supplied `limit` (search / dead-code / architecture rows). */
|
|
19
|
+
export declare const MAX_LIMIT = 500;
|
|
20
|
+
/** Hard cap on a free-text query length (bounds work; search is substring, not regex → no ReDoS). */
|
|
21
|
+
export declare const MAX_QUERY_LEN = 200;
|
|
22
|
+
/** Hard cap on a file-path argument length. */
|
|
23
|
+
export declare const MAX_PATH_LEN = 1024;
|
|
24
|
+
/**
|
|
25
|
+
* A `symbolId` in the canonical `"${filePath}:${line}:${column}"` shape. The
|
|
26
|
+
* trailing two colon-groups must be integers; the leading file segment is
|
|
27
|
+
* unconstrained here (the port resolves it — an unknown id is a structured
|
|
28
|
+
* not-found, not a validation error).
|
|
29
|
+
*/
|
|
30
|
+
export declare const symbolId: () => z.ZodString;
|
|
31
|
+
/**
|
|
32
|
+
* A project-relative file path constrained to the project root: no absolute
|
|
33
|
+
* paths, no `..` traversal segments. The graph catalog keys occurrences by
|
|
34
|
+
* project-relative path, so a constrained relative path is also the only thing
|
|
35
|
+
* that can match.
|
|
36
|
+
*/
|
|
37
|
+
export declare const filePath: () => z.ZodString;
|
|
38
|
+
/** A 1-based source line number. */
|
|
39
|
+
export declare const line: () => z.ZodNumber;
|
|
40
|
+
/** A length-bounded free-text search query (substring match — not a regex). */
|
|
41
|
+
export declare const query: () => z.ZodString;
|
|
42
|
+
/** A walk depth, clamped to `[1, MAX_DEPTH]`, defaulting to {@link DEFAULT_DEPTH}. */
|
|
43
|
+
export declare const depth: () => z.ZodDefault<z.ZodNumber>;
|
|
44
|
+
/** An optional result cap, clamped to `[1, MAX_LIMIT]`. */
|
|
45
|
+
export declare const limit: () => z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
/** A registered-tool id (validated against the live registry in the handler). */
|
|
47
|
+
export declare const toolId: () => z.ZodString;
|
|
48
|
+
/** Severity filter for `get_latest_findings`. */
|
|
49
|
+
export declare const severity: () => z.ZodOptional<z.ZodEnum<{
|
|
50
|
+
errors: "errors";
|
|
51
|
+
warnings: "warnings";
|
|
52
|
+
all: "all";
|
|
53
|
+
}>>;
|
|
54
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iEAAiE;AACjE,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,mDAAmD;AACnD,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,sFAAsF;AACtF,eAAO,MAAM,SAAS,MAAM,CAAC;AAC7B,qGAAqG;AACrG,eAAO,MAAM,aAAa,MAAM,CAAC;AACjC,+CAA+C;AAC/C,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,mBAKsD,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,mBAYhB,CAAC;AAEN,oCAAoC;AACpC,eAAO,MAAM,IAAI,mBAAoC,CAAC;AAEtD,+EAA+E;AAC/E,eAAO,MAAM,KAAK,mBAA6C,CAAC;AAEhE,sFAAsF;AACtF,eAAO,MAAM,KAAK,iCAAsE,CAAC;AAEzF,2DAA2D;AAC3D,eAAO,MAAM,KAAK,kCAA8D,CAAC;AAEjF,iFAAiF;AACjF,eAAO,MAAM,MAAM,mBAAkC,CAAC;AAEtD,iDAAiD;AACjD,eAAO,MAAM,QAAQ;;;;GAAyD,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-tool Zod input field schemas (ADR-0084 §Hardening, Phase 7).
|
|
3
|
+
*
|
|
4
|
+
* Every MCP tool declares a Zod **raw shape** as its `inputSchema`; the SDK
|
|
5
|
+
* validates arguments against it BEFORE the wrapped handler runs, so a malformed
|
|
6
|
+
* `symbolId`, an out-of-range `depth`, or a `..`-traversal `file` is rejected at
|
|
7
|
+
* the trust boundary and never reaches a port. These are the shared field
|
|
8
|
+
* builders each tool composes — validation lives here (the boundary), never in
|
|
9
|
+
* the ports.
|
|
10
|
+
*
|
|
11
|
+
* DTOs carry symbol METADATA only; none of these inputs accept raw file bodies.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
/** Hard depth cap on bounded adjacency walks (bounds memory). */
|
|
15
|
+
export const MAX_DEPTH = 5;
|
|
16
|
+
/** Default walk depth when the caller omits it. */
|
|
17
|
+
export const DEFAULT_DEPTH = 5;
|
|
18
|
+
/** Hard cap on a caller-supplied `limit` (search / dead-code / architecture rows). */
|
|
19
|
+
export const MAX_LIMIT = 500;
|
|
20
|
+
/** Hard cap on a free-text query length (bounds work; search is substring, not regex → no ReDoS). */
|
|
21
|
+
export const MAX_QUERY_LEN = 200;
|
|
22
|
+
/** Hard cap on a file-path argument length. */
|
|
23
|
+
export const MAX_PATH_LEN = 1024;
|
|
24
|
+
/**
|
|
25
|
+
* A `symbolId` in the canonical `"${filePath}:${line}:${column}"` shape. The
|
|
26
|
+
* trailing two colon-groups must be integers; the leading file segment is
|
|
27
|
+
* unconstrained here (the port resolves it — an unknown id is a structured
|
|
28
|
+
* not-found, not a validation error).
|
|
29
|
+
*/
|
|
30
|
+
export const symbolId = () => z
|
|
31
|
+
.string()
|
|
32
|
+
.min(3)
|
|
33
|
+
.max(MAX_PATH_LEN + 16)
|
|
34
|
+
.regex(/^.+:\d+:\d+$/, 'symbolId must be "<filePath>:<line>:<column>"');
|
|
35
|
+
/**
|
|
36
|
+
* A project-relative file path constrained to the project root: no absolute
|
|
37
|
+
* paths, no `..` traversal segments. The graph catalog keys occurrences by
|
|
38
|
+
* project-relative path, so a constrained relative path is also the only thing
|
|
39
|
+
* that can match.
|
|
40
|
+
*/
|
|
41
|
+
export const filePath = () => z
|
|
42
|
+
.string()
|
|
43
|
+
.min(1)
|
|
44
|
+
.max(MAX_PATH_LEN)
|
|
45
|
+
.refine((p) => !p.startsWith('/') && !/^[A-Za-z]:[\\/]/.test(p), 'file must be a project-relative path (not absolute)')
|
|
46
|
+
.refine((p) => !p.split(/[\\/]/).includes('..'), 'file must not contain ".." traversal segments');
|
|
47
|
+
/** A 1-based source line number. */
|
|
48
|
+
export const line = () => z.number().int().positive();
|
|
49
|
+
/** A length-bounded free-text search query (substring match — not a regex). */
|
|
50
|
+
export const query = () => z.string().min(1).max(MAX_QUERY_LEN);
|
|
51
|
+
/** A walk depth, clamped to `[1, MAX_DEPTH]`, defaulting to {@link DEFAULT_DEPTH}. */
|
|
52
|
+
export const depth = () => z.number().int().min(1).max(MAX_DEPTH).default(DEFAULT_DEPTH);
|
|
53
|
+
/** An optional result cap, clamped to `[1, MAX_LIMIT]`. */
|
|
54
|
+
export const limit = () => z.number().int().positive().max(MAX_LIMIT).optional();
|
|
55
|
+
/** A registered-tool id (validated against the live registry in the handler). */
|
|
56
|
+
export const toolId = () => z.string().min(1).max(64);
|
|
57
|
+
/** Severity filter for `get_latest_findings`. */
|
|
58
|
+
export const severity = () => z.enum(['errors', 'warnings', 'all']).optional();
|
|
59
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iEAAiE;AACjE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B,mDAAmD;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,sFAAsF;AACtF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAC7B,qGAAqG;AACrG,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC,+CAA+C;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAC3B,CAAC;KACE,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC;KACtB,KAAK,CAAC,cAAc,EAAE,+CAA+C,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAC3B,CAAC;KACE,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,YAAY,CAAC;KACjB,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EACvD,qDAAqD,CACtD;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ols` — name/substring symbol lookup (ADR-0084, Task 4.1).
|
|
3
|
+
*
|
|
4
|
+
* Returns the shared `{ data, freshness, truncated? }` envelope every graph tool
|
|
5
|
+
* reuses. Each result is a {@link SymbolRef} carrying the stable
|
|
6
|
+
* `symbolId = "${filePath}:${line}:${column}"` + `bodyHash` — the identity all
|
|
7
|
+
* downstream graph tools accept (never a bare name). Reads only `graphPort`.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpToolDeps } from './types.js';
|
|
10
|
+
import type { McpStdioServer } from '../server.js';
|
|
11
|
+
export declare function registerSearchSymbols(server: McpStdioServer, deps: McpToolDeps): void;
|
|
12
|
+
//# sourceMappingURL=search-symbols.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-symbols.d.ts","sourceRoot":"","sources":["../../src/tools/search-symbols.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CA2BrF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `search_symbols` — name/substring symbol lookup (ADR-0084, Task 4.1).
|
|
3
|
+
*
|
|
4
|
+
* Returns the shared `{ data, freshness, truncated? }` envelope every graph tool
|
|
5
|
+
* reuses. Each result is a {@link SymbolRef} carrying the stable
|
|
6
|
+
* `symbolId = "${filePath}:${line}:${column}"` + `bodyHash` — the identity all
|
|
7
|
+
* downstream graph tools accept (never a bare name). Reads only `graphPort`.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { query as querySchema, limit as limitSchema } from './schemas.js';
|
|
11
|
+
import { errorResult, jsonResult } from './tool-result.js';
|
|
12
|
+
export function registerSearchSymbols(server, deps) {
|
|
13
|
+
server.register('search_symbols', {
|
|
14
|
+
title: 'Search symbols',
|
|
15
|
+
description: 'Find functions/methods by name (case-insensitive substring). Returns symbolId ' +
|
|
16
|
+
'("<filePath>:<line>:<column>") + bodyHash for each match — pass that symbolId to ' +
|
|
17
|
+
'who_calls, callees_of, blast_radius, or trace_path. Results carry a freshness verdict; ' +
|
|
18
|
+
'a missing catalog returns empty data (run refresh_graph once to build it).',
|
|
19
|
+
inputSchema: {
|
|
20
|
+
query: querySchema(),
|
|
21
|
+
kind: z.string().min(1).max(32).optional(),
|
|
22
|
+
limit: limitSchema(),
|
|
23
|
+
},
|
|
24
|
+
}, ({ query, kind, limit }) => {
|
|
25
|
+
const opts = limit === undefined ? undefined : { limit };
|
|
26
|
+
const outcome = deps.graph.searchSymbols(query, opts);
|
|
27
|
+
if (!outcome.ok)
|
|
28
|
+
return errorResult(outcome.error);
|
|
29
|
+
const result = outcome.value;
|
|
30
|
+
if (kind === undefined)
|
|
31
|
+
return jsonResult(result);
|
|
32
|
+
// Optional kind narrowing is applied post-hoc on the (already capped) page.
|
|
33
|
+
const filtered = result.data.filter((ref) => ref.kind === kind);
|
|
34
|
+
return jsonResult({ ...result, data: filtered });
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=search-symbols.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-symbols.js","sourceRoot":"","sources":["../../src/tools/search-symbols.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK3D,MAAM,UAAU,qBAAqB,CAAC,MAAsB,EAAE,IAAiB;IAC7E,MAAM,CAAC,QAAQ,CACb,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,gFAAgF;YAChF,mFAAmF;YACnF,yFAAyF;YACzF,4EAA4E;QAC9E,WAAW,EAAE;YACX,KAAK,EAAE,WAAW,EAAE;YACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;YAC1C,KAAK,EAAE,WAAW,EAAE;SACrB;KACF,EACD,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;QACzB,MAAM,IAAI,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,OAAO,CAAC,EAAE;YAAE,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAC7B,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;QAClD,4EAA4E;QAC5E,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QAChE,OAAO,UAAU,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACnD,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `show_run` — replay one stored run (ADR-0084, Task 4.5).
|
|
3
|
+
*
|
|
4
|
+
* Reads `resultsPort.showRun()` ONLY — resolves the ref (a session id or the
|
|
5
|
+
* `latest` sentinel, which requires `tool`), decodes the persisted payload, and
|
|
6
|
+
* applies the same agent filters/raw shape as CLI `sessions show`. Carries
|
|
7
|
+
* session provenance + `recommendedNext`. Never re-runs a tool.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpToolDeps } from './types.js';
|
|
10
|
+
import type { McpStdioServer } from '../server.js';
|
|
11
|
+
export declare function registerShowRun(server: McpStdioServer, deps: McpToolDeps): void;
|
|
12
|
+
//# sourceMappingURL=show-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-run.d.ts","sourceRoot":"","sources":["../../src/tools/show-run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CA+B/E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `show_run` — replay one stored run (ADR-0084, Task 4.5).
|
|
3
|
+
*
|
|
4
|
+
* Reads `resultsPort.showRun()` ONLY — resolves the ref (a session id or the
|
|
5
|
+
* `latest` sentinel, which requires `tool`), decodes the persisted payload, and
|
|
6
|
+
* applies the same agent filters/raw shape as CLI `sessions show`. Carries
|
|
7
|
+
* session provenance + `recommendedNext`. Never re-runs a tool.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { toolId as toolIdSchema } from './schemas.js';
|
|
11
|
+
import { errorResult, jsonResult, unknownToolError } from './tool-result.js';
|
|
12
|
+
export function registerShowRun(server, deps) {
|
|
13
|
+
server.register('show_run', {
|
|
14
|
+
title: 'Show an OpenSIP run',
|
|
15
|
+
description: 'Replay a stored OpenSIP run by id, or "latest" (with `tool`). Returns the decoded ' +
|
|
16
|
+
'finding envelope plus session provenance and recommendedNext commands — the same ' +
|
|
17
|
+
'filters/raw shape as `opensip sessions show`. Use `filters` (e.g. errors-only, ' +
|
|
18
|
+
'warnings-only, top:N) to narrow. Replays persisted data; never re-runs the tool.',
|
|
19
|
+
inputSchema: {
|
|
20
|
+
ref: z.string().min(1).max(128),
|
|
21
|
+
tool: toolIdSchema().optional(),
|
|
22
|
+
filters: z.array(z.string().min(1).max(64)).max(16).optional(),
|
|
23
|
+
raw: z.boolean().optional(),
|
|
24
|
+
},
|
|
25
|
+
}, async ({ ref, tool, filters, raw }) => {
|
|
26
|
+
if (tool !== undefined && !deps.validToolIds.has(tool)) {
|
|
27
|
+
return unknownToolError(tool, deps.validToolIds);
|
|
28
|
+
}
|
|
29
|
+
const outcome = await deps.results.showRun({
|
|
30
|
+
ref,
|
|
31
|
+
...(tool === undefined ? {} : { tool }),
|
|
32
|
+
...(filters === undefined ? {} : { filters }),
|
|
33
|
+
...(raw === undefined ? {} : { raw }),
|
|
34
|
+
});
|
|
35
|
+
if (!outcome.ok)
|
|
36
|
+
return errorResult(outcome.error);
|
|
37
|
+
return jsonResult(outcome.value);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=show-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-run.js","sourceRoot":"","sources":["../../src/tools/show-run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAK7E,MAAM,UAAU,eAAe,CAAC,MAAsB,EAAE,IAAiB;IACvE,MAAM,CAAC,QAAQ,CACb,UAAU,EACV;QACE,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EACT,oFAAoF;YACpF,mFAAmF;YACnF,iFAAiF;YACjF,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K,CAAC,CAAC;IACnC,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared MCP tool-result helpers (ADR-0084).
|
|
3
|
+
*
|
|
4
|
+
* Every graph tool returns the same `{ data, freshness, truncated? }` envelope
|
|
5
|
+
* (the {@link McpToolResult} the ports already produce); every result tool
|
|
6
|
+
* returns an {@link McpResultReplay}. Both are serialized into a JSON-RPC reply
|
|
7
|
+
* the SAME way: a single `text` content item carrying the pretty-printed JSON.
|
|
8
|
+
*
|
|
9
|
+
* We deliberately do NOT set `structuredContent` (no per-tool `outputSchema` is
|
|
10
|
+
* declared — the SDK only honours `structuredContent` against an output schema),
|
|
11
|
+
* so the JSON text content is the single, widely-compatible payload channel.
|
|
12
|
+
*
|
|
13
|
+
* A port/domain failure (`Result` err arm) is surfaced as an `isError: true`
|
|
14
|
+
* result whose JSON body is the structured {@link McpReadError} — the agent sees
|
|
15
|
+
* a machine-readable `code` + `message`, never a thrown stack. `throw` stays
|
|
16
|
+
* reserved for genuine infra failures (the SDK converts those to a JSON-RPC error
|
|
17
|
+
* frame; the server's `dispatch` logs the decision point).
|
|
18
|
+
*/
|
|
19
|
+
import type { McpReadError } from '../mcp-error.js';
|
|
20
|
+
import type { CallToolResult } from '../server.js';
|
|
21
|
+
/** Serialize a successful tool payload as a single pretty-printed JSON text item. */
|
|
22
|
+
export declare function jsonResult(payload: unknown): CallToolResult;
|
|
23
|
+
/** Surface a structured domain error as an `isError` result (machine-readable body). */
|
|
24
|
+
export declare function errorResult(error: McpReadError): CallToolResult;
|
|
25
|
+
/** Build an inline structured error result from a `code` + `message` pair. */
|
|
26
|
+
export declare function failure(code: string, message: string): CallToolResult;
|
|
27
|
+
/** A structured `unknown-tool` error for a `tool` argument outside the live registry. */
|
|
28
|
+
export declare function unknownToolError(tool: string, valid: ReadonlySet<string>): CallToolResult;
|
|
29
|
+
//# sourceMappingURL=tool-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-result.d.ts","sourceRoot":"","sources":["../../src/tools/tool-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CAE3D;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,cAAc,CAK/D;AAED,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAErE;AAED,yFAAyF;AACzF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,cAAc,CAGzF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared MCP tool-result helpers (ADR-0084).
|
|
3
|
+
*
|
|
4
|
+
* Every graph tool returns the same `{ data, freshness, truncated? }` envelope
|
|
5
|
+
* (the {@link McpToolResult} the ports already produce); every result tool
|
|
6
|
+
* returns an {@link McpResultReplay}. Both are serialized into a JSON-RPC reply
|
|
7
|
+
* the SAME way: a single `text` content item carrying the pretty-printed JSON.
|
|
8
|
+
*
|
|
9
|
+
* We deliberately do NOT set `structuredContent` (no per-tool `outputSchema` is
|
|
10
|
+
* declared — the SDK only honours `structuredContent` against an output schema),
|
|
11
|
+
* so the JSON text content is the single, widely-compatible payload channel.
|
|
12
|
+
*
|
|
13
|
+
* A port/domain failure (`Result` err arm) is surfaced as an `isError: true`
|
|
14
|
+
* result whose JSON body is the structured {@link McpReadError} — the agent sees
|
|
15
|
+
* a machine-readable `code` + `message`, never a thrown stack. `throw` stays
|
|
16
|
+
* reserved for genuine infra failures (the SDK converts those to a JSON-RPC error
|
|
17
|
+
* frame; the server's `dispatch` logs the decision point).
|
|
18
|
+
*/
|
|
19
|
+
/** Serialize a successful tool payload as a single pretty-printed JSON text item. */
|
|
20
|
+
export function jsonResult(payload) {
|
|
21
|
+
return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
|
|
22
|
+
}
|
|
23
|
+
/** Surface a structured domain error as an `isError` result (machine-readable body). */
|
|
24
|
+
export function errorResult(error) {
|
|
25
|
+
return {
|
|
26
|
+
content: [{ type: 'text', text: JSON.stringify({ error }, null, 2) }],
|
|
27
|
+
isError: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Build an inline structured error result from a `code` + `message` pair. */
|
|
31
|
+
export function failure(code, message) {
|
|
32
|
+
return errorResult({ code, message });
|
|
33
|
+
}
|
|
34
|
+
/** A structured `unknown-tool` error for a `tool` argument outside the live registry. */
|
|
35
|
+
export function unknownToolError(tool, valid) {
|
|
36
|
+
const known = [...valid].sort().join(', ') || '(none registered)';
|
|
37
|
+
return failure('unknown-tool', `Unknown tool "${tool}". Registered tools: ${known}.`);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=tool-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-result.js","sourceRoot":"","sources":["../../src/tools/tool-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,qFAAqF;AACrF,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACjF,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,KAAmB;IAC7C,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACrE,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,OAAe;IACnD,OAAO,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AACxC,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,KAA0B;IACvE,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC;IAClE,OAAO,OAAO,CAAC,cAAc,EAAE,iBAAiB,IAAI,wBAAwB,KAAK,GAAG,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `trace_path` — shortest forward call path `from → … → to` (ADR-0084, Task 4.2).
|
|
3
|
+
*
|
|
4
|
+
* The third caller of the shared {@link boundedBfs}: resolves both symbolIds via
|
|
5
|
+
* the port, runs a goal-directed BFS over the forward-call adjacency, and (on a
|
|
6
|
+
* hit) reconstructs the path via the BFS parent map. No path within the depth
|
|
7
|
+
* bound returns `{ found: false, path: [] }` — not an error.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpToolDeps } from './types.js';
|
|
10
|
+
import type { McpStdioServer } from '../server.js';
|
|
11
|
+
export declare function registerTracePath(server: McpStdioServer, deps: McpToolDeps): void;
|
|
12
|
+
//# sourceMappingURL=trace-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-path.d.ts","sourceRoot":"","sources":["../../src/tools/trace-path.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAiDjF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `trace_path` — shortest forward call path `from → … → to` (ADR-0084, Task 4.2).
|
|
3
|
+
*
|
|
4
|
+
* The third caller of the shared {@link boundedBfs}: resolves both symbolIds via
|
|
5
|
+
* the port, runs a goal-directed BFS over the forward-call adjacency, and (on a
|
|
6
|
+
* hit) reconstructs the path via the BFS parent map. No path within the depth
|
|
7
|
+
* bound returns `{ found: false, path: [] }` — not an error.
|
|
8
|
+
*/
|
|
9
|
+
import { boundedBfs, MAX_WALK_NODES, reconstructPath } from './graph-walk.js';
|
|
10
|
+
import { depth as depthSchema, symbolId as symbolIdSchema } from './schemas.js';
|
|
11
|
+
import { errorResult, failure, jsonResult } from './tool-result.js';
|
|
12
|
+
export function registerTracePath(server, deps) {
|
|
13
|
+
server.register('trace_path', {
|
|
14
|
+
title: 'Trace a call path',
|
|
15
|
+
description: 'Find a forward call path from one symbol to another (fromSymbolId reaches toSymbolId ' +
|
|
16
|
+
'through calls), within `depth` levels (default 5, max 5). Pass symbolIds from ' +
|
|
17
|
+
'search_symbols/get_symbol. Returns the ordered path, or { found: false } when none ' +
|
|
18
|
+
'exists within the bound.',
|
|
19
|
+
inputSchema: {
|
|
20
|
+
fromSymbolId: symbolIdSchema(),
|
|
21
|
+
toSymbolId: symbolIdSchema(),
|
|
22
|
+
depth: depthSchema(),
|
|
23
|
+
},
|
|
24
|
+
}, ({ fromSymbolId, toSymbolId, depth }) => {
|
|
25
|
+
const from = deps.graph.resolveSymbolId(fromSymbolId);
|
|
26
|
+
if (!from.ok)
|
|
27
|
+
return errorResult(from.error);
|
|
28
|
+
const to = deps.graph.resolveSymbolId(toSymbolId);
|
|
29
|
+
if (!to.ok)
|
|
30
|
+
return errorResult(to.error);
|
|
31
|
+
const fromRef = from.value.data;
|
|
32
|
+
const toRef = to.value.data;
|
|
33
|
+
if (fromRef === undefined || toRef === undefined) {
|
|
34
|
+
const missing = fromRef === undefined ? fromSymbolId : toSymbolId;
|
|
35
|
+
return failure('symbol-not-found', `Unknown symbolId "${missing}". Obtain valid symbolIds from search_symbols or get_symbol.`);
|
|
36
|
+
}
|
|
37
|
+
const graph = deps.graph.calleeGraph();
|
|
38
|
+
if (!graph.ok)
|
|
39
|
+
return errorResult(graph.error);
|
|
40
|
+
const { data: snapshot, freshness } = graph.value;
|
|
41
|
+
const walk = boundedBfs(snapshot.edges, fromRef.bodyHash, {
|
|
42
|
+
depth,
|
|
43
|
+
cap: MAX_WALK_NODES,
|
|
44
|
+
goal: toRef.bodyHash,
|
|
45
|
+
});
|
|
46
|
+
if (!walk.foundGoal) {
|
|
47
|
+
const data = { found: false, path: [] };
|
|
48
|
+
return jsonResult({ data, freshness, ...(walk.truncated ? { truncated: true } : {}) });
|
|
49
|
+
}
|
|
50
|
+
const path = reconstructPath(walk.parents, fromRef.bodyHash, toRef.bodyHash)
|
|
51
|
+
.map((hash) => snapshot.resolve(hash))
|
|
52
|
+
.filter((ref) => ref !== undefined);
|
|
53
|
+
const data = { found: true, path };
|
|
54
|
+
return jsonResult({ data, freshness });
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=trace-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-path.js","sourceRoot":"","sources":["../../src/tools/trace-path.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,k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AAC,KAAK,CAAC,CAAC;QAC/C,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;QAClD,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;YACxD,KAAK;YACL,GAAG,EAAE,cAAc;YACnB,IAAI,EAAE,KAAK,CAAC,QAAQ;SACrB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,GAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;YACtD,OAAO,UAAU,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,IAAI,GAAgB,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;aACtF,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aACrC,MAAM,CAAC,CAAC,GAAG,EAAoB,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;QACxD,MAAM,IAAI,GAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACjD,OAAO,UAAU,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IACzC,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared registration context for the MCP tools (ADR-0084).
|
|
3
|
+
*
|
|
4
|
+
* Each tool file exports a `register<Name>(server, deps)` function; the host
|
|
5
|
+
* passes the SAME pre-built ports the server captured plus the live set of
|
|
6
|
+
* registered tool ids (for the result tools' `tool`-argument validation). Tools
|
|
7
|
+
* read ONLY their injected port — never `currentScope()`, never a run-command
|
|
8
|
+
* entry point (the `mcp-results-no-rerun` invariant).
|
|
9
|
+
*/
|
|
10
|
+
import type { GraphReadPort } from '../graph-read-port.js';
|
|
11
|
+
import type { ResultsReadPort } from '../results-read-port.js';
|
|
12
|
+
export interface McpToolDeps {
|
|
13
|
+
/** Pre-built graph read port (graph tools). */
|
|
14
|
+
readonly graph: GraphReadPort;
|
|
15
|
+
/** Pre-built results/history read port (result tools). */
|
|
16
|
+
readonly results: ResultsReadPort;
|
|
17
|
+
/** The live registered tool ids — `get_latest_findings`/`show_run` validate `tool` against these. */
|
|
18
|
+
readonly validToolIds: ReadonlySet<string>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,qGAAqG;IACrG,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared registration context for the MCP tools (ADR-0084).
|
|
3
|
+
*
|
|
4
|
+
* Each tool file exports a `register<Name>(server, deps)` function; the host
|
|
5
|
+
* passes the SAME pre-built ports the server captured plus the live set of
|
|
6
|
+
* registered tool ids (for the result tools' `tool`-argument validation). Tools
|
|
7
|
+
* read ONLY their injected port — never `currentScope()`, never a run-command
|
|
8
|
+
* entry point (the `mcp-results-no-rerun` invariant).
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `who_calls` — bounded reverse call walk (ADR-0084, Task 4.2).
|
|
3
|
+
*
|
|
4
|
+
* Resolves the input `symbolId` via the port (unknown id → structured error),
|
|
5
|
+
* then runs the shared {@link boundedBfs} over the reverse-call adjacency
|
|
6
|
+
* snapshot. Cycle-safe, depth-bounded (default 5, max 5), node-capped with a
|
|
7
|
+
* `truncated` flag. Returns the `{ data, freshness, truncated? }` envelope.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpToolDeps } from './types.js';
|
|
10
|
+
import type { McpStdioServer } from '../server.js';
|
|
11
|
+
export declare function registerWhoCalls(server: McpStdioServer, deps: McpToolDeps): void;
|
|
12
|
+
//# sourceMappingURL=who-calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"who-calls.d.ts","sourceRoot":"","sources":["../../src/tools/who-calls.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAWhF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `who_calls` — bounded reverse call walk (ADR-0084, Task 4.2).
|
|
3
|
+
*
|
|
4
|
+
* Resolves the input `symbolId` via the port (unknown id → structured error),
|
|
5
|
+
* then runs the shared {@link boundedBfs} over the reverse-call adjacency
|
|
6
|
+
* snapshot. Cycle-safe, depth-bounded (default 5, max 5), node-capped with a
|
|
7
|
+
* `truncated` flag. Returns the `{ data, freshness, truncated? }` envelope.
|
|
8
|
+
*/
|
|
9
|
+
import { registerCallWalkTool } from './call-walk-tool.js';
|
|
10
|
+
export function registerWhoCalls(server, deps) {
|
|
11
|
+
registerCallWalkTool(server, deps.graph, {
|
|
12
|
+
name: 'who_calls',
|
|
13
|
+
title: 'Who calls a symbol',
|
|
14
|
+
description: 'Find the callers of a symbol (reverse call graph), out to `depth` levels (default 5, ' +
|
|
15
|
+
'max 5). Pass a symbolId from search_symbols/get_symbol. Edges are body-hash-union ' +
|
|
16
|
+
'(twin-aware): a result is reachable through any occurrence sharing a body. Large fan-in ' +
|
|
17
|
+
'is node-capped with truncated:true.',
|
|
18
|
+
graph: (port) => port.callerGraph(),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=who-calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"who-calls.js","sourceRoot":"","sources":["../../src/tools/who-calls.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAK3D,MAAM,UAAU,gBAAgB,CAAC,MAAsB,EAAE,IAAiB;IACxE,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE;QACvC,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EACT,uFAAuF;YACvF,oFAAoF;YACpF,0FAA0F;YAC1F,qCAAqC;QACvC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE;KACpC,CAAC,CAAC;AACL,CAAC"}
|