ttsc 0.18.4 → 0.19.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 (137) hide show
  1. package/README.md +5 -6
  2. package/cmd/graphbench/main.go +1 -1
  3. package/cmd/platform/main.go +1 -48
  4. package/cmd/ttsc/build_branches_test.go +5 -1
  5. package/cmd/ttsc/main.go +0 -50
  6. package/cmd/ttsc/main_alias_branches_test.go +6 -12
  7. package/cmd/ttscgraph/dump.go +13 -3
  8. package/cmd/ttscserver/main.go +5 -3
  9. package/driver/lsp.go +13 -1
  10. package/driver/plugins.go +35 -0
  11. package/driver/program.go +7 -8
  12. package/driver/rewrite.go +381 -21
  13. package/go.mod +1 -0
  14. package/internal/graph/build.go +297 -3
  15. package/internal/graph/build_records_a_node_per_top_level_declaration_test.go +16 -2
  16. package/internal/graph/diagnostics.go +5 -4
  17. package/internal/graph/dump.go +60 -4
  18. package/internal/graph/dump_is_a_function_of_the_source_test.go +71 -0
  19. package/internal/graph/dump_serializes_the_full_graph_test.go +16 -4
  20. package/internal/graph/edges.go +122 -11
  21. package/internal/graph/exports.go +74 -17
  22. package/internal/graph/graph.go +33 -1
  23. package/internal/graph/node_identity_is_position_invariant_test.go +4 -2
  24. package/internal/graph/resolve.go +24 -0
  25. package/internal/graphsymbols/provider.go +50 -14
  26. package/internal/lspserver/lsp_native_plugin_source.go +77 -23
  27. package/internal/lspserver/lsp_plugin.go +19 -2
  28. package/internal/lspserver/lsp_proxy.go +244 -52
  29. package/internal/lspserver/lsp_server.go +35 -27
  30. package/internal/lspserver/lsp_symbols.go +25 -16
  31. package/lib/TtscCompiler.d.ts +10 -0
  32. package/lib/TtscCompiler.js +24 -6
  33. package/lib/TtscCompiler.js.map +1 -1
  34. package/lib/TtscService.js +9 -7
  35. package/lib/TtscService.js.map +1 -1
  36. package/lib/compiler/internal/compileProjectInMemory.js +1 -0
  37. package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
  38. package/lib/compiler/internal/project/createNativeProjectContextArgs.d.ts +3 -0
  39. package/lib/compiler/internal/project/createNativeProjectContextArgs.js +14 -0
  40. package/lib/compiler/internal/project/createNativeProjectContextArgs.js.map +1 -0
  41. package/lib/compiler/internal/project/readProjectConfig.js +53 -4
  42. package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
  43. package/lib/compiler/internal/project/resolveProjectConfig.d.ts +9 -2
  44. package/lib/compiler/internal/project/resolveProjectConfig.js +45 -16
  45. package/lib/compiler/internal/project/resolveProjectConfig.js.map +1 -1
  46. package/lib/compiler/internal/residentTransformProcess.d.ts +16 -5
  47. package/lib/compiler/internal/residentTransformProcess.js +68 -20
  48. package/lib/compiler/internal/residentTransformProcess.js.map +1 -1
  49. package/lib/compiler/internal/runBuild.d.ts +11 -0
  50. package/lib/compiler/internal/runBuild.js +44 -8
  51. package/lib/compiler/internal/runBuild.js.map +1 -1
  52. package/lib/compiler/internal/runSingleFileEmit.js +7 -4
  53. package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
  54. package/lib/compiler/internal/sharedHostHelpers.d.ts +16 -0
  55. package/lib/compiler/internal/sharedHostHelpers.js +23 -0
  56. package/lib/compiler/internal/sharedHostHelpers.js.map +1 -1
  57. package/lib/compiler/internal/startResidentTransform.js +18 -1
  58. package/lib/compiler/internal/startResidentTransform.js.map +1 -1
  59. package/lib/compiler/internal/transformProjectInMemory.js +34 -8
  60. package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
  61. package/lib/flags/parser.d.ts +17 -0
  62. package/lib/flags/parser.js +11 -1
  63. package/lib/flags/parser.js.map +1 -1
  64. package/lib/flags/schema.js +7 -0
  65. package/lib/flags/schema.js.map +1 -1
  66. package/lib/launcher/internal/prepareExecution.js +21 -2
  67. package/lib/launcher/internal/prepareExecution.js.map +1 -1
  68. package/lib/launcher/internal/runTtsc.js +13 -53
  69. package/lib/launcher/internal/runTtsc.js.map +1 -1
  70. package/lib/launcher/internal/runTtscserver.js +11 -0
  71. package/lib/launcher/internal/runTtscserver.js.map +1 -1
  72. package/lib/launcher/internal/runTtsx.js +27 -11
  73. package/lib/launcher/internal/runTtsx.js.map +1 -1
  74. package/lib/launcher/internal/runtimeHooks.d.ts +81 -0
  75. package/lib/launcher/internal/runtimeHooks.js +632 -43
  76. package/lib/launcher/internal/runtimeHooks.js.map +1 -1
  77. package/lib/launcher/internal/servedSourceMap.d.ts +25 -0
  78. package/lib/launcher/internal/servedSourceMap.js +164 -0
  79. package/lib/launcher/internal/servedSourceMap.js.map +1 -0
  80. package/lib/plugin/internal/buildSourcePlugin.d.ts +146 -2
  81. package/lib/plugin/internal/buildSourcePlugin.js +651 -113
  82. package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
  83. package/lib/plugin/internal/loadProjectPlugins.d.ts +7 -0
  84. package/lib/plugin/internal/loadProjectPlugins.js +33 -10
  85. package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
  86. package/lib/structures/ITtscCompilerContext.d.ts +16 -2
  87. package/lib/structures/ITtscPluginCapabilities.d.ts +8 -0
  88. package/lib/structures/ITtscPluginFactoryContext.d.ts +14 -0
  89. package/lib/structures/internal/ITtscParsedProjectConfig.d.ts +3 -0
  90. package/lib/structures/internal/ITtscProjectIdentity.d.ts +17 -0
  91. package/lib/structures/internal/ITtscProjectIdentity.js +3 -0
  92. package/lib/structures/internal/ITtscProjectIdentity.js.map +1 -0
  93. package/lib/structures/internal/TtscCommonOptions.d.ts +8 -0
  94. package/package.json +11 -8
  95. package/shim/ast/lint.go +10 -0
  96. package/shim/ast/shim.go +44 -0
  97. package/shim/checker/enums_gen.go +19 -0
  98. package/shim/checker/shim.go +130 -0
  99. package/shim/diagnosticwriter/lint.go +30 -3
  100. package/shim/scanner/regexp.go +27 -0
  101. package/src/TtscCompiler.ts +25 -6
  102. package/src/TtscService.ts +15 -7
  103. package/src/compiler/internal/compileProjectInMemory.ts +1 -0
  104. package/src/compiler/internal/project/createNativeProjectContextArgs.ts +15 -0
  105. package/src/compiler/internal/project/readProjectConfig.ts +61 -5
  106. package/src/compiler/internal/project/resolveProjectConfig.ts +51 -21
  107. package/src/compiler/internal/residentTransformProcess.ts +95 -21
  108. package/src/compiler/internal/runBuild.ts +76 -9
  109. package/src/compiler/internal/runSingleFileEmit.ts +7 -4
  110. package/src/compiler/internal/sharedHostHelpers.ts +24 -0
  111. package/src/compiler/internal/startResidentTransform.ts +21 -1
  112. package/src/compiler/internal/transformProjectInMemory.ts +49 -6
  113. package/src/flags/parser.ts +28 -1
  114. package/src/flags/schema.ts +8 -0
  115. package/src/launcher/internal/prepareExecution.ts +22 -2
  116. package/src/launcher/internal/runTtsc.ts +13 -61
  117. package/src/launcher/internal/runTtscserver.ts +14 -0
  118. package/src/launcher/internal/runTtsx.ts +28 -13
  119. package/src/launcher/internal/runtimeHooks.ts +771 -53
  120. package/src/launcher/internal/servedSourceMap.ts +183 -0
  121. package/src/plugin/internal/buildSourcePlugin.ts +859 -122
  122. package/src/plugin/internal/loadProjectPlugins.ts +36 -6
  123. package/src/structures/ITtscCompilerContext.ts +17 -2
  124. package/src/structures/ITtscPluginCapabilities.ts +9 -0
  125. package/src/structures/ITtscPluginFactoryContext.ts +15 -0
  126. package/src/structures/internal/ITtscParsedProjectConfig.ts +3 -0
  127. package/src/structures/internal/ITtscProjectIdentity.ts +17 -0
  128. package/src/structures/internal/TtscCommonOptions.ts +8 -0
  129. package/tools/shim_audit/baseline.json +16 -7
  130. package/tools/shim_audit/main.go +777 -71
  131. package/tools/shim_audit/main_test.go +28 -1
  132. package/tools/shim_audit/producer_exemptions_require_rationale_test.go +42 -0
  133. package/tools/shim_audit/producer_surface_includes_exposed_methods_test.go +154 -0
  134. package/tools/shim_audit/producer_surface_rejects_unproducible_reference_test.go +142 -0
  135. package/utility/host.go +46 -20
  136. package/utility/serve.go +1 -1
  137. package/shim/checker/signature_api_completeness.go +0 -58
package/README.md CHANGED
@@ -8,8 +8,8 @@ A `typescript-go` toolchain for compiler-powered plugins and type-safe execution
8
8
 
9
9
  - **`ttsc`**: build, check, and transform.
10
10
  - **`ttsx`**: execute TypeScript with type checking.
11
- - **`@ttsc/lint`**: lint violations as compiler errors.
12
- - **`@ttsc/graph`**: MCP code graph that reduce token usage.
11
+ - [**`@ttsc/lint`**](https://github.com/samchon/ttsc/tree/master/packages/lint): lint violations as compiler errors.
12
+ - [**`@ttsc/graph`**](https://github.com/samchon/ttsc/tree/master/packages/graph): MCP code graph that reduce token usage.
13
13
  - **plugin support**: compiler-powered libraries, such as `typia`.
14
14
 
15
15
  ## Setup
@@ -76,6 +76,7 @@ Supported bundlers:
76
76
  - Webpack
77
77
  - Rspack
78
78
  - Next.js
79
+ - Turbopack
79
80
  - Farm
80
81
  - Bun
81
82
 
@@ -127,12 +128,10 @@ See [`@ttsc/vscode`](https://github.com/samchon/ttsc/tree/master/packages/vscode
127
128
 
128
129
  ### Coding Agents (MCP)
129
130
 
130
- `@ttsc/graph` gives a coding agent a checker-resolved map of your project, over MCP.
131
+ `@ttsc/graph` gives a coding agent a checker-resolved graph of your project, over MCP.
131
132
 
132
133
  It answers what relates to a symbol and what a change affects, straight from the type checker, so the agent stops grepping and re-reading files.
133
134
 
134
- It also carries the project's full diagnostics: type errors, `@ttsc/lint` violations, and plugin findings. They are fused onto the graph, so an agent sees a change's reach over what is already broken before editing.
135
-
136
135
  ```bash
137
136
  npm install -D ttsc @ttsc/graph typescript
138
137
  ```
@@ -266,7 +265,7 @@ See the [Programmatic API guide](https://ttsc.dev/docs/ttsc/api) for the full li
266
265
 
267
266
  - [`@ttsc/banner`](https://github.com/samchon/ttsc/tree/master/packages/banner): adds `@packageDocumentation` JSDoc banners.
268
267
  - [`@ttsc/lint`](https://github.com/samchon/ttsc/tree/master/packages/lint): lints and formats TypeScript source.
269
- - [`@ttsc/graph`](https://github.com/samchon/ttsc/tree/master/packages/graph): MCP server exposing a checker-resolved code graph and diagnostics to coding agents.
268
+ - [`@ttsc/graph`](https://github.com/samchon/ttsc/tree/master/packages/graph): MCP server exposing a checker-resolved code graph to coding agents.
270
269
  - [`@ttsc/paths`](https://github.com/samchon/ttsc/tree/master/packages/paths): rewrites source path aliases so JS and declaration emit receive relative imports.
271
270
  - [`@ttsc/strip`](https://github.com/samchon/ttsc/tree/master/packages/strip): removes configured calls and `debugger` statements.
272
271
  - [`@ttsc/unplugin`](https://github.com/samchon/ttsc/tree/master/packages/unplugin): runs `ttsc` plugins inside bundlers supported by `unplugin`.
@@ -6,7 +6,7 @@
6
6
  // it N times and take medians.
7
7
  //
8
8
  // Counts and coverage are deterministic; timings are indicative and only
9
- // meaningful on a quiet host (see .codex/skills/benchmark).
9
+ // meaningful on a quiet host (see .agents/skills/benchmark/SKILL.md).
10
10
  package main
11
11
 
12
12
  import (
@@ -2,12 +2,10 @@
2
2
  //
3
3
  // The real compiler and runner commands live in the JavaScript launchers so
4
4
  // they can resolve the consuming project's `typescript` and
5
- // plugin descriptors. This binary only supplies version/platform metadata and
6
- // a tiny demo command for package smoke tests.
5
+ // plugin descriptors. This binary only supplies version/platform metadata.
7
6
  package main
8
7
 
9
8
  import (
10
- "flag"
11
9
  "fmt"
12
10
  "io"
13
11
  "os"
@@ -50,8 +48,6 @@ func run(args []string) int {
50
48
  case "-v", "--version", "version":
51
49
  printVersion(stdout)
52
50
  return 0
53
- case "demo":
54
- return runDemo(args[1:])
55
51
  case "build", "check":
56
52
  fmt.Fprintf(
57
53
  stderr,
@@ -90,48 +86,5 @@ plugin-selected native sidecar.
90
86
 
91
87
  Usage:
92
88
  ttsc --version
93
- ttsc demo --type=string
94
89
  `))
95
90
  }
96
-
97
- // runDemo implements the demo sub-command, printing a synthetic JavaScript
98
- // arrow function for the requested atomic type. Smoke tests in CI invoke this
99
- // to verify the binary executes correctly.
100
- func runDemo(args []string) int {
101
- fs := flag.NewFlagSet("demo", flag.ContinueOnError)
102
- fs.SetOutput(stderr)
103
- typ := fs.String("type", "string", "atomic type to simulate")
104
- if err := fs.Parse(args); err != nil {
105
- return 2
106
- }
107
-
108
- arrow, err := demoArrow(*typ)
109
- if err != nil {
110
- fmt.Fprintf(stderr, "ttsc platform helper demo: %v\n", err)
111
- return 2
112
- }
113
-
114
- fmt.Fprintf(stdout, "// demo<%s> -> emitted by ttsc platform helper %s\n", *typ, version)
115
- fmt.Fprintln(stdout, arrow)
116
- return 0
117
- }
118
-
119
- // demoArrow returns a JavaScript arrow-function expression for the named
120
- // atomic TypeScript type. It is the platform-helper counterpart of the same
121
- // function in cmd/ttsc, kept separate to avoid a shared-binary dependency.
122
- func demoArrow(name string) (string, error) {
123
- switch strings.ToLower(name) {
124
- case "any":
125
- return "(input) => true", nil
126
- case "boolean":
127
- return `(input) => "boolean" === typeof input`, nil
128
- case "number":
129
- return `(input) => "number" === typeof input`, nil
130
- case "bigint":
131
- return `(input) => "bigint" === typeof input`, nil
132
- case "string", "":
133
- return `(input) => "string" === typeof input`, nil
134
- default:
135
- return "", fmt.Errorf("unknown --type value %q (want: string|number|boolean|bigint|any)", name)
136
- }
137
- }
@@ -84,7 +84,11 @@ export { value };
84
84
  code, _, errText = captureCommand(t, func() int {
85
85
  return runBuild([]string{"--cwd", root, "--tsconfig", "tsconfig.json", "--emit", "--outDir", "blocked"})
86
86
  })
87
- if code != 2 || !strings.Contains(errText, "not a directory") {
87
+ // The write fails because outDir is a regular file. Assert on the exit code
88
+ // and the platform-agnostic TS5033 "Could not write file" diagnostic prefix,
89
+ // not the OS errno, which differs by platform (POSIX ENOTDIR "not a
90
+ // directory" vs Windows "The system cannot find the path specified").
91
+ if code != 2 || !strings.Contains(errText, "Could not write file") {
88
92
  t.Fatalf("emit failure mismatch: code=%d stderr=%q", code, errText)
89
93
  }
90
94
 
package/cmd/ttsc/main.go CHANGED
@@ -2,8 +2,6 @@
2
2
  //
3
3
  // Current responsibilities:
4
4
  // - Report version and platform (`ttsc --version`).
5
- // - Exercise a native rewrite backend end-to-end (`ttsc demo --type=string`)
6
- // so smoke tests can verify the Go binary really runs.
7
5
  // - Host the native project build and check paths used by plugin-selected
8
6
  // sidecars and smoke tests.
9
7
  //
@@ -12,7 +10,6 @@
12
10
  package main
13
11
 
14
12
  import (
15
- "flag"
16
13
  "fmt"
17
14
  "io"
18
15
  "os"
@@ -51,8 +48,6 @@ func run(args []string) int {
51
48
  case "-v", "--version", "version":
52
49
  printVersion(stdout)
53
50
  return 0
54
- case "demo":
55
- return runDemo(args[1:])
56
51
  case "build":
57
52
  return runBuild(args[1:])
58
53
  case "api-compile":
@@ -126,7 +121,6 @@ Project build:
126
121
  ttsc compiles the current tsconfig.json, matching the tsc/tsgo shape.
127
122
  build Compatibility alias for the same project build lane.
128
123
  check Compatibility alias for --noEmit validation.
129
- demo Run a native backend smoke pipeline with synthetic input.
130
124
  version Print version, build info, and platform.
131
125
  help Show this help.
132
126
 
@@ -139,16 +133,11 @@ Build options:
139
133
  --verbose Print the per-call summary banner and emitted file list.
140
134
  --manifest=FILE Write emitted file paths as JSON to FILE after build --emit.
141
135
 
142
- Demo options:
143
- --type=T Atomic TypeScript type to simulate. One of:
144
- string, number, boolean, bigint, any (default: string).
145
-
146
136
  Examples:
147
137
  ttsc --version
148
138
  ttsc
149
139
  ttsc -p ./tsconfig.json
150
140
  ttsc --noEmit
151
- ttsc demo --type=number
152
141
 
153
142
  Integration guide (bundlers):
154
143
  - Next.js / Nuxt / Bun: "ttsc" in your pipeline replaces tsc and
@@ -157,42 +146,3 @@ Integration guide (bundlers):
157
146
  per-package tsconfig.json references work unchanged.
158
147
  `))
159
148
  }
160
-
161
- func runDemo(args []string) int {
162
- fs := flag.NewFlagSet("demo", flag.ContinueOnError)
163
- fs.SetOutput(stderr)
164
- typ := fs.String("type", "string", "atomic type to simulate")
165
- if err := fs.Parse(args); err != nil {
166
- return 2
167
- }
168
-
169
- arrow, err := demoArrow(*typ)
170
- if err != nil {
171
- fmt.Fprintf(stderr, "ttsc demo: %v\n", err)
172
- return 2
173
- }
174
-
175
- fmt.Fprintf(stdout, "// demo<%s> -> emitted by ttsc %s\n", *typ, version)
176
- fmt.Fprintln(stdout, arrow)
177
- return 0
178
- }
179
-
180
- // demoArrow returns a JavaScript arrow-function expression that validates the
181
- // named atomic TypeScript type at runtime. Used by the demo sub-command to
182
- // produce a small synthetic emit that smoke tests can assert on.
183
- func demoArrow(name string) (string, error) {
184
- switch strings.ToLower(name) {
185
- case "any":
186
- return "(input) => true", nil
187
- case "boolean":
188
- return `(input) => "boolean" === typeof input`, nil
189
- case "number":
190
- return `(input) => "number" === typeof input`, nil
191
- case "bigint":
192
- return `(input) => "bigint" === typeof input`, nil
193
- case "string", "":
194
- return `(input) => "string" === typeof input`, nil
195
- default:
196
- return "", fmt.Errorf("unknown --type value %q (want: string|number|boolean|bigint|any)", name)
197
- }
198
- }
@@ -2,23 +2,17 @@ package main
2
2
 
3
3
  import "testing"
4
4
 
5
- // TestMainAliasBranches verifies main command aliases cover flag-shaped demo and cts project inputs.
5
+ // TestMainAliasBranches verifies `.cts` project inputs remain build aliases.
6
6
  //
7
7
  // The top-level dispatcher treats extension-shaped arguments as build aliases
8
- // while demo owns its own flag parser. These small branches keep compatibility
9
- // with `ttsc ./tsconfig.cts`-style invocations and malformed demo flags.
8
+ // so `ttsc ./tsconfig.cts` stays compatible with tsc-style invocations instead
9
+ // of being rejected as an unknown command.
10
10
  //
11
- // 1. Run demo with a missing flag value.
12
- // 2. Dispatch a `.cts` argument through the build alias path.
13
- // 3. Assert both routes fail through their intended parser.
11
+ // 1. Dispatch a `.cts` argument through the build alias path.
12
+ // 2. Let project discovery inspect the missing file.
13
+ // 3. Assert the build lane reports its command-error status.
14
14
  func TestMainAliasBranches(t *testing.T) {
15
15
  code, _, _ := captureCommand(t, func() int {
16
- return run([]string{"demo", "--type"})
17
- })
18
- if code != 2 {
19
- t.Fatalf("demo flag status mismatch: %d", code)
20
- }
21
- code, _, _ = captureCommand(t, func() int {
22
16
  return run([]string{"project.cts"})
23
17
  })
24
18
  if code != 2 {
@@ -59,11 +59,21 @@ func runDump(args []string) int {
59
59
 
60
60
  g := graph.Build(prog)
61
61
  ignored := graph.GitIgnoredFiles(cwd, g)
62
- data, err := graph.MarshalDump(g, cwd, tsconfig, ignored, graph.SourceTexts(prog), *prettyFlag)
63
- if err != nil {
62
+ // Stream the document out instead of marshalling it into one byte slice and
63
+ // then copying that slice into a string: on VS Code the dump is 323 MB, so
64
+ // the string conversion alone was a second full copy of it, for nothing. The
65
+ // encoder writes through a buffer straight to stdout.
66
+ if err := graph.EncodeDump(
67
+ stdout,
68
+ g,
69
+ cwd,
70
+ tsconfig,
71
+ ignored,
72
+ graph.SourceTexts(prog),
73
+ *prettyFlag,
74
+ ); err != nil {
64
75
  fmt.Fprintf(stderr, "ttscgraph: %v\n", err)
65
76
  return 1
66
77
  }
67
- fmt.Fprintln(stdout, string(data))
68
78
  return 0
69
79
  }
@@ -133,9 +133,11 @@ func runLSP(args []string) int {
133
133
  }
134
134
 
135
135
  // The SymbolProvider answers textDocument/documentSymbol and
136
- // textDocument/references locally from ttsc's compiler-backed code graph;
137
- // tsgo's native LSP does not implement them. It loads the program lazily on
138
- // the first such request, so wiring it here adds no startup cost.
136
+ // textDocument/references from ttsc's compiler-backed code graph. tsgo
137
+ // implements both methods itself, so the proxy forwards to tsgo whenever it
138
+ // advertises the capability and consults this provider only as a fallback
139
+ // (tsgo did not advertise). It loads the program lazily on the first such
140
+ // request, so wiring it here adds no startup cost.
139
141
  symbolProvider := graphsymbols.NewProvider(cwd, strings.TrimSpace(*tsconfigFlag))
140
142
 
141
143
  err = runLSPServer(ctx, lspserver.LSPServerOptions{
package/driver/lsp.go CHANGED
@@ -49,6 +49,12 @@ type LSPTextEdit = lspserver.LSPTextEdit
49
49
  // LSPDocumentVersion is the driver-level alias for lspserver.LSPDocumentVersion.
50
50
  type LSPDocumentVersion = lspserver.LSPDocumentVersion
51
51
 
52
+ // LSPProjectDiagnostics is the driver-level alias for a project publication.
53
+ type LSPProjectDiagnostics = lspserver.LSPProjectDiagnostics
54
+
55
+ // LSPDiagnosticsResult separates document and project plugin diagnostics.
56
+ type LSPDiagnosticsResult = lspserver.LSPDiagnosticsResult
57
+
52
58
  // LSPSymbolKind is the driver-level alias for lspserver.LSPSymbolKind.
53
59
  type LSPSymbolKind = lspserver.LSPSymbolKind
54
60
 
@@ -104,6 +110,12 @@ type LSPServerOptions = lspserver.LSPServerOptions
104
110
  // LSPUpstreamRunner is the driver-level alias for lspserver.LSPUpstreamRunner.
105
111
  type LSPUpstreamRunner = lspserver.LSPUpstreamRunner
106
112
 
113
+ // LSPUpstreamValidator is the driver-level alias for lspserver.LSPUpstreamValidator.
114
+ type LSPUpstreamValidator = lspserver.LSPUpstreamValidator
115
+
116
+ // LSPUpstream is the driver-level alias for lspserver.LSPUpstream.
117
+ type LSPUpstream = lspserver.LSPUpstream
118
+
107
119
  // MaxFrameBytes is the maximum byte length of a single JSON-RPC frame
108
120
  // the proxy will read without returning ErrFrameTooLarge.
109
121
  const MaxFrameBytes = lspserver.MaxFrameBytes
@@ -118,6 +130,7 @@ var ErrFrameClosed = lspserver.ErrFrameClosed
118
130
  var ErrFrameTooLarge = lspserver.ErrFrameTooLarge
119
131
  var ErrInvalidJSONRPC = lspserver.ErrInvalidJSONRPC
120
132
  var ErrLSPUpstreamPanic = lspserver.ErrLSPUpstreamPanic
133
+ var ErrLSPUpstreamRunnerRequired = lspserver.ErrLSPUpstreamRunnerRequired
121
134
  var ErrLSPCwdRequired = lspserver.ErrLSPCwdRequired
122
135
  var ErrLSPTsgoBinaryRequired = lspserver.ErrLSPTsgoBinaryRequired
123
136
 
@@ -128,7 +141,6 @@ var NewFrameReader = lspserver.NewFrameReader
128
141
  var WriteFrame = lspserver.WriteFrame
129
142
  var ParseEnvelope = lspserver.ParseEnvelope
130
143
  var RecoverPanicAs = lspserver.RecoverPanicAs
131
- var WithUpstreamRunnerForTest = lspserver.WithUpstreamRunnerForTest
132
144
  var RunLSPServer = lspserver.RunLSPServer
133
145
  var DenyNpmInstall = lspserver.DenyNpmInstall
134
146
 
package/driver/plugins.go CHANGED
@@ -4,6 +4,7 @@ import (
4
4
  "encoding/json"
5
5
  "fmt"
6
6
  "os"
7
+ "path/filepath"
7
8
  "strings"
8
9
  )
9
10
 
@@ -13,6 +14,40 @@ import (
13
14
  // linked plugins are active.
14
15
  const LinkedPluginsEnv = "TTSC_LINKED_PLUGINS_JSON"
15
16
 
17
+ // PluginConfigDirEnv is the environment variable through which the ttsc
18
+ // launcher passes the project root that plugin config-file discovery and
19
+ // relative "configFile" resolution anchor at. The launcher sets it on every
20
+ // native plugin spawn; it matters when the compiled tsconfig is a generated
21
+ // wrapper outside the project — e.g. @ttsc/unplugin writes a compiler-options
22
+ // overlay into the system temp directory that `extends` the real project
23
+ // config — where the tsconfig directory no longer identifies the project and
24
+ // an unanchored discovery walk would climb the temp tree instead. It rides
25
+ // the environment rather than a CLI flag so third-party native hosts with
26
+ // strict flag sets are unaffected and linked plugins running inside them
27
+ // still receive it.
28
+ const PluginConfigDirEnv = "TTSC_PLUGIN_CONFIG_DIR"
29
+
30
+ // PluginConfigBaseDir returns the directory where a plugin anchors its
31
+ // config-file discovery walk and resolves relative "configFile" paths.
32
+ // The explicit PluginConfigDirEnv channel wins when set; otherwise the
33
+ // tsconfig's directory is used, falling back to cwd when no tsconfig is set.
34
+ func PluginConfigBaseDir(cwd, tsconfigPath string) string {
35
+ if dir := strings.TrimSpace(os.Getenv(PluginConfigDirEnv)); dir != "" {
36
+ if !filepath.IsAbs(dir) && cwd != "" {
37
+ dir = filepath.Join(cwd, dir)
38
+ }
39
+ return filepath.Clean(dir)
40
+ }
41
+ if tsconfigPath != "" {
42
+ resolved := tsconfigPath
43
+ if !filepath.IsAbs(resolved) {
44
+ resolved = filepath.Join(cwd, resolved)
45
+ }
46
+ return filepath.Dir(resolved)
47
+ }
48
+ return cwd
49
+ }
50
+
16
51
  // PluginEntry is the manifest shape ttsc passes to driver-level plugins.
17
52
  type PluginEntry struct {
18
53
  Config map[string]any `json:"config"`
package/driver/program.go CHANGED
@@ -81,15 +81,14 @@ func NewLintDiagnostic(
81
81
  lint: lint,
82
82
  }
83
83
  if file != nil {
84
+ pos = lint.Pos()
84
85
  d.File = file.FileName()
85
- if pos >= 0 {
86
- length := lint.Len()
87
- d.Start = &pos
88
- d.Length = &length
89
- line, col := shimscanner.GetECMALineAndByteOffsetOfPosition(file, pos)
90
- d.Line = line + 1
91
- d.Column = col + 1
92
- }
86
+ length := lint.Len()
87
+ d.Start = &pos
88
+ d.Length = &length
89
+ line, col := shimscanner.GetECMALineAndByteOffsetOfPosition(file, pos)
90
+ d.Line = line + 1
91
+ d.Column = col + 1
93
92
  }
94
93
  return d
95
94
  }