@beyondwork/wb-cli 0.1.12 → 0.1.14
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 +18 -0
- package/README.md +113 -0
- package/media/icon.png +0 -0
- package/out/extension.js +67 -1
- package/package.json +17 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v0.1.14
|
|
4
|
+
|
|
5
|
+
- Documentation updates.
|
|
6
|
+
|
|
7
|
+
## v0.1.13
|
|
8
|
+
|
|
9
|
+
- Make it easier to import a workblock that only exists on the filesystem. Right-click on a connection, select `Store new workblock`. This will import the workblock and bind it to the local dir.
|
|
10
|
+
|
|
11
|
+
## v0.1.12
|
|
12
|
+
|
|
13
|
+
- Automatically map local directories to remote workspaces.
|
|
14
|
+
|
|
15
|
+
## v0.1.11
|
|
16
|
+
|
|
17
|
+
- Better error handling and display.
|
|
18
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Beyond Work
|
|
2
|
+
|
|
3
|
+
This extension and cli is for interacting with the Beyond Work platform. This package provides both a VS Code extension and a command-line interface (CLI) for working with Beyond Work workblocks.
|
|
4
|
+
|
|
5
|
+
# VS Code Extension
|
|
6
|
+
|
|
7
|
+
The Beyond Work VS Code extension enables developers to write, test, and manage Workblocks directly within Visual Studio Code. Using a remote file system, it provides direct access to your Beyond Work Workblocks, making it the ideal tool for developers who want a full-featured editor for creating and updating Workblocks.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Use this to edit workblocks via VSCode. The extension allows you to connect to Beyond Work and bind workblocks to directories on your local machine.
|
|
12
|
+
The workblocks in those workspaces can then be stored as files on your local machine.
|
|
13
|
+
|
|
14
|
+
The extension has 3 features:
|
|
15
|
+
|
|
16
|
+
- Get a work block from an existing workspace to local filesystem
|
|
17
|
+
- Set a work block on a workspace from local files
|
|
18
|
+
- Live sync work blocks between open workspaces and local filesystem
|
|
19
|
+
|
|
20
|
+
Work blocks are expected to be placed in a directory that contains nothing but work blocks. When starting from scratch simply create a new directory somewhere.
|
|
21
|
+
|
|
22
|
+
### Getting started
|
|
23
|
+
|
|
24
|
+
First step is to create a new connection. Click the `+` button in the BEYOND WORK sidebar, or use CMD-SHIFT-P and type `Beyond Work: Add Connection`.
|
|
25
|
+
Then, enter the hostname of the Beyond Work instance you want to connect to. This is the same hostname you use to access the web UI.
|
|
26
|
+
|
|
27
|
+
Then, click on the connection in the BEYOND WORK sidebar. This will prompt for an API key. You can get this by creating a new token under the account settings.
|
|
28
|
+
|
|
29
|
+
The connection should now have a blue checkmark. Under it, workspaces with an open editor will be shown. Each of them can be bound to a directory by clicking on them
|
|
30
|
+
and choosing `Choose a directory`.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Getting a work block
|
|
34
|
+
|
|
35
|
+
Click a workspace in the menu and choose \`Get workblock from workspace\`. This takes the work block that's in the workspace provided and downloads it to the directory associated with the workspace.
|
|
36
|
+
|
|
37
|
+
### Setting a work block
|
|
38
|
+
|
|
39
|
+
Click a workspace in the menu and choose \`Store workblock to workspace\`. This takes the work block files in the associated directory and combines them into a work block definition and sets it in the workspace provided.
|
|
40
|
+
|
|
41
|
+
Note that this does not actually store the work block outside the workspace. In order to do that open the work block editor in the workspace and click store.
|
|
42
|
+
|
|
43
|
+
### Syncing work blocks
|
|
44
|
+
|
|
45
|
+
Click a workspace in the menu and choose \`Enable sync\`.
|
|
46
|
+
|
|
47
|
+
If a workblock is changed in the UI, either via the editor or by an agent, that change will be reflected in the local files. If local files are changed they are automatically set on the workspace. It's possible to have the UI editor open while editing files locally, the editor will update live as files are saved.
|
|
48
|
+
|
|
49
|
+
Notice that workblocks are validated before they are set on a workspace. If a workblock is not valid, errors will be shown in the files.
|
|
50
|
+
|
|
51
|
+
### Directory structure
|
|
52
|
+
|
|
53
|
+
The work block directory structure is like this:
|
|
54
|
+
|
|
55
|
+
<pre>
|
|
56
|
+
Base dir/
|
|
57
|
+
work_block_1/
|
|
58
|
+
task_1/
|
|
59
|
+
assets/
|
|
60
|
+
asset1.txt
|
|
61
|
+
task_1.py
|
|
62
|
+
manifest.yaml
|
|
63
|
+
</pre>
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## CLI Tool
|
|
67
|
+
|
|
68
|
+
In addition to the VS Code extension, this package provides a command-line interface (CLI) for working with Beyond Work workblocks.
|
|
69
|
+
|
|
70
|
+
### Installation as a CLI tool
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm install -g beyondwork
|
|
74
|
+
# or
|
|
75
|
+
yarn global add beyondwork
|
|
76
|
+
# or
|
|
77
|
+
pnpm add -g beyondwork
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### CLI Usage
|
|
81
|
+
|
|
82
|
+
#### Assemble a workblock from a directory
|
|
83
|
+
```bash
|
|
84
|
+
beyondwork assemble /path/to/workblock/dir [--output output.json]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This command takes a directory containing workblock files and assembles them into a complete workblock JSON object. The structure follows the Beyond Work format:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
Base dir/
|
|
91
|
+
work_block_1/
|
|
92
|
+
task_1/
|
|
93
|
+
assets/
|
|
94
|
+
asset1.txt
|
|
95
|
+
task_1.py
|
|
96
|
+
manifest.yaml
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Programmatic Usage
|
|
100
|
+
|
|
101
|
+
You can also use the library programmatically:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { assembleWorkblock, storeWorkblockFiles } from 'beyondwork/lib/utils';
|
|
105
|
+
|
|
106
|
+
// Assemble a workblock from files
|
|
107
|
+
const workblock = await assembleWorkblock('/path/to/workblock');
|
|
108
|
+
|
|
109
|
+
// Store a workblock as files
|
|
110
|
+
await storeWorkblockFiles('/output/path', workblockObject);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
|
package/media/icon.png
ADDED
|
Binary file
|
package/out/extension.js
CHANGED
|
@@ -259,6 +259,72 @@ function activate(context) {
|
|
|
259
259
|
treeDataProvider.removeConnection(connection);
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
|
+
const storeNewWorkblock = vscode.commands.registerCommand("beyondwork.beyondwork.storeWorkblock", async (item) => {
|
|
263
|
+
outputChannel.appendLine(`Store new workblock`);
|
|
264
|
+
const opts = {
|
|
265
|
+
canSelectFolders: true,
|
|
266
|
+
canSelectFiles: false,
|
|
267
|
+
canSelectMany: false,
|
|
268
|
+
openLabel: "Select folder for the workblock",
|
|
269
|
+
};
|
|
270
|
+
const baseDir = await vscode.window.showOpenDialog(opts);
|
|
271
|
+
if (!baseDir?.length) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const manifestDir = await (0, lib_1.locateManifest)(baseDir[0].fsPath);
|
|
275
|
+
if (!manifestDir) {
|
|
276
|
+
vscode.window.showErrorMessage(`No manifest.yaml found in selected directory`);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
// Assemble workblock from selected directory
|
|
280
|
+
const wb = await (0, lib_1.assembleWorkblock)(baseDir[0].fsPath, outputLogger);
|
|
281
|
+
if (!wb) {
|
|
282
|
+
vscode.window.showErrorMessage("Failed to assemble workblock from directory");
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const host = item?.connection?.host;
|
|
286
|
+
if (!host) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const client = clientsByHost[host];
|
|
290
|
+
if (!client) {
|
|
291
|
+
vscode.window.showErrorMessage(`Not connected to ${host}`);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
outputChannel.appendLine(`Creating new stream for workblock '${wb.name}' on host ${host}`);
|
|
295
|
+
try {
|
|
296
|
+
const stream = await client.storeWorkblock(wb);
|
|
297
|
+
outputChannel.appendLine(`Created stream ${stream.id} (${stream.title})`);
|
|
298
|
+
// Ensure host mapping structures exist
|
|
299
|
+
if (!streamsByHost[host]) {
|
|
300
|
+
streamsByHost[host] = [];
|
|
301
|
+
}
|
|
302
|
+
hostsByStream[stream.id] = host;
|
|
303
|
+
// Insert new stream into list if not present
|
|
304
|
+
if (!streamsByHost[host].some((s) => s.id === stream.id)) {
|
|
305
|
+
streamsByHost[host].push({
|
|
306
|
+
id: stream.id,
|
|
307
|
+
editing: stream.editing ?? true,
|
|
308
|
+
title: stream.title ?? wb.name,
|
|
309
|
+
});
|
|
310
|
+
streamsByHost[host] = streamsByHost[host].sort((a, b) => a.title.localeCompare(b.title));
|
|
311
|
+
}
|
|
312
|
+
// Bind directory to stream
|
|
313
|
+
streamsByDir[stream.id] = baseDir[0].fsPath;
|
|
314
|
+
context.globalState.update("bw_streams_dir", streamsByDir);
|
|
315
|
+
// Store latest workblock for change tracking
|
|
316
|
+
latestWorkblocks[host + stream.id] = wb;
|
|
317
|
+
// Update tree view
|
|
318
|
+
treeDataProvider.setStreamsForHost(host, streamsByHost[host]);
|
|
319
|
+
treeDataProvider.refresh();
|
|
320
|
+
vscode.window.showInformationMessage(`Created and bound new stream '${stream.title}'`);
|
|
321
|
+
}
|
|
322
|
+
catch (e) {
|
|
323
|
+
const msg = e?.message ?? String(e);
|
|
324
|
+
outputChannel.appendLine(`Failed to create stream: ${msg}`);
|
|
325
|
+
vscode.window.showErrorMessage(`Failed to create stream: ${msg}`);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
262
328
|
const bindStream = vscode.commands.registerCommand("beyondwork.beyondwork.bindStream", async (stream, dir) => {
|
|
263
329
|
outputChannel.appendLine(`Binding stream ${stream.id} ${dir}`);
|
|
264
330
|
const opts = {
|
|
@@ -486,7 +552,7 @@ Base dir/
|
|
|
486
552
|
const saveListener = vscode.workspace.onDidSaveTextDocument((doc) => {
|
|
487
553
|
onFileChange(doc.uri, true);
|
|
488
554
|
});
|
|
489
|
-
context.subscriptions.push(providerReg, addConnectionCmd, connectToTenantCmd, clearConnectionsCmd, removeConnectionCmd, bindStream, getWB, setWB, streamOptions, syncSelected, help, watcher, treeView, outputChannel, diagnosticCollection, saveListener);
|
|
555
|
+
context.subscriptions.push(providerReg, addConnectionCmd, connectToTenantCmd, clearConnectionsCmd, removeConnectionCmd, storeNewWorkblock, bindStream, getWB, setWB, streamOptions, syncSelected, help, watcher, treeView, outputChannel, diagnosticCollection, saveListener);
|
|
490
556
|
}
|
|
491
557
|
function deactivate() {
|
|
492
558
|
for (const [key, cl] of Object.entries(clientsByHost)) {
|
package/package.json
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
"name": "@beyondwork/wb-cli",
|
|
3
3
|
"publisher": "beyondwork",
|
|
4
4
|
"displayName": "Beyond Work",
|
|
5
|
-
"description": "
|
|
6
|
-
"version": "0.1.
|
|
5
|
+
"description": "Tool for interacting with Beyond Work workblocks from VS Code and CLI.",
|
|
6
|
+
"version": "0.1.14",
|
|
7
|
+
"icon": "media/icon.png",
|
|
7
8
|
"engines": {
|
|
8
9
|
"vscode": "^1.94.0",
|
|
9
10
|
"node": ">=16.0.0"
|
|
@@ -17,7 +18,11 @@
|
|
|
17
18
|
"files": [
|
|
18
19
|
"out/lib/**/*",
|
|
19
20
|
"out/cli.js",
|
|
20
|
-
"out/extension.js"
|
|
21
|
+
"out/extension.js",
|
|
22
|
+
"media/icon.png",
|
|
23
|
+
"CHANGELOG.md",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE.txt"
|
|
21
26
|
],
|
|
22
27
|
"main": "./out/extension.js",
|
|
23
28
|
"private": false,
|
|
@@ -42,6 +47,10 @@
|
|
|
42
47
|
"title": "Beyond Work: Remove Connection",
|
|
43
48
|
"icon": "$(trash)"
|
|
44
49
|
},
|
|
50
|
+
{
|
|
51
|
+
"command": "beyondwork.beyondwork.storeWorkblock",
|
|
52
|
+
"title": "Beyond Work: Store new workblock"
|
|
53
|
+
},
|
|
45
54
|
{
|
|
46
55
|
"command": "beyondwork.beyondwork.help",
|
|
47
56
|
"title": "Beyond Work: Help",
|
|
@@ -71,6 +80,11 @@
|
|
|
71
80
|
"command": "beyondwork.beyondwork.removeConnection",
|
|
72
81
|
"when": "view == beyondworkConnections",
|
|
73
82
|
"group": "navigation"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"command": "beyondwork.beyondwork.storeWorkblock",
|
|
86
|
+
"when": "view == beyondworkConnections",
|
|
87
|
+
"group": "navigation"
|
|
74
88
|
}
|
|
75
89
|
]
|
|
76
90
|
},
|