@aiderdesk/aiderdesk 0.79.1 → 0.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/out/renderer/assets/{AgentSettings-DlLAuLnM.js → AgentSettings-B_H7Zpgy.js} +403 -360
  2. package/out/renderer/assets/{InfoIcon-C1TeBp5L.js → InfoIcon-D7q9WWkf.js} +1 -1
  3. package/out/renderer/assets/{Onboarding-Dh8FRGur.js → Onboarding-BKjX09cc.js} +4 -4
  4. package/out/renderer/assets/{ProviderHeader-VLzB9p23.js → ProviderHeader-Cs728L-d.js} +888 -524
  5. package/out/renderer/assets/{SettingsPage-B3CLZ8tc.js → SettingsPage-JucARU7D.js} +731 -541
  6. package/out/renderer/assets/{UsageDashboard-D83T3HwC.js → UsageDashboard-DILP_J6x.js} +9 -13
  7. package/out/renderer/assets/{abnfDiagram-N423BO3Z-BRDZM1mW.js → abnfDiagram-N423BO3Z-FwzcDSg0.js} +4 -4
  8. package/out/renderer/assets/{arc-CbzEqNM1.js → arc-BUCbLDDN.js} +1 -1
  9. package/out/renderer/assets/{architectureDiagram-T3A2C74G-Bvd5Je3R.js → architectureDiagram-T3A2C74G-DwIgf-vu.js} +3 -3
  10. package/out/renderer/assets/{blockDiagram-VBNYF7ZC-C_NaWxTi.js → blockDiagram-VBNYF7ZC-mi-N7mTd.js} +4 -4
  11. package/out/renderer/assets/{c4Diagram-5PPSVZJV-DguNzZCo.js → c4Diagram-5PPSVZJV-DwdgAnsC.js} +2 -2
  12. package/out/renderer/assets/{channel-Cnrvb6bA.js → channel-FZb5X6MG.js} +1 -1
  13. package/out/renderer/assets/{chunk-2GRJ4B5K-r99iLppH.js → chunk-2GRJ4B5K-94IZD4IQ.js} +1 -1
  14. package/out/renderer/assets/{chunk-2Q5K7J3B-C3uutlD6.js → chunk-2Q5K7J3B-KWOSRYgu.js} +1 -1
  15. package/out/renderer/assets/{chunk-5RXB4S5H-CR6Mx5Iz.js → chunk-5RXB4S5H-B1lEzoZd.js} +4 -4
  16. package/out/renderer/assets/{chunk-5VM5RSS4-X7PVl-ef.js → chunk-5VM5RSS4-DU4fVgUS.js} +1 -1
  17. package/out/renderer/assets/{chunk-6Q2QTUOP-JehvOsAC.js → chunk-6Q2QTUOP-CfXk4iDZ.js} +1 -1
  18. package/out/renderer/assets/{chunk-GF5L2VYU-B3ppa4PP.js → chunk-GF5L2VYU-CQNT5-FI.js} +5 -5
  19. package/out/renderer/assets/{chunk-JWPE2WC7-CFZRPI77.js → chunk-JWPE2WC7-BD4AfUn4.js} +1 -1
  20. package/out/renderer/assets/{chunk-KBJHAD2P-BBjc6zok.js → chunk-KBJHAD2P-DHAVKPli.js} +1 -1
  21. package/out/renderer/assets/{chunk-RYQCIY6F-BZvHC_mQ.js → chunk-RYQCIY6F-CVVFEloA.js} +3 -3
  22. package/out/renderer/assets/{chunk-XXDRQBXY-Ck-RRkxC.js → chunk-XXDRQBXY-D2JNzJXq.js} +1 -1
  23. package/out/renderer/assets/{classDiagram-JCYQIIEL-NNfXWT4B.js → classDiagram-JCYQIIEL-7W7lot8b.js} +6 -6
  24. package/out/renderer/assets/{classDiagram-v2-OCEON4UE-NNfXWT4B.js → classDiagram-v2-OCEON4UE-7W7lot8b.js} +6 -6
  25. package/out/renderer/assets/{cose-bilkent-JH36ORCC-CViVoXgl.js → cose-bilkent-JH36ORCC-CZMhh5W9.js} +1 -1
  26. package/out/renderer/assets/{cynefin-VYW2F7L2-DX5D0uIU.js → cynefin-VYW2F7L2-x-xDxroP.js} +1 -1
  27. package/out/renderer/assets/{cynefinDiagram-MW4NZA55-Cp2wCsOt.js → cynefinDiagram-MW4NZA55-B41JtjtO.js} +3 -3
  28. package/out/renderer/assets/{dagre-VZM6K2ZE-eNIYYO0O.js → dagre-VZM6K2ZE-Dj-zvUXp.js} +5 -5
  29. package/out/renderer/assets/{diagram-7IWD3JNH-Bg1vGWhI.js → diagram-7IWD3JNH-CFaAve_t.js} +4 -4
  30. package/out/renderer/assets/{diagram-B4RE2ZJO-D_JxirT4.js → diagram-B4RE2ZJO-Dlv48H7Y.js} +3 -3
  31. package/out/renderer/assets/{diagram-LBJQPF4R-LQpr0xek.js → diagram-LBJQPF4R-BucHVRed.js} +3 -3
  32. package/out/renderer/assets/{diagram-Q27KOJAE-BL-MLj4m.js → diagram-Q27KOJAE-B611lqWJ.js} +4 -4
  33. package/out/renderer/assets/{diagram-UB23O5K3-BlUt9ZmL.js → diagram-UB23O5K3-CLoEDYB7.js} +3 -3
  34. package/out/renderer/assets/{ebnfDiagram-BXEA7PRR-BGckdM6s.js → ebnfDiagram-BXEA7PRR-jrXkTnrz.js} +4 -4
  35. package/out/renderer/assets/{erDiagram-JOGREHBK-DmWOmMZk.js → erDiagram-JOGREHBK-03zjLqsa.js} +4 -4
  36. package/out/renderer/assets/{flowDiagram-UKHOOZJN-lOEUIjdB.js → flowDiagram-UKHOOZJN-Bp2wNUMb.js} +6 -6
  37. package/out/renderer/assets/{ganttDiagram-PKOTCBZU-CZtmjxYB.js → ganttDiagram-PKOTCBZU-D43jD8yv.js} +3 -3
  38. package/out/renderer/assets/{gitGraphDiagram-DS77QQ5N-DE5y9iux.js → gitGraphDiagram-DS77QQ5N-BnRYgTHV.js} +4 -4
  39. package/out/renderer/assets/{graph-DSMw-VBh.js → graph-Cc2_HGX0.js} +1 -1
  40. package/out/renderer/assets/{index-ebiHDnXl.js → index-6f-oeIlk.js} +2 -2
  41. package/out/renderer/assets/{index-Buw1KWG-.js → index-B1FCOdrT.js} +1 -1
  42. package/out/renderer/assets/{index-DDiIQL3b.js → index-B1zpIvcm.js} +3 -3
  43. package/out/renderer/assets/{index-mytNi5ms.js → index-B7u0PpZD.js} +1 -1
  44. package/out/renderer/assets/{index-B-wIGFrM.js → index-BAmWP-pk.js} +1 -1
  45. package/out/renderer/assets/{index-OJ1PmhTm.js → index-BD3e_Ot8.js} +2 -2
  46. package/out/renderer/assets/{index-DZze20ab.js → index-BDNv0FnP.js} +2 -2
  47. package/out/renderer/assets/{index-ChixxdQV.js → index-BlIAKIdk.js} +2 -2
  48. package/out/renderer/assets/{index-BfqM1vG3.js → index-BsROeHY9.js} +1 -1
  49. package/out/renderer/assets/{index-UQ28Qgl7.js → index-BshLKdRe.js} +5 -5
  50. package/out/renderer/assets/{index--__lgq6v.js → index-C1CZtLbF.js} +1 -1
  51. package/out/renderer/assets/{index-Bjy__dpB.js → index-C5ukVhTq.js} +2 -2
  52. package/out/renderer/assets/{index-vAx0mdd8.js → index-C9gITpjJ.js} +4 -4
  53. package/out/renderer/assets/{index-MDUSPmtz.js → index-CDQDyOcK.js} +5 -5
  54. package/out/renderer/assets/{index-Dgmvrciv.js → index-CIU9ZkBS.js} +3 -3
  55. package/out/renderer/assets/{index-qfaXmy0Y.js → index-CKmzZHZf.js} +1 -1
  56. package/out/renderer/assets/{index-Brdnttud.js → index-CLpvp3hq.js} +2 -2
  57. package/out/renderer/assets/{index-CgczHs0-.js → index-CRXUdV-u.js} +96 -3
  58. package/out/renderer/assets/{index-DMzzmyZE.js → index-CqrtPgJE.js} +2233 -1739
  59. package/out/renderer/assets/{index-BZaWk11Q.js → index-D3uMH-q1.js} +1 -1
  60. package/out/renderer/assets/{index-CZCIyO4U.js → index-D8TTB4-r.js} +5 -5
  61. package/out/renderer/assets/{index-DH7BFHAa.css → index-D98qpStd.css} +41 -14
  62. package/out/renderer/assets/{index-DD6bNfA0.js → index-DJFjmSQJ.js} +5 -5
  63. package/out/renderer/assets/{index-BDYZfF3J.js → index-DTGsvPds.js} +2 -2
  64. package/out/renderer/assets/{index-BbLpDvA3.js → index-DVc8XWTX.js} +5 -5
  65. package/out/renderer/assets/{index-Dz4P0Q9P.js → index-DvZhzJfh.js} +2 -2
  66. package/out/renderer/assets/{index-BRDlnXGV.js → index-Kj4O6jrs.js} +2 -2
  67. package/out/renderer/assets/{index-D4xEcHbg.js → index-KleIXLpB.js} +2 -2
  68. package/out/renderer/assets/{index-1JC2_Wd3.js → index-LF-blgre.js} +2 -2
  69. package/out/renderer/assets/{index-u_V0DpfA.js → index-RmenzFuK.js} +5 -5
  70. package/out/renderer/assets/{index-Cwqf0NbI.js → index-StlvWzAQ.js} +2 -2
  71. package/out/renderer/assets/{index-DMAjk3_P.js → index-aEJRypjl.js} +1 -1
  72. package/out/renderer/assets/{index-tUvIVnIS.js → index-cIujfEiH.js} +1 -1
  73. package/out/renderer/assets/{infoDiagram-6WML65LV-DM7_nqt3.js → infoDiagram-6WML65LV-BZrdglKf.js} +2 -2
  74. package/out/renderer/assets/{ishikawaDiagram-WSZJBQD7-DrWSKswv.js → ishikawaDiagram-WSZJBQD7-M3-Bx05k.js} +1 -1
  75. package/out/renderer/assets/{journeyDiagram-NVQOT4AX-Csn7KuKV.js → journeyDiagram-NVQOT4AX-OUrdoMWw.js} +4 -4
  76. package/out/renderer/assets/{jsx-dev-runtime-CTchQKOk.js → jsx-dev-runtime-BmYtwnS5.js} +1 -1
  77. package/out/renderer/assets/{kanban-definition-27J2QSJJ-BRXIW-y6.js → kanban-definition-27J2QSJJ-Bp1bLsvM.js} +2 -2
  78. package/out/renderer/assets/{layout-CjgVHH-8.js → layout-DHkE0LRs.js} +3 -3
  79. package/out/renderer/assets/{linear-7N8jztD_.js → linear-CbGhnOuY.js} +1 -1
  80. package/out/renderer/assets/{map-fXOUEC9w.js → map-cIUn-qth.js} +2 -2
  81. package/out/renderer/assets/{mindmap-definition-FAOFIHXS-eH5ANg_6.js → mindmap-definition-FAOFIHXS-Cn4b5kOp.js} +3 -3
  82. package/out/renderer/assets/{pegDiagram-VL7TDLO6-_S1HcQ4v.js → pegDiagram-VL7TDLO6-CVKr1c2L.js} +4 -4
  83. package/out/renderer/assets/{pieDiagram-7S7Q4E2Y-BbkejzGW.js → pieDiagram-7S7Q4E2Y-CWcOq9Qb.js} +4 -4
  84. package/out/renderer/assets/{quadrantDiagram-CIZ2JOQS-C9-OKkJL.js → quadrantDiagram-CIZ2JOQS-P3JVAK0b.js} +2 -2
  85. package/out/renderer/assets/{railroadDiagram-AXF67PYL-9VliFuUM.js → railroadDiagram-AXF67PYL-0ofS2KCh.js} +4 -4
  86. package/out/renderer/assets/{requirementDiagram-LRYGKXZP-Dr0S14Mj.js → requirementDiagram-LRYGKXZP-BKJvTfyp.js} +3 -3
  87. package/out/renderer/assets/{sankeyDiagram-W5VNT64P--k6pZLfZ.js → sankeyDiagram-W5VNT64P-rhaheiUH.js} +1 -1
  88. package/out/renderer/assets/{sequenceDiagram-SI44F4Z6-Bx4rTgvS.js → sequenceDiagram-SI44F4Z6-OYjmpEqz.js} +3 -3
  89. package/out/renderer/assets/{sizeCapture-X5ZJPWSS-BkRX3y1x.js → sizeCapture-X5ZJPWSS-CL0ajR5N.js} +1 -1
  90. package/out/renderer/assets/{stateDiagram-OKZ733FA-VF2TYKH_.js → stateDiagram-OKZ733FA-oiMfVXQn.js} +8 -8
  91. package/out/renderer/assets/{stateDiagram-v2-UEYNNEHI-BodH9nuP.js → stateDiagram-v2-UEYNNEHI-CcFKN2iZ.js} +5 -5
  92. package/out/renderer/assets/{swimlanes-SLNWSIFB-TnShw-0l.js → swimlanes-SLNWSIFB-DVH6NvWT.js} +6 -6
  93. package/out/renderer/assets/{swimlanesDiagram-ULZ7WXOC-CemoGOe8.js → swimlanesDiagram-ULZ7WXOC-CsUQN2E5.js} +7 -7
  94. package/out/renderer/assets/{time-CTB9_khZ.js → time-rV3KZfw-.js} +1 -1
  95. package/out/renderer/assets/{timeline-definition-Z64GVDOM-PQXf9HIJ.js → timeline-definition-Z64GVDOM-E-YDHKWt.js} +2 -2
  96. package/out/renderer/assets/{vennDiagram-T6HMQDX7-Db5aCF6z.js → vennDiagram-T6HMQDX7-2y9Eqtpd.js} +1 -1
  97. package/out/renderer/assets/{wardleyDiagram-T6FBY63Y-DI3Rr8Jy.js → wardleyDiagram-T6FBY63Y-D_iD5USe.js} +3 -3
  98. package/out/renderer/assets/{xychartDiagram-ELKLHX3M-CYptZ7pE.js → xychartDiagram-ELKLHX3M-NFI2AtZ8.js} +2 -2
  99. package/out/renderer/index.html +2 -2
  100. package/out/resources/skills/extension-creator/SKILL.md +46 -0
  101. package/out/resources/skills/extension-creator/assets/scripts/validate-extension-ui.mjs +479 -0
  102. package/out/resources/skills/extension-creator/references/extension-interface.md +8 -0
  103. package/out/resources/skills/extension-creator/references/in-repo-flow.md +1 -0
  104. package/out/resources/skills/extension-creator/references/project-global-flow.md +2 -1
  105. package/out/resources/skills/extension-creator/references/ui-components.md +21 -0
  106. package/out/runner.js +1077 -365
  107. package/package.json +53 -53
@@ -20,8 +20,8 @@
20
20
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
21
21
  <meta name="apple-mobile-web-app-title" content="AiderDesk">
22
22
  <link rel="apple-touch-icon" href="/icon-192.png">
23
- <script type="module" crossorigin src="./assets/index-DMzzmyZE.js"></script>
24
- <link rel="stylesheet" crossorigin href="./assets/index-DH7BFHAa.css">
23
+ <script type="module" crossorigin src="./assets/index-CqrtPgJE.js"></script>
24
+ <link rel="stylesheet" crossorigin href="./assets/index-D98qpStd.css">
25
25
  </head>
26
26
 
27
27
  <body>
@@ -144,6 +144,24 @@ Do not use when:
144
144
 
145
145
  **Never:** Use `'extension-settings'` placement — it was removed; use the dedicated config API instead
146
146
 
147
+ ### Rule: Validate UI components after creation
148
+
149
+ **When:** Any UI or config component (.jsx file) was created or modified
150
+
151
+ **Then:** Run the validator script and fix all reported issues
152
+
153
+ **Must:** Run `node <skill-dir>/assets/scripts/validate-extension-ui.mjs <file-or-dir>` where `<skill-dir>` is this skill's directory
154
+
155
+ **Must:** Ensure every file passes — exit code 0, all lines say `PASS`
156
+
157
+ **Must:** Fix all `[SYNTAX]` issues (the component would crash at render time) and `[TYPE]` issues (typos in props, React API, or `ui.*` component names)
158
+
159
+ **If:** A file uses config-style props (`config`, `updateConfig`) but is not named `Config*.jsx`
160
+
161
+ **Then:** Add `--type=config` (conversely, `--type=ui` forces UI-component props)
162
+
163
+ **Note:** The script needs `sucrase`, `typescript`, and `@types/react` resolvable (they are, when the aider-desk repo is available); otherwise it degrades to whatever checks are possible and says so in a warning
164
+
147
165
  ### Rule: Update registry and docs (In-Repo only)
148
166
 
149
167
  **When:** Target is In-Repo and extension file is created
@@ -196,6 +214,9 @@ Do not use when:
196
214
  - If extension needs constants, create constants.ts
197
215
  - If extension has placement-based UI components, create .jsx files for components (recommended for components > 20 lines)
198
216
 
217
+ **After any .jsx file is created:**
218
+ - Validate it: `node <skill-dir>/assets/scripts/validate-extension-ui.mjs <extension-dir>` — all files must pass
219
+
199
220
  ### For In-Repo target:
200
221
 
201
222
  1. Confirm user wants In-Repo (only available in aider-desk project)
@@ -211,6 +232,9 @@ Do not use when:
211
232
  **Between steps 3 and 5:**
212
233
  - Same optional files as Project/Global flow above
213
234
 
235
+ **After any .jsx file is created:**
236
+ - Validate it: `node <skill-dir>/assets/scripts/validate-extension-ui.mjs <extension-dir>` — all files must pass
237
+
214
238
  ## Preconditions
215
239
 
216
240
  Before using this skill, verify:
@@ -245,6 +269,7 @@ After completing this skill, verify:
245
269
  - Static `metadata` property on the class includes all required fields (name, version)
246
270
  - Default export is the extension class
247
271
  - No `@/` imports used
272
+ - All UI/config .jsx components pass `assets/scripts/validate-extension-ui.mjs`
248
273
  - **If In-Repo:** extensions.json updated correctly
249
274
  - **If In-Repo:** docs-site/docs/extensions/extensions-gallery.md updated
250
275
  - **If In-Repo:** Type checking passes
@@ -350,6 +375,26 @@ After completing this skill, verify:
350
375
  - When ambiguous: If the user says "log", "show", "display", or "report" something, default to `addLogMessage` (user-visible). Use `context.log` only for internal diagnostics.
351
376
  - Note: `context.log` is always available; `getTaskContext()` returns `null` outside a task, so always use optional chaining (`?.`)
352
377
 
378
+ **Situation:** Extension needs to manage resource cleanup (timers, watchers, child processes)
379
+
380
+ **Pattern:**
381
+ - When: Extension creates resources in `onLoad`, `onProjectStarted`, or event handlers that need cleanup
382
+ - Then: Use `context.addDisposable()` to co-locate setup and cleanup logic
383
+ - Setup runs immediately; if it returns a function, that function is called on unload (LIFO order). The cleanup may be sync or async (`Promise`) — async cleanups are awaited during unload
384
+ - Disposers run **before** `onUnload` is called, so both patterns work together
385
+ - Example:
386
+ ```typescript
387
+ async onLoad(context: ExtensionContext) {
388
+ // Setup and cleanup are co-located — no need to track in onUnload
389
+ context.addDisposable(() => {
390
+ const timer = setInterval(() => doWork(), 1000);
391
+ return () => clearInterval(timer);
392
+ });
393
+ }
394
+ // onUnload still works as a fallback for anything not registered via addDisposable
395
+ ```
396
+ - If setup returns `void`, no cleanup is registered — useful for fire-and-forget side effects
397
+
353
398
  **Situation:** Extension needs to store or retrieve memories
354
399
 
355
400
  **Pattern:**
@@ -447,6 +492,7 @@ After completing this skill, verify:
447
492
 
448
493
  ## Assets
449
494
 
495
+ - [scripts/validate-extension-ui.mjs](assets/scripts/validate-extension-ui.mjs) - UI component validator (syntax + type check)
450
496
  - [templates/single-file.ts.template](assets/templates/single-file.ts.template) - Single-file template
451
497
  - [templates/folder-extension/](assets/templates/folder-extension/) - Folder template (basic)
452
498
  - [templates/folder-extension-with-config/index.ts.template](assets/templates/folder-extension-with-config/index.ts.template) - Folder template with config component API
@@ -0,0 +1,479 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * validate-extension-ui.mjs — validates AiderDesk extension UI components (.jsx files)
4
+ *
5
+ * Performs two checks per file:
6
+ * 1. SYNTAX — runs the exact Sucrase transform the app uses at runtime
7
+ * (packages/common/src/jsx-transpiler.ts), so anything that would fail
8
+ * to render is caught here.
9
+ * 2. TYPES — compiles the template with the TypeScript compiler API against
10
+ * the real runtime props contract (props, ui, icons, executeExtensionAction,
11
+ * config/updateConfig, ...), catching typos and bad prop usage statically.
12
+ *
13
+ * Usage:
14
+ * node validate-extension-ui.mjs <file-or-dir> [...] [options]
15
+ *
16
+ * Options:
17
+ * --type=ui|config|auto Component kind (default: auto — files named
18
+ * Config*.jsx/tsx are treated as config components)
19
+ * --no-types Skip the TypeScript check (syntax only)
20
+ * --no-sucrase Skip the runtime-transform syntax check
21
+ * -h, --help Show this help
22
+ *
23
+ * Exit codes: 0 = all files valid, 1 = at least one failure, 2 = usage/environment error
24
+ */
25
+
26
+ import fs from 'node:fs';
27
+ import path from 'node:path';
28
+ import os from 'node:os';
29
+ import { fileURLToPath } from 'node:url';
30
+ import { createRequire } from 'node:module';
31
+
32
+ const require = createRequire(import.meta.url);
33
+
34
+ const SCRIPT_NAME = 'validate-extension-ui.mjs';
35
+ const JSX_EXTENSIONS = ['.jsx', '.tsx'];
36
+ const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'out', '__tests__']);
37
+
38
+ const printHelp = () => {
39
+ console.log(`Usage: node ${SCRIPT_NAME} <file-or-dir> [...] [options]
40
+
41
+ Options:
42
+ --type=ui|config|auto Component kind (default: auto — files named
43
+ Config*.jsx/tsx are treated as config components)
44
+ --no-types Skip the TypeScript check (syntax only)
45
+ --no-sucrase Skip the runtime-transform syntax check
46
+ -h, --help Show this help`);
47
+ };
48
+
49
+ const parseArgs = (argv) => {
50
+ const targets = [];
51
+ let type = 'auto';
52
+ let runTypes = true;
53
+ let runSucrase = true;
54
+
55
+ for (const arg of argv) {
56
+ if (arg === '-h' || arg === '--help') {
57
+ printHelp();
58
+ process.exit(0);
59
+ } else if (arg.startsWith('--type=')) {
60
+ const value = arg.slice('--type='.length);
61
+ if (!['ui', 'config', 'auto'].includes(value)) {
62
+ console.error(`Error: invalid --type value '${value}' (expected ui, config or auto)`);
63
+ process.exit(2);
64
+ }
65
+ type = value;
66
+ } else if (arg === '--no-types') {
67
+ runTypes = false;
68
+ } else if (arg === '--no-sucrase') {
69
+ runSucrase = false;
70
+ } else if (arg.startsWith('-')) {
71
+ console.error(`Error: unknown option '${arg}'`);
72
+ printHelp();
73
+ process.exit(2);
74
+ } else {
75
+ targets.push(arg);
76
+ }
77
+ }
78
+
79
+ return { targets, type, runTypes, runSucrase };
80
+ };
81
+
82
+ const loadOptional = (loader) => {
83
+ try {
84
+ return loader();
85
+ } catch {
86
+ return undefined;
87
+ }
88
+ };
89
+
90
+ const findRepoRoot = (startDir) => {
91
+ let dir = startDir;
92
+ while (true) {
93
+ if (fs.existsSync(path.join(dir, 'packages', 'common', 'src', 'types', 'common.ts'))) {
94
+ return dir;
95
+ }
96
+ const parent = path.dirname(dir);
97
+ if (parent === dir) {
98
+ return undefined;
99
+ }
100
+ dir = parent;
101
+ }
102
+ };
103
+
104
+ const resolveEnvironment = () => {
105
+ const sucrase = loadOptional(() => require('sucrase'));
106
+ const typescript = loadOptional(() => require('typescript'));
107
+ const reactTypesPkg = loadOptional(() => require.resolve('@types/react/package.json'));
108
+ const reactTypesDir = reactTypesPkg ? path.dirname(reactTypesPkg) : undefined;
109
+ const repoRoot = findRepoRoot(path.dirname(fileURLToPath(import.meta.url)));
110
+ const commonTypesAvailable = repoRoot !== undefined && reactTypesDir !== undefined;
111
+ return { sucrase, typescript, reactTypesDir, repoRoot, commonTypesAvailable };
112
+ };
113
+
114
+ const collectFiles = (targets) => {
115
+ const files = [];
116
+
117
+ const walk = (dir) => {
118
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
119
+ const fullPath = path.join(dir, entry.name);
120
+ if (entry.isDirectory()) {
121
+ if (!SKIP_DIRS.has(entry.name)) {
122
+ walk(fullPath);
123
+ }
124
+ } else if (entry.isFile() && JSX_EXTENSIONS.includes(path.extname(entry.name))) {
125
+ files.push(fullPath);
126
+ }
127
+ }
128
+ };
129
+
130
+ for (const target of targets) {
131
+ let stat;
132
+ try {
133
+ stat = fs.statSync(target);
134
+ } catch {
135
+ console.error(`Error: '${target}' does not exist`);
136
+ process.exit(2);
137
+ }
138
+ if (stat.isDirectory()) {
139
+ walk(target);
140
+ } else {
141
+ files.push(path.resolve(target));
142
+ }
143
+ }
144
+
145
+ return [...new Set(files)].sort();
146
+ };
147
+
148
+ const detectKind = (filePath, typeOverride) => {
149
+ if (typeOverride === 'ui' || typeOverride === 'config') {
150
+ return typeOverride;
151
+ }
152
+ return /^config.*\.(jsx|tsx)$/i.test(path.basename(filePath)) ? 'config' : 'ui';
153
+ };
154
+
155
+ // Mirrors packages/common/src/jsx-transpiler.ts exactly
156
+ const transpileLikeRuntime = (template, transform) => {
157
+ const REACT_IMPORT = 'import React from "react";';
158
+ const prepended = `${REACT_IMPORT}\nexport default ${template}`;
159
+ const result = transform(prepended, { transforms: ['jsx', 'typescript'], production: true });
160
+ if (result.diagnostics && result.diagnostics.length > 0) {
161
+ const diag = result.diagnostics[0];
162
+ const err = new Error(diag.message || 'Syntax error');
163
+ err.loc = diag.loc;
164
+ throw err;
165
+ }
166
+ return result.code;
167
+ };
168
+
169
+ const mapSucraseLocation = (loc) => {
170
+ if (!loc || typeof loc.line !== 'number') {
171
+ return undefined;
172
+ }
173
+ const templateLine = loc.line - 1;
174
+ if (templateLine < 1) {
175
+ return undefined;
176
+ }
177
+ let column = loc.column;
178
+ if (loc.line === 2) {
179
+ column = typeof column === 'number' ? Math.max(0, column - 'export default '.length) : column;
180
+ }
181
+ return { line: templateLine, column };
182
+ };
183
+
184
+ const buildPropsType = (kind, commonTypesAvailable) => {
185
+ const typeImports = commonTypesAvailable
186
+ ? `import type { AgentProfile, Message, Model, ProviderProfile, TaskData } from '@common/types';
187
+ import type { ApplicationAPI } from '@common/api';`
188
+ : `type AgentProfile = any;
189
+ type Message = any;
190
+ type Model = any;
191
+ type ProviderProfile = any;
192
+ type TaskData = any;
193
+ type ApplicationAPI = any;`;
194
+
195
+ const shared = `${typeImports}
196
+
197
+ type __AnyHandler = (...args: any[]) => any;
198
+ type __AnyComponentProps = {
199
+ children?: any;
200
+ onChange?: __AnyHandler;
201
+ onClick?: __AnyHandler;
202
+ onMouseEnter?: __AnyHandler;
203
+ onMouseLeave?: __AnyHandler;
204
+ onFocus?: __AnyHandler;
205
+ onBlur?: __AnyHandler;
206
+ onSubmit?: __AnyHandler;
207
+ onKeyDown?: __AnyHandler;
208
+ onKeyUp?: __AnyHandler;
209
+ onLoad?: __AnyHandler;
210
+ onError?: __AnyHandler;
211
+ renderItem?: __AnyHandler;
212
+ render?: __AnyHandler;
213
+ [key: string]: any;
214
+ };
215
+ type __AnyComponent = React.ComponentType<__AnyComponentProps>;
216
+ type __ExecuteExtensionAction = (action: string, ...args: unknown[]) => Promise<any>;
217
+
218
+ type __UIComponents = {
219
+ Button: __AnyComponent;
220
+ Checkbox: __AnyComponent;
221
+ Input: __AnyComponent;
222
+ Select: __AnyComponent;
223
+ TextArea: __AnyComponent;
224
+ IconButton: __AnyComponent;
225
+ RadioButton: __AnyComponent;
226
+ MultiSelect: __AnyComponent;
227
+ Slider: __AnyComponent;
228
+ DatePicker: __AnyComponent;
229
+ Chip: __AnyComponent;
230
+ ModelSelector: __AnyComponent;
231
+ Tooltip: __AnyComponent;
232
+ LoadingOverlay: __AnyComponent;
233
+ ConfirmDialog: __AnyComponent;
234
+ ModalOverlayLayout: __AnyComponent;
235
+ CodeBlock: __AnyComponent;
236
+ ExpandableMessageBlock: __AnyComponent;
237
+ };`;
238
+
239
+ const uiProps = `type __ComponentProps = {
240
+ projectDir?: string;
241
+ task?: TaskData;
242
+ agentProfile?: AgentProfile;
243
+ models: Model[];
244
+ providers: ProviderProfile[];
245
+ ui: __UIComponents;
246
+ icons: Record<string, Record<string, any>>;
247
+ libraries: Record<string, any>;
248
+ activateTask?: (taskId: string) => void;
249
+ executeExtensionAction: __ExecuteExtensionAction;
250
+ data: any;
251
+ api?: ApplicationAPI;
252
+ taskId?: string;
253
+ // index signature: extensions narrow with manual message.type checks, which TS cannot follow
254
+ message?: Message & Record<string, any>;
255
+ mode?: string;
256
+ onRunPrompt?: () => void;
257
+ onResumeTask?: () => void;
258
+ onDeleteTask?: () => void;
259
+ renderDefaultTaskActions?: () => React.ReactNode;
260
+ };`;
261
+
262
+ const configProps = `type __ComponentProps = {
263
+ extensionId: string;
264
+ config: Record<string, any> | null;
265
+ updateConfig: (newConfig: any) => void;
266
+ executeExtensionAction: __ExecuteExtensionAction;
267
+ ui: __UIComponents;
268
+ icons: Record<string, Record<string, any>>;
269
+ models: Model[];
270
+ providers: ProviderProfile[];
271
+ projectDir?: string;
272
+ task?: TaskData;
273
+ agentProfile?: AgentProfile;
274
+ api?: ApplicationAPI;
275
+ };`;
276
+
277
+ return `${shared}\n${kind === 'config' ? configProps : uiProps}\n`;
278
+ };
279
+
280
+ const typeCheckTemplate = (template, kind, env, sourceLines) => {
281
+ const header = `import * as React from 'react';\n${buildPropsType(kind, env.commonTypesAvailable)}`;
282
+ const footer = '\nconst __cmp: (props: __ComponentProps) => React.ReactNode = ';
283
+ const fileContent = `${header}${footer}${template};\n`;
284
+
285
+ const headerLineCount = header.split('\n').length + footer.split('\n').length - 1;
286
+
287
+ const tmpDir = env.repoRoot
288
+ ? path.join(env.repoRoot, 'node_modules', '.cache', 'aiderdesk-ext-ui-check')
289
+ : path.join(os.tmpdir(), 'aiderdesk-ext-ui-check');
290
+ fs.mkdirSync(tmpDir, { recursive: true });
291
+
292
+ const hash = [...template].reduce((acc, ch) => (acc * 31 + ch.charCodeAt(0)) >>> 0, 7);
293
+ const tmpFile = path.join(tmpDir, `check-${kind}-${hash.toString(36)}.tsx`);
294
+ fs.writeFileSync(tmpFile, fileContent);
295
+
296
+ try {
297
+ const compilerOptions = {
298
+ // deliberately loose: extension JSX is JavaScript at runtime, so patterns like
299
+ // useState(null)/useState([]) must not be flagged; typos and unknown names still are
300
+ noEmit: true,
301
+ target: env.typescript.ScriptTarget.ES2022,
302
+ module: env.typescript.ModuleKind.ESNext,
303
+ moduleResolution: env.typescript.ModuleResolutionKind.Bundler,
304
+ jsx: env.typescript.JsxEmit.ReactJSX,
305
+ lib: ['lib.es2022.d.ts', 'lib.dom.d.ts', 'lib.dom.iterable.d.ts'],
306
+ skipLibCheck: true,
307
+ esModuleInterop: true,
308
+ forceConsistentCasingInFileNames: true,
309
+ };
310
+
311
+ if (env.repoRoot) {
312
+ compilerOptions.baseUrl = env.repoRoot;
313
+ compilerOptions.paths = {
314
+ '@common/*': [path.join(env.repoRoot, 'packages', 'common', 'src', '*')],
315
+ };
316
+ } else if (env.reactTypesDir) {
317
+ compilerOptions.baseUrl = os.tmpdir();
318
+ compilerOptions.paths = {
319
+ react: [path.join(env.reactTypesDir, 'index.d.ts')],
320
+ 'react/jsx-runtime': [path.join(env.reactTypesDir, 'jsx-runtime.d.ts')],
321
+ };
322
+ }
323
+
324
+ const program = env.typescript.createProgram([tmpFile], compilerOptions);
325
+ const sourceFile = program.getSourceFile(tmpFile);
326
+ if (!sourceFile) {
327
+ return [{ line: 0, column: 0, message: 'Internal error: could not create TypeScript source file' }];
328
+ }
329
+
330
+ const diagnostics = [
331
+ ...env.typescript.getPreEmitDiagnostics(program).filter((d) => d.file === sourceFile),
332
+ ].filter((d) => {
333
+ const message = env.typescript.flattenDiagnosticMessageText(d.messageText, ' ');
334
+ // skip "Property 'x' does not exist on type '{ ... }'" — anonymous object literals come from
335
+ // spreads of dynamic data and local JS-style objects; extension JSX is untyped at runtime
336
+ if (d.code === 2339 && /on type '\{.*\}'\.?\s*$/.test(message)) {
337
+ return false;
338
+ }
339
+ // skip "Expected 1 arguments, but got 0. Did you forget 'void' ... 'Promise'?" — calling
340
+ // resolve() with no arguments is idiomatic JavaScript and fine at runtime
341
+ if (d.code === 2794 && /Did you forget to include 'void' in your type argument to 'Promise'/.test(message)) {
342
+ return false;
343
+ }
344
+ return true;
345
+ });
346
+
347
+ return diagnostics.map((diag) => {
348
+ const pos = diag.file.getLineAndCharacterOfPosition(diag.start);
349
+ const line = pos.line + 2 - headerLineCount;
350
+ const column = pos.character + 1;
351
+ const message = env.typescript.flattenDiagnosticMessageText(diag.messageText, ' ');
352
+ const excerpt = line >= 1 && line <= sourceLines.length ? sourceLines[line - 1].trim() : undefined;
353
+ return { line, column, message, excerpt };
354
+ });
355
+ } finally {
356
+ try {
357
+ fs.unlinkSync(tmpFile);
358
+ } catch {
359
+ // best-effort cleanup
360
+ }
361
+ }
362
+ };
363
+
364
+ const formatIssue = (label, issue) => {
365
+ const location = issue.line >= 1 ? `${issue.line}:${issue.column}` : 'line ?';
366
+ const lines = [` [${label}] ${location} ${issue.message}`];
367
+ if (issue.excerpt) {
368
+ lines.push(` ${issue.excerpt}`);
369
+ }
370
+ return lines.join('\n');
371
+ };
372
+
373
+ const displayPath = (filePath) => {
374
+ const relative = path.relative(process.cwd(), filePath);
375
+ return relative && !relative.startsWith('..') && !path.isAbsolute(relative) ? relative : filePath;
376
+ };
377
+
378
+ const cleanSucraseMessage = (message) => {
379
+ return message.split('\n')[0].replace(/\s*\(\d+:\d+\)\s*$/, '');
380
+ };
381
+
382
+ const validateFile = (filePath, kind, opts, env) => {
383
+ const relative = displayPath(filePath);
384
+ const template = fs.readFileSync(filePath, 'utf8');
385
+ const sourceLines = template.split('\n');
386
+ const issues = [];
387
+ const checksRun = [];
388
+
389
+ if (opts.runSucrase && env.sucrase) {
390
+ checksRun.push('syntax');
391
+ try {
392
+ transpileLikeRuntime(template, env.sucrase.transform);
393
+ } catch (error) {
394
+ const mapped = mapSucraseLocation(error.loc);
395
+ const line = mapped?.line ?? 0;
396
+ issues.push({
397
+ label: 'SYNTAX',
398
+ line,
399
+ column: mapped?.column ?? 0,
400
+ message: cleanSucraseMessage(error.message) || 'Syntax error',
401
+ excerpt: line >= 1 && line <= sourceLines.length ? sourceLines[line - 1].trim() : undefined,
402
+ });
403
+ }
404
+ }
405
+
406
+ if (opts.runTypes && env.typescript && env.reactTypesDir) {
407
+ checksRun.push('types');
408
+ for (const issue of typeCheckTemplate(template, kind, env, sourceLines)) {
409
+ issues.push({ label: 'TYPE', ...issue });
410
+ }
411
+ }
412
+
413
+ if (issues.length === 0) {
414
+ console.log(`PASS ${relative} (${kind}) — ${checksRun.length > 0 ? checksRun.join(', ') : 'no checks'}`);
415
+ return true;
416
+ }
417
+
418
+ console.log(`FAIL ${relative} (${kind})`);
419
+ for (const issue of issues) {
420
+ console.log(formatIssue(issue.label, issue));
421
+ }
422
+ return false;
423
+ };
424
+
425
+ const main = () => {
426
+ const opts = parseArgs(process.argv.slice(2));
427
+
428
+ if (opts.targets.length === 0) {
429
+ console.error('Error: no files or directories given');
430
+ printHelp();
431
+ process.exit(2);
432
+ }
433
+
434
+ const env = resolveEnvironment();
435
+ const warnings = [];
436
+ if (opts.runSucrase && !env.sucrase) {
437
+ warnings.push('sucrase not resolvable — runtime syntax check skipped (run from the aider-desk repo or install sucrase)');
438
+ }
439
+ if (opts.runTypes && (!env.typescript || !env.reactTypesDir)) {
440
+ warnings.push('typescript or @types/react not resolvable — type check skipped (run from the aider-desk repo or install them)');
441
+ }
442
+ if (opts.runTypes && env.typescript && env.reactTypesDir && !env.commonTypesAvailable) {
443
+ warnings.push('AiderDesk common types not found — checking with permissive (any) prop types');
444
+ }
445
+ for (const warning of warnings) {
446
+ console.log(`Warning: ${warning}`);
447
+ }
448
+ if (!opts.runTypes && !opts.runSucrase) {
449
+ console.error('Error: both checks disabled — nothing to validate');
450
+ process.exit(2);
451
+ }
452
+ if (warnings.length > 0 && !env.sucrase && (!env.typescript || !env.reactTypesDir)) {
453
+ console.error('Error: no validator dependencies available at all — cannot validate');
454
+ process.exit(2);
455
+ }
456
+
457
+ const files = collectFiles(opts.targets);
458
+ if (files.length === 0) {
459
+ console.error('Error: no .jsx/.tsx files found in the given targets');
460
+ process.exit(2);
461
+ }
462
+
463
+ console.log(`Validating ${files.length} file(s)...\n`);
464
+ let passed = 0;
465
+ let failed = 0;
466
+ for (const file of files) {
467
+ const kind = detectKind(file, opts.type);
468
+ if (validateFile(file, kind, opts, env)) {
469
+ passed++;
470
+ } else {
471
+ failed++;
472
+ }
473
+ }
474
+
475
+ console.log(`\nSummary: ${passed} passed, ${failed} failed`);
476
+ process.exit(failed > 0 ? 1 : 0);
477
+ };
478
+
479
+ main();
@@ -298,6 +298,14 @@ Context object passed to extension methods, providing access to AiderDesk APIs.
298
298
 
299
299
  ```typescript
300
300
  interface ExtensionContext {
301
+ /** Register a setup function whose returned cleanup function will be called
302
+ * automatically when the extension is unloaded.
303
+ * Setup runs immediately. Cleanup runs in reverse order of registration (LIFO).
304
+ * Cleanup may return a Promise; async cleanups are awaited during unload and
305
+ * errors are logged without blocking other cleanups.
306
+ * If setup returns void, no cleanup is registered. */
307
+ addDisposable(setup: () => (() => void | Promise<void>) | void): void;
308
+
301
309
  /** Log a message prefixed with the extension name. Type defaults to 'info'. */
302
310
  log(message: string, type?: 'info' | 'error' | 'warn' | 'debug'): void;
303
311
 
@@ -120,6 +120,7 @@ npm install
120
120
  ### Step 7: Verify
121
121
 
122
122
  - Run type checking: `npm run typecheck`
123
+ - Validate UI/config components (.jsx files) if any (see [ui-components.md](ui-components.md) → Validating components): `node <skill-dir>/assets/scripts/validate-extension-ui.mjs <extension-dir>` — all files must pass
123
124
  - Run tests if applicable: `npm run test`
124
125
  - Verify extension loads without errors
125
126
  - Check that extension appears in extensions list
@@ -66,7 +66,8 @@ Reference: [extension-interface.md](extension-interface.md)
66
66
 
67
67
  ### Step 4: Verify
68
68
 
69
- The extension will be auto-discovered by AiderDesk from the target directory. No restart needed — extensions are watched and loaded dynamically.
69
+ - If the extension has UI or config components (.jsx files), validate them (see [ui-components.md](ui-components.md) → Validating components): `node <skill-dir>/assets/scripts/validate-extension-ui.mjs <extension-dir>` — all files must pass
70
+ - The extension will be auto-discovered by AiderDesk from the target directory. No restart needed — extensions are watched and loaded dynamically.
70
71
 
71
72
  ## What NOT to do (Project/Global)
72
73
 
@@ -998,6 +998,27 @@ class MyExtension implements Extension {
998
998
  }
999
999
  ```
1000
1000
 
1001
+ ## Validating Components
1002
+
1003
+ Extension UI and config components are JSX strings, so they are not covered by normal TypeScript project checks. The extension-creator skill ships a validator script that checks them statically:
1004
+
1005
+ ```bash
1006
+ node <skill-dir>/assets/scripts/validate-extension-ui.mjs <Component.jsx | extension-dir> [--type=ui|config|auto]
1007
+ ```
1008
+
1009
+ The script runs two checks per file:
1010
+
1011
+ 1. **Syntax** — applies the exact Sucrase transform the app uses at runtime, so anything that would fail to render is caught
1012
+ 2. **Types** — compiles the template against the real runtime props contract (`props.ui.*`, `executeExtensionAction`, `config`/`updateConfig`, React API, `message`, etc.), catching typos like `props.updataConfig` or `React.useStat`
1013
+
1014
+ Behavior details:
1015
+
1016
+ - Files named `Config*.jsx` are treated as config components automatically; use `--type=ui` or `--type=config` to override
1017
+ - Directories are scanned recursively for `.jsx`/`.tsx` files (skips `node_modules`)
1018
+ - `--no-types` runs the syntax check only
1019
+ - Exit code 0 means all files pass; each failure prints `[SYNTAX]`/`[TYPE]` issues with line/column
1020
+ - Requires `sucrase`, `typescript`, and `@types/react` to be resolvable (true inside the aider-desk repo); otherwise it degrades to the checks that are possible and prints a warning
1021
+
1001
1022
  ## Best Practices
1002
1023
 
1003
1024
  ### Performance