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

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 (315) hide show
  1. package/README.md +82 -79
  2. package/assets/editor-extensions/typecad-debug/README.md +25 -26
  3. package/dist/api/config.d.ts +22 -26
  4. package/dist/api/schema/types.d.ts +20 -3
  5. package/dist/api/shared/async-runtime-static.d.ts +1 -1
  6. package/dist/api/shared/async-runtime-static.js +5 -5
  7. package/dist/api/shared/async-types.d.ts +3 -2
  8. package/dist/api/shared/board-catalog.d.ts +2 -0
  9. package/dist/api/shared/board-catalog.js +6 -0
  10. package/dist/api/shared/board-resolver.d.ts +4 -7
  11. package/dist/api/shared/board-resolver.js +2 -1
  12. package/dist/api/shared/coop-scheduler.d.ts +1 -1
  13. package/dist/api/shared/coop-scheduler.js +1 -1
  14. package/dist/api/shared/cpp-type-ir.d.ts +1 -1
  15. package/dist/api/shared/cpp-type-ir.js +1 -1
  16. package/dist/api/shared/display-profile.d.ts +1 -1
  17. package/dist/api/shared/display-profile.js +3 -5
  18. package/dist/api/shared/framework-manifest-registry.d.ts +1 -1
  19. package/dist/api/shared/framework-manifest-registry.js +0 -1
  20. package/dist/api/shared/framework-manifest.d.ts +7 -6
  21. package/dist/api/shared/framework-manifest.js +6 -11
  22. package/dist/api/shared/hal-op-ir.d.ts +294 -685
  23. package/dist/api/shared/hal-op-ir.js +31 -65
  24. package/dist/api/shared/index.d.ts +0 -4
  25. package/dist/api/shared/index.js +1 -7
  26. package/dist/api/shared/ir-core.d.ts +6 -0
  27. package/dist/api/shared/ir-declarations.d.ts +4 -0
  28. package/dist/api/shared/ir.d.ts +1 -3
  29. package/dist/api/shared/platform-strategy.d.ts +14 -37
  30. package/dist/api/shared/polyfill-helper-registry.js +0 -5
  31. package/dist/api/shared/polyfill-types.js +0 -27
  32. package/dist/api/shared/promise-runtime.js +3 -3
  33. package/dist/api/shared/spdx-licenses.d.ts +12 -10
  34. package/dist/api/shared/spdx-licenses.js +1 -1
  35. package/dist/api/shared/toolchain-types.d.ts +1 -1
  36. package/dist/api/shared/toolchain-types.js +3 -3
  37. package/dist/api/shared/types.d.ts +0 -3
  38. package/dist/api/shared/validate-framework-manifest.js +13 -33
  39. package/dist/board-catalog/dts-reader.d.ts +220 -0
  40. package/dist/board-catalog/dts-reader.js +1052 -0
  41. package/dist/board-catalog/index.d.ts +11 -0
  42. package/dist/board-catalog/index.js +12 -0
  43. package/dist/board-catalog/pinconfig.d.ts +48 -0
  44. package/dist/board-catalog/pinconfig.js +263 -0
  45. package/dist/board-catalog/sdk.d.ts +82 -0
  46. package/dist/board-catalog/sdk.js +180 -0
  47. package/dist/board-catalog/store.d.ts +196 -0
  48. package/dist/board-catalog/store.js +363 -0
  49. package/dist/board-catalog/types.d.ts +233 -0
  50. package/dist/board-catalog/types.js +7 -0
  51. package/dist/board-catalog/walker.d.ts +112 -0
  52. package/dist/board-catalog/walker.js +1101 -0
  53. package/dist/cli-utils.d.ts +2 -2
  54. package/dist/cli-utils.js +5 -5
  55. package/dist/cli.js +219 -242
  56. package/dist/config-loader.d.ts +14 -19
  57. package/dist/config-loader.js +240 -78
  58. package/dist/config-schema.d.ts +3 -5
  59. package/dist/config-schema.js +8 -8
  60. package/dist/contract/board-generator.d.ts +4 -4
  61. package/dist/contract/board-generator.js +16 -5
  62. package/dist/contract/contract-parser.d.ts +27 -0
  63. package/dist/contract/contract-parser.js +76 -0
  64. package/dist/contract/index.d.ts +1 -1
  65. package/dist/contract/index.js +70 -21
  66. package/dist/create/active-board-catalog.d.ts +9 -0
  67. package/dist/create/active-board-catalog.js +94 -0
  68. package/dist/create/board-catalog.generated.d.ts +96 -0
  69. package/dist/create/board-catalog.generated.js +128737 -0
  70. package/dist/create/board-search.d.ts +23 -0
  71. package/dist/create/board-search.js +88 -0
  72. package/dist/create/editor-integration.d.ts +4 -2
  73. package/dist/create/editor-integration.js +41 -2
  74. package/dist/create/framework-catalog.d.ts +57 -9
  75. package/dist/create/framework-catalog.js +76 -57
  76. package/dist/create/index.d.ts +5 -11
  77. package/dist/create/index.js +3 -8
  78. package/dist/create/mcu-target.d.ts +39 -0
  79. package/dist/create/mcu-target.js +80 -0
  80. package/dist/create/pack-targets.d.ts +19 -0
  81. package/dist/create/pack-targets.js +56 -0
  82. package/dist/create/scaffold.d.ts +4 -7
  83. package/dist/create/scaffold.js +19 -109
  84. package/dist/create/templates.d.ts +32 -5
  85. package/dist/create/templates.js +130 -116
  86. package/dist/create/wizard.d.ts +12 -1
  87. package/dist/create/wizard.js +168 -38
  88. package/dist/debug/preprocessor.d.ts +5 -0
  89. package/dist/debug/preprocessor.js +31 -7
  90. package/dist/diagnostics/diagnostics-report.d.ts +1 -1
  91. package/dist/diagnostics/diagnostics-report.js +3 -11
  92. package/dist/diagnostics/json-schema.d.ts +1 -1
  93. package/dist/diagnostics/md-writer.js +2 -2
  94. package/dist/diagnostics/mermaid-builder.d.ts +1 -1
  95. package/dist/diagnostics/mermaid-builder.js +1 -1
  96. package/dist/emit/cpp-emitter.js +4 -1
  97. package/dist/emit/emitters/class-emitter.js +32 -4
  98. package/dist/emit/emitters/emitter-context.d.ts +11 -0
  99. package/dist/emit/emitters/entrypoint-synthesizer.js +1 -1
  100. package/dist/emit/emitters/function-emitter-impl.js +33 -17
  101. package/dist/emit/emitters/output-finalizer.d.ts +7 -0
  102. package/dist/emit/emitters/output-finalizer.js +31 -23
  103. package/dist/emit/emitters/setup.js +125 -63
  104. package/dist/emit/emitters/top-level-prep.js +1 -1
  105. package/dist/emit/emitters/type-decl-emitter.js +13 -8
  106. package/dist/emit/emitters/ui-emitter.js +1 -1
  107. package/dist/emit/expression-renderer.d.ts +3 -3
  108. package/dist/emit/expression-renderer.js +17 -7
  109. package/dist/emit/route-hal-op.js +17 -48
  110. package/dist/emit/snprintf-helpers.d.ts +1 -3
  111. package/dist/emit/snprintf-helpers.js +1 -39
  112. package/dist/emit/statement-renderer.d.ts +0 -4
  113. package/dist/emit/statement-renderer.js +54 -45
  114. package/dist/emit/utils/async-state-machine.d.ts +16 -9
  115. package/dist/emit/utils/async-state-machine.js +56 -54
  116. package/dist/emit/utils/comment-helpers.d.ts +0 -8
  117. package/dist/emit/utils/comment-helpers.js +1 -1
  118. package/dist/emit/utils/cpp-helpers.d.ts +2 -2
  119. package/dist/emit/utils/cpp-helpers.js +2 -2
  120. package/dist/emit/utils/hal-op-cpp-type.js +4 -6
  121. package/dist/emit/utils/index.d.ts +3 -3
  122. package/dist/emit/utils/index.js +3 -3
  123. package/dist/emit/utils/type-inference.d.ts +1 -29
  124. package/dist/emit/utils/type-inference.js +0 -75
  125. package/dist/framework-package.d.ts +3 -0
  126. package/dist/framework-package.js +23 -6
  127. package/dist/framework-registry.d.ts +5 -5
  128. package/dist/frameworks/native/graphics/terminal-preview.d.ts +5 -0
  129. package/dist/frameworks/native/graphics/terminal-preview.js +33 -0
  130. package/dist/frameworks/native/index.d.ts +3 -0
  131. package/dist/frameworks/native/index.js +15 -0
  132. package/dist/frameworks/native/native-compile.d.ts +17 -0
  133. package/dist/frameworks/native/native-compile.js +170 -0
  134. package/dist/frameworks/native/native-config.d.ts +41 -0
  135. package/dist/frameworks/native/native-config.js +7 -0
  136. package/dist/frameworks/native/strategy.d.ts +97 -0
  137. package/dist/frameworks/native/strategy.js +664 -0
  138. package/dist/ir/board-resolver.d.ts +18 -23
  139. package/dist/ir/board-resolver.js +43 -401
  140. package/dist/ir/build-ir-state.d.ts +3 -0
  141. package/dist/ir/build-ir-state.js +42 -0
  142. package/dist/ir/build-ir.d.ts +1 -1
  143. package/dist/ir/build-ir.js +40 -42
  144. package/dist/ir/declaration-builders.js +1 -0
  145. package/dist/ir/expression-to-ir.js +17 -10
  146. package/dist/ir/hal/hal-emitter.d.ts +0 -2
  147. package/dist/ir/hal/hal-emitter.js +92 -41
  148. package/dist/ir/hal/hal-parser.d.ts +5 -5
  149. package/dist/ir/hal/hal-parser.js +128 -36
  150. package/dist/ir/hal/hal-plugins.d.ts +0 -1
  151. package/dist/ir/hal/hal-plugins.js +425 -716
  152. package/dist/ir/heap-analysis.js +2 -41
  153. package/dist/ir/identifier-collector.js +32 -20
  154. package/dist/ir/network-validation.js +7 -11
  155. package/dist/ir/ownership-analysis.js +75 -13
  156. package/dist/ir/peripheral-usage.d.ts +8 -2
  157. package/dist/ir/peripheral-usage.js +78 -149
  158. package/dist/ir/peripheral-validation.js +23 -3
  159. package/dist/ir/pin-capability-validation.d.ts +12 -0
  160. package/dist/ir/pin-capability-validation.js +61 -97
  161. package/dist/ir/pin-mode-validation.js +5 -5
  162. package/dist/ir/program-analysis.d.ts +8 -15
  163. package/dist/ir/program-analysis.js +140 -323
  164. package/dist/ir/pulldown-validation.js +11 -4
  165. package/dist/ir/resource-analysis.js +15 -3
  166. package/dist/ir/statement-to-ir.js +0 -6
  167. package/dist/ir/timing-validation.js +1 -1
  168. package/dist/ir/transformers/array-methods.js +11 -5
  169. package/dist/ir/transformers/call-statement.js +20 -87
  170. package/dist/ir/transformers/callback-context-registry.d.ts +1 -1
  171. package/dist/ir/transformers/callback-context-registry.js +8 -16
  172. package/dist/ir/transformers/control-flow.js +0 -13
  173. package/dist/ir/transformers/expressions.js +10 -9
  174. package/dist/ir/transformers/hal-call-resolver.d.ts +2 -2
  175. package/dist/ir/transformers/hal-call-resolver.js +24 -10
  176. package/dist/ir/transformers/hal-emit-helpers.d.ts +2 -2
  177. package/dist/ir/transformers/hal-emit-helpers.js +2 -2
  178. package/dist/ir/transformers/namespace-methods.js +1 -1
  179. package/dist/ir/transformers/ui-callback-lowering.d.ts +0 -2
  180. package/dist/ir/transformers/ui-callback-lowering.js +0 -24
  181. package/dist/ir/transformers/variables.js +338 -42
  182. package/dist/ir/try-catch-validation.js +4 -3
  183. package/dist/ir/type-resolution.js +15 -4
  184. package/dist/ir/validation-orchestrator.js +0 -9
  185. package/dist/libdef/cpp-to-decl.d.ts +0 -9
  186. package/dist/libdef/cpp-to-decl.js +0 -72
  187. package/dist/libdef/registry.d.ts +0 -1
  188. package/dist/libdef/registry.js +1 -24
  189. package/dist/library/init.d.ts +1 -1
  190. package/dist/library/init.js +137 -137
  191. package/dist/library-packages.d.ts +1 -1
  192. package/dist/library-packages.js +1 -1
  193. package/dist/mapping/peripheral-names.js +9 -4
  194. package/dist/mapping/source-map.d.ts +3 -4
  195. package/dist/mapping/source-map.js +12 -18
  196. package/dist/orchestrator/graph-builder.d.ts +3 -3
  197. package/dist/orchestrator/graph-builder.js +13 -12
  198. package/dist/orchestrator/type-checker.d.ts +3 -3
  199. package/dist/orchestrator/type-checker.js +3 -3
  200. package/dist/platform/async-runtime.js +1 -1
  201. package/dist/platform/coop-scheduler-runtime.js +2 -2
  202. package/dist/platform/generic-debug-codegen.d.ts +36 -0
  203. package/dist/platform/generic-debug-codegen.js +185 -0
  204. package/dist/platform/generic-strategy.d.ts +3 -4
  205. package/dist/platform/generic-strategy.js +5 -80
  206. package/dist/platform/index.js +1 -1
  207. package/dist/platform/registry.d.ts +2 -2
  208. package/dist/platform/registry.js +2 -2
  209. package/dist/safety/asil-decorators.d.ts +32 -0
  210. package/dist/safety/asil-decorators.js +32 -0
  211. package/dist/safety/authoring.d.ts +85 -0
  212. package/dist/safety/authoring.js +61 -0
  213. package/dist/safety/engine.d.ts +3 -0
  214. package/dist/safety/engine.js +83 -0
  215. package/dist/safety/hal/ops.d.ts +48 -0
  216. package/dist/safety/hal/ops.js +46 -0
  217. package/dist/safety/iso26262/analyze.d.ts +13 -0
  218. package/dist/safety/iso26262/analyze.js +29 -0
  219. package/dist/safety/iso26262/asil.d.ts +10 -0
  220. package/dist/safety/iso26262/asil.js +22 -0
  221. package/dist/safety/iso26262/collect.d.ts +14 -0
  222. package/dist/safety/iso26262/collect.js +137 -0
  223. package/dist/safety/iso26262/goto-checker.d.ts +10 -0
  224. package/dist/safety/iso26262/goto-checker.js +72 -0
  225. package/dist/safety/iso26262/heap-checker.d.ts +7 -0
  226. package/dist/safety/iso26262/heap-checker.js +57 -0
  227. package/dist/safety/iso26262/init-checker.d.ts +13 -0
  228. package/dist/safety/iso26262/init-checker.js +127 -0
  229. package/dist/safety/iso26262/loop-checker.d.ts +7 -0
  230. package/dist/safety/iso26262/loop-checker.js +86 -0
  231. package/dist/safety/iso26262/recursion-checker.d.ts +9 -0
  232. package/dist/safety/iso26262/recursion-checker.js +134 -0
  233. package/dist/safety/iso26262/sidecar-writer.d.ts +25 -0
  234. package/dist/safety/iso26262/sidecar-writer.js +13 -0
  235. package/dist/safety/passes/pinMode-intercept.d.ts +3 -0
  236. package/dist/safety/passes/pinMode-intercept.js +60 -0
  237. package/dist/safety/runtime/mode-table.d.ts +5 -0
  238. package/dist/safety/runtime/mode-table.js +55 -0
  239. package/dist/safety/runtime/polyfills.d.ts +6 -0
  240. package/dist/safety/runtime/polyfills.js +12 -0
  241. package/dist/safety/runtime/result-struct.d.ts +11 -0
  242. package/dist/safety/runtime/result-struct.js +98 -0
  243. package/dist/safety/runtime/safe-int.d.ts +33 -0
  244. package/dist/safety/runtime/safe-int.js +170 -0
  245. package/dist/safety/runtime/safe-traits.d.ts +4 -0
  246. package/dist/safety/runtime/safe-traits.js +95 -0
  247. package/dist/safety/runtime/safe-variable.d.ts +39 -0
  248. package/dist/safety/runtime/safe-variable.js +226 -0
  249. package/dist/safety/runtime/vote.d.ts +8 -0
  250. package/dist/safety/runtime/vote.js +92 -0
  251. package/dist/safety/runtime/write-verify.d.ts +8 -0
  252. package/dist/safety/runtime/write-verify.js +71 -0
  253. package/dist/safety/safe-int-types.d.ts +45 -0
  254. package/dist/safety/safe-int-types.js +25 -0
  255. package/dist/safety/safe-variable-types.d.ts +29 -0
  256. package/dist/safety/safe-variable-types.js +19 -0
  257. package/dist/safety/safety-bridge.d.ts +5 -6
  258. package/dist/safety/safety-bridge.js +15 -28
  259. package/dist/safety/sidecar-bridge.d.ts +1 -3
  260. package/dist/safety/sidecar-bridge.js +3 -20
  261. package/dist/safety/specifiers.d.ts +6 -0
  262. package/dist/safety/specifiers.js +14 -0
  263. package/dist/safety-hook.d.ts +8 -7
  264. package/dist/safety-hook.js +12 -13
  265. package/dist/testing.d.ts +4 -5
  266. package/dist/testing.js +5 -5
  267. package/dist/transpile/resolution.d.ts +1 -1
  268. package/dist/transpile/resolution.js +18 -9
  269. package/dist/transpile/test-pins.d.ts +18 -0
  270. package/dist/transpile/test-pins.js +142 -0
  271. package/dist/transpile.d.ts +1 -2
  272. package/dist/transpile.js +36 -30
  273. package/dist/types.d.ts +26 -26
  274. package/dist/ui-hook.d.ts +1 -1
  275. package/dist/utils/cli.d.ts +2 -2
  276. package/dist/utils/cli.js +92 -154
  277. package/dist/utils/fs.d.ts +3 -4
  278. package/dist/utils/fs.js +4 -5
  279. package/dist/utils/strings.d.ts +0 -1
  280. package/dist/utils/strings.js +0 -8
  281. package/dist/utils/ui.d.ts +5 -2
  282. package/dist/utils/ui.js +13 -3
  283. package/package.json +158 -157
  284. package/dist/add-preset.d.ts +0 -4
  285. package/dist/add-preset.js +0 -74
  286. package/dist/api/shared/async-symbol-detector.d.ts +0 -11
  287. package/dist/api/shared/async-symbol-detector.js +0 -140
  288. package/dist/api/shared/native-display-op-resolver.d.ts +0 -10
  289. package/dist/api/shared/native-display-op-resolver.js +0 -64
  290. package/dist/create/board-checklist.d.ts +0 -2
  291. package/dist/create/board-checklist.js +0 -52
  292. package/dist/create/board-codegen.d.ts +0 -9
  293. package/dist/create/board-codegen.js +0 -238
  294. package/dist/create/board-generators.d.ts +0 -12
  295. package/dist/create/board-generators.js +0 -651
  296. package/dist/create/board-spec.d.ts +0 -181
  297. package/dist/create/board-spec.js +0 -214
  298. package/dist/install/framework-catalog.d.ts +0 -53
  299. package/dist/install/framework-catalog.js +0 -107
  300. package/dist/install/handle-install.d.ts +0 -35
  301. package/dist/install/handle-install.js +0 -177
  302. package/dist/install/index.d.ts +0 -4
  303. package/dist/install/index.js +0 -3
  304. package/dist/ir/pin-state-tracking.d.ts +0 -58
  305. package/dist/ir/pin-state-tracking.js +0 -182
  306. package/dist/ir/pwm-timer-sharing.d.ts +0 -4
  307. package/dist/ir/pwm-timer-sharing.js +0 -94
  308. package/dist/ir/timer0-pwm-timing-conflict.d.ts +0 -4
  309. package/dist/ir/timer0-pwm-timing-conflict.js +0 -72
  310. package/dist/libdef/component-decls.d.ts +0 -2
  311. package/dist/libdef/component-decls.js +0 -6
  312. package/dist/libdef/component-discovery.d.ts +0 -43
  313. package/dist/libdef/component-discovery.js +0 -83
  314. package/dist/theme-tokens.d.ts +0 -22
  315. package/dist/theme-tokens.js +0 -172
@@ -0,0 +1,23 @@
1
+ /** The discriminator union the wizard switches on. */
2
+ export type TargetPick = {
3
+ kind: 'native';
4
+ } | {
5
+ kind: 'mcu';
6
+ id: string;
7
+ } | {
8
+ kind: 'board';
9
+ entry: {
10
+ identifier: string;
11
+ name: string;
12
+ soc: string;
13
+ };
14
+ };
15
+ export declare function pickTarget(): Promise<TargetPick | undefined>;
16
+ /** Back-compat alias for the board-only picker (still used by tests/tools
17
+ * that want boards only). */
18
+ export declare function pickBoard(): Promise<{
19
+ identifier: string;
20
+ name: string;
21
+ soc: string;
22
+ curated: boolean;
23
+ } | undefined>;
@@ -0,0 +1,88 @@
1
+ // ---------------------------------------------------------------------------
2
+ // board-search.ts — the create-wizard target picker: one filterable select.
3
+ //
4
+ // Everything the wizard can target rides a single searchable list:
5
+ // - Native Desktop (the one non-embedded target)
6
+ // - Bare silicon (soc entries — contract/custom-PCB projects)
7
+ // - Every Zephyr board variant from the generated catalog (1,300+;
8
+ // the curated nine sit wherever their names sort — no badge, the
9
+ // picker is a flat search surface)
10
+ //
11
+ // Typing "esp32" narrows to the espressif variants; typing "nrf52" to the
12
+ // Nordic ones; arrows + enter pick. Uses inquirer-select-pro's filter mode.
13
+ // ---------------------------------------------------------------------------
14
+ import { select } from 'inquirer-select-pro';
15
+ import { activeBoardCatalog } from '../board-catalog/index.js';
16
+ import { KNOWN_TARGETS } from './scaffold.js';
17
+ /** Flat option list: native first, then bare silicon, then every board
18
+ * variant (alphabetical by the pack's directory-walk order). */
19
+ function targetOptions() {
20
+ const native = KNOWN_TARGETS
21
+ .filter((t) => t.isNative)
22
+ .map((t) => ({ name: `${t.displayName} (Windows/Linux executable)`, value: `native:${t.id}` }));
23
+ const boards = Object.values(activeBoardCatalog()).map((b) => ({
24
+ name: `${b.name} (${b.identifier})`,
25
+ value: b.identifier,
26
+ }));
27
+ return [...native, ...boards];
28
+ }
29
+ /** Resolve a picked value back to its discriminated form. */
30
+ function resolvePick(value) {
31
+ if (value.startsWith('native:'))
32
+ return { kind: 'native' };
33
+ // Board: value IS the qualified identifier.
34
+ const entry = activeBoardCatalog()[value];
35
+ if (!entry)
36
+ return undefined;
37
+ return { kind: 'board', entry: { identifier: entry.identifier, name: entry.name, soc: value.split('/')[1] } };
38
+ }
39
+ /**
40
+ * Build a filterable options loader for `inquirer-select-pro`. The select
41
+ * only enables its filter input when `options` is a *function* (a static
42
+ * array disables filtering entirely), so we wrap the flat list in a
43
+ * case-insensitive substring matcher.
44
+ */
45
+ function filterableTargetOptions() {
46
+ const all = targetOptions();
47
+ return (input) => {
48
+ const query = (input ?? '').trim().toLowerCase();
49
+ if (!query)
50
+ return all;
51
+ return all.filter((o) => o.name.toLowerCase().includes(query));
52
+ };
53
+ }
54
+ export async function pickTarget() {
55
+ const value = await select({
56
+ message: 'Target (type to filter — e.g. "esp32", "nucleo", "native"):',
57
+ multiple: false,
58
+ options: filterableTargetOptions(),
59
+ filter: true,
60
+ pageSize: 15,
61
+ });
62
+ if (value === undefined || value === null)
63
+ return undefined;
64
+ return resolvePick(value);
65
+ }
66
+ /** Back-compat alias for the board-only picker (still used by tests/tools
67
+ * that want boards only). */
68
+ export async function pickBoard() {
69
+ const boards = Object.values(activeBoardCatalog()).map((b) => ({ name: `${b.name} (${b.identifier})`, value: b.identifier }));
70
+ const value = await select({
71
+ message: 'Board (type to filter — e.g. "esp32", "nucleo_f411"):',
72
+ multiple: false,
73
+ options: (input) => {
74
+ const query = (input ?? '').trim().toLowerCase();
75
+ if (!query)
76
+ return boards;
77
+ return boards.filter((b) => b.name.toLowerCase().includes(query));
78
+ },
79
+ filter: true,
80
+ pageSize: 15,
81
+ });
82
+ if (value === undefined || value === null)
83
+ return undefined;
84
+ const entry = activeBoardCatalog()[value];
85
+ if (!entry)
86
+ return undefined;
87
+ return { identifier: entry.identifier, name: entry.name, soc: value.split('/')[1], curated: false };
88
+ }
@@ -25,6 +25,8 @@ export declare function generateTasksJson(existingTasks?: ReadonlyArray<Record<s
25
25
  * companion .vscode/extensions.json and — when the project has a `dev` watch
26
26
  * script — the .vscode/tasks.json watch task. Returns the absolute paths
27
27
  * written, or [] when the extension assets are missing (warns, never throws).
28
- * `assetsRoot` overrides the bundled-asset location (tests).
28
+ * `assetsRoot` overrides the bundled-asset location (tests). `hideNpm` (used by
29
+ * `cuttlefish create` for end-user projects) also writes settings.json keys
30
+ * that hide VS Code's NPM Scripts view and npm task detection.
29
31
  */
30
- export declare function writeEditorIntegration(outDir: string, assetsRoot?: string): string[];
32
+ export declare function writeEditorIntegration(outDir: string, assetsRoot?: string, hideNpm?: boolean): string[];
@@ -180,14 +180,50 @@ function hasDevScript(outDir) {
180
180
  return false;
181
181
  }
182
182
  }
183
+ /**
184
+ * Settings that hide VS Code's web-dev npm surface in end-user projects. The
185
+ * scaffolded package.json is build tooling, not an npm package the user
186
+ * develops — without these, VS Code shows the NPM Scripts explorer view,
187
+ * auto-detected npm tasks, and Debug codelenses over the scripts.
188
+ */
189
+ const END_USER_NPM_SETTINGS = {
190
+ 'npm.autoDetect': 'off',
191
+ 'npm.exclude': '**/package.json',
192
+ 'debug.javascript.codelens.npmScripts': 'never',
193
+ };
194
+ /**
195
+ * Read-merge-write .vscode/settings.json with the npm-hiding settings. Merge-
196
+ * safe because the framework debug writer may also contribute settings
197
+ * (e.g. cortex-debug paths) — those must survive.
198
+ */
199
+ function writeNpmHiddenSettings(vscodeDir) {
200
+ const settingsPath = path.join(vscodeDir, 'settings.json');
201
+ let doc = {};
202
+ if (fs.existsSync(settingsPath)) {
203
+ try {
204
+ const parsed = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
205
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
206
+ doc = parsed;
207
+ }
208
+ }
209
+ catch {
210
+ // malformed — start fresh
211
+ }
212
+ }
213
+ Object.assign(doc, END_USER_NPM_SETTINGS);
214
+ fs.writeFileSync(settingsPath, `${JSON.stringify(doc, null, 2)}\n`, 'utf-8');
215
+ return settingsPath;
216
+ }
183
217
  /**
184
218
  * Copy the bundled extensions into <outDir>/.vscode/extensions/, then write the
185
219
  * companion .vscode/extensions.json and — when the project has a `dev` watch
186
220
  * script — the .vscode/tasks.json watch task. Returns the absolute paths
187
221
  * written, or [] when the extension assets are missing (warns, never throws).
188
- * `assetsRoot` overrides the bundled-asset location (tests).
222
+ * `assetsRoot` overrides the bundled-asset location (tests). `hideNpm` (used by
223
+ * `cuttlefish create` for end-user projects) also writes settings.json keys
224
+ * that hide VS Code's NPM Scripts view and npm task detection.
189
225
  */
190
- export function writeEditorIntegration(outDir, assetsRoot) {
226
+ export function writeEditorIntegration(outDir, assetsRoot, hideNpm = false) {
191
227
  const vscodeDir = path.join(outDir, '.vscode');
192
228
  const extensionRoot = path.join(vscodeDir, 'extensions');
193
229
  const root = assetsRoot ?? ASSETS_ROOT;
@@ -214,5 +250,8 @@ export function writeEditorIntegration(outDir, assetsRoot) {
214
250
  if (hasDevScript(outDir)) {
215
251
  written.push(writeTasksJson(vscodeDir));
216
252
  }
253
+ if (hideNpm) {
254
+ written.push(writeNpmHiddenSettings(vscodeDir));
255
+ }
217
256
  return written;
218
257
  }
@@ -12,13 +12,23 @@ export interface FrameworkCatalogEntry {
12
12
  * be offered (it would fail at the package-manager step).
13
13
  */
14
14
  installable: boolean;
15
+ /**
16
+ * True when the framework ships inside @typecad/cuttlefish (no separate npm
17
+ * package): the scaffold must not add it to project dependencies, and the
18
+ * loader (framework-package.ts) resolves it internally instead of via
19
+ * require.resolve. The config string stays the package name for continuity.
20
+ */
21
+ builtin?: boolean;
15
22
  }
16
23
  /**
17
- * The installable frameworks. Kept aligned with the packages/ directory:
18
- * framework-arduino, framework-native, framework-zephyr all ship real packages.
19
- * esp-idf is intentionally absent (no published package in this repo).
24
+ * The usable frameworks. zephyr ships as a real package; native is built
25
+ * into @typecad/cuttlefish (formerly a separate package, now resolved
26
+ * internally). esp-idf is intentionally absent (no published package).
20
27
  */
21
28
  export declare const FRAMEWORK_CATALOG: readonly FrameworkCatalogEntry[];
29
+ /** True iff the framework package ships inside @typecad/cuttlefish and needs
30
+ * no separate npm dependency in scaffolded projects. */
31
+ export declare function isBuiltinFramework(packageName: string): boolean;
22
32
  /** Structural shape we need from a board/target. Keeps this module decoupled
23
33
  * from the KnownTarget type (and trivially testable with literals). */
24
34
  export interface BoardLike {
@@ -27,6 +37,44 @@ export interface BoardLike {
27
37
  }
28
38
  /** Look up a catalog entry by framework id (e.g. "arduino"). */
29
39
  export declare function frameworkCatalogEntry(id: string): FrameworkCatalogEntry | undefined;
40
+ /**
41
+ * Zephyr build targets come straight from the board catalog (the pack or a
42
+ * local `cuttlefish board sync` overlay) — every catalog board carries its
43
+ * own qualified `west build -b` target. There is no curated id→target map.
44
+ */
45
+ /**
46
+ * Probe method a board offers, for `cuttlefish create`'s wizard (which runs
47
+ * BEFORE the framework is installed, so it reads the board data pack — the
48
+ * same table boardgen emits into the generated board module for tier-3
49
+ * boards, extracted from each board's own board.cmake runners).
50
+ */
51
+ export interface CatalogProbeMethod {
52
+ id: string;
53
+ description: string;
54
+ }
55
+ /**
56
+ * The probe methods a board offers, from the board data pack. Accepts a
57
+ * qualified Zephyr target ('blackpill_f401ce/stm32f401xe'), a bare board id,
58
+ * or undefined. Empty when the board ships no runner table — then no probe
59
+ * question is asked and no zephyr.probe section is scaffolded.
60
+ */
61
+ export declare function probeMethodsForBoard(boardId: string | undefined): CatalogProbeMethod[];
62
+ /**
63
+ * Pre-baked zephyr.runnerArgs the selected probe method needs to flash
64
+ * reliably — sourced from the method's captured debugCfg (the board's
65
+ * support/openocd.cfg, verbatim), so the scaffold bakes in facts, not board
66
+ * names.
67
+ *
68
+ * The one quirk today: a cfg that drives OpenOCD resets through the SRST pin
69
+ * (`reset_config srst…`) while the probe's NRST line may not reach the target
70
+ * — hobby boards like the WeAct BlackPill break no NRST out at all, so
71
+ * `reset init` asserts a pin that reaches nothing and dies with "timed out
72
+ * while waiting for target halted". Core-domain resets (SYSRESETREQ) are
73
+ * pin-independent. Boards declaring `connect_assert_srst` are excluded: that
74
+ * strategy only works with NRST wired, so the pin is provably connected there
75
+ * and connect-under-reset is worth keeping.
76
+ */
77
+ export declare function probeRunnerQuirks(boardId: string | undefined, methodId: string | undefined): string[];
30
78
  export interface FrameworkTargetProfile {
31
79
  /** Framework-specific build target (FQBN for Arduino, board id for Zephyr). */
32
80
  buildTarget?: string;
@@ -36,19 +84,19 @@ export interface FrameworkTargetProfile {
36
84
  export interface TargetProfileInput {
37
85
  id: string;
38
86
  isNative?: boolean;
39
- /** The board's Arduino FQBN, as currently stored on KnownTarget. */
87
+ /** The board's default build target, as currently stored on KnownTarget. */
40
88
  buildTarget?: string;
41
89
  }
42
90
  /**
43
91
  * Resolve the framework-specific buildTarget + toolchain type for a
44
- * (board, framework) pair. Arduino reuses the board's FQBN; Zephyr maps to the
45
- * Zephyr board id; native returns an empty profile (the native config writes
46
- * neither field).
92
+ * (board, framework) pair. Zephyr maps the board id to its Zephyr board
93
+ * target; native returns an empty profile (the native config writes neither
94
+ * field); any unlisted framework falls back to the board's stored target.
47
95
  */
48
96
  export declare function frameworkTargetProfile(target: TargetProfileInput, frameworkId: string): FrameworkTargetProfile;
49
97
  /**
50
98
  * The framework ids compatible with a board. Native boards map to ["native"];
51
- * embedded boards map via ARCHITECTURE_FRAMEWORKS (falling back to arduino for
99
+ * embedded boards map via ARCHITECTURE_FRAMEWORKS (falling back to zephyr for
52
100
  * unknown architectures). Order is preserved as the catalog order so the most
53
101
  * common framework is offered first in the prompt.
54
102
  */
@@ -58,7 +106,7 @@ export declare function frameworksForTarget(target: BoardLike): FrameworkCatalog
58
106
  * board's architecture AND installable. Auto-picking narrows via
59
107
  * frameworksForTarget, but an explicit `--framework` bypasses that narrowing —
60
108
  * callers accepting one must reject anything this returns false for (e.g.
61
- * `--framework arduino` on the Zephyr-only xiao-nrf52840).
109
+ * `--framework native` on an embedded board).
62
110
  */
63
111
  export declare function frameworkCompatibleWithTarget(target: BoardLike, frameworkId: string): boolean;
64
112
  export type PackageManager = "npm" | "pnpm" | "yarn";
@@ -7,87 +7,105 @@
7
7
  // detectPackageManager) so it unit-tests cleanly.
8
8
  import path from "node:path";
9
9
  import fs from "node:fs";
10
+ import { findPackBoard } from "./pack-targets.js";
10
11
  /**
11
- * The installable frameworks. Kept aligned with the packages/ directory:
12
- * framework-arduino, framework-native, framework-zephyr all ship real packages.
13
- * esp-idf is intentionally absent (no published package in this repo).
12
+ * The usable frameworks. zephyr ships as a real package; native is built
13
+ * into @typecad/cuttlefish (formerly a separate package, now resolved
14
+ * internally). esp-idf is intentionally absent (no published package).
14
15
  */
15
16
  export const FRAMEWORK_CATALOG = [
16
- { id: "arduino", packageName: "@typecad/framework-arduino", label: "Arduino (digitalWrite, Wire, SPI)", installable: true },
17
17
  { id: "zephyr", packageName: "@typecad/framework-zephyr", label: "Zephyr RTOS", installable: true },
18
- { id: "native", packageName: "@typecad/framework-native", label: "Native (Windows/Linux executable)", installable: true },
18
+ { id: "native", packageName: "@typecad/framework-native", label: "Native (Windows/Linux executable)", installable: true, builtin: true },
19
19
  ];
20
+ /** True iff the framework package ships inside @typecad/cuttlefish and needs
21
+ * no separate npm dependency in scaffolded projects. */
22
+ export function isBuiltinFramework(packageName) {
23
+ return FRAMEWORK_CATALOG.some((f) => f.packageName === packageName && f.builtin === true);
24
+ }
20
25
  /**
21
26
  * Architecture → compatible framework ids. Derived from each framework
22
27
  * package's framework.manifest.ts `profile.targets`:
23
- * - arduino: avr, esp32 family, rp2040/rp2350, samd, stm32
24
- * - zephyr: nrf52 (xiao_ble), esp32 family (esp32, esp32s3, esp32c3, esp32c6)
28
+ * - zephyr: nrf52 (xiao_ble), esp32 family (esp32, esp32s3, esp32c3, esp32c6),
29
+ * rp2040/rp2350 (rpi_pico, rpi_pico2), stm32f411 (blackpill),
30
+ * samd21 (nano_33_iot)
25
31
  * - native: desktop only
26
- * Unknown embedded architectures fall back to [arduino] (the broadest core).
32
+ * Unknown embedded architectures fall back to [zephyr].
27
33
  */
28
34
  const ARCHITECTURE_FRAMEWORKS = {
29
- avr: ["arduino"],
30
- esp32: ["arduino", "zephyr"],
31
- esp32s2: ["arduino"],
32
- esp32s3: ["arduino", "zephyr"],
33
- esp32c3: ["arduino", "zephyr"],
34
- esp32c6: ["arduino", "zephyr"],
35
- rp2040: ["arduino"],
36
- rp2350: ["arduino"],
37
- samd: ["arduino"],
38
- // Per-chip key (esp32c3/c6 style). The generic 'stm32' entry stays
39
- // ["arduino"] for future STM32duino support; the F411 Black Pill is
40
- // Zephyr-only today.
35
+ esp32: ["zephyr"],
36
+ esp32s3: ["zephyr"],
37
+ esp32c3: ["zephyr"],
38
+ esp32c6: ["zephyr"],
39
+ rp2040: ["zephyr"],
40
+ rp2350: ["zephyr"],
41
+ // Per-chip key (stm32f411 style) — the Black Pill's generic 'stm32' family
42
+ // has no other supported silicon today.
43
+ samd21: ["zephyr"],
41
44
  stm32f411: ["zephyr"],
42
- stm32: ["arduino"],
43
45
  nrf52: ["zephyr"],
44
46
  };
45
- const FALLBACK_FRAMEWORKS = ["arduino"];
47
+ const FALLBACK_FRAMEWORKS = ["zephyr"];
46
48
  /** Look up a catalog entry by framework id (e.g. "arduino"). */
47
49
  export function frameworkCatalogEntry(id) {
48
50
  return FRAMEWORK_CATALOG.find((f) => f.id === id);
49
51
  }
50
52
  // ── framework-specific build target + toolchain ─────────────────────────────
51
- // A board's buildTarget string is NOT framework-independent: Arduino uses an
52
- // FQBN (e.g. 'esp32:esp32:esp32s3') while Zephyr uses a board id for
53
- // `west build -b` (e.g. 'esp32s3_devkitc'). The scaffold must pick the right
54
- // one for the chosen framework, and the matching toolchain backend
55
- // ('arduino-cli' vs 'west'). Source for Zephyr board ids: framework-zephyr's
53
+ // A board's buildTarget string is framework-specific: Zephyr uses a board id
54
+ // for `west build -b` (e.g. 'esp32s3_devkitc/esp32s3/procpu'). The scaffold
55
+ // must pick the right one for the chosen framework, and the matching
56
+ // toolchain backend ('west'). Source for Zephyr board ids: framework-zephyr's
56
57
  // chip registry (src/chips/index.ts) + the demo configs.
57
58
  const FRAMEWORK_TOOLCHAIN = {
58
- arduino: "arduino-cli",
59
59
  zephyr: "west",
60
60
  // native has no toolchain (the native config path writes neither field).
61
61
  };
62
62
  /**
63
- * Zephyr board target for each cuttlefish board id that supports Zephyr. These
64
- * are the full qualified targets passed to `west build -b <target>` (framework-
65
- * zephyr's chipForTarget splits on '/' and takes the board id, so the qualified
66
- * form resolves correctly there too). Zephyr 4.3+ REQUIRES the qualifier for
67
- * multi-core ESP32 boards — the bare id (e.g. 'esp32s3_devkitc') is rejected
68
- * with "Board qualifiers ... not found". procpu is the main application core.
63
+ * The probe methods a board offers, from the board data pack. Accepts a
64
+ * qualified Zephyr target ('blackpill_f401ce/stm32f401xe'), a bare board id,
65
+ * or undefined. Empty when the board ships no runner table then no probe
66
+ * question is asked and no zephyr.probe section is scaffolded.
69
67
  */
70
- const ZEPHYR_BOARD_IDS = {
71
- "esp32-devkit": "esp32_devkitc/esp32/procpu",
72
- esp32s3: "esp32s3_devkitc/esp32s3/procpu",
73
- // Single-variant RISC-V board — the bare id is also accepted, but the
74
- // qualified form is kept for consistency (verified against Zephyr 4.3
75
- // boards/espressif/esp32c3_devkitm).
76
- esp32c3: "esp32c3_devkitm/esp32c3",
77
- // hpcore/lpcore cpucluster variants — the qualified form is required (the
78
- // bare id is rejected); hpcore is the application core.
79
- esp32c6: "esp32c6_devkitc/esp32c6/hpcore",
80
- // First STM32 target WeAct Black Pill V2.0 (STM32F411CEU6). Single
81
- // variant; qualified for consistency with every other catalog target.
82
- "blackpill-f411ce": "blackpill_f411ce/stm32f411xe",
83
- // nRF52840 (single core), base (non-sense) variant.
84
- "xiao-nrf52840": "xiao_ble/nrf52840",
85
- };
68
+ export function probeMethodsForBoard(boardId) {
69
+ if (!boardId)
70
+ return [];
71
+ const entry = findPackBoard(boardId);
72
+ if (!entry?.probeMethods)
73
+ return [];
74
+ return entry.probeMethods.map((m) => ({ id: m.id, description: m.description }));
75
+ }
76
+ /**
77
+ * Pre-baked zephyr.runnerArgs the selected probe method needs to flash
78
+ * reliablysourced from the method's captured debugCfg (the board's
79
+ * support/openocd.cfg, verbatim), so the scaffold bakes in facts, not board
80
+ * names.
81
+ *
82
+ * The one quirk today: a cfg that drives OpenOCD resets through the SRST pin
83
+ * (`reset_config srst…`) while the probe's NRST line may not reach the target
84
+ * — hobby boards like the WeAct BlackPill break no NRST out at all, so
85
+ * `reset init` asserts a pin that reaches nothing and dies with "timed out
86
+ * while waiting for target halted". Core-domain resets (SYSRESETREQ) are
87
+ * pin-independent. Boards declaring `connect_assert_srst` are excluded: that
88
+ * strategy only works with NRST wired, so the pin is provably connected there
89
+ * and connect-under-reset is worth keeping.
90
+ */
91
+ export function probeRunnerQuirks(boardId, methodId) {
92
+ if (!boardId || !methodId)
93
+ return [];
94
+ const method = findPackBoard(boardId)?.probeMethods?.find((m) => m.id === methodId);
95
+ // Only the openocd runner consumes the board cfg's reset_config — other
96
+ // runners (jlink, dfu-util, …) carry their own reset strategy.
97
+ if (!method || method.runner !== 'openocd')
98
+ return [];
99
+ const cfg = method.debugCfg ?? [];
100
+ const srst = cfg.some((line) => /reset_config\s+srst/.test(line));
101
+ const connectAssert = cfg.some((line) => /connect_assert_srst/.test(line));
102
+ return srst && !connectAssert ? ['--cmd-pre-init=reset_config none'] : [];
103
+ }
86
104
  /**
87
105
  * Resolve the framework-specific buildTarget + toolchain type for a
88
- * (board, framework) pair. Arduino reuses the board's FQBN; Zephyr maps to the
89
- * Zephyr board id; native returns an empty profile (the native config writes
90
- * neither field).
106
+ * (board, framework) pair. Zephyr maps the board id to its Zephyr board
107
+ * target; native returns an empty profile (the native config writes neither
108
+ * field); any unlisted framework falls back to the board's stored target.
91
109
  */
92
110
  export function frameworkTargetProfile(target, frameworkId) {
93
111
  if (target.isNative) {
@@ -95,14 +113,15 @@ export function frameworkTargetProfile(target, frameworkId) {
95
113
  }
96
114
  const toolchainType = FRAMEWORK_TOOLCHAIN[frameworkId];
97
115
  if (frameworkId === "zephyr") {
98
- return { buildTarget: ZEPHYR_BOARD_IDS[target.id], toolchainType };
116
+ // The target input's buildTarget IS the qualified catalog identifier.
117
+ return { buildTarget: target.buildTarget, toolchainType };
99
118
  }
100
- // Arduino (and any unlisted framework)use the board's FQBN.
119
+ // Unlisted framework → pass the board's stored build target through.
101
120
  return { buildTarget: target.buildTarget, toolchainType };
102
121
  }
103
122
  /**
104
123
  * The framework ids compatible with a board. Native boards map to ["native"];
105
- * embedded boards map via ARCHITECTURE_FRAMEWORKS (falling back to arduino for
124
+ * embedded boards map via ARCHITECTURE_FRAMEWORKS (falling back to zephyr for
106
125
  * unknown architectures). Order is preserved as the catalog order so the most
107
126
  * common framework is offered first in the prompt.
108
127
  */
@@ -123,7 +142,7 @@ export function frameworksForTarget(target) {
123
142
  * board's architecture AND installable. Auto-picking narrows via
124
143
  * frameworksForTarget, but an explicit `--framework` bypasses that narrowing —
125
144
  * callers accepting one must reject anything this returns false for (e.g.
126
- * `--framework arduino` on the Zephyr-only xiao-nrf52840).
145
+ * `--framework native` on an embedded board).
127
146
  */
128
147
  export function frameworkCompatibleWithTarget(target, frameworkId) {
129
148
  return frameworksForTarget(target).some((f) => f.id === frameworkId && f.installable);
@@ -1,18 +1,12 @@
1
- export { scaffoldProject, normalizeProjectName, KNOWN_TARGETS, KNOWN_BOARDS, registerKnownTarget, printCreateNextSteps } from './scaffold.js';
2
- export type { KnownTarget, KnownBoard, ScaffoldProjectResult } from './scaffold.js';
3
- export { FRAMEWORK_CATALOG, frameworksForTarget, frameworkCompatibleWithTarget, frameworkCatalogEntry, detectPackageManager, frameworkTargetProfile } from './framework-catalog.js';
4
- export type { FrameworkCatalogEntry, BoardLike, PackageManager, FrameworkTargetProfile, TargetProfileInput } from './framework-catalog.js';
1
+ export { scaffoldProject, normalizeProjectName, KNOWN_TARGETS, printCreateNextSteps } from './scaffold.js';
2
+ export type { KnownTarget, ScaffoldProjectResult } from './scaffold.js';
3
+ export { FRAMEWORK_CATALOG, frameworksForTarget, frameworkCompatibleWithTarget, frameworkCatalogEntry, detectPackageManager, frameworkTargetProfile, probeMethodsForBoard, probeRunnerQuirks } from './framework-catalog.js';
4
+ export type { FrameworkCatalogEntry, BoardLike, PackageManager, FrameworkTargetProfile, TargetProfileInput, CatalogProbeMethod } from './framework-catalog.js';
5
5
  export { installProjectDependencies, __setProjectInstallRunnerForTest } from './install-deps.js';
6
6
  export type { ProjectInstallResult } from './install-deps.js';
7
- export { generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterSketch, generateStarterTest, generateStarterSim, generateGitignore, generateEditorconfig, generateEslintConfig, } from './templates.js';
7
+ export { generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterProgram, generateStarterTest, generateStarterSim, generateGitignore, generateEditorconfig, generateEslintConfig, } from './templates.js';
8
8
  export type { CreateProjectOptions } from './templates.js';
9
9
  export { runCreateWizard } from './wizard.js';
10
10
  export { generateFrameworkDebugArtifacts } from './debug-artifacts.js';
11
11
  export type { FrameworkDebugArtifactsOptions, FrameworkModuleLoader } from './debug-artifacts.js';
12
12
  export { generateExtensionsJson, generateTasksJson, watchBuildTask, writeEditorIntegration, bundledExtensionSourceDir, typecadUiExtensionSourceDir, TYPECAD_UI_EXTENSION_ID, TYPECAD_DEBUG_EXTENSION_ID, WATCH_TASK_LABEL, } from './editor-integration.js';
13
- export { scaffoldBoardPackages } from './board-codegen.js';
14
- export type { ScaffoldBoardResult } from './board-codegen.js';
15
- export { generateFrameworkChecklist } from './board-checklist.js';
16
- export { parseBoardSpec, safeParseBoardSpec, stripJsonc, BoardSpecSchema } from './board-spec.js';
17
- export type { BoardSpec } from './board-spec.js';
18
- export * as BoardGenerators from './board-generators.js';
@@ -1,12 +1,7 @@
1
- export { scaffoldProject, normalizeProjectName, KNOWN_TARGETS, KNOWN_BOARDS, registerKnownTarget, printCreateNextSteps } from './scaffold.js';
2
- export { FRAMEWORK_CATALOG, frameworksForTarget, frameworkCompatibleWithTarget, frameworkCatalogEntry, detectPackageManager, frameworkTargetProfile } from './framework-catalog.js';
1
+ export { scaffoldProject, normalizeProjectName, KNOWN_TARGETS, printCreateNextSteps } from './scaffold.js';
2
+ export { FRAMEWORK_CATALOG, frameworksForTarget, frameworkCompatibleWithTarget, frameworkCatalogEntry, detectPackageManager, frameworkTargetProfile, probeMethodsForBoard, probeRunnerQuirks } from './framework-catalog.js';
3
3
  export { installProjectDependencies, __setProjectInstallRunnerForTest } from './install-deps.js';
4
- export { generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterSketch, generateStarterTest, generateStarterSim, generateGitignore, generateEditorconfig, generateEslintConfig, } from './templates.js';
4
+ export { generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterProgram, generateStarterTest, generateStarterSim, generateGitignore, generateEditorconfig, generateEslintConfig, } from './templates.js';
5
5
  export { runCreateWizard } from './wizard.js';
6
6
  export { generateFrameworkDebugArtifacts } from './debug-artifacts.js';
7
7
  export { generateExtensionsJson, generateTasksJson, watchBuildTask, writeEditorIntegration, bundledExtensionSourceDir, typecadUiExtensionSourceDir, TYPECAD_UI_EXTENSION_ID, TYPECAD_DEBUG_EXTENSION_ID, WATCH_TASK_LABEL, } from './editor-integration.js';
8
- // Board codegen tool (`cuttlefish board add`)
9
- export { scaffoldBoardPackages } from './board-codegen.js';
10
- export { generateFrameworkChecklist } from './board-checklist.js';
11
- export { parseBoardSpec, safeParseBoardSpec, stripJsonc, BoardSpecSchema } from './board-spec.js';
12
- export * as BoardGenerators from './board-generators.js';
@@ -0,0 +1,39 @@
1
+ import { type KnownMcu, type KnownTarget } from './scaffold.js';
2
+ /** An MCU catalog entry shaped for the create flow (KnownTarget-compatible:
3
+ * no board target, soc set, plus the silicon extras). */
4
+ export interface McuCreateTarget extends KnownTarget {
5
+ isNative: false;
6
+ board?: undefined;
7
+ /** Zephyr SoC name — the curated soc descriptor key. */
8
+ soc: string;
9
+ /** Datasheet port pin for the starter program. */
10
+ starterPin: string;
11
+ }
12
+ /** Look up an MCU catalog entry by id (e.g. 'stm32f411'). */
13
+ export declare function findKnownMcu(id: string): KnownMcu | undefined;
14
+ /** Convert a catalog entry into the create-flow target shape. */
15
+ export declare function mcuAsTarget(mcu: KnownMcu): McuCreateTarget;
16
+ /** True when the MCU package carries silicon Zephyr data (socs) — the
17
+ * precondition for both generated custom boards and the board snapshot. */
18
+ export declare function mcuSupportsZephyr(mcu: McuCreateTarget): boolean;
19
+ /** A snapshot board plus its default qualified `west build -b` target. */
20
+ export interface McuZephyrBoard {
21
+ name: string;
22
+ vendor: string;
23
+ soc: string;
24
+ /** Qualified target (e.g. 'blackpill_f411ce/stm32f411xe',
25
+ * 'esp32s3_devkitc/esp32s3/procpu'). */
26
+ target: string;
27
+ }
28
+ /** Every catalog board variant whose SoC matches the bare-silicon soc. */
29
+ export declare function zephyrBoardsForMcu(mcu: McuCreateTarget): McuZephyrBoard[];
30
+ /** Look one board up by its (bare) name — for the non-interactive
31
+ * `--zephyr-board <name>` flag. Undefined when the board is not in the
32
+ * snapshot under one of the MCU's SoCs. */
33
+ export declare function findZephyrBoardForMcu(mcu: McuCreateTarget, name: string): McuZephyrBoard | undefined;
34
+ /**
35
+ * Sanitize a raw name into a legal Zephyr board name — the same rules
36
+ * framework-zephyr's generator applies (lowercase `[a-z0-9_]`), duplicated
37
+ * here because create runs before the framework package is installed.
38
+ */
39
+ export declare function sanitizeBoardName(raw: string): string;
@@ -0,0 +1,80 @@
1
+ // ---------------------------------------------------------------------------
2
+ // MCU-only create-target resolution
3
+ //
4
+ // Shared logic for `cuttlefish create --mcu <id>` and the wizard's bare-MCU
5
+ // entries: framework narrowing (Zephyr needs the package's silicon zephyr
6
+ // block), the Zephyr board decision (generated custom board vs any upstream
7
+ // board whose SoC matches, from the exhaustive snapshot), and the default
8
+ // qualified `west build -b` target.
9
+ // ---------------------------------------------------------------------------
10
+ import { KNOWN_MCUS } from './scaffold.js';
11
+ import { activeBoardCatalog } from './active-board-catalog.js';
12
+ /** Look up an MCU catalog entry by id (e.g. 'stm32f411'). */
13
+ export function findKnownMcu(id) {
14
+ return KNOWN_MCUS.find((m) => m.id === id);
15
+ }
16
+ /** Convert a catalog entry into the create-flow target shape. */
17
+ export function mcuAsTarget(mcu) {
18
+ return {
19
+ id: mcu.id,
20
+ displayName: mcu.displayName,
21
+ isNative: false,
22
+ architecture: mcu.architecture,
23
+ soc: mcu.soc,
24
+ starterPin: mcu.starterPin,
25
+ };
26
+ }
27
+ /** True when the MCU package carries silicon Zephyr data (socs) — the
28
+ * precondition for both generated custom boards and the board snapshot. */
29
+ export function mcuSupportsZephyr(mcu) {
30
+ return true;
31
+ }
32
+ // ── Zephyr board snapshot ────────────────────────────────────────────────────
33
+ /**
34
+ * CPU-cluster qualifier defaults for multi-variant SoCs — Zephyr rejects the
35
+ * bare board name when a board ships multiple variants with no default, and
36
+ * the application core / M33 cluster is the one firmware targets (mirrors the
37
+ * qualified forms in framework-catalog's ZEPHYR_BOARD_IDS).
38
+ */
39
+ const SOC_CLUSTER_QUALIFIER = {
40
+ esp32: 'procpu',
41
+ esp32s3: 'procpu',
42
+ esp32c6: 'hpcore',
43
+ rp2350a: 'm33',
44
+ rp2350b: 'm33',
45
+ };
46
+ /** Every catalog board variant whose SoC matches the bare-silicon soc. */
47
+ export function zephyrBoardsForMcu(mcu) {
48
+ const results = [];
49
+ for (const [identifier, entry] of Object.entries(activeBoardCatalog())) {
50
+ const soc = identifier.split('/')[1];
51
+ if (soc !== mcu.soc)
52
+ continue;
53
+ results.push({
54
+ name: entry.name,
55
+ vendor: entry.vendor,
56
+ soc,
57
+ target: identifier,
58
+ });
59
+ }
60
+ return results.sort((a, b) => a.name.localeCompare(b.name));
61
+ }
62
+ /** Look one board up by its (bare) name — for the non-interactive
63
+ * `--zephyr-board <name>` flag. Undefined when the board is not in the
64
+ * snapshot under one of the MCU's SoCs. */
65
+ export function findZephyrBoardForMcu(mcu, name) {
66
+ return zephyrBoardsForMcu(mcu).find((b) => b.name === name);
67
+ }
68
+ // ── Custom-board naming ──────────────────────────────────────────────────────
69
+ /**
70
+ * Sanitize a raw name into a legal Zephyr board name — the same rules
71
+ * framework-zephyr's generator applies (lowercase `[a-z0-9_]`), duplicated
72
+ * here because create runs before the framework package is installed.
73
+ */
74
+ export function sanitizeBoardName(raw) {
75
+ const cleaned = raw
76
+ .toLowerCase()
77
+ .replace(/[^a-z0-9_]+/g, '_')
78
+ .replace(/^_+|_+$/g, '');
79
+ return cleaned.length > 0 ? cleaned : 'custom_board';
80
+ }