@ttsc/vscode 0.13.1 → 0.14.0-dev.20260528.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.
package/README.md CHANGED
@@ -4,18 +4,21 @@
4
4
 
5
5
  MIT licensed · [npm](https://www.npmjs.com/package/@ttsc/vscode) · [docs](https://ttsc.dev/docs) · [Discord](https://discord.gg/E94XhzrUCZ)
6
6
 
7
- VSCode extension for [`ttsc`](https://ttsc.dev) projects.
7
+ VS Code extension for [`ttsc`](https://ttsc.dev) projects.
8
8
 
9
- Lint diagnostics, format hints, and plugin code actions appear in your editor live — the same diagnostics `ttsc` would emit at build time, shown as you type.
9
+ It starts the `ttscserver` language-server launcher from your project's own
10
+ `ttsc` dependency, so VS Code uses the same TypeScript-Go version your project
11
+ pins.
10
12
 
11
13
  ## Requirements
12
14
 
13
15
  - **VS Code** 1.94 or later
14
16
  - **Node.js** 18 or later
15
- - **`ttsc` installed in your project** — the extension uses the language server that ships with your project's `ttsc` package
17
+ - **`ttsc` installed in your project** — the extension uses the language server
18
+ that ships with your project's `ttsc` package
16
19
 
17
20
  ```bash
18
- npm install -D ttsc @ttsc/lint @typescript/native-preview
21
+ npm install -D ttsc @typescript/native-preview
19
22
  ```
20
23
 
21
24
  ## Install
@@ -41,14 +44,32 @@ Marketplace release is tracked for v1; once it lands, the `npx` step goes away.
41
44
 
42
45
  ## What it adds
43
46
 
44
- The extension activates on any TypeScript, JavaScript, TSX, or JSX file inside a project that has `ttsc` installed.
45
-
46
- - **Live lint underlines.** Violations from `@ttsc/lint` (and any third-party rule plugins you've installed) appear in the same gutter as TypeScript type errors — same `error TSxxxxx` shape.
47
- - **Quick fixes** for autofixable rules under the lightbulb menu.
48
- - **Command palette entries:**
49
- - `ttsc: Apply lint fixes to current file`
50
- - `ttsc: Format current document`
51
- - `ttsc: Restart language server`
47
+ The extension activates on TypeScript, JavaScript, TSX, and JSX files, then
48
+ starts a server only when it can resolve a project-local `ttscserver`.
49
+
50
+ - **Project-local language server.** The extension resolves `ttscserver` from
51
+ the active file's package/workspace, then starts the project-selected
52
+ `tsgo --lsp --stdio` process behind it.
53
+ - **TypeScript-Go diagnostics and editor features.** Hover, navigation,
54
+ completions, and TypeScript-Go diagnostics come from the upstream `tsgo` LSP
55
+ process.
56
+ - **ttsc plugin diagnostics and actions.** LSP-capable plugins are discovered
57
+ from the same project config and merged into the editor stream. `@ttsc/lint`
58
+ currently contributes lint diagnostics, fix-all actions, and document format
59
+ edits. Plugin diagnostics, code actions, and command computation use the
60
+ saved project state today; commands return VS Code `WorkspaceEdit`s and the
61
+ editor applies them only while the touched documents are still clean.
62
+ - **Monorepo-aware server roots.** Multi-root workspaces start server contexts
63
+ from the active file and workspace folders, resolved from the nearest
64
+ `tsconfig*.json` / `jsconfig*.json`. Add packages as VS Code workspace
65
+ folders when you want each package to keep its own active server context.
66
+ - **Command palette entries:** `ttsc: Restart language server`,
67
+ `ttsc: Fix all lint issues`, and `ttsc: Format document`. The lint and
68
+ format commands require an LSP-capable plugin that owns those command ids,
69
+ such as `@ttsc/lint`. The VS Code extension registers wrapper commands for
70
+ those built-in lint/format flows; other plugin command ids are advertised
71
+ through the language client and their returned `changes`-map `WorkspaceEdit`s
72
+ are applied with the same clean-document guard.
52
73
 
53
74
  The extension's identifier inside VS Code is `samchon.ttsc`.
54
75
 
@@ -56,18 +77,19 @@ The extension's identifier inside VS Code is `samchon.ttsc`.
56
77
 
57
78
  Open VS Code's settings (`Ctrl+,` / `Cmd+,`) and search for `ttsc`, or edit `settings.json` directly:
58
79
 
59
- | Setting | Default | Effect |
60
- | --- | --- | --- |
61
- | `ttsc.serverPath` | `""` | Absolute path to a language-server binary. Empty means use the one bundled with the project's `ttsc` install almost always what you want. |
62
- | `ttsc.trace.server` | `"off"` | Set to `"messages"` or `"verbose"` to log LSP traffic. The log goes to **View → Output → ttsc**. Useful when diagnostics don't show up. |
80
+ | Setting | Default | Effect |
81
+ | ------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
82
+ | `ttsc.serverPath` | `""` | Absolute path to a `ttscserver` launcher or native binary. Empty uses the project's `ttsc` launcher, which builds `TTSC_LSP_PLUGINS_JSON` for plugin diagnostics/actions. Direct native paths need that manifest supplied out of band. |
83
+ | `ttsc.trace.server` | `"off"` | Set to `"messages"` or `"verbose"` to log LSP traffic. The trace goes to **View → Output → ttsc (trace)**; server logs stay under **ttsc**. Useful when diagnostics don't show up. |
63
84
 
64
85
  ## Troubleshooting
65
86
 
66
- If lint underlines don't appear after install:
87
+ If TypeScript-Go or ttsc plugin diagnostics don't appear after install:
67
88
 
68
- 1. **Check the project has `ttsc`:** `npx ttsc --version`. If this errors, install `ttsc @ttsc/lint @typescript/native-preview` in the project first.
69
- 2. **Read the server log:** open **View Output**, pick **ttsc** from the dropdown.
70
- 3. **Restart the server:** command palette`ttsc: Restart language server`.
71
- 4. **Verbose tracing:** set `ttsc.trace.server` to `"verbose"`, repeat step 2.
89
+ 1. **Check the project has `ttsc`:** `npx ttsc --version`. If this errors, install `ttsc @typescript/native-preview` in the project first.
90
+ 2. **Check the same config in the CLI:** run `npx ttsc --noEmit -p <selected tsconfig>` from the project root and confirm the plugin diagnostics appear there.
91
+ 3. **Read the server log:** open **ViewOutput**, pick **ttsc** from the dropdown.
92
+ 4. **Restart the server:** command palette `ttsc: Restart language server`.
93
+ 5. **Verbose tracing:** set `ttsc.trace.server` to `"verbose"`, then read **View → Output → ttsc (trace)**.
72
94
 
73
95
  If `npx ttsc-vscode` errors with `\`code\` CLI not found on PATH`: open VS Code → command palette → **Shell Command: Install 'code' command in PATH**, then retry the install.
package/bin/install.js CHANGED
@@ -6,39 +6,97 @@ const path = require("node:path");
6
6
  const pkgRoot = path.resolve(__dirname, "..");
7
7
  const distDir = path.join(pkgRoot, "dist");
8
8
  const extensionId = "samchon.ttsc";
9
-
10
- const sub = process.argv[2] ?? "install";
9
+ const version = require(path.join(pkgRoot, "package.json")).version;
11
10
 
12
11
  function findVsix() {
13
12
  if (!fs.existsSync(distDir)) return null;
14
- const hits = fs.readdirSync(distDir).filter((f) => f.endsWith(".vsix"));
15
- return hits.length ? path.join(distDir, hits[0]) : null;
13
+ const expected = path.join(distDir, `ttsc-vscode-${version}.vsix`);
14
+ return fs.existsSync(expected) ? expected : null;
15
+ }
16
+
17
+ function createCodeCommand(
18
+ args,
19
+ platform = process.platform,
20
+ env = process.env,
21
+ ) {
22
+ if (platform === "win32") {
23
+ return {
24
+ command: env.ComSpec || "cmd.exe",
25
+ args: ["/d", "/s", "/c", quoteWindowsCommand(["code", ...args])],
26
+ };
27
+ }
28
+ return { command: "code", args };
29
+ }
30
+
31
+ function quoteWindowsCommand(args) {
32
+ return `"${args.map(quoteWindowsArg).join(" ")}"`;
33
+ }
34
+
35
+ function quoteWindowsArg(arg) {
36
+ return `"${String(arg).replace(/"/g, '\\"').replace(/%/g, "%%")}"`;
16
37
  }
17
38
 
18
39
  function runCode(args, vsixForFallback) {
19
- const r = cp.spawnSync("code", args, { stdio: "inherit" });
40
+ const command = createCodeCommand(args);
41
+ const r = cp.spawnSync(command.command, command.args, { stdio: "inherit" });
20
42
  if (r.error && r.error.code === "ENOENT") {
21
- console.error("`code` CLI not found on PATH.");
22
- console.error("Either:");
23
- console.error(" - Open VSCode, then run \"Shell Command: Install 'code' command in PATH\" from the command palette.");
24
- if (vsixForFallback) {
25
- console.error(` - Or install manually: VSCode > Extensions > \"...\" menu > Install from VSIX > ${vsixForFallback}`);
26
- }
43
+ printCodeNotFound(vsixForFallback);
27
44
  process.exit(1);
28
45
  }
46
+ if (process.platform === "win32" && (r.status ?? 1) !== 0) {
47
+ printCodeFailed(r.status ?? 1, vsixForFallback);
48
+ }
29
49
  process.exit(r.status ?? 1);
30
50
  }
31
51
 
32
- if (sub === "install") {
33
- const vsix = findVsix();
34
- if (!vsix) {
35
- console.error(`No .vsix bundled in ${distDir}. Reinstall @ttsc/vscode or report a packaging bug.`);
52
+ function printCodeNotFound(vsixForFallback) {
53
+ console.error("`code` CLI not found on PATH.");
54
+ console.error("Either:");
55
+ console.error(
56
+ " - Open VS Code, then run \"Shell Command: Install 'code' command in PATH\" from the command palette.",
57
+ );
58
+ if (vsixForFallback) {
59
+ console.error(
60
+ ` - Or install manually: VS Code > Extensions > \"...\" menu > Install from VSIX > ${vsixForFallback}`,
61
+ );
62
+ }
63
+ }
64
+
65
+ function printCodeFailed(status, vsixForFallback) {
66
+ console.error(`VS Code CLI exited with status ${status}.`);
67
+ if (vsixForFallback) {
68
+ console.error(
69
+ `Install manually: VS Code > Extensions > "..." menu > Install from VSIX > ${vsixForFallback}`,
70
+ );
71
+ }
72
+ }
73
+
74
+ function main(argv = process.argv.slice(2)) {
75
+ const sub = argv[0] ?? "install";
76
+ if (sub === "install") {
77
+ const vsix = findVsix();
78
+ if (!vsix) {
79
+ console.error(
80
+ `No .vsix bundled in ${distDir}. Reinstall @ttsc/vscode or report a packaging bug.`,
81
+ );
82
+ process.exit(1);
83
+ }
84
+ runCode(["--install-extension", vsix, "--force"], vsix);
85
+ } else if (sub === "uninstall") {
86
+ runCode(["--uninstall-extension", extensionId]);
87
+ } else {
88
+ console.error(`Usage: ttsc-vscode <install|uninstall>`);
36
89
  process.exit(1);
37
90
  }
38
- runCode(["--install-extension", vsix, "--force"], vsix);
39
- } else if (sub === "uninstall") {
40
- runCode(["--uninstall-extension", extensionId]);
41
- } else {
42
- console.error(`Usage: ttsc-vscode <install|uninstall>`);
43
- process.exit(1);
44
91
  }
92
+
93
+ if (require.main === module) {
94
+ main();
95
+ }
96
+
97
+ module.exports = {
98
+ createCodeCommand,
99
+ findVsix,
100
+ main,
101
+ quoteWindowsCommand,
102
+ };