ttsc 0.12.3 → 0.13.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.
Files changed (151) hide show
  1. package/cmd/platform/main.go +9 -0
  2. package/cmd/ttsc/api_compile.go +122 -101
  3. package/cmd/ttsc/api_compile_branches_test.go +55 -57
  4. package/cmd/ttsc/api_transform.go +67 -49
  5. package/cmd/ttsc/api_transform_branches_test.go +30 -32
  6. package/cmd/ttsc/build.go +141 -108
  7. package/cmd/ttsc/build_branches_test.go +95 -97
  8. package/cmd/ttsc/filter.go +70 -0
  9. package/cmd/ttsc/filter_strips_unknown_forwarded_flag_test.go +61 -0
  10. package/cmd/ttsc/flags_gen.go +30 -0
  11. package/cmd/ttsc/helpers_test.go +39 -28
  12. package/cmd/ttsc/main.go +111 -104
  13. package/cmd/ttsc/main_alias_branches_test.go +21 -23
  14. package/cmd/ttscserver/main.go +96 -90
  15. package/cmd/ttscserver/run_lsp_prefers_tsgo_flag_test.go +22 -22
  16. package/cmd/ttscserver/run_lsp_reports_server_error_test.go +22 -22
  17. package/cmd/ttscserver/run_lsp_uses_tsgo_environment_test.go +23 -23
  18. package/cmd/utility-host/main.go +30 -23
  19. package/driver/lsp.go +53 -7
  20. package/driver/plugins.go +88 -72
  21. package/driver/program.go +464 -340
  22. package/driver/rewrite.go +477 -380
  23. package/internal/lspserver/lsp_envelope.go +64 -64
  24. package/internal/lspserver/lsp_frame.go +60 -60
  25. package/internal/lspserver/lsp_plugin.go +57 -57
  26. package/internal/lspserver/lsp_proxy.go +265 -251
  27. package/internal/lspserver/lsp_server.go +155 -144
  28. package/lib/TtscCompiler.d.ts +7 -0
  29. package/lib/TtscCompiler.js +7 -0
  30. package/lib/TtscCompiler.js.map +1 -1
  31. package/lib/compiler/internal/buildNativeCompiler.d.ts +11 -1
  32. package/lib/compiler/internal/buildNativeCompiler.js +23 -3
  33. package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
  34. package/lib/compiler/internal/compileProjectInMemory.d.ts +9 -0
  35. package/lib/compiler/internal/compileProjectInMemory.js +36 -21
  36. package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
  37. package/lib/compiler/internal/paths.d.ts +27 -0
  38. package/lib/compiler/internal/paths.js +70 -0
  39. package/lib/compiler/internal/paths.js.map +1 -0
  40. package/lib/compiler/internal/project/readProjectConfig.d.ts +9 -1
  41. package/lib/compiler/internal/project/readProjectConfig.js +80 -1
  42. package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
  43. package/lib/compiler/internal/project/resolveProjectConfig.d.ts +13 -1
  44. package/lib/compiler/internal/project/resolveProjectConfig.js +42 -1
  45. package/lib/compiler/internal/project/resolveProjectConfig.js.map +1 -1
  46. package/lib/compiler/internal/resolveBinary.d.ts +9 -1
  47. package/lib/compiler/internal/resolveBinary.js +17 -1
  48. package/lib/compiler/internal/resolveBinary.js.map +1 -1
  49. package/lib/compiler/internal/resolveEmittedJavaScript.d.ts +16 -1
  50. package/lib/compiler/internal/resolveEmittedJavaScript.js +42 -10
  51. package/lib/compiler/internal/resolveEmittedJavaScript.js.map +1 -1
  52. package/lib/compiler/internal/resolveTsgo.d.ts +21 -1
  53. package/lib/compiler/internal/resolveTsgo.js +23 -1
  54. package/lib/compiler/internal/resolveTsgo.js.map +1 -1
  55. package/lib/compiler/internal/runBuild.d.ts +24 -4
  56. package/lib/compiler/internal/runBuild.js +355 -93
  57. package/lib/compiler/internal/runBuild.js.map +1 -1
  58. package/lib/compiler/internal/runSingleFileEmit.d.ts +10 -1
  59. package/lib/compiler/internal/runSingleFileEmit.js +14 -1
  60. package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
  61. package/lib/compiler/internal/sharedHostHelpers.d.ts +5 -0
  62. package/lib/compiler/internal/sharedHostHelpers.js +6 -2
  63. package/lib/compiler/internal/sharedHostHelpers.js.map +1 -1
  64. package/lib/compiler/internal/spawnNative.d.ts +21 -0
  65. package/lib/compiler/internal/spawnNative.js +59 -0
  66. package/lib/compiler/internal/spawnNative.js.map +1 -0
  67. package/lib/compiler/internal/transformProjectInMemory.d.ts +15 -1
  68. package/lib/compiler/internal/transformProjectInMemory.js +57 -61
  69. package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
  70. package/lib/flags/parser.d.ts +63 -0
  71. package/lib/flags/parser.js +254 -0
  72. package/lib/flags/parser.js.map +1 -0
  73. package/lib/flags/schema.d.ts +147 -0
  74. package/lib/flags/schema.js +405 -0
  75. package/lib/flags/schema.js.map +1 -0
  76. package/lib/launcher/internal/getCompilerVersionText.js +7 -0
  77. package/lib/launcher/internal/getCompilerVersionText.js.map +1 -1
  78. package/lib/launcher/internal/prepareExecution.js +35 -0
  79. package/lib/launcher/internal/prepareExecution.js.map +1 -1
  80. package/lib/launcher/internal/resolveCacheDir.d.ts +9 -0
  81. package/lib/launcher/internal/resolveCacheDir.js +22 -0
  82. package/lib/launcher/internal/resolveCacheDir.js.map +1 -0
  83. package/lib/launcher/internal/resolveTtscserverBinary.js +2 -0
  84. package/lib/launcher/internal/resolveTtscserverBinary.js.map +1 -1
  85. package/lib/launcher/internal/runTtsc.d.ts +10 -0
  86. package/lib/launcher/internal/runTtsc.js +90 -153
  87. package/lib/launcher/internal/runTtsc.js.map +1 -1
  88. package/lib/launcher/internal/runTtscserver.js +10 -35
  89. package/lib/launcher/internal/runTtscserver.js.map +1 -1
  90. package/lib/launcher/internal/runTtsx.d.ts +8 -0
  91. package/lib/launcher/internal/runTtsx.js +137 -79
  92. package/lib/launcher/internal/runTtsx.js.map +1 -1
  93. package/lib/plugin/internal/buildSourcePlugin.d.ts +38 -0
  94. package/lib/plugin/internal/buildSourcePlugin.js +40 -17
  95. package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
  96. package/lib/plugin/internal/loadProjectPlugins.d.ts +26 -0
  97. package/lib/plugin/internal/loadProjectPlugins.js +90 -41
  98. package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
  99. package/lib/structures/ITtscCompilerTransformation.d.ts +15 -2
  100. package/lib/structures/ITtscPlugin.d.ts +24 -0
  101. package/lib/structures/ITtscPluginCapabilities.d.ts +29 -0
  102. package/lib/structures/ITtscPluginCapabilities.js +3 -0
  103. package/lib/structures/ITtscPluginCapabilities.js.map +1 -0
  104. package/lib/structures/index.d.ts +1 -0
  105. package/lib/structures/index.js +1 -0
  106. package/lib/structures/index.js.map +1 -1
  107. package/lib/structures/internal/ITtscLoadedNativePlugin.d.ts +5 -0
  108. package/lib/structures/internal/TtscCommonOptions.d.ts +19 -0
  109. package/lib/structures/internal/TtscSingleFileEmitOptions.d.ts +0 -2
  110. package/package.json +9 -9
  111. package/shim/ast/shim.go +24 -0
  112. package/shim/checker/shim.go +35 -0
  113. package/shim/core/shim.go +17 -0
  114. package/shim/diagnosticwriter/shim.go +4 -0
  115. package/shim/lsp/shim.go +3 -3
  116. package/shim/printer/shim.go +20 -0
  117. package/src/TtscCompiler.ts +7 -0
  118. package/src/compiler/internal/buildNativeCompiler.ts +23 -3
  119. package/src/compiler/internal/compileProjectInMemory.ts +34 -25
  120. package/src/compiler/internal/paths.ts +68 -0
  121. package/src/compiler/internal/project/readProjectConfig.ts +86 -1
  122. package/src/compiler/internal/project/resolveProjectConfig.ts +44 -1
  123. package/src/compiler/internal/resolveBinary.ts +17 -1
  124. package/src/compiler/internal/resolveEmittedJavaScript.ts +43 -12
  125. package/src/compiler/internal/resolveTsgo.ts +29 -1
  126. package/src/compiler/internal/runBuild.ts +398 -112
  127. package/src/compiler/internal/runSingleFileEmit.ts +14 -1
  128. package/src/compiler/internal/sharedHostHelpers.ts +7 -7
  129. package/src/compiler/internal/spawnNative.ts +64 -0
  130. package/src/compiler/internal/transformProjectInMemory.ts +47 -67
  131. package/src/flags/parser.ts +367 -0
  132. package/src/flags/schema.ts +570 -0
  133. package/src/launcher/internal/getCompilerVersionText.ts +7 -0
  134. package/src/launcher/internal/prepareExecution.ts +35 -0
  135. package/src/launcher/internal/resolveCacheDir.ts +19 -0
  136. package/src/launcher/internal/resolveTtscserverBinary.ts +2 -0
  137. package/src/launcher/internal/runTtsc.ts +97 -143
  138. package/src/launcher/internal/runTtscserver.ts +9 -1
  139. package/src/launcher/internal/runTtsx.ts +149 -82
  140. package/src/plugin/internal/buildSourcePlugin.ts +40 -14
  141. package/src/plugin/internal/loadProjectPlugins.ts +116 -45
  142. package/src/structures/ITtscCompilerTransformation.ts +15 -2
  143. package/src/structures/ITtscPlugin.ts +26 -1
  144. package/src/structures/ITtscPluginCapabilities.ts +29 -0
  145. package/src/structures/index.ts +1 -0
  146. package/src/structures/internal/ITtscLoadedNativePlugin.ts +5 -0
  147. package/src/structures/internal/TtscCommonOptions.ts +19 -0
  148. package/src/structures/internal/TtscSingleFileEmitOptions.ts +0 -2
  149. package/tools/gen_shims/main.go +43 -8
  150. package/utility/flags_gen.go +30 -0
  151. package/utility/host.go +304 -245
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ // Schema-driven CLI parser used by both `runTtsc.ts` and `runTtsx.ts`.
3
+ //
4
+ // One engine, one schema. Each subcommand picks the subset of FLAG_SCHEMA it
5
+ // accepts and feeds it through `parseFlags`. The engine returns:
6
+ //
7
+ // * `values` — typed values for every consumed flag.
8
+ // * `passthrough` — flags ttsc did not consume but must forward verbatim
9
+ // to tsgo (or to native sidecars via `--tsgo-args`).
10
+ // * `positional` — bare non-flag tokens (file paths, entry files, …).
11
+ //
12
+ // The schema is the spec; behaviour at every layer boundary is determined by
13
+ // the FlagSpec attributes, not by ad-hoc `if (arg === "--foo")` branches.
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.parseFlags = parseFlags;
16
+ exports.getBoolean = getBoolean;
17
+ exports.getString = getString;
18
+ exports.getNumber = getNumber;
19
+ const schema_1 = require("./schema");
20
+ /**
21
+ * Parse `argv` according to FLAG_SCHEMA filtered by `subcommand`. Returns a
22
+ * `ParseResult`. Throws `Error` (with the configured prefix) on invalid
23
+ * input — unknown subcommand-only flag, missing required value, value that
24
+ * fails its validator.
25
+ */
26
+ function parseFlags(opts) {
27
+ const accepted = new Map();
28
+ for (const flag of (0, schema_1.flagsForSubcommand)(opts.subcommand)) {
29
+ // A flag enters the launcher's `accepted` set only when its
30
+ // `consumedBy` includes `"launcher"`. Flags consumed solely by tsgo
31
+ // or by native sidecars (e.g. `--showConfig`, `--listFilesOnly`)
32
+ // must fall through to `forwardKnownButUnaccepted` so the launcher
33
+ // forwards them verbatim instead of storing them in `values` where
34
+ // no consumer reads them back out. The previous shape — filter on
35
+ // `subcommands` only — silently dropped every tsgo-only terminal
36
+ // flag at the launcher boundary (the RC-1 / RC-2 class the schema
37
+ // is meant to make impossible).
38
+ if (!flag.consumedBy.includes("launcher"))
39
+ continue;
40
+ accepted.set(flag.name, flag);
41
+ for (const alias of flag.aliases ?? [])
42
+ accepted.set(alias, flag);
43
+ }
44
+ const values = new Map();
45
+ const passthrough = [];
46
+ const positional = [];
47
+ const tail = [];
48
+ let remainder = null;
49
+ if (opts.honorDoubleDashSeparator === true) {
50
+ const separator = opts.argv.indexOf("--");
51
+ if (separator !== -1) {
52
+ remainder = [...opts.argv.slice(separator + 1)];
53
+ }
54
+ }
55
+ const head = [
56
+ ...(remainder === null ? opts.argv : opts.argv.slice(0, indexOfSeparator(opts.argv))),
57
+ ];
58
+ let forwardingTail = false;
59
+ while (head.length !== 0) {
60
+ const current = head.shift();
61
+ if (forwardingTail) {
62
+ // Post-sentinel tokens belong to the user's program (e.g. the typia.ts
63
+ // entry's own argv: `ttsx typia.ts generate --input X`). They MUST NOT
64
+ // be forwarded to tsgo — the caller distinguishes `tail` from
65
+ // `passthrough` so script args never reach tsgo's option parser.
66
+ tail.push(current);
67
+ continue;
68
+ }
69
+ // `--foo=value` / `-p=value` form: split before resolving against the
70
+ // schema. Both long (`--foo`) and short (`-p`) aliases support the
71
+ // inline-value shape — without splitting the short form, `-p=value`
72
+ // would fall through as an unknown token and be forwarded to tsgo,
73
+ // bypassing the launcher's own consumer (e.g. plugin discovery against
74
+ // the wrong project root).
75
+ const equalsIndex = current.startsWith("-") ? current.indexOf("=") : -1;
76
+ const token = equalsIndex === -1 ? current : current.slice(0, equalsIndex);
77
+ const inlineValue = equalsIndex === -1 ? undefined : current.slice(equalsIndex + 1);
78
+ const flag = accepted.get(token);
79
+ if (flag !== undefined) {
80
+ consumeFlag(values, flag, token, inlineValue, head, opts.errorPrefix);
81
+ continue;
82
+ }
83
+ // Token IS a known flag but is not accepted by THIS subcommand. The
84
+ // engine forwards it to tsgo just like an unknown flag — the same
85
+ // policy the bare-lane parser applied (RC-1 prevention).
86
+ const globalFlag = schema_1.FLAG_BY_NAME.get(token);
87
+ if (globalFlag !== undefined) {
88
+ forwardKnownButUnaccepted(passthrough, globalFlag, current, inlineValue, head);
89
+ continue;
90
+ }
91
+ // Truly unknown `-`-prefixed token: forward to tsgo verbatim. This
92
+ // is what makes `ttsc --strict file.ts` work — ttsc does not need to
93
+ // re-implement every tsgo flag.
94
+ if (current.startsWith("-")) {
95
+ passthrough.push(current);
96
+ continue;
97
+ }
98
+ // Bare token: positional argument (file / entry / project path).
99
+ positional.push(current);
100
+ if (opts.forwardAfterFirstPositional === true &&
101
+ positional.length === 1) {
102
+ forwardingTail = true;
103
+ }
104
+ }
105
+ if (remainder !== null) {
106
+ // `--` separator: everything after goes to the user program when we are
107
+ // in tail mode (ttsx after the entry), otherwise to tsgo as passthrough.
108
+ const sink = forwardingTail ? tail : passthrough;
109
+ for (const token of remainder)
110
+ sink.push(token);
111
+ }
112
+ return { values, passthrough, positional, tail };
113
+ }
114
+ /**
115
+ * Pull the value for `flag` from either `inlineValue` (`--flag=value`) or
116
+ * the next argv token (`--flag value`), validate it per the schema, and
117
+ * write it to the result map.
118
+ */
119
+ function consumeFlag(values, flag, token, inlineValue, rest, errorPrefix) {
120
+ if (flag.kind === "boolean") {
121
+ if (inlineValue !== undefined) {
122
+ // `--flag=false` / `--flag=true` inline form. Anything other than
123
+ // a recognised literal stays loud: `--singleThreaded=yes` silently
124
+ // becoming `true` is the kind of footgun the RCA's RC-4 class
125
+ // covers. Mirrors `validatePositiveInt`'s style.
126
+ const literal = parseBooleanLiteral(inlineValue);
127
+ if (literal === undefined) {
128
+ throw new Error(`${errorPrefix} ${token} expects \`true\` or \`false\`, got ${JSON.stringify(inlineValue)}`);
129
+ }
130
+ values.set(flag.name, literal);
131
+ return;
132
+ }
133
+ // Space form `--flag true` / `--flag false`: peek the next token and
134
+ // consume it only when it parses as a boolean literal. tsgo accepts
135
+ // this shape natively; the launcher must mirror it so `ttsc --noEmit
136
+ // false` does not corrupt argv (positional sink getting `false`,
137
+ // tsgo seeing it as a stray input file).
138
+ if (rest.length > 0) {
139
+ const peek = parseBooleanLiteral(rest[0]);
140
+ if (peek !== undefined) {
141
+ rest.shift();
142
+ values.set(flag.name, peek);
143
+ return;
144
+ }
145
+ }
146
+ values.set(flag.name, true);
147
+ return;
148
+ }
149
+ const raw = inlineValue !== undefined ? inlineValue : takeValueToken(token, rest, errorPrefix);
150
+ if (flag.validator === "positiveInt") {
151
+ values.set(flag.name, validatePositiveInt(token, raw, errorPrefix));
152
+ return;
153
+ }
154
+ values.set(flag.name, raw);
155
+ }
156
+ /**
157
+ * Read the value token that follows `flag`. Throws if argv ends here OR if
158
+ * the next token looks like another flag (`-` prefix). Without the
159
+ * "looks like a flag" guard `ttsc --cwd --strict src/main.ts` would silently
160
+ * consume `--strict` as the value of `--cwd`, leaving `--strict` lost and
161
+ * `cwd` set to a junk path. Mirrors the symmetric guard already in
162
+ * `forwardKnownButUnaccepted` (RC-1 fairness — the two value-resolution
163
+ * paths must agree on what counts as "a missing value").
164
+ */
165
+ function takeValueToken(flag, rest, errorPrefix) {
166
+ const value = rest.shift();
167
+ if (value === undefined) {
168
+ throw new Error(`${errorPrefix} ${flag} requires a value`);
169
+ }
170
+ if (value.startsWith("-")) {
171
+ // Put it back so the next loop iteration parses it as its own flag.
172
+ rest.unshift(value);
173
+ throw new Error(`${errorPrefix} ${flag} requires a value (next token ${JSON.stringify(value)} starts with "-")`);
174
+ }
175
+ return value;
176
+ }
177
+ /**
178
+ * Parse a CLI boolean literal — `true`/`false` only (case-sensitive to
179
+ * match tsgo's parser). Returns `undefined` for any other token so the
180
+ * caller knows to throw or treat as a non-value.
181
+ */
182
+ function parseBooleanLiteral(raw) {
183
+ if (raw === "true")
184
+ return true;
185
+ if (raw === "false")
186
+ return false;
187
+ return undefined;
188
+ }
189
+ /**
190
+ * Validate a `positiveInt` value. Mirrors tsgo's `--checkers minValue:1`
191
+ * constraint so a typo fails loudly at the launcher rather than reaching
192
+ * tsgo with an invalid argument.
193
+ */
194
+ function validatePositiveInt(flag, raw, errorPrefix) {
195
+ const value = Number(raw);
196
+ if (!Number.isInteger(value) || value < 1) {
197
+ throw new Error(`${errorPrefix} ${flag} expects a positive integer, got ${JSON.stringify(raw)}`);
198
+ }
199
+ return value;
200
+ }
201
+ /**
202
+ * Forward a flag the schema knows about but the current subcommand does
203
+ * not accept. The launcher will hand it to tsgo (or to native sidecars
204
+ * via `--tsgo-args`); without this branch the parser would lose the
205
+ * value token of a `--flag value` pair.
206
+ */
207
+ function forwardKnownButUnaccepted(passthrough, flag, original, inlineValue, rest) {
208
+ passthrough.push(original);
209
+ // Boolean flags carry no value. `--foo=value` already encodes the value
210
+ // inline. Otherwise the next argv token is the flag's value: keep it
211
+ // adjacent so tsgo receives the pair intact.
212
+ if (flag.kind === "boolean" || inlineValue !== undefined) {
213
+ return;
214
+ }
215
+ if (rest.length === 0)
216
+ return;
217
+ if (rest[0].startsWith("-"))
218
+ return;
219
+ passthrough.push(rest.shift());
220
+ }
221
+ /**
222
+ * Return the index of the `--` separator in `argv`, or `argv.length` when
223
+ * absent. The parser slices on this index when honorDoubleDashSeparator.
224
+ */
225
+ function indexOfSeparator(argv) {
226
+ const index = argv.indexOf("--");
227
+ return index === -1 ? argv.length : index;
228
+ }
229
+ // -----------------------------------------------------------------------------
230
+ // Typed accessors. The parser stores raw values (string | boolean | number) so
231
+ // the engine stays untyped; callers pick the shape per flag.
232
+ // -----------------------------------------------------------------------------
233
+ /** Return the boolean value of `flag` or `undefined` if not present. */
234
+ function getBoolean(result, flag) {
235
+ const value = result.values.get(flag);
236
+ if (typeof value === "boolean")
237
+ return value;
238
+ return undefined;
239
+ }
240
+ /** Return the string value of `flag` or `undefined` if not present. */
241
+ function getString(result, flag) {
242
+ const value = result.values.get(flag);
243
+ if (typeof value === "string")
244
+ return value;
245
+ return undefined;
246
+ }
247
+ /** Return the numeric value of `flag` or `undefined` if not present. */
248
+ function getNumber(result, flag) {
249
+ const value = result.values.get(flag);
250
+ if (typeof value === "number")
251
+ return value;
252
+ return undefined;
253
+ }
254
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/flags/parser.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,EAAE;AACF,6EAA6E;AAC7E,iEAAiE;AACjE,EAAE;AACF,4DAA4D;AAC5D,2EAA2E;AAC3E,yEAAyE;AACzE,yEAAyE;AACzE,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;;;;;;AAO1E,qCAA4D;AAmD5D;;;;;GAKG;AACH,oBAA2B,IAAkB;IAC3C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC7C,KAAK,MAAM,IAAI,IAAI,IAAA,2BAAkB,EAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACvD,4DAA4D;QAC5D,oEAAoE;QACpE,iEAAiE;QACjE,mEAAmE;QACnE,mEAAmE;QACnE,kEAAkE;QAClE,iEAAiE;QACjE,kEAAkE;QAClE,gCAAgC;QAChC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC;YAAE,SAAS;QACpD,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,EAAE;YAAE,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C;AAC5C,CAAC;AAED,gFAAgF;AAChF,+EAA+E;AAC/E,6DAA6D;AAC7D,gFAAgF;AAEhF,wEAAwE;AACxE,oBACE,MAAmB,EACnB,IAAY;IAEZ,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,uEAAuE;AACvE,mBACE,MAAmB,EACnB,IAAY;IAEZ,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,wEAAwE;AACxE,mBACE,MAAmB,EACnB,IAAY;IAEZ,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Subcommands the ttsc CLI dispatches to. The bare `"ttsc"` entry covers the
3
+ * default lane (no explicit subcommand, e.g. `ttsc -p tsconfig.json`).
4
+ */
5
+ export type TtscSubcommand = "ttsc" | "build" | "check" | "fix" | "format" | "prepare" | "clean";
6
+ /**
7
+ * Subcommands the ttsx CLI dispatches to. ttsx exposes a single lane today
8
+ * but the schema mirrors ttsc's shape so future subcommands plug in without a
9
+ * second engine.
10
+ */
11
+ export type TtsxSubcommand = "ttsx";
12
+ export type AnySubcommand = TtscSubcommand | TtsxSubcommand;
13
+ /**
14
+ * Layers a flag can be consumed by. The order reflects the runtime pipeline:
15
+ *
16
+ * launcher → runBuild → tsgo / native sidecars (host, lint).
17
+ *
18
+ * A flag must declare at least one consumer. `forwardTo` declares where the
19
+ * flag travels when the consuming layer does not absorb it (e.g. ttsc-owned
20
+ * flags that the JS launcher consumes and re-emits as different tsgo flags).
21
+ */
22
+ export type FlagLayer = "launcher" | "runBuild" | "tsgo" | "host" | "lint";
23
+ /**
24
+ * Argument shape of a flag.
25
+ *
26
+ * * `boolean` — `--flag` / `--flag=true` / `--flag=false`. No value
27
+ * token is consumed.
28
+ * * `value` — `--flag value` or `--flag=value`. Required value.
29
+ * * `valueOptional` — `--flag` standalone is allowed; if followed by a
30
+ * non-flag token that token is consumed as the value.
31
+ * (Currently unused — declared for future flags like
32
+ * `--watch [path]`.)
33
+ */
34
+ export type FlagKind = "boolean" | "value" | "valueOptional";
35
+ /**
36
+ * Validation predicate for `value`-kind flags. `none` is the default
37
+ * (accept any string).
38
+ */
39
+ export type ValueValidator = "none" | "positiveInt";
40
+ /**
41
+ * One CLI flag's complete contract. Every layer's behaviour is structural —
42
+ * which subcommands accept the flag, where it is consumed, where it is
43
+ * forwarded, whether it is terminal (prints and exits) — so the next layer
44
+ * never silently drops the flag.
45
+ */
46
+ export interface FlagSpec {
47
+ /**
48
+ * Canonical flag name including leading dashes (`"--singleThreaded"`). The
49
+ * generator uses this as the map key in the Go allow-list and as the first
50
+ * column of the docs table.
51
+ */
52
+ readonly name: string;
53
+ /**
54
+ * Alternative spellings (`"-p"`, `"--project"` for `--tsconfig`). The
55
+ * parsing engine treats every alias as an equivalent of `name`.
56
+ */
57
+ readonly aliases?: readonly string[];
58
+ /** Argument shape: boolean / required value / optional value. */
59
+ readonly kind: FlagKind;
60
+ /**
61
+ * For `value` flags: optional validator. `positiveInt` mirrors the
62
+ * `--checkers minValue:1` constraint tsgo enforces.
63
+ */
64
+ readonly validator?: ValueValidator;
65
+ /** Subcommands that accept this flag. */
66
+ readonly subcommands: readonly AnySubcommand[];
67
+ /**
68
+ * Layers that read the flag into a typed option. Order matters only for
69
+ * documentation; the parsing engine merges across layers.
70
+ */
71
+ readonly consumedBy: readonly FlagLayer[];
72
+ /**
73
+ * Where the flag travels when the consuming layer does not absorb it.
74
+ * Default for any flag a layer does not consume is `"tsgo"` — i.e. the
75
+ * launcher forwards an unknown flag to tsgo via passthrough. Setting this
76
+ * to `undefined` while `consumedBy: ["launcher"]` is set means the flag is
77
+ * intentionally consumed-not-forwarded (e.g. ttsc-internal `--binary`).
78
+ */
79
+ readonly forwardTo?: FlagLayer;
80
+ /**
81
+ * Terminal flags ask the underlying tool to print something and exit
82
+ * (`--help`, `--version`, `--showConfig`, `--listFilesOnly`, `--all`,
83
+ * `--init`). ttsc must not wrap them in a pre-emit pass — that is how the
84
+ * `--showConfig prints twice` bug appeared (RC-2).
85
+ */
86
+ readonly terminal?: boolean;
87
+ /**
88
+ * `true` when ttsc may add this flag to tsgo internally and post-process
89
+ * the output. If the user also forwards the same flag, ttsc keeps the
90
+ * user-visible behaviour (no double-print, no swallowed output). The
91
+ * shadow check is structural rather than `passthrough.includes("…")`.
92
+ *
93
+ * Currently true for `--listEmittedFiles`, `--noEmit`, `--pretty`.
94
+ */
95
+ readonly internalShadow?: boolean;
96
+ /**
97
+ * Reserved for future use: native hosts that opt in via
98
+ * `capabilities.threadingArgs`. The flag travels to such hosts as a bare
99
+ * CLI argument; everything else routes through `--tsgo-args`.
100
+ */
101
+ readonly nativeCapability?: "threadingArgs";
102
+ /** Human description for `--help` and the docs table. */
103
+ readonly description: string;
104
+ }
105
+ /**
106
+ * Single source of truth for every flag the ttsc / ttsx CLI accepts. New
107
+ * flags are added here and only here; the generator rebuilds the parsers and
108
+ * the Go allow-lists from this table.
109
+ *
110
+ * Constraints enforced by the parser and the generator:
111
+ *
112
+ * 1. Every flag is uniquely identified by `name`; aliases must not collide
113
+ * with other flags' `name` or `aliases`.
114
+ * 2. A flag listed in `consumedBy: ["launcher"]` without a `forwardTo`
115
+ * consumes-not-forwards. The generator flags this in the docs and the
116
+ * Go allow-list so the boundary is explicit.
117
+ * 3. A flag with `subcommands` covering `clean` or `prepare` is parsed by
118
+ * the project-args lane; the parsing engine accepts the same flag in
119
+ * build / check / fix / format without a separate parser.
120
+ */
121
+ export declare const FLAG_SCHEMA: readonly FlagSpec[];
122
+ /**
123
+ * Lookup of `name` and every alias → its canonical FlagSpec. Built once at
124
+ * module load so the parsing engine has O(1) flag resolution.
125
+ */
126
+ export declare const FLAG_BY_NAME: ReadonlyMap<string, FlagSpec>;
127
+ /**
128
+ * Terminal flags as a derived set. Used by `runBuild.ts` to skip the
129
+ * pre-emit pass when one is present.
130
+ */
131
+ export declare const TERMINAL_FLAGS: ReadonlySet<string>;
132
+ /**
133
+ * `internalShadow: true` flags as a derived set. Used by `runBuild.ts` to
134
+ * detect a user-forwarded copy of a flag ttsc adds internally so the
135
+ * post-processor does not eat the user's output.
136
+ */
137
+ export declare const INTERNAL_SHADOW_FLAGS: ReadonlySet<string>;
138
+ /** Tokens (canonical name + aliases) accepted in `subcommand`. */
139
+ export declare function flagsForSubcommand(subcommand: AnySubcommand): FlagSpec[];
140
+ /**
141
+ * Allow-list map for the Go layer named `layer` (`"host"` or `"lint"`):
142
+ * flag-name (no leading dashes) → whether the flag takes a value token.
143
+ * The generator emits a literal Go map with the same shape, but this
144
+ * function is the runtime equivalent — used in tests to verify the
145
+ * generated Go matches the schema.
146
+ */
147
+ export declare function buildGoAllowList(layer: "host" | "lint"): Map<string, boolean>;