@ttsc/graph 0.30.4 → 0.31.0
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 +122 -30
- package/lib/CapturedProcessOutput.d.ts +47 -0
- package/lib/CapturedProcessOutput.js +3 -0
- package/lib/CapturedProcessOutput.js.map +1 -0
- package/lib/ILauncherOption.d.ts +22 -0
- package/lib/ILauncherOption.js +3 -0
- package/lib/ILauncherOption.js.map +1 -0
- package/lib/IProjectOptions.d.ts +18 -0
- package/lib/IProjectOptions.js +3 -0
- package/lib/IProjectOptions.js.map +1 -0
- package/lib/ParsedLauncherOptions.d.ts +13 -0
- package/lib/ParsedLauncherOptions.js +3 -0
- package/lib/ParsedLauncherOptions.js.map +1 -0
- package/lib/TtscGraphApplication.d.ts +38 -1
- package/lib/TtscGraphApplication.js +26 -1
- package/lib/TtscGraphApplication.js.map +1 -1
- package/lib/TtscGraphLauncherArguments.d.ts +115 -0
- package/lib/TtscGraphLauncherArguments.js +181 -0
- package/lib/TtscGraphLauncherArguments.js.map +1 -0
- package/lib/TtscGraphViewSnapshot.d.ts +35 -0
- package/lib/TtscGraphViewSnapshot.js +48 -0
- package/lib/TtscGraphViewSnapshot.js.map +1 -0
- package/lib/index.d.ts +9 -24
- package/lib/index.js +6 -128
- package/lib/index.js.map +1 -1
- package/lib/internal/GraphProcessTrace.d.ts +1 -0
- package/lib/internal/GraphProcessTrace.js +235 -0
- package/lib/internal/GraphProcessTrace.js.map +1 -0
- package/lib/launcherArgs.d.ts +75 -16
- package/lib/launcherArgs.js +77 -8
- package/lib/launcherArgs.js.map +1 -1
- package/lib/model/IArtifactDirectory.d.ts +26 -0
- package/lib/model/IArtifactDirectory.js +3 -0
- package/lib/model/IArtifactDirectory.js.map +1 -0
- package/lib/model/IArtifactInputs.d.ts +19 -0
- package/lib/model/IArtifactInputs.js +3 -0
- package/lib/model/IArtifactInputs.js.map +1 -0
- package/lib/model/IPublishedArtifacts.d.ts +76 -0
- package/lib/model/IPublishedArtifacts.js +3 -0
- package/lib/model/IPublishedArtifacts.js.map +1 -0
- package/lib/model/IPublishedArtifactsResident.d.ts +19 -0
- package/lib/model/IPublishedArtifactsResident.js +3 -0
- package/lib/model/IPublishedArtifactsResident.js.map +1 -0
- package/lib/model/ITtscLintDaemonTarget.d.ts +20 -0
- package/lib/model/ITtscLintDaemonTarget.js +3 -0
- package/lib/model/ITtscLintDaemonTarget.js.map +1 -0
- package/lib/model/TtscGraphLinePeer.d.ts +146 -0
- package/lib/model/TtscGraphLinePeer.js +213 -0
- package/lib/model/TtscGraphLinePeer.js.map +1 -0
- package/lib/model/TtscGraphMemory.d.ts +156 -16
- package/lib/model/TtscGraphMemory.js +228 -222
- package/lib/model/TtscGraphMemory.js.map +1 -1
- package/lib/model/TtscGraphNativeArguments.d.ts +40 -0
- package/lib/model/TtscGraphNativeArguments.js +64 -0
- package/lib/model/TtscGraphNativeArguments.js.map +1 -0
- package/lib/model/TtscGraphNodeId.d.ts +55 -3
- package/lib/model/TtscGraphNodeId.js +40 -2
- package/lib/model/TtscGraphNodeId.js.map +1 -1
- package/lib/model/TtscGraphProjection.d.ts +156 -0
- package/lib/model/TtscGraphProjection.js +390 -0
- package/lib/model/TtscGraphProjection.js.map +1 -0
- package/lib/model/TtscGraphProtocol.d.ts +28 -0
- package/lib/model/TtscGraphProtocol.js +928 -0
- package/lib/model/TtscGraphProtocol.js.map +1 -0
- package/lib/model/TtscGraphReadonly.d.ts +15 -0
- package/lib/model/TtscGraphReadonly.js +3 -0
- package/lib/model/TtscGraphReadonly.js.map +1 -0
- package/lib/model/TtscGraphRequestOptions.d.ts +16 -0
- package/lib/model/TtscGraphRequestOptions.js +3 -0
- package/lib/model/TtscGraphRequestOptions.js.map +1 -0
- package/lib/model/TtscGraphSession.d.ts +82 -36
- package/lib/model/TtscGraphSession.js +164 -1238
- package/lib/model/TtscGraphSession.js.map +1 -1
- package/lib/model/TtscGraphSessionOptions.d.ts +20 -0
- package/lib/model/TtscGraphSessionOptions.js +3 -0
- package/lib/model/TtscGraphSessionOptions.js.map +1 -0
- package/lib/model/TtscGraphSessionState.d.ts +187 -0
- package/lib/model/TtscGraphSessionState.js +417 -0
- package/lib/model/TtscGraphSessionState.js.map +1 -0
- package/lib/model/TtscGraphShardStore.d.ts +64 -3
- package/lib/model/TtscGraphShardStore.js +85 -15
- package/lib/model/TtscGraphShardStore.js.map +1 -1
- package/lib/model/TtscGraphSourceReader.d.ts +31 -8
- package/lib/model/TtscGraphSourceReader.js +37 -13
- package/lib/model/TtscGraphSourceReader.js.map +1 -1
- package/lib/model/TtscLintDaemon.d.ts +35 -17
- package/lib/model/TtscLintDaemon.js +39 -117
- package/lib/model/TtscLintDaemon.js.map +1 -1
- package/lib/model/TtscLintDaemonState.d.ts +69 -0
- package/lib/model/TtscLintDaemonState.js +166 -0
- package/lib/model/TtscLintDaemonState.js.map +1 -0
- package/lib/model/copyGraphRecords.d.ts +14 -0
- package/lib/model/copyGraphRecords.js +19 -0
- package/lib/model/copyGraphRecords.js.map +1 -0
- package/lib/model/copyGraphSnapshot.d.ts +17 -0
- package/lib/model/copyGraphSnapshot.js +33 -0
- package/lib/model/copyGraphSnapshot.js.map +1 -0
- package/lib/model/loadGraph.d.ts +19 -10
- package/lib/model/loadGraph.js +21 -12
- package/lib/model/loadGraph.js.map +1 -1
- package/lib/model/publishedArtifacts.d.ts +78 -97
- package/lib/model/publishedArtifacts.js +271 -85
- package/lib/model/publishedArtifacts.js.map +1 -1
- package/lib/nativeExecutable.d.ts +19 -8
- package/lib/nativeExecutable.js +75 -15
- package/lib/nativeExecutable.js.map +1 -1
- package/lib/reduce.d.ts +19 -45
- package/lib/reduce.js +19 -3
- package/lib/reduce.js.map +1 -1
- package/lib/resolveGraphBinary.d.ts +9 -0
- package/lib/resolveGraphBinary.js +11 -3
- package/lib/resolveGraphBinary.js.map +1 -1
- package/lib/runGraph.d.ts +21 -0
- package/lib/runGraph.js +83 -0
- package/lib/runGraph.js.map +1 -0
- package/lib/server/IResolvedGraphHandle.d.ts +22 -0
- package/lib/server/IResolvedGraphHandle.js +3 -0
- package/lib/server/IResolvedGraphHandle.js.map +1 -0
- package/lib/server/createServer.d.ts +14 -10
- package/lib/server/createServer.js +42 -39
- package/lib/server/createServer.js.map +1 -1
- package/lib/server/exportSurface.d.ts +23 -1
- package/lib/server/exportSurface.js +23 -1
- package/lib/server/exportSurface.js.map +1 -1
- package/lib/server/formatGraphFailure.d.ts +20 -0
- package/lib/server/formatGraphFailure.js +35 -0
- package/lib/server/formatGraphFailure.js.map +1 -0
- package/lib/server/pathPolicy.d.ts +70 -5
- package/lib/server/pathPolicy.js +66 -4
- package/lib/server/pathPolicy.js.map +1 -1
- package/lib/server/resolveHandle.d.ts +10 -5
- package/lib/server/resolveHandle.js +39 -7
- package/lib/server/resolveHandle.js.map +1 -1
- package/lib/server/resultAudit.d.ts +17 -14
- package/lib/server/resultAudit.js +56 -27
- package/lib/server/resultAudit.js.map +1 -1
- package/lib/server/resultNext.d.ts +26 -1
- package/lib/server/resultNext.js +14 -0
- package/lib/server/resultNext.js.map +1 -1
- package/lib/server/runDetails.d.ts +72 -15
- package/lib/server/runDetails.js +104 -69
- package/lib/server/runDetails.js.map +1 -1
- package/lib/server/runEntrypoints.d.ts +9 -0
- package/lib/server/runEntrypoints.js +9 -0
- package/lib/server/runEntrypoints.js.map +1 -1
- package/lib/server/runLookup.d.ts +13 -3
- package/lib/server/runLookup.js +19 -6
- package/lib/server/runLookup.js.map +1 -1
- package/lib/server/runOverview.d.ts +13 -4
- package/lib/server/runOverview.js +13 -4
- package/lib/server/runOverview.js.map +1 -1
- package/lib/server/runTour.d.ts +9 -0
- package/lib/server/runTour.js +33 -65
- package/lib/server/runTour.js.map +1 -1
- package/lib/server/runTrace.d.ts +25 -1
- package/lib/server/runTrace.js +133 -88
- package/lib/server/runTrace.js.map +1 -1
- package/lib/server/startServer.d.ts +16 -0
- package/lib/server/startServer.js +24 -1
- package/lib/server/startServer.js.map +1 -1
- package/lib/structures/ITtscGraphApplication.d.ts +95 -41
- package/lib/structures/ITtscGraphDecorator.d.ts +18 -0
- package/lib/structures/ITtscGraphDetails.d.ts +81 -6
- package/lib/structures/ITtscGraphDocTag.d.ts +17 -8
- package/lib/structures/ITtscGraphDump.d.ts +106 -8
- package/lib/structures/ITtscGraphEdge.d.ts +14 -2
- package/lib/structures/ITtscGraphEntrypoints.d.ts +81 -6
- package/lib/structures/ITtscGraphEscape.d.ts +24 -2
- package/lib/structures/ITtscGraphEvidence.d.ts +9 -0
- package/lib/structures/ITtscGraphLookup.d.ts +42 -9
- package/lib/structures/ITtscGraphNext.d.ts +12 -1
- package/lib/structures/ITtscGraphNode.d.ts +38 -11
- package/lib/structures/ITtscGraphOverview.d.ts +81 -6
- package/lib/structures/ITtscGraphSnapshot.d.ts +97 -2
- package/lib/structures/ITtscGraphSpan.d.ts +9 -0
- package/lib/structures/ITtscGraphTour.d.ts +83 -9
- package/lib/structures/ITtscGraphTrace.d.ts +99 -14
- package/lib/structures/RawDump.d.ts +22 -0
- package/lib/structures/RawDump.js +3 -0
- package/lib/structures/RawDump.js.map +1 -0
- package/lib/structures/RawEdge.d.ts +20 -0
- package/lib/structures/RawEdge.js +3 -0
- package/lib/structures/RawEdge.js.map +1 -0
- package/lib/structures/RawNode.d.ts +26 -0
- package/lib/structures/RawNode.js +3 -0
- package/lib/structures/RawNode.js.map +1 -0
- package/lib/structures/TtscGraphArtifactNodeKind.d.ts +9 -0
- package/lib/structures/TtscGraphArtifactNodeKind.js +9 -0
- package/lib/structures/TtscGraphArtifactNodeKind.js.map +1 -1
- package/lib/structures/TtscGraphDumpEdgeKind.d.ts +15 -1
- package/lib/structures/TtscGraphDumpNodeKind.d.ts +9 -0
- package/lib/structures/TtscGraphEdgeKind.d.ts +13 -4
- package/lib/structures/TtscGraphNodeKind.d.ts +9 -0
- package/lib/structures/TtscGraphNodeModifier.d.ts +9 -0
- package/lib/structures/ViewerLink.d.ts +20 -0
- package/lib/structures/ViewerLink.js +3 -0
- package/lib/structures/ViewerLink.js.map +1 -0
- package/lib/structures/ViewerNode.d.ts +24 -0
- package/lib/structures/ViewerNode.js +3 -0
- package/lib/structures/ViewerNode.js.map +1 -0
- package/lib/structures/ViewerPayload.d.ts +42 -0
- package/lib/structures/ViewerPayload.js +3 -0
- package/lib/structures/ViewerPayload.js.map +1 -0
- package/lib/view.d.ts +9 -0
- package/lib/view.js +203 -91
- package/lib/view.js.map +1 -1
- package/lib/viewer/viewer.js +1 -1
- package/package.json +8 -6
- package/src/CapturedProcessOutput.ts +50 -0
- package/src/ILauncherOption.ts +24 -0
- package/src/IProjectOptions.ts +19 -0
- package/src/ParsedLauncherOptions.ts +13 -0
- package/src/TtscGraphApplication.ts +38 -1
- package/src/TtscGraphLauncherArguments.ts +207 -0
- package/src/TtscGraphViewSnapshot.ts +46 -0
- package/src/index.ts +9 -160
- package/src/internal/GraphProcessTrace.ts +242 -0
- package/src/launcherArgs.ts +89 -23
- package/src/model/IArtifactDirectory.ts +27 -0
- package/src/model/IArtifactInputs.ts +21 -0
- package/src/model/IPublishedArtifacts.ts +81 -0
- package/src/model/IPublishedArtifactsResident.ts +24 -0
- package/src/model/ITtscLintDaemonTarget.ts +22 -0
- package/src/model/TtscGraphLinePeer.ts +318 -0
- package/src/model/TtscGraphMemory.ts +284 -246
- package/src/model/TtscGraphNativeArguments.ts +67 -0
- package/src/model/TtscGraphNodeId.ts +57 -3
- package/src/model/TtscGraphProjection.ts +473 -0
- package/src/model/TtscGraphProtocol.ts +90 -0
- package/src/model/TtscGraphReadonly.ts +17 -0
- package/src/model/TtscGraphRequestOptions.ts +16 -0
- package/src/model/TtscGraphSession.ts +196 -475
- package/src/model/TtscGraphSessionOptions.ts +22 -0
- package/src/model/TtscGraphSessionState.ts +558 -0
- package/src/model/TtscGraphShardStore.ts +99 -23
- package/src/model/TtscGraphSourceReader.ts +37 -15
- package/src/model/TtscLintDaemon.ts +55 -136
- package/src/model/TtscLintDaemonState.ts +174 -0
- package/src/model/copyGraphRecords.ts +17 -0
- package/src/model/copyGraphSnapshot.ts +30 -0
- package/src/model/loadGraph.ts +23 -12
- package/src/model/publishedArtifacts.ts +361 -182
- package/src/nativeExecutable.ts +93 -26
- package/src/reduce.ts +24 -51
- package/src/resolveGraphBinary.ts +13 -3
- package/src/runGraph.ts +90 -0
- package/src/server/IResolvedGraphHandle.ts +24 -0
- package/src/server/createServer.ts +16 -22
- package/src/server/exportSurface.ts +23 -1
- package/src/server/formatGraphFailure.ts +32 -0
- package/src/server/pathPolicy.ts +70 -5
- package/src/server/resolveHandle.ts +45 -14
- package/src/server/resultAudit.ts +58 -27
- package/src/server/resultNext.ts +26 -1
- package/src/server/runDetails.ts +138 -73
- package/src/server/runEntrypoints.ts +13 -1
- package/src/server/runLookup.ts +23 -7
- package/src/server/runOverview.ts +17 -5
- package/src/server/runTour.ts +44 -82
- package/src/server/runTrace.ts +175 -102
- package/src/server/startServer.ts +29 -1
- package/src/structures/ITtscGraphApplication.ts +95 -41
- package/src/structures/ITtscGraphDecorator.ts +18 -0
- package/src/structures/ITtscGraphDetails.ts +81 -6
- package/src/structures/ITtscGraphDocTag.ts +17 -8
- package/src/structures/ITtscGraphDump.ts +106 -8
- package/src/structures/ITtscGraphEdge.ts +14 -2
- package/src/structures/ITtscGraphEntrypoints.ts +81 -6
- package/src/structures/ITtscGraphEscape.ts +24 -2
- package/src/structures/ITtscGraphEvidence.ts +9 -0
- package/src/structures/ITtscGraphLookup.ts +42 -9
- package/src/structures/ITtscGraphNext.ts +12 -1
- package/src/structures/ITtscGraphNode.ts +38 -11
- package/src/structures/ITtscGraphOverview.ts +88 -6
- package/src/structures/ITtscGraphSnapshot.ts +117 -2
- package/src/structures/ITtscGraphSpan.ts +9 -0
- package/src/structures/ITtscGraphTour.ts +83 -9
- package/src/structures/ITtscGraphTrace.ts +100 -14
- package/src/structures/RawDump.ts +25 -0
- package/src/structures/RawEdge.ts +22 -0
- package/src/structures/RawNode.ts +31 -0
- package/src/structures/TtscGraphArtifactNodeKind.ts +9 -0
- package/src/structures/TtscGraphDumpEdgeKind.ts +15 -1
- package/src/structures/TtscGraphDumpNodeKind.ts +9 -0
- package/src/structures/TtscGraphEdgeKind.ts +13 -4
- package/src/structures/TtscGraphNodeKind.ts +9 -0
- package/src/structures/TtscGraphNodeModifier.ts +9 -0
- package/src/structures/ViewerLink.ts +22 -0
- package/src/structures/ViewerNode.ts +28 -0
- package/src/structures/ViewerPayload.ts +52 -0
- package/src/view.ts +208 -110
- package/src/viewer/legend.ts +119 -27
|
@@ -16,6 +16,18 @@ import { runTrace } from "./server/runTrace";
|
|
|
16
16
|
import { ITtscGraphApplication } from "./structures/ITtscGraphApplication";
|
|
17
17
|
import { ITtscGraphEscape } from "./structures/ITtscGraphEscape";
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* A fixed graph generation or a provider synchronizing one before each request.
|
|
21
|
+
*
|
|
22
|
+
* @evidence contracts/common.md#principled-implementation The union admits resident values and synchronous/asynchronous producers with the same graph result contract.
|
|
23
|
+
* @evidence contracts/common.md#clear-and-simple-design One provider boundary lets dispatch use fixed dumps and refreshing sessions without separate applications.
|
|
24
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Refresh remains a supplied ownership boundary instead of foreign graph mutation.
|
|
25
|
+
* @evidence contracts/common.md#meaningful-documentation The native headline states fixed versus synchronized generation and the provider's timing.
|
|
26
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources data shape only: it holds no handle, task or retained state.
|
|
27
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms data shape only: it contains no loop or algorithm.
|
|
28
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work data shape only: it computes nothing another request could share.
|
|
29
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation data shape only: it touches no file, path or process.
|
|
30
|
+
*/
|
|
19
31
|
export type TtscGraphSource =
|
|
20
32
|
| TtscGraphMemory
|
|
21
33
|
| (() => TtscGraphMemory | Promise<TtscGraphMemory>);
|
|
@@ -24,7 +36,7 @@ export type TtscGraphSource =
|
|
|
24
36
|
* The MCP tool surface as a plain class over the resident
|
|
25
37
|
* {@link TtscGraphMemory}.
|
|
26
38
|
*
|
|
27
|
-
* Its public method is the MCP tool: `typia.llm.
|
|
39
|
+
* Its public method is the MCP tool: `typia.llm.controller` reflects
|
|
28
40
|
* {@link ITtscGraphApplication} to generate the tool's JSON schema and argument
|
|
29
41
|
* validator from the signature and JSDoc, with no hand-written schema, and
|
|
30
42
|
* `@typia/mcp`'s `createMcpServer` registers it (see `./server/createServer`).
|
|
@@ -35,6 +47,15 @@ export type TtscGraphSource =
|
|
|
35
47
|
* that graph before the operation when project files changed. Output is kept
|
|
36
48
|
* compact and bounded so a model can read structure without a file read, which
|
|
37
49
|
* is the token win the redesign exists for.
|
|
50
|
+
*
|
|
51
|
+
* @evidence contracts/common.md#principled-implementation Exhaustive request dispatch chooses the matching graph operation and its operation-specific audit; escape bypasses graph acquisition entirely.
|
|
52
|
+
* @evidence contracts/common.md#clear-and-simple-design The class binds one graph provider to pure runners, leaving traversal and ranking with their owning functions.
|
|
53
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No forced first lookup or agent-specific call suppression is introduced; legitimate escape and incomplete coverage remain explicit.
|
|
54
|
+
* @evidence contracts/common.md#meaningful-documentation Native paragraphs explain reflected tool wiring, provider refresh and source-free result ownership.
|
|
55
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources holds only the provider function; the session owns the resources.
|
|
56
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms dispatches one request to its runner and the runners own the algorithms.
|
|
57
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work each non-escape call asks the provider function for the graph, and the provider owns reuse.
|
|
58
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation dispatches to in-memory runners; the provider function owns session and process work.
|
|
38
59
|
*/
|
|
39
60
|
export class TtscGraphApplication implements ITtscGraphApplication {
|
|
40
61
|
private readonly graph: () => TtscGraphMemory | Promise<TtscGraphMemory>;
|
|
@@ -43,6 +64,22 @@ export class TtscGraphApplication implements ITtscGraphApplication {
|
|
|
43
64
|
this.graph = typeof source === "function" ? source : () => source;
|
|
44
65
|
}
|
|
45
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Synchronize the graph once and dispatch the selected request.
|
|
69
|
+
*
|
|
70
|
+
* Escape returns an explicit no-op before invoking the provider. Ranked
|
|
71
|
+
* operations report heuristic selection; details distinguishes capped members
|
|
72
|
+
* from its complete identity facts.
|
|
73
|
+
*
|
|
74
|
+
* @evidence contracts/common.md#principled-implementation Each discriminated branch returns its corresponding runner result with the audit appropriate to that operation's actual completeness.
|
|
75
|
+
* @evidence contracts/common.md#clear-and-simple-design The exhaustive switch owns only dispatch and audit choice; runners own graph semantics and the provider owns synchronization.
|
|
76
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Escape does no indexing, and heuristic selection is not advertised as exhaustive compiler proof.
|
|
77
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose explains provider timing, no-op escape and operation-specific completeness before the tags.
|
|
78
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources keeps nothing between calls.
|
|
79
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms a switch over seven request types that calls one runner.
|
|
80
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work each non-escape call asks the provider function for the graph, and the provider owns reuse.
|
|
81
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation dispatches to in-memory runners; the provider function owns session and process work.
|
|
82
|
+
*/
|
|
46
83
|
public async inspect_typescript_graph(
|
|
47
84
|
props: ITtscGraphApplication.IProps,
|
|
48
85
|
): Promise<ITtscGraphApplication.IOutput> {
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import type { IProjectOptions } from "./IProjectOptions";
|
|
2
|
+
import {
|
|
3
|
+
PROJECT_OPTIONS,
|
|
4
|
+
nonNegativeIntegerOption,
|
|
5
|
+
parseLauncherOptions,
|
|
6
|
+
positiveIntegerOption,
|
|
7
|
+
projectOptions,
|
|
8
|
+
} from "./launcherArgs";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Project, viewer and dump argument contracts consumed by the real launchers.
|
|
12
|
+
*
|
|
13
|
+
* @evidence contracts/common.md#principled-implementation Existing explicit grammar and typed validators qualify project coordinates before real launch work; dump tokens and completion preserve the native contract.
|
|
14
|
+
* @evidence contracts/common.md#clear-and-simple-design This namespace owns launcher grammar, dump launch-vector construction and completion mapping; native process execution remains with runGraph/view.
|
|
15
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Actual facades consume these operations without alternate test entrypoints, executable stand-ins or weakened grammar.
|
|
16
|
+
* @evidence contracts/common.md#meaningful-documentation Member prose identifies coordinate defaults, argv preservation and native completion ownership needed by the facades.
|
|
17
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The namespace groups contracts; its members own native path and process-value representation.
|
|
18
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources returns plain values and holds no handle.
|
|
19
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms groups launcher parsers and completion mappers that each do bounded work.
|
|
20
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work its members run once per launcher invocation, so nothing is shared.
|
|
21
|
+
*/
|
|
22
|
+
export namespace TtscGraphLauncherArguments {
|
|
23
|
+
/**
|
|
24
|
+
* Parse MCP project coordinates with the shared cwd/config defaults.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation The shared PROJECT_OPTIONS grammar rejects unknown or incomplete tokens before projectOptions supplies its supported defaults.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design Only the shared project grammar is selected; startServer retains lazy native lifetime ownership.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Existing public flag and result contracts are used by actual facades without fixture branches or a synthetic producer.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation The native headline states this operation's input/result ownership and relevant absence/default meaning.
|
|
30
|
+
* @evidence contracts/portability.md#os-neutral-implementation Project normalization delegates to Node path.resolve; selected config spelling remains intact, with no shell or separator rewriting.
|
|
31
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources returns a fresh value and keeps no handle or state.
|
|
32
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms one parseLauncherOptions pass over argv plus a path.resolve.
|
|
33
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work parses argv once per process start.
|
|
34
|
+
*/
|
|
35
|
+
export function project(argv: readonly string[]): IProjectOptions {
|
|
36
|
+
return projectOptions(parseLauncherOptions(argv, PROJECT_OPTIONS));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Parse dump project coordinates without altering forwarded tokens.
|
|
41
|
+
*
|
|
42
|
+
* @evidence contracts/common.md#principled-implementation The original dump grammar accepts its cwd/config aliases, pretty booleans and help flags, rejecting incomplete or unknown options before resolution.
|
|
43
|
+
* @evidence contracts/common.md#clear-and-simple-design Dump validation returns coordinates and explicit artifact presence; dumpVector separately preserves the caller tokens actually sent to the producer.
|
|
44
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Existing public flag and result contracts are used by actual facades without fixture branches or a synthetic producer.
|
|
45
|
+
* @evidence contracts/common.md#meaningful-documentation The native headline states this operation's input/result ownership and relevant absence/default meaning.
|
|
46
|
+
* @evidence contracts/portability.md#os-neutral-implementation Project normalization delegates to Node path.resolve; selected config spelling remains intact, with no shell or separator rewriting.
|
|
47
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources returns a fresh value and keeps no handle or state.
|
|
48
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms one parseLauncherOptions pass over argv plus a path.resolve.
|
|
49
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work parses argv once per process start.
|
|
50
|
+
*/
|
|
51
|
+
export function dump(
|
|
52
|
+
argv: readonly string[],
|
|
53
|
+
): IProjectOptions & { artifactsSpecified: boolean } {
|
|
54
|
+
const values = parseLauncherOptions(argv, DUMP_OPTIONS);
|
|
55
|
+
return {
|
|
56
|
+
...projectOptions(values),
|
|
57
|
+
artifactsSpecified: values.has("artifacts"),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Parse viewer coordinates and bounded numeric options with existing
|
|
63
|
+
* defaults.
|
|
64
|
+
*
|
|
65
|
+
* @evidence contracts/common.md#principled-implementation The original viewer grammar plus safe integer validators retains port zero through 65,535 and positive maxNodes through Number.MAX_SAFE_INTEGER before graph work.
|
|
66
|
+
* @evidence contracts/common.md#clear-and-simple-design Project defaults and numeric policy share existing owners; the viewer retains build, reduction and HTTP lifetime.
|
|
67
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Existing public flag and result contracts are used by actual facades without fixture branches or a synthetic producer.
|
|
68
|
+
* @evidence contracts/common.md#meaningful-documentation The native headline states this operation's input/result ownership and relevant absence/default meaning.
|
|
69
|
+
* @evidence contracts/portability.md#os-neutral-implementation Project normalization delegates to Node path.resolve; selected config spelling remains intact, with no shell or separator rewriting.
|
|
70
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources returns a fresh value and keeps no handle or state.
|
|
71
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms one parse pass over argv and up to two integer validations.
|
|
72
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work parses argv once per process start.
|
|
73
|
+
*/
|
|
74
|
+
export function view(argv: readonly string[]): IViewOptions {
|
|
75
|
+
const values = parseLauncherOptions(argv, [
|
|
76
|
+
{ key: "cwd", flags: ["--cwd"], kind: "value" },
|
|
77
|
+
{ key: "tsconfig", flags: ["--tsconfig", "-p"], kind: "value" },
|
|
78
|
+
{ key: "port", flags: ["--port"], kind: "value" },
|
|
79
|
+
{ key: "open", flags: ["--no-open"], kind: "flag" },
|
|
80
|
+
{ key: "max_nodes", flags: ["--max-nodes"], kind: "value" },
|
|
81
|
+
]);
|
|
82
|
+
return {
|
|
83
|
+
...projectOptions(values),
|
|
84
|
+
port:
|
|
85
|
+
values.has("port") === true
|
|
86
|
+
? nonNegativeIntegerOption(values, "port", 65_535)
|
|
87
|
+
: 0,
|
|
88
|
+
open: values.get("open") !== true,
|
|
89
|
+
maxNodes:
|
|
90
|
+
values.has("max_nodes") === true
|
|
91
|
+
? positiveIntegerOption(values, "max_nodes", Number.MAX_SAFE_INTEGER)
|
|
92
|
+
: 1200,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Preserve native dump argv, adding only a present published-artifact path.
|
|
98
|
+
*
|
|
99
|
+
* @evidence contracts/common.md#principled-implementation The dump token precedes the unmodified caller vector; a null publication adds no overlay coordinate.
|
|
100
|
+
* @evidence contracts/common.md#clear-and-simple-design One vector owner is consumed by the actual dump spawn; resident serve/lint vectors remain distinct in their existing owner.
|
|
101
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Existing public flag and result contracts are used by actual facades without fixture branches or a synthetic producer.
|
|
102
|
+
* @evidence contracts/common.md#meaningful-documentation The native headline states this operation's input/result ownership and relevant absence/default meaning.
|
|
103
|
+
* @evidence contracts/portability.md#os-neutral-implementation Separate argv elements preserve path and equals-form spelling exactly for Node spawn, without shell quoting.
|
|
104
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources returns a fresh value and keeps no handle or state.
|
|
105
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms one parse pass over argv and a copy of it with at most two appended entries.
|
|
106
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work builds one argv per spawn.
|
|
107
|
+
*/
|
|
108
|
+
export function dumpVector(
|
|
109
|
+
argv: readonly string[],
|
|
110
|
+
artifacts: string | null,
|
|
111
|
+
): string[] {
|
|
112
|
+
const values = parseLauncherOptions(argv, DUMP_OPTIONS);
|
|
113
|
+
return [
|
|
114
|
+
"dump",
|
|
115
|
+
...argv,
|
|
116
|
+
...(artifacts === null || values.has("artifacts")
|
|
117
|
+
? []
|
|
118
|
+
: ["--artifacts", artifacts]),
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Map native completion to its exit code and optional owned spawn diagnostic.
|
|
124
|
+
*
|
|
125
|
+
* @evidence contracts/common.md#principled-implementation Actual spawn errors return code one with the existing owned prefix; normal status passes through exactly, and absent status remains failure one.
|
|
126
|
+
* @evidence contracts/common.md#clear-and-simple-design The actual dump facade writes only the returned diagnostic and returns this code; completion decides no process timing or retry.
|
|
127
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Existing public flag and result contracts are used by actual facades without fixture branches or a synthetic producer.
|
|
128
|
+
* @evidence contracts/common.md#meaningful-documentation The native headline states this operation's input/result ownership and relevant absence/default meaning.
|
|
129
|
+
* @evidence contracts/portability.md#os-neutral-implementation Node error and nullable numeric status are preserved as native result representations, with no platform shell exit interpretation.
|
|
130
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources returns a small record and retains nothing.
|
|
131
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms reads two fields of the spawn result in constant time.
|
|
132
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work maps one spawn result once.
|
|
133
|
+
*/
|
|
134
|
+
export function dumpCompletion(result: {
|
|
135
|
+
error?: Error;
|
|
136
|
+
status: number | null;
|
|
137
|
+
}): { code: number; diagnostic?: string } {
|
|
138
|
+
if (result.error)
|
|
139
|
+
return { code: 1, diagnostic: `@ttsc/graph: ${result.error.message}\n` };
|
|
140
|
+
return { code: result.status ?? 1 };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Answer help without a producer, or retain the missing-installation failure.
|
|
145
|
+
*
|
|
146
|
+
* This summary is a fallback: installed native dump still owns its exact
|
|
147
|
+
* flags.
|
|
148
|
+
*
|
|
149
|
+
* @evidence contracts/common.md#principled-implementation Only the three existing help spellings qualify a missing-producer success; ordinary dump remains code one with the owned installation diagnostic.
|
|
150
|
+
* @evidence contracts/common.md#clear-and-simple-design The actual unresolved-binary facade writes these channels and returns their code; this operation decides neither resolution nor child execution.
|
|
151
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The qualified help summary names the native authority and its possible drift; no graph fact or native success is fabricated.
|
|
152
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose distinguishes missing-install help from installed authoritative help and ordinary missing-install failure.
|
|
153
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation This completion maps already parsed tokens to fixed text and numeric code, without filesystem or process operations.
|
|
154
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources returns a small record of strings and retains nothing.
|
|
155
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms tests argv against three help spellings and returns a constant summary or message.
|
|
156
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work answers once per failed binary resolution.
|
|
157
|
+
*/
|
|
158
|
+
export function missingDump(argv: readonly string[]): {
|
|
159
|
+
code: 0 | 1;
|
|
160
|
+
stdout?: string;
|
|
161
|
+
stderr?: string;
|
|
162
|
+
} {
|
|
163
|
+
if (argv.some((argument) => DUMP_HELP_FLAGS.has(argument)))
|
|
164
|
+
return { code: 0, stdout: DUMP_HELP_SUMMARY };
|
|
165
|
+
return {
|
|
166
|
+
code: 1,
|
|
167
|
+
stderr:
|
|
168
|
+
"@ttsc/graph: could not resolve the ttscgraph binary. " +
|
|
169
|
+
"Install `ttsc` so its platform package is present, " +
|
|
170
|
+
"or set TTSC_GRAPH_BINARY to an absolute path.\n",
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface IViewOptions extends IProjectOptions {
|
|
176
|
+
port: number;
|
|
177
|
+
open: boolean;
|
|
178
|
+
maxNodes: number;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const DUMP_OPTIONS = [
|
|
182
|
+
{ key: "artifacts", flags: ["--artifacts", "-artifacts"], kind: "string" },
|
|
183
|
+
{ key: "cwd", flags: ["--cwd", "-cwd"], kind: "value" },
|
|
184
|
+
{ key: "tsconfig", flags: ["--tsconfig", "-tsconfig"], kind: "value" },
|
|
185
|
+
{ key: "pretty", flags: ["--pretty", "-pretty"], kind: "boolean" },
|
|
186
|
+
{ key: "help", flags: ["--help", "-help", "-h"], kind: "flag" },
|
|
187
|
+
] as const;
|
|
188
|
+
|
|
189
|
+
/** The native help aliases mirrored only for missing-installation fallback. */
|
|
190
|
+
const DUMP_HELP_FLAGS = new Set(["--help", "-help", "-h"]);
|
|
191
|
+
|
|
192
|
+
/** Short fallback summary pointing to the native command's authoritative help. */
|
|
193
|
+
const DUMP_HELP_SUMMARY = [
|
|
194
|
+
"Usage: ttsc-graph dump [options]",
|
|
195
|
+
"",
|
|
196
|
+
"Write the whole compiler graph as JSON to stdout: every node and edge,",
|
|
197
|
+
"none of the MCP response caps.",
|
|
198
|
+
"",
|
|
199
|
+
"Options:",
|
|
200
|
+
" --cwd <dir> Project root (default: current directory).",
|
|
201
|
+
" --tsconfig <path> Project tsconfig path (default: tsconfig.json).",
|
|
202
|
+
" --pretty Indent the JSON output.",
|
|
203
|
+
"",
|
|
204
|
+
"The native `ttscgraph` binary owns these flags and is not installed here,",
|
|
205
|
+
"so this summary may lag it. Install `ttsc` and rerun for the exact list.",
|
|
206
|
+
"",
|
|
207
|
+
].join("\n");
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { parseDump } from "./model/loadGraph";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Qualify a viewer dump before reduction or HTTP lifetime can begin.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/common.md#principled-implementation The actual shared dump decoder validates syntax, schema agreement and complete shape before a viewer receives facts; failures preserve the existing owned diagnostic and code one.
|
|
7
|
+
* @evidence contracts/common.md#clear-and-simple-design This namespace owns viewer validation/completion while parseDump owns schema authority and runView owns native capture, reduction and HTTP resources.
|
|
8
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Actual generated validation is retained without a handwritten substitute, test-only producer or successful empty fallback.
|
|
9
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose states the before-reduction/HTTP boundary; decode documents success transfer and diagnostic/code meaning.
|
|
10
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms decode owns validation work; the namespace groups its result contract.
|
|
11
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work No result cache is owned by the namespace; runView owns the one-shot snapshot lifetime.
|
|
12
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The grouping acquires no process/socket; decode transfers valid facts to runView.
|
|
13
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation validates dump JSON text that the caller already captured; no file, path or process.
|
|
14
|
+
*/
|
|
15
|
+
export namespace TtscGraphViewSnapshot {
|
|
16
|
+
/**
|
|
17
|
+
* Return validated facts, or the existing viewer diagnostic and failure code.
|
|
18
|
+
*
|
|
19
|
+
* @evidence contracts/common.md#principled-implementation parseDump is the sole generated schema authority; its owned messages pass through once, and an unowned exception receives the existing validation prefix.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design A discriminated result keeps failure before actual reduction/server creation; runView writes only the returned diagnostic and returns its code.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Failed validation never supplies raw facts; no partial cast or alternate executable bypasses the real decoder.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The headline explains valid-fact transfer versus failure diagnostic/code, without claiming this pure result is a process exit by itself.
|
|
23
|
+
* @evidence contracts/performance.md#efficient-algorithms Shared JSON/schema validation is linear in submitted bytes and facts, followed by constant-count diagnostic prefix handling; no historical/project scan is introduced.
|
|
24
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work Each supplied dump requires actual validation; runView reuses the subsequently reduced immutable HTTP payload.
|
|
25
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Only local parsed facts or diagnostic text are created; ownership transfers to the caller and no process, reader, socket or prior dump is retained.
|
|
26
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation parses and validates dump JSON text that the caller already captured; no file, path or process.
|
|
27
|
+
*/
|
|
28
|
+
export function decode(
|
|
29
|
+
text: string,
|
|
30
|
+
):
|
|
31
|
+
| { ok: true; raw: ReturnType<typeof parseDump> }
|
|
32
|
+
| { ok: false; code: 1; diagnostic: string } {
|
|
33
|
+
try {
|
|
34
|
+
return { ok: true, raw: parseDump(text) };
|
|
35
|
+
} catch (error) {
|
|
36
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
37
|
+
return {
|
|
38
|
+
ok: false,
|
|
39
|
+
code: 1,
|
|
40
|
+
diagnostic: message.startsWith("@ttsc/graph:")
|
|
41
|
+
? `${message}\n`
|
|
42
|
+
: `@ttsc/graph: could not validate the graph dump: ${message}\n`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
PROJECT_OPTIONS,
|
|
5
|
-
parseLauncherOptions,
|
|
6
|
-
projectOptions,
|
|
7
|
-
} from "./launcherArgs";
|
|
8
|
-
import { publishArtifacts } from "./model/publishedArtifacts";
|
|
9
|
-
import { ensureExecutable } from "./nativeExecutable";
|
|
10
|
-
import { resolveGraphBinary } from "./resolveGraphBinary";
|
|
11
|
-
import { startServer } from "./server/startServer";
|
|
12
|
-
import { runView } from "./view";
|
|
13
|
-
|
|
14
|
-
/** What a graph result says about where its facts came from. */
|
|
1
|
+
/** Public graph launchers, resident sessions, audit vocabulary and viewer DTOs. */
|
|
15
2
|
export {
|
|
16
3
|
RESULT_AUDIT,
|
|
17
4
|
RESULT_AUDIT_DETAILS,
|
|
@@ -19,152 +6,14 @@ export {
|
|
|
19
6
|
RESULT_AUDIT_ESCAPE,
|
|
20
7
|
RESULT_AUDIT_SELECTION,
|
|
21
8
|
} from "./server/resultAudit";
|
|
22
|
-
|
|
23
|
-
// Programmatic entry points. Each resolves its native binary from the project
|
|
24
|
-
// `cwd` it is given (see `resolveGraphBinary`), so a caller that graphs a
|
|
25
|
-
// project other than its own process directory names it once and the binary is
|
|
26
|
-
// found under that project's installed `ttsc`.
|
|
27
9
|
export { resolveGraphBinary } from "./resolveGraphBinary";
|
|
28
|
-
/**
|
|
29
|
-
* The viewer reduction the `view` command runs before serving a payload.
|
|
30
|
-
*
|
|
31
|
-
* Exported because it is one of three copies of the same pure transform — the
|
|
32
|
-
* website's uploaded-dump viewer and the benchmark viewer hold the others — and
|
|
33
|
-
* a shared policy that cannot be measured from outside the package drifts. It
|
|
34
|
-
* already did: two of them filtered git-ignored generated code and this one did
|
|
35
|
-
* not.
|
|
36
|
-
*/
|
|
37
10
|
export { reduce } from "./reduce";
|
|
38
|
-
export type { RawDump
|
|
11
|
+
export type { RawDump } from "./structures/RawDump";
|
|
12
|
+
export type { RawEdge } from "./structures/RawEdge";
|
|
13
|
+
export type { RawNode } from "./structures/RawNode";
|
|
14
|
+
export type { ViewerPayload } from "./structures/ViewerPayload";
|
|
39
15
|
export { DUMP_SCHEMA_VERSION, loadGraph } from "./model/loadGraph";
|
|
40
|
-
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} from "./model/TtscGraphSession";
|
|
45
|
-
|
|
46
|
-
// The server version reported in the MCP handshake; read from this package.
|
|
47
|
-
const VERSION: string = (require("../package.json") as { version: string })
|
|
48
|
-
.version;
|
|
49
|
-
|
|
50
|
-
const DUMP_OPTIONS = [
|
|
51
|
-
{ key: "cwd", flags: ["--cwd", "-cwd"], kind: "value" },
|
|
52
|
-
{ key: "tsconfig", flags: ["--tsconfig", "-tsconfig"], kind: "value" },
|
|
53
|
-
{ key: "pretty", flags: ["--pretty", "-pretty"], kind: "boolean" },
|
|
54
|
-
{ key: "help", flags: ["--help", "-help", "-h"], kind: "flag" },
|
|
55
|
-
] as const;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Run the `@ttsc/graph` launcher.
|
|
59
|
-
*
|
|
60
|
-
* - `view`: JS-orchestrated 3D viewer (dump -> reduce -> serve -> open).
|
|
61
|
-
* - `dump`: pass through to the native `ttscgraph dump`, which prints the whole
|
|
62
|
-
* graph as JSON for piping or the viewer.
|
|
63
|
-
* - Default: serve the MCP graph over stdio. The TypeScript server keeps a native
|
|
64
|
-
* incremental compiler session resident, checks the disk snapshot before each
|
|
65
|
-
* graph operation, and reuses the in-memory graph when unchanged; the agent's
|
|
66
|
-
* MCP client speaks JSON-RPC over this process's stdin/stdout.
|
|
67
|
-
*/
|
|
68
|
-
export function runGraph(
|
|
69
|
-
argv: readonly string[] = process.argv.slice(2),
|
|
70
|
-
): number | void {
|
|
71
|
-
if (argv[0] === "view") return runView(argv.slice(1));
|
|
72
|
-
if (argv[0] === "dump") return runDump(argv.slice(1));
|
|
73
|
-
|
|
74
|
-
const { cwd, tsconfig } = projectOptions(
|
|
75
|
-
parseLauncherOptions(argv, PROJECT_OPTIONS),
|
|
76
|
-
);
|
|
77
|
-
void startServer({ cwd, tsconfig, version: VERSION }).catch(
|
|
78
|
-
(error: unknown) => {
|
|
79
|
-
process.stderr.write(
|
|
80
|
-
`@ttsc/graph: ${error instanceof Error ? error.message : String(error)}\n`,
|
|
81
|
-
);
|
|
82
|
-
process.exit(1);
|
|
83
|
-
},
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** The help spellings `ttscgraph` itself accepts, mirrored for the fallback. */
|
|
88
|
-
const DUMP_HELP_FLAGS = new Set(["--help", "-help", "-h"]);
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Print a `dump` usage summary when the native binary cannot be resolved.
|
|
92
|
-
*
|
|
93
|
-
* This is a fallback, not a second contract: `cmd/ttscgraph/main.go` owns these
|
|
94
|
-
* flags and answers whenever it is installed. Keep this short and point at that
|
|
95
|
-
* authority, so a drift degrades to a stale summary rather than a wrong
|
|
96
|
-
* answer.
|
|
97
|
-
*/
|
|
98
|
-
function printDumpHelp(): void {
|
|
99
|
-
process.stdout.write(
|
|
100
|
-
[
|
|
101
|
-
"Usage: ttsc-graph dump [options]",
|
|
102
|
-
"",
|
|
103
|
-
"Write the whole compiler graph as JSON to stdout: every node and edge,",
|
|
104
|
-
"none of the MCP response caps.",
|
|
105
|
-
"",
|
|
106
|
-
"Options:",
|
|
107
|
-
" --cwd <dir> Project root (default: current directory).",
|
|
108
|
-
" --tsconfig <path> Project tsconfig path (default: tsconfig.json).",
|
|
109
|
-
" --pretty Indent the JSON output.",
|
|
110
|
-
"",
|
|
111
|
-
"The native `ttscgraph` binary owns these flags and is not installed here,",
|
|
112
|
-
"so this summary may lag it. Install `ttsc` and rerun for the exact list.",
|
|
113
|
-
"",
|
|
114
|
-
].join("\n"),
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Pass `dump` through to the native binary, inheriting stdio so the JSON lands
|
|
120
|
-
* on this process's stdout. Returns the child's exit code.
|
|
121
|
-
*/
|
|
122
|
-
function runDump(argv: readonly string[]): number {
|
|
123
|
-
// Resolve the native binary from the target project the caller named with
|
|
124
|
-
// `--cwd`, not from wherever the launcher process happened to start.
|
|
125
|
-
const { cwd, tsconfig } = projectOptions(
|
|
126
|
-
parseLauncherOptions(argv, DUMP_OPTIONS),
|
|
127
|
-
);
|
|
128
|
-
const binary = resolveGraphBinary(process.env, cwd);
|
|
129
|
-
if (binary === null) {
|
|
130
|
-
// `ttscgraph` owns the flag contract, so a resolvable binary always answers
|
|
131
|
-
// `--help` itself and stays the single source of truth. It cannot answer
|
|
132
|
-
// when it is absent, and that is exactly when a caller is most likely to be
|
|
133
|
-
// asking what the command needs — so fall back to a summary that names the
|
|
134
|
-
// authority rather than making usage unreachable behind an install error.
|
|
135
|
-
if (argv.some((argument) => DUMP_HELP_FLAGS.has(argument))) {
|
|
136
|
-
printDumpHelp();
|
|
137
|
-
return 0;
|
|
138
|
-
}
|
|
139
|
-
process.stderr.write(
|
|
140
|
-
"@ttsc/graph: could not resolve the ttscgraph binary. " +
|
|
141
|
-
"Install `ttsc` so its platform package is present, " +
|
|
142
|
-
"or set TTSC_GRAPH_BINARY to an absolute path.\n",
|
|
143
|
-
);
|
|
144
|
-
return 1;
|
|
145
|
-
}
|
|
146
|
-
ensureExecutable(binary);
|
|
147
|
-
// The same artifacts `loadGraph` and the resident session ask for, so the
|
|
148
|
-
// three ways to reach a dump answer a citation the same way. A caller that
|
|
149
|
-
// named `--artifacts` itself owns the answer and is not overridden.
|
|
150
|
-
const published = argv.includes("--artifacts")
|
|
151
|
-
? null
|
|
152
|
-
: publishArtifacts({ cwd, tsconfig });
|
|
153
|
-
const result = spawnSync(
|
|
154
|
-
binary,
|
|
155
|
-
[
|
|
156
|
-
"dump",
|
|
157
|
-
...argv,
|
|
158
|
-
...(published?.file == null ? [] : ["--artifacts", published.file]),
|
|
159
|
-
],
|
|
160
|
-
{
|
|
161
|
-
stdio: "inherit",
|
|
162
|
-
windowsHide: true,
|
|
163
|
-
},
|
|
164
|
-
);
|
|
165
|
-
if (result.error) {
|
|
166
|
-
process.stderr.write(`@ttsc/graph: ${result.error.message}\n`);
|
|
167
|
-
return 1;
|
|
168
|
-
}
|
|
169
|
-
return result.status ?? 1;
|
|
170
|
-
}
|
|
16
|
+
export { TtscGraphSession } from "./model/TtscGraphSession";
|
|
17
|
+
export type { TtscGraphRequestOptions } from "./model/TtscGraphRequestOptions";
|
|
18
|
+
export type { TtscGraphSessionOptions } from "./model/TtscGraphSessionOptions";
|
|
19
|
+
export { runGraph } from "./runGraph";
|