@typecad/cuttlefish 1.0.0-alpha.13 → 1.0.0-alpha.14

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 (64) hide show
  1. package/assets/editor-extensions/typecad-debug/README.md +142 -0
  2. package/assets/editor-extensions/typecad-debug/out/extension.js +347 -0
  3. package/assets/editor-extensions/typecad-debug/out/extension.js.map +1 -0
  4. package/assets/editor-extensions/typecad-debug/package.json +76 -0
  5. package/assets/editor-extensions/typecad-ui/LICENSE +27 -0
  6. package/assets/editor-extensions/typecad-ui/README.md +52 -0
  7. package/assets/editor-extensions/typecad-ui/file-icon-dark.png +0 -0
  8. package/assets/editor-extensions/typecad-ui/file-icon-light.png +0 -0
  9. package/assets/editor-extensions/typecad-ui/icon.png +0 -0
  10. package/assets/editor-extensions/typecad-ui/language-configuration.json +43 -0
  11. package/assets/editor-extensions/typecad-ui/package.json +54 -0
  12. package/assets/editor-extensions/typecad-ui/snippets/typecad-ui.json +80 -0
  13. package/assets/editor-extensions/typecad-ui/syntaxes/markdown-ui.json +45 -0
  14. package/assets/editor-extensions/typecad-ui/syntaxes/typecad-ui.tmLanguage.json +1269 -0
  15. package/dist/api/config.d.ts +8 -1
  16. package/dist/api/shared/framework-manifest.d.ts +61 -504
  17. package/dist/cli.js +17 -6
  18. package/dist/config-loader.js +3 -1
  19. package/dist/config-schema.d.ts +17 -223
  20. package/dist/config-schema.js +1 -0
  21. package/dist/contract/contract-parser.d.ts +9 -127
  22. package/dist/create/board-checklist.js +1 -1
  23. package/dist/create/board-codegen.js +4 -4
  24. package/dist/create/board-spec.d.ts +74 -530
  25. package/dist/create/editor-integration.d.ts +30 -0
  26. package/dist/create/editor-integration.js +218 -0
  27. package/dist/create/eslint-rules-template.d.ts +2 -2
  28. package/dist/create/framework-catalog.d.ts +8 -0
  29. package/dist/create/framework-catalog.js +28 -5
  30. package/dist/create/index.d.ts +7 -6
  31. package/dist/create/index.js +5 -4
  32. package/dist/create/{init-scaffold.d.ts → scaffold.d.ts} +4 -4
  33. package/dist/create/{init-scaffold.js → scaffold.js} +33 -2
  34. package/dist/create/templates.d.ts +29 -0
  35. package/dist/create/{init-templates.js → templates.js} +15 -0
  36. package/dist/create/wizard.d.ts +8 -0
  37. package/dist/create/{init-wizard.js → wizard.js} +11 -4
  38. package/dist/emit/emitters/setup.js +22 -0
  39. package/dist/ir/build-ir.js +24 -3
  40. package/dist/library/catalog.d.ts +35 -0
  41. package/dist/library/catalog.js +67 -0
  42. package/dist/library/cli.d.ts +2 -0
  43. package/dist/library/cli.js +168 -0
  44. package/dist/library/init.d.ts +25 -0
  45. package/dist/library/init.js +397 -0
  46. package/dist/library/install.d.ts +9 -0
  47. package/dist/library/install.js +80 -0
  48. package/dist/library/registry-search.d.ts +34 -0
  49. package/dist/library/registry-search.js +50 -0
  50. package/dist/library/validate.d.ts +17 -0
  51. package/dist/library/validate.js +175 -0
  52. package/dist/library-packages.d.ts +95 -0
  53. package/dist/library-packages.js +275 -0
  54. package/dist/orchestrator/graph-builder.js +16 -0
  55. package/dist/preview/client.js +17 -3
  56. package/dist/testing.d.ts +2 -2
  57. package/dist/testing.js +1 -1
  58. package/dist/transpile.js +55 -0
  59. package/dist/types.d.ts +19 -0
  60. package/dist/utils/cli.d.ts +2 -2
  61. package/dist/utils/cli.js +68 -3
  62. package/package.json +16 -8
  63. package/dist/create/init-templates.d.ts +0 -28
  64. package/dist/create/init-wizard.d.ts +0 -8
@@ -0,0 +1,142 @@
1
+ # TypeCAD Debug
2
+
3
+ A Visual Studio Code extension that bridges VSCode's breakpoint gutter to the
4
+ TypeCAD `Serial.print` debug pipeline. Set breakpoints in your `.ts` source;
5
+ this extension syncs them to `.cuttlefish/breakpoints.json`, which the
6
+ `@typecad/cuttlefish` transpiler reads (when run with `--debug`) to inject
7
+ `Serial.println` instrumentation that reports variable values and lets you
8
+ step through execution.
9
+
10
+ This is the producer half of a two-part system. The consumer half lives in
11
+ [`@typecad/cuttlefish`](../../packages/cuttlefish/src/debug/) and is the
12
+ authoritative source for the on-disk schema and matching behavior described
13
+ below.
14
+
15
+ ## Install
16
+
17
+ This package is `private: true` and is **not** published to the npm registry
18
+ or the VS Code Marketplace. Build the VSIX locally:
19
+
20
+ ```sh
21
+ cd packages/vscode-typecad-debug
22
+ npm install
23
+ npm run compile
24
+ npm run package # produces vscode-typecad-debug-0.2.0.vsix
25
+ code --install-extension vscode-typecad-debug-0.2.0.vsix
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ 1. Open the Command Palette (`Ctrl/Cmd+Shift+P`).
31
+ 2. Run **TypeCAD: Debug with Breakpoints** — or set red-dot breakpoints in the
32
+ gutter and run `cuttlefish build --debug` in a terminal.
33
+ 3. Breakpoints (including conditional breakpoints and logpoints) are written
34
+ to `.cuttlefish/breakpoints.json` on every breakpoint change and on every
35
+ `.ts` save.
36
+ 4. Upload the instrumented firmware and open a serial monitor (`--monitor`).
37
+ At each breakpoint the firmware prints the location, the original source
38
+ line, and the variables in scope, then halts. Two keys are available:
39
+ - **ENTER** — continue (the breakpoint will halt here again the next time
40
+ execution reaches it).
41
+ - **`s`** — skip this breakpoint for the rest of the run: it won't halt
42
+ here again until the device reboots. Other breakpoints are unaffected.
43
+
44
+ ### Commands
45
+
46
+ | Command | Title |
47
+ |---|---|
48
+ | `typecad-debug.toggleBreakpoint` | TypeCAD: Toggle Breakpoint (bound to `F9` in `.ts` files) |
49
+ | `typecad-debug.clearAllBreakpoints` | TypeCAD: Clear All Breakpoints |
50
+ | `typecad-debug.debugWithBreakpoints` | TypeCAD: Debug with Breakpoints |
51
+ | `typecad-debug.syncBreakpoints` | TypeCAD: Sync Breakpoints from VS Code |
52
+ | `typecad-debug.generateDeclaration` | TypeCAD: Generate Declaration from C++ |
53
+
54
+ ### Enabling instrumentation
55
+
56
+ Breakpoints are only injected when cuttlefish is run with `--debug`:
57
+
58
+ ```sh
59
+ cuttlefish build --debug # uses cuttlefish.config.ts entry
60
+ cuttlefish src/index.ts --debug --framework @typecad/framework-arduino --compile --upload --port COM4
61
+ ```
62
+
63
+ See `cuttlefish --help` for the full `--debug` description.
64
+
65
+ ## `.cuttlefish/breakpoints.json` schema
66
+
67
+ The file lives at the project root (or any ancestor of the entry file's
68
+ directory). Each entry uses **the basename** of the source file as `file`
69
+ (this is the only path form that matches reliably on both Windows and POSIX
70
+ under cuttlefish's basename-matching loader):
71
+
72
+ ```jsonc
73
+ {
74
+ "breakpoints": [
75
+ { "file": "index.ts", "line": 12 },
76
+ { "file": "index.ts", "line": 27, "condition": "counter > 5" },
77
+ { "file": "sensor.ts", "line": 8, "logMessage": "reading = {value}" }
78
+ ]
79
+ }
80
+ ```
81
+
82
+ | Field | Type | Required | Notes |
83
+ |---|---|---|---|
84
+ | `file` | string | yes | Source file **basename** (e.g. `index.ts`). |
85
+ | `line` | number | yes | 1-indexed line number. `0` is dropped. |
86
+ | `condition` | string | no | Conditional expression; `===`/`!==` are auto-normalized to `==`/`!=` for C++. |
87
+ | `logMessage` | string | no | Logpoint with `{variable}` interpolation. When present, the breakpoint logs instead of halting. |
88
+
89
+ Two source files sharing the same basename in one project will share
90
+ breakpoints — acceptable for typical single-sketch Arduino projects.
91
+
92
+ ## Native debugging on ESP32-S3
93
+
94
+ For ESP32-S3, this extension's printf instrumentation is superseded by a
95
+ native GDB path. `cuttlefish build --debug` on `esp32s3` emits `#line`
96
+ directives in the generated C++ and writes `.vscode/launch.json` +
97
+ `tasks.json` (at the git/workspace root, where VS Code reads them) plus
98
+ `openocd.cfg` + `sdkconfig.defaults.debug` next to the build output. Press
99
+ **F5** in VS Code and the generated config attaches GDB to the chip's
100
+ built-in USB-Serial-JTAG — one USB cable, no external probe.
101
+
102
+ For Zephyr projects (`@typecad/framework-zephyr` on an esp32s3 board),
103
+ `cuttlefish create` writes the same starter artifacts at project creation —
104
+ `.vscode/launch.json` + `tasks.json` + `src/out/.cuttlefish/openocd.cfg` —
105
+ so F5 works on a fresh project before any build: the preLaunch task runs
106
+ `cuttlefish build --compile --upload --debug`, which builds, flashes, and
107
+ re-merges the launch entry with the build-cache-resolved gdbPath. (The
108
+ starter gdbPath is probed from `$ZEPHYR_SDK_INSTALL_DIR`, the
109
+ zephyr-installer micromamba layout, or `~/zephyr-sdk-*`.)
110
+
111
+ `launch.json` ships a single **`gdbtarget`** configuration, provided by the
112
+ ESP-IDF VS Code extension. The extension's gdbtarget adapter manages OpenOCD
113
+ itself (via its OpenOCD Manager, reading `idf.openOcdConfigs` from settings).
114
+ The `preLaunchTask` is just `build + flash` — no competing OpenOCD process.
115
+ Install the ESP-IDF extension (which bundles OpenOCD + the xtensa GDB, and
116
+ requires ESP-IDF itself configured), set the board's serial port in
117
+ `cuttlefish.config.ts` (`console.port`) or pass `--port`. See
118
+ `demos/demo/README.md` for the full F5 flow.
119
+
120
+ The printf instrumentation documented below remains the path for targets that
121
+ don't yet support native debugging (Arduino, other ESP32 variants).
122
+
123
+ ## Limitations
124
+
125
+ - This is a `Serial.print`-based instrumentation shim, not a DAP debug
126
+ adapter. There is no native step/step-in/step-out — each breakpoint halts
127
+ until ENTER (continue) or `s` (skip this breakpoint for the run) is received
128
+ over serial. **On ESP32-S3, use the native GDB path above instead** — it
129
+ provides full stepping, call stacks, and TS-named variable inspection.
130
+ - The scope analyzer captures module-scope identifiers plus locals and
131
+ parameters in the enclosing function. Member access and arbitrary
132
+ expressions are not resolved; `{ value }` in a logpoint emits the literal
133
+ `"{value}"` if `value` is not in scope.
134
+ - Baud rate is hardcoded to `9600` in the injected `Serial.begin` regardless
135
+ of the CLI `--baud` value.
136
+ - **Target-specific output:** on Arduino/AVR the injected code uses `Serial.*`
137
+ and blocks on `Serial.available()`. On ESP-IDF (`@typecad/framework-esp32`)
138
+ it routes through native `printf` and blocks on `getchar()` with the task
139
+ watchdog fed — so an ESP32 debug build must have `idf.py monitor` (or
140
+ equivalent) attached, or it will hang at the first breakpoint until power
141
+ is cycled. This is the ESP-IDF equivalent of "no IDE attached to a
142
+ breakpoint."
@@ -0,0 +1,347 @@
1
+ "use strict";
2
+ // ---------------------------------------------------------------------------
3
+ // vscode-typecad-debug — VSCode Extension
4
+ //
5
+ // Tracks breakpoints in TypeScript files and syncs them to
6
+ // .cuttlefish/breakpoints.json for the TypeCAD debug preprocessor.
7
+ // Also auto-generates .d.ts declaration files from C++ sources.
8
+ //
9
+ // The breakpoint file is read by @typecad/cuttlefish when invoked with
10
+ // `--debug`. The preprocessor injects Serial.println instrumentation at the
11
+ // recorded line numbers; run `cuttlefish build --debug` (or `cuttlefish
12
+ // index.ts --debug`) to enable it.
13
+ //
14
+ // IMPORTANT: the `file` field in each breakpoint entry is written as the
15
+ // basename only (e.g. "index.ts"). The cuttlefish loader matches breakpoints
16
+ // by exact → basename → suffix, and basename matching is the only strategy
17
+ // that works identically on Windows (backslash) and POSIX (forward slash)
18
+ // without slash normalization. The trade-off is that two files with the same
19
+ // basename in one project share breakpoints — acceptable for typical
20
+ // single-sketch Arduino projects.
21
+ // ---------------------------------------------------------------------------
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
29
+ }) : (function(o, m, k, k2) {
30
+ if (k2 === undefined) k2 = k;
31
+ o[k2] = m[k];
32
+ }));
33
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
34
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
35
+ }) : function(o, v) {
36
+ o["default"] = v;
37
+ });
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
55
+ Object.defineProperty(exports, "__esModule", { value: true });
56
+ exports.activate = activate;
57
+ exports.deactivate = deactivate;
58
+ const vscode = __importStar(require("vscode"));
59
+ const fs = __importStar(require("node:fs"));
60
+ const path = __importStar(require("node:path"));
61
+ const node_child_process_1 = require("node:child_process");
62
+ // ---------------------------------------------------------------------------
63
+ // Constants
64
+ // ---------------------------------------------------------------------------
65
+ /** Relative to the workspace root. */
66
+ const BREAKPOINTS_DIR = '.cuttlefish';
67
+ const BREAKPOINTS_FILE = 'breakpoints.json';
68
+ // ---------------------------------------------------------------------------
69
+ // Extension Activation
70
+ // ---------------------------------------------------------------------------
71
+ function activate(context) {
72
+ console.log('TypeCAD Debug extension activated');
73
+ const breakpointTracker = new BreakpointTracker();
74
+ const toggleCmd = vscode.commands.registerCommand('typecad-debug.toggleBreakpoint', () => breakpointTracker.toggleBreakpoint());
75
+ const clearAllCmd = vscode.commands.registerCommand('typecad-debug.clearAllBreakpoints', () => breakpointTracker.clearAllBreakpoints());
76
+ const debugCmd = vscode.commands.registerCommand('typecad-debug.debugWithBreakpoints', () => breakpointTracker.debugWithBreakpoints());
77
+ const syncCmd = vscode.commands.registerCommand('typecad-debug.syncBreakpoints', () => breakpointTracker.syncFromVSCode());
78
+ // Auto-sync breakpoints when saving TypeScript files.
79
+ const saveListener = vscode.workspace.onDidSaveTextDocument((doc) => {
80
+ if (doc.fileName.endsWith('.ts') && !doc.fileName.includes('node_modules')) {
81
+ breakpointTracker.syncFromVSCode();
82
+ }
83
+ });
84
+ const declGenerator = new DeclarationGenerator();
85
+ const genDeclCmd = vscode.commands.registerCommand('typecad-debug.generateDeclaration', () => declGenerator.generateForCurrentFile());
86
+ // Auto-generate a .d.ts when a C++ file is saved and the sidecar is missing.
87
+ const cppSaveListener = vscode.workspace.onDidSaveTextDocument((doc) => {
88
+ if (doc.fileName.endsWith('.cpp') && !doc.fileName.includes('node_modules')) {
89
+ declGenerator.checkAndGenerate(doc.fileName);
90
+ }
91
+ });
92
+ context.subscriptions.push(toggleCmd, clearAllCmd, debugCmd, syncCmd, saveListener, breakpointTracker, genDeclCmd, cppSaveListener, declGenerator);
93
+ }
94
+ function deactivate() { }
95
+ // ---------------------------------------------------------------------------
96
+ // Breakpoint Tracker
97
+ // ---------------------------------------------------------------------------
98
+ class BreakpointTracker {
99
+ constructor() {
100
+ /** file fsPath → line → Breakpoint. Keys are full fsPaths for dedup. */
101
+ this.breakpoints = new Map();
102
+ this._onDidChange = new vscode.EventEmitter();
103
+ this.onDidChange = this._onDidChange.event;
104
+ this.loadFromFile();
105
+ // VSCode breakpoint gutter changes (red dots, conditions, logpoints).
106
+ vscode.debug.onDidChangeBreakpoints(() => {
107
+ console.log('TypeCAD: Breakpoint change detected');
108
+ this.syncFromVSCode();
109
+ });
110
+ // Re-sync when switching editor so a stale in-memory map doesn't survive.
111
+ vscode.window.onDidChangeActiveTextEditor((editor) => {
112
+ if (editor) {
113
+ this.syncFromVSCode();
114
+ }
115
+ });
116
+ }
117
+ /**
118
+ * Toggle a breakpoint at the current cursor position.
119
+ */
120
+ toggleBreakpoint() {
121
+ const editor = vscode.window.activeTextEditor;
122
+ if (!editor)
123
+ return;
124
+ const filePath = editor.document.uri.fsPath;
125
+ const fileName = path.basename(filePath);
126
+ const line = editor.selection.active.line + 1; // 1-indexed
127
+ if (!this.breakpoints.has(fileName)) {
128
+ this.breakpoints.set(fileName, new Map());
129
+ }
130
+ const fileBreakpoints = this.breakpoints.get(fileName);
131
+ if (fileBreakpoints.has(line)) {
132
+ fileBreakpoints.delete(line);
133
+ vscode.window.showInformationMessage(`TypeCAD: Breakpoint removed at line ${line}`);
134
+ }
135
+ else {
136
+ fileBreakpoints.set(line, { file: fileName, line });
137
+ vscode.window.showInformationMessage(`TypeCAD: Breakpoint added at line ${line}`);
138
+ }
139
+ this.saveToFile();
140
+ this._onDidChange.fire();
141
+ }
142
+ /**
143
+ * Clear all breakpoints.
144
+ */
145
+ clearAllBreakpoints() {
146
+ this.breakpoints.clear();
147
+ this.saveToFile();
148
+ vscode.window.showInformationMessage('TypeCAD: All breakpoints cleared');
149
+ this._onDidChange.fire();
150
+ }
151
+ /**
152
+ * Save breakpoints, then run `cuttlefish build --debug` in a terminal.
153
+ */
154
+ async debugWithBreakpoints() {
155
+ const editor = vscode.window.activeTextEditor;
156
+ if (!editor) {
157
+ vscode.window.showErrorMessage('TypeCAD: No active editor');
158
+ return;
159
+ }
160
+ this.saveToFile();
161
+ const terminal = vscode.window.createTerminal('TypeCAD Debug');
162
+ terminal.show();
163
+ terminal.sendText('npx cuttlefish build --debug');
164
+ }
165
+ /**
166
+ * Sync breakpoints from VSCode's built-in breakpoint system.
167
+ * Captures conditional breakpoints and logpoints.
168
+ * REPLACES all breakpoints with the current VS Code state.
169
+ */
170
+ syncFromVSCode() {
171
+ const vscodeBreakpoints = vscode.debug.breakpoints;
172
+ console.log(`TypeCAD: Syncing ${vscodeBreakpoints.length} breakpoints from VS Code`);
173
+ this.breakpoints.clear();
174
+ let count = 0;
175
+ for (const bp of vscodeBreakpoints) {
176
+ if (bp instanceof vscode.SourceBreakpoint) {
177
+ // Key the in-memory map by basename so saveToFile and the toggle path
178
+ // agree on a single canonical key. The loader matches by basename.
179
+ const filePath = bp.location.uri.fsPath;
180
+ const fileName = path.basename(filePath);
181
+ const line = bp.location.range.start.line + 1; // 1-indexed
182
+ if (!this.breakpoints.has(fileName)) {
183
+ this.breakpoints.set(fileName, new Map());
184
+ }
185
+ this.breakpoints.get(fileName).set(line, {
186
+ file: fileName,
187
+ line,
188
+ condition: bp.condition,
189
+ logMessage: bp.logMessage, // LogMessageBreakpoint has this property
190
+ });
191
+ count++;
192
+ }
193
+ }
194
+ this.saveToFile();
195
+ vscode.window.setStatusBarMessage(`TypeCAD: Synced ${count} breakpoints`, 3000);
196
+ console.log(`TypeCAD: Synced ${count} breakpoints to file`);
197
+ }
198
+ /**
199
+ * Load breakpoints from .cuttlefish/breakpoints.json
200
+ */
201
+ loadFromFile() {
202
+ const workspaceFolders = vscode.workspace.workspaceFolders;
203
+ if (!workspaceFolders || workspaceFolders.length === 0)
204
+ return;
205
+ const filePath = path.join(workspaceFolders[0].uri.fsPath, BREAKPOINTS_DIR, BREAKPOINTS_FILE);
206
+ if (!fs.existsSync(filePath))
207
+ return;
208
+ try {
209
+ const content = fs.readFileSync(filePath, 'utf8');
210
+ const map = JSON.parse(content);
211
+ for (const bp of map.breakpoints ?? []) {
212
+ if (!this.breakpoints.has(bp.file)) {
213
+ this.breakpoints.set(bp.file, new Map());
214
+ }
215
+ this.breakpoints.get(bp.file).set(bp.line, bp);
216
+ }
217
+ }
218
+ catch (err) {
219
+ console.error('TypeCAD: Failed to load breakpoints:', err);
220
+ }
221
+ }
222
+ /**
223
+ * Save breakpoints to .cuttlefish/breakpoints.json atomically.
224
+ * Writes to a temp file then renames, so a watching transpiler never reads
225
+ * a half-written file.
226
+ */
227
+ saveToFile() {
228
+ const workspaceFolders = vscode.workspace.workspaceFolders;
229
+ if (!workspaceFolders || workspaceFolders.length === 0) {
230
+ console.log('TypeCAD: No workspace folder, skipping save');
231
+ return;
232
+ }
233
+ const dirPath = path.join(workspaceFolders[0].uri.fsPath, BREAKPOINTS_DIR);
234
+ const filePath = path.join(dirPath, BREAKPOINTS_FILE);
235
+ const tmpPath = `${filePath}.tmp`;
236
+ try {
237
+ if (!fs.existsSync(dirPath)) {
238
+ fs.mkdirSync(dirPath, { recursive: true });
239
+ }
240
+ }
241
+ catch (mkdirErr) {
242
+ console.error('TypeCAD: Failed to create directory:', mkdirErr);
243
+ vscode.window.showErrorMessage(`TypeCAD: Failed to create ${BREAKPOINTS_DIR} directory: ${mkdirErr}`);
244
+ return;
245
+ }
246
+ const map = { breakpoints: [] };
247
+ for (const [, fileBreakpoints] of this.breakpoints) {
248
+ for (const [, bp] of fileBreakpoints) {
249
+ map.breakpoints.push(bp);
250
+ }
251
+ }
252
+ // Stable order for clean diffs and reproducible output.
253
+ map.breakpoints.sort((a, b) => {
254
+ if (a.file !== b.file)
255
+ return a.file.localeCompare(b.file);
256
+ return a.line - b.line;
257
+ });
258
+ try {
259
+ fs.writeFileSync(tmpPath, JSON.stringify(map, null, 2));
260
+ fs.renameSync(tmpPath, filePath);
261
+ console.log(`TypeCAD: Saved ${map.breakpoints.length} breakpoints to ${filePath}`);
262
+ }
263
+ catch (err) {
264
+ // Best effort: clean up the temp file on failure.
265
+ try {
266
+ fs.unlinkSync(tmpPath);
267
+ }
268
+ catch { }
269
+ console.error('TypeCAD: Failed to save breakpoints:', err);
270
+ vscode.window.showErrorMessage(`TypeCAD: Failed to save breakpoints: ${err}`);
271
+ }
272
+ }
273
+ dispose() {
274
+ this._onDidChange.dispose();
275
+ }
276
+ }
277
+ // ---------------------------------------------------------------------------
278
+ // Declaration Generator
279
+ // ---------------------------------------------------------------------------
280
+ class DeclarationGenerator {
281
+ /**
282
+ * Generate a .d.ts sidecar for a C++ file if one is not already present.
283
+ */
284
+ async checkAndGenerate(cppPath) {
285
+ const declPath = cppPath.replace(/\.cpp$/i, '.d.ts');
286
+ if (fs.existsSync(declPath)) {
287
+ return; // Already exists — never clobber.
288
+ }
289
+ const result = await this.generateDeclaration(cppPath, declPath);
290
+ if (result) {
291
+ vscode.window.showInformationMessage(`TypeCAD: Generated ${path.basename(declPath)} from ${path.basename(cppPath)}. Review and adjust types if needed.`);
292
+ }
293
+ }
294
+ /**
295
+ * Generate a declaration for the currently active C++ file.
296
+ */
297
+ async generateForCurrentFile() {
298
+ const editor = vscode.window.activeTextEditor;
299
+ if (!editor) {
300
+ vscode.window.showErrorMessage('TypeCAD: No active editor');
301
+ return;
302
+ }
303
+ const filePath = editor.document.uri.fsPath;
304
+ if (!filePath.endsWith('.cpp')) {
305
+ vscode.window.showErrorMessage('TypeCAD: Active file must be a .cpp file');
306
+ return;
307
+ }
308
+ const declPath = filePath.replace(/\.cpp$/i, '.d.ts');
309
+ const result = await this.generateDeclaration(filePath, declPath);
310
+ if (result) {
311
+ vscode.window.showInformationMessage(`TypeCAD: Generated ${path.basename(declPath)}`);
312
+ const doc = await vscode.workspace.openTextDocument(result);
313
+ await vscode.window.showTextDocument(doc);
314
+ }
315
+ else {
316
+ vscode.window.showWarningMessage('TypeCAD: No classes or constants found in C++ file');
317
+ }
318
+ }
319
+ /**
320
+ * Generate a .d.ts file from a C++ file via the cuttlefish CLI.
321
+ * Uses the monorepo source directly when developing inside this repo,
322
+ * falls back to `npx cuttlefish` for installed users.
323
+ */
324
+ async generateDeclaration(cppPath, declPath) {
325
+ return new Promise((resolve) => {
326
+ const workspaceFolders = vscode.workspace.workspaceFolders;
327
+ // Local-CLI fallback for development inside the typecode monorepo.
328
+ const localCliPath = workspaceFolders
329
+ ? path.join(workspaceFolders[0].uri.fsPath, 'packages/cuttlefish/src/cli.ts')
330
+ : null;
331
+ const cmd = localCliPath && fs.existsSync(localCliPath)
332
+ ? `npx tsx "${localCliPath}" gen-decls "${cppPath}"`
333
+ : `npx cuttlefish gen-decls "${cppPath}"`;
334
+ (0, node_child_process_1.exec)(cmd, { cwd: workspaceFolders?.[0]?.uri.fsPath }, (error) => {
335
+ if (error) {
336
+ console.error('TypeCAD: Failed to generate declaration:', error);
337
+ vscode.window.showErrorMessage(`TypeCAD: Failed to generate declaration: ${error.message}`);
338
+ resolve(null);
339
+ return;
340
+ }
341
+ resolve(fs.existsSync(declPath) ? declPath : null);
342
+ });
343
+ });
344
+ }
345
+ dispose() { }
346
+ }
347
+ //# sourceMappingURL=extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,0CAA0C;AAC1C,EAAE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B,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC;YAC3D,mEAAmE;YACnE,MAAM,YAAY,GAAG,gBAAgB;gBACnC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,gCAAgC,CAAC;gBAC7E,CAAC,CAAC,IAAI,CAAC;YAET,MAAM,GAAG,GAAG,YAAY,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;gBACrD,CAAC,CAAC,YAAY,YAAY,gBAAgB,OAAO,GAAG;gBACpD,CAAC,CAAC,6BAA6B,OAAO,GAAG,CAAC;YAE5C,IAAA,yBAAI,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC9D,IAAI,KAAK,EAAE,CAAC;oBACV,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;oBACjE,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,4CAA4C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;oBAC5F,OAAO,CAAC,IAAI,CAAC,CAAC;oBACd,OAAO;gBACT,CAAC;gBACD,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAU,CAAC;CACnB"}
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "vscode-typecad-debug",
3
+ "displayName": "TypeCAD Debug",
4
+ "description": "Breakpoint debugging for TypeCAD embedded projects",
5
+ "version": "0.2.0",
6
+ "private": true,
7
+ "publisher": "typecad",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/justind000/typecode.git"
12
+ },
13
+ "engines": {
14
+ "vscode": "^1.85.0"
15
+ },
16
+ "categories": [
17
+ "Debuggers"
18
+ ],
19
+ "activationEvents": [
20
+ "onLanguage:typescript",
21
+ "workspaceContains:**/cuttlefish.config.ts"
22
+ ],
23
+ "main": "./out/extension.js",
24
+ "contributes": {
25
+ "commands": [
26
+ {
27
+ "command": "typecad-debug.toggleBreakpoint",
28
+ "title": "TypeCAD: Toggle Breakpoint"
29
+ },
30
+ {
31
+ "command": "typecad-debug.clearAllBreakpoints",
32
+ "title": "TypeCAD: Clear All Breakpoints"
33
+ },
34
+ {
35
+ "command": "typecad-debug.debugWithBreakpoints",
36
+ "title": "TypeCAD: Debug with Breakpoints"
37
+ },
38
+ {
39
+ "command": "typecad-debug.syncBreakpoints",
40
+ "title": "TypeCAD: Sync Breakpoints from VS Code"
41
+ },
42
+ {
43
+ "command": "typecad-debug.generateDeclaration",
44
+ "title": "TypeCAD: Generate Declaration from C++"
45
+ }
46
+ ],
47
+ "keybindings": [
48
+ {
49
+ "command": "typecad-debug.toggleBreakpoint",
50
+ "key": "f9",
51
+ "when": "editorTextFocus && resourceExtname == .ts"
52
+ }
53
+ ],
54
+ "menus": {
55
+ "editor/context": [
56
+ {
57
+ "command": "typecad-debug.toggleBreakpoint",
58
+ "group": "debug",
59
+ "when": "resourceExtname == .ts"
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ "scripts": {
65
+ "vscode:prepublish": "npm run compile",
66
+ "compile": "tsc -p ./",
67
+ "watch": "tsc -watch -p ./",
68
+ "package": "vsce package --no-yarn --no-dependencies"
69
+ },
70
+ "devDependencies": {
71
+ "@types/node": "^22.10.7",
72
+ "@types/vscode": "^1.85.0",
73
+ "@vscode/vsce": "^3.2.0",
74
+ "typescript": "^5.7.3"
75
+ }
76
+ }
@@ -0,0 +1,27 @@
1
+ MIT License with third-party attribution
2
+
3
+ Copyright (c) TypeCAD contributors
4
+
5
+ TextMate grammar and language configuration adapted from sveltejs/language-tools
6
+ (https://github.com/sveltejs/language-tools), Copyright (c) 2020-Present
7
+ sveltejs/language-tools contributors, MIT licensed:
8
+
9
+ Copyright (c) 2020-Present sveltejs/language-tools contributors
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in
19
+ all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # TypeCAD UI (.ui) Syntax
2
+
3
+ Syntax highlighting and editor support for cuttlefish `.ui` single-file
4
+ components. A `.ui` file interleaves three streams — TypeScript in `<script>`,
5
+ CSS in `<style>`, and Svelte-style markup (`on:click={handler}`,
6
+ `{expression}` interpolations) — and the grammar highlights all three by
7
+ embedding VS Code's builtin TypeScript, CSS, and HTML grammars.
8
+
9
+ Beyond the grammar, the extension statically contributes:
10
+
11
+ - **Snippets** for the `.ui` idioms (`screen`, `button`, `bind`, `signal`,
12
+ `canvas`, `list`, …) — type the prefix and Tab.
13
+ - **Markdown injection** so ` ```ui ` fenced blocks highlight in docs.
14
+ - **File icons** for `.ui` files, shown when the active icon theme has no
15
+ mapping (VS Code's default Seti theme has none).
16
+ - **Word/indentation rules** so `{expr}` and `on:click` select as one word and
17
+ Enter indents inside tags and braces.
18
+
19
+ This is a grammar-only extension: no activation events, no code, no
20
+ dependencies beyond static contributions. It never runs anything.
21
+
22
+ ## Why it lives here
23
+
24
+ `cuttlefish create` copies this folder into each new project's
25
+ `.vscode/extensions/typecad-ui/`. VS Code (1.89+, trusted workspaces) detects
26
+ workspace-bundled extensions and installs them scoped to that workspace — the
27
+ project carries its own highlighting with no marketplace install. The
28
+ scaffold also writes `.vscode/extensions.json` with a `forceInstall` entry so
29
+ current VS Code builds install it without a prompt once that feature ships.
30
+
31
+ ## Attribution
32
+
33
+ The TextMate grammar and language configuration are adapted from the Svelte
34
+ team's work in [sveltejs/language-tools]
35
+ (https://github.com/sveltejs/language-tools) (`svelte-vscode/syntaxes/
36
+ svelte.tmLanguage.src.yaml` and `svelte-vscode/language-configuration.json`),
37
+ MIT licensed — see LICENSE. Adaptations: scopes renamed from `source.svelte`
38
+ to `source.typecad-ui`, Svelte built-in element patterns (`<svelte:*>`)
39
+ removed, folding markers adjusted for `<screen>` roots. The `.ui` format is a
40
+ Svelte-syntax subset, so the grammar is otherwise kept structurally identical
41
+ to stay close to upstream.
42
+
43
+ ## Manual install (existing projects)
44
+
45
+ Copy this folder to `<project>/.vscode/extensions/typecad-ui/` and reload the
46
+ VS Code window. Commit it so collaborators get highlighting too.
47
+
48
+ ## Regenerating the icon
49
+
50
+ `icon.png` is rendered by `scripts/render-typecad-ui-icon.mjs` at the repo
51
+ root (dependency-free SDF rasterizer). Re-run it after changing the design or
52
+ dimensions in that script.