@openchamber/web 1.18.3 → 1.19.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-DbUi6I9s.js → CodeMirrorCommentWidgets-DAvopJvy.js} +1 -1
- package/dist/assets/{CommitSection-Jc2_hNPE.js → CommitSection-D9cV-qR9.js} +1 -1
- package/dist/assets/{DiagramEditor-PCrYHBko.js → DiagramEditor-B9NCadU7.js} +1 -1
- package/dist/assets/DiagramView-LKGBwf4G.js +1 -0
- package/dist/assets/{DiffView-DEGlNjMH.js → DiffView-BWNq-0ov.js} +2 -2
- package/dist/assets/FilesView-DB-Q0Gkz.js +14 -0
- package/dist/assets/{GitView-C-n17voy.js → GitView-DsWXqWx3.js} +3 -3
- package/dist/assets/{JsonTreeView-BYcgdTOQ.js → JsonTreeView-h4dHASlq.js} +1 -1
- package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +12 -0
- package/dist/assets/OnboardingScreen-CDjgzxEe.js +1 -0
- package/dist/assets/{PatchDiff-Bn7bfgUv.js → PatchDiff-jPKTJje5.js} +1 -1
- package/dist/assets/{PierreDiffViewer-D1fWvrUn.js → PierreDiffViewer-D_Gt4A_6.js} +1 -1
- package/dist/assets/PlanView-UvuxIl9-.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +1 -0
- package/dist/assets/SettingsView-3B9VN6Ys.js +28 -0
- package/dist/assets/SettingsWindow-CqQNDKNd.js +1 -0
- package/dist/assets/{ToolOutputDialog-BtIJkFno.js → ToolOutputDialog-PmjlAxVE.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-i3PQo6_0.js → ToolPartDiffPreview-B34Xw9wq.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-DkcusvMa.js → VirtualizedFileDiff-B37yB9jZ.js} +3 -3
- package/dist/assets/{WalkthroughView-Cc5Hd6P5.js → WalkthroughView-Bxun3k66.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-xPena3W2.js → computeVirtualFileMetrics-DYFv_yZS.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +1 -0
- package/dist/assets/de-DbV6CLxv.js +9 -0
- package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
- package/dist/assets/es-CVDlyzZ4.js +15 -0
- package/dist/assets/fr-Czc-p0g-.js +13 -0
- package/dist/assets/index-1OhiMDBz.css +1 -0
- package/dist/assets/index-BSvmTvZl.js +1 -0
- package/dist/assets/index-DzriVon2.js +7 -0
- package/dist/assets/{isDiffPlainText-Dudf-dWx.js → isDiffPlainText-DwHKxDYc.js} +1 -1
- package/dist/assets/{isFilePlainText-DS4QV1dd.js → isFilePlainText-Dwq6ILxo.js} +1 -1
- package/dist/assets/ja-dwc9NM_S.js +15 -0
- package/dist/assets/ko-Ds1DZ8FX.js +15 -0
- package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
- package/dist/assets/main-BF51IOVF.js +921 -0
- package/dist/assets/{main-C0DyIwTb.js → main-D7UPARut.js} +2 -2
- package/dist/assets/markdownCore-BgeBDwD3.js +2 -0
- package/dist/assets/{miniChat-CGfrxKpJ.js → miniChat-BISXSGOo.js} +2 -2
- package/dist/assets/mobile-BnYxVuvw.js +2 -0
- package/dist/assets/{patchFileDiff-C5D1OPCa.js → patchFileDiff-BEDPDypx.js} +2 -2
- package/dist/assets/pl-CLiTO7i-.js +15 -0
- package/dist/assets/pt-BR-GIimJgpK.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +2 -0
- package/dist/assets/{renderMobileApp-B5HA4qbi.js → renderMobileApp-BiMbzPq9.js} +7 -7
- package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +15 -0
- package/dist/assets/scheduledTasksApi-01zzfzqH.js +1 -0
- package/dist/assets/{shikiHighlight-CmanopUB.js → shikiHighlight-DXYW46vW.js} +1 -1
- package/dist/assets/uk-DLfgD1ki.js +15 -0
- package/dist/assets/{useAppFontEffects-sHmU5b8u.js → useAppFontEffects-CbzHzFop.js} +139 -142
- package/dist/assets/{useInlineCommentController-gt56WkxJ.js → useInlineCommentController-CegKdDXi.js} +2 -2
- package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-BYlZTzrw.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-Dihw9MtL.js → vendor-codemirror-language-data-CiAYDJXN.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-adaMkgkm.js +39 -0
- package/dist/assets/{web-components-BL-Ur2Tb.js → web-components-DCLjCO9n.js} +1 -1
- package/dist/assets/zh-CN-DkeP5awK.js +15 -0
- package/dist/assets/zh-TW-BocaFm3d.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/index.js +116 -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 +56 -0
- package/server/lib/agent-memory/project-resolution.test.js +85 -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 +427 -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/dev-tunnel/client.js +20 -1
- package/server/lib/dev-tunnel/tunnel.test.js +9 -0
- package/server/lib/fs/DOCUMENTATION.md +3 -0
- package/server/lib/fs/routes.js +149 -32
- package/server/lib/fs/routes.test.js +225 -0
- package/server/lib/git/DOCUMENTATION.md +8 -0
- package/server/lib/git/service.js +121 -67
- package/server/lib/git/service.test.js +129 -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/markdown-image-grants/DOCUMENTATION.md +36 -0
- package/server/lib/markdown-image-grants/routes.js +340 -0
- package/server/lib/markdown-image-grants/routes.test.js +221 -0
- 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 +6 -4
- 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 +22 -0
- package/server/lib/opencode/plugins.js +12 -3
- package/server/lib/opencode/plugins.test.js +18 -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/routes.js +4 -1
- package/server/lib/opencode/server-startup-runtime.js +22 -1
- package/server/lib/opencode/server-startup-runtime.test.js +44 -0
- package/server/lib/opencode/settings-helpers.js +11 -0
- package/server/lib/opencode/settings-helpers.test.js +35 -0
- package/server/lib/opencode/settings-runtime.js +51 -0
- package/server/lib/opencode/shared.js +120 -16
- package/server/lib/opencode/shared.test.js +185 -1
- package/server/lib/project-context/DOCUMENTATION.md +158 -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 +667 -0
- package/server/lib/project-context/runtime.test.js +498 -0
- package/server/lib/quota/DOCUMENTATION.md +16 -1
- 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 +72 -0
- package/server/lib/quota/providers/index.js +22 -2
- package/server/lib/quota/providers/index.test.js +10 -1
- 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 +87 -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 +22 -22
- package/server/lib/skills-catalog/curated-sources.js +1 -1
- package/server/lib/skills-catalog/curated-sources.test.js +10 -0
- package/server/lib/small-model/index.js +8 -0
- package/server/lib/small-model/index.test.js +31 -1
- package/server/lib/small-model/routes.js +3 -1
- package/dist/assets/DiagramView-CndEcZNu.js +0 -1
- package/dist/assets/FilesView-CzUgIvUm.js +0 -14
- package/dist/assets/MarkdownImageGallery-DzHwkVIH.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DUcIcWgs.js +0 -12
- package/dist/assets/OnboardingScreen-BmN0lhk4.js +0 -1
- package/dist/assets/PlanView-CWM0iyFk.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-Cez-9xRh.js +0 -1
- package/dist/assets/SettingsView-Bl1drwPw.js +0 -28
- package/dist/assets/SettingsWindow-DL5axjDZ.js +0 -1
- package/dist/assets/contextPanelEmbeddedChat-tQekJUAF.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-CVNuER6G.css +0 -1
- package/dist/assets/index-Crz1YOFl.js +0 -1
- package/dist/assets/index-iFY_N5aO.js +0 -7
- package/dist/assets/ja-DHpqbVmr.js +0 -15
- package/dist/assets/ko-CwLkS3nx.js +0 -15
- package/dist/assets/main-CAxX6DAN.js +0 -915
- package/dist/assets/markdownCore-DhfzuGXu.js +0 -2
- package/dist/assets/markdownImageAssets-BTNlRyjd.js +0 -1
- package/dist/assets/mobile-DEmhwNcV.js +0 -2
- package/dist/assets/pl-CcZILN8q.js +0 -15
- package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-Dpbswpom.js +0 -2
- package/dist/assets/runtimeEndpointReset-cbahJ3hD.js +0 -13
- package/dist/assets/scheduledTasksApi-BxgGWTL8.js +0 -1
- package/dist/assets/uk-BA2kZR38.js +0 -15
- 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
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, test } from 'bun:test';
|
|
2
|
+
import fsPromises from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { createAgentMemoryActions } from './actions.js';
|
|
7
|
+
import { createAgentMemoryRuntime } from './runtime.js';
|
|
8
|
+
import { createProjectIdFromPath } from '../projects/project-id.js';
|
|
9
|
+
|
|
10
|
+
const DIRECTORY = '/tmp/some-project';
|
|
11
|
+
|
|
12
|
+
class TestError extends Error {
|
|
13
|
+
constructor(message, status) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.status = status;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let actions;
|
|
20
|
+
let runtime;
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
const rootDir = await fsPromises.mkdtemp(path.join(os.tmpdir(), 'oc-memory-actions-'));
|
|
24
|
+
runtime = createAgentMemoryRuntime({
|
|
25
|
+
fsPromises,
|
|
26
|
+
path,
|
|
27
|
+
userConfigRoot: path.join(rootDir, 'config'),
|
|
28
|
+
projectsDirPath: path.join(rootDir, 'config', 'projects'),
|
|
29
|
+
});
|
|
30
|
+
actions = createAgentMemoryActions({
|
|
31
|
+
agentMemoryRuntime: runtime,
|
|
32
|
+
createError: (message, status) => new TestError(message, status),
|
|
33
|
+
resolveProjectId: async (directory) => createProjectIdFromPath(directory),
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('scope', () => {
|
|
38
|
+
test('project scope files against the session directory, not a model-supplied id', async () => {
|
|
39
|
+
await actions.execute('memory.save', {
|
|
40
|
+
scope: 'project',
|
|
41
|
+
title: 'Uses bun',
|
|
42
|
+
body: 'Tests run with bun test.',
|
|
43
|
+
projectId: 'path_somewhere_else',
|
|
44
|
+
}, DIRECTORY);
|
|
45
|
+
|
|
46
|
+
const stored = await runtime.read({
|
|
47
|
+
scope: 'project',
|
|
48
|
+
projectId: createProjectIdFromPath(DIRECTORY),
|
|
49
|
+
});
|
|
50
|
+
expect(stored.entries.map((entry) => entry.title)).toEqual(['Uses bun']);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('project scope without a session directory fails instead of writing global', async () => {
|
|
54
|
+
await expect(actions.execute('memory.save', { scope: 'project', title: 'T', body: 'b' }, null))
|
|
55
|
+
.rejects.toThrow('needs a session directory');
|
|
56
|
+
expect((await runtime.read({ scope: 'global' })).entries).toHaveLength(0);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('an unknown scope is rejected', async () => {
|
|
60
|
+
await expect(actions.execute('memory.save', { scope: 'team', title: 'T', body: 'b' }, DIRECTORY))
|
|
61
|
+
.rejects.toThrow('scope must be global or project');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('an unknown action is rejected', async () => {
|
|
65
|
+
await expect(actions.execute('memory.forget', {}, DIRECTORY)).rejects.toThrow('Unsupported memory action');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('save', () => {
|
|
70
|
+
test('requires title and body', async () => {
|
|
71
|
+
await expect(actions.execute('memory.save', { scope: 'global', body: 'b' }, DIRECTORY))
|
|
72
|
+
.rejects.toThrow('title is required');
|
|
73
|
+
await expect(actions.execute('memory.save', { scope: 'global', title: 't' }, DIRECTORY))
|
|
74
|
+
.rejects.toThrow('body is required');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('rejects an unknown type', async () => {
|
|
78
|
+
await expect(actions.execute('memory.save', {
|
|
79
|
+
scope: 'global', title: 't', body: 'b', type: 'nonsense',
|
|
80
|
+
}, DIRECTORY)).rejects.toThrow('type must be');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('reports a correction as replaced so the agent does not claim a second memory', async () => {
|
|
84
|
+
await actions.execute('memory.save', {
|
|
85
|
+
scope: 'global',
|
|
86
|
+
title: 'Prefers Ukrainian replies',
|
|
87
|
+
body: 'The user wants answers written in Ukrainian.',
|
|
88
|
+
}, DIRECTORY);
|
|
89
|
+
|
|
90
|
+
const result = await actions.execute('memory.save', {
|
|
91
|
+
scope: 'global',
|
|
92
|
+
title: 'Answers should be in Ukrainian',
|
|
93
|
+
body: 'The user wants replies written in Ukrainian.',
|
|
94
|
+
}, DIRECTORY);
|
|
95
|
+
|
|
96
|
+
expect(result.replaced).toBe(true);
|
|
97
|
+
expect((await runtime.read({ scope: 'global' })).entries).toHaveLength(1);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('announces the write so an open panel can show it', async () => {
|
|
101
|
+
const seen = [];
|
|
102
|
+
const announcing = createAgentMemoryActions({
|
|
103
|
+
agentMemoryRuntime: runtime,
|
|
104
|
+
createError: (message, status) => new TestError(message, status),
|
|
105
|
+
resolveProjectId: async (directory) => createProjectIdFromPath(directory),
|
|
106
|
+
onMemoryChanged: (event) => seen.push(event),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
await announcing.execute('memory.save', { scope: 'project', title: 'T', body: 'b' }, DIRECTORY);
|
|
110
|
+
|
|
111
|
+
expect(seen).toEqual([{ scope: 'project', projectId: createProjectIdFromPath(DIRECTORY) }]);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('a broken listener does not fail the write', async () => {
|
|
115
|
+
const announcing = createAgentMemoryActions({
|
|
116
|
+
agentMemoryRuntime: runtime,
|
|
117
|
+
createError: (message, status) => new TestError(message, status),
|
|
118
|
+
resolveProjectId: async (directory) => createProjectIdFromPath(directory),
|
|
119
|
+
onMemoryChanged: () => { throw new Error('listener exploded'); },
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const result = await announcing.execute('memory.save', { scope: 'global', title: 'T', body: 'b' }, DIRECTORY);
|
|
123
|
+
|
|
124
|
+
// The memory is already on disk; a broken notification must not report it
|
|
125
|
+
// back as a failure.
|
|
126
|
+
expect(result.memory.title).toBe('T');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
describe('worktree sessions reach the project store', () => {
|
|
131
|
+
test('every memory action resolves the directory through the project resolver', async () => {
|
|
132
|
+
const WORKTREE = '/tmp/worktree-checkout';
|
|
133
|
+
const worktreeAware = createAgentMemoryActions({
|
|
134
|
+
agentMemoryRuntime: runtime,
|
|
135
|
+
createError: (message, status) => new TestError(message, status),
|
|
136
|
+
// A worktree session must land in the project's store, not one keyed by
|
|
137
|
+
// the worktree path that the panel never reads.
|
|
138
|
+
resolveProjectId: async () => createProjectIdFromPath(DIRECTORY),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const saved = await worktreeAware.execute('memory.save', {
|
|
142
|
+
scope: 'project', title: 'Learned in a worktree', body: 'Body.',
|
|
143
|
+
}, WORKTREE);
|
|
144
|
+
|
|
145
|
+
expect((await runtime.read({ scope: 'project', projectId: createProjectIdFromPath(DIRECTORY) })).entries)
|
|
146
|
+
.toHaveLength(1);
|
|
147
|
+
|
|
148
|
+
// Reading and listing must agree with the write, or the agent would store
|
|
149
|
+
// something it can never find again.
|
|
150
|
+
const read = await worktreeAware.execute('memory.read', {
|
|
151
|
+
scope: 'project', memoryId: saved.memory.memoryId,
|
|
152
|
+
}, WORKTREE);
|
|
153
|
+
expect(read.memory.body).toBe('Body.');
|
|
154
|
+
|
|
155
|
+
const listed = await worktreeAware.execute('memory.list', {}, WORKTREE);
|
|
156
|
+
expect(listed.memories.map((memory) => memory.title)).toEqual(['Learned in a worktree']);
|
|
157
|
+
|
|
158
|
+
await worktreeAware.execute('memory.delete', {
|
|
159
|
+
scope: 'project', memoryId: saved.memory.memoryId,
|
|
160
|
+
}, WORKTREE);
|
|
161
|
+
expect((await runtime.read({ scope: 'project', projectId: createProjectIdFromPath(DIRECTORY) })).entries)
|
|
162
|
+
.toHaveLength(0);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('read', () => {
|
|
167
|
+
test('reads by the title the session index shows', async () => {
|
|
168
|
+
await actions.execute('memory.save', { scope: 'global', title: 'Uses bun', body: 'Full text here.' }, DIRECTORY);
|
|
169
|
+
|
|
170
|
+
const result = await actions.execute('memory.read', { scope: 'global', title: 'uses BUN' }, DIRECTORY);
|
|
171
|
+
|
|
172
|
+
expect(result.memory.body).toBe('Full text here.');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test('reads by id', async () => {
|
|
176
|
+
const saved = await actions.execute('memory.save', { scope: 'global', title: 'T', body: 'Full text.' }, DIRECTORY);
|
|
177
|
+
|
|
178
|
+
const result = await actions.execute('memory.read', {
|
|
179
|
+
scope: 'global', memoryId: saved.memory.memoryId,
|
|
180
|
+
}, DIRECTORY);
|
|
181
|
+
|
|
182
|
+
expect(result.memory.body).toBe('Full text.');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test('requires something to look up', async () => {
|
|
186
|
+
await expect(actions.execute('memory.read', { scope: 'global' }, DIRECTORY))
|
|
187
|
+
.rejects.toThrow('requires memoryId or title');
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test('a miss is reported, not answered with an empty memory', async () => {
|
|
191
|
+
await expect(actions.execute('memory.read', { scope: 'global', title: 'absent' }, DIRECTORY))
|
|
192
|
+
.rejects.toThrow('No memory matches');
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test('finds a memory without being told which store holds it', async () => {
|
|
196
|
+
// Scope decides everything for a write, but for a read it is only which
|
|
197
|
+
// drawer to open — demanding it turned a legible request into an error.
|
|
198
|
+
await actions.execute('memory.save', { scope: 'global', title: 'About user', body: 'Global text.' }, DIRECTORY);
|
|
199
|
+
|
|
200
|
+
const result = await actions.execute('memory.read', { title: 'About user' }, DIRECTORY);
|
|
201
|
+
|
|
202
|
+
expect(result.memory.body).toBe('Global text.');
|
|
203
|
+
expect(result.memory.scope).toBe('global');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test('prefers the project store when both hold the same title', async () => {
|
|
207
|
+
await actions.execute('memory.save', { scope: 'global', title: 'Shared', body: 'Global text.' }, DIRECTORY);
|
|
208
|
+
await actions.execute('memory.save', { scope: 'project', title: 'Shared', body: 'Project text.' }, DIRECTORY);
|
|
209
|
+
|
|
210
|
+
const result = await actions.execute('memory.read', { title: 'Shared' }, DIRECTORY);
|
|
211
|
+
|
|
212
|
+
expect(result.memory.scope).toBe('project');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test('an unscoped miss is still reported', async () => {
|
|
216
|
+
await expect(actions.execute('memory.read', { title: 'absent' }, DIRECTORY))
|
|
217
|
+
.rejects.toThrow('No memory matches');
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test('a store that failed to load is not reported as an absent memory', async () => {
|
|
221
|
+
const failing = createAgentMemoryActions({
|
|
222
|
+
agentMemoryRuntime: {
|
|
223
|
+
readAll: async () => ({ global: [], project: [], globalFailed: true, projectFailed: false }),
|
|
224
|
+
},
|
|
225
|
+
createError: (message, status) => new TestError(message, status),
|
|
226
|
+
resolveProjectId: async (directory) => createProjectIdFromPath(directory),
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// Answering "no such memory" would send the agent off to store it again.
|
|
230
|
+
await expect(failing.execute('memory.read', { title: 'anything' }, DIRECTORY))
|
|
231
|
+
.rejects.toThrow('could not be read');
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test('does not reach across scopes', async () => {
|
|
235
|
+
await actions.execute('memory.save', { scope: 'project', title: 'Uses bun', body: 'x' }, DIRECTORY);
|
|
236
|
+
|
|
237
|
+
await expect(actions.execute('memory.read', { scope: 'global', title: 'Uses bun' }, DIRECTORY))
|
|
238
|
+
.rejects.toThrow('No memory matches');
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
describe('list', () => {
|
|
243
|
+
test('lists both scopes by default and labels which is which', async () => {
|
|
244
|
+
await actions.execute('memory.save', { scope: 'global', title: 'About user', body: 'x' }, DIRECTORY);
|
|
245
|
+
await actions.execute('memory.save', { scope: 'project', title: 'About project', body: 'y' }, DIRECTORY);
|
|
246
|
+
|
|
247
|
+
const result = await actions.execute('memory.list', {}, DIRECTORY);
|
|
248
|
+
|
|
249
|
+
expect(result.memories.map((memory) => [memory.title, memory.scope])).toEqual([
|
|
250
|
+
['About user', 'global'],
|
|
251
|
+
['About project', 'project'],
|
|
252
|
+
]);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test('listing never carries bodies', async () => {
|
|
256
|
+
await actions.execute('memory.save', { scope: 'global', title: 'T', body: 'Long body text.' }, DIRECTORY);
|
|
257
|
+
|
|
258
|
+
const result = await actions.execute('memory.list', { scope: 'global' }, DIRECTORY);
|
|
259
|
+
|
|
260
|
+
expect(result.memories[0].body).toBeUndefined();
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test('a broken scope is reported rather than shown as empty', async () => {
|
|
264
|
+
const failing = createAgentMemoryActions({
|
|
265
|
+
agentMemoryRuntime: {
|
|
266
|
+
readAll: async () => ({ global: [], project: [], globalFailed: true, projectFailed: false }),
|
|
267
|
+
},
|
|
268
|
+
createError: (message, status) => new TestError(message, status),
|
|
269
|
+
resolveProjectId: async (directory) => createProjectIdFromPath(directory),
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const result = await failing.execute('memory.list', {}, DIRECTORY);
|
|
273
|
+
|
|
274
|
+
expect(result.globalUnavailable).toBe(true);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
describe('delete', () => {
|
|
279
|
+
test('removes the entry', async () => {
|
|
280
|
+
const saved = await actions.execute('memory.save', { scope: 'global', title: 'T', body: 'b' }, DIRECTORY);
|
|
281
|
+
|
|
282
|
+
await actions.execute('memory.delete', { scope: 'global', memoryId: saved.memory.memoryId }, DIRECTORY);
|
|
283
|
+
|
|
284
|
+
expect((await runtime.read({ scope: 'global' })).entries).toHaveLength(0);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test('requires an id', async () => {
|
|
288
|
+
await expect(actions.execute('memory.delete', { scope: 'global' }, DIRECTORY))
|
|
289
|
+
.rejects.toThrow('memoryId is required');
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test('reports a miss instead of claiming success', async () => {
|
|
293
|
+
await expect(actions.execute('memory.delete', { scope: 'global', memoryId: 'absent' }, DIRECTORY))
|
|
294
|
+
.rejects.toThrow('No memory has that id');
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
describe('when the user switches memory off', () => {
|
|
299
|
+
const disabled = () => createAgentMemoryActions({
|
|
300
|
+
agentMemoryRuntime: runtime,
|
|
301
|
+
createError: (message, status) => new TestError(message, status),
|
|
302
|
+
resolveProjectId: async (directory) => createProjectIdFromPath(directory),
|
|
303
|
+
isAgentMemoryEnabled: async () => false,
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
test('refuses to write, so nothing accumulates unseen', async () => {
|
|
307
|
+
// The tool lives in the OpenCode child until it restarts, so the agent can
|
|
308
|
+
// still call this after the switch goes off. Those writes would land on
|
|
309
|
+
// disk while the panel showing them is hidden.
|
|
310
|
+
await expect(disabled().execute('memory.save', { scope: 'global', title: 'T', body: 'b' }, DIRECTORY))
|
|
311
|
+
.rejects.toThrow('switched off');
|
|
312
|
+
expect((await runtime.read({ scope: 'global' })).entries).toHaveLength(0);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
test('refuses to read as well', async () => {
|
|
316
|
+
await expect(disabled().execute('memory.list', {}, DIRECTORY)).rejects.toThrow('switched off');
|
|
317
|
+
await expect(disabled().execute('memory.read', { title: 'x' }, DIRECTORY)).rejects.toThrow('switched off');
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
test('an unreadable setting closes the surface rather than opening it', async () => {
|
|
321
|
+
const unknown = createAgentMemoryActions({
|
|
322
|
+
agentMemoryRuntime: runtime,
|
|
323
|
+
createError: (message, status) => new TestError(message, status),
|
|
324
|
+
resolveProjectId: async (directory) => createProjectIdFromPath(directory),
|
|
325
|
+
isAgentMemoryEnabled: async () => { throw new Error('settings unreadable'); },
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
await expect(unknown.execute('memory.save', { scope: 'global', title: 'T', body: 'b' }, DIRECTORY))
|
|
329
|
+
.rejects.toThrow('switched off');
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
test('works normally while it is on', async () => {
|
|
333
|
+
const on = createAgentMemoryActions({
|
|
334
|
+
agentMemoryRuntime: runtime,
|
|
335
|
+
createError: (message, status) => new TestError(message, status),
|
|
336
|
+
resolveProjectId: async (directory) => createProjectIdFromPath(directory),
|
|
337
|
+
isAgentMemoryEnabled: async () => true,
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
const result = await on.execute('memory.save', { scope: 'global', title: 'T', body: 'b' }, DIRECTORY);
|
|
341
|
+
expect(result.saved).toBe(true);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether agent memory exists at all in this build.
|
|
3
|
+
*
|
|
4
|
+
* The feature is complete but not released: it ships dark so it can be tested
|
|
5
|
+
* against real work without appearing to users who have not asked for it. With
|
|
6
|
+
* the flag unset there is no tool, no routes, no session index and no settings
|
|
7
|
+
* row — not a switch left in the off position, which would invite someone to
|
|
8
|
+
* turn on something unannounced.
|
|
9
|
+
*
|
|
10
|
+
* Read per call rather than captured at import, so a process started with the
|
|
11
|
+
* variable set is the only thing that decides — no build step bakes it in.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const TRUTHY = new Set(['1', 'true', 'yes', 'on']);
|
|
15
|
+
|
|
16
|
+
export const isAgentMemoryFeatureAvailable = () => {
|
|
17
|
+
const raw = process.env.OPENCHAMBER_MEMORY_ENABLE;
|
|
18
|
+
return typeof raw === 'string' && TRUTHY.has(raw.trim().toLowerCase());
|
|
19
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { isAgentMemoryFeatureAvailable } from './feature-flag.js';
|
|
4
|
+
|
|
5
|
+
const original = process.env.OPENCHAMBER_MEMORY_ENABLE;
|
|
6
|
+
|
|
7
|
+
afterEach(() => {
|
|
8
|
+
if (original === undefined) delete process.env.OPENCHAMBER_MEMORY_ENABLE;
|
|
9
|
+
else process.env.OPENCHAMBER_MEMORY_ENABLE = original;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe('the unreleased feature gate', () => {
|
|
13
|
+
test('is closed when the variable is unset', () => {
|
|
14
|
+
delete process.env.OPENCHAMBER_MEMORY_ENABLE;
|
|
15
|
+
expect(isAgentMemoryFeatureAvailable()).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('opens for the usual truthy spellings', () => {
|
|
19
|
+
for (const value of ['1', 'true', 'TRUE', 'yes', 'on', ' true ']) {
|
|
20
|
+
process.env.OPENCHAMBER_MEMORY_ENABLE = value;
|
|
21
|
+
expect(isAgentMemoryFeatureAvailable()).toBe(true);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('stays closed for anything else, including "false"', () => {
|
|
26
|
+
for (const value of ['', '0', 'false', 'no', 'off', 'maybe']) {
|
|
27
|
+
process.env.OPENCHAMBER_MEMORY_ENABLE = value;
|
|
28
|
+
expect(isAgentMemoryFeatureAvailable()).toBe(false);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('is read per call, so a process started with it set is what decides', () => {
|
|
33
|
+
delete process.env.OPENCHAMBER_MEMORY_ENABLE;
|
|
34
|
+
expect(isAgentMemoryFeatureAvailable()).toBe(false);
|
|
35
|
+
process.env.OPENCHAMBER_MEMORY_ENABLE = '1';
|
|
36
|
+
expect(isAgentMemoryFeatureAvailable()).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which project's memory a session directory belongs to.
|
|
3
|
+
*
|
|
4
|
+
* A session often runs in a worktree, whose path is not the project's path.
|
|
5
|
+
* Keying memory by the session directory filed a worktree's memories under a
|
|
6
|
+
* project the panel never reads, so the agent stored them and the user never
|
|
7
|
+
* saw them. Every worktree of a repository shares one project memory, which is
|
|
8
|
+
* also what the user means by "this project".
|
|
9
|
+
*
|
|
10
|
+
* A directory that is itself a configured project is taken as-is; anything else
|
|
11
|
+
* resolves to its primary worktree. The configured check comes first because a
|
|
12
|
+
* user may register a worktree as a project in its own right, and that choice
|
|
13
|
+
* has to win over the git topology.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
|
|
18
|
+
import { createProjectIdFromPath } from '../projects/project-id.js';
|
|
19
|
+
|
|
20
|
+
const normalize = (value) => {
|
|
21
|
+
if (typeof value !== 'string') return '';
|
|
22
|
+
const trimmed = value.trim();
|
|
23
|
+
return trimmed ? path.resolve(trimmed) : '';
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const createMemoryProjectResolver = (dependencies) => {
|
|
27
|
+
const { listProjectPaths, resolvePrimaryWorktreeRoot } = dependencies;
|
|
28
|
+
|
|
29
|
+
return async (directory) => {
|
|
30
|
+
const resolved = normalize(directory);
|
|
31
|
+
if (!resolved) {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let configured = [];
|
|
36
|
+
try {
|
|
37
|
+
configured = ((await listProjectPaths()) || []).map(normalize).filter(Boolean);
|
|
38
|
+
} catch {
|
|
39
|
+
// An unreadable project list must not lose the memory: the git-derived
|
|
40
|
+
// root below still converges every worktree of the repository on one
|
|
41
|
+
// store rather than scattering one per checkout.
|
|
42
|
+
}
|
|
43
|
+
if (configured.includes(resolved)) {
|
|
44
|
+
return createProjectIdFromPath(resolved);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let primaryRoot = '';
|
|
48
|
+
try {
|
|
49
|
+
primaryRoot = normalize((await resolvePrimaryWorktreeRoot(resolved))?.root);
|
|
50
|
+
} catch {
|
|
51
|
+
// Not a git checkout, or git is unavailable.
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return createProjectIdFromPath(primaryRoot || resolved);
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { createMemoryProjectResolver } from './project-resolution.js';
|
|
4
|
+
import { createProjectIdFromPath } from '../projects/project-id.js';
|
|
5
|
+
|
|
6
|
+
const PROJECT = '/Users/x/projects/openchamber';
|
|
7
|
+
const WORKTREE = '/Users/x/.local/share/opencode/worktree/abc/jammy-koala';
|
|
8
|
+
|
|
9
|
+
const createResolver = (overrides = {}) => createMemoryProjectResolver({
|
|
10
|
+
listProjectPaths: async () => [PROJECT],
|
|
11
|
+
resolvePrimaryWorktreeRoot: async (directory) => (
|
|
12
|
+
directory === WORKTREE ? { root: PROJECT } : { root: directory }
|
|
13
|
+
),
|
|
14
|
+
...overrides,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('resolving a session directory to its project', () => {
|
|
18
|
+
test('a worktree resolves to the project it belongs to', async () => {
|
|
19
|
+
const resolve = createResolver();
|
|
20
|
+
|
|
21
|
+
// The bug this exists for: keyed by its own path, a worktree wrote memory
|
|
22
|
+
// into a project the panel never reads.
|
|
23
|
+
expect(await resolve(WORKTREE)).toBe(createProjectIdFromPath(PROJECT));
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('the project directory resolves to itself', async () => {
|
|
27
|
+
const resolve = createResolver();
|
|
28
|
+
|
|
29
|
+
expect(await resolve(PROJECT)).toBe(createProjectIdFromPath(PROJECT));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('every worktree of one repository shares a store', async () => {
|
|
33
|
+
const second = '/Users/x/.local/share/opencode/worktree/abc/other';
|
|
34
|
+
const resolve = createResolver({
|
|
35
|
+
resolvePrimaryWorktreeRoot: async () => ({ root: PROJECT }),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
expect(await resolve(WORKTREE)).toBe(await resolve(second));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('a worktree registered as a project in its own right keeps its own store', async () => {
|
|
42
|
+
// The user's explicit choice wins over the git topology.
|
|
43
|
+
const resolve = createResolver({ listProjectPaths: async () => [PROJECT, WORKTREE] });
|
|
44
|
+
|
|
45
|
+
expect(await resolve(WORKTREE)).toBe(createProjectIdFromPath(WORKTREE));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('a directory outside any repository keys by itself', async () => {
|
|
49
|
+
const resolve = createResolver();
|
|
50
|
+
|
|
51
|
+
expect(await resolve('/tmp/loose')).toBe(createProjectIdFromPath('/tmp/loose'));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('no directory resolves to nothing rather than to some default project', async () => {
|
|
55
|
+
const resolve = createResolver();
|
|
56
|
+
|
|
57
|
+
expect(await resolve('')).toBe('');
|
|
58
|
+
expect(await resolve(null)).toBe('');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('trailing slashes and relative segments do not fork the store', async () => {
|
|
62
|
+
const resolve = createResolver();
|
|
63
|
+
|
|
64
|
+
expect(await resolve(`${PROJECT}/`)).toBe(createProjectIdFromPath(PROJECT));
|
|
65
|
+
expect(await resolve(`${PROJECT}/packages/..`)).toBe(createProjectIdFromPath(PROJECT));
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('when something is unavailable', () => {
|
|
70
|
+
test('an unreadable project list still converges worktrees on the repository', async () => {
|
|
71
|
+
const resolve = createResolver({
|
|
72
|
+
listProjectPaths: async () => { throw new Error('settings unreadable'); },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(await resolve(WORKTREE)).toBe(createProjectIdFromPath(PROJECT));
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('git being unavailable falls back to the directory instead of failing', async () => {
|
|
79
|
+
const resolve = createResolver({
|
|
80
|
+
resolvePrimaryWorktreeRoot: async () => { throw new Error('git missing'); },
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(await resolve(WORKTREE)).toBe(createProjectIdFromPath(WORKTREE));
|
|
84
|
+
});
|
|
85
|
+
});
|