@openchamber/web 1.18.4 → 1.20.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 (251) hide show
  1. package/README.md +1 -0
  2. package/dist/assets/{CodeMirrorCommentWidgets-4qZbrEXU.js → CodeMirrorCommentWidgets-C36E738Y.js} +1 -1
  3. package/dist/assets/{CommitSection-MJmntVPJ.js → CommitSection-C-F3AX6D.js} +1 -1
  4. package/dist/assets/{DiagramEditor-jnG3Hbxg.js → DiagramEditor-BPECg1jS.js} +1 -1
  5. package/dist/assets/DiagramView-D0YNMix8.js +1 -0
  6. package/dist/assets/DiffView-BHWaMYCC.js +4 -0
  7. package/dist/assets/FilesView-NMBCW2Tm.js +14 -0
  8. package/dist/assets/{GitView-DBFrDDBv.js → GitView-Rp8P1KEI.js} +4 -4
  9. package/dist/assets/{JsonTreeView-DLW2Wy1g.js → JsonTreeView-KnXFN2A-.js} +1 -1
  10. package/dist/assets/MarkdownImageGallery-BMn3mtor.js +1 -0
  11. package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +12 -0
  12. package/dist/assets/OnboardingScreen-CenIeD4v.js +1 -0
  13. package/dist/assets/{PatchDiff-BuLPx7AN.js → PatchDiff-BzVOVog8.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-BHm4Yr0X.js → PierreDiffViewer-Dlby4XqT.js} +2 -2
  15. package/dist/assets/PlanView-Czu1KMJa.js +4 -0
  16. package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +1 -0
  17. package/dist/assets/SettingsView-B6vmuf-c.js +28 -0
  18. package/dist/assets/SettingsWindow-CauZpdD3.js +1 -0
  19. package/dist/assets/ToolOutputDialog-BB1c--Zr.js +15 -0
  20. package/dist/assets/ToolPartDiffPreview-DaOIDISD.js +8 -0
  21. package/dist/assets/{VirtualizedFileDiff-CwGocYQd.js → VirtualizedFileDiff-lESMT-2b.js} +4 -4
  22. package/dist/assets/{WalkthroughView-5DyvN03T.js → WalkthroughView-CaSYE0lw.js} +2 -2
  23. package/dist/assets/{computeVirtualFileMetrics-Da00Jg7M.js → computeVirtualFileMetrics-DkRR5b75.js} +2 -2
  24. package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +1 -0
  25. package/dist/assets/de-DFdX3ABv.js +9 -0
  26. package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
  27. package/dist/assets/es-iC-FKvV9.js +15 -0
  28. package/dist/assets/fr-BBbi_1AL.js +13 -0
  29. package/dist/assets/index-BiEgzzkg.js +1 -0
  30. package/dist/assets/index-Cwmuwk3V.js +7 -0
  31. package/dist/assets/index-GNm1wgUH.css +1 -0
  32. package/dist/assets/{isDiffPlainText-D9YpoLrV.js → isDiffPlainText-BG53Ixxy.js} +1 -1
  33. package/dist/assets/{isFilePlainText-gTibdNIe.js → isFilePlainText-BbV-39jl.js} +1 -1
  34. package/dist/assets/ja-DQLQJL2J.js +15 -0
  35. package/dist/assets/ko-BeElEB4Y.js +15 -0
  36. package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
  37. package/dist/assets/main-Dpzo18z7.js +2 -0
  38. package/dist/assets/main-WMjtYzJs.js +921 -0
  39. package/dist/assets/markdownCore--tDmyI_v.js +2 -0
  40. package/dist/assets/miniChat-ldEghBLB.js +2 -0
  41. package/dist/assets/mobile-Dk-VGreF.js +2 -0
  42. package/dist/assets/{patchFileDiff-KNkxM1C1.js → patchFileDiff-BcFaMtMu.js} +1 -1
  43. package/dist/assets/pl-CLHt2_vV.js +15 -0
  44. package/dist/assets/pt-BR-C_MPUq7e.js +15 -0
  45. package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +2 -0
  46. package/dist/assets/renderMobileApp-CDfHS5rr.js +25 -0
  47. package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +15 -0
  48. package/dist/assets/scheduledTasksApi-BFSlqgnG.js +1 -0
  49. package/dist/assets/{shikiHighlight-C7LTbwFx.js → shikiHighlight-DCT2Sq_z.js} +1 -1
  50. package/dist/assets/uk-PhsC-c4-.js +15 -0
  51. package/dist/assets/{useAppFontEffects-BikB6enL.js → useAppFontEffects-B53Rb6m7.js} +168 -164
  52. package/dist/assets/useInlineCommentController-DSfrIBKT.js +2 -0
  53. package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-DsHmyMwp.js} +1 -1
  54. package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +1 -0
  55. package/dist/assets/vendor-codemirror-commands-B7H_j0iU.js +1 -0
  56. package/dist/assets/{vendor-codemirror-lang-angular-CgY7_gQ1.js → vendor-codemirror-lang-angular-DEPs2M5t.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-lang-cpp-B5Ta4enQ.js → vendor-codemirror-lang-cpp-DhkseaMo.js} +1 -1
  58. package/dist/assets/{vendor-codemirror-lang-css-VgNqFSH-.js → vendor-codemirror-lang-css-O0cZX78y.js} +1 -1
  59. package/dist/assets/{vendor-codemirror-lang-go-LxLz62pp.js → vendor-codemirror-lang-go-fMdQYcON.js} +1 -1
  60. package/dist/assets/vendor-codemirror-lang-html-CfgK872x.js +1 -0
  61. package/dist/assets/{vendor-codemirror-lang-java-Bksi1PH4.js → vendor-codemirror-lang-java-CQj4S3zl.js} +1 -1
  62. package/dist/assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js +13 -0
  63. package/dist/assets/{vendor-codemirror-lang-jinja-C7npuDD7.js → vendor-codemirror-lang-jinja-BmZZv8g-.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-lang-json-ryCw7nab.js → vendor-codemirror-lang-json-CMBS2tG9.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-lang-less-BxsZJD6N.js → vendor-codemirror-lang-less-C6Eo8hVS.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-lang-liquid-De6qch10.js → vendor-codemirror-lang-liquid-DSTR47-H.js} +1 -1
  67. package/dist/assets/vendor-codemirror-lang-markdown-BPGOH9ye.js +1 -0
  68. package/dist/assets/{vendor-codemirror-lang-php-Cm1es33p.js → vendor-codemirror-lang-php-DD9udfPH.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-python-N414WYK-.js → vendor-codemirror-lang-python-HahnQaAS.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-rust-C_WuUStH.js → vendor-codemirror-lang-rust-nLTovbjv.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-sass-8UHTCAOM.js → vendor-codemirror-lang-sass-pL2Yc72v.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-sql-CV3sMA5D.js → vendor-codemirror-lang-sql-BVBnan19.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-vue-DzvC1Dhk.js → vendor-codemirror-lang-vue-BqGzJVm1.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-wast-jlr-LDdA.js → vendor-codemirror-lang-wast-B0_m5DqU.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-xml-CrO63OVp.js → vendor-codemirror-lang-xml-Dj3voadT.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-yaml-dxi6CISW.js → vendor-codemirror-lang-yaml-yu-9Z5u7.js} +1 -1
  77. package/dist/assets/vendor-codemirror-language-BgPj_McA.js +3 -0
  78. package/dist/assets/{vendor-codemirror-language-data-CLHw8NWn.js → vendor-codemirror-language-data-vch3tJ4c.js} +2 -2
  79. package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +2 -0
  80. package/dist/assets/{vendor-codemirror-state-CNWM3Q8V.js → vendor-codemirror-state-C9awkmn-.js} +5 -5
  81. package/dist/assets/vendor-codemirror-view-CiLROUVV.js +4 -0
  82. package/dist/assets/vendor-replit-codemirror-vim-B2DJlAhT.js +6 -0
  83. package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
  84. package/dist/assets/vendor-zod-C9ioTTSo.js +39 -0
  85. package/dist/assets/{web-components-GMc3oR3i.js → web-components-pcwCTWjC.js} +4 -4
  86. package/dist/assets/zh-CN-wF-NOFHM.js +15 -0
  87. package/dist/assets/zh-TW-4m4-A7rT.js +15 -0
  88. package/dist/index.html +5 -4
  89. package/dist/mini-chat.html +4 -3
  90. package/dist/mobile.html +4 -3
  91. package/package.json +3 -5
  92. package/server/index.js +152 -3
  93. package/server/lib/agent-memory/actions.js +243 -0
  94. package/server/lib/agent-memory/actions.test.js +343 -0
  95. package/server/lib/agent-memory/feature-flag.js +19 -0
  96. package/server/lib/agent-memory/feature-flag.test.js +38 -0
  97. package/server/lib/agent-memory/project-resolution.js +65 -0
  98. package/server/lib/agent-memory/project-resolution.test.js +94 -0
  99. package/server/lib/agent-memory/routes.http.test.js +270 -0
  100. package/server/lib/agent-memory/routes.js +169 -0
  101. package/server/lib/agent-memory/runtime.js +432 -0
  102. package/server/lib/agent-memory/runtime.test.js +344 -0
  103. package/server/lib/agent-memory/threat-patterns.js +61 -0
  104. package/server/lib/agent-memory/threat-patterns.test.js +61 -0
  105. package/server/lib/agent-tool/DOCUMENTATION.md +14 -0
  106. package/server/lib/agent-tool/runtime.js +63 -13
  107. package/server/lib/agent-tool/runtime.test.js +85 -2
  108. package/server/lib/context-obligatory/runtime.js +34 -3
  109. package/server/lib/context-obligatory/runtime.test.js +114 -0
  110. package/server/lib/dictation/DOCUMENTATION.md +32 -8
  111. package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
  112. package/server/lib/dictation/local/worker-process.js +2 -2
  113. package/server/lib/dictation/openai-compatible-session.js +3 -2
  114. package/server/lib/dictation/stream-manager.js +77 -34
  115. package/server/lib/dictation/stream-manager.test.js +60 -2
  116. package/server/lib/fs/DOCUMENTATION.md +3 -0
  117. package/server/lib/fs/routes.js +149 -32
  118. package/server/lib/fs/routes.test.js +301 -0
  119. package/server/lib/git/DOCUMENTATION.md +8 -0
  120. package/server/lib/git/routes.js +43 -0
  121. package/server/lib/git/service.js +206 -72
  122. package/server/lib/git/service.test.js +222 -0
  123. package/server/lib/github/DOCUMENTATION.md +14 -3
  124. package/server/lib/github/pr-status.js +188 -83
  125. package/server/lib/github/pr-status.test.js +182 -0
  126. package/server/lib/github/routes.js +36 -30
  127. package/server/lib/notifications/template-runtime.js +2 -3
  128. package/server/lib/openchamber-control/action-resolution.test.js +65 -0
  129. package/server/lib/openchamber-control/actions.js +78 -0
  130. package/server/lib/openchamber-control/service.js +7 -0
  131. package/server/lib/openchamber-sessions/routes.js +14 -0
  132. package/server/lib/opencode/DOCUMENTATION.md +12 -6
  133. package/server/lib/opencode/claude-cli-auth.js +60 -0
  134. package/server/lib/opencode/claude-cli-auth.test.js +54 -0
  135. package/server/lib/opencode/feature-routes-runtime.js +16 -9
  136. package/server/lib/opencode/lifecycle.js +202 -26
  137. package/server/lib/opencode/lifecycle.test.js +179 -1
  138. package/server/lib/opencode/plugins.js +12 -3
  139. package/server/lib/opencode/plugins.test.js +18 -0
  140. package/server/lib/opencode/providers.js +9 -4
  141. package/server/lib/opencode/providers.test.js +27 -0
  142. package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
  143. package/server/lib/opencode/proxy.js +116 -6
  144. package/server/lib/opencode/proxy.test.js +158 -1
  145. package/server/lib/opencode/restart-session-recovery.test.js +59 -0
  146. package/server/lib/opencode/routes.js +4 -1
  147. package/server/lib/opencode/session-runtime.js +39 -2
  148. package/server/lib/opencode/session-runtime.test.js +74 -0
  149. package/server/lib/opencode/settings-helpers.js +26 -0
  150. package/server/lib/opencode/settings-helpers.test.js +57 -0
  151. package/server/lib/opencode/settings-normalization-runtime.js +3 -0
  152. package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
  153. package/server/lib/opencode/settings-runtime.js +83 -10
  154. package/server/lib/opencode/settings-runtime.test.js +85 -0
  155. package/server/lib/opencode/shared.js +120 -16
  156. package/server/lib/opencode/shared.test.js +185 -1
  157. package/server/lib/opencode/skill-routes.js +29 -73
  158. package/server/lib/opencode/skill-routes.test.js +2 -5
  159. package/server/lib/project-context/DOCUMENTATION.md +160 -0
  160. package/server/lib/project-context/routes.http.test.js +264 -0
  161. package/server/lib/project-context/routes.js +237 -0
  162. package/server/lib/project-context/runtime.js +672 -0
  163. package/server/lib/project-context/runtime.test.js +498 -0
  164. package/server/lib/projects/project-config.js +7 -2
  165. package/server/lib/quota/DOCUMENTATION.md +17 -2
  166. package/server/lib/quota/providers/claude/auth.js +113 -0
  167. package/server/lib/quota/providers/claude/auth.test.js +117 -0
  168. package/server/lib/quota/providers/claude/index.js +151 -0
  169. package/server/lib/quota/providers/claude/index.test.js +147 -0
  170. package/server/lib/quota/providers/claude/transforms.js +127 -0
  171. package/server/lib/quota/providers/claude/transforms.test.js +82 -0
  172. package/server/lib/quota/providers/command-code.js +90 -0
  173. package/server/lib/quota/providers/command-code.test.js +85 -0
  174. package/server/lib/quota/providers/index.js +30 -2
  175. package/server/lib/quota/providers/index.test.js +10 -1
  176. package/server/lib/quota/providers/zai.js +26 -6
  177. package/server/lib/quota/providers/zai.test.js +33 -0
  178. package/server/lib/quota/utils/formatters.js +2 -1
  179. package/server/lib/scheduled-tasks/runtime.js +21 -2
  180. package/server/lib/session-knowledge/DOCUMENTATION.md +89 -0
  181. package/server/lib/session-knowledge/routes.js +107 -0
  182. package/server/lib/session-knowledge/runtime.js +331 -0
  183. package/server/lib/session-knowledge/runtime.test.js +275 -0
  184. package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
  185. package/server/lib/skills-catalog/cache.js +120 -1
  186. package/server/lib/skills-catalog/cache.test.js +77 -0
  187. package/server/lib/skills-catalog/curated-sources.js +21 -5
  188. package/server/lib/skills-catalog/curated-sources.test.js +10 -0
  189. package/server/lib/skills-catalog/disk-cache.js +52 -0
  190. package/server/lib/skills-catalog/github-meta.js +139 -0
  191. package/server/lib/skills-catalog/github-meta.test.js +71 -0
  192. package/server/lib/skills-catalog/source.js +0 -5
  193. package/server/lib/small-model/DOCUMENTATION.md +74 -6
  194. package/server/lib/small-model/call.js +46 -12
  195. package/server/lib/small-model/call.test.js +79 -0
  196. package/server/lib/small-model/index.js +57 -6
  197. package/server/lib/small-model/index.test.js +102 -2
  198. package/server/lib/small-model/routes.js +4 -2
  199. package/server/lib/small-model/runtime-providers.js +156 -0
  200. package/server/lib/small-model/runtime-providers.test.js +112 -0
  201. package/dist/assets/DiagramView-CFXxgg_a.js +0 -1
  202. package/dist/assets/DiffView-DZIoOnV7.js +0 -4
  203. package/dist/assets/FilesView-BKL6YlKG.js +0 -14
  204. package/dist/assets/MarkdownImageGallery-DKIylIK7.js +0 -1
  205. package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +0 -12
  206. package/dist/assets/OnboardingScreen-D2Y6djMw.js +0 -1
  207. package/dist/assets/PlanView-ZYEJn8A_.js +0 -4
  208. package/dist/assets/SessionSwitcherDropdown-rro-SsaO.js +0 -1
  209. package/dist/assets/SettingsView-5RmswFZe.js +0 -28
  210. package/dist/assets/SettingsWindow-BZhAYFdS.js +0 -1
  211. package/dist/assets/ToolOutputDialog-Za6V4VMJ.js +0 -15
  212. package/dist/assets/ToolPartDiffPreview-BL-9ixyC.js +0 -8
  213. package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +0 -1
  214. package/dist/assets/de-u7gSnqWs.js +0 -9
  215. package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
  216. package/dist/assets/es-T9O7aAOr.js +0 -15
  217. package/dist/assets/fr-Oor7ewbE.js +0 -13
  218. package/dist/assets/index-BzIpNlNE.css +0 -1
  219. package/dist/assets/index-C0yNhuZw.js +0 -1
  220. package/dist/assets/index-DRpChWux.js +0 -7
  221. package/dist/assets/ja-DHpqbVmr.js +0 -15
  222. package/dist/assets/ko-CwLkS3nx.js +0 -15
  223. package/dist/assets/main-D7UcL3VQ.js +0 -2
  224. package/dist/assets/main-DPMd2iKS.js +0 -915
  225. package/dist/assets/markdownCore-DDrHVneM.js +0 -2
  226. package/dist/assets/miniChat-O_GVoEbc.js +0 -2
  227. package/dist/assets/mobile-Br4TtAqc.js +0 -2
  228. package/dist/assets/pl-CcZILN8q.js +0 -15
  229. package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
  230. package/dist/assets/renderElectronMiniChatApp-CJpdxTT1.js +0 -2
  231. package/dist/assets/renderMobileApp-toj9cXoh.js +0 -25
  232. package/dist/assets/runtimeEndpointReset-BVmispdD.js +0 -13
  233. package/dist/assets/scheduledTasksApi-ByKya3Un.js +0 -1
  234. package/dist/assets/uk-BA2kZR38.js +0 -15
  235. package/dist/assets/useInlineCommentController-CYPvYJDt.js +0 -2
  236. package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
  237. package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
  238. package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
  239. package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
  240. package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
  241. package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
  242. package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
  243. package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
  244. package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
  245. package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
  246. package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
  247. package/server/lib/quota/providers/claude.js +0 -107
  248. package/server/lib/skills-catalog/clawdhub/api.js +0 -126
  249. package/server/lib/skills-catalog/clawdhub/install.js +0 -238
  250. package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
  251. package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
@@ -1,107 +0,0 @@
1
- import { readAuthFile } from '../../opencode/auth.js';
2
- import {
3
- getAuthEntry,
4
- normalizeAuthEntry,
5
- buildResult,
6
- toUsageWindow,
7
- toNumber,
8
- toTimestamp
9
- } from '../utils/index.js';
10
-
11
- export const providerId = 'claude';
12
- export const providerName = 'Claude';
13
- const aliases = ['anthropic', 'claude'];
14
-
15
- export const isConfigured = () => {
16
- const auth = readAuthFile();
17
- const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
18
- return Boolean(entry?.access || entry?.token);
19
- };
20
-
21
- export const fetchQuota = async () => {
22
- const auth = readAuthFile();
23
- const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
24
- const accessToken = entry?.access ?? entry?.token;
25
-
26
- if (!accessToken) {
27
- return buildResult({
28
- providerId,
29
- providerName,
30
- ok: false,
31
- configured: false,
32
- error: 'Not configured'
33
- });
34
- }
35
-
36
- try {
37
- const response = await fetch('https://api.anthropic.com/api/oauth/usage', {
38
- method: 'GET',
39
- headers: {
40
- Authorization: `Bearer ${accessToken}`,
41
- 'anthropic-beta': 'oauth-2025-04-20'
42
- }
43
- });
44
-
45
- if (!response.ok) {
46
- return buildResult({
47
- providerId,
48
- providerName,
49
- ok: false,
50
- configured: true,
51
- error: `API error: ${response.status}`
52
- });
53
- }
54
-
55
- const payload = await response.json();
56
- const windows = {};
57
- const fiveHour = payload?.five_hour ?? null;
58
- const sevenDay = payload?.seven_day ?? null;
59
- const sevenDaySonnet = payload?.seven_day_sonnet ?? null;
60
- const sevenDayOpus = payload?.seven_day_opus ?? null;
61
-
62
- if (fiveHour) {
63
- windows['5h'] = toUsageWindow({
64
- usedPercent: toNumber(fiveHour.utilization),
65
- windowSeconds: null,
66
- resetAt: toTimestamp(fiveHour.resets_at)
67
- });
68
- }
69
- if (sevenDay) {
70
- windows['7d'] = toUsageWindow({
71
- usedPercent: toNumber(sevenDay.utilization),
72
- windowSeconds: null,
73
- resetAt: toTimestamp(sevenDay.resets_at)
74
- });
75
- }
76
- if (sevenDaySonnet) {
77
- windows['7d-sonnet'] = toUsageWindow({
78
- usedPercent: toNumber(sevenDaySonnet.utilization),
79
- windowSeconds: null,
80
- resetAt: toTimestamp(sevenDaySonnet.resets_at)
81
- });
82
- }
83
- if (sevenDayOpus) {
84
- windows['7d-opus'] = toUsageWindow({
85
- usedPercent: toNumber(sevenDayOpus.utilization),
86
- windowSeconds: null,
87
- resetAt: toTimestamp(sevenDayOpus.resets_at)
88
- });
89
- }
90
-
91
- return buildResult({
92
- providerId,
93
- providerName,
94
- ok: true,
95
- configured: true,
96
- usage: { windows }
97
- });
98
- } catch (error) {
99
- return buildResult({
100
- providerId,
101
- providerName,
102
- ok: false,
103
- configured: true,
104
- error: error instanceof Error ? error.message : 'Request failed'
105
- });
106
- }
107
- };
@@ -1,126 +0,0 @@
1
- /**
2
- * ClawdHub API client
3
- *
4
- * ClawdHub is a public skill registry at https://clawdhub.com
5
- * This client provides methods to fetch skills list and download skill packages.
6
- */
7
-
8
- const CLAWDHUB_API_BASE = 'https://clawdhub.com/api/v1';
9
- const CLAWDHUB_PAGE_LIMIT = 25;
10
-
11
- // Rate limiting: ClawdHub allows 120 requests/minute
12
- const RATE_LIMIT_DELAY_MS = 100;
13
- let lastRequestTime = 0;
14
-
15
- async function rateLimitedFetch(url, options = {}) {
16
- const maxAttempts = 10;
17
-
18
- let lastResponse = null;
19
-
20
- for (let attempt = 0; attempt < maxAttempts; attempt++) {
21
- const now = Date.now();
22
- const elapsed = now - lastRequestTime;
23
- if (elapsed < RATE_LIMIT_DELAY_MS) {
24
- await new Promise((resolve) => setTimeout(resolve, RATE_LIMIT_DELAY_MS - elapsed));
25
- }
26
- lastRequestTime = Date.now();
27
-
28
- const response = await fetch(url, {
29
- ...options,
30
- headers: {
31
- Accept: 'application/json',
32
- 'User-Agent': 'OpenChamber/1.0',
33
- ...options.headers,
34
- },
35
- });
36
-
37
- lastResponse = response;
38
-
39
- if (response.status === 429 || response.status >= 500) {
40
- if (attempt < maxAttempts - 1) {
41
- const waitMs = 50 * (attempt + 1);
42
- await new Promise((resolve) => setTimeout(resolve, waitMs));
43
- continue;
44
- }
45
- }
46
-
47
- return response;
48
- }
49
-
50
- return lastResponse;
51
- }
52
-
53
- /**
54
- * Fetch paginated list of skills from ClawdHub
55
- * @param {Object} options
56
- * @param {string} [options.cursor] - Pagination cursor from previous response
57
- * @returns {Promise<{ items: Array, nextCursor?: string }>}
58
- */
59
- export async function fetchClawdHubSkills({ cursor } = {}) {
60
- const url = cursor
61
- ? `${CLAWDHUB_API_BASE}/skills?cursor=${encodeURIComponent(cursor)}&limit=${CLAWDHUB_PAGE_LIMIT}`
62
- : `${CLAWDHUB_API_BASE}/skills?limit=${CLAWDHUB_PAGE_LIMIT}`;
63
-
64
- const response = await rateLimitedFetch(url);
65
-
66
- if (!response.ok) {
67
- const text = await response.text().catch(() => '');
68
- throw new Error(`ClawdHub API error (${response.status}): ${text || response.statusText}`);
69
- }
70
-
71
- const data = await response.json();
72
- const nextCursor =
73
- (typeof data.nextCursor === 'string' && data.nextCursor) ||
74
- (typeof data.next_cursor === 'string' && data.next_cursor) ||
75
- (typeof data.next === 'string' && data.next) ||
76
- (typeof data.cursor === 'string' && data.cursor) ||
77
- null;
78
-
79
- return {
80
- items: data.items || [],
81
- nextCursor,
82
- };
83
- }
84
-
85
- /**
86
- * Download a skill package as a ZIP buffer
87
- * @param {string} slug - Skill slug/identifier
88
- * @param {string} version - Specific version string
89
- * @returns {Promise<ArrayBuffer>} - ZIP file contents
90
- */
91
- export async function downloadClawdHubSkill(slug, version) {
92
- const versionParam = typeof version === 'string' && version !== 'latest'
93
- ? `&version=${encodeURIComponent(version)}`
94
- : '&tag=latest';
95
- const url = `${CLAWDHUB_API_BASE}/download?slug=${encodeURIComponent(slug)}${versionParam}`;
96
-
97
- const response = await rateLimitedFetch(url, {
98
- headers: {
99
- Accept: 'application/zip',
100
- },
101
- });
102
-
103
- if (!response.ok) {
104
- const text = await response.text().catch(() => '');
105
- throw new Error(`ClawdHub download error (${response.status}): ${text || response.statusText}`);
106
- }
107
-
108
- return response.arrayBuffer();
109
- }
110
-
111
- /**
112
- * Get skill metadata without version details
113
- * @param {string} slug - Skill slug/identifier
114
- * @returns {Promise<Object>}
115
- */
116
- export async function fetchClawdHubSkillInfo(slug) {
117
- const url = `${CLAWDHUB_API_BASE}/skills/${encodeURIComponent(slug)}`;
118
- const response = await rateLimitedFetch(url);
119
-
120
- if (!response.ok) {
121
- const text = await response.text().catch(() => '');
122
- throw new Error(`ClawdHub skill error (${response.status}): ${text || response.statusText}`);
123
- }
124
-
125
- return response.json();
126
- }
@@ -1,238 +0,0 @@
1
- /**
2
- * ClawdHub skill installation
3
- *
4
- * Downloads skills from ClawdHub as ZIP files and extracts them
5
- * to the appropriate skill directory.
6
- */
7
-
8
- import fs from 'fs';
9
- import os from 'os';
10
- import path from 'path';
11
- import AdmZip from 'adm-zip';
12
-
13
- import { downloadClawdHubSkill, fetchClawdHubSkillInfo } from './api.js';
14
-
15
- const SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/;
16
-
17
- function normalizeUserSkillDir(userSkillDir) {
18
- if (!userSkillDir) return null;
19
- const legacySkillDir = path.join(os.homedir(), '.config', 'opencode', 'skill');
20
- const pluralSkillDir = path.join(os.homedir(), '.config', 'opencode', 'skills');
21
- if (userSkillDir === legacySkillDir) {
22
- if (fs.existsSync(legacySkillDir) && !fs.existsSync(pluralSkillDir)) return legacySkillDir;
23
- return pluralSkillDir;
24
- }
25
- return userSkillDir;
26
- }
27
-
28
- function validateSkillName(skillName) {
29
- if (typeof skillName !== 'string') return false;
30
- if (skillName.length < 1 || skillName.length > 64) return false;
31
- return SKILL_NAME_PATTERN.test(skillName);
32
- }
33
-
34
- async function safeRm(dir) {
35
- try {
36
- await fs.promises.rm(dir, { recursive: true, force: true });
37
- } catch {
38
- // ignore
39
- }
40
- }
41
-
42
- async function ensureDir(dirPath) {
43
- await fs.promises.mkdir(dirPath, { recursive: true });
44
- }
45
-
46
- function getTargetSkillDir({ scope, targetSource, workingDirectory, userSkillDir, skillName }) {
47
- const source = targetSource === 'agents' ? 'agents' : 'opencode';
48
-
49
- if (scope === 'user') {
50
- if (source === 'agents') {
51
- return path.join(os.homedir(), '.agents', 'skills', skillName);
52
- }
53
- return path.join(userSkillDir, skillName);
54
- }
55
-
56
- if (!workingDirectory) {
57
- throw new Error('workingDirectory is required for project installs');
58
- }
59
-
60
- if (source === 'agents') {
61
- return path.join(workingDirectory, '.agents', 'skills', skillName);
62
- }
63
-
64
- return path.join(workingDirectory, '.opencode', 'skills', skillName);
65
- }
66
-
67
- /**
68
- * Install skills from ClawdHub registry
69
- * @param {Object} options
70
- * @param {string} options.scope - 'user' or 'project'
71
- * @param {string} [options.targetSource] - 'opencode' or 'agents'
72
- * @param {string} [options.workingDirectory] - Required for project scope
73
- * @param {string} options.userSkillDir - User skills directory
74
- * @param {Array} options.selections - Array of { skillDir, clawdhub: { slug, version } }
75
- * @param {string} [options.conflictPolicy] - 'prompt', 'skipAll', or 'overwriteAll'
76
- * @param {Object} [options.conflictDecisions] - Per-skill conflict decisions
77
- * @returns {Promise<{ ok: boolean, installed?: Array, skipped?: Array, error?: Object }>}
78
- */
79
- export async function installSkillsFromClawdHub({
80
- scope,
81
- targetSource,
82
- workingDirectory,
83
- userSkillDir,
84
- selections,
85
- conflictPolicy,
86
- conflictDecisions,
87
- } = {}) {
88
- if (scope !== 'user' && scope !== 'project') {
89
- return { ok: false, error: { kind: 'invalidSource', message: 'Invalid scope' } };
90
- }
91
-
92
- if (targetSource !== undefined && targetSource !== 'opencode' && targetSource !== 'agents') {
93
- return { ok: false, error: { kind: 'invalidSource', message: 'Invalid target source' } };
94
- }
95
-
96
- if (!userSkillDir) {
97
- return { ok: false, error: { kind: 'unknown', message: 'userSkillDir is required' } };
98
- }
99
-
100
- const normalizedUserSkillDir = normalizeUserSkillDir(userSkillDir);
101
- if (normalizedUserSkillDir) {
102
- userSkillDir = normalizedUserSkillDir;
103
- }
104
-
105
- if (scope === 'project' && !workingDirectory) {
106
- return { ok: false, error: { kind: 'invalidSource', message: 'Project installs require a directory parameter' } };
107
- }
108
-
109
- const requestedSkills = Array.isArray(selections) ? selections : [];
110
- if (requestedSkills.length === 0) {
111
- return { ok: false, error: { kind: 'invalidSource', message: 'No skills selected for installation' } };
112
- }
113
-
114
- // Build installation plans
115
- const skillPlans = requestedSkills.map((sel) => {
116
- const slug = sel.clawdhub?.slug || sel.skillDir;
117
- const version = sel.clawdhub?.version || 'latest';
118
- return {
119
- slug,
120
- version,
121
- installable: validateSkillName(slug),
122
- };
123
- });
124
-
125
- // Check for conflicts before downloading
126
- const conflicts = [];
127
- for (const plan of skillPlans) {
128
- if (!plan.installable) {
129
- continue;
130
- }
131
-
132
- const targetDir = getTargetSkillDir({ scope, targetSource, workingDirectory, userSkillDir, skillName: plan.slug });
133
- if (fs.existsSync(targetDir)) {
134
- const decision = conflictDecisions?.[plan.slug];
135
- const hasAutoPolicy = conflictPolicy === 'skipAll' || conflictPolicy === 'overwriteAll';
136
- if (!decision && !hasAutoPolicy) {
137
- conflicts.push({ skillName: plan.slug, scope, source: targetSource === 'agents' ? 'agents' : 'opencode' });
138
- }
139
- }
140
- }
141
-
142
- if (conflicts.length > 0) {
143
- return {
144
- ok: false,
145
- error: {
146
- kind: 'conflicts',
147
- message: 'Some skills already exist in the selected scope',
148
- conflicts,
149
- },
150
- };
151
- }
152
-
153
- const installed = [];
154
- const skipped = [];
155
-
156
- for (const plan of skillPlans) {
157
- if (!plan.installable) {
158
- skipped.push({ skillName: plan.slug, reason: 'Invalid skill name' });
159
- continue;
160
- }
161
-
162
- try {
163
- // Resolve 'latest' version if needed
164
- let resolvedVersion = plan.version;
165
- if (resolvedVersion === 'latest') {
166
- try {
167
- const info = await fetchClawdHubSkillInfo(plan.slug);
168
- const latest = info.skill?.tags?.latest || info.latestVersion?.version || null;
169
- if (latest) {
170
- resolvedVersion = latest;
171
- }
172
- } catch {
173
- // ignore
174
- }
175
-
176
- if (resolvedVersion === 'latest') {
177
- skipped.push({ skillName: plan.slug, reason: 'Unable to resolve latest version' });
178
- continue;
179
- }
180
- }
181
-
182
- const targetDir = getTargetSkillDir({ scope, targetSource, workingDirectory, userSkillDir, skillName: plan.slug });
183
- const exists = fs.existsSync(targetDir);
184
-
185
- // Determine conflict resolution
186
- let decision = conflictDecisions?.[plan.slug] || null;
187
- if (!decision) {
188
- if (exists && conflictPolicy === 'skipAll') decision = 'skip';
189
- if (exists && conflictPolicy === 'overwriteAll') decision = 'overwrite';
190
- if (!exists) decision = 'overwrite'; // No conflict, proceed
191
- }
192
-
193
- if (exists && decision === 'skip') {
194
- skipped.push({ skillName: plan.slug, reason: 'Already installed (skipped)' });
195
- continue;
196
- }
197
-
198
- if (exists && decision === 'overwrite') {
199
- await safeRm(targetDir);
200
- }
201
-
202
- // Download the skill ZIP
203
- const zipBuffer = await downloadClawdHubSkill(plan.slug, resolvedVersion);
204
-
205
- // Extract to a temp directory first for validation
206
- const tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), `clawdhub-${plan.slug}-`));
207
-
208
- try {
209
- const zip = new AdmZip(Buffer.from(zipBuffer));
210
- zip.extractAllTo(tempDir, true);
211
-
212
- // Verify SKILL.md exists
213
- const skillMdPath = path.join(tempDir, 'SKILL.md');
214
- if (!fs.existsSync(skillMdPath)) {
215
- skipped.push({ skillName: plan.slug, reason: 'SKILL.md not found in downloaded package' });
216
- continue;
217
- }
218
-
219
- // Move to target directory
220
- await ensureDir(path.dirname(targetDir));
221
- await fs.promises.rename(tempDir, targetDir);
222
-
223
- installed.push({ skillName: plan.slug, scope, source: targetSource === 'agents' ? 'agents' : 'opencode' });
224
- } catch (extractError) {
225
- await safeRm(tempDir);
226
- throw extractError;
227
- }
228
- } catch (error) {
229
- console.error(`Failed to install ClawdHub skill "${plan.slug}":`, error);
230
- skipped.push({
231
- skillName: plan.slug,
232
- reason: error instanceof Error ? error.message : 'Failed to download or extract skill',
233
- });
234
- }
235
- }
236
-
237
- return { ok: true, installed, skipped };
238
- }
@@ -1,100 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
- import fs from 'node:fs';
3
- import os from 'node:os';
4
- import path from 'node:path';
5
- import AdmZip from 'adm-zip';
6
-
7
- // Mock the ClawdHub network client so no real HTTP happens. The download
8
- // function is what feeds the ZIP buffer into adm-zip inside install.js.
9
- vi.mock('./api.js', () => ({
10
- downloadClawdHubSkill: vi.fn(),
11
- fetchClawdHubSkillInfo: vi.fn(),
12
- }));
13
-
14
- const { downloadClawdHubSkill } = await import('./api.js');
15
- const { installSkillsFromClawdHub } = await import('./install.js');
16
-
17
- /**
18
- * Build a real ZIP archive with adm-zip (the dependency under test).
19
- * Returns the raw Buffer, mirroring what downloadClawdHubSkill resolves to.
20
- */
21
- function buildSkillZip(entries) {
22
- const zip = new AdmZip();
23
- for (const [entryName, content] of Object.entries(entries)) {
24
- zip.addFile(entryName, Buffer.from(content, 'utf8'));
25
- }
26
- return zip.toBuffer();
27
- }
28
-
29
- describe('installSkillsFromClawdHub (adm-zip extraction path)', () => {
30
- let userSkillDir;
31
-
32
- beforeEach(async () => {
33
- // Keep the target dir under os.tmpdir() so the temp->target rename in
34
- // install.js stays on one filesystem (avoids EXDEV cross-device errors).
35
- userSkillDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'clawdhub-test-skills-'));
36
- vi.clearAllMocks();
37
- });
38
-
39
- afterEach(async () => {
40
- await fs.promises.rm(userSkillDir, { recursive: true, force: true }).catch(() => {});
41
- });
42
-
43
- it('extracts a real ZIP (incl. nested subdirectories) into the target skill dir', async () => {
44
- const skillMd = 'name: demo-skill\ndescription: adm-zip extraction regression guard\n';
45
- const nested = 'nested file content for subdirectory extraction check\n';
46
- downloadClawdHubSkill.mockResolvedValue(
47
- buildSkillZip({ 'SKILL.md': skillMd, 'nested/data.txt': nested }),
48
- );
49
-
50
- const result = await installSkillsFromClawdHub({
51
- scope: 'user',
52
- targetSource: 'opencode',
53
- userSkillDir,
54
- // Non-'latest' version avoids the fetchClawdHubSkillInfo resolve branch.
55
- selections: [{ clawdhub: { slug: 'demo-skill', version: '1.0.0' } }],
56
- });
57
-
58
- expect(result.ok).toBe(true);
59
- expect(result.installed).toEqual([
60
- { skillName: 'demo-skill', scope: 'user', source: 'opencode' },
61
- ]);
62
- expect(result.skipped).toEqual([]);
63
-
64
- // downloadClawdHubSkill received the resolved (non-latest) version.
65
- expect(downloadClawdHubSkill).toHaveBeenCalledWith('demo-skill', '1.0.0');
66
-
67
- // adm-zip actually wrote the files, preserving the nested subdirectory.
68
- const targetDir = path.join(userSkillDir, 'demo-skill');
69
- const skillMdPath = path.join(targetDir, 'SKILL.md');
70
- const nestedPath = path.join(targetDir, 'nested', 'data.txt');
71
-
72
- expect(fs.existsSync(skillMdPath)).toBe(true);
73
- expect(fs.existsSync(nestedPath)).toBe(true);
74
- expect(fs.readFileSync(skillMdPath, 'utf8')).toBe(skillMd);
75
- expect(fs.readFileSync(nestedPath, 'utf8')).toBe(nested);
76
- });
77
-
78
- it('skips a package whose extracted contents lack SKILL.md', async () => {
79
- // Valid ZIP, but no SKILL.md at the root -> install.js must skip it and
80
- // must NOT create the target dir. This exercises the extractAllTo path
81
- // followed by the post-extraction validation.
82
- downloadClawdHubSkill.mockResolvedValue(
83
- buildSkillZip({ 'README.md': 'no skill manifest here\n' }),
84
- );
85
-
86
- const result = await installSkillsFromClawdHub({
87
- scope: 'user',
88
- targetSource: 'opencode',
89
- userSkillDir,
90
- selections: [{ clawdhub: { slug: 'broken-skill', version: '1.0.0' } }],
91
- });
92
-
93
- expect(result.ok).toBe(true);
94
- expect(result.installed).toEqual([]);
95
- expect(result.skipped).toEqual([
96
- { skillName: 'broken-skill', reason: 'SKILL.md not found in downloaded package' },
97
- ]);
98
- expect(fs.existsSync(path.join(userSkillDir, 'broken-skill'))).toBe(false);
99
- });
100
- });
@@ -1,61 +0,0 @@
1
- /**
2
- * ClawdHub skill scanning
3
- *
4
- * Fetches all available skills from the ClawdHub registry
5
- * and transforms them into SkillsCatalogItem format.
6
- */
7
-
8
- import { fetchClawdHubSkills } from './api.js';
9
-
10
- const CLAWDHUB_PAGE_LIMIT = 25;
11
-
12
- const mapClawdHubItem = (item) => {
13
- const latestVersion = item.tags?.latest || item.latestVersion?.version || '1.0.0';
14
-
15
- return {
16
- sourceId: 'clawdhub',
17
- repoSource: 'clawdhub:registry',
18
- repoSubpath: null,
19
- gitIdentityId: null,
20
- skillDir: item.slug,
21
- skillName: item.slug,
22
- frontmatterName: item.displayName || item.slug,
23
- description: item.summary || null,
24
- installable: true,
25
- warnings: [],
26
- // ClawdHub-specific metadata
27
- clawdhub: {
28
- slug: item.slug,
29
- version: latestVersion,
30
- displayName: item.displayName,
31
- owner: item.owner?.handle || null,
32
- downloads: item.stats?.downloads || 0,
33
- stars: item.stats?.stars || 0,
34
- versionsCount: item.stats?.versions || 1,
35
- createdAt: item.createdAt,
36
- updatedAt: item.updatedAt,
37
- },
38
- };
39
- };
40
-
41
- /**
42
- * Scan a single ClawdHub page (cursor-based)
43
- * @returns {Promise<{ ok: boolean, items?: Array, nextCursor?: string | null, error?: Object }>}
44
- */
45
- export async function scanClawdHubPage({ cursor } = {}) {
46
- try {
47
- const { items, nextCursor } = await fetchClawdHubSkills({ cursor });
48
- const mapped = (items || []).map(mapClawdHubItem).slice(0, CLAWDHUB_PAGE_LIMIT);
49
- mapped.sort((a, b) => (b.clawdhub?.downloads || 0) - (a.clawdhub?.downloads || 0));
50
- return { ok: true, items: mapped, nextCursor: nextCursor || null };
51
- } catch (error) {
52
- console.error('ClawdHub page scan error:', error);
53
- return {
54
- ok: false,
55
- error: {
56
- kind: 'networkError',
57
- message: error instanceof Error ? error.message : 'Failed to fetch skills from ClawdHub',
58
- },
59
- };
60
- }
61
- }