@ttsc/graph 0.16.7 → 0.16.9
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 +41 -43
- package/lib/TtscGraphApplication.js +5 -3
- package/lib/TtscGraphApplication.js.map +1 -1
- package/lib/model/loadGraph.js +74 -90
- package/lib/model/loadGraph.js.map +1 -1
- package/lib/reduce.js +34 -3
- package/lib/reduce.js.map +1 -1
- package/lib/server/createServer.js +199 -189
- package/lib/server/createServer.js.map +1 -1
- package/package.json +4 -8
- package/src/TtscGraphApplication.ts +5 -3
- package/src/reduce.ts +37 -5
- package/src/server/createServer.ts +18 -88
- package/src/structures/ITtscGraphApplication.ts +104 -6
- package/lib/server/instructions.js +0 -92
- package/lib/server/instructions.js.map +0 -1
- package/src/server/instructions.ts +0 -88
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServer.js","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"createServer.js","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oCAA6C;AAC7C,kDAAmD;AAEnD,kEAAgF;AAGhF;;;;;;;;;;;GAWG;AACH,sBACE,KAAsB,EACtB,OAAe;IAEf,MAAM,UAAU,GAA0C;QACxD,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,YAAY;QAClB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CP for coding agents, backed by ttsc's in-process TypeScript-Go compiler.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -14,14 +14,10 @@
|
|
|
14
14
|
},
|
|
15
15
|
"./package.json": "./package.json"
|
|
16
16
|
},
|
|
17
|
-
"ttsc": {
|
|
18
|
-
"plugin": {
|
|
19
|
-
"transform": "typia/lib/transform"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
17
|
"dependencies": {
|
|
23
18
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
24
|
-
"typia": "13.0.0-
|
|
19
|
+
"@typia/mcp": "13.0.0-rc.1",
|
|
20
|
+
"typia": "13.0.0-rc.1"
|
|
25
21
|
},
|
|
26
22
|
"keywords": [
|
|
27
23
|
"ttsc",
|
|
@@ -43,7 +39,7 @@
|
|
|
43
39
|
"three": "^0.184.0",
|
|
44
40
|
"three-forcegraph": "^1.43.4",
|
|
45
41
|
"typescript": "7.0.1-rc",
|
|
46
|
-
"ttsc": "0.16.
|
|
42
|
+
"ttsc": "0.16.9"
|
|
47
43
|
},
|
|
48
44
|
"repository": {
|
|
49
45
|
"type": "git",
|
|
@@ -15,10 +15,11 @@ export type TtscGraphSource = TtscGraphMemory | (() => TtscGraphMemory);
|
|
|
15
15
|
* The MCP tool surface as a plain class over the resident
|
|
16
16
|
* {@link TtscGraphMemory}.
|
|
17
17
|
*
|
|
18
|
-
* Its public method is the MCP tool: `typia.llm.
|
|
18
|
+
* Its public method is the MCP tool: `typia.llm.application` reflects
|
|
19
19
|
* {@link ITtscGraphApplication} to generate the tool's JSON schema and argument
|
|
20
|
-
* validator from the signature and JSDoc, with no hand-written schema
|
|
21
|
-
*
|
|
20
|
+
* validator from the signature and JSDoc, with no hand-written schema, and
|
|
21
|
+
* `@typia/mcp`'s `createMcpServer` registers it (see `./server/createServer`).
|
|
22
|
+
* The method delegates to the pure graph functions in `./server`, which are
|
|
22
23
|
* unit-testable without a transport; this class only binds them to the graph.
|
|
23
24
|
*
|
|
24
25
|
* Every method answers from the resident graph; none recompiles. Output is kept
|
|
@@ -70,6 +71,7 @@ export class TtscGraphApplication implements ITtscGraphApplication {
|
|
|
70
71
|
result: runTour(this.graph(), props.request),
|
|
71
72
|
};
|
|
72
73
|
default:
|
|
74
|
+
props.request satisfies never;
|
|
73
75
|
throw new Error("Unknown graph request type");
|
|
74
76
|
}
|
|
75
77
|
}
|
package/src/reduce.ts
CHANGED
|
@@ -55,6 +55,11 @@ function posix(p: string): string {
|
|
|
55
55
|
return p.replace(/\\/g, "/");
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/** An absolute path (POSIX or Windows drive); relative dumps skip rerooting. */
|
|
59
|
+
function isAbsolute(p: string): boolean {
|
|
60
|
+
return /^(?:[A-Za-z]:)?\//.test(posix(p));
|
|
61
|
+
}
|
|
62
|
+
|
|
58
63
|
function commonRoot(files: string[]): string {
|
|
59
64
|
if (files.length === 0) return "";
|
|
60
65
|
let parts = posix(files[0]!).split("/");
|
|
@@ -68,10 +73,13 @@ function commonRoot(files: string[]): string {
|
|
|
68
73
|
return parts.join("/");
|
|
69
74
|
}
|
|
70
75
|
|
|
76
|
+
// An empty root means the dump's paths are already project-relative (the
|
|
77
|
+
// current `ttscgraph dump` contract); they pass through structure-intact.
|
|
71
78
|
function relativize(abs: string, root: string): string {
|
|
72
79
|
const a = posix(abs);
|
|
73
80
|
const r = posix(root).replace(/\/+$/, "");
|
|
74
|
-
if (r
|
|
81
|
+
if (!r) return a;
|
|
82
|
+
if (a === r || a.startsWith(r + "/"))
|
|
75
83
|
return a.slice(r.length).replace(/^\/+/, "");
|
|
76
84
|
const nm = a.lastIndexOf("node_modules/");
|
|
77
85
|
if (nm >= 0) return a.slice(nm);
|
|
@@ -97,6 +105,26 @@ function degreeOf(
|
|
|
97
105
|
return degree;
|
|
98
106
|
}
|
|
99
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Collapse the fine-grained wire kinds `ttscgraph dump` emits (calls,
|
|
110
|
+
* instantiates, renders, accesses, type_ref, extends, implements) into the
|
|
111
|
+
* three display families the viewer colors and its legend name. An unknown kind
|
|
112
|
+
* passes through and renders with the fallback color.
|
|
113
|
+
*/
|
|
114
|
+
const DISPLAY_KIND: Record<string, string> = {
|
|
115
|
+
calls: "value-call",
|
|
116
|
+
instantiates: "value-call",
|
|
117
|
+
renders: "value-call",
|
|
118
|
+
accesses: "value-call",
|
|
119
|
+
type_ref: "type-ref",
|
|
120
|
+
extends: "heritage",
|
|
121
|
+
implements: "heritage",
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
function displayKind(kind: string): string {
|
|
125
|
+
return DISPLAY_KIND[kind] ?? kind;
|
|
126
|
+
}
|
|
127
|
+
|
|
100
128
|
export function reduce(
|
|
101
129
|
raw: RawDump,
|
|
102
130
|
{
|
|
@@ -105,9 +133,13 @@ export function reduce(
|
|
|
105
133
|
}: { maxNodes?: number; keepExternal?: boolean } = {},
|
|
106
134
|
): ViewerPayload {
|
|
107
135
|
const keptByExternal = raw.nodes.filter((n) => keepExternal || !n.external);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
);
|
|
136
|
+
// Reroot only absolute paths (the legacy dump contract); a current dump's
|
|
137
|
+
// paths are already project-relative and keep their structure as-is.
|
|
138
|
+
const projectFiles = raw.nodes.filter((n) => !n.external).map((n) => n.file);
|
|
139
|
+
const root =
|
|
140
|
+
projectFiles.length > 0 && isAbsolute(projectFiles[0]!)
|
|
141
|
+
? commonRoot(projectFiles)
|
|
142
|
+
: "";
|
|
111
143
|
|
|
112
144
|
const liveIds = new Set(keptByExternal.map((n) => n.id));
|
|
113
145
|
const liveEdges = raw.edges.filter(
|
|
@@ -145,7 +177,7 @@ export function reduce(
|
|
|
145
177
|
.map((e) => ({
|
|
146
178
|
source: rewriteId(e.from, root),
|
|
147
179
|
target: rewriteId(e.to, root),
|
|
148
|
-
kind: e.kind,
|
|
180
|
+
kind: displayKind(e.kind),
|
|
149
181
|
}))
|
|
150
182
|
.filter((e) => nodeIds.has(e.source) && nodeIds.has(e.target));
|
|
151
183
|
|
|
@@ -1,101 +1,31 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
ListToolsRequestSchema,
|
|
5
|
-
} from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
-
import typia from "typia";
|
|
2
|
+
import { createMcpServer } from "@typia/mcp";
|
|
3
|
+
import typia, { type ILlmController } from "typia";
|
|
7
4
|
|
|
8
5
|
import { TtscGraphApplication, TtscGraphSource } from "../TtscGraphApplication";
|
|
9
|
-
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
10
6
|
import { ITtscGraphApplication } from "../structures/ITtscGraphApplication";
|
|
11
|
-
import { instructions } from "./instructions";
|
|
12
7
|
|
|
13
8
|
/**
|
|
14
|
-
* Build the MCP server for a graph. `typia.llm.
|
|
15
|
-
* {@link ITtscGraphApplication} into
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* below are the minimal standalone registration: list the generated functions,
|
|
19
|
-
* and on a call validate the arguments (returning typia's errors for the model
|
|
20
|
-
* to self-correct) before invoking the method.
|
|
9
|
+
* Build the MCP server for a graph. `typia.llm.application` reflects
|
|
10
|
+
* {@link ITtscGraphApplication} into the tool schema and validator (no
|
|
11
|
+
* hand-written schema), and `createMcpServer` from `@typia/mcp` handles the
|
|
12
|
+
* list/call registration, argument validation, and structured output.
|
|
21
13
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
14
|
+
* We assemble the `ILlmController` (`{ protocol, name, application, execute }`)
|
|
15
|
+
* directly rather than via `typia.llm.controller` so the server is named
|
|
16
|
+
* "ttsc-graph" on our terms, not coupled to a reflected class name. Handshake
|
|
17
|
+
* instructions come from the class JSDoc; the single tool is named from its
|
|
18
|
+
* method, `inspect_typescript_graph`.
|
|
26
19
|
*/
|
|
27
20
|
export function createServer(
|
|
28
21
|
graph: TtscGraphSource,
|
|
29
22
|
version: string,
|
|
30
23
|
): McpServer {
|
|
31
|
-
const controller
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
(input: unknown) => unknown
|
|
39
|
-
>;
|
|
40
|
-
|
|
41
|
-
const server = new McpServer(
|
|
42
|
-
{ name: "ttsc-graph", version },
|
|
43
|
-
{ capabilities: { tools: {} }, instructions },
|
|
44
|
-
);
|
|
45
|
-
const raw = server.server;
|
|
46
|
-
|
|
47
|
-
raw.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
48
|
-
tools: functions.map((func) => ({
|
|
49
|
-
name: func.name,
|
|
50
|
-
description: func.description,
|
|
51
|
-
inputSchema: {
|
|
52
|
-
type: "object" as const,
|
|
53
|
-
properties: func.parameters.properties,
|
|
54
|
-
required: func.parameters.required,
|
|
55
|
-
additionalProperties: false,
|
|
56
|
-
$defs: func.parameters.$defs,
|
|
57
|
-
},
|
|
58
|
-
})),
|
|
59
|
-
}));
|
|
60
|
-
|
|
61
|
-
raw.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
62
|
-
const func = functions.find((f) => f.name === request.params.name);
|
|
63
|
-
const method = execute[request.params.name];
|
|
64
|
-
if (func === undefined || method === undefined) {
|
|
65
|
-
return error(`Unknown tool: ${request.params.name}`);
|
|
66
|
-
}
|
|
67
|
-
// Validate an empty object when a client omits `arguments`, so typia can
|
|
68
|
-
// return field-level errors instead of a generic "expected object".
|
|
69
|
-
const validation = func.validate(request.params.arguments ?? {});
|
|
70
|
-
if (!validation.success) {
|
|
71
|
-
// Hand typia's validation errors back so the model can correct its call.
|
|
72
|
-
return error(JSON.stringify(validation.errors, null, 2));
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const result = await method.call(execute, validation.data);
|
|
76
|
-
return {
|
|
77
|
-
content: [
|
|
78
|
-
{
|
|
79
|
-
type: "text" as const,
|
|
80
|
-
text: result === undefined ? "Success" : JSON.stringify(result),
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
};
|
|
84
|
-
} catch (exception) {
|
|
85
|
-
return error(
|
|
86
|
-
exception instanceof Error
|
|
87
|
-
? `${exception.name}: ${exception.message}`
|
|
88
|
-
: String(exception),
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return server;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function error(text: string): {
|
|
97
|
-
isError: true;
|
|
98
|
-
content: { type: "text"; text: string }[];
|
|
99
|
-
} {
|
|
100
|
-
return { isError: true, content: [{ type: "text", text }] };
|
|
24
|
+
const controller: ILlmController<ITtscGraphApplication> = {
|
|
25
|
+
protocol: "class",
|
|
26
|
+
name: "ttsc-graph",
|
|
27
|
+
application: typia.llm.application<ITtscGraphApplication>(),
|
|
28
|
+
execute: new TtscGraphApplication(graph),
|
|
29
|
+
};
|
|
30
|
+
return createMcpServer(controller, version);
|
|
101
31
|
}
|
|
@@ -6,7 +6,91 @@ import { ITtscGraphOverview } from "./ITtscGraphOverview";
|
|
|
6
6
|
import { ITtscGraphTour } from "./ITtscGraphTour";
|
|
7
7
|
import { ITtscGraphTrace } from "./ITtscGraphTrace";
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* ## What This MCP Is
|
|
11
|
+
*
|
|
12
|
+
* `inspect_typescript_graph` returns a compiler-built TypeScript graph contract
|
|
13
|
+
* for the current source snapshot.
|
|
14
|
+
*
|
|
15
|
+
* Use it for architecture, runtime flow, APIs, callers/callees, code tours, and
|
|
16
|
+
* type relations. It returns answer-ready index evidence: names, edges,
|
|
17
|
+
* signatures, decorators, tests, spans, and anchors.
|
|
18
|
+
*
|
|
19
|
+
* Until TS source is edited, returned graph facts are sacred, infallible
|
|
20
|
+
* compiler truth. Never verify them with files or more graph calls.
|
|
21
|
+
*
|
|
22
|
+
* ## Result Contract
|
|
23
|
+
*
|
|
24
|
+
* - The returned object is the graph evidence contract: names, signatures, spans,
|
|
25
|
+
* decorators, tests, edges, steps, anchors, and `next` are answer evidence,
|
|
26
|
+
* not hints.
|
|
27
|
+
* - When `next.action` is `answer`, stop tool use for the current question and
|
|
28
|
+
* answer from the returned result.
|
|
29
|
+
* - `truncated` means the answer surface hit an index cap. Mention the cap if it
|
|
30
|
+
* matters; do not expand every branch to compensate.
|
|
31
|
+
* - When `next.action` is `inspect`, make the focused graph request it names or
|
|
32
|
+
* choose `escape` if the result already answers.
|
|
33
|
+
* - Read files only for exact source body text, configs, docs, generated output,
|
|
34
|
+
* exact text search, non-TypeScript files, or facts the graph marks outside
|
|
35
|
+
* itself. A returned span is a citation anchor, not a reading command.
|
|
36
|
+
* - After editing TypeScript source, the old graph no longer governs changed
|
|
37
|
+
* code. Rebuild/reload the graph or verify changed code normally.
|
|
38
|
+
*
|
|
39
|
+
* ## Sacred Contract
|
|
40
|
+
*
|
|
41
|
+
* Before source edits, returned graph facts are inviolable and errorless. Never
|
|
42
|
+
* use extra graph calls, repository search, or file reads to doubt, fact-check,
|
|
43
|
+
* humanize, re-derive, re-narrate, or re-confirm returned nodes, spans, edges,
|
|
44
|
+
* signatures, decorators, tests, references, steps, or anchors.
|
|
45
|
+
*
|
|
46
|
+
* ## Tour Contract
|
|
47
|
+
*
|
|
48
|
+
* Use `tour` for repository orientation, read-next, architecture tours, and
|
|
49
|
+
* broad runtime flow, including questions that name several phases or
|
|
50
|
+
* subsystems. A tour is the complete index-level answer surface: central
|
|
51
|
+
* entrypoints, primary flow, nearby paths, tests, and anchors. Do not decompose
|
|
52
|
+
* a broad tour into lookup/details loops unless the user later asks for a named
|
|
53
|
+
* missing symbol or exact source text.
|
|
54
|
+
*
|
|
55
|
+
* ## Use Contract
|
|
56
|
+
*
|
|
57
|
+
* 1. Ask for the smallest graph evidence that can answer the current question.
|
|
58
|
+
* 2. Broad flow, repository-orientation, code-tour, or read-next question: start
|
|
59
|
+
* with `tour`.
|
|
60
|
+
* 3. Concrete named symbol: use `lookup`, then `details` only if needed.
|
|
61
|
+
* 4. Known endpoint pair or one selected handle: use one `trace`.
|
|
62
|
+
* 5. Unknown narrow orientation: use `entrypoints` once.
|
|
63
|
+
* 6. Selected symbol shape: use `details` for one to three handles.
|
|
64
|
+
* 7. Follow the returned `next`: answer, inspect once more, leave graph, or
|
|
65
|
+
* clarify.
|
|
66
|
+
* 8. Use `escape` when another graph call would repeat evidence or the remaining
|
|
67
|
+
* evidence is outside the TypeScript graph.
|
|
68
|
+
*
|
|
69
|
+
* Most TypeScript structure answers need one or two graph calls.
|
|
70
|
+
*
|
|
71
|
+
* ## Request Fields
|
|
72
|
+
*
|
|
73
|
+
* Fill the visible checklist, then exactly one request.
|
|
74
|
+
*
|
|
75
|
+
* - `question`: restate the code question being considered.
|
|
76
|
+
* - `draft`: initial request type and why it seems smallest.
|
|
77
|
+
* - `review`: correct a wrong, broad, stale, or duplicate draft. If graph facts
|
|
78
|
+
* already answer, if prior `next.action` was `answer`, or if the next
|
|
79
|
+
* evidence is outside the indexed TypeScript graph, say so here and make
|
|
80
|
+
* `request.type` be `escape`. If a broad flow draft is not `tour`, correct it
|
|
81
|
+
* here.
|
|
82
|
+
* - `request`: final request after review.
|
|
83
|
+
*
|
|
84
|
+
* ## How to answer from graph evidence
|
|
85
|
+
*
|
|
86
|
+
* - Use returned node names, signatures, edges, references, evidence, and
|
|
87
|
+
* `sourceSpan` ranges directly.
|
|
88
|
+
* - Explain the central path first, then mention important branches.
|
|
89
|
+
* - For tests, impact, or reading lists, returned nodes and ranges are the answer
|
|
90
|
+
* evidence, not search keywords.
|
|
91
|
+
* - A returned range is a sacred citation anchor, not permission to open the
|
|
92
|
+
* file.
|
|
93
|
+
*/
|
|
10
94
|
export interface ITtscGraphApplication {
|
|
11
95
|
/**
|
|
12
96
|
* Inspect the TypeScript compiler graph contract.
|
|
@@ -44,12 +128,12 @@ export namespace ITtscGraphApplication {
|
|
|
44
128
|
/**
|
|
45
129
|
* Initial request plan before final arguments are filled.
|
|
46
130
|
*
|
|
47
|
-
* Name the intended request type and why it seems smallest
|
|
48
|
-
* architecture, repository-orientation, and read-next
|
|
49
|
-
* normally draft `tour`; narrow named symbols can draft
|
|
50
|
-
* or `details`.
|
|
131
|
+
* Name the intended request type in `type` and why it seems smallest in
|
|
132
|
+
* `reason`. Broad flow, architecture, repository-orientation, and read-next
|
|
133
|
+
* questions should normally draft `tour`; narrow named symbols can draft
|
|
134
|
+
* `lookup`, `trace`, or `details`.
|
|
51
135
|
*/
|
|
52
|
-
draft:
|
|
136
|
+
draft: IDraft;
|
|
53
137
|
|
|
54
138
|
/**
|
|
55
139
|
* Final self-review before calling.
|
|
@@ -72,6 +156,20 @@ export namespace ITtscGraphApplication {
|
|
|
72
156
|
| ITtscGraphEscape.IRequest;
|
|
73
157
|
}
|
|
74
158
|
|
|
159
|
+
/**
|
|
160
|
+
* First-pass request plan, filled before the final `request` arguments.
|
|
161
|
+
*
|
|
162
|
+
* `reason` comes before `type` so the justification is written before the
|
|
163
|
+
* choice it justifies.
|
|
164
|
+
*/
|
|
165
|
+
export interface IDraft {
|
|
166
|
+
/** Why this request type looks like the smallest useful next step. */
|
|
167
|
+
reason: string;
|
|
168
|
+
|
|
169
|
+
/** The request type being considered, corrected later in `review`. */
|
|
170
|
+
type: IProps["request"]["type"];
|
|
171
|
+
}
|
|
172
|
+
|
|
75
173
|
/** The selected request's output. `result.type` mirrors `request.type`. */
|
|
76
174
|
export interface IResult {
|
|
77
175
|
/** Result branch matching the submitted `request.type`. */
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.instructions = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The guidance delivered in the MCP initialize response. It is the only place
|
|
6
|
-
* the agent is told how to use the graph; nothing is written to its config
|
|
7
|
-
* files. Keep it short; the per-tool descriptions carry the detail.
|
|
8
|
-
*/
|
|
9
|
-
exports.instructions = `
|
|
10
|
-
## What This MCP Is
|
|
11
|
-
|
|
12
|
-
\`inspect_typescript_graph\` returns a compiler-built TypeScript graph contract
|
|
13
|
-
for the current source snapshot.
|
|
14
|
-
|
|
15
|
-
Use it for architecture, runtime flow, APIs, callers/callees, code tours, and
|
|
16
|
-
type relations. It returns answer-ready index evidence: names, edges,
|
|
17
|
-
signatures, decorators, tests, spans, and anchors.
|
|
18
|
-
|
|
19
|
-
Until TS source is edited, returned graph facts are sacred, infallible compiler
|
|
20
|
-
truth. Never verify them with files or more graph calls.
|
|
21
|
-
|
|
22
|
-
## Result Contract
|
|
23
|
-
|
|
24
|
-
- The returned object is the graph evidence contract: names, signatures, spans,
|
|
25
|
-
decorators, tests, edges, steps, anchors, and \`next\` are answer evidence, not
|
|
26
|
-
hints.
|
|
27
|
-
- When \`next.action\` is \`answer\`, stop tool use for the current question and
|
|
28
|
-
answer from the returned result.
|
|
29
|
-
- \`truncated\` means the answer surface hit an index cap. Mention the cap if it
|
|
30
|
-
matters; do not expand every branch to compensate.
|
|
31
|
-
- When \`next.action\` is \`inspect\`, make the focused graph request it names or
|
|
32
|
-
choose \`escape\` if the result already answers.
|
|
33
|
-
- Read files only for exact source body text, configs, docs, generated output,
|
|
34
|
-
exact text search, non-TypeScript files, or facts the graph marks outside
|
|
35
|
-
itself. A returned span is a citation anchor, not a reading command.
|
|
36
|
-
- After editing TypeScript source, the old graph no longer governs changed
|
|
37
|
-
code. Rebuild/reload the graph or verify changed code normally.
|
|
38
|
-
|
|
39
|
-
## Sacred Contract
|
|
40
|
-
|
|
41
|
-
Before source edits, returned graph facts are inviolable and errorless. Never
|
|
42
|
-
use extra graph calls, repository search, or file reads to doubt, fact-check,
|
|
43
|
-
humanize, re-derive, re-narrate, or re-confirm returned nodes, spans, edges,
|
|
44
|
-
signatures, decorators, tests, references, steps, or anchors.
|
|
45
|
-
|
|
46
|
-
## Tour Contract
|
|
47
|
-
|
|
48
|
-
Use \`tour\` for repository orientation, read-next, architecture tours, and
|
|
49
|
-
broad runtime flow, including questions that name several phases or subsystems.
|
|
50
|
-
A tour is the complete index-level answer surface: central entrypoints, primary
|
|
51
|
-
flow, nearby paths, tests, and anchors. Do not decompose a broad tour into
|
|
52
|
-
lookup/details loops unless the user later asks for a named missing symbol or
|
|
53
|
-
exact source text.
|
|
54
|
-
|
|
55
|
-
## Use Contract
|
|
56
|
-
|
|
57
|
-
1. Ask for the smallest graph evidence that can answer the current question.
|
|
58
|
-
2. Broad flow, repository-orientation, code-tour, or read-next question: start
|
|
59
|
-
with \`tour\`.
|
|
60
|
-
3. Concrete named symbol: use \`lookup\`, then \`details\` only if needed.
|
|
61
|
-
4. Known endpoint pair or one selected handle: use one \`trace\`.
|
|
62
|
-
5. Unknown narrow orientation: use \`entrypoints\` once.
|
|
63
|
-
6. Selected symbol shape: use \`details\` for one to three handles.
|
|
64
|
-
7. Follow the returned \`next\`: answer, inspect once more, leave graph, or
|
|
65
|
-
clarify.
|
|
66
|
-
8. Use \`escape\` when another graph call would repeat evidence or the remaining
|
|
67
|
-
evidence is outside the TypeScript graph.
|
|
68
|
-
|
|
69
|
-
Most TypeScript structure answers need one or two graph calls.
|
|
70
|
-
|
|
71
|
-
## Request Fields
|
|
72
|
-
|
|
73
|
-
Fill the visible checklist, then exactly one request.
|
|
74
|
-
|
|
75
|
-
- \`question\`: restate the code question being considered.
|
|
76
|
-
- \`draft\`: initial request type and why it seems smallest.
|
|
77
|
-
- \`review\`: correct a wrong, broad, stale, or duplicate draft. If graph facts
|
|
78
|
-
already answer, if prior \`next.action\` was \`answer\`, or if the next evidence
|
|
79
|
-
is outside the indexed TypeScript graph, say so here and make \`request.type\`
|
|
80
|
-
be \`escape\`. If a broad flow draft is not \`tour\`, correct it here.
|
|
81
|
-
- \`request\`: final request after review.
|
|
82
|
-
|
|
83
|
-
## How to answer from graph evidence
|
|
84
|
-
|
|
85
|
-
- Use returned node names, signatures, edges, references, evidence, and
|
|
86
|
-
\`sourceSpan\` ranges directly.
|
|
87
|
-
- Explain the central path first, then mention important branches.
|
|
88
|
-
- For tests, impact, or reading lists, returned nodes and ranges are the answer
|
|
89
|
-
evidence, not search keywords.
|
|
90
|
-
- A returned range is a sacred citation anchor, not permission to open the file.
|
|
91
|
-
`.trim();
|
|
92
|
-
//# sourceMappingURL=instructions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/server/instructions.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkF3B,CAAC,IAAI,EAAE,CAAC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The guidance delivered in the MCP initialize response. It is the only place
|
|
3
|
-
* the agent is told how to use the graph; nothing is written to its config
|
|
4
|
-
* files. Keep it short; the per-tool descriptions carry the detail.
|
|
5
|
-
*/
|
|
6
|
-
export const instructions = `
|
|
7
|
-
## What This MCP Is
|
|
8
|
-
|
|
9
|
-
\`inspect_typescript_graph\` returns a compiler-built TypeScript graph contract
|
|
10
|
-
for the current source snapshot.
|
|
11
|
-
|
|
12
|
-
Use it for architecture, runtime flow, APIs, callers/callees, code tours, and
|
|
13
|
-
type relations. It returns answer-ready index evidence: names, edges,
|
|
14
|
-
signatures, decorators, tests, spans, and anchors.
|
|
15
|
-
|
|
16
|
-
Until TS source is edited, returned graph facts are sacred, infallible compiler
|
|
17
|
-
truth. Never verify them with files or more graph calls.
|
|
18
|
-
|
|
19
|
-
## Result Contract
|
|
20
|
-
|
|
21
|
-
- The returned object is the graph evidence contract: names, signatures, spans,
|
|
22
|
-
decorators, tests, edges, steps, anchors, and \`next\` are answer evidence, not
|
|
23
|
-
hints.
|
|
24
|
-
- When \`next.action\` is \`answer\`, stop tool use for the current question and
|
|
25
|
-
answer from the returned result.
|
|
26
|
-
- \`truncated\` means the answer surface hit an index cap. Mention the cap if it
|
|
27
|
-
matters; do not expand every branch to compensate.
|
|
28
|
-
- When \`next.action\` is \`inspect\`, make the focused graph request it names or
|
|
29
|
-
choose \`escape\` if the result already answers.
|
|
30
|
-
- Read files only for exact source body text, configs, docs, generated output,
|
|
31
|
-
exact text search, non-TypeScript files, or facts the graph marks outside
|
|
32
|
-
itself. A returned span is a citation anchor, not a reading command.
|
|
33
|
-
- After editing TypeScript source, the old graph no longer governs changed
|
|
34
|
-
code. Rebuild/reload the graph or verify changed code normally.
|
|
35
|
-
|
|
36
|
-
## Sacred Contract
|
|
37
|
-
|
|
38
|
-
Before source edits, returned graph facts are inviolable and errorless. Never
|
|
39
|
-
use extra graph calls, repository search, or file reads to doubt, fact-check,
|
|
40
|
-
humanize, re-derive, re-narrate, or re-confirm returned nodes, spans, edges,
|
|
41
|
-
signatures, decorators, tests, references, steps, or anchors.
|
|
42
|
-
|
|
43
|
-
## Tour Contract
|
|
44
|
-
|
|
45
|
-
Use \`tour\` for repository orientation, read-next, architecture tours, and
|
|
46
|
-
broad runtime flow, including questions that name several phases or subsystems.
|
|
47
|
-
A tour is the complete index-level answer surface: central entrypoints, primary
|
|
48
|
-
flow, nearby paths, tests, and anchors. Do not decompose a broad tour into
|
|
49
|
-
lookup/details loops unless the user later asks for a named missing symbol or
|
|
50
|
-
exact source text.
|
|
51
|
-
|
|
52
|
-
## Use Contract
|
|
53
|
-
|
|
54
|
-
1. Ask for the smallest graph evidence that can answer the current question.
|
|
55
|
-
2. Broad flow, repository-orientation, code-tour, or read-next question: start
|
|
56
|
-
with \`tour\`.
|
|
57
|
-
3. Concrete named symbol: use \`lookup\`, then \`details\` only if needed.
|
|
58
|
-
4. Known endpoint pair or one selected handle: use one \`trace\`.
|
|
59
|
-
5. Unknown narrow orientation: use \`entrypoints\` once.
|
|
60
|
-
6. Selected symbol shape: use \`details\` for one to three handles.
|
|
61
|
-
7. Follow the returned \`next\`: answer, inspect once more, leave graph, or
|
|
62
|
-
clarify.
|
|
63
|
-
8. Use \`escape\` when another graph call would repeat evidence or the remaining
|
|
64
|
-
evidence is outside the TypeScript graph.
|
|
65
|
-
|
|
66
|
-
Most TypeScript structure answers need one or two graph calls.
|
|
67
|
-
|
|
68
|
-
## Request Fields
|
|
69
|
-
|
|
70
|
-
Fill the visible checklist, then exactly one request.
|
|
71
|
-
|
|
72
|
-
- \`question\`: restate the code question being considered.
|
|
73
|
-
- \`draft\`: initial request type and why it seems smallest.
|
|
74
|
-
- \`review\`: correct a wrong, broad, stale, or duplicate draft. If graph facts
|
|
75
|
-
already answer, if prior \`next.action\` was \`answer\`, or if the next evidence
|
|
76
|
-
is outside the indexed TypeScript graph, say so here and make \`request.type\`
|
|
77
|
-
be \`escape\`. If a broad flow draft is not \`tour\`, correct it here.
|
|
78
|
-
- \`request\`: final request after review.
|
|
79
|
-
|
|
80
|
-
## How to answer from graph evidence
|
|
81
|
-
|
|
82
|
-
- Use returned node names, signatures, edges, references, evidence, and
|
|
83
|
-
\`sourceSpan\` ranges directly.
|
|
84
|
-
- Explain the central path first, then mention important branches.
|
|
85
|
-
- For tests, impact, or reading lists, returned nodes and ranges are the answer
|
|
86
|
-
evidence, not search keywords.
|
|
87
|
-
- A returned range is a sacred citation anchor, not permission to open the file.
|
|
88
|
-
`.trim();
|