@beyondwork/wb-cli 0.1.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/LICENSE.txt +33 -0
- package/out/cli.js +85 -0
- package/out/extension.js +592 -0
- package/out/lib/index.js +27 -0
- package/out/lib/index.js.map +1 -0
- package/out/lib/logger.js +28 -0
- package/out/lib/logger.js.map +1 -0
- package/out/lib/workblock.js +185 -0
- package/out/lib/workblock.js.map +1 -0
- package/package.json +130 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 BeyondWork. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are proprietary
|
|
6
|
+
and confidential. The Software is protected by copyright law and international
|
|
7
|
+
treaties.
|
|
8
|
+
|
|
9
|
+
Use of the Software is subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
1. NO DISTRIBUTION: You may not distribute, share, sublicense, lend, lease, or
|
|
12
|
+
transfer the Software or any portion thereof to any third party.
|
|
13
|
+
|
|
14
|
+
2. NO MODIFICATION: You may not modify, adapt, translate, reverse engineer,
|
|
15
|
+
decompile, disassemble, or create derivative works based on the Software.
|
|
16
|
+
|
|
17
|
+
3. NO COPYING: You may not copy the Software except as specifically allowed by
|
|
18
|
+
applicable licensing terms.
|
|
19
|
+
|
|
20
|
+
4. PROPRIETARY RIGHTS: All title, ownership rights, and intellectual property
|
|
21
|
+
rights in and to the Software shall remain with Beyond Work.
|
|
22
|
+
|
|
23
|
+
5. UPDATES: Beyond Work reserves the right to update, modify, or discontinue the
|
|
24
|
+
Software at any time without notice.
|
|
25
|
+
|
|
26
|
+
6. TERMINATION: Your rights under this license will terminate automatically if you
|
|
27
|
+
fail to comply with any of its terms.
|
|
28
|
+
|
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
30
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
31
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL BEYONDWORK BE LIABLE
|
|
32
|
+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM THE SOFTWARE OR THE USE OR
|
|
33
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/out/cli.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const commander_1 = require("commander");
|
|
40
|
+
const lib_1 = require("./lib");
|
|
41
|
+
// Setup logger
|
|
42
|
+
const logger = new lib_1.ConsoleLogger();
|
|
43
|
+
// Define CLI
|
|
44
|
+
commander_1.program
|
|
45
|
+
.name('beyondwork')
|
|
46
|
+
.description('CLI for working with Beyond Work workblocks')
|
|
47
|
+
.version(process.env.npm_package_version || '0.0.0');
|
|
48
|
+
commander_1.program
|
|
49
|
+
.command('assemble <directory>')
|
|
50
|
+
.description('Assemble a workblock from a directory')
|
|
51
|
+
.option('-o, --output <file>', 'Output file (defaults to stdout)')
|
|
52
|
+
.action(async (directory, options) => {
|
|
53
|
+
try {
|
|
54
|
+
// Resolve absolute path
|
|
55
|
+
const dirPath = path.resolve(directory);
|
|
56
|
+
// Check if directory exists
|
|
57
|
+
if (!fs.existsSync(dirPath)) {
|
|
58
|
+
logger.error(`Directory does not exist: ${dirPath}`);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
// Assemble workblock
|
|
62
|
+
const workblock = await (0, lib_1.assembleWorkblock)(dirPath, logger);
|
|
63
|
+
if (!workblock) {
|
|
64
|
+
logger.error('Failed to assemble workblock');
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
// Format output
|
|
68
|
+
const output = JSON.stringify(workblock, null, 2);
|
|
69
|
+
// Write to file or stdout
|
|
70
|
+
if (options.output) {
|
|
71
|
+
const outputPath = path.resolve(options.output);
|
|
72
|
+
fs.writeFileSync(outputPath, output);
|
|
73
|
+
logger.log(`Workblock written to ${outputPath}`);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
process.stdout.write(output);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
logger.error(`Error: ${error}`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
commander_1.program.parse();
|
|
85
|
+
//# sourceMappingURL=cli.js.map
|
package/out/extension.js
ADDED
|
@@ -0,0 +1,592 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.connectToHost = connectToHost;
|
|
40
|
+
exports.activate = activate;
|
|
41
|
+
exports.deactivate = deactivate;
|
|
42
|
+
const vscode = __importStar(require("vscode"));
|
|
43
|
+
const client_1 = require("./client");
|
|
44
|
+
const tree_data_provider_1 = require("./tree_data_provider");
|
|
45
|
+
const types_1 = require("./types");
|
|
46
|
+
const auth_1 = require("./auth");
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const yaml_1 = require("yaml");
|
|
50
|
+
const markdown_it_1 = __importDefault(require("markdown-it"));
|
|
51
|
+
const lib_1 = require("./lib");
|
|
52
|
+
const clientsByHost = {};
|
|
53
|
+
let diagnosticCollection;
|
|
54
|
+
let outputChannel;
|
|
55
|
+
let streamsByDir;
|
|
56
|
+
let hostsByStream;
|
|
57
|
+
let syncStreams;
|
|
58
|
+
let streamsByHost;
|
|
59
|
+
let latestWorkblocks;
|
|
60
|
+
let outputLogger;
|
|
61
|
+
async function onWorkblockChange(streamId, workblock, treeDataProvider, host) {
|
|
62
|
+
console.log("onWorkblockChange", streamId, workblock?.state);
|
|
63
|
+
if (!workblock) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const dir = streamsByDir[streamId];
|
|
67
|
+
if (!dir) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const localWb = await (0, lib_1.assembleWorkblock)(dir, outputLogger);
|
|
71
|
+
if (!localWb) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const uWb = (0, lib_1.trimWorkblock)(workblock);
|
|
75
|
+
const uLocalWb = (0, lib_1.trimWorkblock)(localWb);
|
|
76
|
+
treeDataProvider.setSyncStatus(host, streamId, JSON.stringify(uWb) !== JSON.stringify(uLocalWb));
|
|
77
|
+
}
|
|
78
|
+
async function connectToHost(host, context, treeDataProvider) {
|
|
79
|
+
if (clientsByHost[host]) {
|
|
80
|
+
clientsByHost[host].disconnect();
|
|
81
|
+
delete clientsByHost[host];
|
|
82
|
+
}
|
|
83
|
+
const token = await (0, auth_1.getApiToken)(context, host);
|
|
84
|
+
if (!token) {
|
|
85
|
+
throw new Error(`Failed to retrieve token for ${host}.`);
|
|
86
|
+
}
|
|
87
|
+
const newClient = new client_1.BeyondWorkClient();
|
|
88
|
+
newClient.addStreamHandler((message) => {
|
|
89
|
+
treeDataProvider.setStreamsForHost(host, message);
|
|
90
|
+
treeDataProvider.updateConnectionStatus(host, 'connected');
|
|
91
|
+
streamsByHost[host] = message;
|
|
92
|
+
hostsByStream = {};
|
|
93
|
+
for (const stream of message) {
|
|
94
|
+
hostsByStream[stream.id] = host;
|
|
95
|
+
}
|
|
96
|
+
Promise.all(message.map(async (stream) => {
|
|
97
|
+
return await newClient.getWorkblock(stream.id);
|
|
98
|
+
})).then((workblocks) => {
|
|
99
|
+
workblocks.map((wb, idx) => {
|
|
100
|
+
onWorkblockChange(message[idx].id, wb, treeDataProvider, host);
|
|
101
|
+
if (wb) {
|
|
102
|
+
latestWorkblocks[host + message[idx].id] = wb;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
console.log("got workblocks", workblocks);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
newClient.addEventHandler(async (message) => {
|
|
109
|
+
for (const msg of message) {
|
|
110
|
+
if (msg.type == "workblock") {
|
|
111
|
+
if (syncStreams[msg.stream_id] !== undefined && msg.work_block?.work_block) {
|
|
112
|
+
await storeWorkblockFiles(syncStreams[msg.stream_id], msg.work_block?.work_block, newClient);
|
|
113
|
+
}
|
|
114
|
+
await onWorkblockChange(msg.stream_id, msg.work_block?.work_block, treeDataProvider, host);
|
|
115
|
+
latestWorkblocks[host + msg.stream_id] = msg.work_block?.work_block;
|
|
116
|
+
}
|
|
117
|
+
if (msg.type == "stream") {
|
|
118
|
+
if (msg.stream?.stream?.editing) {
|
|
119
|
+
hostsByStream[msg.stream?.stream?.id] = host;
|
|
120
|
+
streamsByHost[host].push({
|
|
121
|
+
id: msg.stream?.stream?.id,
|
|
122
|
+
editing: msg.stream?.stream?.editing,
|
|
123
|
+
title: msg.stream?.stream?.title,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
streamsByHost[host] = streamsByHost[host].filter(s => s.id !== msg.stream?.stream?.id);
|
|
128
|
+
}
|
|
129
|
+
streamsByHost[host] = streamsByHost[host].sort((a, b) => a.title.localeCompare(b.title));
|
|
130
|
+
treeDataProvider.setStreamsForHost(host, streamsByHost[host]);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
newClient.addOnDisconnect(() => {
|
|
135
|
+
treeDataProvider.updateConnectionStatus(host, 'disconnected');
|
|
136
|
+
});
|
|
137
|
+
newClient.connect(host, token, context);
|
|
138
|
+
clientsByHost[host] = newClient;
|
|
139
|
+
context.globalState.update('bw_current_connection', host);
|
|
140
|
+
return newClient;
|
|
141
|
+
}
|
|
142
|
+
function activate(context) {
|
|
143
|
+
diagnosticCollection = vscode.languages.createDiagnosticCollection('validation');
|
|
144
|
+
outputChannel = vscode.window.createOutputChannel('Beyond Work');
|
|
145
|
+
outputLogger = new lib_1.VSCodeLogger(outputChannel);
|
|
146
|
+
streamsByDir = context.globalState.get('bw_streams_dir') ?? {};
|
|
147
|
+
syncStreams = context.globalState.get('bw_sync_streams') ?? {};
|
|
148
|
+
hostsByStream = {};
|
|
149
|
+
streamsByHost = {};
|
|
150
|
+
latestWorkblocks = {};
|
|
151
|
+
const treeDataProvider = new tree_data_provider_1.BeyondWorkTreeDataProvider(context, streamsByDir, syncStreams);
|
|
152
|
+
const treeView = vscode.window.createTreeView('beyondworkConnections', {
|
|
153
|
+
treeDataProvider: treeDataProvider,
|
|
154
|
+
showCollapseAll: false,
|
|
155
|
+
canSelectMany: true,
|
|
156
|
+
});
|
|
157
|
+
const stringContentProvider = new StringDocumentContentProvider();
|
|
158
|
+
const providerReg = vscode.workspace.registerTextDocumentContentProvider("bw-manifest", stringContentProvider);
|
|
159
|
+
const onFileChange = async (uri, sync) => {
|
|
160
|
+
const ignorePatterns = ['node_modules/', '.git/'];
|
|
161
|
+
if (ignorePatterns.some((pattern) => uri.fsPath.includes(pattern))) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
for (const [streamId, dir] of Object.entries(streamsByDir)) {
|
|
165
|
+
if (uri.fsPath.startsWith(dir)) {
|
|
166
|
+
const host = hostsByStream[streamId];
|
|
167
|
+
if (host) {
|
|
168
|
+
if (syncStreams[streamId] !== undefined && sync) {
|
|
169
|
+
await setWorkblock(dir, host, streamId).then(() => {
|
|
170
|
+
;
|
|
171
|
+
treeDataProvider.setSyncStatus(host, streamId, false);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
await onWorkblockChange(streamId, latestWorkblocks[host + streamId], treeDataProvider, host);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const addConnectionCmd = vscode.commands.registerCommand('beyondwork.beyondwork.addConnection', async () => {
|
|
182
|
+
let host = await vscode.window.showInputBox({
|
|
183
|
+
prompt: 'Enter the hostname you want to connect to',
|
|
184
|
+
placeHolder: 'Hostname (eg. acme.prod-eu1.bworker.ai)',
|
|
185
|
+
validateInput: (value) => {
|
|
186
|
+
try {
|
|
187
|
+
new URL(`${value.startsWith('https://') ? '' : 'https://'}${value}`);
|
|
188
|
+
return null; // valid
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
return 'Please enter a valid hostname';
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
if (!host) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
treeDataProvider.addConnection({
|
|
199
|
+
host,
|
|
200
|
+
status: 'disconnected'
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
const connectToTenantCmd = vscode.commands.registerCommand('beyondwork.beyondwork.connectToTenant', async (tenant) => {
|
|
204
|
+
tenant.status = 'connecting';
|
|
205
|
+
treeDataProvider.updateConnectionStatus(tenant.host, 'connecting');
|
|
206
|
+
await connectToHost(tenant.host, context, treeDataProvider);
|
|
207
|
+
});
|
|
208
|
+
const clearConnectionsCmd = vscode.commands.registerCommand('beyondwork.beyondwork.clearConnections', () => {
|
|
209
|
+
// Clear from tree, and remove all token references
|
|
210
|
+
(0, auth_1.clearApiTokens)(context);
|
|
211
|
+
treeDataProvider.clear();
|
|
212
|
+
// Disconnect all active clients
|
|
213
|
+
for (const host in clientsByHost) {
|
|
214
|
+
clientsByHost[host].disconnect();
|
|
215
|
+
delete clientsByHost[host];
|
|
216
|
+
}
|
|
217
|
+
vscode.window.showInformationMessage('All connections cleared.');
|
|
218
|
+
});
|
|
219
|
+
const removeConnectionCmd = vscode.commands.registerCommand('beyondwork.beyondwork.removeConnection', async (item) => {
|
|
220
|
+
let connection;
|
|
221
|
+
if (item) {
|
|
222
|
+
connection = item.connection;
|
|
223
|
+
}
|
|
224
|
+
if (!connection) {
|
|
225
|
+
const all = treeDataProvider.getConnections();
|
|
226
|
+
if (all.length === 0) {
|
|
227
|
+
vscode.window.showInformationMessage('No connections to remove.');
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const picked = await vscode.window.showQuickPick(all.map(c => ({ label: c.host, description: c.status, connection: c })), { placeHolder: 'Select a connection to remove' });
|
|
231
|
+
connection = picked?.connection;
|
|
232
|
+
}
|
|
233
|
+
if (!connection)
|
|
234
|
+
return;
|
|
235
|
+
const yesNo = await vscode.window.showWarningMessage(`Are you sure you want to remove the connection to ${connection.host}?`, 'Yes', 'No');
|
|
236
|
+
if (yesNo === 'Yes') {
|
|
237
|
+
// Disconnect & remove from tree
|
|
238
|
+
if (clientsByHost[connection.host]) {
|
|
239
|
+
clientsByHost[connection.host].disconnect();
|
|
240
|
+
delete clientsByHost[connection.host];
|
|
241
|
+
}
|
|
242
|
+
treeDataProvider.removeConnection(connection);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
const bindStream = vscode.commands.registerCommand('beyondwork.beyondwork.bindStream', async (stream, dir) => {
|
|
246
|
+
outputChannel.appendLine(`Binding stream ${stream.id} ${dir}`);
|
|
247
|
+
const opts = {
|
|
248
|
+
canSelectFolders: true,
|
|
249
|
+
canSelectFiles: false,
|
|
250
|
+
canSelectMany: false,
|
|
251
|
+
openLabel: 'Select folder for the workblock'
|
|
252
|
+
};
|
|
253
|
+
if (dir) {
|
|
254
|
+
opts.defaultUri = vscode.Uri.file(dir);
|
|
255
|
+
}
|
|
256
|
+
const baseDir = await vscode.window.showOpenDialog(opts);
|
|
257
|
+
if (!baseDir?.length) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
streamsByDir[stream.id] = baseDir[0].fsPath;
|
|
261
|
+
context.globalState.update('bw_streams_dir', streamsByDir);
|
|
262
|
+
treeDataProvider.refresh();
|
|
263
|
+
});
|
|
264
|
+
const getWB = vscode.commands.registerCommand('beyondwork.beyondwork.get', async (item) => {
|
|
265
|
+
outputChannel.appendLine(`Getting workblock ${item.stream}`);
|
|
266
|
+
if (!item.dir) {
|
|
267
|
+
vscode.window.showErrorMessage('Please bind a directory to the stream first');
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const client = clientsByHost[item.connection.host];
|
|
271
|
+
const wb = await client.getWorkblock(item.stream.id);
|
|
272
|
+
outputChannel.appendLine(`Got workblock ${wb}`);
|
|
273
|
+
if (!wb) {
|
|
274
|
+
vscode.window.showErrorMessage('No workblock in workspace');
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
storeWorkblockFiles(item.dir, wb, client);
|
|
278
|
+
});
|
|
279
|
+
const setWB = vscode.commands.registerCommand('beyondwork.beyondwork.set', async (item) => {
|
|
280
|
+
outputChannel.appendLine(`Setting workblock ${item.stream}`);
|
|
281
|
+
if (!item.dir) {
|
|
282
|
+
vscode.window.showErrorMessage('Please bind a directory to the stream first');
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
setWorkblock(item.dir, item.connection.host, item.stream.id);
|
|
286
|
+
});
|
|
287
|
+
const compareChanges = async (item) => {
|
|
288
|
+
const wb = await (0, lib_1.assembleWorkblock)(item.dir, outputLogger);
|
|
289
|
+
const stored = await clientsByHost[item.connection.host].getWorkblock(item.stream.id);
|
|
290
|
+
const file1 = vscode.Uri.parse('bw-manifest:local.yaml');
|
|
291
|
+
const file2 = vscode.Uri.parse('bw-manifest:stored.yaml');
|
|
292
|
+
if (wb) {
|
|
293
|
+
stringContentProvider.setContent(file1, (0, yaml_1.stringify)((0, lib_1.trimWorkblock)(wb)));
|
|
294
|
+
}
|
|
295
|
+
if (stored) {
|
|
296
|
+
stringContentProvider.setContent(file2, (0, yaml_1.stringify)((0, lib_1.trimWorkblock)(stored)));
|
|
297
|
+
}
|
|
298
|
+
vscode.commands.executeCommand('vscode.diff', file1, file2, 'Local vs stored workblock');
|
|
299
|
+
};
|
|
300
|
+
const streamOptions = vscode.commands.registerCommand('beyondwork.beyondwork.showStreamOptions', async (item) => {
|
|
301
|
+
outputChannel.appendLine(`Stream options ${item}`);
|
|
302
|
+
const dirOpt = item.dir ? `Change directory from ${item.dir}` : 'Choose a directory for the workspace';
|
|
303
|
+
const options = [
|
|
304
|
+
dirOpt,
|
|
305
|
+
];
|
|
306
|
+
if (item.dir) {
|
|
307
|
+
options.push('Remove directory binding');
|
|
308
|
+
options.push('Get workblock from workspace');
|
|
309
|
+
options.push('Store workblock to workspace');
|
|
310
|
+
if (syncStreams[item.stream.id] === undefined) {
|
|
311
|
+
options.push('Enable sync');
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
options.push('Disable sync');
|
|
315
|
+
}
|
|
316
|
+
if (item.modified) {
|
|
317
|
+
options.push('Compare changes');
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
vscode.window.showQuickPick(options, {
|
|
321
|
+
placeHolder: 'Select an action'
|
|
322
|
+
}).then(selection => {
|
|
323
|
+
if (selection) {
|
|
324
|
+
switch (selection) {
|
|
325
|
+
case dirOpt:
|
|
326
|
+
vscode.commands.executeCommand('beyondwork.beyondwork.bindStream', item.stream, item.dir);
|
|
327
|
+
break;
|
|
328
|
+
case 'Get workblock from workspace':
|
|
329
|
+
vscode.commands.executeCommand('beyondwork.beyondwork.get', item);
|
|
330
|
+
break;
|
|
331
|
+
case 'Store workblock to workspace':
|
|
332
|
+
vscode.commands.executeCommand('beyondwork.beyondwork.set', item);
|
|
333
|
+
break;
|
|
334
|
+
case 'Enable sync':
|
|
335
|
+
syncStreams[item.stream.id] = item.dir;
|
|
336
|
+
context.globalState.update('bw_sync_streams', syncStreams);
|
|
337
|
+
treeDataProvider.refresh();
|
|
338
|
+
break;
|
|
339
|
+
case 'Disable sync':
|
|
340
|
+
delete syncStreams[item.stream.id];
|
|
341
|
+
context.globalState.update('bw_sync_streams', syncStreams);
|
|
342
|
+
treeDataProvider.refresh();
|
|
343
|
+
break;
|
|
344
|
+
case 'Compare changes':
|
|
345
|
+
compareChanges(item);
|
|
346
|
+
break;
|
|
347
|
+
case 'Remove directory binding':
|
|
348
|
+
delete streamsByDir[item.stream.id];
|
|
349
|
+
delete syncStreams[item.stream.id];
|
|
350
|
+
context.globalState.update('bw_streams_dir', streamsByDir);
|
|
351
|
+
treeDataProvider.refresh();
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
const syncSelected = vscode.commands.registerCommand('beyondwork.beyondwork.storeSelected', async () => {
|
|
358
|
+
const items = treeView.selection.filter(item => item.contextValue === 'beyondwork.stream');
|
|
359
|
+
for (const item of items) {
|
|
360
|
+
const si = item;
|
|
361
|
+
if (si.dir) {
|
|
362
|
+
await setWorkblock(si.dir, si.connection.host, si.stream.id);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
const help = vscode.commands.registerCommand('beyondwork.beyondwork.help', async () => {
|
|
367
|
+
const panel = vscode.window.createWebviewPanel('help', 'Beyond Work Help', vscode.ViewColumn.One, {
|
|
368
|
+
enableCommandUris: true,
|
|
369
|
+
});
|
|
370
|
+
const md = new markdown_it_1.default({
|
|
371
|
+
html: true,
|
|
372
|
+
linkify: true,
|
|
373
|
+
typographer: true,
|
|
374
|
+
});
|
|
375
|
+
panel.webview.html = md.render(`# Beyond Work VSCode Extension
|
|
376
|
+
|
|
377
|
+
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.
|
|
378
|
+
The workblocks in those workspaces can then be stored as files on your local machine.
|
|
379
|
+
|
|
380
|
+
The extension has 3 features:
|
|
381
|
+
|
|
382
|
+
- Get a work block from an existing workspace to local filesystem
|
|
383
|
+
- Set a work block on a workspace from local files
|
|
384
|
+
- Live sync work blocks between open workspaces and local filesystem
|
|
385
|
+
|
|
386
|
+
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.
|
|
387
|
+
|
|
388
|
+
## Getting started
|
|
389
|
+
|
|
390
|
+
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](command:beyondwork.beyondwork.addConnection).
|
|
391
|
+
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.
|
|
392
|
+
|
|
393
|
+
Then, click on the connection in the BEYOND WORK sidebar. This will prompt for an API key. You can get this by running \`!tokencreate\` in any workspace.
|
|
394
|
+
|
|
395
|
+
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
|
|
396
|
+
and choosing \`Choose a directory\`.
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
### Getting a work block
|
|
400
|
+
|
|
401
|
+
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.
|
|
402
|
+
|
|
403
|
+
### Setting a work block
|
|
404
|
+
|
|
405
|
+
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.
|
|
406
|
+
|
|
407
|
+
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.
|
|
408
|
+
|
|
409
|
+
### Syncing work blocks
|
|
410
|
+
|
|
411
|
+
Click a workspace in the menu and choose \`Enable sync\`.
|
|
412
|
+
|
|
413
|
+
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.
|
|
414
|
+
|
|
415
|
+
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.
|
|
416
|
+
|
|
417
|
+
## Directory structure
|
|
418
|
+
|
|
419
|
+
The work block directory structure is like this:
|
|
420
|
+
|
|
421
|
+
<pre>
|
|
422
|
+
Base dir/
|
|
423
|
+
work_block_1/
|
|
424
|
+
task_1/
|
|
425
|
+
assets/
|
|
426
|
+
asset1.txt
|
|
427
|
+
task_1.py
|
|
428
|
+
manifest.yaml
|
|
429
|
+
</pre>
|
|
430
|
+
`);
|
|
431
|
+
});
|
|
432
|
+
let prevHost = context.globalState.get('bw_current_connection', '');
|
|
433
|
+
if (prevHost) {
|
|
434
|
+
treeDataProvider.updateConnectionStatus(prevHost, 'connecting');
|
|
435
|
+
connectToHost(prevHost, context, treeDataProvider).then(() => {
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
const watcher = vscode.workspace.createFileSystemWatcher('**/*');
|
|
439
|
+
watcher.onDidChange(async (uri) => {
|
|
440
|
+
await onFileChange(uri, false);
|
|
441
|
+
});
|
|
442
|
+
watcher.onDidCreate(async (uri) => {
|
|
443
|
+
await onFileChange(uri, false);
|
|
444
|
+
});
|
|
445
|
+
watcher.onDidDelete(async (uri) => {
|
|
446
|
+
await onFileChange(uri, false);
|
|
447
|
+
});
|
|
448
|
+
const saveListener = vscode.workspace.onDidSaveTextDocument((doc) => {
|
|
449
|
+
onFileChange(doc.uri, true);
|
|
450
|
+
});
|
|
451
|
+
context.subscriptions.push(providerReg, addConnectionCmd, connectToTenantCmd, clearConnectionsCmd, removeConnectionCmd, bindStream, getWB, setWB, streamOptions, syncSelected, help, watcher, treeView, outputChannel, diagnosticCollection, saveListener);
|
|
452
|
+
}
|
|
453
|
+
function deactivate() {
|
|
454
|
+
for (const [key, cl] of Object.entries(clientsByHost)) {
|
|
455
|
+
cl.disconnect();
|
|
456
|
+
delete clientsByHost[key];
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
async function setWorkblock(dir, host, streamId) {
|
|
460
|
+
console.log('Setting workblock', dir, host, streamId);
|
|
461
|
+
const client = clientsByHost[host];
|
|
462
|
+
if (!client) {
|
|
463
|
+
vscode.window.showErrorMessage(`Not connected to ${host}`);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
const mf = await (0, lib_1.locateManifest)(dir);
|
|
467
|
+
const wb = await (0, lib_1.assembleWorkblock)(dir, outputLogger);
|
|
468
|
+
if (!wb) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const validation = await client.setWorkblock(streamId, wb);
|
|
472
|
+
if (validation.length > 0) {
|
|
473
|
+
outputChannel.appendLine(`Validation errors: ${JSON.stringify(validation)}`);
|
|
474
|
+
const diagnostics = [];
|
|
475
|
+
for (const err of validation) {
|
|
476
|
+
if (err.library) {
|
|
477
|
+
const uri = vscode.Uri.file(path.join(dir, 'library.py'));
|
|
478
|
+
const range = new vscode.Range(0, 0, 0, 0);
|
|
479
|
+
const diag = new vscode.Diagnostic(range, err.library.error, vscode.DiagnosticSeverity.Error);
|
|
480
|
+
diagnostics.push([uri, [diag]]);
|
|
481
|
+
}
|
|
482
|
+
if (err.module) {
|
|
483
|
+
const uri = vscode.Uri.file(mf);
|
|
484
|
+
const range = new vscode.Range(0, 0, 0, 0);
|
|
485
|
+
const diag = new vscode.Diagnostic(range, err.module.error, vscode.DiagnosticSeverity.Error);
|
|
486
|
+
diagnostics.push([uri, [diag]]);
|
|
487
|
+
}
|
|
488
|
+
if (err.task) {
|
|
489
|
+
const task = wb.modules[err.task.module_index].tasks[err.task.index];
|
|
490
|
+
const uri = vscode.Uri.file(path.join(dir, (0, lib_1.normalizedFilename)(wb.modules[err.task.module_index].name), (0, lib_1.normalizedFilename)(task.name), `${(0, lib_1.normalizedFilename)(task.name)}.py`));
|
|
491
|
+
const range = new vscode.Range(0, 0, 0, 0);
|
|
492
|
+
const diag = new vscode.Diagnostic(range, err.task.error, vscode.DiagnosticSeverity.Error);
|
|
493
|
+
diagnostics.push([uri, [diag]]);
|
|
494
|
+
}
|
|
495
|
+
if (err.business_event) {
|
|
496
|
+
const uri = vscode.Uri.file(mf);
|
|
497
|
+
const range = new vscode.Range(0, 0, 0, 0);
|
|
498
|
+
const diag = new vscode.Diagnostic(range, err.business_event.error, vscode.DiagnosticSeverity.Error);
|
|
499
|
+
diagnostics.push([uri, [diag]]);
|
|
500
|
+
}
|
|
501
|
+
if (err.workblock) {
|
|
502
|
+
const uri = vscode.Uri.file(mf);
|
|
503
|
+
const range = new vscode.Range(0, 0, 0, 0);
|
|
504
|
+
const diag = new vscode.Diagnostic(range, err.workblock.error, vscode.DiagnosticSeverity.Error);
|
|
505
|
+
diagnostics.push([uri, [diag]]);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
diagnosticCollection.set(diagnostics);
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
diagnosticCollection.clear();
|
|
512
|
+
outputChannel.appendLine(`Set workblock ${streamId}`);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
async function storeWorkblockFiles(dir, wb, client) {
|
|
516
|
+
const mf = await (0, lib_1.locateManifest)(dir);
|
|
517
|
+
const resolve = async (path, key) => {
|
|
518
|
+
const value = await client.getBlob(key);
|
|
519
|
+
fs.writeFileSync(path, value);
|
|
520
|
+
};
|
|
521
|
+
wb = JSON.parse(JSON.stringify(wb));
|
|
522
|
+
const promises = [];
|
|
523
|
+
for (const module of wb.modules ?? []) {
|
|
524
|
+
const moduleName = (0, lib_1.normalizedFilename)(module.name);
|
|
525
|
+
fs.mkdirSync(path.join(dir, moduleName), { recursive: true });
|
|
526
|
+
const moduleDir = path.join(dir, moduleName);
|
|
527
|
+
for (const task of module.tasks ?? []) {
|
|
528
|
+
if (task.action.type != types_1.ActionType.Code) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (!task.action.value) {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
const name = (0, lib_1.normalizedFilename)(task.name);
|
|
535
|
+
fs.mkdirSync(path.join(moduleDir, name), { recursive: true });
|
|
536
|
+
const taskDir = path.join(moduleDir, name);
|
|
537
|
+
const taskPath = await (0, lib_1.locateFile)(taskDir, '.py', `${name}.py`);
|
|
538
|
+
promises.push(resolve(taskPath, task.action.value));
|
|
539
|
+
if (task.assets) {
|
|
540
|
+
fs.mkdirSync(path.join(moduleDir, name, "assets"), { recursive: true });
|
|
541
|
+
for (const [key, asset] of Object.entries(task.assets)) {
|
|
542
|
+
const assetPath = path.join(moduleDir, name, "assets", key);
|
|
543
|
+
if (asset.data) {
|
|
544
|
+
promises.push(resolve(assetPath, asset.data));
|
|
545
|
+
}
|
|
546
|
+
if (asset.text) {
|
|
547
|
+
promises.push(resolve(assetPath, asset.text));
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
delete task.created_at;
|
|
552
|
+
delete task.updated_at;
|
|
553
|
+
delete task.action.value;
|
|
554
|
+
delete task.assets;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (wb.library) {
|
|
558
|
+
const libPath = path.join(dir, 'library.py');
|
|
559
|
+
promises.push(resolve(libPath, wb.library));
|
|
560
|
+
}
|
|
561
|
+
if (wb.logo) {
|
|
562
|
+
const logoPath = path.join(dir, 'logo.svg');
|
|
563
|
+
promises.push(resolve(logoPath, wb.logo));
|
|
564
|
+
}
|
|
565
|
+
await Promise.all(promises);
|
|
566
|
+
const out = JSON.parse(JSON.stringify(wb));
|
|
567
|
+
delete out.created_at;
|
|
568
|
+
delete out.updated_at;
|
|
569
|
+
delete out.state;
|
|
570
|
+
delete out.branch_user;
|
|
571
|
+
delete out.storing;
|
|
572
|
+
delete out.actor;
|
|
573
|
+
delete out.library;
|
|
574
|
+
delete out.logo;
|
|
575
|
+
fs.writeFileSync(mf, (0, yaml_1.stringify)(out));
|
|
576
|
+
}
|
|
577
|
+
class StringDocumentContentProvider {
|
|
578
|
+
_onDidChange = new vscode.EventEmitter();
|
|
579
|
+
_content = "";
|
|
580
|
+
contents = {};
|
|
581
|
+
setContent(uri, value) {
|
|
582
|
+
this.contents[uri.toString()] = value;
|
|
583
|
+
this._onDidChange.fire(uri);
|
|
584
|
+
}
|
|
585
|
+
provideTextDocumentContent(uri) {
|
|
586
|
+
return this.contents[uri.toString()] ?? "";
|
|
587
|
+
}
|
|
588
|
+
get onDidChange() {
|
|
589
|
+
return this._onDidChange.event;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
//# sourceMappingURL=extension.js.map
|
package/out/lib/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Beyond Work Library
|
|
4
|
+
*
|
|
5
|
+
* This module exports the core functionality for working with Beyond Work workblocks
|
|
6
|
+
* in both VS Code extension and npm package contexts.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
// Re-export utility functions
|
|
24
|
+
__exportStar(require("./workblock"), exports);
|
|
25
|
+
// Re-export logger interfaces and implementations
|
|
26
|
+
__exportStar(require("./logger"), exports);
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,8BAA8B;AAC9B,8CAA4B;AAE5B,kDAAkD;AAClD,2CAAyB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VSCodeLogger = exports.ConsoleLogger = void 0;
|
|
4
|
+
// Default console logger for CLI usage
|
|
5
|
+
class ConsoleLogger {
|
|
6
|
+
log(message) {
|
|
7
|
+
console.log(message);
|
|
8
|
+
}
|
|
9
|
+
error(message) {
|
|
10
|
+
console.error(message);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ConsoleLogger = ConsoleLogger;
|
|
14
|
+
// VS Code adapter for the Logger interface
|
|
15
|
+
class VSCodeLogger {
|
|
16
|
+
outputChannel;
|
|
17
|
+
constructor(outputChannel) {
|
|
18
|
+
this.outputChannel = outputChannel;
|
|
19
|
+
}
|
|
20
|
+
log(message) {
|
|
21
|
+
this.outputChannel.appendLine(message);
|
|
22
|
+
}
|
|
23
|
+
error(message) {
|
|
24
|
+
this.outputChannel.appendLine(`ERROR: ${message}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.VSCodeLogger = VSCodeLogger;
|
|
28
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":";;;AAQA,uCAAuC;AACvC,MAAa,aAAa;IACtB,GAAG,CAAC,OAAe;QACf,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,OAAe;QACjB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACJ;AARD,sCAQC;AAED,2CAA2C;AAC3C,MAAa,YAAY;IACD;IAApB,YAAoB,aAAmC;QAAnC,kBAAa,GAAb,aAAa,CAAsB;IAAG,CAAC;IAE3D,GAAG,CAAC,OAAe;QACf,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,OAAe;QACjB,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;CACJ;AAVD,oCAUC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.trimWorkblock = trimWorkblock;
|
|
40
|
+
exports.locateManifest = locateManifest;
|
|
41
|
+
exports.locateFile = locateFile;
|
|
42
|
+
exports.normalizedFilename = normalizedFilename;
|
|
43
|
+
exports.assembleWorkblock = assembleWorkblock;
|
|
44
|
+
exports.findGitIgnoreDir = findGitIgnoreDir;
|
|
45
|
+
exports.isFileGitIgnored = isFileGitIgnored;
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const mime = __importStar(require("mime-types"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const yaml_1 = require("yaml");
|
|
50
|
+
const ignore_1 = __importDefault(require("ignore"));
|
|
51
|
+
function trimWorkblock(wb) {
|
|
52
|
+
const ignoreFields = ["created_at", "updated_at", "state", "actor", "branch_user", "storing", "description"];
|
|
53
|
+
const uWb = wb;
|
|
54
|
+
for (const field of ignoreFields) {
|
|
55
|
+
delete uWb[field];
|
|
56
|
+
}
|
|
57
|
+
for (const task of uWb.tasks ?? []) {
|
|
58
|
+
delete task['created_at'];
|
|
59
|
+
delete task['updated_at'];
|
|
60
|
+
delete task['explanation'];
|
|
61
|
+
task['action']['value'] = task['action']['value']?.trim();
|
|
62
|
+
if (!task['assets']) {
|
|
63
|
+
task['assets'] = {};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (uWb['library']) {
|
|
67
|
+
uWb['library'] = uWb['library'].trim();
|
|
68
|
+
}
|
|
69
|
+
return uWb;
|
|
70
|
+
}
|
|
71
|
+
async function locateManifest(dir) {
|
|
72
|
+
return await locateFile(dir, 'manifest.yaml', 'manifest.yaml');
|
|
73
|
+
}
|
|
74
|
+
async function locateFile(dir, suffix, defaultName) {
|
|
75
|
+
if (!fs.existsSync(dir)) {
|
|
76
|
+
return path.join(dir, defaultName);
|
|
77
|
+
}
|
|
78
|
+
const entries = await fs.promises.readdir(dir);
|
|
79
|
+
const file = entries.find(entry => entry.endsWith(suffix));
|
|
80
|
+
if (file) {
|
|
81
|
+
return path.join(dir, file);
|
|
82
|
+
}
|
|
83
|
+
return path.join(dir, defaultName);
|
|
84
|
+
}
|
|
85
|
+
function normalizedFilename(name) {
|
|
86
|
+
return name.toLowerCase().replaceAll(' ', '_');
|
|
87
|
+
}
|
|
88
|
+
async function assembleWorkblock(dir, log) {
|
|
89
|
+
const ft = await import('file-type');
|
|
90
|
+
const mf = await locateManifest(dir);
|
|
91
|
+
if (!fs.existsSync(mf)) {
|
|
92
|
+
log.log(`Manifest file ${mf} not found`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const data = fs.readFileSync(mf, 'utf8');
|
|
96
|
+
const wb = (0, yaml_1.parse)(data);
|
|
97
|
+
wb.state = "modified";
|
|
98
|
+
wb.updated_at = new Date().toISOString();
|
|
99
|
+
for (const module of wb.modules ?? []) {
|
|
100
|
+
const moduleDir = path.join(dir, normalizedFilename(module.name));
|
|
101
|
+
if (!fs.existsSync(moduleDir)) {
|
|
102
|
+
log.log(`Module directory ${moduleDir} not found`);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for (const task of module.tasks ?? []) {
|
|
106
|
+
const name = normalizedFilename(task.name);
|
|
107
|
+
const taskDir = path.join(moduleDir, name);
|
|
108
|
+
if (!fs.existsSync(taskDir)) {
|
|
109
|
+
log.log(`Task directory ${taskDir} not found`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const taskPath = await locateFile(taskDir, '.py', `${name}.py`);
|
|
113
|
+
if (!fs.existsSync(taskPath)) {
|
|
114
|
+
log.log(`Task file ${taskPath} not found`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
task.action.value = fs.readFileSync(taskPath, 'utf8');
|
|
118
|
+
if (fs.existsSync(path.join(moduleDir, name, 'assets'))) {
|
|
119
|
+
if (!task.assets) {
|
|
120
|
+
task.assets = {};
|
|
121
|
+
}
|
|
122
|
+
const assets = fs.readdirSync(path.join(moduleDir, name, 'assets'));
|
|
123
|
+
for (const asset of assets) {
|
|
124
|
+
const assetPath = path.join(moduleDir, name, 'assets', asset);
|
|
125
|
+
if (fs.statSync(assetPath).isDirectory()) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (await isFileGitIgnored(assetPath, log)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
let fileType = (await ft.fileTypeFromFile(assetPath))?.mime;
|
|
132
|
+
if (!fileType) {
|
|
133
|
+
fileType = mime.lookup(asset) || 'text/plain';
|
|
134
|
+
}
|
|
135
|
+
task.assets[asset] = {
|
|
136
|
+
content_type: fileType,
|
|
137
|
+
text: fs.readFileSync(assetPath, 'utf8'),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
;
|
|
143
|
+
}
|
|
144
|
+
if (fs.existsSync(path.join(dir, 'library.py'))) {
|
|
145
|
+
wb.library = fs.readFileSync(path.join(dir, 'library.py'), 'utf8');
|
|
146
|
+
}
|
|
147
|
+
if (fs.existsSync(path.join(dir, 'logo.svg'))) {
|
|
148
|
+
wb.logo = fs.readFileSync(path.join(dir, 'logo.svg'), 'utf8');
|
|
149
|
+
}
|
|
150
|
+
return wb;
|
|
151
|
+
}
|
|
152
|
+
function findGitIgnoreDir(startPath) {
|
|
153
|
+
let currentDir = startPath;
|
|
154
|
+
if (!fs.statSync(currentDir).isDirectory()) {
|
|
155
|
+
currentDir = path.dirname(currentDir);
|
|
156
|
+
}
|
|
157
|
+
while (currentDir !== path.parse(currentDir).root) {
|
|
158
|
+
const gitignorePath = path.join(currentDir, '.gitignore');
|
|
159
|
+
const gitDirPath = path.join(currentDir, '.git');
|
|
160
|
+
if (fs.existsSync(gitDirPath)) {
|
|
161
|
+
return fs.existsSync(gitignorePath) ? currentDir : null;
|
|
162
|
+
}
|
|
163
|
+
currentDir = path.dirname(currentDir);
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
async function isFileGitIgnored(filePath, log) {
|
|
168
|
+
try {
|
|
169
|
+
const gitignoreDir = findGitIgnoreDir(filePath);
|
|
170
|
+
if (!gitignoreDir) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
const gitignorePath = path.join(gitignoreDir, '.gitignore');
|
|
174
|
+
const gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
|
|
175
|
+
const relativePath = path.relative(gitignoreDir, filePath);
|
|
176
|
+
const ig = (0, ignore_1.default)();
|
|
177
|
+
ig.add(gitignoreContent);
|
|
178
|
+
return ig.ignores(relativePath);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
log.log(`Error checking gitignore status: ${error}`);
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=workblock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workblock.js","sourceRoot":"","sources":["../../src/lib/workblock.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,sCAoBC;AAED,wCAEC;AAED,gCAcC;AAGD,gDAEC;AAED,8CAoEC;AAED,4CAkBC;AAED,4CAmBC;AArKD,uCAAyB;AAEzB,iDAAmC;AACnC,2CAA6B;AAC7B,+BAA6B;AAC7B,oDAA4B;AAI5B,SAAgB,aAAa,CAAC,EAAuB;IACjD,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IAC7G,MAAM,GAAG,GAAwB,EAAE,CAAA;IACnC,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;QAC/B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,CAAC,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4
|
+
"displayName": "Beyond Work",
|
|
5
|
+
"description": "Beyond Work is a tool for managing your work in a way that is easy to use and understand.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"engines": {
|
|
8
|
+
"vscode": "^1.94.0",
|
|
9
|
+
"node": ">=16.0.0"
|
|
10
|
+
},
|
|
11
|
+
"categories": [
|
|
12
|
+
"Other"
|
|
13
|
+
],
|
|
14
|
+
"bin": {
|
|
15
|
+
"beyondwork": "./out/cli.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"out/lib/**/*",
|
|
19
|
+
"out/cli.js"
|
|
20
|
+
],
|
|
21
|
+
"main": "./out/extension.js",
|
|
22
|
+
"private": false,
|
|
23
|
+
"contributes": {
|
|
24
|
+
"configuration": {
|
|
25
|
+
"title": "Beyond Work",
|
|
26
|
+
"properties": {}
|
|
27
|
+
},
|
|
28
|
+
"commands": [
|
|
29
|
+
{
|
|
30
|
+
"command": "beyondwork.beyondwork.addConnection",
|
|
31
|
+
"title": "Beyond Work: Add Connection",
|
|
32
|
+
"icon": "$(add)"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"command": "beyondwork.beyondwork.clearConnections",
|
|
36
|
+
"title": "Beyond Work: Clear Connections",
|
|
37
|
+
"icon": "$(trash)"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"command": "beyondwork.beyondwork.removeConnection",
|
|
41
|
+
"title": "Beyond Work: Remove Connection",
|
|
42
|
+
"icon": "$(trash)"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"command": "beyondwork.beyondwork.help",
|
|
46
|
+
"title": "Beyond Work: Help",
|
|
47
|
+
"icon": "$(question)"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"command": "beyondwork.beyondwork.storeSelected",
|
|
51
|
+
"title": "Beyond Work: Store to selected workspaces",
|
|
52
|
+
"icon": "$(sync)"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"menus": {
|
|
56
|
+
"view/title": [
|
|
57
|
+
{
|
|
58
|
+
"command": "beyondwork.beyondwork.addConnection",
|
|
59
|
+
"when": "view == beyondworkConnections",
|
|
60
|
+
"group": "navigation"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"command": "beyondwork.beyondwork.help",
|
|
64
|
+
"when": "view == beyondworkConnections",
|
|
65
|
+
"group": "navigation"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"view/item/context": [
|
|
69
|
+
{
|
|
70
|
+
"command": "beyondwork.beyondwork.removeConnection",
|
|
71
|
+
"when": "view == beyondworkConnections",
|
|
72
|
+
"group": "navigation"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"views": {
|
|
77
|
+
"explorer": [
|
|
78
|
+
{
|
|
79
|
+
"id": "beyondworkConnections",
|
|
80
|
+
"name": "Beyond Work"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"@types/markdown-it": "^14.1.2",
|
|
87
|
+
"@types/mocha": "^10.0.9",
|
|
88
|
+
"@types/node": "~20.17.0",
|
|
89
|
+
"@types/vscode": "^1.94.0",
|
|
90
|
+
"@types/ws": "^8.5.12",
|
|
91
|
+
"@typescript-eslint/eslint-plugin": "^8.8.1",
|
|
92
|
+
"@typescript-eslint/parser": "^8.8.1",
|
|
93
|
+
"@vscode/test-cli": "^0.0.10",
|
|
94
|
+
"@vscode/test-electron": "^2.4.1",
|
|
95
|
+
"@vscode/vsce": "^3.3.2",
|
|
96
|
+
"esbuild": "^0.25.0",
|
|
97
|
+
"eslint": "^9.12.0",
|
|
98
|
+
"npm": "^10.7.0",
|
|
99
|
+
"typescript": "^5.6.3"
|
|
100
|
+
},
|
|
101
|
+
"dependencies": {
|
|
102
|
+
"@types/glob": "^8.1.0",
|
|
103
|
+
"@types/mime-types": "^2.1.4",
|
|
104
|
+
"@types/ws": "^8.5.12",
|
|
105
|
+
"ansi-regex": "^5.0.1",
|
|
106
|
+
"child_process": "^1.0.2",
|
|
107
|
+
"commander": "^13.1.0",
|
|
108
|
+
"crypto": "^1.0.1",
|
|
109
|
+
"file-type": "^20.0.0",
|
|
110
|
+
"glob": "^11.0.0",
|
|
111
|
+
"ignore": "^7.0.3",
|
|
112
|
+
"markdown-it": "^14.1.0",
|
|
113
|
+
"mime-types": "^2.1.35",
|
|
114
|
+
"mocha": "^10.8.2",
|
|
115
|
+
"node-fetch-cache": "^5.0.2",
|
|
116
|
+
"uuid": "^11.0.3",
|
|
117
|
+
"ws": "^8.18.0",
|
|
118
|
+
"yaml": "^2.6.0"
|
|
119
|
+
},
|
|
120
|
+
"scripts": {
|
|
121
|
+
"compile": "pnpm run check-types && node esbuild.js --production && pnpm run build-webview",
|
|
122
|
+
"check-types": "tsc --noEmit",
|
|
123
|
+
"watch": "tsc -watch -p ./",
|
|
124
|
+
"watch:esbuild": "node esbuild.js --watch",
|
|
125
|
+
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
|
|
126
|
+
"package": "pnpm run check-types && node esbuild.js --production && pnpm run build-webview",
|
|
127
|
+
"build-webview": "esbuild ./src/webview/main.ts --bundle --outfile=extension/out/webview/main.js --format=iife --platform=browser",
|
|
128
|
+
"build-lib": "tsc -p tsconfig.json"
|
|
129
|
+
}
|
|
130
|
+
}
|