ttsc 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,8 +33,8 @@ export type TtscSubcommand =
33
33
  | "clean";
34
34
 
35
35
  /**
36
- * Subcommands the ttsx CLI dispatches to. ttsx exposes a single lane today
37
- * but the schema mirrors ttsc's shape so future subcommands plug in without a
36
+ * Subcommands the ttsx CLI dispatches to. ttsx exposes a single lane today but
37
+ * the schema mirrors ttsc's shape so future subcommands plug in without a
38
38
  * second engine.
39
39
  */
40
40
  export type TtsxSubcommand = "ttsx";
@@ -44,7 +44,7 @@ export type AnySubcommand = TtscSubcommand | TtsxSubcommand;
44
44
  /**
45
45
  * Layers a flag can be consumed by. The order reflects the runtime pipeline:
46
46
  *
47
- * launcher → runBuild → tsgo / native sidecars (host, lint).
47
+ * Launcher → runBuild → tsgo / native sidecars (host, lint).
48
48
  *
49
49
  * A flag must declare at least one consumer. `forwardTo` declares where the
50
50
  * flag travels when the consuming layer does not absorb it (e.g. ttsc-owned
@@ -60,19 +60,18 @@ export type FlagLayer =
60
60
  /**
61
61
  * Argument shape of a flag.
62
62
  *
63
- * * `boolean` — `--flag` / `--flag=true` / `--flag=false`. No value
64
- * token is consumed.
65
- * * `value` — `--flag value` or `--flag=value`. Required value.
66
- * * `valueOptional` — `--flag` standalone is allowed; if followed by a
67
- * non-flag token that token is consumed as the value.
68
- * (Currently unused — declared for future flags like
69
- * `--watch [path]`.)
63
+ * - `boolean` — `--flag` / `--flag=true` / `--flag=false`. No value token is
64
+ * consumed.
65
+ * - `value` — `--flag value` or `--flag=value`. Required value.
66
+ * - `valueOptional` — `--flag` standalone is allowed; if followed by a non-flag
67
+ * token that token is consumed as the value. (Currently unused — declared for
68
+ * future flags like `--watch [path]`.)
70
69
  */
71
70
  export type FlagKind = "boolean" | "value" | "valueOptional";
72
71
 
73
72
  /**
74
- * Validation predicate for `value`-kind flags. `none` is the default
75
- * (accept any string).
73
+ * Validation predicate for `value`-kind flags. `none` is the default (accept
74
+ * any string).
76
75
  */
77
76
  export type ValueValidator = "none" | "positiveInt";
78
77
 
@@ -91,8 +90,8 @@ export interface FlagSpec {
91
90
  readonly name: string;
92
91
 
93
92
  /**
94
- * Alternative spellings (`"-p"`, `"--project"` for `--tsconfig`). The
95
- * parsing engine treats every alias as an equivalent of `name`.
93
+ * Alternative spellings (`"-p"`, `"--project"` for `--tsconfig`). The parsing
94
+ * engine treats every alias as an equivalent of `name`.
96
95
  */
97
96
  readonly aliases?: readonly string[];
98
97
 
@@ -115,10 +114,10 @@ export interface FlagSpec {
115
114
  readonly consumedBy: readonly FlagLayer[];
116
115
 
117
116
  /**
118
- * Where the flag travels when the consuming layer does not absorb it.
119
- * Default for any flag a layer does not consume is `"tsgo"` — i.e. the
120
- * launcher forwards an unknown flag to tsgo via passthrough. Setting this
121
- * to `undefined` while `consumedBy: ["launcher"]` is set means the flag is
117
+ * Where the flag travels when the consuming layer does not absorb it. Default
118
+ * for any flag a layer does not consume is `"tsgo"` — i.e. the launcher
119
+ * forwards an unknown flag to tsgo via passthrough. Setting this to
120
+ * `undefined` while `consumedBy: ["launcher"]` is set means the flag is
122
121
  * intentionally consumed-not-forwarded (e.g. ttsc-internal `--binary`).
123
122
  */
124
123
  readonly forwardTo?: FlagLayer;
@@ -132,41 +131,41 @@ export interface FlagSpec {
132
131
  readonly terminal?: boolean;
133
132
 
134
133
  /**
135
- * `true` when ttsc may add this flag to tsgo internally and post-process
136
- * the output. If the user also forwards the same flag, ttsc keeps the
137
- * user-visible behaviour (no double-print, no swallowed output). The
138
- * shadow check is structural rather than `passthrough.includes("…")`.
134
+ * `true` when ttsc may add this flag to tsgo internally and post-process the
135
+ * output. If the user also forwards the same flag, ttsc keeps the
136
+ * user-visible behaviour (no double-print, no swallowed output). The shadow
137
+ * check is structural rather than `passthrough.includes("…")`.
139
138
  *
140
139
  * Currently true for `--listEmittedFiles`, `--noEmit`, `--pretty`.
141
140
  */
142
141
  readonly internalShadow?: boolean;
143
142
 
144
143
  /**
145
- * Reserved for future use: native hosts that opt in via
146
- * `capabilities.threadingArgs`. The flag travels to such hosts as a bare
147
- * CLI argument; everything else routes through `--tsgo-args`.
144
+ * Native sidecar capability that must be declared before ttsc sends this flag
145
+ * as a bare CLI argument. Everything else routes through `--tsgo-args` or
146
+ * stays in the JS launcher.
148
147
  */
149
- readonly nativeCapability?: "threadingArgs";
148
+ readonly nativeCapability?: "diagnosticsTiming" | "threadingArgs";
150
149
 
151
150
  /** Human description for `--help` and the docs table. */
152
151
  readonly description: string;
153
152
  }
154
153
 
155
154
  /**
156
- * Single source of truth for every flag the ttsc / ttsx CLI accepts. New
157
- * flags are added here and only here; the generator rebuilds the parsers and
158
- * the Go allow-lists from this table.
155
+ * Single source of truth for every flag the ttsc / ttsx CLI accepts. New flags
156
+ * are added here and only here; the generator rebuilds the parsers and the Go
157
+ * allow-lists from this table.
159
158
  *
160
159
  * Constraints enforced by the parser and the generator:
161
160
  *
162
- * 1. Every flag is uniquely identified by `name`; aliases must not collide
163
- * with other flags' `name` or `aliases`.
164
- * 2. A flag listed in `consumedBy: ["launcher"]` without a `forwardTo`
165
- * consumes-not-forwards. The generator flags this in the docs and the
166
- * Go allow-list so the boundary is explicit.
167
- * 3. A flag with `subcommands` covering `clean` or `prepare` is parsed by
168
- * the project-args lane; the parsing engine accepts the same flag in
169
- * build / check / fix / format without a separate parser.
161
+ * 1. Every flag is uniquely identified by `name`; aliases must not collide with
162
+ * other flags' `name` or `aliases`.
163
+ * 2. A flag listed in `consumedBy: ["launcher"]` without a `forwardTo`
164
+ * consumes-not-forwards. The generator flags this in the docs and the Go
165
+ * allow-list so the boundary is explicit.
166
+ * 3. A flag with `subcommands` covering `clean` or `prepare` is parsed by the
167
+ * project-args lane; the parsing engine accepts the same flag in build /
168
+ * check / fix / format without a separate parser.
170
169
  */
171
170
  export const FLAG_SCHEMA: readonly FlagSpec[] = [
172
171
  // -------------------------------------------------------------------------
@@ -391,6 +390,26 @@ export const FLAG_SCHEMA: readonly FlagSpec[] = [
391
390
  internalShadow: true,
392
391
  description: "Toggle tsgo pretty-printed diagnostics (forwarded to tsgo).",
393
392
  },
393
+ {
394
+ name: "--diagnostics",
395
+ kind: "boolean",
396
+ subcommands: ["ttsc", "ttsx", "build", "check", "fix", "format"],
397
+ consumedBy: ["runBuild", "tsgo", "lint"],
398
+ forwardTo: "tsgo",
399
+ nativeCapability: "diagnosticsTiming",
400
+ description:
401
+ "Print compiler performance information; plugin-backed ttsc runs add plugin wall-clock timings.",
402
+ },
403
+ {
404
+ name: "--extendedDiagnostics",
405
+ kind: "boolean",
406
+ subcommands: ["ttsc", "ttsx", "build", "check", "fix", "format"],
407
+ consumedBy: ["runBuild", "tsgo", "lint"],
408
+ forwardTo: "tsgo",
409
+ nativeCapability: "diagnosticsTiming",
410
+ description:
411
+ "Print detailed compiler performance information; plugin-backed ttsc runs add plugin wall-clock timings.",
412
+ },
394
413
  {
395
414
  name: "--showConfig",
396
415
  kind: "boolean",
@@ -516,8 +535,8 @@ function register(
516
535
  }
517
536
 
518
537
  /**
519
- * Terminal flags as a derived set. Used by `runBuild.ts` to skip the
520
- * pre-emit pass when one is present.
538
+ * Terminal flags as a derived set. Used by `runBuild.ts` to skip the pre-emit
539
+ * pass when one is present.
521
540
  */
522
541
  export const TERMINAL_FLAGS: ReadonlySet<string> = new Set(
523
542
  FLAG_SCHEMA.flatMap((flag) =>
@@ -543,10 +562,10 @@ export function flagsForSubcommand(subcommand: AnySubcommand): FlagSpec[] {
543
562
 
544
563
  /**
545
564
  * Allow-list map for the Go layer named `layer` (`"host"` or `"lint"`):
546
- * flag-name (no leading dashes) → whether the flag takes a value token.
547
- * The generator emits a literal Go map with the same shape, but this
548
- * function is the runtime equivalent — used in tests to verify the
549
- * generated Go matches the schema.
565
+ * flag-name (no leading dashes) → whether the flag takes a value token. The
566
+ * generator emits a literal Go map with the same shape, but this function is
567
+ * the runtime equivalent — used in tests to verify the generated Go matches the
568
+ * schema.
550
569
  */
551
570
  export function buildGoAllowList(layer: "host" | "lint"): Map<string, boolean> {
552
571
  const out = new Map<string, boolean>();
@@ -9,19 +9,31 @@
9
9
  * silently dropping the flag for anything else.
10
10
  *
11
11
  * Every field is optional and defaults to `false`. Plugin authors opt in by
12
- * setting only the capabilities their sidecar actually implements; ttsc
13
- * keeps the conservative default for everything else.
12
+ * setting only the capabilities their sidecar actually implements; ttsc keeps
13
+ * the conservative default for everything else.
14
14
  */
15
15
  export interface ITtscPluginCapabilities {
16
+ /**
17
+ * Whether the sidecar accepts `--diagnostics` and `--extendedDiagnostics` on
18
+ * its command line and may print plugin-owned timing detail to stdout.
19
+ *
20
+ * When `false` (the default), ttsc keeps diagnostics flags out of native
21
+ * sidecar argv so older strict hosts do not reject them. The ttsc launcher
22
+ * still records the coarse sidecar wall-clock timing itself.
23
+ *
24
+ * @default false
25
+ */
26
+ diagnosticsTiming?: boolean;
27
+
16
28
  /**
17
29
  * Whether the sidecar accepts `--singleThreaded` and `--checkers` on its
18
- * command line. The lint sidecar parses both flags via
19
- * `parseSubcommandFlags` and threads them into `loadProgram` (parse phase)
20
- * and `engine.SetSerial` (rule walk); other check-stage hosts may not.
30
+ * command line. The lint sidecar parses both flags via `parseSubcommandFlags`
31
+ * and threads them into `loadProgram` (parse phase) and `engine.SetSerial`
32
+ * (rule walk); other check-stage hosts may not.
21
33
  *
22
- * When `false` (the default), ttsc strips both flags from the sidecar's
23
- * arg list — the conservative behavior that ad3443a restored after
24
- * `#113` over-forwarded them to typia/nestia hosts.
34
+ * When `false` (the default), ttsc strips both flags from the sidecar's arg
35
+ * list — the conservative behavior that ad3443a restored after `#113`
36
+ * over-forwarded them to typia/nestia hosts.
25
37
  *
26
38
  * @default false
27
39
  */