@beyondwork/wb-cli 0.1.27 → 0.1.29
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/CHANGELOG.md +10 -0
- package/README.md +6 -14
- package/out/cli.js +257 -567
- package/out/extension.js +193 -861
- package/package.json +15 -11
- package/wb-cli/skills/bw-workblock/SKILL.md +67 -0
- package/wb-cli/skills/bw-workblock/references/browser-run.sh +95 -0
- package/wb-cli/skills/bw-workblock/references/browser-validation.md +44 -0
- package/wb-cli/skills/bw-workblock/references/validate-ui.mjs +208 -0
- package/out/auth.js +0 -75
- package/out/auth.js.map +0 -1
- package/out/cli.js.map +0 -1
- package/out/cli.test.js +0 -195
- package/out/cli.test.js.map +0 -1
- package/out/client.js +0 -117
- package/out/client.js.map +0 -1
- package/out/connection_feedback.js +0 -45
- package/out/connection_feedback.js.map +0 -1
- package/out/extension.js.map +0 -1
- package/out/lib/branches.js +0 -138
- package/out/lib/branches.js.map +0 -1
- package/out/lib/branches.test.js +0 -185
- package/out/lib/branches.test.js.map +0 -1
- package/out/lib/cli-security.test.js +0 -146
- package/out/lib/cli-security.test.js.map +0 -1
- package/out/lib/index.js +0 -29
- package/out/lib/index.js.map +0 -1
- package/out/lib/logger.js +0 -28
- package/out/lib/logger.js.map +0 -1
- package/out/lib/workblock.js +0 -470
- package/out/lib/workblock.js.map +0 -1
- package/out/lib/workblock.test.js +0 -607
- package/out/lib/workblock.test.js.map +0 -1
- package/out/lib/workspace.js +0 -282
- package/out/lib/workspace.js.map +0 -1
- package/out/lib/workspace.test.js +0 -666
- package/out/lib/workspace.test.js.map +0 -1
- package/out/lib/ws-client.test.js +0 -188
- package/out/lib/ws-client.test.js.map +0 -1
- package/out/tree_data_provider.js +0 -274
- package/out/tree_data_provider.js.map +0 -1
- package/out/types.js +0 -25
- package/out/types.js.map +0 -1
- package/out/ws-client.js +0 -466
- package/out/ws-client.js.map +0 -1
|
@@ -1,666 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const assert = __importStar(require("node:assert/strict"));
|
|
37
|
-
const workspace_1 = require("./workspace");
|
|
38
|
-
const STREAM_ID = "42b99b44-8e41-46b5-aaf4-f45656505950";
|
|
39
|
-
const THREAD_ID = "92186d93-607a-4f27-a5fd-0a2646fd97c6";
|
|
40
|
-
const USER_ID = "8d52f62c-818d-4c97-968d-e7e4cd3ab58c";
|
|
41
|
-
const WORKBLOCK_ID = "d7bd49ad-3584-41e5-9279-b1b505862c74";
|
|
42
|
-
const mainBranch = {
|
|
43
|
-
head_commit: "main-head",
|
|
44
|
-
last_changed: "2026-07-29T00:00:00Z",
|
|
45
|
-
name: "main",
|
|
46
|
-
};
|
|
47
|
-
const userBranch = {
|
|
48
|
-
head_commit: "user-head",
|
|
49
|
-
last_changed: "2026-07-29T00:30:00Z",
|
|
50
|
-
name: `features/my-feature@users/${USER_ID}`,
|
|
51
|
-
};
|
|
52
|
-
const conversationBranch = {
|
|
53
|
-
head_commit: "conversation-head",
|
|
54
|
-
last_changed: "2026-07-29T01:00:00Z",
|
|
55
|
-
name: `features/my-feature@stream/${STREAM_ID}`,
|
|
56
|
-
};
|
|
57
|
-
const threadBranch = {
|
|
58
|
-
head_commit: "thread-head",
|
|
59
|
-
last_changed: "2026-07-29T02:00:00Z",
|
|
60
|
-
name: `features/my-feature@stream/${STREAM_ID}@thread/${THREAD_ID}`,
|
|
61
|
-
};
|
|
62
|
-
function workspace(overrides = {}) {
|
|
63
|
-
return {
|
|
64
|
-
branch: conversationBranch.name,
|
|
65
|
-
created_at: "2026-07-29T01:00:00Z",
|
|
66
|
-
id: STREAM_ID,
|
|
67
|
-
thread_id: THREAD_ID,
|
|
68
|
-
title: "Investigate the import",
|
|
69
|
-
updated_at: "2026-07-29T02:00:00Z",
|
|
70
|
-
user_id: USER_ID,
|
|
71
|
-
workblock_id: WORKBLOCK_ID,
|
|
72
|
-
...overrides,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
describe("isConversationBranch", () => {
|
|
76
|
-
it("accepts stream branches and threads under them", () => {
|
|
77
|
-
assert.equal((0, workspace_1.isConversationBranch)(conversationBranch.name), true);
|
|
78
|
-
assert.equal((0, workspace_1.isConversationBranch)(threadBranch.name), true);
|
|
79
|
-
});
|
|
80
|
-
it("rejects every other branch shape", () => {
|
|
81
|
-
assert.equal((0, workspace_1.isConversationBranch)(undefined), false);
|
|
82
|
-
assert.equal((0, workspace_1.isConversationBranch)(""), false);
|
|
83
|
-
assert.equal((0, workspace_1.isConversationBranch)("main"), false);
|
|
84
|
-
assert.equal((0, workspace_1.isConversationBranch)("features/my-feature"), false);
|
|
85
|
-
assert.equal((0, workspace_1.isConversationBranch)(userBranch.name), false);
|
|
86
|
-
assert.equal((0, workspace_1.isConversationBranch)(`features/my-feature@thread/${THREAD_ID}`), false);
|
|
87
|
-
assert.equal((0, workspace_1.isConversationBranch)("features/my-feature@stream/not-a-uuid"), false);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
describe("isFeatureBranch", () => {
|
|
91
|
-
it("accepts only plain version branches", () => {
|
|
92
|
-
assert.equal((0, workspace_1.isFeatureBranch)("features/my-feature"), true);
|
|
93
|
-
assert.equal((0, workspace_1.isFeatureBranch)("main"), false);
|
|
94
|
-
assert.equal((0, workspace_1.isFeatureBranch)("features/"), false);
|
|
95
|
-
assert.equal((0, workspace_1.isFeatureBranch)(userBranch.name), false);
|
|
96
|
-
assert.equal((0, workspace_1.isFeatureBranch)(conversationBranch.name), false);
|
|
97
|
-
assert.equal((0, workspace_1.isFeatureBranch)(`features/my-feature@thread/${THREAD_ID}`), false);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
describe("versionBranchOf", () => {
|
|
101
|
-
it("returns the branch a work branch belongs to", () => {
|
|
102
|
-
assert.equal((0, workspace_1.versionBranchOf)("main"), "main");
|
|
103
|
-
assert.equal((0, workspace_1.versionBranchOf)(`main@thread/${THREAD_ID}`), "main");
|
|
104
|
-
assert.equal((0, workspace_1.versionBranchOf)("features/my-feature"), "features/my-feature");
|
|
105
|
-
assert.equal((0, workspace_1.versionBranchOf)(userBranch.name), "features/my-feature");
|
|
106
|
-
assert.equal((0, workspace_1.versionBranchOf)(conversationBranch.name), "features/my-feature");
|
|
107
|
-
assert.equal((0, workspace_1.versionBranchOf)(threadBranch.name), "features/my-feature");
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe("conversationForkTarget", () => {
|
|
111
|
-
it("names the version branch a conversation forks from", () => {
|
|
112
|
-
assert.equal((0, workspace_1.conversationForkTarget)("features/my-feature"), "features/my-feature");
|
|
113
|
-
assert.equal((0, workspace_1.conversationForkTarget)(userBranch.name), "features/my-feature");
|
|
114
|
-
assert.equal((0, workspace_1.conversationForkTarget)(conversationBranch.name), "features/my-feature");
|
|
115
|
-
assert.equal((0, workspace_1.conversationForkTarget)(threadBranch.name), "features/my-feature");
|
|
116
|
-
assert.equal((0, workspace_1.conversationForkTarget)(`features/my-feature@thread/${THREAD_ID}`), "features/my-feature");
|
|
117
|
-
});
|
|
118
|
-
it("has no target where the server rejects a stream branch", () => {
|
|
119
|
-
assert.equal((0, workspace_1.conversationForkTarget)("main"), undefined);
|
|
120
|
-
assert.equal((0, workspace_1.conversationForkTarget)(`main@thread/${THREAD_ID}`), undefined);
|
|
121
|
-
assert.equal((0, workspace_1.conversationForkTarget)(`main@users/${USER_ID}`), undefined);
|
|
122
|
-
assert.equal((0, workspace_1.conversationForkTarget)("features/"), undefined);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
describe("studioWorkspaceCreationTarget", () => {
|
|
126
|
-
it("attaches main and feature workspaces directly", () => {
|
|
127
|
-
assert.deepEqual((0, workspace_1.studioWorkspaceCreationTarget)("main"), {
|
|
128
|
-
branch: "main",
|
|
129
|
-
createUserBranch: false,
|
|
130
|
-
});
|
|
131
|
-
assert.deepEqual((0, workspace_1.studioWorkspaceCreationTarget)("features/my-feature"), {
|
|
132
|
-
branch: "features/my-feature",
|
|
133
|
-
createUserBranch: false,
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
it("creates a workspace on the selected user branch", () => {
|
|
137
|
-
assert.deepEqual((0, workspace_1.studioWorkspaceCreationTarget)(userBranch.name), {
|
|
138
|
-
branch: "features/my-feature",
|
|
139
|
-
createUserBranch: true,
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
it("does not recreate a conversation branch", () => {
|
|
143
|
-
assert.equal((0, workspace_1.studioWorkspaceCreationTarget)(conversationBranch.name), undefined);
|
|
144
|
-
});
|
|
145
|
-
it("does not create a workspace for any thread branch", () => {
|
|
146
|
-
assert.equal((0, workspace_1.studioWorkspaceCreationTarget)(threadBranch.name), undefined);
|
|
147
|
-
assert.equal((0, workspace_1.studioWorkspaceCreationTarget)(`main@thread/${THREAD_ID}`), undefined);
|
|
148
|
-
assert.equal((0, workspace_1.studioWorkspaceCreationTarget)(`features/my-feature@thread/${THREAD_ID}`), undefined);
|
|
149
|
-
assert.equal((0, workspace_1.studioWorkspaceCreationTarget)(`${userBranch.name}@thread/${THREAD_ID}`), undefined);
|
|
150
|
-
});
|
|
151
|
-
it("treats a malformed stream suffix as a plain branch", () => {
|
|
152
|
-
assert.deepEqual((0, workspace_1.studioWorkspaceCreationTarget)("features/my-feature@stream/not-a-uuid"), {
|
|
153
|
-
branch: "features/my-feature@stream/not-a-uuid",
|
|
154
|
-
createUserBranch: false,
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
describe("stripThreadSuffix", () => {
|
|
159
|
-
it("removes a trailing thread suffix only", () => {
|
|
160
|
-
assert.equal((0, workspace_1.stripThreadSuffix)(threadBranch.name), conversationBranch.name);
|
|
161
|
-
assert.equal((0, workspace_1.stripThreadSuffix)(userBranch.name), userBranch.name);
|
|
162
|
-
assert.equal((0, workspace_1.stripThreadSuffix)("main"), "main");
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
describe("getFeatureName", () => {
|
|
166
|
-
it("returns the version name for user and conversation branches", () => {
|
|
167
|
-
assert.equal((0, workspace_1.getFeatureName)("features/my-feature"), "my-feature");
|
|
168
|
-
assert.equal((0, workspace_1.getFeatureName)(userBranch.name), "my-feature");
|
|
169
|
-
assert.equal((0, workspace_1.getFeatureName)(conversationBranch.name), "my-feature");
|
|
170
|
-
});
|
|
171
|
-
it("returns the version name for thread branches", () => {
|
|
172
|
-
assert.equal((0, workspace_1.getFeatureName)(threadBranch.name), "my-feature");
|
|
173
|
-
assert.equal((0, workspace_1.getFeatureName)(`${userBranch.name}@thread/${THREAD_ID}`), "my-feature");
|
|
174
|
-
assert.equal((0, workspace_1.getFeatureName)(`features/my-feature@thread/${THREAD_ID}`), "my-feature");
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
describe("hasConversationWorkspace", () => {
|
|
178
|
-
it("only counts live workspaces on conversation branches", () => {
|
|
179
|
-
assert.equal((0, workspace_1.hasConversationWorkspace)([]), false);
|
|
180
|
-
assert.equal((0, workspace_1.hasConversationWorkspace)([workspace({ branch: "main" })]), false);
|
|
181
|
-
assert.equal((0, workspace_1.hasConversationWorkspace)([workspace({ branch: userBranch.name })]), false);
|
|
182
|
-
assert.equal((0, workspace_1.hasConversationWorkspace)([workspace({ archived: true })]), false);
|
|
183
|
-
assert.equal((0, workspace_1.hasConversationWorkspace)([workspace()]), true);
|
|
184
|
-
assert.equal((0, workspace_1.hasConversationWorkspace)([workspace({ thread_id: undefined })]), true);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
describe("latestConversationOn", () => {
|
|
188
|
-
it("picks the most recently updated conversation on the version", () => {
|
|
189
|
-
const older = workspace({ id: "older", updated_at: "2026-07-29T02:00:00Z" });
|
|
190
|
-
const newer = workspace({ id: "newer", updated_at: "2026-07-30T02:00:00Z" });
|
|
191
|
-
const otherVersion = workspace({
|
|
192
|
-
id: "other",
|
|
193
|
-
branch: `features/other@stream/${STREAM_ID}`,
|
|
194
|
-
updated_at: "2026-07-31T02:00:00Z",
|
|
195
|
-
});
|
|
196
|
-
assert.equal((0, workspace_1.latestConversationOn)([older, newer, otherVersion], "features/my-feature")?.id, "newer");
|
|
197
|
-
assert.equal((0, workspace_1.latestConversationOn)([otherVersion], "features/my-feature"), undefined);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
describe("mergeActiveConversationBranches", () => {
|
|
201
|
-
it("adds an active conversation with its workspace metadata", () => {
|
|
202
|
-
const result = (0, workspace_1.mergeActiveConversationBranches)([mainBranch], [mainBranch, conversationBranch], [workspace()]);
|
|
203
|
-
assert.deepEqual(result.map((branch) => branch.name), [mainBranch.name, conversationBranch.name]);
|
|
204
|
-
assert.equal(result[1].workspace?.title, "Investigate the import");
|
|
205
|
-
});
|
|
206
|
-
it("keeps legacy conversation rows that have no thread id", () => {
|
|
207
|
-
const result = (0, workspace_1.mergeActiveConversationBranches)([mainBranch], [mainBranch, conversationBranch], [workspace({ thread_id: undefined })]);
|
|
208
|
-
assert.deepEqual(result.map((branch) => branch.name), [mainBranch.name, conversationBranch.name]);
|
|
209
|
-
});
|
|
210
|
-
it("omits archived and missing conversation branches", () => {
|
|
211
|
-
const result = (0, workspace_1.mergeActiveConversationBranches)([mainBranch], [mainBranch, conversationBranch], [
|
|
212
|
-
workspace({ archived: true }),
|
|
213
|
-
workspace({
|
|
214
|
-
branch: `features/missing@stream/6a4ee779-4848-49c7-8eb1-48ce288da35c`,
|
|
215
|
-
}),
|
|
216
|
-
]);
|
|
217
|
-
assert.deepEqual(result, [mainBranch]);
|
|
218
|
-
});
|
|
219
|
-
it("does not inject a workspace on main into the tree", () => {
|
|
220
|
-
const result = (0, workspace_1.mergeActiveConversationBranches)([userBranch], [mainBranch, userBranch], [workspace({ branch: "main" })]);
|
|
221
|
-
assert.deepEqual(result, [userBranch]);
|
|
222
|
-
});
|
|
223
|
-
it("does not relabel a user branch workspace as a conversation", () => {
|
|
224
|
-
const result = (0, workspace_1.mergeActiveConversationBranches)([userBranch], [mainBranch, userBranch], [workspace({ branch: userBranch.name })]);
|
|
225
|
-
assert.deepEqual(result, [userBranch]);
|
|
226
|
-
assert.equal(result[0].workspace, undefined);
|
|
227
|
-
});
|
|
228
|
-
it("ignores workspace rows without a branch", () => {
|
|
229
|
-
const result = (0, workspace_1.mergeActiveConversationBranches)([mainBranch], [mainBranch, conversationBranch], [workspace({ branch: undefined })]);
|
|
230
|
-
assert.deepEqual(result, [mainBranch]);
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
class FakeClient {
|
|
234
|
-
options;
|
|
235
|
-
createCalls = [];
|
|
236
|
-
findCalls = [];
|
|
237
|
-
listCalls = [];
|
|
238
|
-
getCalls = [];
|
|
239
|
-
constructor(options = {}) {
|
|
240
|
-
this.options = options;
|
|
241
|
-
}
|
|
242
|
-
async createStudioWorkspace(_workblockId, branch, title, createUserBranch, createStreamBranch) {
|
|
243
|
-
this.createCalls.push({
|
|
244
|
-
branch,
|
|
245
|
-
title,
|
|
246
|
-
createUserBranch,
|
|
247
|
-
createStreamBranch,
|
|
248
|
-
});
|
|
249
|
-
if (this.options.createError) {
|
|
250
|
-
throw this.options.createError;
|
|
251
|
-
}
|
|
252
|
-
return { id: this.options.createdStreamId ?? "created-stream" };
|
|
253
|
-
}
|
|
254
|
-
async findStudioWorkspaceOnBranch(_workblockId, targetBranch, ignoreErrors) {
|
|
255
|
-
this.findCalls.push({ branch: targetBranch, ignoreErrors });
|
|
256
|
-
if (this.options.findError) {
|
|
257
|
-
throw this.options.findError;
|
|
258
|
-
}
|
|
259
|
-
return this.options.onBranch?.[targetBranch];
|
|
260
|
-
}
|
|
261
|
-
async getStudioWorkspace(streamId, ignoreErrors) {
|
|
262
|
-
this.getCalls.push({ streamId, ignoreErrors });
|
|
263
|
-
if (this.options.accessError) {
|
|
264
|
-
throw this.options.accessError;
|
|
265
|
-
}
|
|
266
|
-
return workspace({ id: streamId });
|
|
267
|
-
}
|
|
268
|
-
async listStudioWorkspaces(userId, workblockId, ignoreErrors) {
|
|
269
|
-
this.listCalls.push({ userId, workblockId, ignoreErrors });
|
|
270
|
-
if (this.options.listError) {
|
|
271
|
-
throw this.options.listError;
|
|
272
|
-
}
|
|
273
|
-
if (userId) {
|
|
274
|
-
if (this.options.userListError) {
|
|
275
|
-
throw this.options.userListError;
|
|
276
|
-
}
|
|
277
|
-
return this.options.workspacesByUser ?? [];
|
|
278
|
-
}
|
|
279
|
-
if (this.options.workblockListError) {
|
|
280
|
-
throw this.options.workblockListError;
|
|
281
|
-
}
|
|
282
|
-
return this.options.workspacesForWorkblock ?? [];
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
function permissionDenied() {
|
|
286
|
-
return Object.assign(new Error("forbidden"), { code: "PermissionDenied" });
|
|
287
|
-
}
|
|
288
|
-
function alreadyExists() {
|
|
289
|
-
return Object.assign(new Error("resource already exists"), {
|
|
290
|
-
code: "AlreadyExists",
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
describe("resolveStudioWorkspace", () => {
|
|
294
|
-
it("reuses the workspace already on the branch", async () => {
|
|
295
|
-
const client = new FakeClient({
|
|
296
|
-
onBranch: { "features/my-feature": "existing" },
|
|
297
|
-
});
|
|
298
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
299
|
-
workblockId: WORKBLOCK_ID,
|
|
300
|
-
branch: "features/my-feature",
|
|
301
|
-
userId: USER_ID,
|
|
302
|
-
});
|
|
303
|
-
assert.deepEqual(resolved, { streamId: "existing", created: false });
|
|
304
|
-
assert.deepEqual(client.createCalls, []);
|
|
305
|
-
});
|
|
306
|
-
it("resolves a thread branch through its parent workspace", async () => {
|
|
307
|
-
const client = new FakeClient({
|
|
308
|
-
onBranch: { [conversationBranch.name]: "existing" },
|
|
309
|
-
});
|
|
310
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
311
|
-
workblockId: WORKBLOCK_ID,
|
|
312
|
-
branch: threadBranch.name,
|
|
313
|
-
userId: USER_ID,
|
|
314
|
-
});
|
|
315
|
-
assert.equal(resolved.streamId, "existing");
|
|
316
|
-
assert.deepEqual(client.findCalls, [
|
|
317
|
-
{ branch: conversationBranch.name, ignoreErrors: true },
|
|
318
|
-
]);
|
|
319
|
-
});
|
|
320
|
-
it("names the version to open when a conversation has no workspace", async () => {
|
|
321
|
-
const client = new FakeClient();
|
|
322
|
-
await assert.rejects((0, workspace_1.resolveStudioWorkspace)(client, {
|
|
323
|
-
workblockId: WORKBLOCK_ID,
|
|
324
|
-
branch: conversationBranch.name,
|
|
325
|
-
userId: USER_ID,
|
|
326
|
-
}), /Open features\/my-feature instead/);
|
|
327
|
-
assert.deepEqual(client.createCalls, []);
|
|
328
|
-
});
|
|
329
|
-
it("never creates a workspace from a thread branch on main", async () => {
|
|
330
|
-
const client = new FakeClient();
|
|
331
|
-
await assert.rejects((0, workspace_1.resolveStudioWorkspace)(client, {
|
|
332
|
-
workblockId: WORKBLOCK_ID,
|
|
333
|
-
branch: `main@thread/${THREAD_ID}`,
|
|
334
|
-
userId: USER_ID,
|
|
335
|
-
}), /Open main instead/);
|
|
336
|
-
assert.deepEqual(client.createCalls, []);
|
|
337
|
-
});
|
|
338
|
-
it("attaches to the version branch when nothing indicates multitask", async () => {
|
|
339
|
-
const client = new FakeClient();
|
|
340
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
341
|
-
workblockId: WORKBLOCK_ID,
|
|
342
|
-
branch: "features/my-feature",
|
|
343
|
-
title: "My workblock (features/my-feature)",
|
|
344
|
-
userId: USER_ID,
|
|
345
|
-
});
|
|
346
|
-
assert.equal(resolved.created, true);
|
|
347
|
-
assert.deepEqual(client.createCalls, [
|
|
348
|
-
{
|
|
349
|
-
branch: "features/my-feature",
|
|
350
|
-
title: "My workblock (features/my-feature)",
|
|
351
|
-
createUserBranch: false,
|
|
352
|
-
createStreamBranch: false,
|
|
353
|
-
},
|
|
354
|
-
]);
|
|
355
|
-
});
|
|
356
|
-
it("forks a conversation branch when multitask is known", async () => {
|
|
357
|
-
const client = new FakeClient();
|
|
358
|
-
await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
359
|
-
workblockId: WORKBLOCK_ID,
|
|
360
|
-
branch: "features/my-feature",
|
|
361
|
-
title: "My workblock (features/my-feature)",
|
|
362
|
-
userId: USER_ID,
|
|
363
|
-
multitask: true,
|
|
364
|
-
});
|
|
365
|
-
assert.deepEqual(client.createCalls, [
|
|
366
|
-
{
|
|
367
|
-
branch: "features/my-feature",
|
|
368
|
-
title: undefined,
|
|
369
|
-
createUserBranch: false,
|
|
370
|
-
createStreamBranch: true,
|
|
371
|
-
},
|
|
372
|
-
]);
|
|
373
|
-
});
|
|
374
|
-
it("infers multitask from the user's own conversations", async () => {
|
|
375
|
-
const client = new FakeClient({
|
|
376
|
-
workspacesByUser: [
|
|
377
|
-
workspace({ branch: `features/other@stream/${STREAM_ID}` }),
|
|
378
|
-
],
|
|
379
|
-
});
|
|
380
|
-
await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
381
|
-
workblockId: WORKBLOCK_ID,
|
|
382
|
-
branch: "features/my-feature",
|
|
383
|
-
userId: USER_ID,
|
|
384
|
-
});
|
|
385
|
-
assert.equal(client.createCalls[0].createStreamBranch, true);
|
|
386
|
-
});
|
|
387
|
-
it("infers multitask from another user's conversation on the workblock", async () => {
|
|
388
|
-
const client = new FakeClient({
|
|
389
|
-
workspacesForWorkblock: [
|
|
390
|
-
workspace({ user_id: "someone-else", id: "theirs" }),
|
|
391
|
-
],
|
|
392
|
-
});
|
|
393
|
-
await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
394
|
-
workblockId: WORKBLOCK_ID,
|
|
395
|
-
branch: "features/my-feature",
|
|
396
|
-
userId: USER_ID,
|
|
397
|
-
});
|
|
398
|
-
assert.equal(client.createCalls[0].createStreamBranch, true);
|
|
399
|
-
});
|
|
400
|
-
it("reuses the user's latest conversation on the version", async () => {
|
|
401
|
-
const client = new FakeClient({
|
|
402
|
-
onBranch: { [conversationBranch.name]: "existing-conversation" },
|
|
403
|
-
workspacesByUser: [workspace()],
|
|
404
|
-
});
|
|
405
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
406
|
-
workblockId: WORKBLOCK_ID,
|
|
407
|
-
branch: "features/my-feature",
|
|
408
|
-
userId: USER_ID,
|
|
409
|
-
multitask: true,
|
|
410
|
-
});
|
|
411
|
-
assert.deepEqual(resolved, {
|
|
412
|
-
streamId: "existing-conversation",
|
|
413
|
-
created: false,
|
|
414
|
-
});
|
|
415
|
-
assert.deepEqual(client.createCalls, []);
|
|
416
|
-
});
|
|
417
|
-
it("creates a fresh conversation when the recorded one is gone", async () => {
|
|
418
|
-
const client = new FakeClient({
|
|
419
|
-
workspacesByUser: [workspace()],
|
|
420
|
-
});
|
|
421
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
422
|
-
workblockId: WORKBLOCK_ID,
|
|
423
|
-
branch: "features/my-feature",
|
|
424
|
-
userId: USER_ID,
|
|
425
|
-
multitask: true,
|
|
426
|
-
});
|
|
427
|
-
assert.equal(resolved.created, true);
|
|
428
|
-
assert.equal(client.createCalls[0].createStreamBranch, true);
|
|
429
|
-
});
|
|
430
|
-
it("requests a user branch without forking a conversation", async () => {
|
|
431
|
-
const client = new FakeClient();
|
|
432
|
-
await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
433
|
-
workblockId: WORKBLOCK_ID,
|
|
434
|
-
branch: userBranch.name,
|
|
435
|
-
userId: USER_ID,
|
|
436
|
-
multitask: true,
|
|
437
|
-
});
|
|
438
|
-
assert.deepEqual(client.createCalls, [
|
|
439
|
-
{
|
|
440
|
-
branch: "features/my-feature",
|
|
441
|
-
title: undefined,
|
|
442
|
-
createUserBranch: true,
|
|
443
|
-
createStreamBranch: false,
|
|
444
|
-
},
|
|
445
|
-
]);
|
|
446
|
-
});
|
|
447
|
-
it("reuses the raced workspace when the branch slot was just claimed", async () => {
|
|
448
|
-
const client = new FakeClient({ createError: alreadyExists() });
|
|
449
|
-
let findCall = 0;
|
|
450
|
-
client.findStudioWorkspaceOnBranch = async (_workblockId, targetBranch, ignoreErrors) => {
|
|
451
|
-
client.findCalls.push({ branch: targetBranch, ignoreErrors });
|
|
452
|
-
findCall += 1;
|
|
453
|
-
return findCall === 1 ? undefined : "raced-stream";
|
|
454
|
-
};
|
|
455
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
456
|
-
workblockId: WORKBLOCK_ID,
|
|
457
|
-
branch: "features/my-feature",
|
|
458
|
-
userId: USER_ID,
|
|
459
|
-
});
|
|
460
|
-
assert.deepEqual(resolved, { streamId: "raced-stream", created: false });
|
|
461
|
-
assert.equal(client.createCalls.length, 1);
|
|
462
|
-
});
|
|
463
|
-
it("matches a branch conflict reported only in the message", async () => {
|
|
464
|
-
const client = new FakeClient({
|
|
465
|
-
createError: new Error("a workspace already exists on this branch"),
|
|
466
|
-
});
|
|
467
|
-
let findCall = 0;
|
|
468
|
-
client.findStudioWorkspaceOnBranch = async (_workblockId, targetBranch, ignoreErrors) => {
|
|
469
|
-
client.findCalls.push({ branch: targetBranch, ignoreErrors });
|
|
470
|
-
findCall += 1;
|
|
471
|
-
return findCall === 1 ? undefined : "raced-stream";
|
|
472
|
-
};
|
|
473
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
474
|
-
workblockId: WORKBLOCK_ID,
|
|
475
|
-
branch: "features/my-feature",
|
|
476
|
-
userId: USER_ID,
|
|
477
|
-
});
|
|
478
|
-
assert.equal(resolved.streamId, "raced-stream");
|
|
479
|
-
});
|
|
480
|
-
it("rethrows create failures that are not branch conflicts", async () => {
|
|
481
|
-
const client = new FakeClient({ createError: new Error("boom") });
|
|
482
|
-
await assert.rejects((0, workspace_1.resolveStudioWorkspace)(client, {
|
|
483
|
-
workblockId: WORKBLOCK_ID,
|
|
484
|
-
branch: "features/my-feature",
|
|
485
|
-
userId: USER_ID,
|
|
486
|
-
}), /boom/);
|
|
487
|
-
});
|
|
488
|
-
it("reports the lookup failure on a branch it cannot create", async () => {
|
|
489
|
-
const client = new FakeClient({ findError: new Error("ws down") });
|
|
490
|
-
await assert.rejects((0, workspace_1.resolveStudioWorkspace)(client, {
|
|
491
|
-
workblockId: WORKBLOCK_ID,
|
|
492
|
-
branch: conversationBranch.name,
|
|
493
|
-
userId: USER_ID,
|
|
494
|
-
}), /ws down/);
|
|
495
|
-
assert.deepEqual(client.createCalls, []);
|
|
496
|
-
});
|
|
497
|
-
it("falls through to create when the workspace lookup fails", async () => {
|
|
498
|
-
const client = new FakeClient({ findError: new Error("ws down") });
|
|
499
|
-
const logged = [];
|
|
500
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
501
|
-
workblockId: WORKBLOCK_ID,
|
|
502
|
-
branch: "features/my-feature",
|
|
503
|
-
userId: USER_ID,
|
|
504
|
-
log: (message) => logged.push(message),
|
|
505
|
-
});
|
|
506
|
-
assert.equal(resolved.created, true);
|
|
507
|
-
assert.ok(logged.some((line) => line.includes("ws down")));
|
|
508
|
-
});
|
|
509
|
-
it("refuses to attach to the version branch when the listing fails", async () => {
|
|
510
|
-
const client = new FakeClient({ listError: new Error("list down") });
|
|
511
|
-
await assert.rejects((0, workspace_1.resolveStudioWorkspace)(client, {
|
|
512
|
-
workblockId: WORKBLOCK_ID,
|
|
513
|
-
branch: "features/my-feature",
|
|
514
|
-
userId: USER_ID,
|
|
515
|
-
}), /Could not tell whether features\/my-feature uses Studio conversations: list down/);
|
|
516
|
-
assert.deepEqual(client.createCalls, []);
|
|
517
|
-
});
|
|
518
|
-
it("still forks a conversation when only the listing fails", async () => {
|
|
519
|
-
const client = new FakeClient({ listError: new Error("list down") });
|
|
520
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
521
|
-
workblockId: WORKBLOCK_ID,
|
|
522
|
-
branch: "features/my-feature",
|
|
523
|
-
userId: USER_ID,
|
|
524
|
-
multitask: true,
|
|
525
|
-
});
|
|
526
|
-
assert.equal(resolved.created, true);
|
|
527
|
-
assert.equal(client.createCalls[0].createStreamBranch, true);
|
|
528
|
-
});
|
|
529
|
-
it("forks when only the tenant-wide listing fails but the user has conversations", async () => {
|
|
530
|
-
const client = new FakeClient({
|
|
531
|
-
workblockListError: new Error("list down"),
|
|
532
|
-
workspacesByUser: [
|
|
533
|
-
workspace({ branch: `features/other@stream/${STREAM_ID}` }),
|
|
534
|
-
],
|
|
535
|
-
});
|
|
536
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
537
|
-
workblockId: WORKBLOCK_ID,
|
|
538
|
-
branch: "features/my-feature",
|
|
539
|
-
userId: USER_ID,
|
|
540
|
-
});
|
|
541
|
-
assert.equal(resolved.created, true);
|
|
542
|
-
assert.equal(client.createCalls[0].createStreamBranch, true);
|
|
543
|
-
});
|
|
544
|
-
it("falls back to the tenant-wide listing when the user's own fails", async () => {
|
|
545
|
-
const client = new FakeClient({
|
|
546
|
-
userListError: new Error("user list down"),
|
|
547
|
-
workspacesForWorkblock: [workspace({ id: "theirs" })],
|
|
548
|
-
});
|
|
549
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
550
|
-
workblockId: WORKBLOCK_ID,
|
|
551
|
-
branch: "features/my-feature",
|
|
552
|
-
userId: USER_ID,
|
|
553
|
-
});
|
|
554
|
-
assert.equal(resolved.created, true);
|
|
555
|
-
assert.equal(client.createCalls[0].createStreamBranch, true);
|
|
556
|
-
});
|
|
557
|
-
it("attaches to the version branch only on a listing that answered", async () => {
|
|
558
|
-
const client = new FakeClient({
|
|
559
|
-
userListError: new Error("user list down"),
|
|
560
|
-
});
|
|
561
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
562
|
-
workblockId: WORKBLOCK_ID,
|
|
563
|
-
branch: "features/my-feature",
|
|
564
|
-
userId: USER_ID,
|
|
565
|
-
});
|
|
566
|
-
assert.equal(resolved.created, true);
|
|
567
|
-
assert.equal(client.createCalls[0].createStreamBranch, false);
|
|
568
|
-
assert.deepEqual(client.listCalls, [
|
|
569
|
-
{ userId: USER_ID, workblockId: WORKBLOCK_ID, ignoreErrors: true },
|
|
570
|
-
{ userId: undefined, workblockId: WORKBLOCK_ID, ignoreErrors: true },
|
|
571
|
-
]);
|
|
572
|
-
});
|
|
573
|
-
it("keeps the failures it handles out of the global error handlers", async () => {
|
|
574
|
-
const client = new FakeClient({
|
|
575
|
-
onBranch: { [conversationBranch.name]: "existing-conversation" },
|
|
576
|
-
workspacesByUser: [workspace()],
|
|
577
|
-
});
|
|
578
|
-
await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
579
|
-
workblockId: WORKBLOCK_ID,
|
|
580
|
-
branch: "features/my-feature",
|
|
581
|
-
userId: USER_ID,
|
|
582
|
-
multitask: true,
|
|
583
|
-
});
|
|
584
|
-
assert.ok(client.findCalls.length > 0);
|
|
585
|
-
assert.ok(client.listCalls.length > 0);
|
|
586
|
-
assert.deepEqual(client.findCalls.map((call) => call.ignoreErrors), client.findCalls.map(() => true));
|
|
587
|
-
assert.deepEqual(client.listCalls.map((call) => call.ignoreErrors), client.listCalls.map(() => true));
|
|
588
|
-
});
|
|
589
|
-
it("probes workspace access without raising a global error", async () => {
|
|
590
|
-
const client = new FakeClient({
|
|
591
|
-
onBranch: { "features/my-feature": "existing" },
|
|
592
|
-
});
|
|
593
|
-
await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
594
|
-
workblockId: WORKBLOCK_ID,
|
|
595
|
-
branch: "features/my-feature",
|
|
596
|
-
userId: USER_ID,
|
|
597
|
-
});
|
|
598
|
-
assert.deepEqual(client.getCalls, [
|
|
599
|
-
{ streamId: "existing", ignoreErrors: true },
|
|
600
|
-
]);
|
|
601
|
-
});
|
|
602
|
-
it("surfaces a branch conflict re-find failure", async () => {
|
|
603
|
-
const client = new FakeClient({ createError: alreadyExists() });
|
|
604
|
-
client.findStudioWorkspaceOnBranch = async (_workblockId, targetBranch, ignoreErrors) => {
|
|
605
|
-
client.findCalls.push({ branch: targetBranch, ignoreErrors });
|
|
606
|
-
if (client.findCalls.length > 1) {
|
|
607
|
-
throw new Error("re-find down");
|
|
608
|
-
}
|
|
609
|
-
return undefined;
|
|
610
|
-
};
|
|
611
|
-
await assert.rejects((0, workspace_1.resolveStudioWorkspace)(client, {
|
|
612
|
-
workblockId: WORKBLOCK_ID,
|
|
613
|
-
branch: "features/my-feature",
|
|
614
|
-
userId: USER_ID,
|
|
615
|
-
}), /re-find down/);
|
|
616
|
-
assert.equal(client.findCalls[client.findCalls.length - 1].ignoreErrors, undefined);
|
|
617
|
-
});
|
|
618
|
-
it("reports the owning workspace instead of a bare permission error", async () => {
|
|
619
|
-
const client = new FakeClient({
|
|
620
|
-
onBranch: { "features/my-feature": "teammates-stream" },
|
|
621
|
-
accessError: permissionDenied(),
|
|
622
|
-
workspacesForWorkblock: [
|
|
623
|
-
workspace({ id: "teammates-stream", title: "Ada's workspace" }),
|
|
624
|
-
],
|
|
625
|
-
});
|
|
626
|
-
await assert.rejects((0, workspace_1.resolveStudioWorkspace)(client, {
|
|
627
|
-
workblockId: WORKBLOCK_ID,
|
|
628
|
-
branch: "features/my-feature",
|
|
629
|
-
userId: USER_ID,
|
|
630
|
-
}), /Ada's workspace/);
|
|
631
|
-
assert.deepEqual(client.createCalls, []);
|
|
632
|
-
});
|
|
633
|
-
it("still opens a workspace when the access probe fails for other reasons", async () => {
|
|
634
|
-
const client = new FakeClient({
|
|
635
|
-
onBranch: { "features/my-feature": "existing" },
|
|
636
|
-
accessError: new Error("probe down"),
|
|
637
|
-
});
|
|
638
|
-
const resolved = await (0, workspace_1.resolveStudioWorkspace)(client, {
|
|
639
|
-
workblockId: WORKBLOCK_ID,
|
|
640
|
-
branch: "features/my-feature",
|
|
641
|
-
userId: USER_ID,
|
|
642
|
-
});
|
|
643
|
-
assert.equal(resolved.streamId, "existing");
|
|
644
|
-
});
|
|
645
|
-
});
|
|
646
|
-
describe("createConversationWorkspace", () => {
|
|
647
|
-
it("forks a conversation branch from a version branch", async () => {
|
|
648
|
-
const client = new FakeClient({ createdStreamId: "new-conversation" });
|
|
649
|
-
const stream = await (0, workspace_1.createConversationWorkspace)(client, WORKBLOCK_ID, "features/my-feature");
|
|
650
|
-
assert.equal(stream.id, "new-conversation");
|
|
651
|
-
assert.deepEqual(client.createCalls, [
|
|
652
|
-
{
|
|
653
|
-
branch: "features/my-feature",
|
|
654
|
-
title: undefined,
|
|
655
|
-
createUserBranch: false,
|
|
656
|
-
createStreamBranch: true,
|
|
657
|
-
},
|
|
658
|
-
]);
|
|
659
|
-
});
|
|
660
|
-
it("refuses to fork from anything but a version branch", async () => {
|
|
661
|
-
const client = new FakeClient();
|
|
662
|
-
await assert.rejects((0, workspace_1.createConversationWorkspace)(client, WORKBLOCK_ID, conversationBranch.name), /not one/);
|
|
663
|
-
assert.deepEqual(client.createCalls, []);
|
|
664
|
-
});
|
|
665
|
-
});
|
|
666
|
-
//# sourceMappingURL=workspace.test.js.map
|