accrete-kit 0.1.0 → 0.2.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +9 -2
  3. package/dist/scaffold/assets/generated/release.json +1 -1
  4. package/dist/scaffold/manifest.json +2 -2
  5. package/dist/ui/LICENSE +21 -0
  6. package/dist/ui/THIRD-PARTY-NOTICES +212 -0
  7. package/dist/ui/bin/accrete-ui.mjs +46 -0
  8. package/dist/ui/page/app.js +49 -0
  9. package/dist/ui/page/index.html +17 -0
  10. package/dist/ui/page/panels/activity.css +80 -0
  11. package/dist/ui/page/panels/activity.js +85 -0
  12. package/dist/ui/page/panels/agents.css +61 -0
  13. package/dist/ui/page/panels/agents.js +173 -0
  14. package/dist/ui/page/panels/objects.css +155 -0
  15. package/dist/ui/page/panels/objects.js +309 -0
  16. package/dist/ui/page/panels/running.css +35 -0
  17. package/dist/ui/page/panels/running.js +159 -0
  18. package/dist/ui/page/style.css +86 -0
  19. package/dist/ui/page/terminal.js +88 -0
  20. package/dist/ui/server/agent-sessions.mjs +600 -0
  21. package/dist/ui/server/auth.mjs +29 -0
  22. package/dist/ui/server/deps.mjs +12 -0
  23. package/dist/ui/server/documents.mjs +285 -0
  24. package/dist/ui/server/events.mjs +18 -0
  25. package/dist/ui/server/processes.mjs +110 -0
  26. package/dist/ui/server/readers/activity.mjs +134 -0
  27. package/dist/ui/server/readers/agents.mjs +45 -0
  28. package/dist/ui/server/readers/objects.mjs +261 -0
  29. package/dist/ui/server/readers/running.mjs +245 -0
  30. package/dist/ui/server/scope.mjs +36 -0
  31. package/dist/ui/server/server.mjs +156 -0
  32. package/dist/ui/server/terminal.mjs +134 -0
  33. package/dist/ui/server/workspace.mjs +26 -0
  34. package/dist/ui/ui.json +3 -0
  35. package/dist/ui/vendor/@xterm/addon-fit/lib/addon-fit.mjs +18 -0
  36. package/dist/ui/vendor/@xterm/addon-unicode11/lib/addon-unicode11.mjs +44 -0
  37. package/dist/ui/vendor/@xterm/addon-webgl/lib/addon-webgl.mjs +101 -0
  38. package/dist/ui/vendor/@xterm/xterm/css/xterm.css +285 -0
  39. package/dist/ui/vendor/@xterm/xterm/lib/xterm.mjs +53 -0
  40. package/dist/ui/vendor/node-pty/lib/eventEmitter2.js +47 -0
  41. package/dist/ui/vendor/node-pty/lib/index.js +52 -0
  42. package/dist/ui/vendor/node-pty/lib/interfaces.js +7 -0
  43. package/dist/ui/vendor/node-pty/lib/terminal.js +190 -0
  44. package/dist/ui/vendor/node-pty/lib/types.js +7 -0
  45. package/dist/ui/vendor/node-pty/lib/unixTerminal.js +346 -0
  46. package/dist/ui/vendor/node-pty/lib/utils.js +39 -0
  47. package/dist/ui/vendor/node-pty/package.json +64 -0
  48. package/dist/ui/vendor/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  49. package/dist/ui/vendor/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  50. package/dist/ui/vendor/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  51. package/dist/ui/vendor/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
  52. package/dist/ui/vendor/ws/index.js +22 -0
  53. package/dist/ui/vendor/ws/lib/buffer-util.js +142 -0
  54. package/dist/ui/vendor/ws/lib/constants.js +19 -0
  55. package/dist/ui/vendor/ws/lib/event-target.js +292 -0
  56. package/dist/ui/vendor/ws/lib/extension.js +203 -0
  57. package/dist/ui/vendor/ws/lib/limiter.js +55 -0
  58. package/dist/ui/vendor/ws/lib/permessage-deflate.js +530 -0
  59. package/dist/ui/vendor/ws/lib/receiver.js +743 -0
  60. package/dist/ui/vendor/ws/lib/sender.js +610 -0
  61. package/dist/ui/vendor/ws/lib/stream.js +161 -0
  62. package/dist/ui/vendor/ws/lib/subprotocol.js +62 -0
  63. package/dist/ui/vendor/ws/lib/validation.js +152 -0
  64. package/dist/ui/vendor/ws/lib/websocket-server.js +562 -0
  65. package/dist/ui/vendor/ws/lib/websocket.js +1426 -0
  66. package/dist/ui/vendor/ws/package.json +74 -0
  67. package/lib/cli.mjs +22 -4
  68. package/lib/ui.mjs +24 -0
  69. package/package.json +5 -5
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "ws",
3
+ "version": "8.22.1",
4
+ "description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
5
+ "keywords": [
6
+ "HyBi",
7
+ "Push",
8
+ "RFC-6455",
9
+ "WebSocket",
10
+ "WebSockets",
11
+ "real-time"
12
+ ],
13
+ "homepage": "https://github.com/websockets/ws",
14
+ "bugs": "https://github.com/websockets/ws/issues",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/websockets/ws.git"
18
+ },
19
+ "author": "Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)",
20
+ "license": "MIT",
21
+ "main": "index.js",
22
+ "exports": {
23
+ ".": {
24
+ "browser": "./browser.js",
25
+ "import": "./wrapper.mjs",
26
+ "require": "./index.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "browser": "browser.js",
31
+ "engines": {
32
+ "node": ">=10.0.0"
33
+ },
34
+ "files": [
35
+ "browser.js",
36
+ "index.js",
37
+ "lib/*.js",
38
+ "wrapper.mjs"
39
+ ],
40
+ "scripts": {
41
+ "test": "nyc --reporter=lcov --reporter=text mocha --throw-deprecation test/*.test.js",
42
+ "integration": "mocha --throw-deprecation test/*.integration.js",
43
+ "lint": "eslint . && prettier --check --ignore-path .gitignore \"**/*.{json,md,yaml,yml}\""
44
+ },
45
+ "peerDependencies": {
46
+ "bufferutil": "^4.0.1",
47
+ "utf-8-validate": ">=5.0.2"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "bufferutil": {
51
+ "optional": true
52
+ },
53
+ "utf-8-validate": {
54
+ "optional": true
55
+ }
56
+ },
57
+ "devDependencies": {
58
+ "@eslint/js": "^10.0.1",
59
+ "benchmark": "^2.1.4",
60
+ "bufferutil": "^4.0.1",
61
+ "eslint": "^10.0.1",
62
+ "eslint-config-prettier": "^10.0.1",
63
+ "eslint-plugin-prettier": "^5.0.0",
64
+ "globals": "^17.0.0",
65
+ "mocha": "^8.4.0",
66
+ "nyc": "^15.0.0",
67
+ "prettier": "^3.0.0",
68
+ "utf-8-validate": "^6.0.0"
69
+ },
70
+ "allowScripts": {
71
+ "bufferutil": true,
72
+ "utf-8-validate": true
73
+ }
74
+ }
package/lib/cli.mjs CHANGED
@@ -5,6 +5,7 @@ import { parseArgs } from 'node:util';
5
5
  import { AccreteError } from './fsutil.mjs';
6
6
  import { BINARY } from './kernel.mjs';
7
7
  import { MARKER, loadScaffold } from './scaffold.mjs';
8
+ import { checkUi, runUi } from './ui.mjs';
8
9
  import { createWorkspace, findWorkspace, installWorkspace, upgradeWorkspace } from './workspace.mjs';
9
10
 
10
11
  const USAGE = `Create or upgrade an ACCRETE Workspace, and install its Kernel.
@@ -13,6 +14,7 @@ const USAGE = `Create or upgrade an ACCRETE Workspace, and install its Kernel.
13
14
  npx accrete-kit@latest create . Add to this directory or repository
14
15
  npx accrete-kit@latest upgrade [OPTIONS]
15
16
  npx accrete-kit@<version> install [OPTIONS] Restore this host's Kernel after a clone
17
+ npx accrete-kit@latest ui [OPTIONS] Watch a Workspace in a local web page, macOS only
16
18
 
17
19
  Create options:
18
20
  --name NAME --id ID --timezone IANA_ZONE
@@ -29,10 +31,15 @@ Upgrade options:
29
31
  Install options:
30
32
  --project PATH --json
31
33
 
34
+ UI options:
35
+ --project PATH --no-open --no-tmux --port N
36
+
32
37
  --no-install skips installing the Kernel binary. Owner edits are preserved: a conflict
33
38
  leaves the file alone and writes a candidate under .accrete/template-upgrades/. The Kernel
34
39
  runs as ${BINARY}; accrete-kit does not forward commands to it.`;
35
40
 
41
+ const UI_ONLY = ['no-open', 'no-tmux', 'port'];
42
+
36
43
  const OPTIONS = {
37
44
  name: { type: 'string' },
38
45
  id: { type: 'string' },
@@ -44,6 +51,9 @@ const OPTIONS = {
44
51
  'dry-run': { type: 'boolean' },
45
52
  accept: { type: 'string' },
46
53
  json: { type: 'boolean' },
54
+ 'no-open': { type: 'boolean' },
55
+ 'no-tmux': { type: 'boolean' },
56
+ port: { type: 'string' },
47
57
  help: { type: 'boolean', short: 'h' },
48
58
  version: { type: 'boolean', short: 'v' }
49
59
  };
@@ -113,12 +123,12 @@ function selectWorkspace(values, directories, cwd, command) {
113
123
  }
114
124
 
115
125
  function install(values, directories, scaffold, cwd) {
116
- refuse(values, ['name', 'id', 'timezone', 'no-git', 'no-install', 'dry-run', 'agents', 'accept'], 'to install');
126
+ refuse(values, ['name', 'id', 'timezone', 'no-git', 'no-install', 'dry-run', 'agents', 'accept', ...UI_ONLY], 'to install');
117
127
  return installWorkspace(selectWorkspace(values, directories, cwd, 'install'), scaffold);
118
128
  }
119
129
 
120
130
  function upgrade(values, directories, scaffold, cwd) {
121
- refuse(values, ['name', 'id', 'timezone', 'no-git'], 'to upgrade');
131
+ refuse(values, ['name', 'id', 'timezone', 'no-git', ...UI_ONLY], 'to upgrade');
122
132
  if (values.accept !== undefined && values.agents !== undefined) throw new AccreteError('invalid', '--accept and --agents are separate operations');
123
133
  const root = selectWorkspace(values, directories, cwd, 'upgrade');
124
134
  return upgradeWorkspace(root, {
@@ -130,7 +140,7 @@ function upgrade(values, directories, scaffold, cwd) {
130
140
  }
131
141
 
132
142
  function create(values, directories, scaffold, cwd) {
133
- refuse(values, ['project', 'dry-run', 'accept'], 'to create');
143
+ refuse(values, ['project', 'dry-run', 'accept', ...UI_ONLY], 'to create');
134
144
  if (directories.length !== 1) throw new AccreteError('invalid', 'create takes one directory, or . for this one');
135
145
  return createWorkspace(path.resolve(cwd, directories[0]), {
136
146
  name: values.name,
@@ -142,6 +152,13 @@ function create(values, directories, scaffold, cwd) {
142
152
  }, scaffold);
143
153
  }
144
154
 
155
+ /** The server stays in the foreground, so this returns its exit code and no receipt. */
156
+ function ui(values, directories, cwd) {
157
+ refuse(values, ['name', 'id', 'timezone', 'agents', 'no-git', 'no-install', 'dry-run', 'accept', 'json'], 'to ui');
158
+ checkUi();
159
+ return runUi(selectWorkspace(values, directories, cwd, 'ui'), values);
160
+ }
161
+
145
162
  const COMMANDS = { create, upgrade, install };
146
163
 
147
164
  export function main(argv, cwd = process.cwd()) {
@@ -164,8 +181,9 @@ export function main(argv, cwd = process.cwd()) {
164
181
  return 0;
165
182
  }
166
183
  const [command, ...directories] = positionals;
184
+ if (command === 'ui') return ui(values, directories, cwd);
167
185
  if (!Object.hasOwn(COMMANDS, command ?? '')) {
168
- throw new AccreteError('invalid', command === undefined ? 'Name a subcommand: create, upgrade or install' : `Unknown subcommand ${command}; use create, upgrade or install`);
186
+ throw new AccreteError('invalid', command === undefined ? 'Name a subcommand: create, upgrade, install or ui' : `Unknown subcommand ${command}; use create, upgrade, install or ui`);
169
187
  }
170
188
  const receipt = COMMANDS[command](values, directories, scaffold, cwd);
171
189
  receipt.next_steps = nextSteps(receipt, cwd);
package/lib/ui.mjs ADDED
@@ -0,0 +1,24 @@
1
+ // The accrete-ui this package carries, run in the foreground until it exits.
2
+ import { spawnSync } from 'node:child_process';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { AccreteError } from './fsutil.mjs';
7
+
8
+ const BUNDLED = new URL('../dist/ui/bin/accrete-ui.mjs', import.meta.url);
9
+
10
+ /** Before a Workspace is looked for: this host and this package can run the UI. */
11
+ export function checkUi() {
12
+ if (process.platform !== 'darwin') throw new AccreteError('dependency', 'The UI is macOS only for now');
13
+ if (!fs.existsSync(BUNDLED)) throw new AccreteError('dependency', 'This copy of accrete-kit has no UI in dist/ui; in a checkout, run scripts/fetch-ui.mjs');
14
+ }
15
+
16
+ export function runUi(root, values) {
17
+ const args = [fileURLToPath(BUNDLED), '--project', root];
18
+ if (values['no-open']) args.push('--no-open');
19
+ if (values['no-tmux']) args.push('--no-tmux');
20
+ if (values.port !== undefined) args.push('--port', values.port);
21
+ const { status, signal, error } = spawnSync(process.execPath, args, { stdio: 'inherit' });
22
+ if (error) throw new AccreteError('storage', `Cannot run the UI: ${error.message}`);
23
+ return status ?? 128 + os.constants.signals[signal];
24
+ }
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "accrete-kit",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Create and upgrade ACCRETE Workspaces",
5
5
  "license": "MIT",
6
6
  "repository": { "type": "git", "url": "git+https://github.com/Wanli-Wylie/accrete-template.git" },
7
7
  "type": "module",
8
8
  "engines": { "node": ">=20" },
9
9
  "bin": { "accrete-kit": "bin/accrete-kit.mjs" },
10
- "files": ["bin/", "lib/", "dist/scaffold/", "dist/kernel/", "LICENSE", "CHANGELOG.md"],
11
- "accrete": { "cli": "0.1.0", "cliRepo": "Wanli-Wylie/accrete-cli" },
10
+ "files": ["bin/", "lib/", "dist/scaffold/", "dist/kernel/", "dist/ui/", "LICENSE", "CHANGELOG.md"],
11
+ "accrete": { "cli": "0.1.0", "cliRepo": "Wanli-Wylie/accrete-cli", "ui": "0.1.0", "uiRepo": "Wanli-Wylie/accrete-ui" },
12
12
  "scripts": {
13
13
  "build": "node scripts/build.mjs",
14
14
  "check": "node scripts/build.mjs --check",
15
15
  "pretest": "node scripts/build.mjs",
16
- "test": "node --test test/install.test.mjs test/cli.test.mjs test/kernel.test.mjs test/contract.test.mjs test/package.test.mjs",
17
- "prepublishOnly": "node scripts/fetch-kernel.mjs --check",
16
+ "test": "node --test test/install.test.mjs test/cli.test.mjs test/kernel.test.mjs test/contract.test.mjs test/ui.test.mjs test/package.test.mjs",
17
+ "prepublishOnly": "node scripts/fetch-kernel.mjs --check && node scripts/fetch-ui.mjs --check",
18
18
  "prepack": "node scripts/build.mjs"
19
19
  }
20
20
  }