@openchamber/web 1.19.0 → 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 (153) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-DAvopJvy.js → CodeMirrorCommentWidgets-C36E738Y.js} +1 -1
  2. package/dist/assets/{CommitSection-D9cV-qR9.js → CommitSection-C-F3AX6D.js} +1 -1
  3. package/dist/assets/{DiagramEditor-B9NCadU7.js → DiagramEditor-BPECg1jS.js} +1 -1
  4. package/dist/assets/DiagramView-D0YNMix8.js +1 -0
  5. package/dist/assets/DiffView-BHWaMYCC.js +4 -0
  6. package/dist/assets/FilesView-NMBCW2Tm.js +14 -0
  7. package/dist/assets/{GitView-DsWXqWx3.js → GitView-Rp8P1KEI.js} +4 -4
  8. package/dist/assets/{JsonTreeView-h4dHASlq.js → JsonTreeView-KnXFN2A-.js} +1 -1
  9. package/dist/assets/{MarkdownImageGallery-n0ikH-xm.js → MarkdownImageGallery-BMn3mtor.js} +1 -1
  10. package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +12 -0
  11. package/dist/assets/{OnboardingScreen-CDjgzxEe.js → OnboardingScreen-CenIeD4v.js} +1 -1
  12. package/dist/assets/{PatchDiff-jPKTJje5.js → PatchDiff-BzVOVog8.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-D_Gt4A_6.js → PierreDiffViewer-Dlby4XqT.js} +2 -2
  14. package/dist/assets/PlanView-Czu1KMJa.js +4 -0
  15. package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +1 -0
  16. package/dist/assets/SettingsView-B6vmuf-c.js +28 -0
  17. package/dist/assets/SettingsWindow-CauZpdD3.js +1 -0
  18. package/dist/assets/ToolOutputDialog-BB1c--Zr.js +15 -0
  19. package/dist/assets/ToolPartDiffPreview-DaOIDISD.js +8 -0
  20. package/dist/assets/{VirtualizedFileDiff-B37yB9jZ.js → VirtualizedFileDiff-lESMT-2b.js} +4 -4
  21. package/dist/assets/{WalkthroughView-Bxun3k66.js → WalkthroughView-CaSYE0lw.js} +1 -1
  22. package/dist/assets/{computeVirtualFileMetrics-DYFv_yZS.js → computeVirtualFileMetrics-DkRR5b75.js} +2 -2
  23. package/dist/assets/{contextPanelEmbeddedChat-BO1wRpaN.js → contextPanelEmbeddedChat-BEARQjgn.js} +1 -1
  24. package/dist/assets/de-DFdX3ABv.js +9 -0
  25. package/dist/assets/es-iC-FKvV9.js +15 -0
  26. package/dist/assets/fr-BBbi_1AL.js +13 -0
  27. package/dist/assets/{index-BSvmTvZl.js → index-BiEgzzkg.js} +1 -1
  28. package/dist/assets/index-Cwmuwk3V.js +7 -0
  29. package/dist/assets/index-GNm1wgUH.css +1 -0
  30. package/dist/assets/{isDiffPlainText-DwHKxDYc.js → isDiffPlainText-BG53Ixxy.js} +1 -1
  31. package/dist/assets/{isFilePlainText-Dwq6ILxo.js → isFilePlainText-BbV-39jl.js} +1 -1
  32. package/dist/assets/ja-DQLQJL2J.js +15 -0
  33. package/dist/assets/ko-BeElEB4Y.js +15 -0
  34. package/dist/assets/main-Dpzo18z7.js +2 -0
  35. package/dist/assets/main-WMjtYzJs.js +921 -0
  36. package/dist/assets/markdownCore--tDmyI_v.js +2 -0
  37. package/dist/assets/miniChat-ldEghBLB.js +2 -0
  38. package/dist/assets/mobile-Dk-VGreF.js +2 -0
  39. package/dist/assets/{patchFileDiff-BEDPDypx.js → patchFileDiff-BcFaMtMu.js} +2 -2
  40. package/dist/assets/pl-CLHt2_vV.js +15 -0
  41. package/dist/assets/pt-BR-C_MPUq7e.js +15 -0
  42. package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +2 -0
  43. package/dist/assets/{renderMobileApp-BiMbzPq9.js → renderMobileApp-CDfHS5rr.js} +7 -7
  44. package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +15 -0
  45. package/dist/assets/{scheduledTasksApi-01zzfzqH.js → scheduledTasksApi-BFSlqgnG.js} +1 -1
  46. package/dist/assets/{shikiHighlight-DXYW46vW.js → shikiHighlight-DCT2Sq_z.js} +1 -1
  47. package/dist/assets/uk-PhsC-c4-.js +15 -0
  48. package/dist/assets/{useAppFontEffects-CbzHzFop.js → useAppFontEffects-B53Rb6m7.js} +166 -159
  49. package/dist/assets/useInlineCommentController-DSfrIBKT.js +2 -0
  50. package/dist/assets/{vendor-base-ui-BYlZTzrw.js → vendor-base-ui-DsHmyMwp.js} +1 -1
  51. package/dist/assets/{vendor-codemirror-language-data-CiAYDJXN.js → vendor-codemirror-language-data-vch3tJ4c.js} +2 -2
  52. package/dist/assets/vendor-zod-C9ioTTSo.js +39 -0
  53. package/dist/assets/{web-components-DCLjCO9n.js → web-components-pcwCTWjC.js} +4 -4
  54. package/dist/assets/zh-CN-wF-NOFHM.js +15 -0
  55. package/dist/assets/zh-TW-4m4-A7rT.js +15 -0
  56. package/dist/index.html +5 -4
  57. package/dist/mini-chat.html +4 -3
  58. package/dist/mobile.html +4 -3
  59. package/package.json +3 -5
  60. package/server/index.js +36 -0
  61. package/server/lib/agent-memory/project-resolution.js +10 -1
  62. package/server/lib/agent-memory/project-resolution.test.js +9 -0
  63. package/server/lib/agent-memory/runtime.js +7 -2
  64. package/server/lib/dictation/DOCUMENTATION.md +32 -8
  65. package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
  66. package/server/lib/dictation/local/worker-process.js +2 -2
  67. package/server/lib/dictation/openai-compatible-session.js +3 -2
  68. package/server/lib/dictation/stream-manager.js +77 -34
  69. package/server/lib/dictation/stream-manager.test.js +60 -2
  70. package/server/lib/fs/routes.test.js +76 -0
  71. package/server/lib/git/routes.js +43 -0
  72. package/server/lib/git/service.js +85 -5
  73. package/server/lib/git/service.test.js +93 -0
  74. package/server/lib/opencode/DOCUMENTATION.md +6 -2
  75. package/server/lib/opencode/feature-routes-runtime.js +5 -9
  76. package/server/lib/opencode/lifecycle.js +202 -26
  77. package/server/lib/opencode/lifecycle.test.js +179 -1
  78. package/server/lib/opencode/providers.js +9 -4
  79. package/server/lib/opencode/providers.test.js +27 -0
  80. package/server/lib/opencode/restart-session-recovery.test.js +59 -0
  81. package/server/lib/opencode/session-runtime.js +39 -2
  82. package/server/lib/opencode/session-runtime.test.js +74 -0
  83. package/server/lib/opencode/settings-helpers.js +15 -0
  84. package/server/lib/opencode/settings-helpers.test.js +22 -0
  85. package/server/lib/opencode/settings-normalization-runtime.js +3 -0
  86. package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
  87. package/server/lib/opencode/settings-runtime.js +32 -10
  88. package/server/lib/opencode/settings-runtime.test.js +85 -0
  89. package/server/lib/opencode/skill-routes.js +29 -73
  90. package/server/lib/opencode/skill-routes.test.js +2 -5
  91. package/server/lib/project-context/DOCUMENTATION.md +2 -0
  92. package/server/lib/project-context/runtime.js +7 -2
  93. package/server/lib/projects/project-config.js +7 -2
  94. package/server/lib/quota/DOCUMENTATION.md +1 -1
  95. package/server/lib/quota/providers/claude/index.js +2 -2
  96. package/server/lib/quota/providers/command-code.js +1 -1
  97. package/server/lib/quota/providers/command-code.test.js +13 -0
  98. package/server/lib/quota/providers/index.js +12 -4
  99. package/server/lib/quota/providers/zai.js +26 -6
  100. package/server/lib/quota/providers/zai.test.js +33 -0
  101. package/server/lib/session-knowledge/DOCUMENTATION.md +2 -0
  102. package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
  103. package/server/lib/skills-catalog/cache.js +120 -1
  104. package/server/lib/skills-catalog/cache.test.js +77 -0
  105. package/server/lib/skills-catalog/curated-sources.js +21 -5
  106. package/server/lib/skills-catalog/curated-sources.test.js +4 -4
  107. package/server/lib/skills-catalog/disk-cache.js +52 -0
  108. package/server/lib/skills-catalog/github-meta.js +139 -0
  109. package/server/lib/skills-catalog/github-meta.test.js +71 -0
  110. package/server/lib/skills-catalog/source.js +0 -5
  111. package/server/lib/small-model/DOCUMENTATION.md +74 -6
  112. package/server/lib/small-model/call.js +46 -12
  113. package/server/lib/small-model/call.test.js +79 -0
  114. package/server/lib/small-model/index.js +51 -8
  115. package/server/lib/small-model/index.test.js +73 -3
  116. package/server/lib/small-model/routes.js +1 -1
  117. package/server/lib/small-model/runtime-providers.js +156 -0
  118. package/server/lib/small-model/runtime-providers.test.js +112 -0
  119. package/dist/assets/DiagramView-LKGBwf4G.js +0 -1
  120. package/dist/assets/DiffView-BWNq-0ov.js +0 -4
  121. package/dist/assets/FilesView-DB-Q0Gkz.js +0 -14
  122. package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +0 -12
  123. package/dist/assets/PlanView-UvuxIl9-.js +0 -4
  124. package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +0 -1
  125. package/dist/assets/SettingsView-3B9VN6Ys.js +0 -28
  126. package/dist/assets/SettingsWindow-CqQNDKNd.js +0 -1
  127. package/dist/assets/ToolOutputDialog-PmjlAxVE.js +0 -15
  128. package/dist/assets/ToolPartDiffPreview-B34Xw9wq.js +0 -8
  129. package/dist/assets/de-DbV6CLxv.js +0 -9
  130. package/dist/assets/es-CVDlyzZ4.js +0 -15
  131. package/dist/assets/fr-Czc-p0g-.js +0 -13
  132. package/dist/assets/index-1OhiMDBz.css +0 -1
  133. package/dist/assets/index-DzriVon2.js +0 -7
  134. package/dist/assets/ja-dwc9NM_S.js +0 -15
  135. package/dist/assets/ko-Ds1DZ8FX.js +0 -15
  136. package/dist/assets/main-BF51IOVF.js +0 -921
  137. package/dist/assets/main-D7UPARut.js +0 -2
  138. package/dist/assets/markdownCore-BgeBDwD3.js +0 -2
  139. package/dist/assets/miniChat-BISXSGOo.js +0 -2
  140. package/dist/assets/mobile-BnYxVuvw.js +0 -2
  141. package/dist/assets/pl-CLiTO7i-.js +0 -15
  142. package/dist/assets/pt-BR-GIimJgpK.js +0 -15
  143. package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +0 -2
  144. package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +0 -15
  145. package/dist/assets/uk-DLfgD1ki.js +0 -15
  146. package/dist/assets/useInlineCommentController-CegKdDXi.js +0 -2
  147. package/dist/assets/vendor-zod-adaMkgkm.js +0 -39
  148. package/dist/assets/zh-CN-DkeP5awK.js +0 -15
  149. package/dist/assets/zh-TW-BocaFm3d.js +0 -15
  150. package/server/lib/skills-catalog/clawdhub/api.js +0 -126
  151. package/server/lib/skills-catalog/clawdhub/install.js +0 -238
  152. package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
  153. package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
@@ -69,14 +69,11 @@ const startSkillsApp = ({ projectRoot }) => {
69
69
  SKILL_DIR,
70
70
  getCuratedSkillsSources: () => [],
71
71
  getCacheKey: () => 'k',
72
- getCachedScan: () => null,
73
- setCachedScan: () => {},
72
+ scanWithCache: async (_key, loader) => loader(),
74
73
  parseSkillRepoSource: () => ({ ok: false }),
75
74
  scanSkillsRepository: async () => ({ ok: false }),
76
75
  installSkillsFromRepository: async () => ({ ok: false }),
77
- scanClawdHubPage: async () => ({ ok: false }),
78
- installSkillsFromClawdHub: async () => ({ ok: false }),
79
- isClawdHubSource: () => false,
76
+ fetchGitHubRepoMetas: async () => ({}),
80
77
  getProfiles: () => [],
81
78
  getProfile: () => null,
82
79
  });
@@ -3,6 +3,8 @@
3
3
  Server-owned storage for the Project Notes surface: free-form notes, todos, and
4
4
  plan markdown files.
5
5
 
6
+ The managed Chats root (`~/.config/openchamber/chats`) is also one context owner. Every dated per-session directory beneath it resolves to that root, so Notes, Todo, Plans, pinned knowledge, and project memory are shared across ordinary chats without registering Chats as a user project.
7
+
6
8
  ## Ownership
7
9
 
8
10
  | Path | Owner | Contents |
@@ -231,8 +231,13 @@ export const createProjectContextRuntime = (deps) => {
231
231
  const writeJsonAtomic = async (filePath, value) => {
232
232
  const temporaryPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
233
233
  await fsPromises.mkdir(path.dirname(filePath), { recursive: true });
234
- await fsPromises.writeFile(temporaryPath, JSON.stringify(value, null, 2), 'utf8');
235
- await fsPromises.rename(temporaryPath, filePath);
234
+ try {
235
+ await fsPromises.writeFile(temporaryPath, JSON.stringify(value, null, 2), 'utf8');
236
+ await fsPromises.rename(temporaryPath, filePath);
237
+ } catch (error) {
238
+ await fsPromises.rm(temporaryPath, { force: true }).catch(() => {});
239
+ throw error;
240
+ }
236
241
  };
237
242
 
238
243
  const withWriteLock = async (projectId, mutate) => {
@@ -536,8 +536,13 @@ export const createProjectConfigRuntime = (deps) => {
536
536
  };
537
537
 
538
538
  await fsPromises.mkdir(parentDirectory, { recursive: true });
539
- await fsPromises.writeFile(temporaryPath, JSON.stringify(merged, null, 2), 'utf8');
540
- await fsPromises.rename(temporaryPath, filePath);
539
+ try {
540
+ await fsPromises.writeFile(temporaryPath, JSON.stringify(merged, null, 2), 'utf8');
541
+ await fsPromises.rename(temporaryPath, filePath);
542
+ } catch (error) {
543
+ await fsPromises.rm(temporaryPath, { force: true }).catch(() => {});
544
+ throw error;
545
+ }
541
546
  };
542
547
 
543
548
  const withProjectWriteLock = async (projectID, mutate) => {
@@ -101,4 +101,4 @@ The provider computes `usedPercent` from whichever of `used`/`remaining` is pres
101
101
  - Keep provider IDs stable; clients use them directly.
102
102
  - Avoid adding alias-based dispatch in `fetchQuotaForProvider`; dispatch currently expects exact provider IDs.
103
103
  - Keep Google behavior changes isolated and review `providers/google/*` together.
104
- - Z.ai Coding Plan exposes separate 5-hour and weekly `TOKENS_LIMIT` entries plus a monthly `TIME_LIMIT` for MCP tools; web and VS Code must preserve all three windows.
104
+ - Z.ai Coding Plan exposes separate 5-hour and weekly token/credit limit entries plus a monthly `TIME_LIMIT` for MCP tools. The API renamed the limit type from `TOKENS_LIMIT` to `CREDIT_LIMIT` (same `unit`/`number` window semantics); `CREDIT_LIMIT` entries additionally carry `usage` (total), `currentValue` (consumed), and `remaining`, surfaced as a credit `valueLabel`, and the payload's `data.level` becomes `planLabel`. Web and VS Code must preserve these windows and stay in sync.
@@ -81,7 +81,7 @@ const fetchQuotaUncoalesced = async () => {
81
81
 
82
82
  if (Date.now() < cooldownUntil) {
83
83
  return cachedResultFor(fingerprint, credential.planLabel)
84
- ?? failure('Rate limited by Anthropic. Retrying shortly.');
84
+ ?? failure('Rate limited. Retrying soon.');
85
85
  }
86
86
 
87
87
  let response;
@@ -100,7 +100,7 @@ const fetchQuotaUncoalesced = async () => {
100
100
  if (response.status === 429) {
101
101
  cooldownUntil = Date.now() + cooldownFromHeader(response);
102
102
  return cachedResultFor(fingerprint, credential.planLabel)
103
- ?? failure('Rate limited by Anthropic. Retrying shortly.');
103
+ ?? failure('Rate limited. Retrying soon.');
104
104
  }
105
105
 
106
106
  if (response.status === 401 || response.status === 403) {
@@ -3,7 +3,7 @@ import { asObject, buildResult, getAuthEntry, normalizeAuthEntry, toNumber, toUs
3
3
 
4
4
  export const providerId = 'command-code';
5
5
  export const providerName = 'Command Code';
6
- export const aliases = ['command-code'];
6
+ export const aliases = ['command-code', 'commandcode', 'command_code', 'command code'];
7
7
 
8
8
  const API_BASE_URL = 'https://api.commandcode.ai';
9
9
 
@@ -69,4 +69,17 @@ describe('Command Code quota provider', () => {
69
69
  expect(fetchMock.mock.calls[0][1].headers.Authorization).toBe('Bearer test-token');
70
70
  vi.unstubAllGlobals();
71
71
  });
72
+
73
+ it('recognizes Command Code auth entries under supported provider ID variants', async () => {
74
+ for (const providerId of ['commandcode', 'command_code', 'command code']) {
75
+ const fetchMock = vi.fn()
76
+ .mockResolvedValueOnce(new Response(JSON.stringify({ org: { id: 'org-1' } })))
77
+ .mockResolvedValueOnce(new Response(JSON.stringify(creditsPayload)));
78
+ vi.stubGlobal('fetch', fetchMock);
79
+
80
+ const result = await fetchQuota({ [providerId]: { type: 'oauth', access: 'test-token' } });
81
+ expect(result).toMatchObject({ providerId: 'command-code', ok: true, configured: true });
82
+ vi.unstubAllGlobals();
83
+ }
84
+ });
72
85
  });
@@ -160,6 +160,13 @@ const registry = {
160
160
 
161
161
  const pendingFetches = new Map();
162
162
 
163
+ const normalizeQuotaProviderId = (providerId) => {
164
+ if (typeof providerId !== 'string') return providerId;
165
+ return ['command-code', 'commandcode', 'command_code', 'command code'].includes(providerId.trim().toLowerCase())
166
+ ? 'command-code'
167
+ : providerId;
168
+ };
169
+
163
170
  export const listConfiguredQuotaProviders = () => {
164
171
  const configured = [];
165
172
 
@@ -203,13 +210,14 @@ const fetchQuotaForProviderUncoalesced = async (providerId) => {
203
210
  };
204
211
 
205
212
  export const fetchQuotaForProvider = (providerId) => {
206
- const existing = pendingFetches.get(providerId);
213
+ const normalizedProviderId = normalizeQuotaProviderId(providerId);
214
+ const existing = pendingFetches.get(normalizedProviderId);
207
215
  if (existing) return existing;
208
216
 
209
- const pending = fetchQuotaForProviderUncoalesced(providerId).finally(() => {
210
- if (pendingFetches.get(providerId) === pending) pendingFetches.delete(providerId);
217
+ const pending = fetchQuotaForProviderUncoalesced(normalizedProviderId).finally(() => {
218
+ if (pendingFetches.get(normalizedProviderId) === pending) pendingFetches.delete(normalizedProviderId);
211
219
  });
212
- pendingFetches.set(providerId, pending);
220
+ pendingFetches.set(normalizedProviderId, pending);
213
221
  return pending;
214
222
  };
215
223
 
@@ -4,6 +4,7 @@ import {
4
4
  normalizeAuthEntry,
5
5
  buildResult,
6
6
  toUsageWindow,
7
+ toNumber,
7
8
  resolveWindowSeconds,
8
9
  resolveWindowLabel,
9
10
  normalizeTimestamp
@@ -13,6 +14,20 @@ export const providerId = 'zai-coding-plan';
13
14
  export const providerName = 'z.ai';
14
15
  const aliases = ['zai-coding-plan', 'zai', 'z.ai'];
15
16
 
17
+ // CREDIT_LIMIT entries carry `usage` (total credits), `currentValue` (consumed),
18
+ // and `remaining`; TOKENS_LIMIT entries only carry a percentage.
19
+ const formatCreditAmount = (value) => {
20
+ if (value < 1000) return value.toLocaleString('en-US');
21
+ return `${Math.round(value / 100) / 10}k`;
22
+ };
23
+
24
+ const formatCreditValueLabel = (limit) => {
25
+ const used = toNumber(limit?.currentValue);
26
+ const total = toNumber(limit?.usage);
27
+ if (used === null || total === null) return null;
28
+ return `${formatCreditAmount(used)} / ${formatCreditAmount(total)} credits`;
29
+ };
30
+
16
31
  export const isConfigured = () => {
17
32
  const auth = readAuthFile();
18
33
  const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
@@ -56,16 +71,20 @@ export const fetchQuota = async () => {
56
71
  const payload = await response.json();
57
72
  const limits = Array.isArray(payload?.data?.limits) ? payload.data.limits : [];
58
73
  const windows = {};
59
- for (const tokensLimit of limits.filter((limit) => limit?.type === 'TOKENS_LIMIT')) {
60
- const windowSeconds = resolveWindowSeconds(tokensLimit);
74
+ // The API renamed TOKENS_LIMIT to CREDIT_LIMIT; field semantics stayed the same,
75
+ // so both limit types map to the same windows.
76
+ for (const limit of limits.filter((entry) => entry?.type === 'TOKENS_LIMIT' || entry?.type === 'CREDIT_LIMIT')) {
77
+ const windowSeconds = resolveWindowSeconds(limit);
61
78
  const windowLabel = resolveWindowLabel(windowSeconds);
62
- const resetAt = tokensLimit?.nextResetTime ? normalizeTimestamp(tokensLimit.nextResetTime) : null;
63
- const usedPercent = typeof tokensLimit?.percentage === 'number' ? tokensLimit.percentage : null;
79
+ const resetAt = limit?.nextResetTime ? normalizeTimestamp(limit.nextResetTime) : null;
80
+ const usedPercent = typeof limit?.percentage === 'number' ? limit.percentage : null;
81
+ const creditValueLabel = formatCreditValueLabel(limit);
64
82
 
65
83
  windows[windowLabel] = toUsageWindow({
66
84
  usedPercent,
67
85
  windowSeconds,
68
- resetAt
86
+ resetAt,
87
+ valueLabel: creditValueLabel
69
88
  });
70
89
  }
71
90
 
@@ -83,7 +102,8 @@ export const fetchQuota = async () => {
83
102
  providerName,
84
103
  ok: true,
85
104
  configured: true,
86
- usage: { windows }
105
+ usage: { windows },
106
+ planLabel: typeof payload?.data?.level === 'string' && payload.data.level ? payload.data.level : null
87
107
  });
88
108
  } catch (error) {
89
109
  return buildResult({
@@ -51,4 +51,37 @@ describe('Z.ai quota provider', () => {
51
51
  resetAt: 1787128459979,
52
52
  });
53
53
  });
54
+
55
+ it('maps CREDIT_LIMIT entries to windows with credit value labels and plan level', async () => {
56
+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(mockResponse({
57
+ code: 200,
58
+ data: {
59
+ limits: [
60
+ { type: 'CREDIT_LIMIT', unit: 3, number: 5, usage: 12000, currentValue: 65, remaining: 11934, percentage: 1, nextResetTime: 1787257978907 },
61
+ { type: 'CREDIT_LIMIT', unit: 6, number: 1, usage: 60000, currentValue: 65, remaining: 59934, percentage: 1, nextResetTime: 1787844668997 },
62
+ ],
63
+ level: 'pro',
64
+ },
65
+ })));
66
+
67
+ const result = await fetchQuota();
68
+ const windows = result.usage.windows;
69
+
70
+ expect(result.ok).toBe(true);
71
+ expect(result.planLabel).toBe('pro');
72
+ expect(windows['5h']).toMatchObject({
73
+ usedPercent: 1,
74
+ remainingPercent: 99,
75
+ windowSeconds: 5 * 60 * 60,
76
+ resetAt: 1787257978907,
77
+ valueLabel: '65 / 12k credits',
78
+ });
79
+ expect(windows.weekly).toMatchObject({
80
+ usedPercent: 1,
81
+ remainingPercent: 99,
82
+ windowSeconds: 7 * 24 * 60 * 60,
83
+ resetAt: 1787844668997,
84
+ valueLabel: '65 / 60k credits',
85
+ });
86
+ });
54
87
  });
@@ -24,6 +24,8 @@ attached to that session. Pins never come from project-wide note or plan state.
24
24
  A new-session draft passes its pins into this metadata when its first message
25
25
  creates the session.
26
26
 
27
+ Directories beneath the managed `~/.config/openchamber/chats` root resolve to that root before project context and project memory are read. Every ordinary chat therefore shares one Chats knowledge owner instead of creating an unreachable context store for each dated session directory.
28
+
27
29
  `session.metadata.openchamber.knowledge_context_delivered` holds the signature
28
30
  of what the session is carrying. It lives with the session, so it survives the
29
31
  tab closing and is visible to every sender, including the ones with no tab.
@@ -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 ClawHub 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, ClawHub).
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/`: ClawHub registry integration.
15
- - `index.js`: Public API exports for ClawHub.
16
- - `scan.js`: Scanning ClawHub registry with pagination.
17
- - `install.js`: Installation from ClawHub (ZIP download).
18
- - `api.js`: ClawHub 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, ClawHub).
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
- ### ClawHub Integration (`clawdhub/index.js`)
44
- - `isClawdHubSource(source)`: Check if source string refers to ClawHub.
45
- - `scanClawdHub()`: Scan entire ClawHub registry for all skills (paginated, max 20 pages).
46
- - `scanClawdHubPage({ cursor })`: Scan a single page of ClawHub results with cursor-based pagination.
47
- - `installSkillsFromClawdHub({ scope, targetSource, workingDirectory, userSkillDir, selections, conflictPolicy, conflictDecisions })`: Install skills from ClawHub by downloading ZIP files.
48
- - `fetchClawdHubSkills({ cursor })`: Fetch paginated skills list from ClawHub 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
- ### ClawHub 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
- ### ClawHub 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 ClawHub 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
- ### ClawHub Scan Response
105
- - `ok`: Boolean indicating success.
106
- - `items`: Array of skill items with ClawHub-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 ClawHub.
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
- ### ClawHub Integration
148
- - ClawHub 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: 'ClawHub',
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
 
@@ -2,9 +2,9 @@ import { describe, expect, it } from 'vitest';
2
2
  import { getCuratedSkillsSources } from './curated-sources.js';
3
3
 
4
4
  describe('getCuratedSkillsSources', () => {
5
- it('labels the ClawHub curated source as ClawHub', () => {
6
- const clawhub = getCuratedSkillsSources().find((source) => source.id === 'clawdhub');
7
- expect(clawhub).toBeDefined();
8
- expect(clawhub.label).toBe('ClawHub');
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
9
  });
10
10
  });