@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.
- package/README.md +1 -0
- package/dist/assets/{CodeMirrorCommentWidgets-4qZbrEXU.js → CodeMirrorCommentWidgets-C36E738Y.js} +1 -1
- package/dist/assets/{CommitSection-MJmntVPJ.js → CommitSection-C-F3AX6D.js} +1 -1
- package/dist/assets/{DiagramEditor-jnG3Hbxg.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-DBFrDDBv.js → GitView-Rp8P1KEI.js} +4 -4
- package/dist/assets/{JsonTreeView-DLW2Wy1g.js → JsonTreeView-KnXFN2A-.js} +1 -1
- package/dist/assets/MarkdownImageGallery-BMn3mtor.js +1 -0
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +12 -0
- package/dist/assets/OnboardingScreen-CenIeD4v.js +1 -0
- package/dist/assets/{PatchDiff-BuLPx7AN.js → PatchDiff-BzVOVog8.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BHm4Yr0X.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-CwGocYQd.js → VirtualizedFileDiff-lESMT-2b.js} +4 -4
- package/dist/assets/{WalkthroughView-5DyvN03T.js → WalkthroughView-CaSYE0lw.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-Da00Jg7M.js → computeVirtualFileMetrics-DkRR5b75.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +1 -0
- package/dist/assets/de-DFdX3ABv.js +9 -0
- package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
- package/dist/assets/es-iC-FKvV9.js +15 -0
- package/dist/assets/fr-BBbi_1AL.js +13 -0
- package/dist/assets/index-BiEgzzkg.js +1 -0
- package/dist/assets/index-Cwmuwk3V.js +7 -0
- package/dist/assets/index-GNm1wgUH.css +1 -0
- package/dist/assets/{isDiffPlainText-D9YpoLrV.js → isDiffPlainText-BG53Ixxy.js} +1 -1
- package/dist/assets/{isFilePlainText-gTibdNIe.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/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
- 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-KNkxM1C1.js → patchFileDiff-BcFaMtMu.js} +1 -1
- 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-CDfHS5rr.js +25 -0
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +15 -0
- package/dist/assets/scheduledTasksApi-BFSlqgnG.js +1 -0
- package/dist/assets/{shikiHighlight-C7LTbwFx.js → shikiHighlight-DCT2Sq_z.js} +1 -1
- package/dist/assets/uk-PhsC-c4-.js +15 -0
- package/dist/assets/{useAppFontEffects-BikB6enL.js → useAppFontEffects-B53Rb6m7.js} +168 -164
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +2 -0
- package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-DsHmyMwp.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +1 -0
- package/dist/assets/vendor-codemirror-commands-B7H_j0iU.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-angular-CgY7_gQ1.js → vendor-codemirror-lang-angular-DEPs2M5t.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-B5Ta4enQ.js → vendor-codemirror-lang-cpp-DhkseaMo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-VgNqFSH-.js → vendor-codemirror-lang-css-O0cZX78y.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-LxLz62pp.js → vendor-codemirror-lang-go-fMdQYcON.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-html-CfgK872x.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-java-Bksi1PH4.js → vendor-codemirror-lang-java-CQj4S3zl.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js +13 -0
- package/dist/assets/{vendor-codemirror-lang-jinja-C7npuDD7.js → vendor-codemirror-lang-jinja-BmZZv8g-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-ryCw7nab.js → vendor-codemirror-lang-json-CMBS2tG9.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-BxsZJD6N.js → vendor-codemirror-lang-less-C6Eo8hVS.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-De6qch10.js → vendor-codemirror-lang-liquid-DSTR47-H.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-markdown-BPGOH9ye.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-php-Cm1es33p.js → vendor-codemirror-lang-php-DD9udfPH.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-N414WYK-.js → vendor-codemirror-lang-python-HahnQaAS.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-C_WuUStH.js → vendor-codemirror-lang-rust-nLTovbjv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-8UHTCAOM.js → vendor-codemirror-lang-sass-pL2Yc72v.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-CV3sMA5D.js → vendor-codemirror-lang-sql-BVBnan19.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DzvC1Dhk.js → vendor-codemirror-lang-vue-BqGzJVm1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-jlr-LDdA.js → vendor-codemirror-lang-wast-B0_m5DqU.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-CrO63OVp.js → vendor-codemirror-lang-xml-Dj3voadT.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-dxi6CISW.js → vendor-codemirror-lang-yaml-yu-9Z5u7.js} +1 -1
- package/dist/assets/vendor-codemirror-language-BgPj_McA.js +3 -0
- package/dist/assets/{vendor-codemirror-language-data-CLHw8NWn.js → vendor-codemirror-language-data-vch3tJ4c.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +2 -0
- package/dist/assets/{vendor-codemirror-state-CNWM3Q8V.js → vendor-codemirror-state-C9awkmn-.js} +5 -5
- package/dist/assets/vendor-codemirror-view-CiLROUVV.js +4 -0
- package/dist/assets/vendor-replit-codemirror-vim-B2DJlAhT.js +6 -0
- package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
- package/dist/assets/vendor-zod-C9ioTTSo.js +39 -0
- package/dist/assets/{web-components-GMc3oR3i.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 +152 -3
- package/server/lib/agent-memory/actions.js +243 -0
- package/server/lib/agent-memory/actions.test.js +343 -0
- package/server/lib/agent-memory/feature-flag.js +19 -0
- package/server/lib/agent-memory/feature-flag.test.js +38 -0
- package/server/lib/agent-memory/project-resolution.js +65 -0
- package/server/lib/agent-memory/project-resolution.test.js +94 -0
- package/server/lib/agent-memory/routes.http.test.js +270 -0
- package/server/lib/agent-memory/routes.js +169 -0
- package/server/lib/agent-memory/runtime.js +432 -0
- package/server/lib/agent-memory/runtime.test.js +344 -0
- package/server/lib/agent-memory/threat-patterns.js +61 -0
- package/server/lib/agent-memory/threat-patterns.test.js +61 -0
- package/server/lib/agent-tool/DOCUMENTATION.md +14 -0
- package/server/lib/agent-tool/runtime.js +63 -13
- package/server/lib/agent-tool/runtime.test.js +85 -2
- package/server/lib/context-obligatory/runtime.js +34 -3
- package/server/lib/context-obligatory/runtime.test.js +114 -0
- 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/DOCUMENTATION.md +3 -0
- package/server/lib/fs/routes.js +149 -32
- package/server/lib/fs/routes.test.js +301 -0
- package/server/lib/git/DOCUMENTATION.md +8 -0
- package/server/lib/git/routes.js +43 -0
- package/server/lib/git/service.js +206 -72
- package/server/lib/git/service.test.js +222 -0
- package/server/lib/github/DOCUMENTATION.md +14 -3
- package/server/lib/github/pr-status.js +188 -83
- package/server/lib/github/pr-status.test.js +182 -0
- package/server/lib/github/routes.js +36 -30
- package/server/lib/notifications/template-runtime.js +2 -3
- package/server/lib/openchamber-control/action-resolution.test.js +65 -0
- package/server/lib/openchamber-control/actions.js +78 -0
- package/server/lib/openchamber-control/service.js +7 -0
- package/server/lib/openchamber-sessions/routes.js +14 -0
- package/server/lib/opencode/DOCUMENTATION.md +12 -6
- package/server/lib/opencode/claude-cli-auth.js +60 -0
- package/server/lib/opencode/claude-cli-auth.test.js +54 -0
- package/server/lib/opencode/feature-routes-runtime.js +16 -9
- package/server/lib/opencode/lifecycle.js +202 -26
- package/server/lib/opencode/lifecycle.test.js +179 -1
- package/server/lib/opencode/plugins.js +12 -3
- package/server/lib/opencode/plugins.test.js +18 -0
- package/server/lib/opencode/providers.js +9 -4
- package/server/lib/opencode/providers.test.js +27 -0
- package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
- package/server/lib/opencode/proxy.js +116 -6
- package/server/lib/opencode/proxy.test.js +158 -1
- package/server/lib/opencode/restart-session-recovery.test.js +59 -0
- package/server/lib/opencode/routes.js +4 -1
- 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 +26 -0
- package/server/lib/opencode/settings-helpers.test.js +57 -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 +83 -10
- package/server/lib/opencode/settings-runtime.test.js +85 -0
- package/server/lib/opencode/shared.js +120 -16
- package/server/lib/opencode/shared.test.js +185 -1
- 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 +160 -0
- package/server/lib/project-context/routes.http.test.js +264 -0
- package/server/lib/project-context/routes.js +237 -0
- package/server/lib/project-context/runtime.js +672 -0
- package/server/lib/project-context/runtime.test.js +498 -0
- package/server/lib/projects/project-config.js +7 -2
- package/server/lib/quota/DOCUMENTATION.md +17 -2
- package/server/lib/quota/providers/claude/auth.js +113 -0
- package/server/lib/quota/providers/claude/auth.test.js +117 -0
- package/server/lib/quota/providers/claude/index.js +151 -0
- package/server/lib/quota/providers/claude/index.test.js +147 -0
- package/server/lib/quota/providers/claude/transforms.js +127 -0
- package/server/lib/quota/providers/claude/transforms.test.js +82 -0
- package/server/lib/quota/providers/command-code.js +90 -0
- package/server/lib/quota/providers/command-code.test.js +85 -0
- package/server/lib/quota/providers/index.js +30 -2
- package/server/lib/quota/providers/index.test.js +10 -1
- package/server/lib/quota/providers/zai.js +26 -6
- package/server/lib/quota/providers/zai.test.js +33 -0
- package/server/lib/quota/utils/formatters.js +2 -1
- package/server/lib/scheduled-tasks/runtime.js +21 -2
- package/server/lib/session-knowledge/DOCUMENTATION.md +89 -0
- package/server/lib/session-knowledge/routes.js +107 -0
- package/server/lib/session-knowledge/runtime.js +331 -0
- package/server/lib/session-knowledge/runtime.test.js +275 -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 +10 -0
- 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 +57 -6
- package/server/lib/small-model/index.test.js +102 -2
- package/server/lib/small-model/routes.js +4 -2
- 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-CFXxgg_a.js +0 -1
- package/dist/assets/DiffView-DZIoOnV7.js +0 -4
- package/dist/assets/FilesView-BKL6YlKG.js +0 -14
- package/dist/assets/MarkdownImageGallery-DKIylIK7.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +0 -12
- package/dist/assets/OnboardingScreen-D2Y6djMw.js +0 -1
- package/dist/assets/PlanView-ZYEJn8A_.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-rro-SsaO.js +0 -1
- package/dist/assets/SettingsView-5RmswFZe.js +0 -28
- package/dist/assets/SettingsWindow-BZhAYFdS.js +0 -1
- package/dist/assets/ToolOutputDialog-Za6V4VMJ.js +0 -15
- package/dist/assets/ToolPartDiffPreview-BL-9ixyC.js +0 -8
- package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +0 -1
- package/dist/assets/de-u7gSnqWs.js +0 -9
- package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
- package/dist/assets/es-T9O7aAOr.js +0 -15
- package/dist/assets/fr-Oor7ewbE.js +0 -13
- package/dist/assets/index-BzIpNlNE.css +0 -1
- package/dist/assets/index-C0yNhuZw.js +0 -1
- package/dist/assets/index-DRpChWux.js +0 -7
- package/dist/assets/ja-DHpqbVmr.js +0 -15
- package/dist/assets/ko-CwLkS3nx.js +0 -15
- package/dist/assets/main-D7UcL3VQ.js +0 -2
- package/dist/assets/main-DPMd2iKS.js +0 -915
- package/dist/assets/markdownCore-DDrHVneM.js +0 -2
- package/dist/assets/miniChat-O_GVoEbc.js +0 -2
- package/dist/assets/mobile-Br4TtAqc.js +0 -2
- package/dist/assets/pl-CcZILN8q.js +0 -15
- package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-CJpdxTT1.js +0 -2
- package/dist/assets/renderMobileApp-toj9cXoh.js +0 -25
- package/dist/assets/runtimeEndpointReset-BVmispdD.js +0 -13
- package/dist/assets/scheduledTasksApi-ByKya3Un.js +0 -1
- package/dist/assets/uk-BA2kZR38.js +0 -15
- package/dist/assets/useInlineCommentController-CYPvYJDt.js +0 -2
- package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
- package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
- package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
- package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
- package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
- package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
- package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
- package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
- package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
- package/server/lib/quota/providers/claude.js +0 -107
- 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
|
@@ -3,6 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
4
|
|
|
5
5
|
import { mintOutsideFileGrant, registerFsRoutes } from './routes.js';
|
|
6
|
+
import { createProjectDirectoryRuntime } from '../opencode/project-directory-runtime.js';
|
|
6
7
|
|
|
7
8
|
const createRouteRegistry = () => {
|
|
8
9
|
const routes = new Map();
|
|
@@ -140,6 +141,30 @@ const registerWrite = (fsPromises) => {
|
|
|
140
141
|
return getRoute('POST', '/api/fs/write');
|
|
141
142
|
};
|
|
142
143
|
|
|
144
|
+
const registerUpload = (fsPromises) => {
|
|
145
|
+
const { app, getRoute } = createRouteRegistry();
|
|
146
|
+
registerFsRoutes(app, {
|
|
147
|
+
os: { homedir: () => '/home/user' },
|
|
148
|
+
path: path.posix,
|
|
149
|
+
fsPromises: {
|
|
150
|
+
realpath: async (targetPath) => {
|
|
151
|
+
if (targetPath === '/repo') return targetPath;
|
|
152
|
+
throw Object.assign(new Error('not found'), { code: 'ENOENT' });
|
|
153
|
+
},
|
|
154
|
+
stat: async () => ({ isDirectory: () => false }),
|
|
155
|
+
...fsPromises,
|
|
156
|
+
},
|
|
157
|
+
spawn: vi.fn(),
|
|
158
|
+
crypto: { randomUUID: () => 'job-0' },
|
|
159
|
+
normalizeDirectoryPath: (p) => p,
|
|
160
|
+
resolveProjectDirectory: async () => ({ directory: '/repo' }),
|
|
161
|
+
buildAugmentedPath: () => '/usr/bin',
|
|
162
|
+
resolveGitBinaryForSpawn: () => 'git',
|
|
163
|
+
openchamberUserConfigRoot: '/home/user/.config',
|
|
164
|
+
});
|
|
165
|
+
return getRoute('POST', '/api/fs/upload');
|
|
166
|
+
};
|
|
167
|
+
|
|
143
168
|
const registerRead = (fsPromises) => {
|
|
144
169
|
const { app, getRoute } = createRouteRegistry();
|
|
145
170
|
registerFsRoutes(app, {
|
|
@@ -233,6 +258,28 @@ const callWrite = async (handler, body) => {
|
|
|
233
258
|
return res;
|
|
234
259
|
};
|
|
235
260
|
|
|
261
|
+
const callUpload = async (handler, {
|
|
262
|
+
body = Buffer.from('upload'),
|
|
263
|
+
chunks,
|
|
264
|
+
includeContentLength = true,
|
|
265
|
+
path: filePath = '/repo/file.bin',
|
|
266
|
+
overwrite = false,
|
|
267
|
+
} = {}) => {
|
|
268
|
+
const res = createMockResponse();
|
|
269
|
+
const uploadChunks = chunks ?? [body];
|
|
270
|
+
const headers = { 'content-type': 'application/octet-stream' };
|
|
271
|
+
if (includeContentLength) headers['content-length'] = String(body.length);
|
|
272
|
+
const req = {
|
|
273
|
+
headers,
|
|
274
|
+
query: { path: filePath, overwrite: overwrite ? 'true' : undefined },
|
|
275
|
+
async *[Symbol.asyncIterator]() {
|
|
276
|
+
yield* uploadChunks;
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
await handler(req, res);
|
|
280
|
+
return res;
|
|
281
|
+
};
|
|
282
|
+
|
|
236
283
|
const callRead = async (handler, query) => {
|
|
237
284
|
const res = createMockResponse();
|
|
238
285
|
await handler({ query }, res);
|
|
@@ -340,7 +387,186 @@ describe('fs write', () => {
|
|
|
340
387
|
});
|
|
341
388
|
});
|
|
342
389
|
|
|
390
|
+
describe('fs upload', () => {
|
|
391
|
+
it('streams a binary file to temp storage before committing it without overwrite', async () => {
|
|
392
|
+
const write = vi.fn(async (_buffer, _offset, length) => ({ bytesWritten: length }));
|
|
393
|
+
const close = vi.fn(async () => undefined);
|
|
394
|
+
const fsPromises = {
|
|
395
|
+
open: vi.fn(async () => ({ write, close })),
|
|
396
|
+
link: vi.fn(async () => undefined),
|
|
397
|
+
rename: vi.fn(async () => undefined),
|
|
398
|
+
unlink: vi.fn(async () => undefined),
|
|
399
|
+
};
|
|
400
|
+
const handler = registerUpload(fsPromises);
|
|
401
|
+
|
|
402
|
+
const body = Buffer.from([0, 1, 2, 255]);
|
|
403
|
+
const res = await callUpload(handler, {
|
|
404
|
+
body,
|
|
405
|
+
chunks: [body.subarray(0, 2), body.subarray(2)],
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
expect(res.body).toEqual({ success: true, path: '/repo/file.bin' });
|
|
409
|
+
const tmp = fsPromises.open.mock.calls[0][0];
|
|
410
|
+
expect(tmp).toMatch(/^\/repo\/file\.bin\.upload-/);
|
|
411
|
+
expect(fsPromises.open).toHaveBeenCalledWith(tmp, 'wx');
|
|
412
|
+
expect(write).toHaveBeenNthCalledWith(1, Buffer.from([0, 1]), 0, 2, null);
|
|
413
|
+
expect(write).toHaveBeenNthCalledWith(2, Buffer.from([2, 255]), 0, 2, null);
|
|
414
|
+
expect(close).toHaveBeenCalledTimes(1);
|
|
415
|
+
expect(fsPromises.link).toHaveBeenCalledWith(tmp, '/repo/file.bin');
|
|
416
|
+
expect(fsPromises.unlink).toHaveBeenCalledWith(tmp);
|
|
417
|
+
expect(fsPromises.rename).not.toHaveBeenCalled();
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('returns a conflict instead of silently replacing an existing file', async () => {
|
|
421
|
+
const fsPromises = {
|
|
422
|
+
realpath: vi.fn(async (targetPath) => targetPath),
|
|
423
|
+
stat: vi.fn(async () => ({ isDirectory: () => false })),
|
|
424
|
+
open: vi.fn(async () => ({ write: vi.fn(), close: vi.fn() })),
|
|
425
|
+
};
|
|
426
|
+
const handler = registerUpload(fsPromises);
|
|
427
|
+
|
|
428
|
+
const res = await callUpload(handler);
|
|
429
|
+
|
|
430
|
+
expect(res.statusCode).toBe(409);
|
|
431
|
+
expect(res.body).toEqual({ error: 'File already exists', reason: 'already-exists' });
|
|
432
|
+
expect(fsPromises.open).not.toHaveBeenCalled();
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('atomically replaces a file only when overwrite is explicit', async () => {
|
|
436
|
+
const write = vi.fn(async (_buffer, _offset, length) => ({ bytesWritten: length }));
|
|
437
|
+
const fsPromises = {
|
|
438
|
+
realpath: vi.fn(async (targetPath) => targetPath),
|
|
439
|
+
stat: vi.fn(async () => ({ isDirectory: () => false })),
|
|
440
|
+
open: vi.fn(async () => ({ write, close: vi.fn(async () => undefined) })),
|
|
441
|
+
rename: vi.fn(async () => undefined),
|
|
442
|
+
unlink: vi.fn(async () => undefined),
|
|
443
|
+
};
|
|
444
|
+
const handler = registerUpload(fsPromises);
|
|
445
|
+
|
|
446
|
+
const res = await callUpload(handler, { overwrite: true });
|
|
447
|
+
|
|
448
|
+
expect(res.body).toEqual({ success: true, path: '/repo/file.bin' });
|
|
449
|
+
const tmp = fsPromises.open.mock.calls[0][0];
|
|
450
|
+
expect(tmp).toMatch(/^\/repo\/file\.bin\.upload-/);
|
|
451
|
+
expect(write).toHaveBeenCalledWith(Buffer.from('upload'), 0, 6, null);
|
|
452
|
+
expect(fsPromises.rename).toHaveBeenCalledWith(tmp, '/repo/file.bin');
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('rejects an existing directory before reading the upload body', async () => {
|
|
456
|
+
const fsPromises = {
|
|
457
|
+
realpath: vi.fn(async (targetPath) => targetPath),
|
|
458
|
+
stat: vi.fn(async () => ({ isDirectory: () => true })),
|
|
459
|
+
open: vi.fn(async () => ({ write: vi.fn(), close: vi.fn() })),
|
|
460
|
+
};
|
|
461
|
+
const handler = registerUpload(fsPromises);
|
|
462
|
+
|
|
463
|
+
const res = await callUpload(handler);
|
|
464
|
+
|
|
465
|
+
expect(res.statusCode).toBe(400);
|
|
466
|
+
expect(res.body).toEqual({ error: 'Specified path is a directory' });
|
|
467
|
+
expect(fsPromises.open).not.toHaveBeenCalled();
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
it('rejects a destination parent that resolves outside the workspace', async () => {
|
|
471
|
+
const fsPromises = {
|
|
472
|
+
realpath: vi.fn(async (targetPath) => targetPath === '/repo/link' ? '/outside' : targetPath),
|
|
473
|
+
open: vi.fn(async () => ({ write: vi.fn(), close: vi.fn() })),
|
|
474
|
+
};
|
|
475
|
+
const handler = registerUpload(fsPromises);
|
|
476
|
+
|
|
477
|
+
const res = await callUpload(handler, { path: '/repo/link/file.bin' });
|
|
478
|
+
|
|
479
|
+
expect(res.statusCode).toBe(403);
|
|
480
|
+
expect(res.body).toEqual({ error: 'Access denied' });
|
|
481
|
+
expect(fsPromises.open).not.toHaveBeenCalled();
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it('cleans up a partial temp file when the configured streaming limit is exceeded', async () => {
|
|
485
|
+
const previous = process.env.OPENCHAMBER_FS_UPLOAD_MAX_BYTES;
|
|
486
|
+
process.env.OPENCHAMBER_FS_UPLOAD_MAX_BYTES = '5';
|
|
487
|
+
const write = vi.fn(async (_buffer, _offset, length) => ({ bytesWritten: length }));
|
|
488
|
+
const fsPromises = {
|
|
489
|
+
open: vi.fn(async () => ({ write, close: vi.fn(async () => undefined) })),
|
|
490
|
+
link: vi.fn(async () => undefined),
|
|
491
|
+
unlink: vi.fn(async () => undefined),
|
|
492
|
+
};
|
|
493
|
+
try {
|
|
494
|
+
const handler = registerUpload(fsPromises);
|
|
495
|
+
const res = await callUpload(handler, {
|
|
496
|
+
body: Buffer.from('123456'),
|
|
497
|
+
chunks: [Buffer.from('123'), Buffer.from('456')],
|
|
498
|
+
includeContentLength: false,
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
expect(res.statusCode).toBe(413);
|
|
502
|
+
expect(res.body).toEqual({ error: 'File exceeds maximum size of 5 bytes' });
|
|
503
|
+
expect(write).toHaveBeenCalledWith(Buffer.from('123'), 0, 3, null);
|
|
504
|
+
expect(fsPromises.link).not.toHaveBeenCalled();
|
|
505
|
+
expect(fsPromises.unlink).toHaveBeenCalledWith(expect.stringMatching(/^\/repo\/file\.bin\.upload-/));
|
|
506
|
+
} finally {
|
|
507
|
+
if (previous === undefined) delete process.env.OPENCHAMBER_FS_UPLOAD_MAX_BYTES;
|
|
508
|
+
else process.env.OPENCHAMBER_FS_UPLOAD_MAX_BYTES = previous;
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
it('rejects a declared oversized upload before opening a temp file', async () => {
|
|
513
|
+
const previous = process.env.OPENCHAMBER_FS_UPLOAD_MAX_BYTES;
|
|
514
|
+
process.env.OPENCHAMBER_FS_UPLOAD_MAX_BYTES = '5';
|
|
515
|
+
const fsPromises = {
|
|
516
|
+
open: vi.fn(async () => ({ write: vi.fn(), close: vi.fn() })),
|
|
517
|
+
};
|
|
518
|
+
try {
|
|
519
|
+
const handler = registerUpload(fsPromises);
|
|
520
|
+
const res = await callUpload(handler, { body: Buffer.from('123456') });
|
|
521
|
+
|
|
522
|
+
expect(res.statusCode).toBe(413);
|
|
523
|
+
expect(res.body).toEqual({ error: 'File exceeds maximum size of 5 bytes' });
|
|
524
|
+
expect(fsPromises.open).not.toHaveBeenCalled();
|
|
525
|
+
} finally {
|
|
526
|
+
if (previous === undefined) delete process.env.OPENCHAMBER_FS_UPLOAD_MAX_BYTES;
|
|
527
|
+
else process.env.OPENCHAMBER_FS_UPLOAD_MAX_BYTES = previous;
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
it('keeps the existing file when a target appears before the atomic commit', async () => {
|
|
532
|
+
const error = Object.assign(new Error('exists'), { code: 'EEXIST' });
|
|
533
|
+
const fsPromises = {
|
|
534
|
+
open: vi.fn(async () => ({
|
|
535
|
+
write: vi.fn(async (_buffer, _offset, length) => ({ bytesWritten: length })),
|
|
536
|
+
close: vi.fn(async () => undefined),
|
|
537
|
+
})),
|
|
538
|
+
link: vi.fn(async () => { throw error; }),
|
|
539
|
+
unlink: vi.fn(async () => undefined),
|
|
540
|
+
};
|
|
541
|
+
const handler = registerUpload(fsPromises);
|
|
542
|
+
|
|
543
|
+
const res = await callUpload(handler);
|
|
544
|
+
|
|
545
|
+
expect(res.statusCode).toBe(409);
|
|
546
|
+
expect(res.body).toEqual({ error: 'File already exists', reason: 'already-exists' });
|
|
547
|
+
expect(fsPromises.unlink).toHaveBeenCalledWith(expect.stringMatching(/^\/repo\/file\.bin\.upload-/));
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
|
|
343
551
|
describe('fs read', () => {
|
|
552
|
+
it('reads workspace files through symlinks that resolve outside the workspace', async () => {
|
|
553
|
+
const fsPromises = {
|
|
554
|
+
realpath: vi.fn(async (targetPath) => {
|
|
555
|
+
if (targetPath === '/repo/link.txt') return '/shared/target.txt';
|
|
556
|
+
return targetPath;
|
|
557
|
+
}),
|
|
558
|
+
stat: vi.fn(async () => ({ isFile: () => true, size: 6 })),
|
|
559
|
+
readFile: vi.fn(async () => 'shared'),
|
|
560
|
+
};
|
|
561
|
+
const handler = registerRead(fsPromises);
|
|
562
|
+
|
|
563
|
+
const res = await callRead(handler, { path: '/repo/link.txt' });
|
|
564
|
+
|
|
565
|
+
expect(res.statusCode).toBe(200);
|
|
566
|
+
expect(res.body).toBe('shared');
|
|
567
|
+
expect(fsPromises.readFile).toHaveBeenCalledWith('/shared/target.txt', 'utf8');
|
|
568
|
+
});
|
|
569
|
+
|
|
344
570
|
it('rejects outside workspace reads without a grant', async () => {
|
|
345
571
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
346
572
|
const fsPromises = {
|
|
@@ -823,3 +1049,78 @@ describe('fs list symlink path space (issue 2627)', () => {
|
|
|
823
1049
|
});
|
|
824
1050
|
}
|
|
825
1051
|
});
|
|
1052
|
+
|
|
1053
|
+
describe('fs stat directory scope (issue 3019)', () => {
|
|
1054
|
+
// Wires the real project-directory runtime so the stat route resolves the
|
|
1055
|
+
// workspace exactly as the server does: explicit x-opencode-directory header
|
|
1056
|
+
// first, then the settings.lastDirectory fallback. The renderer's file
|
|
1057
|
+
// reference probes must send the header because lastDirectory reflects the
|
|
1058
|
+
// directory the UI last browsed, not the session's directory.
|
|
1059
|
+
const registerStatWithProjectDirectoryRuntime = () => {
|
|
1060
|
+
const projectDirectoryRuntime = createProjectDirectoryRuntime({
|
|
1061
|
+
fsPromises: {
|
|
1062
|
+
stat: async (targetPath) => {
|
|
1063
|
+
if (targetPath === '/repo-a' || targetPath === '/repo-b') {
|
|
1064
|
+
return { isDirectory: () => true };
|
|
1065
|
+
}
|
|
1066
|
+
return { isDirectory: () => false, isFile: () => true, size: 12 };
|
|
1067
|
+
},
|
|
1068
|
+
realpath: async (targetPath) => targetPath,
|
|
1069
|
+
},
|
|
1070
|
+
path: { resolve: (p) => path.posix.resolve(p) },
|
|
1071
|
+
normalizeDirectoryPath: (p) => p,
|
|
1072
|
+
readSettingsFromDiskMigrated: async () => ({ lastDirectory: '/repo-a', projects: [] }),
|
|
1073
|
+
getReadSettingsFromDiskMigrated: undefined,
|
|
1074
|
+
sanitizeProjects: (input) => input,
|
|
1075
|
+
});
|
|
1076
|
+
|
|
1077
|
+
const { app, getRoute } = createRouteRegistry();
|
|
1078
|
+
registerFsRoutes(app, {
|
|
1079
|
+
os: { homedir: () => '/home/user' },
|
|
1080
|
+
path: path.posix,
|
|
1081
|
+
fsPromises: {
|
|
1082
|
+
realpath: async (targetPath) => targetPath,
|
|
1083
|
+
stat: async () => ({ isFile: () => true, size: 12 }),
|
|
1084
|
+
},
|
|
1085
|
+
spawn: vi.fn(),
|
|
1086
|
+
crypto: { randomUUID: () => 'job-0' },
|
|
1087
|
+
normalizeDirectoryPath: (p) => p,
|
|
1088
|
+
resolveProjectDirectory: projectDirectoryRuntime.resolveProjectDirectory,
|
|
1089
|
+
buildAugmentedPath: () => '/usr/bin',
|
|
1090
|
+
resolveGitBinaryForSpawn: () => 'git',
|
|
1091
|
+
openchamberUserConfigRoot: '/home/user/.config',
|
|
1092
|
+
});
|
|
1093
|
+
return getRoute('GET', '/api/fs/stat');
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
const callStat = async (handler, { headers = {}, query }) => {
|
|
1097
|
+
const res = createMockResponse();
|
|
1098
|
+
const req = {
|
|
1099
|
+
query,
|
|
1100
|
+
get: (name) => headers[name.toLowerCase()] ?? undefined,
|
|
1101
|
+
};
|
|
1102
|
+
await handler(req, res);
|
|
1103
|
+
return res;
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
it('rejects a stat for a file under the session directory when only lastDirectory resolves the workspace', async () => {
|
|
1107
|
+
const handler = registerStatWithProjectDirectoryRuntime();
|
|
1108
|
+
|
|
1109
|
+
const res = await callStat(handler, { query: { path: '/repo-b/src/index.ts', optional: 'true' } });
|
|
1110
|
+
|
|
1111
|
+
expect(res.statusCode).toBe(400);
|
|
1112
|
+
expect(res.body).toEqual({ error: 'Path is outside of active workspace' });
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
it('accepts the same stat when the session directory rides the x-opencode-directory header', async () => {
|
|
1116
|
+
const handler = registerStatWithProjectDirectoryRuntime();
|
|
1117
|
+
|
|
1118
|
+
const res = await callStat(handler, {
|
|
1119
|
+
headers: { 'x-opencode-directory': '/repo-b' },
|
|
1120
|
+
query: { path: '/repo-b/src/index.ts', optional: 'true' },
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1123
|
+
expect(res.statusCode).toBe(200);
|
|
1124
|
+
expect(res.body.isFile).toBe(true);
|
|
1125
|
+
});
|
|
1126
|
+
});
|
|
@@ -52,6 +52,14 @@ The following functions are exported and used by the web server:
|
|
|
52
52
|
- `removeWorktree(directory, input)`: Remove a worktree (optionally delete local branch).
|
|
53
53
|
- `isLinkedWorktree(directory)`: Check if directory is a linked worktree (not primary).
|
|
54
54
|
|
|
55
|
+
### Worktree creation from a GitHub pull request
|
|
56
|
+
The UI provisions `pr-<owner>` via `ensureRemoteName`/`ensureRemoteUrl`
|
|
57
|
+
(HTTPS clone URL preferred over SSH) and checks out
|
|
58
|
+
`remotes/pr-<owner>/<head>`. A missing head URL or unreachable fork fails with
|
|
59
|
+
a clear error before a worktree is kept. If upstream fetch fails during
|
|
60
|
+
bootstrap, tracking is left unset rather than writing `branch.*.remote` /
|
|
61
|
+
`branch.*.merge` for a ref that was never fetched.
|
|
62
|
+
|
|
55
63
|
### Commit and Remote Operations
|
|
56
64
|
- `commit(directory, message, options)`: Create a commit from the current index. `options.stageFiles` may be provided with `options.files` by older callers to stage only selected unstaged rows before committing, but the shared Git panel now stages/unstages explicitly before commit.
|
|
57
65
|
- `pull(directory, options)`: Pull changes from remote.
|
package/server/lib/git/routes.js
CHANGED
|
@@ -428,6 +428,49 @@ export function registerGitRoutes(app) {
|
|
|
428
428
|
}
|
|
429
429
|
});
|
|
430
430
|
|
|
431
|
+
app.get('/api/git/branch-base', async (req, res) => {
|
|
432
|
+
const { getBranchBase } = await getGitLibraries();
|
|
433
|
+
try {
|
|
434
|
+
const directory = resolveDirectoryQuery(req.query.directory);
|
|
435
|
+
if (!directory) {
|
|
436
|
+
return res.status(400).json({ error: 'directory parameter is required' });
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const branch = resolveDirectoryQuery(req.query.branch);
|
|
440
|
+
if (!branch) {
|
|
441
|
+
return res.status(400).json({ error: 'branch parameter is required' });
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const result = await getBranchBase(directory, branch);
|
|
445
|
+
res.json(result);
|
|
446
|
+
} catch (error) {
|
|
447
|
+
console.error('Failed to get branch base:', error);
|
|
448
|
+
res.status(500).json({ error: error.message || 'Failed to get branch base' });
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
app.get('/api/git/range-files', async (req, res) => {
|
|
453
|
+
const { getRangeFiles } = await getGitLibraries();
|
|
454
|
+
try {
|
|
455
|
+
const directory = resolveDirectoryQuery(req.query.directory);
|
|
456
|
+
if (!directory) {
|
|
457
|
+
return res.status(400).json({ error: 'directory parameter is required' });
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
const base = resolveDirectoryQuery(req.query.base);
|
|
461
|
+
const head = resolveDirectoryQuery(req.query.head);
|
|
462
|
+
if (!base || !head) {
|
|
463
|
+
return res.status(400).json({ error: 'base and head parameters are required' });
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const files = await getRangeFiles(directory, { base, head });
|
|
467
|
+
res.json({ files });
|
|
468
|
+
} catch (error) {
|
|
469
|
+
console.error('Failed to get git range files:', error);
|
|
470
|
+
res.status(500).json({ error: error.message || 'Failed to get git range files' });
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
|
|
431
474
|
app.post('/api/git/revert', async (req, res) => {
|
|
432
475
|
const { revertFile } = await getGitLibraries();
|
|
433
476
|
try {
|