@ttsc/graph 0.16.4 → 0.16.5

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.
Files changed (109) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +24 -53
  3. package/lib/TtscGraphApplication.js +46 -0
  4. package/lib/TtscGraphApplication.js.map +1 -0
  5. package/lib/index.js +31 -108
  6. package/lib/index.js.map +1 -1
  7. package/lib/model/TtscGraphMemory.js +185 -0
  8. package/lib/model/TtscGraphMemory.js.map +1 -0
  9. package/lib/model/loadGraph.js +418 -0
  10. package/lib/model/loadGraph.js.map +1 -0
  11. package/lib/reduce.js +101 -0
  12. package/lib/reduce.js.map +1 -0
  13. package/lib/resolveGraphBinary.js +42 -0
  14. package/lib/resolveGraphBinary.js.map +1 -0
  15. package/lib/server/createServer.js +1227 -0
  16. package/lib/server/createServer.js.map +1 -0
  17. package/lib/server/instructions.js +32 -0
  18. package/lib/server/instructions.js.map +1 -0
  19. package/lib/server/resolveHandle.js +25 -0
  20. package/lib/server/resolveHandle.js.map +1 -0
  21. package/lib/server/runExpand.js +177 -0
  22. package/lib/server/runExpand.js.map +1 -0
  23. package/lib/server/runIndex.js +146 -0
  24. package/lib/server/runIndex.js.map +1 -0
  25. package/lib/server/runOverview.js +150 -0
  26. package/lib/server/runOverview.js.map +1 -0
  27. package/lib/server/runQuery.js +147 -0
  28. package/lib/server/runQuery.js.map +1 -0
  29. package/lib/server/runTrace.js +219 -0
  30. package/lib/server/runTrace.js.map +1 -0
  31. package/lib/server/startServer.js +21 -0
  32. package/lib/server/startServer.js.map +1 -0
  33. package/lib/structures/ITtscGraphApplication.js +3 -0
  34. package/lib/structures/ITtscGraphApplication.js.map +1 -0
  35. package/lib/structures/ITtscGraphDecorator.js +3 -0
  36. package/lib/structures/ITtscGraphDecorator.js.map +1 -0
  37. package/lib/structures/ITtscGraphDiagnostic.js +3 -0
  38. package/lib/structures/ITtscGraphDiagnostic.js.map +1 -0
  39. package/lib/structures/ITtscGraphDump.js +3 -0
  40. package/lib/structures/ITtscGraphDump.js.map +1 -0
  41. package/lib/structures/ITtscGraphEdge.js +3 -0
  42. package/lib/structures/ITtscGraphEdge.js.map +1 -0
  43. package/lib/structures/ITtscGraphEvidence.js +3 -0
  44. package/lib/structures/ITtscGraphEvidence.js.map +1 -0
  45. package/lib/structures/ITtscGraphExpand.js +3 -0
  46. package/lib/structures/ITtscGraphExpand.js.map +1 -0
  47. package/lib/structures/ITtscGraphIndex.js +3 -0
  48. package/lib/structures/ITtscGraphIndex.js.map +1 -0
  49. package/lib/structures/ITtscGraphNode.js +3 -0
  50. package/lib/structures/ITtscGraphNode.js.map +1 -0
  51. package/lib/structures/ITtscGraphOverview.js +3 -0
  52. package/lib/structures/ITtscGraphOverview.js.map +1 -0
  53. package/lib/structures/ITtscGraphQuery.js +3 -0
  54. package/lib/structures/ITtscGraphQuery.js.map +1 -0
  55. package/lib/structures/ITtscGraphTrace.js +3 -0
  56. package/lib/structures/ITtscGraphTrace.js.map +1 -0
  57. package/lib/structures/TtscGraphEdgeKind.js +3 -0
  58. package/lib/structures/TtscGraphEdgeKind.js.map +1 -0
  59. package/lib/structures/TtscGraphNodeKind.js +3 -0
  60. package/lib/structures/TtscGraphNodeKind.js.map +1 -0
  61. package/lib/structures/TtscGraphNodeModifier.js +3 -0
  62. package/lib/structures/TtscGraphNodeModifier.js.map +1 -0
  63. package/lib/structures/index.js +37 -0
  64. package/lib/structures/index.js.map +1 -0
  65. package/lib/view.js +140 -0
  66. package/lib/view.js.map +1 -0
  67. package/lib/viewer/index.html +123 -0
  68. package/lib/viewer/viewer.js +4610 -0
  69. package/package.json +17 -4
  70. package/src/TtscGraphApplication.ts +57 -0
  71. package/src/index.ts +40 -126
  72. package/src/model/TtscGraphMemory.ts +204 -0
  73. package/src/model/loadGraph.ts +85 -0
  74. package/src/reduce.ts +165 -0
  75. package/src/resolveGraphBinary.ts +40 -0
  76. package/src/server/createServer.ts +104 -0
  77. package/src/server/instructions.ts +28 -0
  78. package/src/server/resolveHandle.ts +34 -0
  79. package/src/server/runExpand.ts +186 -0
  80. package/src/server/runIndex.ts +181 -0
  81. package/src/server/runOverview.ts +154 -0
  82. package/src/server/runQuery.ts +150 -0
  83. package/src/server/runTrace.ts +233 -0
  84. package/src/server/startServer.ts +25 -0
  85. package/src/structures/ITtscGraphApplication.ts +68 -0
  86. package/src/structures/ITtscGraphDecorator.ts +33 -0
  87. package/src/structures/ITtscGraphDiagnostic.ts +34 -0
  88. package/src/structures/ITtscGraphDump.ts +35 -0
  89. package/src/structures/ITtscGraphEdge.ts +24 -0
  90. package/src/structures/ITtscGraphEvidence.ts +29 -0
  91. package/src/structures/ITtscGraphExpand.ts +85 -0
  92. package/src/structures/ITtscGraphIndex.ts +100 -0
  93. package/src/structures/ITtscGraphNode.ts +64 -0
  94. package/src/structures/ITtscGraphOverview.ts +79 -0
  95. package/src/structures/ITtscGraphQuery.ts +49 -0
  96. package/src/structures/ITtscGraphTrace.ts +97 -0
  97. package/src/structures/TtscGraphEdgeKind.ts +23 -0
  98. package/src/structures/TtscGraphNodeKind.ts +26 -0
  99. package/src/structures/TtscGraphNodeModifier.ts +19 -0
  100. package/src/structures/index.ts +21 -0
  101. package/src/view.ts +155 -0
  102. package/src/viewer/index.html +123 -0
  103. package/src/viewer/main.ts +209 -0
  104. package/lib/bin.d.ts +0 -2
  105. package/lib/diagnostics.d.ts +0 -23
  106. package/lib/diagnostics.js +0 -84
  107. package/lib/diagnostics.js.map +0 -1
  108. package/lib/index.d.ts +0 -29
  109. package/src/diagnostics.ts +0 -93
@@ -0,0 +1,1227 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.createServer = createServer;
40
+ const _a = __importStar(require("typia/lib/internal/_llmApplicationFinalize"));
41
+ const _b = __importStar(require("typia/lib/internal/_validateReport"));
42
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
43
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
44
+ const typia_1 = __importDefault(require("typia"));
45
+ const TtscGraphApplication_1 = require("../TtscGraphApplication");
46
+ const instructions_1 = require("./instructions");
47
+ /**
48
+ * Build the MCP server for a graph. `typia.llm.controller` reflects
49
+ * {@link ITtscGraphApplication} into a validated tool application — every tool's
50
+ * JSON schema and argument validator is generated from the method's TypeScript
51
+ * types and JSDoc, so there is no hand-written schema. The list/call handlers
52
+ * below are the minimal standalone registration: list the generated functions,
53
+ * and on a call validate the arguments (returning typia's errors for the model
54
+ * to self-correct) before invoking the method.
55
+ *
56
+ * Registration is inlined rather than pulled from `@typia/mcp` to keep the
57
+ * dependency surface to `typia` plus the MCP SDK and avoid version-pinning the
58
+ * wider typia ecosystem; the shape it relies on is `typia.llm.controller`'s
59
+ * public output.
60
+ */
61
+ function createServer(graph, version) {
62
+ const controller = {
63
+ "protocol": "class",
64
+ "name": "graph",
65
+ "execute": new TtscGraphApplication_1.TtscGraphApplication(graph),
66
+ "application": _a._llmApplicationFinalize({
67
+ functions: [
68
+ {
69
+ description: "The first source-free index for a code question: ranked symbols, exact code\nhandles mentioned in the query, declaration signatures, and direct\ndependency context. Use this before reading source.",
70
+ name: "graph_index",
71
+ output: {
72
+ type: "object",
73
+ properties: {
74
+ hits: {
75
+ type: "array",
76
+ items: {
77
+ $ref: "#/$defs/ITtscGraphIndex.IHit"
78
+ },
79
+ description: "Ranked symbols relevant to the query."
80
+ },
81
+ mentions: {
82
+ type: "array",
83
+ items: {
84
+ $ref: "#/$defs/ITtscGraphIndex.IMention"
85
+ },
86
+ description: "Code handles written directly in the query, resolved when possible."
87
+ },
88
+ neighborhood: {
89
+ type: "array",
90
+ items: {
91
+ $ref: "#/$defs/ITtscGraphIndex.INeighborhood"
92
+ },
93
+ description: "Direct dependency context for the resolved mentions and highest hits."
94
+ },
95
+ next: {
96
+ $ref: "#/$defs/ITtscGraphIndex.INext",
97
+ description: "Follow-up handles for deeper graph calls."
98
+ },
99
+ query: {
100
+ type: "string",
101
+ description: "The original query the index was built for."
102
+ },
103
+ truncated: {
104
+ type: "boolean",
105
+ description: "True when result caps hid additional seeds or references."
106
+ }
107
+ },
108
+ required: [
109
+ "query",
110
+ "hits",
111
+ "mentions",
112
+ "neighborhood",
113
+ "next"
114
+ ],
115
+ additionalProperties: false,
116
+ $defs: {
117
+ "ITtscGraphIndex.IHit": {
118
+ type: "object",
119
+ properties: {
120
+ file: {
121
+ type: "string"
122
+ },
123
+ id: {
124
+ type: "string"
125
+ },
126
+ kind: {
127
+ type: "string"
128
+ },
129
+ line: {
130
+ type: "number",
131
+ description: "1-based declaration line, when known."
132
+ },
133
+ name: {
134
+ type: "string"
135
+ },
136
+ score: {
137
+ type: "number",
138
+ description: "Relative relevance; higher is a better match."
139
+ },
140
+ signature: {
141
+ type: "string",
142
+ description: "Declaration head, included only for indexed symbols."
143
+ }
144
+ },
145
+ required: [
146
+ "id",
147
+ "name",
148
+ "kind",
149
+ "file",
150
+ "score"
151
+ ],
152
+ additionalProperties: false
153
+ },
154
+ "ITtscGraphIndex.IMention": {
155
+ type: "object",
156
+ properties: {
157
+ candidates: {
158
+ type: "array",
159
+ items: {
160
+ $ref: "#/$defs/ITtscGraphIndex.INode"
161
+ }
162
+ },
163
+ handle: {
164
+ type: "string"
165
+ },
166
+ node: {
167
+ $ref: "#/$defs/ITtscGraphIndex.INode"
168
+ }
169
+ },
170
+ required: [
171
+ "handle"
172
+ ],
173
+ additionalProperties: false
174
+ },
175
+ "ITtscGraphIndex.INeighborhood": {
176
+ type: "object",
177
+ properties: {
178
+ dependedOnBy: {
179
+ type: "array",
180
+ items: {
181
+ $ref: "#/$defs/ITtscGraphIndex.IReference"
182
+ }
183
+ },
184
+ dependsOn: {
185
+ type: "array",
186
+ items: {
187
+ $ref: "#/$defs/ITtscGraphIndex.IReference"
188
+ }
189
+ },
190
+ file: {
191
+ type: "string"
192
+ },
193
+ id: {
194
+ type: "string"
195
+ },
196
+ kind: {
197
+ type: "string"
198
+ },
199
+ line: {
200
+ type: "number",
201
+ description: "1-based declaration line, when known."
202
+ },
203
+ name: {
204
+ type: "string"
205
+ },
206
+ signature: {
207
+ type: "string",
208
+ description: "Declaration head, included only for indexed symbols."
209
+ }
210
+ },
211
+ required: [
212
+ "id",
213
+ "name",
214
+ "kind",
215
+ "file",
216
+ "dependsOn",
217
+ "dependedOnBy"
218
+ ],
219
+ additionalProperties: false
220
+ },
221
+ "ITtscGraphIndex.INext": {
222
+ type: "object",
223
+ properties: {
224
+ expand: {
225
+ type: "array",
226
+ items: {
227
+ type: "string"
228
+ },
229
+ description: "Pass these ids to `graph_expand`, with `source: true` only when needed."
230
+ },
231
+ traceFrom: {
232
+ type: "array",
233
+ items: {
234
+ type: "string"
235
+ },
236
+ description: "Pass these ids to `graph_trace` when following dependency flow."
237
+ }
238
+ },
239
+ required: [
240
+ "expand",
241
+ "traceFrom"
242
+ ],
243
+ additionalProperties: false
244
+ },
245
+ "ITtscGraphIndex.INode": {
246
+ type: "object",
247
+ properties: {
248
+ file: {
249
+ type: "string"
250
+ },
251
+ id: {
252
+ type: "string"
253
+ },
254
+ kind: {
255
+ type: "string"
256
+ },
257
+ line: {
258
+ type: "number",
259
+ description: "1-based declaration line, when known."
260
+ },
261
+ name: {
262
+ type: "string"
263
+ },
264
+ signature: {
265
+ type: "string",
266
+ description: "Declaration head, included only for indexed symbols."
267
+ }
268
+ },
269
+ required: [
270
+ "id",
271
+ "name",
272
+ "kind",
273
+ "file"
274
+ ],
275
+ additionalProperties: false
276
+ },
277
+ "ITtscGraphIndex.IReference": {
278
+ type: "object",
279
+ properties: {
280
+ file: {
281
+ type: "string"
282
+ },
283
+ id: {
284
+ type: "string"
285
+ },
286
+ kind: {
287
+ type: "string"
288
+ },
289
+ line: {
290
+ type: "number",
291
+ description: "1-based declaration line, when known."
292
+ },
293
+ name: {
294
+ type: "string"
295
+ },
296
+ relation: {
297
+ type: "string"
298
+ }
299
+ },
300
+ required: [
301
+ "id",
302
+ "name",
303
+ "kind",
304
+ "file",
305
+ "relation"
306
+ ],
307
+ additionalProperties: false
308
+ }
309
+ }
310
+ },
311
+ parameters: {
312
+ type: "object",
313
+ properties: {
314
+ limit: {
315
+ type: "number",
316
+ description: "Maximum ranked hits to return."
317
+ },
318
+ neighbors: {
319
+ type: "number",
320
+ description: "Maximum direct dependencies and dependents to return per indexed symbol."
321
+ },
322
+ query: {
323
+ type: "string",
324
+ description: "A natural code question or search phrase. Mix prose with code handles,\nfor example `how Repository.find loads relations` or\n`SelectQueryBuilder.setFindOptions join aliases`."
325
+ }
326
+ },
327
+ required: [
328
+ "query"
329
+ ],
330
+ additionalProperties: false,
331
+ $defs: {}
332
+ },
333
+ validate: (() => {
334
+ const _io0 = input => "string" === typeof input.query && (undefined === input.limit || "number" === typeof input.limit) && (undefined === input.neighbors || "number" === typeof input.neighbors);
335
+ const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.query || _report(_exceptionable, {
336
+ path: _path + ".query",
337
+ expected: "string",
338
+ value: input.query
339
+ }), undefined === input.limit || "number" === typeof input.limit || _report(_exceptionable, {
340
+ path: _path + ".limit",
341
+ expected: "(number | undefined)",
342
+ value: input.limit
343
+ }), undefined === input.neighbors || "number" === typeof input.neighbors || _report(_exceptionable, {
344
+ path: _path + ".neighbors",
345
+ expected: "(number | undefined)",
346
+ value: input.neighbors
347
+ })].every(flag => flag);
348
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
349
+ let errors;
350
+ let _report;
351
+ return input => {
352
+ if (false === __is(input)) {
353
+ errors = [];
354
+ _report = _b._validateReport(errors);
355
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
356
+ path: _path + "",
357
+ expected: "ITtscGraphIndex.IProps",
358
+ value: input
359
+ })) && _vo0(input, _path + "", true) || _report(true, {
360
+ path: _path + "",
361
+ expected: "ITtscGraphIndex.IProps",
362
+ value: input
363
+ }))(input, "$input", true);
364
+ const success = 0 === errors.length;
365
+ return success ? {
366
+ success,
367
+ data: input
368
+ } : {
369
+ success,
370
+ errors,
371
+ data: input
372
+ };
373
+ }
374
+ return {
375
+ success: true,
376
+ data: input
377
+ };
378
+ };
379
+ })()
380
+ },
381
+ {
382
+ description: "The project's architecture \u2014 folder layers, dependency hotspots, and the\npublic API. Call first to orient on an unfamiliar codebase.",
383
+ name: "graph_overview",
384
+ output: {
385
+ type: "object",
386
+ properties: {
387
+ counts: {
388
+ $ref: "#/$defs/ITtscGraphOverview.ICounts",
389
+ description: "Size of the graph."
390
+ },
391
+ hotspots: {
392
+ type: "array",
393
+ items: {
394
+ $ref: "#/$defs/ITtscGraphOverview.IHotspot"
395
+ },
396
+ description: "Highest-dependency symbols, busiest first."
397
+ },
398
+ layers: {
399
+ type: "array",
400
+ items: {
401
+ $ref: "#/$defs/ITtscGraphOverview.ILayer"
402
+ },
403
+ description: "Folder layering, largest first."
404
+ },
405
+ project: {
406
+ type: "string",
407
+ description: "Absolute project root."
408
+ },
409
+ publicApi: {
410
+ type: "array",
411
+ items: {
412
+ $ref: "#/$defs/ITtscGraphOverview.IPublicApi"
413
+ },
414
+ description: "Exported API symbols, most-depended-on first."
415
+ }
416
+ },
417
+ required: [
418
+ "project",
419
+ "counts"
420
+ ],
421
+ additionalProperties: false,
422
+ $defs: {
423
+ "ITtscGraphOverview.ICounts": {
424
+ type: "object",
425
+ properties: {
426
+ byKind: {
427
+ $ref: "#/$defs/Recordstringnumber",
428
+ description: "Node count per kind."
429
+ },
430
+ edges: {
431
+ type: "number"
432
+ },
433
+ files: {
434
+ type: "number"
435
+ },
436
+ nodes: {
437
+ type: "number"
438
+ }
439
+ },
440
+ required: [
441
+ "files",
442
+ "nodes",
443
+ "edges",
444
+ "byKind"
445
+ ],
446
+ additionalProperties: false
447
+ },
448
+ "ITtscGraphOverview.IHotspot": {
449
+ type: "object",
450
+ properties: {
451
+ fanIn: {
452
+ type: "number",
453
+ description: "Non-structural edges pointing at this symbol."
454
+ },
455
+ fanOut: {
456
+ type: "number",
457
+ description: "Non-structural edges leaving this symbol."
458
+ },
459
+ file: {
460
+ type: "string"
461
+ },
462
+ id: {
463
+ type: "string"
464
+ },
465
+ kind: {
466
+ type: "string"
467
+ },
468
+ name: {
469
+ type: "string"
470
+ }
471
+ },
472
+ required: [
473
+ "id",
474
+ "name",
475
+ "kind",
476
+ "file",
477
+ "fanIn",
478
+ "fanOut"
479
+ ],
480
+ additionalProperties: false
481
+ },
482
+ "ITtscGraphOverview.ILayer": {
483
+ type: "object",
484
+ properties: {
485
+ dir: {
486
+ type: "string",
487
+ description: "Directory, project-relative."
488
+ },
489
+ exported: {
490
+ type: "number",
491
+ description: "Exported symbols declared under it."
492
+ },
493
+ files: {
494
+ type: "number",
495
+ description: "Distinct source files under it."
496
+ }
497
+ },
498
+ required: [
499
+ "dir",
500
+ "files",
501
+ "exported"
502
+ ],
503
+ additionalProperties: false
504
+ },
505
+ "ITtscGraphOverview.IPublicApi": {
506
+ type: "object",
507
+ properties: {
508
+ file: {
509
+ type: "string",
510
+ description: "Project-relative path of the file that declares it."
511
+ },
512
+ kind: {
513
+ type: "string",
514
+ description: "Its declaration kind (`class`, `interface`, `function`, \u2026)."
515
+ },
516
+ name: {
517
+ type: "string",
518
+ description: "The exported symbol's name."
519
+ }
520
+ },
521
+ required: [
522
+ "name",
523
+ "kind",
524
+ "file"
525
+ ],
526
+ additionalProperties: false
527
+ },
528
+ Recordstringnumber: {
529
+ type: "object",
530
+ properties: {},
531
+ required: [],
532
+ additionalProperties: {
533
+ type: "number"
534
+ }
535
+ }
536
+ }
537
+ },
538
+ parameters: {
539
+ type: "object",
540
+ properties: {
541
+ aspect: {
542
+ type: "string",
543
+ "enum": [
544
+ "all",
545
+ "hotspots",
546
+ "layers",
547
+ "publicApi"
548
+ ],
549
+ description: "The facet to project, or `all` for every facet. `layers` is the folder\nlayering, `hotspots` the highest-dependency symbols, `publicApi` the\nexported API symbols ranked by how depended-on they are."
550
+ }
551
+ },
552
+ required: [],
553
+ additionalProperties: false,
554
+ $defs: {}
555
+ },
556
+ validate: (() => {
557
+ const _io0 = input => undefined === input.aspect || "all" === input.aspect || "hotspots" === input.aspect || "layers" === input.aspect || "publicApi" === input.aspect;
558
+ const _vo0 = (input, _path, _exceptionable = true) => [undefined === input.aspect || "all" === input.aspect || "hotspots" === input.aspect || "layers" === input.aspect || "publicApi" === input.aspect || _report(_exceptionable, {
559
+ path: _path + ".aspect",
560
+ expected: "(\"all\" | \"hotspots\" | \"layers\" | \"publicApi\" | undefined)",
561
+ value: input.aspect
562
+ })].every(flag => flag);
563
+ const __is = input => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
564
+ let errors;
565
+ let _report;
566
+ return input => {
567
+ if (false === __is(input)) {
568
+ errors = [];
569
+ _report = _b._validateReport(errors);
570
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input && false === Array.isArray(input) || _report(true, {
571
+ path: _path + "",
572
+ expected: "ITtscGraphOverview.IProps",
573
+ value: input
574
+ })) && _vo0(input, _path + "", true) || _report(true, {
575
+ path: _path + "",
576
+ expected: "ITtscGraphOverview.IProps",
577
+ value: input
578
+ }))(input, "$input", true);
579
+ const success = 0 === errors.length;
580
+ return success ? {
581
+ success,
582
+ data: input
583
+ } : {
584
+ success,
585
+ errors,
586
+ data: input
587
+ };
588
+ }
589
+ return {
590
+ success: true,
591
+ data: input
592
+ };
593
+ };
594
+ })()
595
+ },
596
+ {
597
+ description: "The declared shape of the given symbols: each one's signature, and for a\nclass/interface/namespace its members. Handles may be ids or dotted symbol\nnames. Set `source: true` to also read a specific body, `neighbors: true`\nto list what it uses and what uses it.",
598
+ name: "graph_expand",
599
+ output: {
600
+ type: "object",
601
+ properties: {
602
+ nodes: {
603
+ type: "array",
604
+ items: {
605
+ $ref: "#/$defs/ITtscGraphExpand.INode"
606
+ }
607
+ },
608
+ unknown: {
609
+ type: "array",
610
+ items: {
611
+ type: "string"
612
+ },
613
+ description: "Handles that resolved to no node, or that were ambiguous."
614
+ }
615
+ },
616
+ required: [
617
+ "nodes",
618
+ "unknown"
619
+ ],
620
+ additionalProperties: false,
621
+ $defs: {
622
+ "ITtscGraphExpand.IMember": {
623
+ type: "object",
624
+ properties: {
625
+ kind: {
626
+ type: "string"
627
+ },
628
+ line: {
629
+ type: "number",
630
+ description: "1-based declaration line, when known."
631
+ },
632
+ name: {
633
+ type: "string"
634
+ },
635
+ signature: {
636
+ type: "string",
637
+ description: "The member's declaration signature."
638
+ }
639
+ },
640
+ required: [
641
+ "name",
642
+ "kind"
643
+ ],
644
+ additionalProperties: false
645
+ },
646
+ "ITtscGraphExpand.INode": {
647
+ type: "object",
648
+ properties: {
649
+ dependedOnBy: {
650
+ type: "array",
651
+ items: {
652
+ $ref: "#/$defs/ITtscGraphExpand.IReference"
653
+ },
654
+ description: "Symbols that use this node (incoming dependency edges)."
655
+ },
656
+ dependsOn: {
657
+ type: "array",
658
+ items: {
659
+ $ref: "#/$defs/ITtscGraphExpand.IReference"
660
+ },
661
+ description: "Symbols this node uses (outgoing dependency edges)."
662
+ },
663
+ file: {
664
+ type: "string"
665
+ },
666
+ id: {
667
+ type: "string"
668
+ },
669
+ kind: {
670
+ type: "string"
671
+ },
672
+ line: {
673
+ type: "number",
674
+ description: "1-based declaration line, when known."
675
+ },
676
+ members: {
677
+ type: "array",
678
+ items: {
679
+ $ref: "#/$defs/ITtscGraphExpand.IMember"
680
+ },
681
+ description: "For a class, interface, namespace, module, enum, or file: the symbols it\ncontains, each with its own signature \u2014 the member outline a consumer\nreaches for, without the bodies."
682
+ },
683
+ name: {
684
+ type: "string"
685
+ },
686
+ signature: {
687
+ type: "string",
688
+ description: "The declaration signature \u2014 its first line(s) up to the body."
689
+ },
690
+ source: {
691
+ type: "string",
692
+ description: "The full declaration source \u2014 only when `source` was requested."
693
+ },
694
+ truncated: {
695
+ type: "boolean",
696
+ description: "True when `source` was cut at the line cap."
697
+ }
698
+ },
699
+ required: [
700
+ "id",
701
+ "name",
702
+ "kind",
703
+ "file"
704
+ ],
705
+ additionalProperties: false
706
+ },
707
+ "ITtscGraphExpand.IReference": {
708
+ type: "object",
709
+ properties: {
710
+ id: {
711
+ type: "string"
712
+ },
713
+ kind: {
714
+ type: "string"
715
+ },
716
+ name: {
717
+ type: "string"
718
+ },
719
+ relation: {
720
+ type: "string",
721
+ description: "The edge kind connecting the two (`calls`, `type_ref`, \u2026)."
722
+ }
723
+ },
724
+ required: [
725
+ "id",
726
+ "name",
727
+ "kind",
728
+ "relation"
729
+ ],
730
+ additionalProperties: false
731
+ }
732
+ }
733
+ },
734
+ parameters: {
735
+ type: "object",
736
+ properties: {
737
+ handles: {
738
+ type: "array",
739
+ items: {
740
+ type: "string"
741
+ },
742
+ description: "Node ids from another tool, or dotted symbol handles such as\n`OrderService.create`. Pass every handle you need in one call."
743
+ },
744
+ neighbors: {
745
+ type: "boolean",
746
+ description: "Also list each node's direct dependencies and dependents (the symbols it\nuses and the symbols that use it)."
747
+ },
748
+ source: {
749
+ type: "boolean",
750
+ description: "Return the full declaration source body too. Off by default: expand\nreturns the declared shape \u2014 a symbol's signature, and a class/interface/\nnamespace's member outline \u2014 which is what you usually need and a\nfraction of the tokens. Turn this on only for the few leaf functions or\nmethods whose actual control-flow logic you must read."
751
+ }
752
+ },
753
+ required: [
754
+ "handles"
755
+ ],
756
+ additionalProperties: false,
757
+ $defs: {}
758
+ },
759
+ validate: (() => {
760
+ const _io0 = input => Array.isArray(input.handles) && input.handles.every(elem => "string" === typeof elem) && (undefined === input.neighbors || "boolean" === typeof input.neighbors) && (undefined === input.source || "boolean" === typeof input.source);
761
+ const _vo0 = (input, _path, _exceptionable = true) => [(Array.isArray(input.handles) || _report(_exceptionable, {
762
+ path: _path + ".handles",
763
+ expected: "Array<string>",
764
+ value: input.handles
765
+ })) && input.handles.map((elem, _index2) => "string" === typeof elem || _report(_exceptionable, {
766
+ path: _path + ".handles[" + _index2 + "]",
767
+ expected: "string",
768
+ value: elem
769
+ })).every(flag => flag) || _report(_exceptionable, {
770
+ path: _path + ".handles",
771
+ expected: "Array<string>",
772
+ value: input.handles
773
+ }), undefined === input.neighbors || "boolean" === typeof input.neighbors || _report(_exceptionable, {
774
+ path: _path + ".neighbors",
775
+ expected: "(boolean | undefined)",
776
+ value: input.neighbors
777
+ }), undefined === input.source || "boolean" === typeof input.source || _report(_exceptionable, {
778
+ path: _path + ".source",
779
+ expected: "(boolean | undefined)",
780
+ value: input.source
781
+ })].every(flag => flag);
782
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
783
+ let errors;
784
+ let _report;
785
+ return input => {
786
+ if (false === __is(input)) {
787
+ errors = [];
788
+ _report = _b._validateReport(errors);
789
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
790
+ path: _path + "",
791
+ expected: "ITtscGraphExpand.IProps",
792
+ value: input
793
+ })) && _vo0(input, _path + "", true) || _report(true, {
794
+ path: _path + "",
795
+ expected: "ITtscGraphExpand.IProps",
796
+ value: input
797
+ }))(input, "$input", true);
798
+ const success = 0 === errors.length;
799
+ return success ? {
800
+ success,
801
+ data: input
802
+ } : {
803
+ success,
804
+ errors,
805
+ data: input
806
+ };
807
+ }
808
+ return {
809
+ success: true,
810
+ data: input
811
+ };
812
+ };
813
+ })()
814
+ },
815
+ {
816
+ description: "Find any symbol \u2014 class, function, method, or field \u2014 by name or\ndescription. Each hit comes with its signature, so the query alone often\nanswers the question, and `next.expand` gives handles for source\nfollow-up.",
817
+ name: "graph_query",
818
+ output: {
819
+ type: "object",
820
+ properties: {
821
+ hits: {
822
+ type: "array",
823
+ items: {
824
+ $ref: "#/$defs/ITtscGraphQuery.IHit"
825
+ }
826
+ },
827
+ next: {
828
+ $ref: "#/$defs/ITtscGraphQuery.INext",
829
+ description: "Follow-up handles for source or member details."
830
+ }
831
+ },
832
+ required: [
833
+ "hits",
834
+ "next"
835
+ ],
836
+ additionalProperties: false,
837
+ $defs: {
838
+ "ITtscGraphQuery.IHit": {
839
+ type: "object",
840
+ properties: {
841
+ file: {
842
+ type: "string"
843
+ },
844
+ id: {
845
+ type: "string"
846
+ },
847
+ kind: {
848
+ type: "string"
849
+ },
850
+ line: {
851
+ type: "number",
852
+ description: "1-based declaration line, when known."
853
+ },
854
+ name: {
855
+ type: "string"
856
+ },
857
+ score: {
858
+ type: "number",
859
+ description: "Relative relevance; higher is a better match."
860
+ },
861
+ signature: {
862
+ type: "string",
863
+ description: "The hit's declaration signature, so you can often answer without\nexpanding."
864
+ }
865
+ },
866
+ required: [
867
+ "id",
868
+ "name",
869
+ "kind",
870
+ "file",
871
+ "score"
872
+ ],
873
+ additionalProperties: false
874
+ },
875
+ "ITtscGraphQuery.INext": {
876
+ type: "object",
877
+ properties: {
878
+ expand: {
879
+ type: "array",
880
+ items: {
881
+ type: "string"
882
+ },
883
+ description: "Pass these ids to `graph_expand`, with `source: true` only when needed."
884
+ }
885
+ },
886
+ required: [
887
+ "expand"
888
+ ],
889
+ additionalProperties: false
890
+ }
891
+ }
892
+ },
893
+ parameters: {
894
+ type: "object",
895
+ properties: {
896
+ limit: {
897
+ type: "number",
898
+ description: "Maximum hits to return."
899
+ },
900
+ query: {
901
+ type: "string",
902
+ description: "What to find, in natural language and code vocabulary mixed freely \u2014 a\nsymbol name, a dotted member (`OrderService.create`), or a phrase\n(`shopping order create`, `repository find relations`). Exact names are\nnot required; subword and CamelCase matches rank too."
903
+ }
904
+ },
905
+ required: [
906
+ "query"
907
+ ],
908
+ additionalProperties: false,
909
+ $defs: {}
910
+ },
911
+ validate: (() => {
912
+ const _io0 = input => "string" === typeof input.query && (undefined === input.limit || "number" === typeof input.limit);
913
+ const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.query || _report(_exceptionable, {
914
+ path: _path + ".query",
915
+ expected: "string",
916
+ value: input.query
917
+ }), undefined === input.limit || "number" === typeof input.limit || _report(_exceptionable, {
918
+ path: _path + ".limit",
919
+ expected: "(number | undefined)",
920
+ value: input.limit
921
+ })].every(flag => flag);
922
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
923
+ let errors;
924
+ let _report;
925
+ return input => {
926
+ if (false === __is(input)) {
927
+ errors = [];
928
+ _report = _b._validateReport(errors);
929
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
930
+ path: _path + "",
931
+ expected: "ITtscGraphQuery.IProps",
932
+ value: input
933
+ })) && _vo0(input, _path + "", true) || _report(true, {
934
+ path: _path + "",
935
+ expected: "ITtscGraphQuery.IProps",
936
+ value: input
937
+ }))(input, "$input", true);
938
+ const success = 0 === errors.length;
939
+ return success ? {
940
+ success,
941
+ data: input
942
+ } : {
943
+ success,
944
+ errors,
945
+ data: input
946
+ };
947
+ }
948
+ return {
949
+ success: true,
950
+ data: input
951
+ };
952
+ };
953
+ })()
954
+ },
955
+ {
956
+ description: "Follow dependency flow from a symbol: `forward` to what it uses, `reverse`\nto what uses it, or `impact` to the public API and tests a change reaches.\nGive `from`/`to` as ids or dotted names to get the path between two symbols\nin one call \u2014 how A reaches B.",
957
+ name: "graph_trace",
958
+ output: {
959
+ type: "object",
960
+ properties: {
961
+ candidates: {
962
+ type: "array",
963
+ items: {
964
+ $ref: "#/$defs/ITtscGraphTrace.INode"
965
+ },
966
+ description: "When `from` was an ambiguous name, the matches to disambiguate with."
967
+ },
968
+ direction: {
969
+ type: "string"
970
+ },
971
+ hops: {
972
+ type: "array",
973
+ items: {
974
+ $ref: "#/$defs/ITtscGraphTrace.IHop"
975
+ },
976
+ description: "Edges traversed, in breadth-first order."
977
+ },
978
+ path: {
979
+ type: "array",
980
+ items: {
981
+ $ref: "#/$defs/ITtscGraphTrace.INode"
982
+ },
983
+ description: "When `to` was given: the ordered dependency path from `from` to `to`\n(`from` first, `to` last), or empty when `to` is not reachable from\n`from`."
984
+ },
985
+ reached: {
986
+ type: "array",
987
+ items: {
988
+ $ref: "#/$defs/ITtscGraphTrace.INode"
989
+ },
990
+ description: "Unique nodes reached (excluding the start), each with its depth and roles."
991
+ },
992
+ start: {
993
+ $ref: "#/$defs/ITtscGraphTrace.INode",
994
+ description: "The resolved start node, or undefined when `from` matched nothing."
995
+ },
996
+ target: {
997
+ $ref: "#/$defs/ITtscGraphTrace.INode",
998
+ description: "The resolved `to` target, when a path was requested."
999
+ },
1000
+ truncated: {
1001
+ type: "boolean",
1002
+ description: "True when the trace hit maxNodes or maxDepth and more flow exists."
1003
+ }
1004
+ },
1005
+ required: [
1006
+ "direction",
1007
+ "hops",
1008
+ "reached",
1009
+ "truncated"
1010
+ ],
1011
+ additionalProperties: false,
1012
+ $defs: {
1013
+ "ITtscGraphTrace.IHop": {
1014
+ type: "object",
1015
+ properties: {
1016
+ depth: {
1017
+ type: "number",
1018
+ description: "Hops from the start (1 = direct)."
1019
+ },
1020
+ from: {
1021
+ type: "string"
1022
+ },
1023
+ kind: {
1024
+ type: "string"
1025
+ },
1026
+ to: {
1027
+ type: "string"
1028
+ }
1029
+ },
1030
+ required: [
1031
+ "from",
1032
+ "to",
1033
+ "kind",
1034
+ "depth"
1035
+ ],
1036
+ additionalProperties: false
1037
+ },
1038
+ "ITtscGraphTrace.INode": {
1039
+ type: "object",
1040
+ properties: {
1041
+ depth: {
1042
+ type: "number",
1043
+ description: "Hops from the start, on a reached node."
1044
+ },
1045
+ file: {
1046
+ type: "string"
1047
+ },
1048
+ id: {
1049
+ type: "string"
1050
+ },
1051
+ kind: {
1052
+ type: "string"
1053
+ },
1054
+ name: {
1055
+ type: "string"
1056
+ },
1057
+ roles: {
1058
+ type: "array",
1059
+ items: {
1060
+ type: "string"
1061
+ },
1062
+ description: "Why this node matters to an impact trace: `exported`, `test`."
1063
+ },
1064
+ signature: {
1065
+ type: "string",
1066
+ description: "The node's signature \u2014 carried on path nodes so the path explains itself."
1067
+ }
1068
+ },
1069
+ required: [
1070
+ "id",
1071
+ "name",
1072
+ "kind",
1073
+ "file"
1074
+ ],
1075
+ additionalProperties: false
1076
+ }
1077
+ }
1078
+ },
1079
+ parameters: {
1080
+ type: "object",
1081
+ properties: {
1082
+ direction: {
1083
+ type: "string",
1084
+ "enum": [
1085
+ "forward",
1086
+ "impact",
1087
+ "reverse"
1088
+ ],
1089
+ description: "`forward` follows what the start uses (callees, instantiations, renders);\n`reverse` follows what uses the start (callers); `impact` is a reverse\ntrace that flags the public API and tests a change would reach."
1090
+ },
1091
+ from: {
1092
+ type: "string",
1093
+ description: "Where to start: a node id from another tool, a simple symbol name, or a\ndotted member name such as `OrderService.create`. An ambiguous name\nreturns its candidates instead of a trace."
1094
+ },
1095
+ maxDepth: {
1096
+ type: "number",
1097
+ description: "How many hops deep to follow."
1098
+ },
1099
+ maxNodes: {
1100
+ type: "number",
1101
+ description: "Cap on reached nodes; the trace stops and marks itself truncated past it."
1102
+ },
1103
+ to: {
1104
+ type: "string",
1105
+ description: "A target symbol: node id, simple symbol name, or dotted member name. When\ngiven, the tool returns the dependency path from `from` to this target \u2014\nthe one-call answer for \"how does A reach B\" \u2014 instead of an open-ended\ntrace."
1106
+ }
1107
+ },
1108
+ required: [
1109
+ "from"
1110
+ ],
1111
+ additionalProperties: false,
1112
+ $defs: {}
1113
+ },
1114
+ validate: (() => {
1115
+ const _io0 = input => "string" === typeof input.from && (undefined === input.to || "string" === typeof input.to) && (undefined === input.direction || "forward" === input.direction || "impact" === input.direction || "reverse" === input.direction) && (undefined === input.maxDepth || "number" === typeof input.maxDepth) && (undefined === input.maxNodes || "number" === typeof input.maxNodes);
1116
+ const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.from || _report(_exceptionable, {
1117
+ path: _path + ".from",
1118
+ expected: "string",
1119
+ value: input.from
1120
+ }), undefined === input.to || "string" === typeof input.to || _report(_exceptionable, {
1121
+ path: _path + ".to",
1122
+ expected: "(string | undefined)",
1123
+ value: input.to
1124
+ }), undefined === input.direction || "forward" === input.direction || "impact" === input.direction || "reverse" === input.direction || _report(_exceptionable, {
1125
+ path: _path + ".direction",
1126
+ expected: "(\"forward\" | \"impact\" | \"reverse\" | undefined)",
1127
+ value: input.direction
1128
+ }), undefined === input.maxDepth || "number" === typeof input.maxDepth || _report(_exceptionable, {
1129
+ path: _path + ".maxDepth",
1130
+ expected: "(number | undefined)",
1131
+ value: input.maxDepth
1132
+ }), undefined === input.maxNodes || "number" === typeof input.maxNodes || _report(_exceptionable, {
1133
+ path: _path + ".maxNodes",
1134
+ expected: "(number | undefined)",
1135
+ value: input.maxNodes
1136
+ })].every(flag => flag);
1137
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
1138
+ let errors;
1139
+ let _report;
1140
+ return input => {
1141
+ if (false === __is(input)) {
1142
+ errors = [];
1143
+ _report = _b._validateReport(errors);
1144
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
1145
+ path: _path + "",
1146
+ expected: "ITtscGraphTrace.IProps",
1147
+ value: input
1148
+ })) && _vo0(input, _path + "", true) || _report(true, {
1149
+ path: _path + "",
1150
+ expected: "ITtscGraphTrace.IProps",
1151
+ value: input
1152
+ }))(input, "$input", true);
1153
+ const success = 0 === errors.length;
1154
+ return success ? {
1155
+ success,
1156
+ data: input
1157
+ } : {
1158
+ success,
1159
+ errors,
1160
+ data: input
1161
+ };
1162
+ }
1163
+ return {
1164
+ success: true,
1165
+ data: input
1166
+ };
1167
+ };
1168
+ })()
1169
+ }
1170
+ ]
1171
+ })
1172
+ };
1173
+ const functions = controller.application.functions;
1174
+ const execute = controller.execute;
1175
+ const server = new mcp_js_1.McpServer({ name: "ttsc-graph", version }, { capabilities: { tools: {} }, instructions: instructions_1.instructions });
1176
+ const raw = server.server;
1177
+ raw.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
1178
+ tools: functions.map((func) => ({
1179
+ name: func.name,
1180
+ description: func.description,
1181
+ inputSchema: {
1182
+ type: "object",
1183
+ properties: func.parameters.properties,
1184
+ required: func.parameters.required,
1185
+ additionalProperties: false,
1186
+ $defs: func.parameters.$defs,
1187
+ },
1188
+ })),
1189
+ }));
1190
+ raw.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
1191
+ const func = functions.find((f) => f.name === request.params.name);
1192
+ const method = execute[request.params.name];
1193
+ if (func === undefined || method === undefined) {
1194
+ return error(`Unknown tool: ${request.params.name}`);
1195
+ }
1196
+ // A client may omit `arguments` for an all-optional tool (e.g. graph_overview);
1197
+ // validate an empty object so that call succeeds instead of failing on "expected object".
1198
+ const validation = func.validate(request.params.arguments ?? {});
1199
+ if (!validation.success) {
1200
+ // Hand typia's validation errors back so the model can correct its call.
1201
+ return error(JSON.stringify(validation.errors, null, 2));
1202
+ }
1203
+ try {
1204
+ const result = await method.call(execute, validation.data);
1205
+ return {
1206
+ content: [
1207
+ {
1208
+ type: "text",
1209
+ text: result === undefined
1210
+ ? "Success"
1211
+ : JSON.stringify(result, null, 2),
1212
+ },
1213
+ ],
1214
+ };
1215
+ }
1216
+ catch (exception) {
1217
+ return error(exception instanceof Error
1218
+ ? `${exception.name}: ${exception.message}`
1219
+ : String(exception));
1220
+ }
1221
+ });
1222
+ return server;
1223
+ }
1224
+ function error(text) {
1225
+ return { isError: true, content: [{ type: "text", text }] };
1226
+ }
1227
+ //# sourceMappingURL=createServer.js.map