@ttsc/graph 0.16.10 → 0.16.11
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/lib/TtscGraphApplication.d.ts +24 -0
- package/lib/bin.d.ts +2 -0
- package/lib/index.d.ts +12 -0
- package/lib/model/TtscGraphMemory.d.ts +41 -0
- package/lib/model/loadGraph.d.ts +23 -0
- package/lib/reduce.d.ts +46 -0
- package/lib/resolveGraphBinary.d.ts +18 -0
- package/lib/server/accessAliases.d.ts +8 -0
- package/lib/server/createServer.d.ts +15 -0
- package/lib/server/pathPolicy.d.ts +9 -0
- package/lib/server/resolveHandle.d.ts +8 -0
- package/lib/server/resultGuide.d.ts +3 -0
- package/lib/server/runDetails.d.ts +24 -0
- package/lib/server/runEntrypoints.d.ts +9 -0
- package/lib/server/runLookup.d.ts +10 -0
- package/lib/server/runOverview.d.ts +10 -0
- package/lib/server/runTour.d.ts +8 -0
- package/lib/server/runTrace.d.ts +10 -0
- package/lib/server/startServer.d.ts +11 -0
- package/lib/structures/ITtscGraphApplication.d.ts +161 -0
- package/lib/structures/ITtscGraphDecorator.d.ts +30 -0
- package/lib/structures/ITtscGraphDetails.d.ts +157 -0
- package/lib/structures/ITtscGraphDiagnostic.d.ts +27 -0
- package/lib/structures/ITtscGraphDump.d.ts +30 -0
- package/lib/structures/ITtscGraphEdge.d.ts +20 -0
- package/lib/structures/ITtscGraphEntrypoints.d.ts +117 -0
- package/lib/structures/ITtscGraphEscape.d.ts +40 -0
- package/lib/structures/ITtscGraphEvidence.d.ts +22 -0
- package/lib/structures/ITtscGraphLookup.d.ts +67 -0
- package/lib/structures/ITtscGraphNext.d.ts +15 -0
- package/lib/structures/ITtscGraphNode.d.ts +58 -0
- package/lib/structures/ITtscGraphOverview.d.ts +85 -0
- package/lib/structures/ITtscGraphTour.d.ts +113 -0
- package/lib/structures/ITtscGraphTrace.d.ts +143 -0
- package/lib/structures/TtscGraphEdgeKind.d.ts +10 -0
- package/lib/structures/TtscGraphNodeKind.d.ts +12 -0
- package/lib/structures/TtscGraphNodeModifier.d.ts +7 -0
- package/lib/structures/index.d.ts +18 -0
- package/lib/view.d.ts +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TtscGraphMemory } from "./model/TtscGraphMemory";
|
|
2
|
+
import { ITtscGraphApplication } from "./structures/ITtscGraphApplication";
|
|
3
|
+
export type TtscGraphSource = TtscGraphMemory | (() => TtscGraphMemory);
|
|
4
|
+
/**
|
|
5
|
+
* The MCP tool surface as a plain class over the resident
|
|
6
|
+
* {@link TtscGraphMemory}.
|
|
7
|
+
*
|
|
8
|
+
* Its public method is the MCP tool: `typia.llm.application` reflects
|
|
9
|
+
* {@link ITtscGraphApplication} to generate the tool's JSON schema and argument
|
|
10
|
+
* validator from the signature and JSDoc, with no hand-written schema, and
|
|
11
|
+
* `@typia/mcp`'s `createMcpServer` registers it (see `./server/createServer`).
|
|
12
|
+
* The method delegates to the pure graph functions in `./server`, which are
|
|
13
|
+
* unit-testable without a transport; this class only binds them to the graph.
|
|
14
|
+
*
|
|
15
|
+
* Every method answers from the resident graph; none recompiles. Output is kept
|
|
16
|
+
* compact and bounded so a model can read structure without a file read, which
|
|
17
|
+
* is the token win the redesign exists for.
|
|
18
|
+
*/
|
|
19
|
+
export declare class TtscGraphApplication implements ITtscGraphApplication {
|
|
20
|
+
private readonly graph;
|
|
21
|
+
constructor(source: TtscGraphSource);
|
|
22
|
+
inspect_typescript_graph(props: ITtscGraphApplication.IProps): ITtscGraphApplication.IResult;
|
|
23
|
+
private escape;
|
|
24
|
+
}
|
package/lib/bin.d.ts
ADDED
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run the `@ttsc/graph` launcher.
|
|
3
|
+
*
|
|
4
|
+
* - `view`: JS-orchestrated 3D viewer (dump -> reduce -> serve -> open).
|
|
5
|
+
* - `dump`: pass through to the native `ttscgraph dump`, which prints the whole
|
|
6
|
+
* graph as JSON for piping or the viewer.
|
|
7
|
+
* - Default: serve the MCP graph over stdio. The TypeScript server runs
|
|
8
|
+
* `ttscgraph dump` once to build the resident graph, then answers tool calls
|
|
9
|
+
* from memory; the agent's MCP client speaks JSON-RPC over this process's
|
|
10
|
+
* stdin/stdout. The process stays alive on the stdio transport.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runGraph(argv?: readonly string[]): number | void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ITtscGraphDump } from "../structures/ITtscGraphDump";
|
|
2
|
+
import { ITtscGraphEdge } from "../structures/ITtscGraphEdge";
|
|
3
|
+
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
4
|
+
/**
|
|
5
|
+
* The in-memory resident graph the MCP tools answer from.
|
|
6
|
+
*
|
|
7
|
+
* It loads one `ttscgraph dump` — the checker-resolved fact graph — then
|
|
8
|
+
* synthesizes the structural relationships the dump deliberately leaves to this
|
|
9
|
+
* layer: `file` container nodes, the `contains` ownership tree, and `exports`
|
|
10
|
+
* edges, plus class/interface member implementation edges and the refinement of
|
|
11
|
+
* a class-member `variable` to a `property`. Every tool call is then a lookup
|
|
12
|
+
* or a traversal over the indexes built here; nothing recompiles.
|
|
13
|
+
*/
|
|
14
|
+
export declare class TtscGraphMemory {
|
|
15
|
+
private readonly byId;
|
|
16
|
+
private readonly outEdges;
|
|
17
|
+
private readonly inEdges;
|
|
18
|
+
private readonly byNameIndex;
|
|
19
|
+
private readonly bySymbolIndex;
|
|
20
|
+
/** The absolute project root the dump was built for. */
|
|
21
|
+
readonly project: string;
|
|
22
|
+
/** Every node, raw plus synthesized (file containers). */
|
|
23
|
+
readonly nodes: readonly ITtscGraphNode[];
|
|
24
|
+
/** Every edge, raw plus synthesized (contains, exports). */
|
|
25
|
+
readonly edges: readonly ITtscGraphEdge[];
|
|
26
|
+
private constructor();
|
|
27
|
+
/** Build a model from a parsed dump, synthesizing structural relationships. */
|
|
28
|
+
static from(dump: ITtscGraphDump): TtscGraphMemory;
|
|
29
|
+
/** The node with this id, or undefined. */
|
|
30
|
+
node(id: string): ITtscGraphNode | undefined;
|
|
31
|
+
/** Edges leaving a node (the node is the `from`). */
|
|
32
|
+
outgoing(id: string): readonly ITtscGraphEdge[];
|
|
33
|
+
/** Edges entering a node (the node is the `to`). */
|
|
34
|
+
incoming(id: string): readonly ITtscGraphEdge[];
|
|
35
|
+
/** Every node whose simple name equals `name`. */
|
|
36
|
+
named(name: string): readonly ITtscGraphNode[];
|
|
37
|
+
/** Every non-file node whose simple or owner-qualified symbol handle matches. */
|
|
38
|
+
symbols(handle: string): readonly ITtscGraphNode[];
|
|
39
|
+
/** Every workspace node on its module's export surface. */
|
|
40
|
+
exported(): ITtscGraphNode[];
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TtscGraphMemory } from "./TtscGraphMemory";
|
|
2
|
+
/**
|
|
3
|
+
* Build the resident {@link TtscGraphMemory} for a project by running `ttscgraph
|
|
4
|
+
* dump` once and loading its JSON. This is the cold path behind the MCP tool
|
|
5
|
+
* calls: one type-check in Go produces the checker-resolved fact graph, then
|
|
6
|
+
* every later tool call is answered from the in-memory model.
|
|
7
|
+
*
|
|
8
|
+
* Throws when the binary cannot be resolved, the dump command fails, or its
|
|
9
|
+
* output is not a readable graph — the server surfaces the failure rather than
|
|
10
|
+
* answering from an empty graph.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadGraph(options?: {
|
|
13
|
+
/** Project root the graph is built for (default: `process.cwd()`). */
|
|
14
|
+
cwd?: string;
|
|
15
|
+
/** Project tsconfig, relative to `cwd` (default: `tsconfig.json`). */
|
|
16
|
+
tsconfig?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Absolute path to the `ttscgraph` binary. Defaults to the per-platform
|
|
19
|
+
* binary resolved from the project's installed `ttsc`; pass it explicitly
|
|
20
|
+
* to point at a custom build.
|
|
21
|
+
*/
|
|
22
|
+
binary?: string;
|
|
23
|
+
}): TtscGraphMemory;
|
package/lib/reduce.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface RawNode {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
kind: string;
|
|
5
|
+
file: string;
|
|
6
|
+
external?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface RawEdge {
|
|
9
|
+
from: string;
|
|
10
|
+
to: string;
|
|
11
|
+
kind: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RawDump {
|
|
14
|
+
project?: string;
|
|
15
|
+
nodes: RawNode[];
|
|
16
|
+
edges: RawEdge[];
|
|
17
|
+
}
|
|
18
|
+
export interface ViewerNode {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
kind: string;
|
|
22
|
+
file: string;
|
|
23
|
+
degree: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ViewerLink {
|
|
26
|
+
source: string;
|
|
27
|
+
target: string;
|
|
28
|
+
kind: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ViewerPayload {
|
|
31
|
+
project: string;
|
|
32
|
+
counts: {
|
|
33
|
+
rawNodes: number;
|
|
34
|
+
rawEdges: number;
|
|
35
|
+
nodes: number;
|
|
36
|
+
links: number;
|
|
37
|
+
droppedExternal: number;
|
|
38
|
+
droppedByCap: number;
|
|
39
|
+
};
|
|
40
|
+
nodes: ViewerNode[];
|
|
41
|
+
links: ViewerLink[];
|
|
42
|
+
}
|
|
43
|
+
export declare function reduce(raw: RawDump, { maxNodes, keepExternal }?: {
|
|
44
|
+
maxNodes?: number;
|
|
45
|
+
keepExternal?: boolean;
|
|
46
|
+
}): ViewerPayload;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the per-platform `ttscgraph` binary, or `null` when it cannot be
|
|
3
|
+
* located.
|
|
4
|
+
*
|
|
5
|
+
* `ttsc` is a peer the user installs alongside `@ttsc/graph` (not a dependency
|
|
6
|
+
* of this launcher), so resolution starts from the user's project, not from
|
|
7
|
+
* this package's own tree.
|
|
8
|
+
*
|
|
9
|
+
* Resolution order:
|
|
10
|
+
*
|
|
11
|
+
* 1. `TTSC_GRAPH_BINARY` env var, when set to an absolute path.
|
|
12
|
+
* 2. The per-platform npm package `@ttsc/<platform>-<arch>/bin/ttscgraph[.exe]`.
|
|
13
|
+
* That package carries `ttsc`, `ttscserver`, and `ttscgraph` together and is
|
|
14
|
+
* an `optionalDependency` of `ttsc`, so it is resolved from `ttsc`'s
|
|
15
|
+
* location — found from `process.cwd()` (the project where the agent ran the
|
|
16
|
+
* server).
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveGraphBinary(env?: NodeJS.ProcessEnv, cwd?: string): string | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
2
|
+
/**
|
|
3
|
+
* Derive stable access-path aliases for a member edge from its source
|
|
4
|
+
* expression. If a hop reaches `Owner.member` through `obj.path.member`, the
|
|
5
|
+
* alias `Owner.path.member` keeps both the resolved owner and the concrete
|
|
6
|
+
* access path visible without reopening source.
|
|
7
|
+
*/
|
|
8
|
+
export declare function accessAliasesFor(node: ITtscGraphNode | undefined, evidenceText: string | undefined): string[] | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { TtscGraphSource } from "../TtscGraphApplication";
|
|
3
|
+
/**
|
|
4
|
+
* Build the MCP server for a graph. `typia.llm.application` reflects
|
|
5
|
+
* {@link ITtscGraphApplication} into the tool schema and validator (no
|
|
6
|
+
* hand-written schema), and `createMcpServer` from `@typia/mcp` handles the
|
|
7
|
+
* list/call registration, argument validation, and structured output.
|
|
8
|
+
*
|
|
9
|
+
* We assemble the `ILlmController` (`{ protocol, name, application, execute }`)
|
|
10
|
+
* directly rather than via `typia.llm.controller` so the server is named
|
|
11
|
+
* "ttsc-graph" on our terms, not coupled to a reflected class name. Handshake
|
|
12
|
+
* instructions come from the class JSDoc; the single tool is named from its
|
|
13
|
+
* method, `inspect_typescript_graph`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createServer(graph: TtscGraphSource, version: string): McpServer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
2
|
+
/** True for dependency declarations outside the authored project graph. */
|
|
3
|
+
export declare function isExternalNode(node: ITtscGraphNode): boolean;
|
|
4
|
+
/** True for tests, examples, fixtures, generated output, and build artifacts. */
|
|
5
|
+
export declare function isSupportPath(file: string): boolean;
|
|
6
|
+
/** True for source files whose declarations are tests or test helpers. */
|
|
7
|
+
export declare function isTestPath(file: string): boolean;
|
|
8
|
+
/** True when exported symbols are unlikely to be authored public API. */
|
|
9
|
+
export declare function isPublicApiNoisePath(file: string): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
|
+
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
3
|
+
export interface IResolvedGraphHandle {
|
|
4
|
+
node?: ITtscGraphNode;
|
|
5
|
+
candidates?: ITtscGraphNode[];
|
|
6
|
+
}
|
|
7
|
+
/** Resolve a tool handle as an id, exact symbol name, or dotted suffix. */
|
|
8
|
+
export declare function resolveGraphHandle(graph: TtscGraphMemory, handle: string, candidateLimit?: number): IResolvedGraphHandle;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
|
+
import { ITtscGraphDecorator } from "../structures/ITtscGraphDecorator";
|
|
3
|
+
import { ITtscGraphDetails } from "../structures/ITtscGraphDetails";
|
|
4
|
+
import { ITtscGraphEdge } from "../structures/ITtscGraphEdge";
|
|
5
|
+
import { ITtscGraphEvidence } from "../structures/ITtscGraphEvidence";
|
|
6
|
+
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
7
|
+
/**
|
|
8
|
+
* Resolve each handle to its declared shape: sourceSpan anchors, signature,
|
|
9
|
+
* direct dependencies, and for containers, member outlines. It answers from the
|
|
10
|
+
* graph's resolved structure instead of inlining implementation bodies.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runDetails(graph: TtscGraphMemory, props: ITtscGraphDetails.IRequest): ITtscGraphDetails;
|
|
13
|
+
/** Decorator facts already captured on a node, omitted when absent. */
|
|
14
|
+
export declare function decoratorsOf(node: ITtscGraphNode): ITtscGraphDecorator[] | undefined;
|
|
15
|
+
/** Relationship evidence as public coordinates, omitted when absent. */
|
|
16
|
+
export declare function edgeEvidenceOf(edge: ITtscGraphEdge): ITtscGraphEvidence | undefined;
|
|
17
|
+
/** Source text is an internal alias hint, not part of the MCP evidence object. */
|
|
18
|
+
export declare function edgeEvidenceTextOf(edge: ITtscGraphEdge): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The declaration signature: the head of the declaration up to and including
|
|
21
|
+
* the line that opens its body (`{`), or the single declaration line when there
|
|
22
|
+
* is no brace, capped so a wrapped signature cannot run away.
|
|
23
|
+
*/
|
|
24
|
+
export declare function signatureOf(project: string, node: ITtscGraphNode): string | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
|
+
import { ITtscGraphEntrypoints } from "../structures/ITtscGraphEntrypoints";
|
|
3
|
+
/**
|
|
4
|
+
* Build the first source-free entrypoints list for a code question. The result
|
|
5
|
+
* gives the model stable handles, declaration signatures, and direct graph
|
|
6
|
+
* context. It is deliberately not a source reader; details adds selected symbol
|
|
7
|
+
* shape and ranges, not implementation text.
|
|
8
|
+
*/
|
|
9
|
+
export declare function runEntrypoints(graph: TtscGraphMemory, props: ITtscGraphEntrypoints.IRequest): ITtscGraphEntrypoints;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
|
+
import { ITtscGraphLookup } from "../structures/ITtscGraphLookup";
|
|
3
|
+
/**
|
|
4
|
+
* Rank the graph's symbols against a natural query. Scoring blends exact and
|
|
5
|
+
* dotted-name matches, CamelCase/subword coverage, file-path terms, a prefix
|
|
6
|
+
* bonus, and dependency centrality, then dampens external, generated, and test
|
|
7
|
+
* nodes and caps per file so the result is a diverse, relevant shortlist rather
|
|
8
|
+
* than one file's roster.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runLookup(graph: TtscGraphMemory, props: ITtscGraphLookup.IRequest): ITtscGraphLookup;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
|
+
import { ITtscGraphOverview } from "../structures/ITtscGraphOverview";
|
|
3
|
+
/**
|
|
4
|
+
* Project a compact, source-read-free architecture map: counts by kind, folder
|
|
5
|
+
* layering with export density, the highest-dependency symbols (ranked by real
|
|
6
|
+
* fan-in/out, excluding structural edges so nesting does not masquerade as
|
|
7
|
+
* dependency), and the export surface by file. Output is bounded so a model
|
|
8
|
+
* reads structure cheaply.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runOverview(graph: TtscGraphMemory, props: ITtscGraphOverview.IRequest): ITtscGraphOverview;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
|
+
import { ITtscGraphTour } from "../structures/ITtscGraphTour";
|
|
3
|
+
/**
|
|
4
|
+
* Compose a repository-orientation/code-tour answer surface from existing graph
|
|
5
|
+
* operations. It returns selected symbols, flows, nearby edges, test anchors,
|
|
6
|
+
* and answer anchors without reading or embedding source bodies.
|
|
7
|
+
*/
|
|
8
|
+
export declare function runTour(graph: TtscGraphMemory, props: ITtscGraphTour.IRequest): ITtscGraphTour;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
|
+
import { ITtscGraphTrace } from "../structures/ITtscGraphTrace";
|
|
3
|
+
/**
|
|
4
|
+
* Breadth-first trace along the dependency graph. Structural
|
|
5
|
+
* (contains/exports/imports) edges are excluded so the path is real call/type
|
|
6
|
+
* flow; forward walks callees, reverse and impact walk callers. Impact
|
|
7
|
+
* additionally tags each reached node's role so the blast radius on the public
|
|
8
|
+
* surface is legible.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runTrace(graph: TtscGraphMemory, props: ITtscGraphTrace.IRequest): ITtscGraphTrace;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serve the graph tools over MCP on stdio. The server answers the MCP handshake
|
|
3
|
+
* immediately and builds the resident graph on the first tool call, so a large
|
|
4
|
+
* project cannot make the client give up before tools are advertised.
|
|
5
|
+
*/
|
|
6
|
+
export declare function startServer(options: {
|
|
7
|
+
cwd?: string;
|
|
8
|
+
tsconfig?: string;
|
|
9
|
+
/** Server version reported in the MCP handshake. */
|
|
10
|
+
version: string;
|
|
11
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { ITtscGraphDetails } from "./ITtscGraphDetails";
|
|
2
|
+
import { ITtscGraphEntrypoints } from "./ITtscGraphEntrypoints";
|
|
3
|
+
import { ITtscGraphEscape } from "./ITtscGraphEscape";
|
|
4
|
+
import { ITtscGraphLookup } from "./ITtscGraphLookup";
|
|
5
|
+
import { ITtscGraphOverview } from "./ITtscGraphOverview";
|
|
6
|
+
import { ITtscGraphTour } from "./ITtscGraphTour";
|
|
7
|
+
import { ITtscGraphTrace } from "./ITtscGraphTrace";
|
|
8
|
+
/**
|
|
9
|
+
* ## What This MCP Is
|
|
10
|
+
*
|
|
11
|
+
* `inspect_typescript_graph` returns a compiler-built TypeScript graph contract
|
|
12
|
+
* for the current source snapshot.
|
|
13
|
+
*
|
|
14
|
+
* Use it for architecture, runtime flow, APIs, callers/callees, code tours, and
|
|
15
|
+
* type relations. It returns answer-ready index evidence: names, edges,
|
|
16
|
+
* signatures, decorators, tests, spans, and anchors.
|
|
17
|
+
*
|
|
18
|
+
* Until TS source is edited, returned graph facts are sacred, infallible
|
|
19
|
+
* compiler truth. Never verify them with files or more graph calls.
|
|
20
|
+
*
|
|
21
|
+
* ## Result Contract
|
|
22
|
+
*
|
|
23
|
+
* - The returned object is the graph evidence contract: names, signatures, spans,
|
|
24
|
+
* decorators, tests, edges, steps, anchors, and `next` are answer evidence,
|
|
25
|
+
* not hints.
|
|
26
|
+
* - When `next.action` is `answer`, stop tool use for the current question and
|
|
27
|
+
* answer from the returned result.
|
|
28
|
+
* - `truncated` means the answer surface hit an index cap. Mention the cap if it
|
|
29
|
+
* matters; do not expand every branch to compensate.
|
|
30
|
+
* - When `next.action` is `inspect`, make the focused graph request it names or
|
|
31
|
+
* choose `escape` if the result already answers.
|
|
32
|
+
* - Read files only for exact source body text, configs, docs, generated output,
|
|
33
|
+
* exact text search, non-TypeScript files, or facts the graph marks outside
|
|
34
|
+
* itself. A returned span is a citation anchor, not a reading command.
|
|
35
|
+
* - After editing TypeScript source, the old graph no longer governs changed
|
|
36
|
+
* code. Rebuild/reload the graph or verify changed code normally.
|
|
37
|
+
*
|
|
38
|
+
* ## Sacred Contract
|
|
39
|
+
*
|
|
40
|
+
* Before source edits, returned graph facts are inviolable and errorless. Never
|
|
41
|
+
* use extra graph calls, repository search, or file reads to doubt, fact-check,
|
|
42
|
+
* humanize, re-derive, re-narrate, or re-confirm returned nodes, spans, edges,
|
|
43
|
+
* signatures, decorators, tests, references, steps, or anchors.
|
|
44
|
+
*
|
|
45
|
+
* ## Tour Contract
|
|
46
|
+
*
|
|
47
|
+
* Use `tour` for repository orientation, read-next, architecture tours, and
|
|
48
|
+
* broad runtime flow, including questions that name several phases or
|
|
49
|
+
* subsystems. A tour is the complete index-level answer surface: central
|
|
50
|
+
* entrypoints, primary flow, nearby paths, tests, and anchors. Do not decompose
|
|
51
|
+
* a broad tour into lookup/details loops unless the user later asks for a named
|
|
52
|
+
* missing symbol or exact source text.
|
|
53
|
+
*
|
|
54
|
+
* ## Use Contract
|
|
55
|
+
*
|
|
56
|
+
* 1. Ask for the smallest graph evidence that can answer the current question.
|
|
57
|
+
* 2. Broad flow, repository-orientation, code-tour, or read-next question: start
|
|
58
|
+
* with `tour`.
|
|
59
|
+
* 3. Concrete named symbol: use `lookup`, then `details` only if needed.
|
|
60
|
+
* 4. Known endpoint pair or one selected handle: use one `trace`.
|
|
61
|
+
* 5. Unknown narrow orientation: use `entrypoints` once.
|
|
62
|
+
* 6. Selected symbol shape: use `details` for one to three handles.
|
|
63
|
+
* 7. Follow the returned `next`: answer, inspect once more, leave graph, or
|
|
64
|
+
* clarify.
|
|
65
|
+
* 8. Use `escape` when another graph call would repeat evidence or the remaining
|
|
66
|
+
* evidence is outside the TypeScript graph.
|
|
67
|
+
*
|
|
68
|
+
* Most TypeScript structure answers need one or two graph calls.
|
|
69
|
+
*
|
|
70
|
+
* ## Request Fields
|
|
71
|
+
*
|
|
72
|
+
* Fill the visible checklist, then exactly one request.
|
|
73
|
+
*
|
|
74
|
+
* - `question`: restate the code question being considered.
|
|
75
|
+
* - `draft`: initial request type and why it seems smallest.
|
|
76
|
+
* - `review`: correct a wrong, broad, stale, or duplicate draft. If graph facts
|
|
77
|
+
* already answer, if prior `next.action` was `answer`, or if the next
|
|
78
|
+
* evidence is outside the indexed TypeScript graph, say so here and make
|
|
79
|
+
* `request.type` be `escape`. If a broad flow draft is not `tour`, correct it
|
|
80
|
+
* 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
|
|
91
|
+
* file.
|
|
92
|
+
*/
|
|
93
|
+
export interface ITtscGraphApplication {
|
|
94
|
+
/**
|
|
95
|
+
* Inspect the TypeScript compiler graph contract.
|
|
96
|
+
*
|
|
97
|
+
* Use this before repository search when an answer depends on TypeScript
|
|
98
|
+
* symbols, calls, types, decorators, references, ranges, or runtime/source
|
|
99
|
+
* relationships. For repository orientation, read-next, architecture, and
|
|
100
|
+
* broad runtime flow questions, use `tour`.
|
|
101
|
+
*
|
|
102
|
+
* Returned nodes, edges, signatures, spans, tests, anchors, and `next` are
|
|
103
|
+
* the answer surface. If `next.action` is `answer`, stop tool use and answer
|
|
104
|
+
* from that result. Before source edits, graph facts are sacred, inviolable,
|
|
105
|
+
* complete, and infallible.
|
|
106
|
+
*
|
|
107
|
+
* @param props Reasoning plus one graph request
|
|
108
|
+
* @returns Matching `result` union member
|
|
109
|
+
*/
|
|
110
|
+
inspect_typescript_graph(props: ITtscGraphApplication.IProps): ITtscGraphApplication.IResult;
|
|
111
|
+
}
|
|
112
|
+
export declare namespace ITtscGraphApplication {
|
|
113
|
+
/** Draft, review, then submit exactly one graph request or escape. */
|
|
114
|
+
interface IProps {
|
|
115
|
+
/**
|
|
116
|
+
* User's TypeScript code question.
|
|
117
|
+
*
|
|
118
|
+
* Restate the code question being considered. If the next evidence is a
|
|
119
|
+
* script, config, doc, generated output, exact text, non-TypeScript file,
|
|
120
|
+
* or source body text, choose `escape`.
|
|
121
|
+
*/
|
|
122
|
+
question: string;
|
|
123
|
+
/**
|
|
124
|
+
* Initial request plan before final arguments are filled.
|
|
125
|
+
*
|
|
126
|
+
* Name the intended request type in `type` and why it seems smallest in
|
|
127
|
+
* `reason`. Broad flow, architecture, repository-orientation, and read-next
|
|
128
|
+
* questions should normally draft `tour`; narrow named symbols can draft
|
|
129
|
+
* `lookup`, `trace`, or `details`.
|
|
130
|
+
*/
|
|
131
|
+
draft: IDraft;
|
|
132
|
+
/**
|
|
133
|
+
* Final self-review before calling.
|
|
134
|
+
*
|
|
135
|
+
* Correct a stale, broad, duplicate, or wrong draft here. If broad flow was
|
|
136
|
+
* split into search/detail steps, switch to `tour`. If graph facts already
|
|
137
|
+
* answer, or prior `next.action` was `answer`, make `request.type` be
|
|
138
|
+
* `escape`; do not call graph or read files to re-confirm returned facts.
|
|
139
|
+
*/
|
|
140
|
+
review: string;
|
|
141
|
+
/** Final graph operation chosen after review, or a no-op escape. */
|
|
142
|
+
request: ITtscGraphEntrypoints.IRequest | ITtscGraphLookup.IRequest | ITtscGraphTrace.IRequest | ITtscGraphDetails.IRequest | ITtscGraphOverview.IRequest | ITtscGraphTour.IRequest | ITtscGraphEscape.IRequest;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* First-pass request plan, filled before the final `request` arguments.
|
|
146
|
+
*
|
|
147
|
+
* `reason` comes before `type` so the justification is written before the
|
|
148
|
+
* choice it justifies.
|
|
149
|
+
*/
|
|
150
|
+
interface IDraft {
|
|
151
|
+
/** Why this request type looks like the smallest useful next step. */
|
|
152
|
+
reason: string;
|
|
153
|
+
/** The request type being considered, corrected later in `review`. */
|
|
154
|
+
type: IProps["request"]["type"];
|
|
155
|
+
}
|
|
156
|
+
/** The selected request's output. `result.type` mirrors `request.type`. */
|
|
157
|
+
interface IResult {
|
|
158
|
+
/** Result branch matching the submitted `request.type`. */
|
|
159
|
+
result: ITtscGraphEntrypoints | ITtscGraphLookup | ITtscGraphTrace | ITtscGraphDetails | ITtscGraphOverview | ITtscGraphTour | ITtscGraphEscape;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A decorator as written on a declaration, carried on the decorated
|
|
3
|
+
* {@link ITtscGraphNode}'s `decorators`.
|
|
4
|
+
*
|
|
5
|
+
* The graph reports the decorator faithfully rather than interpreting any
|
|
6
|
+
* framework's convention: the `name` is the decorator as written (`Controller`,
|
|
7
|
+
* `Get`, `TypedRoute.Get`, ...), and statically resolvable literal arguments
|
|
8
|
+
* are preserved so a consumer can apply its own meaning without re-parsing
|
|
9
|
+
* source.
|
|
10
|
+
*/
|
|
11
|
+
export interface ITtscGraphDecorator {
|
|
12
|
+
/**
|
|
13
|
+
* The decorator name as written, qualified through its access path:
|
|
14
|
+
* `Controller`, `Get`, `TypedRoute.Get`, `MessagePattern`.
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
/** The literal call arguments, in source order. Empty for a bare decorator. */
|
|
18
|
+
arguments: ITtscGraphDecorator.IArgument[];
|
|
19
|
+
}
|
|
20
|
+
export declare namespace ITtscGraphDecorator {
|
|
21
|
+
/**
|
|
22
|
+
* One argument of an {@link ITtscGraphDecorator}. `literal` is set only when
|
|
23
|
+
* the argument is a string, number, or boolean literal the producer could
|
|
24
|
+
* resolve statically, so a consumer can use it without evaluating code.
|
|
25
|
+
*/
|
|
26
|
+
interface IArgument {
|
|
27
|
+
/** The statically-resolved literal value, when the argument is a literal. */
|
|
28
|
+
literal?: string | number | boolean;
|
|
29
|
+
}
|
|
30
|
+
}
|