@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.
- package/dist/assets/{CodeMirrorCommentWidgets-DAvopJvy.js → CodeMirrorCommentWidgets-C36E738Y.js} +1 -1
- package/dist/assets/{CommitSection-D9cV-qR9.js → CommitSection-C-F3AX6D.js} +1 -1
- package/dist/assets/{DiagramEditor-B9NCadU7.js → DiagramEditor-BPECg1jS.js} +1 -1
- package/dist/assets/DiagramView-D0YNMix8.js +1 -0
- package/dist/assets/DiffView-BHWaMYCC.js +4 -0
- package/dist/assets/FilesView-NMBCW2Tm.js +14 -0
- package/dist/assets/{GitView-DsWXqWx3.js → GitView-Rp8P1KEI.js} +4 -4
- package/dist/assets/{JsonTreeView-h4dHASlq.js → JsonTreeView-KnXFN2A-.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-n0ikH-xm.js → MarkdownImageGallery-BMn3mtor.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +12 -0
- package/dist/assets/{OnboardingScreen-CDjgzxEe.js → OnboardingScreen-CenIeD4v.js} +1 -1
- package/dist/assets/{PatchDiff-jPKTJje5.js → PatchDiff-BzVOVog8.js} +1 -1
- package/dist/assets/{PierreDiffViewer-D_Gt4A_6.js → PierreDiffViewer-Dlby4XqT.js} +2 -2
- package/dist/assets/PlanView-Czu1KMJa.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +1 -0
- package/dist/assets/SettingsView-B6vmuf-c.js +28 -0
- package/dist/assets/SettingsWindow-CauZpdD3.js +1 -0
- package/dist/assets/ToolOutputDialog-BB1c--Zr.js +15 -0
- package/dist/assets/ToolPartDiffPreview-DaOIDISD.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-B37yB9jZ.js → VirtualizedFileDiff-lESMT-2b.js} +4 -4
- package/dist/assets/{WalkthroughView-Bxun3k66.js → WalkthroughView-CaSYE0lw.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DYFv_yZS.js → computeVirtualFileMetrics-DkRR5b75.js} +2 -2
- package/dist/assets/{contextPanelEmbeddedChat-BO1wRpaN.js → contextPanelEmbeddedChat-BEARQjgn.js} +1 -1
- package/dist/assets/de-DFdX3ABv.js +9 -0
- package/dist/assets/es-iC-FKvV9.js +15 -0
- package/dist/assets/fr-BBbi_1AL.js +13 -0
- package/dist/assets/{index-BSvmTvZl.js → index-BiEgzzkg.js} +1 -1
- package/dist/assets/index-Cwmuwk3V.js +7 -0
- package/dist/assets/index-GNm1wgUH.css +1 -0
- package/dist/assets/{isDiffPlainText-DwHKxDYc.js → isDiffPlainText-BG53Ixxy.js} +1 -1
- package/dist/assets/{isFilePlainText-Dwq6ILxo.js → isFilePlainText-BbV-39jl.js} +1 -1
- package/dist/assets/ja-DQLQJL2J.js +15 -0
- package/dist/assets/ko-BeElEB4Y.js +15 -0
- package/dist/assets/main-Dpzo18z7.js +2 -0
- package/dist/assets/main-WMjtYzJs.js +921 -0
- package/dist/assets/markdownCore--tDmyI_v.js +2 -0
- package/dist/assets/miniChat-ldEghBLB.js +2 -0
- package/dist/assets/mobile-Dk-VGreF.js +2 -0
- package/dist/assets/{patchFileDiff-BEDPDypx.js → patchFileDiff-BcFaMtMu.js} +2 -2
- package/dist/assets/pl-CLHt2_vV.js +15 -0
- package/dist/assets/pt-BR-C_MPUq7e.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +2 -0
- package/dist/assets/{renderMobileApp-BiMbzPq9.js → renderMobileApp-CDfHS5rr.js} +7 -7
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +15 -0
- package/dist/assets/{scheduledTasksApi-01zzfzqH.js → scheduledTasksApi-BFSlqgnG.js} +1 -1
- package/dist/assets/{shikiHighlight-DXYW46vW.js → shikiHighlight-DCT2Sq_z.js} +1 -1
- package/dist/assets/uk-PhsC-c4-.js +15 -0
- package/dist/assets/{useAppFontEffects-CbzHzFop.js → useAppFontEffects-B53Rb6m7.js} +166 -159
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +2 -0
- package/dist/assets/{vendor-base-ui-BYlZTzrw.js → vendor-base-ui-DsHmyMwp.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CiAYDJXN.js → vendor-codemirror-language-data-vch3tJ4c.js} +2 -2
- package/dist/assets/vendor-zod-C9ioTTSo.js +39 -0
- package/dist/assets/{web-components-DCLjCO9n.js → web-components-pcwCTWjC.js} +4 -4
- package/dist/assets/zh-CN-wF-NOFHM.js +15 -0
- package/dist/assets/zh-TW-4m4-A7rT.js +15 -0
- package/dist/index.html +5 -4
- package/dist/mini-chat.html +4 -3
- package/dist/mobile.html +4 -3
- package/package.json +3 -5
- package/server/index.js +36 -0
- package/server/lib/agent-memory/project-resolution.js +10 -1
- package/server/lib/agent-memory/project-resolution.test.js +9 -0
- package/server/lib/agent-memory/runtime.js +7 -2
- package/server/lib/dictation/DOCUMENTATION.md +32 -8
- package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/dictation/openai-compatible-session.js +3 -2
- package/server/lib/dictation/stream-manager.js +77 -34
- package/server/lib/dictation/stream-manager.test.js +60 -2
- package/server/lib/fs/routes.test.js +76 -0
- package/server/lib/git/routes.js +43 -0
- package/server/lib/git/service.js +85 -5
- package/server/lib/git/service.test.js +93 -0
- package/server/lib/opencode/DOCUMENTATION.md +6 -2
- package/server/lib/opencode/feature-routes-runtime.js +5 -9
- package/server/lib/opencode/lifecycle.js +202 -26
- package/server/lib/opencode/lifecycle.test.js +179 -1
- package/server/lib/opencode/providers.js +9 -4
- package/server/lib/opencode/providers.test.js +27 -0
- package/server/lib/opencode/restart-session-recovery.test.js +59 -0
- package/server/lib/opencode/session-runtime.js +39 -2
- package/server/lib/opencode/session-runtime.test.js +74 -0
- package/server/lib/opencode/settings-helpers.js +15 -0
- package/server/lib/opencode/settings-helpers.test.js +22 -0
- package/server/lib/opencode/settings-normalization-runtime.js +3 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
- package/server/lib/opencode/settings-runtime.js +32 -10
- package/server/lib/opencode/settings-runtime.test.js +85 -0
- package/server/lib/opencode/skill-routes.js +29 -73
- package/server/lib/opencode/skill-routes.test.js +2 -5
- package/server/lib/project-context/DOCUMENTATION.md +2 -0
- package/server/lib/project-context/runtime.js +7 -2
- package/server/lib/projects/project-config.js +7 -2
- package/server/lib/quota/DOCUMENTATION.md +1 -1
- package/server/lib/quota/providers/claude/index.js +2 -2
- package/server/lib/quota/providers/command-code.js +1 -1
- package/server/lib/quota/providers/command-code.test.js +13 -0
- package/server/lib/quota/providers/index.js +12 -4
- package/server/lib/quota/providers/zai.js +26 -6
- package/server/lib/quota/providers/zai.test.js +33 -0
- package/server/lib/session-knowledge/DOCUMENTATION.md +2 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
- package/server/lib/skills-catalog/cache.js +120 -1
- package/server/lib/skills-catalog/cache.test.js +77 -0
- package/server/lib/skills-catalog/curated-sources.js +21 -5
- package/server/lib/skills-catalog/curated-sources.test.js +4 -4
- package/server/lib/skills-catalog/disk-cache.js +52 -0
- package/server/lib/skills-catalog/github-meta.js +139 -0
- package/server/lib/skills-catalog/github-meta.test.js +71 -0
- package/server/lib/skills-catalog/source.js +0 -5
- package/server/lib/small-model/DOCUMENTATION.md +74 -6
- package/server/lib/small-model/call.js +46 -12
- package/server/lib/small-model/call.test.js +79 -0
- package/server/lib/small-model/index.js +51 -8
- package/server/lib/small-model/index.test.js +73 -3
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/small-model/runtime-providers.js +156 -0
- package/server/lib/small-model/runtime-providers.test.js +112 -0
- package/dist/assets/DiagramView-LKGBwf4G.js +0 -1
- package/dist/assets/DiffView-BWNq-0ov.js +0 -4
- package/dist/assets/FilesView-DB-Q0Gkz.js +0 -14
- package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +0 -12
- package/dist/assets/PlanView-UvuxIl9-.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +0 -1
- package/dist/assets/SettingsView-3B9VN6Ys.js +0 -28
- package/dist/assets/SettingsWindow-CqQNDKNd.js +0 -1
- package/dist/assets/ToolOutputDialog-PmjlAxVE.js +0 -15
- package/dist/assets/ToolPartDiffPreview-B34Xw9wq.js +0 -8
- package/dist/assets/de-DbV6CLxv.js +0 -9
- package/dist/assets/es-CVDlyzZ4.js +0 -15
- package/dist/assets/fr-Czc-p0g-.js +0 -13
- package/dist/assets/index-1OhiMDBz.css +0 -1
- package/dist/assets/index-DzriVon2.js +0 -7
- package/dist/assets/ja-dwc9NM_S.js +0 -15
- package/dist/assets/ko-Ds1DZ8FX.js +0 -15
- package/dist/assets/main-BF51IOVF.js +0 -921
- package/dist/assets/main-D7UPARut.js +0 -2
- package/dist/assets/markdownCore-BgeBDwD3.js +0 -2
- package/dist/assets/miniChat-BISXSGOo.js +0 -2
- package/dist/assets/mobile-BnYxVuvw.js +0 -2
- package/dist/assets/pl-CLiTO7i-.js +0 -15
- package/dist/assets/pt-BR-GIimJgpK.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +0 -2
- package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +0 -15
- package/dist/assets/uk-DLfgD1ki.js +0 -15
- package/dist/assets/useInlineCommentController-CegKdDXi.js +0 -2
- package/dist/assets/vendor-zod-adaMkgkm.js +0 -39
- package/dist/assets/zh-CN-DkeP5awK.js +0 -15
- package/dist/assets/zh-TW-BocaFm3d.js +0 -15
- package/server/lib/skills-catalog/clawdhub/api.js +0 -126
- package/server/lib/skills-catalog/clawdhub/install.js +0 -238
- package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
- package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
|
@@ -71,6 +71,33 @@ describe('custom provider config persistence', () => {
|
|
|
71
71
|
}).ok).toBe(true);
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
+
test('accepts the OpenCode Responses and Anthropic adapter packages', () => {
|
|
75
|
+
for (const npm of ['@ai-sdk/openai', '@ai-sdk/anthropic']) {
|
|
76
|
+
const result = validateCustomProviderConfig('ok', {
|
|
77
|
+
name: 'X',
|
|
78
|
+
npm,
|
|
79
|
+
env: ['MY_KEY'],
|
|
80
|
+
options: { baseURL: 'https://api.example.com/v1' },
|
|
81
|
+
models: { m: { name: 'M' } },
|
|
82
|
+
});
|
|
83
|
+
expect(result.ok).toBe(true);
|
|
84
|
+
expect(result.value.config.npm).toBe(npm);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('rejects unsupported adapter packages', () => {
|
|
89
|
+
const result = validateCustomProviderConfig('ok', {
|
|
90
|
+
name: 'X',
|
|
91
|
+
npm: '@example/unsupported',
|
|
92
|
+
env: ['MY_KEY'],
|
|
93
|
+
options: { baseURL: 'https://api.example.com/v1' },
|
|
94
|
+
models: { m: { name: 'M' } },
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
expect(result.ok).toBe(false);
|
|
98
|
+
expect(result.error).toContain('@ai-sdk/openai');
|
|
99
|
+
});
|
|
100
|
+
|
|
74
101
|
test('upsertProviderConfig writes and round-trips project config', () => {
|
|
75
102
|
const result = upsertProviderConfig('campus-llm', {
|
|
76
103
|
name: 'Campus LLM',
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { createSessionRuntime } from './session-runtime.js';
|
|
4
|
+
|
|
5
|
+
describe('managed OpenCode restart session recovery', () => {
|
|
6
|
+
it('settles busy sessions and broadcasts one interruption notification', () => {
|
|
7
|
+
const events = [];
|
|
8
|
+
const broadcastUiNotification = vi.fn();
|
|
9
|
+
const rebindUpstream = vi.fn();
|
|
10
|
+
const sessionRuntime = createSessionRuntime({
|
|
11
|
+
writeSseEvent() {},
|
|
12
|
+
getNotificationClients: () => new Set(),
|
|
13
|
+
broadcastEvent: (event) => events.push(event),
|
|
14
|
+
});
|
|
15
|
+
const onOpenCodeRestarted = () => {
|
|
16
|
+
rebindUpstream();
|
|
17
|
+
const { sessionIds } = sessionRuntime.interruptBusySessionsAfterRestart();
|
|
18
|
+
if (sessionIds.length > 0) {
|
|
19
|
+
const multiple = sessionIds.length > 1;
|
|
20
|
+
broadcastUiNotification({
|
|
21
|
+
title: multiple ? 'Chats interrupted' : 'Chat interrupted',
|
|
22
|
+
body: multiple
|
|
23
|
+
? 'OpenCode restarted during running responses. Send a message in each chat to continue.'
|
|
24
|
+
: 'OpenCode restarted during a running response. Send a message to continue.',
|
|
25
|
+
tag: 'opencode-restart-interrupted',
|
|
26
|
+
kind: 'opencode-restart-interrupted',
|
|
27
|
+
sessionId: sessionIds[0],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const markBusy = (sessionID) => sessionRuntime.processOpenCodeSsePayload({
|
|
32
|
+
type: 'session.status',
|
|
33
|
+
properties: { sessionID, status: { type: 'busy' } },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
markBusy('session-1');
|
|
38
|
+
markBusy('session-2');
|
|
39
|
+
markBusy('session-3');
|
|
40
|
+
events.length = 0;
|
|
41
|
+
|
|
42
|
+
onOpenCodeRestarted();
|
|
43
|
+
|
|
44
|
+
expect(rebindUpstream).toHaveBeenCalledOnce();
|
|
45
|
+
expect(sessionRuntime.getActiveSessionCount()).toBe(0);
|
|
46
|
+
expect(Object.values(sessionRuntime.getSessionStateSnapshot()).map((state) => state.status))
|
|
47
|
+
.toEqual(['idle', 'idle', 'idle']);
|
|
48
|
+
expect(events.filter((event) => event.type === 'openchamber:session-status')).toHaveLength(3);
|
|
49
|
+
expect(events.filter((event) => event.type === 'session.error')).toHaveLength(3);
|
|
50
|
+
expect(broadcastUiNotification).toHaveBeenCalledOnce();
|
|
51
|
+
expect(broadcastUiNotification).toHaveBeenCalledWith(expect.objectContaining({
|
|
52
|
+
kind: 'opencode-restart-interrupted',
|
|
53
|
+
sessionId: 'session-1',
|
|
54
|
+
}));
|
|
55
|
+
} finally {
|
|
56
|
+
sessionRuntime.dispose();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -130,7 +130,8 @@ export const createSessionRuntime = ({ writeSseEvent, getNotificationClients, br
|
|
|
130
130
|
const now = Date.now();
|
|
131
131
|
const existing = sessionStates.get(sessionId);
|
|
132
132
|
const existingAttentionState = sessionAttentionStates.get(sessionId);
|
|
133
|
-
|
|
133
|
+
const isRestartInterruption = metadata.reason === 'opencode-restart';
|
|
134
|
+
if (existing && existing.lastUpdateAt > now - 5000 && status === existing.status && !isRestartInterruption) {
|
|
134
135
|
return;
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -145,7 +146,7 @@ export const createSessionRuntime = ({ writeSseEvent, getNotificationClients, br
|
|
|
145
146
|
const attentionState = sessionAttentionStates.get(sessionId);
|
|
146
147
|
const attentionChanged = !!attentionState && existingAttentionState?.needsAttention !== attentionState.needsAttention;
|
|
147
148
|
const clients = getNotificationClients();
|
|
148
|
-
if (!existing || existing.status !== status || attentionChanged) {
|
|
149
|
+
if (!existing || existing.status !== status || attentionChanged || isRestartInterruption) {
|
|
149
150
|
const state = sessionStates.get(sessionId);
|
|
150
151
|
const syntheticPayload = {
|
|
151
152
|
type: 'openchamber:session-status',
|
|
@@ -293,6 +294,41 @@ export const createSessionRuntime = ({ writeSseEvent, getNotificationClients, br
|
|
|
293
294
|
}
|
|
294
295
|
};
|
|
295
296
|
|
|
297
|
+
const interruptBusySessionsAfterRestart = () => {
|
|
298
|
+
const interruptedSessionIds = new Set();
|
|
299
|
+
for (const [sessionId, state] of sessionStates) {
|
|
300
|
+
if (state.status === 'busy' || state.status === 'retry') {
|
|
301
|
+
interruptedSessionIds.add(sessionId);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
for (const [sessionId, activity] of sessionActivityPhases) {
|
|
305
|
+
if (activity.phase === 'busy') {
|
|
306
|
+
interruptedSessionIds.add(sessionId);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const eventId = `opencode-restart-${Date.now()}`;
|
|
311
|
+
for (const sessionId of interruptedSessionIds) {
|
|
312
|
+
updateSessionState(sessionId, 'idle', eventId, {
|
|
313
|
+
message: 'Interrupted by OpenCode restart',
|
|
314
|
+
reason: 'opencode-restart',
|
|
315
|
+
});
|
|
316
|
+
broadcastEvent?.({
|
|
317
|
+
type: 'session.error',
|
|
318
|
+
properties: {
|
|
319
|
+
sessionID: sessionId,
|
|
320
|
+
error: {
|
|
321
|
+
name: 'MessageAbortedError',
|
|
322
|
+
message: 'The running turn was interrupted when OpenCode restarted.',
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
resetAllSessionActivityToIdle();
|
|
329
|
+
return { sessionIds: [...interruptedSessionIds] };
|
|
330
|
+
};
|
|
331
|
+
|
|
296
332
|
const cleanupOldSessionStates = () => {
|
|
297
333
|
const now = Date.now();
|
|
298
334
|
for (const [sessionId, data] of sessionStates) {
|
|
@@ -358,6 +394,7 @@ export const createSessionRuntime = ({ writeSseEvent, getNotificationClients, br
|
|
|
358
394
|
markSessionUnviewed,
|
|
359
395
|
markUserMessageSent,
|
|
360
396
|
resetAllSessionActivityToIdle,
|
|
397
|
+
interruptBusySessionsAfterRestart,
|
|
361
398
|
dispose,
|
|
362
399
|
};
|
|
363
400
|
};
|
|
@@ -179,6 +179,80 @@ describe('session runtime', () => {
|
|
|
179
179
|
expect(runtime.getActiveSessionCount()).toBe(0);
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
+
it('interrupts busy sessions after restart and broadcasts terminal events once', () => {
|
|
183
|
+
const events = [];
|
|
184
|
+
const runtime = createSessionRuntime({
|
|
185
|
+
writeSseEvent() {},
|
|
186
|
+
getNotificationClients: () => new Set(),
|
|
187
|
+
broadcastEvent: (event) => events.push(event),
|
|
188
|
+
});
|
|
189
|
+
runtimes.push(runtime);
|
|
190
|
+
const status = (sessionID, type) => runtime.processOpenCodeSsePayload({
|
|
191
|
+
type: 'session.status',
|
|
192
|
+
properties: { sessionID, status: { type } },
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
status('session-busy-1', 'busy');
|
|
196
|
+
status('session-busy-2', 'retry');
|
|
197
|
+
status('session-busy-3', 'busy');
|
|
198
|
+
status('session-idle', 'idle');
|
|
199
|
+
expect(runtime.getActiveSessionCount()).toBe(3);
|
|
200
|
+
events.length = 0;
|
|
201
|
+
|
|
202
|
+
expect(runtime.interruptBusySessionsAfterRestart()).toEqual({
|
|
203
|
+
sessionIds: ['session-busy-1', 'session-busy-2', 'session-busy-3'],
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
expect(runtime.getActiveSessionCount()).toBe(0);
|
|
207
|
+
expect(runtime.getSessionActivitySnapshot()).toEqual({
|
|
208
|
+
'session-busy-1': { type: 'idle' },
|
|
209
|
+
'session-busy-2': { type: 'idle' },
|
|
210
|
+
'session-busy-3': { type: 'idle' },
|
|
211
|
+
'session-idle': { type: 'idle' },
|
|
212
|
+
});
|
|
213
|
+
expect(runtime.getSessionStateSnapshot()).toEqual({
|
|
214
|
+
'session-busy-1': expect.objectContaining({
|
|
215
|
+
status: 'idle',
|
|
216
|
+
metadata: expect.objectContaining({
|
|
217
|
+
message: 'Interrupted by OpenCode restart',
|
|
218
|
+
reason: 'opencode-restart',
|
|
219
|
+
}),
|
|
220
|
+
}),
|
|
221
|
+
'session-busy-2': expect.objectContaining({ status: 'idle' }),
|
|
222
|
+
'session-busy-3': expect.objectContaining({ status: 'idle' }),
|
|
223
|
+
'session-idle': expect.objectContaining({ status: 'idle' }),
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const terminalEvents = events.filter((event) => (
|
|
227
|
+
event.type === 'openchamber:session-status' || event.type === 'session.error'
|
|
228
|
+
));
|
|
229
|
+
expect(terminalEvents).toHaveLength(6);
|
|
230
|
+
for (const sessionId of ['session-busy-1', 'session-busy-2', 'session-busy-3']) {
|
|
231
|
+
expect(terminalEvents).toContainEqual({
|
|
232
|
+
type: 'openchamber:session-status',
|
|
233
|
+
properties: expect.objectContaining({
|
|
234
|
+
sessionID: sessionId,
|
|
235
|
+
status: 'idle',
|
|
236
|
+
}),
|
|
237
|
+
});
|
|
238
|
+
expect(terminalEvents).toContainEqual({
|
|
239
|
+
type: 'session.error',
|
|
240
|
+
properties: {
|
|
241
|
+
sessionID: sessionId,
|
|
242
|
+
error: {
|
|
243
|
+
name: 'MessageAbortedError',
|
|
244
|
+
message: 'The running turn was interrupted when OpenCode restarted.',
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
expect(terminalEvents.some((event) => event.properties.sessionID === 'session-idle')).toBe(false);
|
|
250
|
+
|
|
251
|
+
events.length = 0;
|
|
252
|
+
expect(runtime.interruptBusySessionsAfterRestart()).toEqual({ sessionIds: [] });
|
|
253
|
+
expect(events).toEqual([]);
|
|
254
|
+
});
|
|
255
|
+
|
|
182
256
|
it('restores activity when busy interrupts cooldown without timer underflow', () => {
|
|
183
257
|
vi.useFakeTimers();
|
|
184
258
|
const runtime = createSessionRuntime({
|
|
@@ -29,6 +29,9 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
29
29
|
const PWA_ORIENTATION_VALUES = new Set(['system', 'portrait', 'landscape']);
|
|
30
30
|
const MOBILE_KEYBOARD_MODE_VALUES = new Set(['native', 'resize-content']);
|
|
31
31
|
const TERMINAL_SHELL_VALUES = new Set(['auto', 'bash', 'zsh', 'sh', 'fish', 'pwsh', 'powershell', 'cmd', 'dash', 'ksh', 'nu']);
|
|
32
|
+
const SIDEBAR_PROJECT_DISPLAY_MODE_VALUES = new Set(['all', 'single']);
|
|
33
|
+
const SIDEBAR_SESSION_GROUPING_MODE_VALUES = new Set(['by-worktree', 'flat']);
|
|
34
|
+
const SIDEBAR_PROJECT_SORT_ORDER_VALUES = new Set(['manual', 'a-z', 'z-a', 'date-added', 'recent']);
|
|
32
35
|
const HIDDEN_MODELS_MAX = 1024;
|
|
33
36
|
const RECENT_EFFORTS_MAX_KEYS = 128;
|
|
34
37
|
const RECENT_EFFORTS_MAX_VARIANTS_PER_KEY = 5;
|
|
@@ -243,6 +246,18 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
243
246
|
if (typeof candidate.activeProjectId === 'string' && candidate.activeProjectId.length > 0) {
|
|
244
247
|
result.activeProjectId = candidate.activeProjectId;
|
|
245
248
|
}
|
|
249
|
+
if (SIDEBAR_PROJECT_DISPLAY_MODE_VALUES.has(candidate.sidebarProjectDisplayMode)) {
|
|
250
|
+
result.sidebarProjectDisplayMode = candidate.sidebarProjectDisplayMode;
|
|
251
|
+
}
|
|
252
|
+
if (SIDEBAR_SESSION_GROUPING_MODE_VALUES.has(candidate.sidebarSessionGroupingMode)) {
|
|
253
|
+
result.sidebarSessionGroupingMode = candidate.sidebarSessionGroupingMode;
|
|
254
|
+
}
|
|
255
|
+
if (SIDEBAR_PROJECT_SORT_ORDER_VALUES.has(candidate.sidebarProjectSortOrder)) {
|
|
256
|
+
result.sidebarProjectSortOrder = candidate.sidebarProjectSortOrder;
|
|
257
|
+
}
|
|
258
|
+
if (typeof candidate.sidebarShowRecentSection === 'boolean') {
|
|
259
|
+
result.sidebarShowRecentSection = candidate.sidebarShowRecentSection;
|
|
260
|
+
}
|
|
246
261
|
|
|
247
262
|
if (Array.isArray(candidate.securityScopedBookmarks)) {
|
|
248
263
|
result.securityScopedBookmarks = normalizeStringArray(candidate.securityScopedBookmarks);
|
|
@@ -66,6 +66,28 @@ describe('settings helpers', () => {
|
|
|
66
66
|
expect(helpers.sanitizeSettingsUpdate({ draftStartersVisible: 'false' })).toEqual({});
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
it('sanitizes shared sidebar display preferences', () => {
|
|
70
|
+
const helpers = createTestHelpers();
|
|
71
|
+
|
|
72
|
+
expect(helpers.sanitizeSettingsUpdate({
|
|
73
|
+
sidebarProjectDisplayMode: 'single',
|
|
74
|
+
sidebarSessionGroupingMode: 'flat',
|
|
75
|
+
sidebarProjectSortOrder: 'z-a',
|
|
76
|
+
sidebarShowRecentSection: false,
|
|
77
|
+
})).toEqual({
|
|
78
|
+
sidebarProjectDisplayMode: 'single',
|
|
79
|
+
sidebarSessionGroupingMode: 'flat',
|
|
80
|
+
sidebarProjectSortOrder: 'z-a',
|
|
81
|
+
sidebarShowRecentSection: false,
|
|
82
|
+
});
|
|
83
|
+
expect(helpers.sanitizeSettingsUpdate({
|
|
84
|
+
sidebarProjectDisplayMode: 'grid',
|
|
85
|
+
sidebarSessionGroupingMode: 'project',
|
|
86
|
+
sidebarProjectSortOrder: 'random',
|
|
87
|
+
sidebarShowRecentSection: 'false',
|
|
88
|
+
})).toEqual({});
|
|
89
|
+
});
|
|
90
|
+
|
|
69
91
|
it('accepts only booleans for wide chat layout', () => {
|
|
70
92
|
const helpers = createTestHelpers();
|
|
71
93
|
|
|
@@ -155,6 +155,7 @@ export const createSettingsNormalizationRuntime = (dependencies) => {
|
|
|
155
155
|
const iconBackground = normalizeIconBackground(candidate.iconBackground);
|
|
156
156
|
const color = typeof candidate.color === 'string' ? candidate.color.trim() : '';
|
|
157
157
|
const defaultModel = typeof candidate.defaultModel === 'string' ? candidate.defaultModel.trim() : '';
|
|
158
|
+
const defaultVariant = typeof candidate.defaultVariant === 'string' ? candidate.defaultVariant.trim() : '';
|
|
158
159
|
const addedAt = Number.isFinite(candidate.addedAt) ? Number(candidate.addedAt) : null;
|
|
159
160
|
const lastOpenedAt = Number.isFinite(candidate.lastOpenedAt)
|
|
160
161
|
? Number(candidate.lastOpenedAt)
|
|
@@ -175,6 +176,8 @@ export const createSettingsNormalizationRuntime = (dependencies) => {
|
|
|
175
176
|
...(iconBackground ? { iconBackground } : {}),
|
|
176
177
|
...(color ? { color } : {}),
|
|
177
178
|
...(defaultModel && defaultModel.includes('/') ? { defaultModel } : {}),
|
|
179
|
+
// A variant is meaningless without the model it belongs to.
|
|
180
|
+
...(defaultModel && defaultModel.includes('/') && defaultVariant ? { defaultVariant } : {}),
|
|
178
181
|
...(Number.isFinite(addedAt) && addedAt >= 0 ? { addedAt } : {}),
|
|
179
182
|
...(Number.isFinite(lastOpenedAt) && lastOpenedAt >= 0 ? { lastOpenedAt } : {}),
|
|
180
183
|
};
|
|
@@ -106,6 +106,22 @@ describe('settings normalization runtime - symlink resolution', () => {
|
|
|
106
106
|
expect(result[0].path).toBe('/resolved/missing/path');
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
+
it('keeps a default thinking level next to its model and drops it alone', () => {
|
|
110
|
+
const runtime = createTestRuntime({
|
|
111
|
+
realpathSync: (p) => p,
|
|
112
|
+
path: { resolve: (p) => p, sep: '/', dirname: (p) => p.split('/').slice(0, -1).join('/') || '/' },
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const projects = [
|
|
116
|
+
{ id: 'proj1', path: '/a', defaultModel: 'anthropic/claude-opus-5', defaultVariant: 'high' },
|
|
117
|
+
{ id: 'proj2', path: '/b', defaultVariant: 'high' },
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
const result = runtime.sanitizeProjects(projects);
|
|
121
|
+
expect(result[0].defaultVariant).toBe('high');
|
|
122
|
+
expect(result[1].defaultVariant).toBe(undefined);
|
|
123
|
+
});
|
|
124
|
+
|
|
109
125
|
it('deduplicates projects that resolve to the same realpath', () => {
|
|
110
126
|
const runtime = createTestRuntime({
|
|
111
127
|
realpathSync: (p) => p.startsWith('/symlink') ? '/real/project' : p,
|
|
@@ -547,25 +547,41 @@ export const createSettingsRuntime = (deps) => {
|
|
|
547
547
|
// briefly opens the target file. Preserve atomic rename everywhere it works,
|
|
548
548
|
// but fall back to a direct replacement so settings persistence does not
|
|
549
549
|
// get permanently wedged on Windows desktop installs.
|
|
550
|
-
|
|
551
|
-
|
|
550
|
+
try {
|
|
551
|
+
await fsPromises.copyFile(tmp, target);
|
|
552
|
+
} finally {
|
|
553
|
+
await fsPromises.rm(tmp, { force: true }).catch(() => {});
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
const cleanupOrphanedSettingsTempFiles = async (directory) => {
|
|
558
|
+
try {
|
|
559
|
+
const entries = await fsPromises.readdir(directory, { withFileTypes: true });
|
|
560
|
+
const cleanupTasks = entries
|
|
561
|
+
.filter((entry) => entry.isFile() && entry.name.startsWith('settings.json.tmp-'))
|
|
562
|
+
.map((entry) => fsPromises.rm(path.join(directory, entry.name), { force: true }).catch(() => {}));
|
|
563
|
+
await Promise.all(cleanupTasks);
|
|
564
|
+
} catch {
|
|
565
|
+
// Best-effort cleanup: errors reading directory must not fail settings operations
|
|
566
|
+
}
|
|
552
567
|
};
|
|
553
568
|
|
|
554
569
|
const writeSettingsToDisk = async (settings) => {
|
|
570
|
+
const settingsDirectory = path.dirname(SETTINGS_FILE_PATH);
|
|
571
|
+
await fsPromises.mkdir(settingsDirectory, { recursive: true, mode: 0o700 });
|
|
572
|
+
if (process.platform !== 'win32') await fsPromises.chmod(settingsDirectory, 0o700);
|
|
573
|
+
// Atomic write: Electron main and ssh-manager read this file via plain
|
|
574
|
+
// readFile + JSON.parse and silently coerce parse errors to {}. A
|
|
575
|
+
// partial read during a non-atomic writeFile would make their next
|
|
576
|
+
// read-modify-write wipe the settings file.
|
|
577
|
+
const tmp = `${SETTINGS_FILE_PATH}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
555
578
|
try {
|
|
556
|
-
const settingsDirectory = path.dirname(SETTINGS_FILE_PATH);
|
|
557
|
-
await fsPromises.mkdir(settingsDirectory, { recursive: true, mode: 0o700 });
|
|
558
|
-
if (process.platform !== 'win32') await fsPromises.chmod(settingsDirectory, 0o700);
|
|
559
|
-
// Atomic write: Electron main and ssh-manager read this file via plain
|
|
560
|
-
// readFile + JSON.parse and silently coerce parse errors to {}. A
|
|
561
|
-
// partial read during a non-atomic writeFile would make their next
|
|
562
|
-
// read-modify-write wipe the settings file.
|
|
563
|
-
const tmp = `${SETTINGS_FILE_PATH}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
564
579
|
await fsPromises.writeFile(tmp, JSON.stringify(settings, null, 2), { encoding: 'utf8', mode: 0o600 });
|
|
565
580
|
if (process.platform !== 'win32') await fsPromises.chmod(tmp, 0o600);
|
|
566
581
|
await replaceFile(tmp, SETTINGS_FILE_PATH);
|
|
567
582
|
if (process.platform !== 'win32') await fsPromises.chmod(SETTINGS_FILE_PATH, 0o600);
|
|
568
583
|
} catch (error) {
|
|
584
|
+
await fsPromises.rm(tmp, { force: true }).catch(() => {});
|
|
569
585
|
console.warn('Failed to write settings file:', error);
|
|
570
586
|
throw error;
|
|
571
587
|
}
|
|
@@ -854,7 +870,13 @@ export const createSettingsRuntime = (deps) => {
|
|
|
854
870
|
return { settings: next, changed: true };
|
|
855
871
|
};
|
|
856
872
|
|
|
873
|
+
let hasCleanedOrphanedTempFiles = false;
|
|
874
|
+
|
|
857
875
|
const readSettingsFromDiskMigrated = async () => {
|
|
876
|
+
if (!hasCleanedOrphanedTempFiles) {
|
|
877
|
+
hasCleanedOrphanedTempFiles = true;
|
|
878
|
+
await cleanupOrphanedSettingsTempFiles(path.dirname(SETTINGS_FILE_PATH));
|
|
879
|
+
}
|
|
858
880
|
const current = await readSettingsFromDisk();
|
|
859
881
|
const migration1 = await migrateSettingsFromLegacyLastDirectory(current);
|
|
860
882
|
const migration2 = await migrateSettingsFromLegacyThemePreferences(migration1.settings);
|
|
@@ -39,6 +39,24 @@ const createRuntime = async () => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
describe('settings runtime', () => {
|
|
42
|
+
it('round-trips shared sidebar preferences through settings.json', async () => {
|
|
43
|
+
const { runtime, settingsFilePath, cleanup } = await createRuntime();
|
|
44
|
+
const preferences = {
|
|
45
|
+
sidebarProjectDisplayMode: 'single',
|
|
46
|
+
sidebarSessionGroupingMode: 'flat',
|
|
47
|
+
sidebarProjectSortOrder: 'date-added',
|
|
48
|
+
sidebarShowRecentSection: false,
|
|
49
|
+
};
|
|
50
|
+
try {
|
|
51
|
+
await runtime.persistSettings(preferences);
|
|
52
|
+
|
|
53
|
+
await expect(runtime.readSettingsFromDisk()).resolves.toEqual(preferences);
|
|
54
|
+
await expect(fsPromises.readFile(settingsFilePath, 'utf8')).resolves.toBe(JSON.stringify(preferences, null, 2));
|
|
55
|
+
} finally {
|
|
56
|
+
await cleanup();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
42
60
|
it.skipIf(process.platform === 'win32')('writes settings with restrictive directory and file permissions', async () => {
|
|
43
61
|
const { runtime, settingsFilePath, tempRoot, cleanup } = await createRuntime();
|
|
44
62
|
try {
|
|
@@ -133,4 +151,71 @@ describe('settings runtime', () => {
|
|
|
133
151
|
await fsPromises.rm(tempRoot, { recursive: true, force: true });
|
|
134
152
|
}
|
|
135
153
|
});
|
|
154
|
+
|
|
155
|
+
it('cleans up orphaned settings.json.tmp files during startup migration', async () => {
|
|
156
|
+
const { runtime, settingsFilePath, tempRoot, cleanup } = await createRuntime();
|
|
157
|
+
try {
|
|
158
|
+
const settingsDir = path.dirname(settingsFilePath);
|
|
159
|
+
const orphan1 = path.join(settingsDir, 'settings.json.tmp-1234-11111-abc');
|
|
160
|
+
const orphan2 = path.join(settingsDir, 'settings.json.tmp-5678-22222-def');
|
|
161
|
+
const unrelated = path.join(settingsDir, 'other-file.json');
|
|
162
|
+
|
|
163
|
+
await fsPromises.writeFile(orphan1, '{"broken": true}', 'utf8');
|
|
164
|
+
await fsPromises.writeFile(orphan2, '{"broken": true}', 'utf8');
|
|
165
|
+
await fsPromises.writeFile(unrelated, '{"keep": true}', 'utf8');
|
|
166
|
+
await fsPromises.writeFile(settingsFilePath, '{"theme": "light"}', 'utf8');
|
|
167
|
+
|
|
168
|
+
await runtime.readSettingsFromDiskMigrated();
|
|
169
|
+
|
|
170
|
+
const files = await fsPromises.readdir(settingsDir);
|
|
171
|
+
expect(files).toContain('settings.json');
|
|
172
|
+
expect(files).toContain('other-file.json');
|
|
173
|
+
expect(files).not.toContain('settings.json.tmp-1234-11111-abc');
|
|
174
|
+
expect(files).not.toContain('settings.json.tmp-5678-22222-def');
|
|
175
|
+
} finally {
|
|
176
|
+
await cleanup();
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('removes temp file when writeSettingsToDisk encounters a write error', async () => {
|
|
181
|
+
const tempRoot = await fsPromises.mkdtemp(path.join(os.tmpdir(), 'oc-settings-runtime-'));
|
|
182
|
+
const settingsFilePath = path.join(tempRoot, 'settings.json');
|
|
183
|
+
let capturedTmp = null;
|
|
184
|
+
const wrappedFs = {
|
|
185
|
+
...fsPromises,
|
|
186
|
+
rename: async (src, dst) => {
|
|
187
|
+
capturedTmp = src;
|
|
188
|
+
const error = new Error('unexpected disk failure');
|
|
189
|
+
error.code = 'EIO';
|
|
190
|
+
throw error;
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
const runtime = createSettingsRuntime({
|
|
194
|
+
fsPromises: wrappedFs,
|
|
195
|
+
path,
|
|
196
|
+
crypto,
|
|
197
|
+
SETTINGS_FILE_PATH: settingsFilePath,
|
|
198
|
+
sanitizeProjects: (projects) => Array.isArray(projects) ? projects : [],
|
|
199
|
+
sanitizeSettingsUpdate: (settings) => settings,
|
|
200
|
+
mergePersistedSettings: (_current, changes) => changes,
|
|
201
|
+
normalizeSettingsPaths: (settings) => ({ settings, changed: false }),
|
|
202
|
+
normalizeStringArray: (values) => Array.isArray(values) ? values.filter((value) => typeof value === 'string') : [],
|
|
203
|
+
formatSettingsResponse: (settings) => settings,
|
|
204
|
+
resolveDirectoryCandidate: (value) => value,
|
|
205
|
+
normalizeManagedRemoteTunnelHostname: (value) => value,
|
|
206
|
+
normalizeManagedRemoteTunnelPresets: (value) => value,
|
|
207
|
+
normalizeManagedRemoteTunnelPresetTokens: (value) => value,
|
|
208
|
+
syncManagedRemoteTunnelConfigWithPresets: async () => {},
|
|
209
|
+
upsertManagedRemoteTunnelToken: async () => {},
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
await expect(runtime.writeSettingsToDisk({ theme: 'dark' })).rejects.toThrow('unexpected disk failure');
|
|
214
|
+
expect(capturedTmp).toBeTruthy();
|
|
215
|
+
const files = await fsPromises.readdir(tempRoot);
|
|
216
|
+
expect(files.some((f) => f.startsWith('settings.json.tmp-'))).toBe(false);
|
|
217
|
+
} finally {
|
|
218
|
+
await fsPromises.rm(tempRoot, { recursive: true, force: true });
|
|
219
|
+
}
|
|
220
|
+
});
|
|
136
221
|
});
|
|
@@ -40,14 +40,11 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
40
40
|
SKILL_DIR,
|
|
41
41
|
getCuratedSkillsSources,
|
|
42
42
|
getCacheKey,
|
|
43
|
-
|
|
44
|
-
setCachedScan,
|
|
43
|
+
scanWithCache,
|
|
45
44
|
parseSkillRepoSource,
|
|
46
45
|
scanSkillsRepository,
|
|
47
46
|
installSkillsFromRepository,
|
|
48
|
-
|
|
49
|
-
installSkillsFromClawdHub,
|
|
50
|
-
isClawdHubSource,
|
|
47
|
+
fetchGitHubRepoMetas,
|
|
51
48
|
getProfiles,
|
|
52
49
|
getProfile,
|
|
53
50
|
} = dependencies;
|
|
@@ -305,9 +302,26 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
305
302
|
}));
|
|
306
303
|
|
|
307
304
|
const sources = [...curatedSources, ...customSources];
|
|
308
|
-
const sourcesForUi = sources.map(({ gitIdentityId, ...rest }) => rest);
|
|
309
305
|
|
|
310
|
-
|
|
306
|
+
const githubRepos = sources
|
|
307
|
+
.map((src) => parseSkillRepoSource(src.source))
|
|
308
|
+
.filter((parsed) => parsed.ok && parsed.host === 'github.com')
|
|
309
|
+
.map((parsed) => parsed.normalizedRepo);
|
|
310
|
+
const repoMetas = await fetchGitHubRepoMetas(githubRepos);
|
|
311
|
+
|
|
312
|
+
const sourcesForUi = sources.map(({ gitIdentityId, ...rest }) => {
|
|
313
|
+
const parsed = parseSkillRepoSource(rest.source);
|
|
314
|
+
const meta = parsed.ok && parsed.host === 'github.com'
|
|
315
|
+
? repoMetas[parsed.normalizedRepo] || {}
|
|
316
|
+
: {};
|
|
317
|
+
return {
|
|
318
|
+
...rest,
|
|
319
|
+
stars: typeof meta.stars === 'number' ? meta.stars : null,
|
|
320
|
+
repoUpdatedAt: typeof meta.repoUpdatedAt === 'string' ? meta.repoUpdatedAt : null,
|
|
321
|
+
};
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
res.json({ ok: true, sources: sourcesForUi, itemsBySource: {} });
|
|
311
325
|
} catch (error) {
|
|
312
326
|
console.error('Failed to load skills catalog:', error);
|
|
313
327
|
res.status(500).json({ ok: false, error: { kind: 'unknown', message: error.message || 'Failed to load catalog' } });
|
|
@@ -327,7 +341,6 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
327
341
|
}
|
|
328
342
|
|
|
329
343
|
const refresh = String(req.query.refresh || '').toLowerCase() === 'true';
|
|
330
|
-
const cursor = typeof req.query.cursor === 'string' ? req.query.cursor : null;
|
|
331
344
|
|
|
332
345
|
const curatedSources = getCuratedSkillsSources();
|
|
333
346
|
const settings = await readSettingsFromDisk();
|
|
@@ -355,26 +368,6 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
355
368
|
);
|
|
356
369
|
const installedByName = new Map(resolvedDiscovered.map((s) => [s.name, s]));
|
|
357
370
|
|
|
358
|
-
if (src.sourceType === 'clawdhub' || isClawdHubSource(src.source)) {
|
|
359
|
-
const scanned = await scanClawdHubPage({ cursor: cursor || null });
|
|
360
|
-
if (!scanned.ok) {
|
|
361
|
-
return res.status(500).json({ ok: false, error: scanned.error });
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
const items = (scanned.items || []).map((item) => {
|
|
365
|
-
const installed = installedByName.get(item.skillName);
|
|
366
|
-
return {
|
|
367
|
-
...item,
|
|
368
|
-
sourceId: src.id,
|
|
369
|
-
installed: installed
|
|
370
|
-
? { isInstalled: true, scope: installed.scope, source: installed.source }
|
|
371
|
-
: { isInstalled: false },
|
|
372
|
-
};
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
return res.json({ ok: true, items, nextCursor: scanned.nextCursor || null });
|
|
376
|
-
}
|
|
377
|
-
|
|
378
371
|
const parsed = parseSkillRepoSource(src.source);
|
|
379
372
|
if (!parsed.ok) {
|
|
380
373
|
return res.status(400).json({ ok: false, error: parsed.error });
|
|
@@ -387,21 +380,19 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
387
380
|
identityId: src.gitIdentityId || '',
|
|
388
381
|
});
|
|
389
382
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
383
|
+
const scanResult = await scanWithCache(
|
|
384
|
+
cacheKey,
|
|
385
|
+
() => scanSkillsRepository({
|
|
393
386
|
source: src.source,
|
|
394
387
|
subpath: src.defaultSubpath,
|
|
395
388
|
defaultSubpath: src.defaultSubpath,
|
|
396
389
|
identity: resolveGitIdentity(src.gitIdentityId),
|
|
397
|
-
})
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
return res.status(500).json({ ok: false, error: scanned.error });
|
|
401
|
-
}
|
|
390
|
+
}),
|
|
391
|
+
{ refresh },
|
|
392
|
+
);
|
|
402
393
|
|
|
403
|
-
|
|
404
|
-
|
|
394
|
+
if (!scanResult.ok) {
|
|
395
|
+
return res.status(500).json({ ok: false, error: scanResult.error });
|
|
405
396
|
}
|
|
406
397
|
|
|
407
398
|
const items = (scanResult.items || []).map((item) => {
|
|
@@ -483,41 +474,6 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
483
474
|
workingDirectory = resolved.directory;
|
|
484
475
|
}
|
|
485
476
|
|
|
486
|
-
if (isClawdHubSource(source)) {
|
|
487
|
-
const result = await installSkillsFromClawdHub({
|
|
488
|
-
scope,
|
|
489
|
-
targetSource,
|
|
490
|
-
workingDirectory,
|
|
491
|
-
userSkillDir: SKILL_DIR,
|
|
492
|
-
selections,
|
|
493
|
-
conflictPolicy,
|
|
494
|
-
conflictDecisions,
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
if (!result.ok) {
|
|
498
|
-
if (result.error?.kind === 'conflicts') {
|
|
499
|
-
return res.status(409).json({ ok: false, error: result.error });
|
|
500
|
-
}
|
|
501
|
-
return res.status(400).json({ ok: false, error: result.error });
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
const installed = result.installed || [];
|
|
505
|
-
const skipped = result.skipped || [];
|
|
506
|
-
const requiresRestart = installed.length > 0;
|
|
507
|
-
|
|
508
|
-
return res.json({
|
|
509
|
-
ok: true,
|
|
510
|
-
installed,
|
|
511
|
-
skipped,
|
|
512
|
-
...(requiresRestart
|
|
513
|
-
? buildDeferredRestartResponse('Skills installed successfully. Restart OpenCode to apply.')
|
|
514
|
-
: {
|
|
515
|
-
requiresReload: false,
|
|
516
|
-
message: 'No skills were installed',
|
|
517
|
-
}),
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
|
|
521
477
|
const identity = resolveGitIdentity(gitIdentityId);
|
|
522
478
|
|
|
523
479
|
const result = await installSkillsFromRepository({
|