@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,21 +1,17 @@
1
1
  # Skills Catalog Module Documentation
2
2
 
3
3
  ## Purpose
4
- This module provides skill discovery, scanning, and installation capabilities for OpenCode. It supports multiple skill sources including git repositories and the ClawdHub registry, with caching and conflict resolution for skill installation.
4
+ This module provides skill discovery, scanning, and installation capabilities for OpenCode. It supports skill sources backed by git repositories, with caching and conflict resolution for skill installation.
5
5
 
6
6
  ## Entrypoints and structure
7
7
  - `packages/web/server/lib/skills-catalog/`: Skills catalog module directory containing all skill-related functionality.
8
8
  - `cache.js`: In-memory cache for scan results with TTL support.
9
- - `curated-sources.js`: Predefined skill sources (Anthropic, ClawdHub).
9
+ - `curated-sources.js`: Predefined skill sources (Anthropic, OpenAI, Cursor, Matt Pocock).
10
+ - `github-meta.js`: Best-effort GitHub repository metadata (stars, last push) with in-memory TTL cache.
10
11
  - `git.js`: Git operations helpers for cloning and auth error detection.
11
12
  - `install.js`: Skills installation from git repositories.
12
13
  - `scan.js`: Skills scanning from git repositories.
13
14
  - `source.js`: Source string parsing for git repositories.
14
- - `clawdhub/`: ClawdHub registry integration.
15
- - `index.js`: Public API exports for ClawdHub.
16
- - `scan.js`: Scanning ClawdHub registry with pagination.
17
- - `install.js`: Installation from ClawdHub (ZIP download).
18
- - `api.js`: ClawdHub API client with rate limiting.
19
15
 
20
16
  ## Public API
21
17
 
@@ -24,13 +20,19 @@ The following functions are exported and used by the web server:
24
20
  ### Cache (`cache.js`)
25
21
  - `getCacheKey({ normalizedRepo, subpath, identityId })`: Generate cache key for scan results.
26
22
  - `getCachedScan(key)`: Retrieve cached scan result if not expired.
27
- - `setCachedScan(key, value, ttlMs)`: Store scan result with TTL (default 30 minutes).
23
+ - `setCachedScan(key, value, ttlMs)`: Store scan result with TTL (default 3 hours).
24
+ - `scanWithCache(key, loader, { refresh })`: Run a scan loader with cache lookup, in-flight deduplication, and a global concurrency limit (2 concurrent scans); only `ok: true` results are cached.
28
25
  - `clearCache()`: Clear all cached scan results.
26
+ - Scan results persist to `skills-catalog-cache.json` in the OpenChamber data dir (debounced, atomic rename) and survive server restarts within the TTL.
29
27
 
30
28
  ### Curated Sources (`curated-sources.js`)
31
- - `getCuratedSkillsSources()`: Return list of curated skill sources (Anthropic, ClawdHub).
29
+ - `getCuratedSkillsSources()`: Return list of curated skill sources (Anthropic, OpenAI, Cursor, Matt Pocock).
32
30
  - `CURATED_SKILLS_SOURCES`: Constant array of predefined sources.
33
31
 
32
+ ### GitHub Repository Metadata (`github-meta.js`)
33
+ - `fetchGitHubRepoMetas(normalizedRepos)`: Fetch `{ stars, repoUpdatedAt }` for GitHub `owner/repo` strings. Best-effort: failures resolve to `null`; in-flight requests deduplicate; results cached in memory and on disk (`skills-github-meta.json`) for three hours.
34
+ - `clearGitHubMetaCache()`: Test-only cache reset.
35
+
34
36
  ### Source Parsing (`source.js`)
35
37
  - `parseSkillRepoSource(source, { subpath })`: Parse git repository source string into structured object with SSH/HTTPS clone URLs, normalized repo, and effective subpath. Supports SSH URLs, HTTPS URLs, and shorthand `owner/repo[/subpath]` format.
36
38
 
@@ -40,20 +42,6 @@ The following functions are exported and used by the web server:
40
42
  ### Git Repository Installation (`install.js`)
41
43
  - `installSkillsFromRepository({ source, subpath, defaultSubpath, identity, scope, targetSource, workingDirectory, userSkillDir, selections, conflictPolicy, conflictDecisions })`: Install skills from git repository. Supports user/project scopes, opencode/agents targets, conflict resolution (prompt/skipAll/overwriteAll), and sparse checkout for efficiency.
42
44
 
43
- ### ClawdHub Integration (`clawdhub/index.js`)
44
- - `isClawdHubSource(source)`: Check if source string refers to ClawdHub.
45
- - `scanClawdHub()`: Scan entire ClawdHub registry for all skills (paginated, max 20 pages).
46
- - `scanClawdHubPage({ cursor })`: Scan a single page of ClawdHub results with cursor-based pagination.
47
- - `installSkillsFromClawdHub({ scope, targetSource, workingDirectory, userSkillDir, selections, conflictPolicy, conflictDecisions })`: Install skills from ClawdHub by downloading ZIP files.
48
- - `fetchClawdHubSkills({ cursor })`: Fetch paginated skills list from ClawdHub API.
49
- - `fetchClawdHubSkillVersion(slug, version)`: Fetch specific skill version details.
50
- - `fetchClawdHubSkillInfo(slug)`: Fetch skill metadata without version details.
51
- - `downloadClawdHubSkill(slug, version)`: Download skill package as ZIP buffer.
52
-
53
- ### ClawdHub Constants (`clawdhub/index.js`)
54
- - `CLAWDHUB_SOURCE_ID`: Source identifier for curated sources.
55
- - `CLAWDHUB_SOURCE_STRING`: Source string format.
56
-
57
45
  ## Internal Helpers
58
46
 
59
47
  The following functions are internal helpers used by exported functions:
@@ -63,10 +51,10 @@ The following functions are internal helpers used by exported functions:
63
51
  - `looksLikeAuthError(message)`: Detect if error message indicates authentication failure (permission denied, publickey, etc.).
64
52
  - `assertGitAvailable()`: Check if git is available in PATH.
65
53
 
66
- ### Skill Name Validation (used in `install.js`, `scan.js`, `clawdhub/install.js`)
54
+ ### Skill Name Validation (used in `install.js`, `scan.js`)
67
55
  - `validateSkillName(skillName)`: Validate skill name against pattern `/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/` (1-64 chars, lowercase alphanumeric with hyphens).
68
56
 
69
- ### File System Helpers (`install.js`, `scan.js`, `clawdhub/install.js`)
57
+ ### File System Helpers (`install.js`, `scan.js`)
70
58
  - `safeRm(dir)`: Safely remove directory recursively (ignores errors).
71
59
  - `ensureDir(dirPath)`: Ensure directory exists with recursive creation.
72
60
  - `copyDirectoryNoSymlinks(srcDir, dstDir)`: Copy directory contents without symlinks, with path traversal protection.
@@ -82,10 +70,6 @@ The following functions are internal helpers used by exported functions:
82
70
  - `toFsPath(repoDir, repoRelPosixPath)`: Convert POSIX path to filesystem path.
83
71
  - `getTargetSkillDir({ scope, targetSource, workingDirectory, userSkillDir, skillName })`: Determine target installation directory based on scope (user/project), targetSource (opencode/agents), and skill name.
84
72
 
85
- ### ClawdHub API Helpers (`clawdhub/api.js`)
86
- - `rateLimitedFetch(url, options)`: Fetch with rate limiting (120 req/min limit, 100ms delay between requests, exponential backoff on 429/500 errors).
87
- - `mapClawdHubItem(item)`: Transform ClawdHub API response to SkillsCatalogItem format.
88
-
89
73
  ## Response Contracts
90
74
 
91
75
  ### Scan Skills Repository Response
@@ -101,12 +85,6 @@ The following functions are internal helpers used by exported functions:
101
85
  - `skipped`: Array of skipped skills with `{ skillName, reason }`.
102
86
  - `error`: Error object with `{ kind, message, conflicts? }` on failure. Kinds: `authRequired`, `networkError`, `conflicts`, `invalidSource`, `unknown`.
103
87
 
104
- ### ClawdHub Scan Response
105
- - `ok`: Boolean indicating success.
106
- - `items`: Array of skill items with ClawdHub-specific metadata in `clawdhub` property.
107
- - `nextCursor`: Pagination cursor for next page (only for `scanClawdHubPage`).
108
- - `error`: Error object with `{ kind, message }` on failure.
109
-
110
88
  ### Parse Source Response
111
89
  - `ok`: Boolean indicating success.
112
90
  - `host`: Git host (e.g., `github.com`, `gitlab.com`).
@@ -129,7 +107,7 @@ The following functions are internal helpers used by exported functions:
129
107
 
130
108
  ### Skill Name Validation
131
109
  - All skill names must match `/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/` (1-64 chars).
132
- - Skill names are derived from directory basenames for git repos and slugs for ClawdHub.
110
+ - Skill names are derived from directory basenames for git repos.
133
111
  - Invalid names result in non-installable skills with appropriate warnings.
134
112
 
135
113
  ### Git Cloning Strategy
@@ -144,17 +122,12 @@ The following functions are internal helpers used by exported functions:
144
122
  - Per-skill decisions override global policy via `conflictDecisions` map.
145
123
  - Conflict response includes `{ skillName, scope, source }` for each conflict.
146
124
 
147
- ### ClawdHub Integration
148
- - ClawdHub API base URL: `https://clawdhub.com/api/v1`.
149
- - Pagination uses cursor-based approach with `MAX_PAGES=20` safety limit.
150
- - Rate limiting: 120 req/min with 100ms delay between requests.
151
- - Downloaded skills are extracted from ZIP files using `adm-zip`.
152
- - Always validate `SKILL.md` exists before installation.
153
-
154
125
  ### Cache Management
155
126
  - Cache keys include `normalizedRepo`, `subpath`, and `identityId` for isolation.
156
- - Default TTL is 30 minutes; can be overridden via `ttlMs` parameter.
157
- - Cache is in-memory (not persisted across restarts).
127
+ - Default TTL is 3 hours for both scan results and GitHub repository metadata.
128
+ - Scan and GitHub metadata caches persist to JSON files in the OpenChamber data dir, so app restarts and page refreshes reuse previous results instead of re-hitting GitHub.
129
+ - Scans run through a global concurrency limiter (2 at a time) with per-key in-flight deduplication.
130
+ - The refresh button passes `refresh: true` and bypasses the cache.
158
131
 
159
132
  ### Security Considerations
160
133
  - Path traversal protection in `copyDirectoryNoSymlinks`: resolves real paths and checks containment.
@@ -1,6 +1,58 @@
1
- const DEFAULT_TTL_MS = 30 * 60 * 1000;
1
+ import { readDiskCache, writeDiskCache } from './disk-cache.js';
2
+
3
+ const DEFAULT_TTL_MS = 3 * 60 * 60 * 1000;
4
+ const DISK_CACHE_FILE = 'skills-catalog-cache.json';
5
+ const MAX_CONCURRENT_SCANS = 2;
2
6
 
3
7
  const cache = new Map();
8
+ const inFlight = new Map();
9
+
10
+ let diskLoaded = false;
11
+ let diskWriteTimer = null;
12
+
13
+ const loadDiskEntries = () => {
14
+ if (diskLoaded) {
15
+ return;
16
+ }
17
+ diskLoaded = true;
18
+ const persisted = readDiskCache(DISK_CACHE_FILE);
19
+ if (!persisted) {
20
+ return;
21
+ }
22
+ const now = Date.now();
23
+ for (const [key, entry] of Object.entries(persisted)) {
24
+ if (
25
+ entry
26
+ && typeof entry === 'object'
27
+ && typeof entry.expiresAt === 'number'
28
+ && entry.expiresAt > now
29
+ && entry.value
30
+ && typeof entry.value === 'object'
31
+ ) {
32
+ cache.set(key, entry);
33
+ }
34
+ }
35
+ };
36
+
37
+ const scheduleDiskWrite = () => {
38
+ if (diskWriteTimer) {
39
+ return;
40
+ }
41
+ diskWriteTimer = setTimeout(() => {
42
+ diskWriteTimer = null;
43
+ const now = Date.now();
44
+ const persisted = {};
45
+ for (const [key, entry] of cache.entries()) {
46
+ if (entry.expiresAt > now) {
47
+ persisted[key] = entry;
48
+ }
49
+ }
50
+ writeDiskCache(DISK_CACHE_FILE, persisted);
51
+ }, 1000);
52
+ if (typeof diskWriteTimer.unref === 'function') {
53
+ diskWriteTimer.unref();
54
+ }
55
+ };
4
56
 
5
57
  export function getCacheKey({ normalizedRepo, subpath, identityId }) {
6
58
  const safeRepo = String(normalizedRepo || '').trim();
@@ -10,6 +62,7 @@ export function getCacheKey({ normalizedRepo, subpath, identityId }) {
10
62
  }
11
63
 
12
64
  export function getCachedScan(key) {
65
+ loadDiskEntries();
13
66
  const entry = cache.get(key);
14
67
  if (!entry) return null;
15
68
  if (Date.now() >= entry.expiresAt) {
@@ -22,4 +75,70 @@ export function getCachedScan(key) {
22
75
  export function setCachedScan(key, value, ttlMs = DEFAULT_TTL_MS) {
23
76
  const ttl = Number.isFinite(ttlMs) ? ttlMs : DEFAULT_TTL_MS;
24
77
  cache.set(key, { expiresAt: Date.now() + ttl, value });
78
+ scheduleDiskWrite();
79
+ }
80
+
81
+ export function clearCache() {
82
+ cache.clear();
83
+ inFlight.clear();
84
+ }
85
+
86
+ // ─── Concurrency-limited scan orchestration ───
87
+
88
+ let activeScans = 0;
89
+ const scanQueue = [];
90
+
91
+ const acquireScanSlot = () => new Promise((resolve) => {
92
+ scanQueue.push(resolve);
93
+ pumpScanQueue();
94
+ });
95
+
96
+ const releaseScanSlot = () => {
97
+ activeScans -= 1;
98
+ pumpScanQueue();
99
+ };
100
+
101
+ const pumpScanQueue = () => {
102
+ while (activeScans < MAX_CONCURRENT_SCANS && scanQueue.length > 0) {
103
+ const resolve = scanQueue.shift();
104
+ activeScans += 1;
105
+ resolve();
106
+ }
107
+ };
108
+
109
+ /**
110
+ * Run `loader` for a scan cache key with deduplication and a global
111
+ * concurrency limit. Concurrent callers for the same key share one loader
112
+ * run; at most MAX_CONCURRENT_SCANS loaders run at once. Only successful
113
+ * (`ok: true`) results are cached.
114
+ */
115
+ export async function scanWithCache(key, loader, { refresh = false } = {}) {
116
+ if (!refresh) {
117
+ const cached = getCachedScan(key);
118
+ if (cached) {
119
+ return cached;
120
+ }
121
+ }
122
+
123
+ const existing = inFlight.get(key);
124
+ if (existing) {
125
+ return existing;
126
+ }
127
+
128
+ const run = (async () => {
129
+ await acquireScanSlot();
130
+ try {
131
+ const result = await loader();
132
+ if (result && result.ok) {
133
+ setCachedScan(key, result);
134
+ }
135
+ return result;
136
+ } finally {
137
+ releaseScanSlot();
138
+ inFlight.delete(key);
139
+ }
140
+ })();
141
+
142
+ inFlight.set(key, run);
143
+ return run;
25
144
  }
@@ -0,0 +1,77 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import fs from 'fs';
3
+ import os from 'os';
4
+ import path from 'path';
5
+ import { clearCache, scanWithCache, setCachedScan, getCachedScan } from './cache.js';
6
+
7
+ let tempDataDir;
8
+
9
+ beforeEach(() => {
10
+ tempDataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skills-cache-test-'));
11
+ process.env.OPENCHAMBER_DATA_DIR = tempDataDir;
12
+ });
13
+
14
+ afterEach(() => {
15
+ delete process.env.OPENCHAMBER_DATA_DIR;
16
+ clearCache();
17
+ vi.restoreAllMocks();
18
+ fs.rmSync(tempDataDir, { recursive: true, force: true });
19
+ });
20
+
21
+ const flushDiskWrites = async () => new Promise((resolve) => setTimeout(resolve, 1200));
22
+
23
+ describe('scanWithCache', () => {
24
+ it('deduplicates concurrent loaders for the same key', async () => {
25
+ const loader = vi.fn(async () => {
26
+ await new Promise((resolve) => setTimeout(resolve, 20));
27
+ return { ok: true, items: [] };
28
+ });
29
+
30
+ const [a, b] = await Promise.all([
31
+ scanWithCache('k', loader),
32
+ scanWithCache('k', loader),
33
+ ]);
34
+
35
+ expect(loader).toHaveBeenCalledTimes(1);
36
+ expect(a).toEqual(b);
37
+ });
38
+
39
+ it('limits concurrent scans across different keys', async () => {
40
+ let running = 0;
41
+ let peak = 0;
42
+ const loader = async () => {
43
+ running += 1;
44
+ peak = Math.max(peak, running);
45
+ await new Promise((resolve) => setTimeout(resolve, 20));
46
+ running -= 1;
47
+ return { ok: true, items: [] };
48
+ };
49
+
50
+ await Promise.all(Array.from({ length: 6 }, (_, i) => scanWithCache(`key-${i}`, loader)));
51
+
52
+ expect(peak).toBeLessThanOrEqual(2);
53
+ });
54
+
55
+ it('does not cache failed scans', async () => {
56
+ await scanWithCache('bad', async () => ({ ok: false, error: { kind: 'networkError', message: 'x' } }));
57
+
58
+ expect(getCachedScan('bad')).toBeNull();
59
+ });
60
+
61
+ it('refresh bypasses the cache', async () => {
62
+ setCachedScan('fresh', { ok: true, items: ['cached'] });
63
+
64
+ const result = await scanWithCache('fresh', async () => ({ ok: true, items: ['reloaded'] }), { refresh: true });
65
+
66
+ expect(result.items).toEqual(['reloaded']);
67
+ expect(getCachedScan('fresh').items).toEqual(['reloaded']);
68
+ });
69
+
70
+ it('persists successful scans to disk for later processes', async () => {
71
+ await scanWithCache('persisted', async () => ({ ok: true, items: [{ skillName: 'x' }] }));
72
+ await flushDiskWrites();
73
+
74
+ const onDisk = JSON.parse(fs.readFileSync(path.join(tempDataDir, 'skills-catalog-cache.json'), 'utf8'));
75
+ expect(onDisk.persisted.value.items).toEqual([{ skillName: 'x' }]);
76
+ });
77
+ });
@@ -8,11 +8,27 @@ const CURATED_SKILLS_SOURCES = [
8
8
  sourceType: 'github',
9
9
  },
10
10
  {
11
- id: 'clawdhub',
12
- label: 'ClawdHub',
13
- description: 'Community skill registry with vector search',
14
- source: 'clawdhub:registry',
15
- sourceType: 'clawdhub',
11
+ id: 'openai',
12
+ label: 'OpenAI',
13
+ description: "OpenAI's curated skills",
14
+ source: 'openai/skills',
15
+ defaultSubpath: 'skills/.curated',
16
+ sourceType: 'github',
17
+ },
18
+ {
19
+ id: 'cursor',
20
+ label: 'Cursor',
21
+ description: "Cursor's plugin skills",
22
+ source: 'cursor/plugins',
23
+ defaultSubpath: 'pstack/skills',
24
+ sourceType: 'github',
25
+ },
26
+ {
27
+ id: 'mattpocock',
28
+ label: 'Matt Pocock',
29
+ description: 'Matt Pocock skills collection',
30
+ source: 'mattpocock/skills',
31
+ sourceType: 'github',
16
32
  },
17
33
  ];
18
34
 
@@ -0,0 +1,10 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { getCuratedSkillsSources } from './curated-sources.js';
3
+
4
+ describe('getCuratedSkillsSources', () => {
5
+ it('includes the Anthropic curated source', () => {
6
+ const anthropic = getCuratedSkillsSources().find((source) => source.id === 'anthropic');
7
+ expect(anthropic).toBeDefined();
8
+ expect(anthropic.label).toBe('Anthropic');
9
+ });
10
+ });
@@ -0,0 +1,52 @@
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+
5
+ const resolveDataDir = () => (process.env.OPENCHAMBER_DATA_DIR
6
+ ? path.resolve(process.env.OPENCHAMBER_DATA_DIR)
7
+ : path.join(os.homedir(), '.config', 'openchamber'));
8
+
9
+ const readJsonFile = (filePath) => {
10
+ try {
11
+ const raw = fs.readFileSync(filePath, 'utf8');
12
+ const parsed = JSON.parse(raw);
13
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : null;
14
+ } catch {
15
+ return null;
16
+ }
17
+ };
18
+
19
+ /**
20
+ * Read a persisted cache object from the OpenChamber data directory.
21
+ * Returns null when the file is missing, unreadable, or malformed.
22
+ */
23
+ export const readDiskCache = (fileName) => {
24
+ try {
25
+ return readJsonFile(path.join(resolveDataDir(), fileName));
26
+ } catch {
27
+ return null;
28
+ }
29
+ };
30
+
31
+ /**
32
+ * Persist a cache object to the OpenChamber data directory with an atomic
33
+ * temp-file rename. Failures are ignored: the in-memory cache stays
34
+ * authoritative and the next successful write retries persistence.
35
+ */
36
+ export const writeDiskCache = (fileName, data) => {
37
+ const filePath = path.join(resolveDataDir(), fileName);
38
+ const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
39
+ try {
40
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
41
+ fs.writeFileSync(tempPath, JSON.stringify(data), { encoding: 'utf8', mode: 0o600 });
42
+ fs.renameSync(tempPath, filePath);
43
+ return true;
44
+ } catch {
45
+ try {
46
+ fs.unlinkSync(tempPath);
47
+ } catch {
48
+ // ignore
49
+ }
50
+ return false;
51
+ }
52
+ };
@@ -0,0 +1,139 @@
1
+ import { readDiskCache, writeDiskCache } from './disk-cache.js';
2
+
3
+ const GITHUB_API_BASE = 'https://api.github.com';
4
+ const CACHE_TTL_MS = 3 * 60 * 60 * 1000;
5
+ const FAILURE_CACHE_TTL_MS = 5 * 60 * 1000;
6
+ // Keep well under the catalog route's client request deadline so optional
7
+ // metadata enrichment can never abort catalog loading.
8
+ const FETCH_TIMEOUT_MS = 1500;
9
+ const DISK_CACHE_FILE = 'skills-github-meta.json';
10
+
11
+ const metaCache = new Map();
12
+ const inFlight = new Map();
13
+
14
+ let diskLoaded = false;
15
+ let diskWriteTimer = null;
16
+
17
+ const loadDiskEntries = () => {
18
+ if (diskLoaded) {
19
+ return;
20
+ }
21
+ diskLoaded = true;
22
+ const persisted = readDiskCache(DISK_CACHE_FILE);
23
+ if (!persisted) {
24
+ return;
25
+ }
26
+ const now = Date.now();
27
+ for (const [repo, entry] of Object.entries(persisted)) {
28
+ if (
29
+ entry
30
+ && typeof entry === 'object'
31
+ && typeof entry.expiresAt === 'number'
32
+ && entry.expiresAt > now
33
+ && entry.value
34
+ && typeof entry.value === 'object'
35
+ ) {
36
+ metaCache.set(repo, entry);
37
+ }
38
+ }
39
+ };
40
+
41
+ const scheduleDiskWrite = () => {
42
+ if (diskWriteTimer) {
43
+ return;
44
+ }
45
+ diskWriteTimer = setTimeout(() => {
46
+ diskWriteTimer = null;
47
+ const now = Date.now();
48
+ const persisted = {};
49
+ for (const [repo, entry] of metaCache.entries()) {
50
+ if (entry.expiresAt > now) {
51
+ persisted[repo] = entry;
52
+ }
53
+ }
54
+ writeDiskCache(DISK_CACHE_FILE, persisted);
55
+ }, 1000);
56
+ if (typeof diskWriteTimer.unref === 'function') {
57
+ diskWriteTimer.unref();
58
+ }
59
+ };
60
+
61
+ const parseMeta = (payload) => {
62
+ if (!payload || typeof payload !== 'object') {
63
+ return null;
64
+ }
65
+ const pushedAt = payload.pushed_at;
66
+ return {
67
+ stars: Number.isFinite(payload.stargazers_count) ? payload.stargazers_count : null,
68
+ repoUpdatedAt: typeof pushedAt === 'string' && pushedAt ? pushedAt : null,
69
+ };
70
+ };
71
+
72
+ const fetchRepoMeta = async (normalizedRepo) => {
73
+ loadDiskEntries();
74
+ const cached = metaCache.get(normalizedRepo);
75
+ if (cached && Date.now() < cached.expiresAt) {
76
+ return cached.value;
77
+ }
78
+
79
+ const existing = inFlight.get(normalizedRepo);
80
+ if (existing) {
81
+ return existing;
82
+ }
83
+
84
+ const run = (async () => {
85
+ try {
86
+ const response = await fetch(`${GITHUB_API_BASE}/repos/${normalizedRepo}`, {
87
+ headers: { Accept: 'application/vnd.github+json' },
88
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
89
+ });
90
+ if (!response.ok) {
91
+ // Cache failures briefly so repeated catalog loads do not re-hit a
92
+ // rate-limited or failing API for the same repository.
93
+ metaCache.set(normalizedRepo, {
94
+ expiresAt: Date.now() + FAILURE_CACHE_TTL_MS,
95
+ value: { stars: null, repoUpdatedAt: null },
96
+ });
97
+ scheduleDiskWrite();
98
+ return null;
99
+ }
100
+
101
+ const value = parseMeta(await response.json());
102
+ if (value) {
103
+ metaCache.set(normalizedRepo, { expiresAt: Date.now() + CACHE_TTL_MS, value });
104
+ scheduleDiskWrite();
105
+ }
106
+ return value;
107
+ } catch {
108
+ metaCache.set(normalizedRepo, {
109
+ expiresAt: Date.now() + FAILURE_CACHE_TTL_MS,
110
+ value: { stars: null, repoUpdatedAt: null },
111
+ });
112
+ scheduleDiskWrite();
113
+ return null;
114
+ } finally {
115
+ inFlight.delete(normalizedRepo);
116
+ }
117
+ })();
118
+
119
+ inFlight.set(normalizedRepo, run);
120
+ return run;
121
+ };
122
+
123
+ /**
124
+ * Fetch GitHub repository metadata (stars, last push) for a list of
125
+ * `owner/repo` strings. Best-effort: failed lookups resolve to null and
126
+ * never block the catalog response.
127
+ */
128
+ export async function fetchGitHubRepoMetas(normalizedRepos) {
129
+ const unique = [...new Set(normalizedRepos.filter(Boolean))];
130
+ const entries = await Promise.all(unique.map(async (repo) => [repo, await fetchRepoMeta(repo)]));
131
+ return Object.fromEntries(entries);
132
+ }
133
+
134
+ /** For tests only: clear the in-memory repository metadata cache. */
135
+ export function clearGitHubMetaCache() {
136
+ metaCache.clear();
137
+ inFlight.clear();
138
+ diskLoaded = true;
139
+ }
@@ -0,0 +1,71 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import fs from 'fs';
3
+ import os from 'os';
4
+ import path from 'path';
5
+ import { clearGitHubMetaCache, fetchGitHubRepoMetas } from './github-meta.js';
6
+
7
+ const originalFetch = globalThis.fetch;
8
+
9
+ let tempDataDir;
10
+
11
+ beforeEach(() => {
12
+ tempDataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-meta-test-'));
13
+ process.env.OPENCHAMBER_DATA_DIR = tempDataDir;
14
+ });
15
+
16
+ afterEach(() => {
17
+ delete process.env.OPENCHAMBER_DATA_DIR;
18
+ globalThis.fetch = originalFetch;
19
+ clearGitHubMetaCache();
20
+ vi.restoreAllMocks();
21
+ fs.rmSync(tempDataDir, { recursive: true, force: true });
22
+ });
23
+
24
+ describe('fetchGitHubRepoMetas', () => {
25
+ it('returns stars and pushed_at from the GitHub API', async () => {
26
+ const fetchMock = vi.fn(async () => new Response(
27
+ JSON.stringify({ stargazers_count: 42, pushed_at: '2026-08-01T00:00:00Z' }),
28
+ { status: 200 },
29
+ ));
30
+ globalThis.fetch = fetchMock;
31
+
32
+ const metas = await fetchGitHubRepoMetas(['anthropics/skills']);
33
+
34
+ expect(metas).toEqual({
35
+ 'anthropics/skills': { stars: 42, repoUpdatedAt: '2026-08-01T00:00:00Z' },
36
+ });
37
+ expect(fetchMock).toHaveBeenCalledTimes(1);
38
+ });
39
+
40
+ it('resolves failed lookups to null without throwing', async () => {
41
+ globalThis.fetch = vi.fn(async () => new Response('rate limited', { status: 403 }));
42
+
43
+ const metas = await fetchGitHubRepoMetas(['anthropics/skills']);
44
+
45
+ expect(metas).toEqual({ 'anthropics/skills': null });
46
+ });
47
+
48
+ it('caches failed lookups briefly to avoid repeat hits', async () => {
49
+ const fetchMock = vi.fn(async () => new Response('rate limited', { status: 403 }));
50
+ globalThis.fetch = fetchMock;
51
+
52
+ await fetchGitHubRepoMetas(['anthropics/skills']);
53
+ const second = await fetchGitHubRepoMetas(['anthropics/skills']);
54
+
55
+ expect(fetchMock).toHaveBeenCalledTimes(1);
56
+ expect(second).toEqual({ 'anthropics/skills': { stars: null, repoUpdatedAt: null } });
57
+ });
58
+
59
+ it('deduplicates repositories', async () => {
60
+ const fetchMock = vi.fn(async () => new Response(
61
+ JSON.stringify({ stargazers_count: 1, pushed_at: null }),
62
+ { status: 200 },
63
+ ));
64
+ globalThis.fetch = fetchMock;
65
+
66
+ const metas = await fetchGitHubRepoMetas(['a/b', 'a/b', null]);
67
+
68
+ expect(fetchMock).toHaveBeenCalledTimes(1);
69
+ expect(metas['a/b']).toEqual({ stars: 1, repoUpdatedAt: null });
70
+ });
71
+ });
@@ -1,5 +1,4 @@
1
1
  const GITHUB_HOST = 'github.com';
2
- const CLAWDHUB_SOURCE_PREFIX = 'clawdhub:';
3
2
 
4
3
 
5
4
  function normalizeGitOwnerRepo(owner, repo) {
@@ -86,7 +85,3 @@ export function parseSkillRepoSource(input, options = {}) {
86
85
 
87
86
  return { ok: false, error: { kind: 'invalidSource', message: 'Unsupported repository source format' } };
88
87
  }
89
-
90
- export function isClawdHubSource(input) {
91
- return typeof input === 'string' && input.trim().toLowerCase().startsWith(CLAWDHUB_SOURCE_PREFIX);
92
- }