@ttsc/graph 0.19.3 → 0.20.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/lib/TtscGraphApplication.js +3 -1
- package/lib/TtscGraphApplication.js.map +1 -1
- package/lib/bin.js +15 -3
- package/lib/bin.js.map +1 -1
- package/lib/index.d.ts +13 -2
- package/lib/index.js +24 -30
- package/lib/index.js.map +1 -1
- package/lib/launcherArgs.d.ts +24 -0
- package/lib/launcherArgs.js +136 -0
- package/lib/launcherArgs.js.map +1 -0
- package/lib/model/TtscGraphMemory.d.ts +9 -5
- package/lib/model/TtscGraphMemory.js +35 -58
- package/lib/model/TtscGraphMemory.js.map +1 -1
- package/lib/model/TtscGraphNodeId.d.ts +17 -0
- package/lib/model/TtscGraphNodeId.js +69 -0
- package/lib/model/TtscGraphNodeId.js.map +1 -0
- package/lib/model/TtscGraphSession.d.ts +23 -7
- package/lib/model/TtscGraphSession.js +402 -210
- package/lib/model/TtscGraphSession.js.map +1 -1
- package/lib/model/TtscGraphSourceReader.d.ts +27 -0
- package/lib/model/TtscGraphSourceReader.js +97 -0
- package/lib/model/TtscGraphSourceReader.js.map +1 -0
- package/lib/model/loadGraph.d.ts +4 -4
- package/lib/model/loadGraph.js +233 -168
- package/lib/model/loadGraph.js.map +1 -1
- package/lib/reduce.d.ts +4 -1
- package/lib/reduce.js +112 -29
- package/lib/reduce.js.map +1 -1
- package/lib/server/createServer.js +17 -6
- package/lib/server/createServer.js.map +1 -1
- package/lib/server/pathPolicy.d.ts +6 -0
- package/lib/server/pathPolicy.js +10 -1
- package/lib/server/pathPolicy.js.map +1 -1
- package/lib/server/resolveHandle.js +22 -18
- package/lib/server/resolveHandle.js.map +1 -1
- package/lib/server/resultAudit.d.ts +41 -20
- package/lib/server/resultAudit.js +62 -34
- package/lib/server/resultAudit.js.map +1 -1
- package/lib/server/resultNext.d.ts +5 -0
- package/lib/server/resultNext.js.map +1 -1
- package/lib/server/runDetails.d.ts +2 -2
- package/lib/server/runDetails.js +54 -108
- package/lib/server/runDetails.js.map +1 -1
- package/lib/server/runEntrypoints.js +1 -1
- package/lib/server/runEntrypoints.js.map +1 -1
- package/lib/server/runLookup.js +1 -1
- package/lib/server/runLookup.js.map +1 -1
- package/lib/server/runTour.js +113 -30
- package/lib/server/runTour.js.map +1 -1
- package/lib/server/runTrace.d.ts +22 -0
- package/lib/server/runTrace.js +293 -63
- package/lib/server/runTrace.js.map +1 -1
- package/lib/structures/ITtscGraphDump.d.ts +13 -13
- package/lib/structures/ITtscGraphNode.d.ts +34 -0
- package/lib/structures/ITtscGraphTrace.d.ts +1 -1
- package/lib/view.js +18 -28
- package/lib/view.js.map +1 -1
- package/package.json +5 -5
- package/src/TtscGraphApplication.ts +5 -1
- package/src/bin.ts +13 -3
- package/src/index.ts +34 -27
- package/src/launcherArgs.ts +168 -0
- package/src/model/TtscGraphMemory.ts +34 -60
- package/src/model/TtscGraphNodeId.ts +77 -0
- package/src/model/TtscGraphSession.ts +228 -55
- package/src/model/TtscGraphSourceReader.ts +117 -0
- package/src/model/loadGraph.ts +4 -4
- package/src/reduce.ts +136 -31
- package/src/server/createServer.ts +12 -2
- package/src/server/pathPolicy.ts +10 -1
- package/src/server/resolveHandle.ts +21 -22
- package/src/server/resultAudit.ts +64 -33
- package/src/server/resultNext.ts +6 -0
- package/src/server/runDetails.ts +57 -113
- package/src/server/runEntrypoints.ts +1 -1
- package/src/server/runLookup.ts +1 -1
- package/src/server/runTour.ts +133 -39
- package/src/server/runTrace.ts +401 -65
- package/src/structures/ITtscGraphDump.ts +13 -13
- package/src/structures/ITtscGraphNode.ts +40 -0
- package/src/structures/ITtscGraphTrace.ts +1 -1
- package/src/view.ts +25 -23
|
@@ -76,11 +76,34 @@ export interface ITtscGraphNode {
|
|
|
76
76
|
* holds instead of minting one per member.
|
|
77
77
|
*/
|
|
78
78
|
enumMembers?: ITtscGraphNode.IEnumMember[];
|
|
79
|
+
/**
|
|
80
|
+
* Direct, statically named members when this variable is initialized with an
|
|
81
|
+
* object literal, in declaration order.
|
|
82
|
+
*
|
|
83
|
+
* The native builder takes identity from the compiler AST and renders the
|
|
84
|
+
* compact signature from the same Program-owned source snapshot. A spread or
|
|
85
|
+
* dynamic computed name has no declaration name it can report soundly, so it
|
|
86
|
+
* contributes no fabricated member.
|
|
87
|
+
*/
|
|
88
|
+
objectMembers?: ITtscGraphNode.IObjectMember[];
|
|
79
89
|
/**
|
|
80
90
|
* Decorators written on this declaration, in source order: raw facts
|
|
81
91
|
* (`@Controller`, `@Get`) a consumer interprets without re-parsing source.
|
|
82
92
|
*/
|
|
83
93
|
decorators?: ITtscGraphDecorator[];
|
|
94
|
+
/**
|
|
95
|
+
* The declaration head, cut by the producer where the compiler says the body
|
|
96
|
+
* opens.
|
|
97
|
+
*
|
|
98
|
+
* Absent when the producer could not bound the head, in which case a consumer
|
|
99
|
+
* falls back to reading the declaration span. That fallback is a line scan,
|
|
100
|
+
* and a physical line is not a declaration boundary: it leaks implementation
|
|
101
|
+
* text when a declaration shares its line with its body, and it stops early
|
|
102
|
+
* when the head itself contains a brace — a type-literal parameter, an object
|
|
103
|
+
* return type, a destructured parameter. Prefer this field wherever it is
|
|
104
|
+
* present.
|
|
105
|
+
*/
|
|
106
|
+
signature?: string;
|
|
84
107
|
/** The declaration span, for display and signatures. */
|
|
85
108
|
evidence?: ITtscGraphEvidence;
|
|
86
109
|
/**
|
|
@@ -101,4 +124,15 @@ export declare namespace ITtscGraphNode {
|
|
|
101
124
|
*/
|
|
102
125
|
value?: string;
|
|
103
126
|
}
|
|
127
|
+
/** One direct, statically named member of an object-literal variable. */
|
|
128
|
+
interface IObjectMember {
|
|
129
|
+
/** The source-visible static property name. */
|
|
130
|
+
name: string;
|
|
131
|
+
/** Whether the declaration is a data property or callable/accessor member. */
|
|
132
|
+
kind: "property" | "method";
|
|
133
|
+
/** 1-based declaration line in the node's file, when source was available. */
|
|
134
|
+
line?: number;
|
|
135
|
+
/** Compact declaration outline rendered from the compiler source snapshot. */
|
|
136
|
+
signature?: string;
|
|
137
|
+
}
|
|
104
138
|
}
|
|
@@ -11,7 +11,7 @@ export interface ITtscGraphTrace {
|
|
|
11
11
|
hops: ITtscGraphTrace.IHop[];
|
|
12
12
|
/** Unique nodes reached (excluding the start), each with its depth and roles. */
|
|
13
13
|
reached: ITtscGraphTrace.INode[];
|
|
14
|
-
/**
|
|
14
|
+
/** In an open trace, true when a bound omitted an eligible node or hop. */
|
|
15
15
|
truncated: boolean;
|
|
16
16
|
/** The resolved `to` target, when a path was requested. */
|
|
17
17
|
target?: ITtscGraphTrace.INode;
|
package/lib/view.js
CHANGED
|
@@ -8,39 +8,29 @@ const node_child_process_1 = require("node:child_process");
|
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_http_1 = __importDefault(require("node:http"));
|
|
10
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const launcherArgs_1 = require("./launcherArgs");
|
|
11
12
|
const nativeExecutable_1 = require("./nativeExecutable");
|
|
12
13
|
const reduce_1 = require("./reduce");
|
|
13
14
|
const resolveGraphBinary_1 = require("./resolveGraphBinary");
|
|
14
15
|
function parseViewArgs(argv) {
|
|
15
|
-
const
|
|
16
|
-
cwd:
|
|
17
|
-
tsconfig: "tsconfig
|
|
18
|
-
port:
|
|
19
|
-
open:
|
|
20
|
-
|
|
16
|
+
const values = (0, launcherArgs_1.parseLauncherOptions)(argv, [
|
|
17
|
+
{ key: "cwd", flags: ["--cwd"], kind: "value" },
|
|
18
|
+
{ key: "tsconfig", flags: ["--tsconfig", "-p"], kind: "value" },
|
|
19
|
+
{ key: "port", flags: ["--port"], kind: "value" },
|
|
20
|
+
{ key: "open", flags: ["--no-open"], kind: "flag" },
|
|
21
|
+
{ key: "max_nodes", flags: ["--max-nodes"], kind: "value" },
|
|
22
|
+
]);
|
|
23
|
+
const project = (0, launcherArgs_1.projectOptions)(values);
|
|
24
|
+
return {
|
|
25
|
+
...project,
|
|
26
|
+
port: values.has("port") === true
|
|
27
|
+
? (0, launcherArgs_1.nonNegativeIntegerOption)(values, "port", 65535)
|
|
28
|
+
: 0,
|
|
29
|
+
open: values.get("open") !== true,
|
|
30
|
+
maxNodes: values.has("max_nodes") === true
|
|
31
|
+
? (0, launcherArgs_1.positiveIntegerOption)(values, "max_nodes", Number.MAX_SAFE_INTEGER)
|
|
32
|
+
: 1200,
|
|
21
33
|
};
|
|
22
|
-
for (let i = 0; i < argv.length; i++) {
|
|
23
|
-
const arg = argv[i];
|
|
24
|
-
if (arg === "--cwd")
|
|
25
|
-
opts.cwd = argv[++i] ?? opts.cwd;
|
|
26
|
-
else if (arg.startsWith("--cwd="))
|
|
27
|
-
opts.cwd = arg.slice("--cwd=".length);
|
|
28
|
-
else if (arg === "--tsconfig" || arg === "-p")
|
|
29
|
-
opts.tsconfig = argv[++i] ?? opts.tsconfig;
|
|
30
|
-
else if (arg.startsWith("--tsconfig="))
|
|
31
|
-
opts.tsconfig = arg.slice("--tsconfig=".length);
|
|
32
|
-
else if (arg === "--port")
|
|
33
|
-
opts.port = Number(argv[++i]);
|
|
34
|
-
else if (arg.startsWith("--port="))
|
|
35
|
-
opts.port = Number(arg.slice("--port=".length));
|
|
36
|
-
else if (arg === "--no-open")
|
|
37
|
-
opts.open = false;
|
|
38
|
-
else if (arg === "--max-nodes")
|
|
39
|
-
opts.maxNodes = Number(argv[++i]);
|
|
40
|
-
else if (arg.startsWith("--max-nodes="))
|
|
41
|
-
opts.maxNodes = Number(arg.slice("--max-nodes=".length));
|
|
42
|
-
}
|
|
43
|
-
return opts;
|
|
44
34
|
}
|
|
45
35
|
/**
|
|
46
36
|
* `ttsc-graph view`: build the project's code graph, reduce it, and serve a
|
package/lib/view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAsD;AACtD,sDAAyB;AACzB,0DAA6B;A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3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Checker-resolved architecture graph over MCP for coding agents, backed by ttsc's in-process TypeScript-Go compiler.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
19
|
-
"@typia/mcp": "13.
|
|
20
|
-
"typia": "13.
|
|
19
|
+
"@typia/mcp": "13.2.0",
|
|
20
|
+
"typia": "13.2.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"ttsc": "0.
|
|
23
|
+
"ttsc": "^0.20.0"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"ttsc",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"three": "^0.184.0",
|
|
43
43
|
"three-forcegraph": "^1.43.4",
|
|
44
44
|
"typescript": "^7.0.2",
|
|
45
|
-
"ttsc": "0.
|
|
45
|
+
"ttsc": "0.20.0"
|
|
46
46
|
},
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
@@ -2,6 +2,7 @@ import { TtscGraphMemory } from "./model/TtscGraphMemory";
|
|
|
2
2
|
import {
|
|
3
3
|
RESULT_AUDIT,
|
|
4
4
|
RESULT_AUDIT_DETAILS,
|
|
5
|
+
RESULT_AUDIT_DETAILS_CAPPED,
|
|
5
6
|
RESULT_AUDIT_ESCAPE,
|
|
6
7
|
RESULT_AUDIT_SELECTION,
|
|
7
8
|
} from "./server/resultAudit";
|
|
@@ -95,7 +96,10 @@ export class TtscGraphApplication implements ITtscGraphApplication {
|
|
|
95
96
|
// not the walk-bounded-and-marked shape RESULT_AUDIT states.
|
|
96
97
|
const r = runDetails(graph, props.request);
|
|
97
98
|
return {
|
|
98
|
-
audit:
|
|
99
|
+
audit:
|
|
100
|
+
r.membersCapped === true
|
|
101
|
+
? RESULT_AUDIT_DETAILS_CAPPED
|
|
102
|
+
: RESULT_AUDIT_DETAILS,
|
|
99
103
|
next: r.next,
|
|
100
104
|
result: r.result,
|
|
101
105
|
};
|
package/src/bin.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { runGraph } from "./index";
|
|
4
|
+
import { GraphArgumentError } from "./launcherArgs";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
try {
|
|
7
|
+
const code = runGraph(process.argv.slice(2));
|
|
8
|
+
if (typeof code === "number") {
|
|
9
|
+
process.exitCode = code;
|
|
10
|
+
}
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if (error instanceof GraphArgumentError) {
|
|
13
|
+
process.stderr.write(`@ttsc/graph: ${error.message}\n`);
|
|
14
|
+
process.exitCode = 2;
|
|
15
|
+
} else {
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
8
18
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import path from "node:path";
|
|
3
2
|
|
|
3
|
+
import {
|
|
4
|
+
PROJECT_OPTIONS,
|
|
5
|
+
parseLauncherOptions,
|
|
6
|
+
projectOptions,
|
|
7
|
+
} from "./launcherArgs";
|
|
4
8
|
import { ensureExecutable } from "./nativeExecutable";
|
|
5
9
|
import { resolveGraphBinary } from "./resolveGraphBinary";
|
|
6
10
|
import { startServer } from "./server/startServer";
|
|
@@ -10,6 +14,7 @@ import { runView } from "./view";
|
|
|
10
14
|
export {
|
|
11
15
|
RESULT_AUDIT,
|
|
12
16
|
RESULT_AUDIT_DETAILS,
|
|
17
|
+
RESULT_AUDIT_DETAILS_CAPPED,
|
|
13
18
|
RESULT_AUDIT_ESCAPE,
|
|
14
19
|
RESULT_AUDIT_SELECTION,
|
|
15
20
|
} from "./server/resultAudit";
|
|
@@ -19,34 +24,34 @@ export {
|
|
|
19
24
|
// project other than its own process directory names it once and the binary is
|
|
20
25
|
// found under that project's installed `ttsc`.
|
|
21
26
|
export { resolveGraphBinary } from "./resolveGraphBinary";
|
|
27
|
+
/**
|
|
28
|
+
* The viewer reduction the `view` command runs before serving a payload.
|
|
29
|
+
*
|
|
30
|
+
* Exported because it is one of three copies of the same pure transform — the
|
|
31
|
+
* website's uploaded-dump viewer and the benchmark viewer hold the others — and
|
|
32
|
+
* a shared policy that cannot be measured from outside the package drifts. It
|
|
33
|
+
* already did: two of them filtered git-ignored generated code and this one did
|
|
34
|
+
* not.
|
|
35
|
+
*/
|
|
36
|
+
export { reduce } from "./reduce";
|
|
37
|
+
export type { RawDump, RawEdge, RawNode, ViewerPayload } from "./reduce";
|
|
22
38
|
export { loadGraph } from "./model/loadGraph";
|
|
23
|
-
export {
|
|
39
|
+
export {
|
|
40
|
+
TtscGraphSession,
|
|
41
|
+
type TtscGraphRequestOptions,
|
|
42
|
+
type TtscGraphSessionOptions,
|
|
43
|
+
} from "./model/TtscGraphSession";
|
|
24
44
|
|
|
25
45
|
// The server version reported in the MCP handshake; read from this package.
|
|
26
46
|
const VERSION: string = (require("../package.json") as { version: string })
|
|
27
47
|
.version;
|
|
28
48
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
cwd: string;
|
|
36
|
-
tsconfig: string;
|
|
37
|
-
} {
|
|
38
|
-
let cwd = process.cwd();
|
|
39
|
-
let tsconfig = "tsconfig.json";
|
|
40
|
-
for (let i = 0; i < argv.length; i++) {
|
|
41
|
-
const arg = argv[i]!;
|
|
42
|
-
if (arg === "--cwd" && i + 1 < argv.length) cwd = argv[++i]!;
|
|
43
|
-
else if (arg.startsWith("--cwd=")) cwd = arg.slice("--cwd=".length);
|
|
44
|
-
else if (arg === "--tsconfig" && i + 1 < argv.length) tsconfig = argv[++i]!;
|
|
45
|
-
else if (arg.startsWith("--tsconfig="))
|
|
46
|
-
tsconfig = arg.slice("--tsconfig=".length);
|
|
47
|
-
}
|
|
48
|
-
return { cwd: path.resolve(cwd), tsconfig };
|
|
49
|
-
}
|
|
49
|
+
const DUMP_OPTIONS = [
|
|
50
|
+
{ key: "cwd", flags: ["--cwd", "-cwd"], kind: "value" },
|
|
51
|
+
{ key: "tsconfig", flags: ["--tsconfig", "-tsconfig"], kind: "value" },
|
|
52
|
+
{ key: "pretty", flags: ["--pretty", "-pretty"], kind: "boolean" },
|
|
53
|
+
{ key: "help", flags: ["--help", "-help", "-h"], kind: "flag" },
|
|
54
|
+
] as const;
|
|
50
55
|
|
|
51
56
|
/**
|
|
52
57
|
* Run the `@ttsc/graph` launcher.
|
|
@@ -63,9 +68,11 @@ export function runGraph(
|
|
|
63
68
|
argv: readonly string[] = process.argv.slice(2),
|
|
64
69
|
): number | void {
|
|
65
70
|
if (argv[0] === "view") return runView(argv.slice(1));
|
|
66
|
-
if (argv[0] === "dump") return runDump(argv);
|
|
71
|
+
if (argv[0] === "dump") return runDump(argv.slice(1));
|
|
67
72
|
|
|
68
|
-
const { cwd, tsconfig } =
|
|
73
|
+
const { cwd, tsconfig } = projectOptions(
|
|
74
|
+
parseLauncherOptions(argv, PROJECT_OPTIONS),
|
|
75
|
+
);
|
|
69
76
|
void startServer({ cwd, tsconfig, version: VERSION }).catch(
|
|
70
77
|
(error: unknown) => {
|
|
71
78
|
process.stderr.write(
|
|
@@ -83,7 +90,7 @@ export function runGraph(
|
|
|
83
90
|
function runDump(argv: readonly string[]): number {
|
|
84
91
|
// Resolve the native binary from the target project the caller named with
|
|
85
92
|
// `--cwd`, not from wherever the launcher process happened to start.
|
|
86
|
-
const { cwd } =
|
|
93
|
+
const { cwd } = projectOptions(parseLauncherOptions(argv, DUMP_OPTIONS));
|
|
87
94
|
const binary = resolveGraphBinary(process.env, cwd);
|
|
88
95
|
if (binary === null) {
|
|
89
96
|
process.stderr.write(
|
|
@@ -94,7 +101,7 @@ function runDump(argv: readonly string[]): number {
|
|
|
94
101
|
return 1;
|
|
95
102
|
}
|
|
96
103
|
ensureExecutable(binary);
|
|
97
|
-
const result = spawnSync(binary, [...argv], {
|
|
104
|
+
const result = spawnSync(binary, ["dump", ...argv], {
|
|
98
105
|
stdio: "inherit",
|
|
99
106
|
windowsHide: true,
|
|
100
107
|
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
export class GraphArgumentError extends Error {
|
|
4
|
+
public constructor(message: string) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "GraphArgumentError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type OptionKind = "value" | "flag" | "boolean";
|
|
11
|
+
|
|
12
|
+
export interface ILauncherOption {
|
|
13
|
+
key: string;
|
|
14
|
+
flags: readonly string[];
|
|
15
|
+
kind: OptionKind;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type ParsedLauncherOptions = ReadonlyMap<string, string | boolean>;
|
|
19
|
+
|
|
20
|
+
export interface IProjectOptions {
|
|
21
|
+
cwd: string;
|
|
22
|
+
tsconfig: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const PROJECT_OPTIONS: readonly ILauncherOption[] = [
|
|
26
|
+
{ key: "cwd", flags: ["--cwd"], kind: "value" },
|
|
27
|
+
{ key: "tsconfig", flags: ["--tsconfig"], kind: "value" },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
/** Parse one complete launcher argument vector and reject every unknown token. */
|
|
31
|
+
export function parseLauncherOptions(
|
|
32
|
+
argv: readonly string[],
|
|
33
|
+
definitions: readonly ILauncherOption[],
|
|
34
|
+
): ParsedLauncherOptions {
|
|
35
|
+
const flags = new Map<string, ILauncherOption>();
|
|
36
|
+
for (const definition of definitions) {
|
|
37
|
+
for (const flag of definition.flags) flags.set(flag, definition);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const parsed = new Map<string, string | boolean>();
|
|
41
|
+
for (let i = 0; i < argv.length; i++) {
|
|
42
|
+
const arg = argv[i]!;
|
|
43
|
+
const exact = flags.get(arg);
|
|
44
|
+
if (exact !== undefined) {
|
|
45
|
+
if (exact.kind === "value") {
|
|
46
|
+
const value = argv[++i];
|
|
47
|
+
if (value === undefined || value.startsWith("-")) {
|
|
48
|
+
throw new GraphArgumentError(`${arg} requires a non-empty value`);
|
|
49
|
+
}
|
|
50
|
+
parsed.set(exact.key, requireValue(arg, value));
|
|
51
|
+
} else {
|
|
52
|
+
parsed.set(exact.key, true);
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const equals = findEqualsOption(arg, flags);
|
|
58
|
+
if (equals === undefined) {
|
|
59
|
+
throw new GraphArgumentError(`unknown option ${arg}`);
|
|
60
|
+
}
|
|
61
|
+
const { definition, flag, value } = equals;
|
|
62
|
+
if (definition.kind === "flag") {
|
|
63
|
+
throw new GraphArgumentError(`${flag} does not take a value`);
|
|
64
|
+
}
|
|
65
|
+
if (definition.kind === "boolean") {
|
|
66
|
+
parsed.set(definition.key, parseBoolean(flag, value));
|
|
67
|
+
} else {
|
|
68
|
+
parsed.set(definition.key, requireValue(flag, value));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return parsed;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Resolve the two project-selection values shared by every launcher lane. */
|
|
75
|
+
export function projectOptions(values: ParsedLauncherOptions): IProjectOptions {
|
|
76
|
+
return {
|
|
77
|
+
cwd: path.resolve(stringValue(values, "cwd") ?? process.cwd()),
|
|
78
|
+
tsconfig: stringValue(values, "tsconfig") ?? "tsconfig.json",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Read a bounded non-negative integer option without JavaScript coercion. */
|
|
83
|
+
export function nonNegativeIntegerOption(
|
|
84
|
+
values: ParsedLauncherOptions,
|
|
85
|
+
key: string,
|
|
86
|
+
maximum: number,
|
|
87
|
+
): number {
|
|
88
|
+
const value = stringValue(values, key);
|
|
89
|
+
if (value === undefined) {
|
|
90
|
+
throw new Error(`Missing required parsed option ${key}`);
|
|
91
|
+
}
|
|
92
|
+
if (!/^\d+$/.test(value)) {
|
|
93
|
+
throw new GraphArgumentError(`${optionName(key)} must be an integer`);
|
|
94
|
+
}
|
|
95
|
+
const number = Number(value);
|
|
96
|
+
if (!Number.isSafeInteger(number) || number > maximum) {
|
|
97
|
+
throw new GraphArgumentError(
|
|
98
|
+
`${optionName(key)} must be between 0 and ${maximum}`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Read a bounded positive integer option without JavaScript coercion. */
|
|
105
|
+
export function positiveIntegerOption(
|
|
106
|
+
values: ParsedLauncherOptions,
|
|
107
|
+
key: string,
|
|
108
|
+
maximum: number,
|
|
109
|
+
): number {
|
|
110
|
+
const value = nonNegativeIntegerOption(values, key, maximum);
|
|
111
|
+
if (value === 0) {
|
|
112
|
+
throw new GraphArgumentError(`${optionName(key)} must be greater than 0`);
|
|
113
|
+
}
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function findEqualsOption(
|
|
118
|
+
arg: string,
|
|
119
|
+
flags: ReadonlyMap<string, ILauncherOption>,
|
|
120
|
+
): { definition: ILauncherOption; flag: string; value: string } | undefined {
|
|
121
|
+
for (const [flag, definition] of flags) {
|
|
122
|
+
const prefix = `${flag}=`;
|
|
123
|
+
if (arg.startsWith(prefix)) {
|
|
124
|
+
return { definition, flag, value: arg.slice(prefix.length) };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function requireValue(flag: string, value: string): string {
|
|
131
|
+
if (value.trim() === "") {
|
|
132
|
+
throw new GraphArgumentError(`${flag} requires a non-empty value`);
|
|
133
|
+
}
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function parseBoolean(flag: string, value: string): boolean {
|
|
138
|
+
switch (value) {
|
|
139
|
+
case "1":
|
|
140
|
+
case "t":
|
|
141
|
+
case "T":
|
|
142
|
+
case "TRUE":
|
|
143
|
+
case "true":
|
|
144
|
+
case "True":
|
|
145
|
+
return true;
|
|
146
|
+
case "0":
|
|
147
|
+
case "f":
|
|
148
|
+
case "F":
|
|
149
|
+
case "FALSE":
|
|
150
|
+
case "false":
|
|
151
|
+
case "False":
|
|
152
|
+
return false;
|
|
153
|
+
default:
|
|
154
|
+
throw new GraphArgumentError(`${flag} requires a boolean value`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function stringValue(
|
|
159
|
+
values: ParsedLauncherOptions,
|
|
160
|
+
key: string,
|
|
161
|
+
): string | undefined {
|
|
162
|
+
const value = values.get(key);
|
|
163
|
+
return typeof value === "string" ? value : undefined;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function optionName(key: string): string {
|
|
167
|
+
return `--${key.replaceAll("_", "-")}`;
|
|
168
|
+
}
|