@ttsc/graph 0.18.4 → 0.19.1
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 +231 -37
- package/lib/TtscGraphApplication.d.ts +1 -1
- package/lib/TtscGraphApplication.js +50 -17
- package/lib/TtscGraphApplication.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.js +20 -1
- package/lib/index.js.map +1 -1
- package/lib/model/TtscGraphMemory.js +80 -22
- package/lib/model/TtscGraphMemory.js.map +1 -1
- package/lib/model/TtscGraphSession.js +92 -138
- package/lib/model/TtscGraphSession.js.map +1 -1
- package/lib/model/loadGraph.js +91 -138
- package/lib/model/loadGraph.js.map +1 -1
- package/lib/resolveGraphBinary.d.ts +4 -2
- package/lib/resolveGraphBinary.js +7 -3
- package/lib/resolveGraphBinary.js.map +1 -1
- package/lib/server/createServer.d.ts +16 -9
- package/lib/server/createServer.js +286 -190
- package/lib/server/createServer.js.map +1 -1
- package/lib/server/exportSurface.d.ts +26 -0
- package/lib/server/exportSurface.js +44 -0
- package/lib/server/exportSurface.js.map +1 -0
- package/lib/server/resolveHandle.d.ts +26 -1
- package/lib/server/resolveHandle.js +124 -4
- package/lib/server/resolveHandle.js.map +1 -1
- package/lib/server/resultAudit.d.ts +74 -0
- package/lib/server/resultAudit.js +110 -0
- package/lib/server/resultAudit.js.map +1 -0
- package/lib/server/resultNext.d.ts +9 -0
- package/lib/server/resultNext.js +11 -0
- package/lib/server/resultNext.js.map +1 -0
- package/lib/server/runDetails.d.ts +15 -3
- package/lib/server/runDetails.js +105 -23
- package/lib/server/runDetails.js.map +1 -1
- package/lib/server/runEntrypoints.d.ts +2 -1
- package/lib/server/runEntrypoints.js +17 -10
- package/lib/server/runEntrypoints.js.map +1 -1
- package/lib/server/runLookup.d.ts +2 -1
- package/lib/server/runLookup.js +21 -9
- package/lib/server/runLookup.js.map +1 -1
- package/lib/server/runOverview.d.ts +2 -1
- package/lib/server/runOverview.js +5 -4
- package/lib/server/runOverview.js.map +1 -1
- package/lib/server/runTour.d.ts +2 -1
- package/lib/server/runTour.js +707 -331
- package/lib/server/runTour.js.map +1 -1
- package/lib/server/runTrace.d.ts +2 -1
- package/lib/server/runTrace.js +234 -54
- package/lib/server/runTrace.js.map +1 -1
- package/lib/structures/ITtscGraphApplication.d.ts +122 -118
- package/lib/structures/ITtscGraphDecorator.d.ts +4 -7
- package/lib/structures/ITtscGraphDetails.d.ts +51 -43
- package/lib/structures/ITtscGraphDump.d.ts +32 -8
- package/lib/structures/ITtscGraphEdge.d.ts +4 -6
- package/lib/structures/ITtscGraphEntrypoints.d.ts +10 -27
- package/lib/structures/ITtscGraphEscape.d.ts +6 -16
- package/lib/structures/ITtscGraphEvidence.d.ts +5 -8
- package/lib/structures/ITtscGraphLookup.d.ts +9 -20
- package/lib/structures/ITtscGraphNext.d.ts +10 -7
- package/lib/structures/ITtscGraphNode.d.ts +17 -8
- package/lib/structures/ITtscGraphOverview.d.ts +10 -14
- package/lib/structures/ITtscGraphSpan.d.ts +29 -0
- package/lib/structures/{ITtscGraphDiagnostic.js → ITtscGraphSpan.js} +1 -1
- package/lib/structures/ITtscGraphSpan.js.map +1 -0
- package/lib/structures/ITtscGraphTour.d.ts +65 -23
- package/lib/structures/ITtscGraphTrace.d.ts +72 -49
- package/lib/structures/TtscGraphEdgeKind.d.ts +7 -1
- package/lib/structures/index.d.ts +1 -1
- package/lib/structures/index.js +1 -1
- package/lib/structures/index.js.map +1 -1
- package/lib/view.js +3 -1
- package/lib/view.js.map +1 -1
- package/package.json +4 -4
- package/src/TtscGraphApplication.ts +58 -27
- package/src/index.ts +19 -1
- package/src/model/TtscGraphMemory.ts +86 -22
- package/src/model/TtscGraphSession.ts +5 -1
- package/src/model/loadGraph.ts +3 -1
- package/src/resolveGraphBinary.ts +7 -3
- package/src/server/createServer.ts +24 -17
- package/src/server/exportSurface.ts +40 -0
- package/src/server/resolveHandle.ts +141 -4
- package/src/server/resultAudit.ts +109 -0
- package/src/server/resultNext.ts +22 -0
- package/src/server/runDetails.ts +112 -28
- package/src/server/runEntrypoints.ts +26 -17
- package/src/server/runLookup.ts +29 -18
- package/src/server/runOverview.ts +9 -10
- package/src/server/runTour.ts +764 -363
- package/src/server/runTrace.ts +265 -71
- package/src/structures/ITtscGraphApplication.ts +124 -118
- package/src/structures/ITtscGraphDecorator.ts +4 -7
- package/src/structures/ITtscGraphDetails.ts +60 -46
- package/src/structures/ITtscGraphDump.ts +37 -8
- package/src/structures/ITtscGraphEdge.ts +4 -6
- package/src/structures/ITtscGraphEntrypoints.ts +10 -30
- package/src/structures/ITtscGraphEscape.ts +6 -19
- package/src/structures/ITtscGraphEvidence.ts +5 -8
- package/src/structures/ITtscGraphLookup.ts +9 -22
- package/src/structures/ITtscGraphNext.ts +10 -7
- package/src/structures/ITtscGraphNode.ts +18 -8
- package/src/structures/ITtscGraphOverview.ts +10 -17
- package/src/structures/ITtscGraphSpan.ts +33 -0
- package/src/structures/ITtscGraphTour.ts +70 -28
- package/src/structures/ITtscGraphTrace.ts +82 -51
- package/src/structures/TtscGraphEdgeKind.ts +7 -0
- package/src/structures/index.ts +1 -1
- package/src/view.ts +3 -1
- package/lib/server/accessAliases.d.ts +0 -8
- package/lib/server/accessAliases.js +0 -53
- package/lib/server/accessAliases.js.map +0 -1
- package/lib/server/resultGuide.d.ts +0 -3
- package/lib/server/resultGuide.js +0 -16
- package/lib/server/resultGuide.js.map +0 -1
- package/lib/structures/ITtscGraphDiagnostic.d.ts +0 -27
- package/lib/structures/ITtscGraphDiagnostic.js.map +0 -1
- package/src/server/accessAliases.ts +0 -55
- package/src/server/resultGuide.ts +0 -20
- package/src/structures/ITtscGraphDiagnostic.ts +0 -34
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ITtscGraphNext } from "./ITtscGraphNext";
|
|
2
1
|
/** The no-op result for when graph is not the useful next evidence source. */
|
|
3
2
|
export interface ITtscGraphEscape {
|
|
4
3
|
/** Discriminator for the no-op escape route. */
|
|
@@ -7,10 +6,6 @@ export interface ITtscGraphEscape {
|
|
|
7
6
|
skipped: true;
|
|
8
7
|
/** Why no graph operation should run. */
|
|
9
8
|
reason: string;
|
|
10
|
-
/** How to proceed after skipping graph work. */
|
|
11
|
-
next: ITtscGraphNext;
|
|
12
|
-
/** Human-readable compatibility note mirroring `next`. */
|
|
13
|
-
guide: string;
|
|
14
9
|
/** Optional note about the next non-graph step. */
|
|
15
10
|
nextStep?: string;
|
|
16
11
|
}
|
|
@@ -20,20 +15,15 @@ export declare namespace ITtscGraphEscape {
|
|
|
20
15
|
/** Discriminator for the no-op escape route. */
|
|
21
16
|
type: "escape";
|
|
22
17
|
/**
|
|
23
|
-
* Why no graph operation should run.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* text, or exact source body text. Name the smallest returned sourceSpan
|
|
28
|
-
* when source body text is truly required.
|
|
18
|
+
* Why no graph operation should run. Use only when the next evidence is
|
|
19
|
+
* outside the indexed graph: package scripts, config files, generated
|
|
20
|
+
* output, prose docs, exact text, or source body text. Name the smallest
|
|
21
|
+
* returned sourceSpan when source body text is truly required.
|
|
29
22
|
*/
|
|
30
23
|
reason: string;
|
|
31
24
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* Keep this short. Examples: `answer from the prior graph result`, `source
|
|
35
|
-
* body needed at returned sourceSpan`, or `ask the user for a concrete
|
|
36
|
-
* symbol`.
|
|
25
|
+
* A short final non-graph note, if useful, for example `answer from the
|
|
26
|
+
* prior graph result` or `source body needed at returned sourceSpan`.
|
|
37
27
|
*/
|
|
38
28
|
nextStep?: string;
|
|
39
29
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A source location
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* does not re-key anything. `startLine`/`startCol` are 1-based. MCP output
|
|
8
|
-
* keeps evidence as coordinates; consumers can read the file themselves when
|
|
9
|
-
* they truly need source text.
|
|
2
|
+
* A source location grounding a node or edge in real code: the declaration span
|
|
3
|
+
* for a node, or the expression range that produced an edge. Display and
|
|
4
|
+
* grounding only, never identity (a node's id is position-invariant, see
|
|
5
|
+
* {@link ITtscGraphNode}). Lines and columns are 1-based; MCP keeps evidence as
|
|
6
|
+
* coordinates, so read the file yourself when you truly need source text.
|
|
10
7
|
*/
|
|
11
8
|
export interface ITtscGraphEvidence {
|
|
12
9
|
/** Project-relative path of the file the span lives in. */
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
|
|
2
|
-
import { ITtscGraphNext } from "./ITtscGraphNext";
|
|
3
2
|
/** Targeted symbol lookup when a concrete name or handle is being resolved. */
|
|
4
3
|
export interface ITtscGraphLookup {
|
|
5
4
|
/** Discriminator for targeted symbol lookup. */
|
|
6
5
|
type: "lookup";
|
|
7
6
|
/** Ranked symbol matches for the query. */
|
|
8
7
|
hits: ITtscGraphLookup.IHit[];
|
|
9
|
-
/** How to use this source-free result next. */
|
|
10
|
-
next: ITtscGraphNext;
|
|
11
|
-
/** Human-readable compatibility note mirroring `next`. */
|
|
12
|
-
guide: string;
|
|
13
8
|
}
|
|
14
9
|
export declare namespace ITtscGraphLookup {
|
|
15
10
|
/** Find a concrete class, method, function, property, type, or dotted handle. */
|
|
@@ -17,26 +12,23 @@ export declare namespace ITtscGraphLookup {
|
|
|
17
12
|
/** Discriminator for targeted symbol lookup. */
|
|
18
13
|
type: "lookup";
|
|
19
14
|
/**
|
|
20
|
-
* What to find
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* ambiguous.
|
|
15
|
+
* What to find: a symbol name, a dotted member (`Service.create`), or a
|
|
16
|
+
* short phrase (`request handler`). Exact names are not required, but this
|
|
17
|
+
* is not a second broad entrypoints call; use it for a missing or ambiguous
|
|
18
|
+
* named handle.
|
|
25
19
|
*/
|
|
26
20
|
query: string;
|
|
27
21
|
/**
|
|
28
|
-
* Maximum hits to return.
|
|
29
|
-
*
|
|
30
|
-
* Prefer the default. Large hit lists usually mean the query is too broad;
|
|
31
|
-
* refine the name instead of raising this.
|
|
22
|
+
* Maximum hits to return. A large hit list usually means the query is too
|
|
23
|
+
* broad; refine the name instead of raising this.
|
|
32
24
|
*
|
|
33
25
|
* @default 5
|
|
34
26
|
*/
|
|
35
27
|
limit?: number;
|
|
36
28
|
/**
|
|
37
29
|
* Include dependency-boundary declarations from node_modules or bundled
|
|
38
|
-
* `.d.ts` libraries.
|
|
39
|
-
*
|
|
30
|
+
* `.d.ts` libraries. Enable only when external type/API boundaries are the
|
|
31
|
+
* question.
|
|
40
32
|
*
|
|
41
33
|
* @default false
|
|
42
34
|
*/
|
|
@@ -54,10 +46,7 @@ export declare namespace ITtscGraphLookup {
|
|
|
54
46
|
file: string;
|
|
55
47
|
/** 1-based declaration line, when known. */
|
|
56
48
|
line?: number;
|
|
57
|
-
/**
|
|
58
|
-
* The hit's declaration signature, so you can often answer without
|
|
59
|
-
* requesting details.
|
|
60
|
-
*/
|
|
49
|
+
/** Declaration signature, often enough to answer without a `details` call. */
|
|
61
50
|
signature?: string;
|
|
62
51
|
/** Decorators written on this declaration, when any. */
|
|
63
52
|
decorators?: ITtscGraphDecorator[];
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** What to do with a compiler-derived graph result. */
|
|
2
2
|
export interface ITtscGraphNext {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* What to do with this result:
|
|
5
5
|
*
|
|
6
|
-
* `answer
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* - `answer`: the result carries the evidence; stop and answer, do not call
|
|
7
|
+
* graph again or read files to re-check it
|
|
8
|
+
* - `inspect`: the result is genuinely partial; make exactly the one `request`
|
|
9
|
+
* named, once
|
|
10
|
+
* - `outside`: the answer is outside the graph; escape and read source
|
|
11
|
+
* - `clarify`: the request was malformed or ambiguous; restate it
|
|
9
12
|
*/
|
|
10
13
|
action: "answer" | "inspect" | "outside" | "clarify";
|
|
11
|
-
/**
|
|
14
|
+
/** The single graph request type to use when `action` is `inspect`. */
|
|
12
15
|
request?: "entrypoints" | "lookup" | "trace" | "details" | "overview" | "tour";
|
|
13
|
-
/** Why the returned
|
|
16
|
+
/** Why the returned evidence supports that action. */
|
|
14
17
|
reason: string;
|
|
15
18
|
}
|
|
@@ -27,25 +27,34 @@ export interface ITtscGraphNode {
|
|
|
27
27
|
/** Project-relative path of the file that declares this node. */
|
|
28
28
|
file: string;
|
|
29
29
|
/**
|
|
30
|
-
* True when the declaration
|
|
31
|
-
*
|
|
32
|
-
* internals.
|
|
30
|
+
* True when the declaration is outside the workspace (a dependency): kept as
|
|
31
|
+
* a named endpoint, not walked into.
|
|
33
32
|
*/
|
|
34
33
|
external: boolean;
|
|
35
34
|
/**
|
|
36
|
-
* True when `file` is git-ignored generated code (
|
|
37
|
-
* output)
|
|
35
|
+
* True when `file` is git-ignored generated code (Prisma client, codegen
|
|
36
|
+
* output); projections desurface these so generated nodes do not bury the
|
|
38
37
|
* authored graph.
|
|
39
38
|
*/
|
|
40
39
|
ignored?: boolean;
|
|
41
40
|
/** True when the symbol is part of its module's export surface. */
|
|
42
41
|
exported?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* True for a declaration made inside another declaration's body: Vue's
|
|
44
|
+
* `baseCreateRenderer.patch`, a callback bound to a const inside a method.
|
|
45
|
+
*
|
|
46
|
+
* It is a name the runtime calls, so a trace, a lookup, or a details request
|
|
47
|
+
* answers with it. An orientation tour does not rank or walk it: a tour is
|
|
48
|
+
* asked what the project's surface is and how it runs, and a body's inner
|
|
49
|
+
* functions are neither — letting them into the seed ranking reshuffled which
|
|
50
|
+
* flows a tour told, and the model went back to the files.
|
|
51
|
+
*/
|
|
52
|
+
closure?: boolean;
|
|
43
53
|
/** Declaration modifiers, when the declaration pass recorded any. */
|
|
44
54
|
modifiers?: TtscGraphNodeModifier[];
|
|
45
55
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* without re-parsing source.
|
|
56
|
+
* Decorators written on this declaration, in source order: raw facts
|
|
57
|
+
* (`@Controller`, `@Get`) a consumer interprets without re-parsing source.
|
|
49
58
|
*/
|
|
50
59
|
decorators?: ITtscGraphDecorator[];
|
|
51
60
|
/** The declaration span, for display and signatures. */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ITtscGraphNext } from "./ITtscGraphNext";
|
|
2
1
|
/** A compact, source-read-free project map for broad orientation only. */
|
|
3
2
|
export interface ITtscGraphOverview {
|
|
4
3
|
/** Discriminator for source-free project overview. */
|
|
@@ -7,10 +6,6 @@ export interface ITtscGraphOverview {
|
|
|
7
6
|
project: string;
|
|
8
7
|
/** Size of the graph. */
|
|
9
8
|
counts: ITtscGraphOverview.ICounts;
|
|
10
|
-
/** How to use this source-free result next. */
|
|
11
|
-
next: ITtscGraphNext;
|
|
12
|
-
/** Human-readable compatibility note mirroring `next`. */
|
|
13
|
-
guide: string;
|
|
14
9
|
/** Folder layering, largest first. */
|
|
15
10
|
layers?: ITtscGraphOverview.ILayer[];
|
|
16
11
|
/** Highest-dependency symbols, busiest first. */
|
|
@@ -24,13 +19,15 @@ export declare namespace ITtscGraphOverview {
|
|
|
24
19
|
/** Discriminator for source-free project overview. */
|
|
25
20
|
type: "overview";
|
|
26
21
|
/**
|
|
27
|
-
*
|
|
28
|
-
* layering, `hotspots` the highest-dependency symbols, `publicApi` the
|
|
29
|
-
* exported API symbols ranked by how depended-on they are.
|
|
22
|
+
* Facet to project, or `all` for every facet:
|
|
30
23
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
24
|
+
* - `layers`: folder layering
|
|
25
|
+
* - `hotspots`: highest-dependency symbols
|
|
26
|
+
* - `publicApi`: exported API symbols ranked by how depended-on they are
|
|
27
|
+
*
|
|
28
|
+
* Broad public-API or layer orientation only. For behavior, lifecycle,
|
|
29
|
+
* request/render/validation flow, caller, or dependency questions, use
|
|
30
|
+
* `entrypoints` then `trace`.
|
|
34
31
|
*
|
|
35
32
|
* @default "all"
|
|
36
33
|
*/
|
|
@@ -77,9 +74,8 @@ export declare namespace ITtscGraphOverview {
|
|
|
77
74
|
fanOut: number;
|
|
78
75
|
}
|
|
79
76
|
/**
|
|
80
|
-
* One
|
|
81
|
-
*
|
|
82
|
-
* excluded.
|
|
77
|
+
* One exported public-API symbol. The list is ranked by how depended-on the
|
|
78
|
+
* symbol is, excluding test, typings, and generated files.
|
|
83
79
|
*/
|
|
84
80
|
type IPublicApi = INode;
|
|
85
81
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A span on the wire, without the file it lives in.
|
|
3
|
+
*
|
|
4
|
+
* The reader already knows the file: a node's span is in the node's `file`, and
|
|
5
|
+
* an edge's span is in the file its `from` id names. Sending the path a second
|
|
6
|
+
* and a third time cost 17% of the document — on VS Code, 55 MB of a 323 MB
|
|
7
|
+
* dump that then has to be encoded, piped, parsed and validated — for a value
|
|
8
|
+
* that is reconstructible exactly.
|
|
9
|
+
*
|
|
10
|
+
* {@link TtscGraphMemory} puts the file back before any of it is read, so what
|
|
11
|
+
* the graph engine and the MCP results see is the whole
|
|
12
|
+
* {@link ITtscGraphEvidence}. This shape exists only between the Go builder and
|
|
13
|
+
* the loader.
|
|
14
|
+
*/
|
|
15
|
+
export interface ITtscGraphSpan {
|
|
16
|
+
/**
|
|
17
|
+
* Present only when it cannot be derived: an `implementation` can live in a
|
|
18
|
+
* different file from the declaration that owns it.
|
|
19
|
+
*/
|
|
20
|
+
file?: string;
|
|
21
|
+
/** 1-based line where the span starts. */
|
|
22
|
+
startLine: number;
|
|
23
|
+
/** 1-based column where the span starts, when known. */
|
|
24
|
+
startCol?: number;
|
|
25
|
+
/** 1-based line where the span ends, when known. */
|
|
26
|
+
endLine?: number;
|
|
27
|
+
/** 1-based column where the span ends, when known. */
|
|
28
|
+
endCol?: number;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITtscGraphSpan.js","sourceRoot":"","sources":["../../src/structures/ITtscGraphSpan.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
|
|
2
|
-
import { ITtscGraphNext } from "./ITtscGraphNext";
|
|
3
2
|
/** Answer-ready, source-free tour evidence for broad code-flow questions. */
|
|
4
3
|
export interface ITtscGraphTour {
|
|
5
4
|
/** Discriminator for code-tour indexing. */
|
|
6
5
|
type: "tour";
|
|
7
|
-
/** Natural code question this tour was built for. */
|
|
8
|
-
query: string;
|
|
9
6
|
/** Central entrypoints selected for the tour. */
|
|
10
7
|
entrypoints: ITtscGraphTour.INode[];
|
|
11
8
|
/** Selected primary runtime flows; sufficient for an index-level tour. */
|
|
@@ -16,31 +13,48 @@ export interface ITtscGraphTour {
|
|
|
16
13
|
tests: ITtscGraphTour.IAnchor[];
|
|
17
14
|
/** Ordered file/line anchors to cite in the final answer, not file reads. */
|
|
18
15
|
answerAnchors: ITtscGraphTour.IAnchor[];
|
|
19
|
-
/**
|
|
20
|
-
next: ITtscGraphNext;
|
|
21
|
-
/** Human-readable compatibility note mirroring `next`. */
|
|
22
|
-
guide: string;
|
|
23
|
-
/** True when any internal slice hit its cap. */
|
|
16
|
+
/** True when some low-signal extras were capped; the returned tour stands. */
|
|
24
17
|
truncated?: boolean;
|
|
25
18
|
}
|
|
26
19
|
export declare namespace ITtscGraphTour {
|
|
27
20
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* lookup/details/trace calls.
|
|
21
|
+
* A broad code tour: entrypoints, primary flow, nearby paths, and tests.
|
|
22
|
+
*
|
|
23
|
+
* It asks for no question of its own — it ranks against the `question` the
|
|
24
|
+
* caller has already written, in the user's words.
|
|
33
25
|
*/
|
|
34
26
|
interface IRequest {
|
|
35
27
|
/** Discriminator for code-tour indexing. */
|
|
36
28
|
type: "tour";
|
|
37
|
-
/** The user's natural code-tour question. */
|
|
38
|
-
query: string;
|
|
39
29
|
/**
|
|
40
|
-
*
|
|
30
|
+
* Symbol names, never a sentence: the machinery you expect the answer to be
|
|
31
|
+
* made of, spelled the way this codebase would spell it. A question about
|
|
32
|
+
* how a job reaches a worker is reinterpreted as `["JobQueue.push",
|
|
33
|
+
* "Scheduler.tick", "Worker.run", "drainQueue"]`.
|
|
41
34
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
35
|
+
* Write them from the question, before you have seen a line of the code. A
|
|
36
|
+
* codebase names many things alike, and the question's own words cannot
|
|
37
|
+
* tell them apart: a question about _tracking_ matches the debug hook named
|
|
38
|
+
* after tracking as readily as the function that does it, and one about a
|
|
39
|
+
* _request_ matches a message listener as readily as an HTTP router. The
|
|
40
|
+
* names say which you meant.
|
|
41
|
+
*
|
|
42
|
+
* Each is resolved like a handle — a symbol name, a `Class.member`. The
|
|
43
|
+
* ones the graph holds take half the tour's entrypoints, the rest stays
|
|
44
|
+
* with what the graph finds central, and a name it does not know, or knows
|
|
45
|
+
* several of, is dropped. So a wrong guess costs nothing, and a specific
|
|
46
|
+
* name is worth more than a general one: `drainQueue` resolves, `queue`
|
|
47
|
+
* does not.
|
|
48
|
+
*
|
|
49
|
+
* Send `[]` when the question names no machinery — "show me the central
|
|
50
|
+
* flow" in a repository you have never seen. There is nothing to
|
|
51
|
+
* reinterpret then: the tour ranks on structure, which is what that
|
|
52
|
+
* question asks for. Do not look names up first to fill this.
|
|
53
|
+
*/
|
|
54
|
+
reinterpretations: string[];
|
|
55
|
+
/**
|
|
56
|
+
* Central entrypoints to seed the tour. Raise only when the question names
|
|
57
|
+
* several public paths that must all appear in one answer.
|
|
44
58
|
*
|
|
45
59
|
* @default 4
|
|
46
60
|
*/
|
|
@@ -68,6 +82,12 @@ export declare namespace ITtscGraphTour {
|
|
|
68
82
|
sourceSpan?: ITtscGraphTour.ISpan;
|
|
69
83
|
/** Declaration head, when available. */
|
|
70
84
|
signature?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The first sentence of the doc comment above the declaration: what the
|
|
87
|
+
* project says this symbol is for. A name and an edge say what calls what;
|
|
88
|
+
* this says why, which is what a tour is asked for.
|
|
89
|
+
*/
|
|
90
|
+
doc?: string;
|
|
71
91
|
/** Decorators written on the declaration, when any. */
|
|
72
92
|
decorators?: ITtscGraphDecorator[];
|
|
73
93
|
}
|
|
@@ -77,13 +97,35 @@ export declare namespace ITtscGraphTour {
|
|
|
77
97
|
start: ITtscGraphTour.INode;
|
|
78
98
|
/** Compact edge summaries in graph order. */
|
|
79
99
|
steps: string[];
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Every node this flow reached, with the handle to call the graph with
|
|
102
|
+
* next.
|
|
103
|
+
*
|
|
104
|
+
* A step is prose — it names both of its ends and the file and line the
|
|
105
|
+
* call sits on — and it carries no handle. So the nodes a step names are
|
|
106
|
+
* listed here too: `steps` is the story, `reached` is what to go on with.
|
|
107
|
+
*/
|
|
108
|
+
reached: ITtscGraphTour.IReached[];
|
|
109
|
+
/** True when some low-signal flow steps were capped; the flow stands. */
|
|
85
110
|
truncated?: boolean;
|
|
86
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* A node a flow reached, as its handle and its declaration line.
|
|
114
|
+
*
|
|
115
|
+
* A node id _is_ its coordinates — `path/to/file.ts#Owner.member:kind` — so a
|
|
116
|
+
* reached node carrying `file` and `kind` beside it bought the same fact
|
|
117
|
+
* three times. Across the benchmark corpus that repetition was 15% of every
|
|
118
|
+
* tour, and a tour is re-sent whole on every turn of the conversation it
|
|
119
|
+
* opened.
|
|
120
|
+
*/
|
|
121
|
+
interface IReached {
|
|
122
|
+
/** Stable node id for later graph calls: `file#Qualified.Name:kind`. */
|
|
123
|
+
id: string;
|
|
124
|
+
/** Qualified symbol name when available, otherwise the simple name. */
|
|
125
|
+
name: string;
|
|
126
|
+
/** 1-based declaration line, when known. */
|
|
127
|
+
line?: number;
|
|
128
|
+
}
|
|
87
129
|
/** A file/line citation chosen by the graph, not source body text. */
|
|
88
130
|
interface IAnchor {
|
|
89
131
|
/** Why this anchor matters in the tour. */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
|
|
2
|
-
import { ITtscGraphNext } from "./ITtscGraphNext";
|
|
3
2
|
/** The compact dependency or caller flow returned from a selected start symbol. */
|
|
4
3
|
export interface ITtscGraphTrace {
|
|
5
4
|
/** Discriminator for dependency tracing. */
|
|
@@ -12,86 +11,119 @@ export interface ITtscGraphTrace {
|
|
|
12
11
|
hops: ITtscGraphTrace.IHop[];
|
|
13
12
|
/** Unique nodes reached (excluding the start), each with its depth and roles. */
|
|
14
13
|
reached: ITtscGraphTrace.INode[];
|
|
15
|
-
/** True when the trace hit
|
|
14
|
+
/** True when the trace hit its node or depth cap; the returned flow stands. */
|
|
16
15
|
truncated: boolean;
|
|
17
16
|
/** The resolved `to` target, when a path was requested. */
|
|
18
17
|
target?: ITtscGraphTrace.INode;
|
|
19
18
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* `from`.
|
|
19
|
+
* Ordered dependency path from `from` to `to` when `to` was given (`from`
|
|
20
|
+
* first, `to` last), empty when `to` is unreachable.
|
|
23
21
|
*/
|
|
24
22
|
path?: ITtscGraphTrace.INode[];
|
|
25
23
|
/** Compact hop summaries preserving node names and edge evidence, capped. */
|
|
26
24
|
steps?: string[];
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Symbols both ends touch, when no call path runs between them.
|
|
27
|
+
*
|
|
28
|
+
* Nothing calls across the gap because in an event-driven codebase nothing
|
|
29
|
+
* does: a handler registers a listener on an emitter, the emitter's `emit()`
|
|
30
|
+
* runs whatever a registration put in an array, and no call edge crosses that
|
|
31
|
+
* array. But both ends touch the emitter, and that is an edge, not a guess —
|
|
32
|
+
* Excalidraw's pointer handler and its store's emit both reference
|
|
33
|
+
* `Store.onDurableIncrementEmitter`, which is exactly the seam the call graph
|
|
34
|
+
* cannot walk.
|
|
35
|
+
*
|
|
36
|
+
* A junction is not a path. It is the symbol to look at next, and the edges
|
|
37
|
+
* that say why.
|
|
38
|
+
*/
|
|
39
|
+
junctions?: ITtscGraphTrace.IJunction[];
|
|
31
40
|
/** When `from` was an ambiguous name, the matches to disambiguate with. */
|
|
32
41
|
candidates?: ITtscGraphTrace.INode[];
|
|
33
42
|
}
|
|
34
43
|
export declare namespace ITtscGraphTrace {
|
|
44
|
+
/** A symbol both ends of an unreachable path touch, and how each touches it. */
|
|
45
|
+
interface IJunction {
|
|
46
|
+
/** Stable node id: trace or inspect this symbol to cross the seam. */
|
|
47
|
+
id: string;
|
|
48
|
+
/** Qualified symbol name when available, otherwise the simple name. */
|
|
49
|
+
name: string;
|
|
50
|
+
/** Declaration kind (`variable`, `method`, `class`, ...). */
|
|
51
|
+
kind: string;
|
|
52
|
+
/** Project-relative path of the file that declares it. */
|
|
53
|
+
file: string;
|
|
54
|
+
/** 1-based declaration line, when known. */
|
|
55
|
+
line?: number;
|
|
56
|
+
/** How the start reaches it: the edge kind, and where that edge sits. */
|
|
57
|
+
fromStart: IJunctionEdge;
|
|
58
|
+
/** How the target reaches it, or is reached from it. */
|
|
59
|
+
fromTarget: IJunctionEdge;
|
|
60
|
+
}
|
|
61
|
+
/** One edge between an end of the requested path and the junction. */
|
|
62
|
+
interface IJunctionEdge {
|
|
63
|
+
/** `calls`, `accesses`, `instantiates`, `type_ref`, ... */
|
|
64
|
+
kind: string;
|
|
65
|
+
/** True when the end is the edge's source, false when it is the target. */
|
|
66
|
+
outgoing: boolean;
|
|
67
|
+
/** Where the reference sits in source. */
|
|
68
|
+
evidence?: ITtscGraphEvidence;
|
|
69
|
+
}
|
|
35
70
|
/** Where and how far to trace dependency flow. */
|
|
36
71
|
interface IRequest {
|
|
37
72
|
/** Discriminator for dependency tracing. */
|
|
38
73
|
type: "trace";
|
|
39
74
|
/**
|
|
40
|
-
* Where to start: a node id
|
|
41
|
-
*
|
|
42
|
-
*
|
|
75
|
+
* Where to start: a node id, a simple symbol name, or a dotted member
|
|
76
|
+
* (`OrderService.create`). An ambiguous name returns its candidates instead
|
|
77
|
+
* of a trace.
|
|
43
78
|
*/
|
|
44
79
|
from: string;
|
|
45
80
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
81
|
+
* Target symbol (node id, simple name, or dotted member). When given, the
|
|
82
|
+
* tool returns the dependency path from `from` to it, the one-call answer
|
|
83
|
+
* for "how does A reach B". Prefer this path mode whenever both ends are
|
|
84
|
+
* known.
|
|
50
85
|
*/
|
|
51
86
|
to?: string;
|
|
52
87
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
88
|
+
* Trace direction:
|
|
89
|
+
*
|
|
90
|
+
* - `forward`: what the start uses (callees, instantiations, renders)
|
|
91
|
+
* - `reverse`: what uses the start (callers); the usual fit for caller
|
|
92
|
+
* questions
|
|
93
|
+
* - `impact`: reverse trace prioritizing public API and test nodes a change
|
|
94
|
+
* reaches; its test nodes are semantic usage edges, not a text search
|
|
58
95
|
*
|
|
59
96
|
* @default "forward"
|
|
60
97
|
*/
|
|
61
98
|
direction?: "forward" | "reverse" | "impact";
|
|
62
99
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
100
|
+
* Non-structural edge family to follow:
|
|
101
|
+
*
|
|
102
|
+
* - `execution`: runtime calls, instantiations, property access, JSX renders
|
|
103
|
+
* - `types`: type references and inheritance
|
|
104
|
+
* - `all`: the full graph
|
|
105
|
+
*
|
|
106
|
+
* Flow questions usually want `execution`, not `all`.
|
|
67
107
|
*
|
|
68
108
|
* @default "all"
|
|
69
109
|
*/
|
|
70
110
|
focus?: "all" | "execution" | "types";
|
|
71
111
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* Prefer the default for open traces. Raise only for path mode or when the
|
|
76
|
-
* previous trace named the missing next hop.
|
|
112
|
+
* Hops deep to follow (open forward/reverse cap at 8, impact at 4, path
|
|
113
|
+
* mode at 12). Raise it to follow a runtime chain to its end in one call.
|
|
77
114
|
*
|
|
78
|
-
* @default
|
|
115
|
+
* @default 3
|
|
79
116
|
*/
|
|
80
117
|
maxDepth?: number;
|
|
81
118
|
/**
|
|
82
|
-
* Cap on reached nodes
|
|
83
|
-
* Open forward/reverse traces are capped at 8 nodes, impact at 16 nodes.
|
|
119
|
+
* Cap on reached nodes (open forward/reverse cap at 32, impact at 16).
|
|
84
120
|
*
|
|
85
|
-
*
|
|
86
|
-
* requires it.
|
|
87
|
-
*
|
|
88
|
-
* @default 6
|
|
121
|
+
* @default 12
|
|
89
122
|
*/
|
|
90
123
|
maxNodes?: number;
|
|
91
124
|
/**
|
|
92
125
|
* Include dependency-boundary nodes from node_modules or bundled `.d.ts`
|
|
93
|
-
* libraries.
|
|
94
|
-
* asks about external type/API boundaries.
|
|
126
|
+
* libraries. Enable only for questions about external type/API boundaries.
|
|
95
127
|
*
|
|
96
128
|
* @default false
|
|
97
129
|
*/
|
|
@@ -107,17 +139,8 @@ export declare namespace ITtscGraphTrace {
|
|
|
107
139
|
kind: string;
|
|
108
140
|
/** Hops from the start (1 = direct). */
|
|
109
141
|
depth: number;
|
|
110
|
-
/**
|
|
111
|
-
* Source span for the expression that produced this hop. It is repository
|
|
112
|
-
* evidence for the hop and can be cited without opening the file.
|
|
113
|
-
*/
|
|
142
|
+
/** Source span that produced the hop: citable without opening the file. */
|
|
114
143
|
evidence?: ITtscGraphEvidence;
|
|
115
|
-
/**
|
|
116
|
-
* Stable access-path aliases derived from edge evidence. These preserve a
|
|
117
|
-
* resolved member's owner and the concrete property path used at the call
|
|
118
|
-
* site.
|
|
119
|
-
*/
|
|
120
|
-
aliases?: string[];
|
|
121
144
|
}
|
|
122
145
|
/** A node on the trace: the start, a reached node, or a candidate. */
|
|
123
146
|
interface INode {
|
|
@@ -6,5 +6,11 @@
|
|
|
6
6
|
* `extends`, `implements`, `overrides`, `renders`) are resolved by the checker
|
|
7
7
|
* — `renders` is a JSX component use. `decorates` carries a decorator fact and
|
|
8
8
|
* `tests` a test-to-subject relationship.
|
|
9
|
+
*
|
|
10
|
+
* `dispatches` is the runtime counterpart of `overrides`/`implements`: the
|
|
11
|
+
* checker resolves a call to the declaration it names, and where that
|
|
12
|
+
* declaration is abstract or an interface member, the code that runs is its
|
|
13
|
+
* implementation. It carries the implementation's declaration span, and a
|
|
14
|
+
* traversal that follows what executes emits it in place of the dead end.
|
|
9
15
|
*/
|
|
10
|
-
export type TtscGraphEdgeKind = "contains" | "exports" | "imports" | "calls" | "accesses" | "instantiates" | "type_ref" | "extends" | "implements" | "overrides" | "decorates" | "renders" | "tests";
|
|
16
|
+
export type TtscGraphEdgeKind = "contains" | "exports" | "imports" | "calls" | "accesses" | "instantiates" | "type_ref" | "extends" | "implements" | "overrides" | "dispatches" | "decorates" | "renders" | "tests";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./ITtscGraphApplication";
|
|
2
2
|
export * from "./ITtscGraphDecorator";
|
|
3
|
-
export * from "./ITtscGraphDiagnostic";
|
|
4
3
|
export * from "./ITtscGraphDump";
|
|
5
4
|
export * from "./ITtscGraphEdge";
|
|
6
5
|
export * from "./ITtscGraphEvidence";
|
|
@@ -12,6 +11,7 @@ export * from "./ITtscGraphOverview";
|
|
|
12
11
|
export * from "./ITtscGraphLookup";
|
|
13
12
|
export * from "./ITtscGraphNext";
|
|
14
13
|
export * from "./ITtscGraphTrace";
|
|
14
|
+
export * from "./ITtscGraphSpan";
|
|
15
15
|
export * from "./ITtscGraphTour";
|
|
16
16
|
export * from "./TtscGraphEdgeKind";
|
|
17
17
|
export * from "./TtscGraphNodeKind";
|