@neta-art/cohub-cli 8.4.1 → 9.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.
Files changed (70) hide show
  1. package/README.md +66 -30
  2. package/dist/board-export.d.ts +21 -36
  3. package/dist/board-export.js +163 -88
  4. package/dist/board-kernel.d.ts +2 -3
  5. package/dist/board-kernel.js +3428 -3770
  6. package/dist/board-time.d.ts +3 -0
  7. package/dist/board-time.js +28 -0
  8. package/dist/commands/apps.js +2 -2
  9. package/dist/commands/auth.js +2 -2
  10. package/dist/commands/boards/examples.d.ts +8 -2
  11. package/dist/commands/boards/examples.js +79 -411
  12. package/dist/commands/boards.d.ts +4 -9
  13. package/dist/commands/boards.js +365 -286
  14. package/dist/commands/desktop.d.ts +1 -5
  15. package/dist/commands/desktop.js +5 -16
  16. package/dist/commands/generations.js +1 -1
  17. package/dist/commands/me.js +1 -1
  18. package/dist/commands/public.js +3 -3
  19. package/dist/commands/references.js +3 -0
  20. package/dist/commands/referrals.js +2 -2
  21. package/dist/commands/run.js +3 -3
  22. package/dist/commands/runtime.d.ts +1 -1
  23. package/dist/commands/runtime.js +14 -9
  24. package/dist/commands/sandboxd-binary.d.ts +1 -1
  25. package/dist/commands/sandboxd-binary.js +2 -23
  26. package/dist/commands/search.js +15 -7
  27. package/dist/commands/space-activity.js +3 -5
  28. package/dist/commands/space-displays.d.ts +2 -0
  29. package/dist/commands/space-displays.js +347 -0
  30. package/dist/commands/space-files.d.ts +5 -0
  31. package/dist/commands/space-files.js +215 -0
  32. package/dist/commands/space-invitations.js +3 -3
  33. package/dist/commands/spaces.d.ts +3 -11
  34. package/dist/commands/spaces.js +146 -75
  35. package/dist/index.js +8 -5
  36. package/dist/runtime/launch.d.ts +2 -0
  37. package/dist/runtime/launch.js +38 -8
  38. package/dist/runtime/presentation.d.ts +1 -0
  39. package/dist/runtime/presentation.js +3 -2
  40. package/dist/runtime/supervisor.d.ts +1 -0
  41. package/dist/runtime/supervisor.js +2 -1
  42. package/dist/space-files/limit.d.ts +2 -0
  43. package/dist/space-files/limit.js +16 -0
  44. package/dist/space-files/operands.d.ts +16 -0
  45. package/dist/space-files/operands.js +33 -0
  46. package/dist/space-files/transfer.d.ts +53 -0
  47. package/dist/space-files/transfer.js +296 -0
  48. package/dist/space-files/upload.d.ts +14 -0
  49. package/dist/space-files/upload.js +53 -0
  50. package/dist/space.d.ts +18 -16
  51. package/dist/space.js +86 -39
  52. package/dist/web.d.ts +1 -0
  53. package/dist/web.js +6 -0
  54. package/package.json +2 -2
  55. package/dist/commands/board-domain.d.ts +0 -2
  56. package/dist/commands/board-domain.js +0 -16
  57. package/dist/commands/boards/animation.d.ts +0 -2
  58. package/dist/commands/boards/animation.js +0 -171
  59. package/dist/commands/boards/appearance.d.ts +0 -2
  60. package/dist/commands/boards/appearance.js +0 -127
  61. package/dist/commands/boards/batch.d.ts +0 -4
  62. package/dist/commands/boards/batch.js +0 -62
  63. package/dist/commands/boards/connections.d.ts +0 -2
  64. package/dist/commands/boards/connections.js +0 -95
  65. package/dist/commands/boards/context.d.ts +0 -31
  66. package/dist/commands/boards/context.js +0 -71
  67. package/dist/commands/boards/items.d.ts +0 -2
  68. package/dist/commands/boards/items.js +0 -184
  69. package/dist/commands/boards/transactions.d.ts +0 -12
  70. package/dist/commands/boards/transactions.js +0 -69
@@ -1,184 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { BoardAuthoringItemSchema, BoardItemPatchSchema, } from "@neta-art/cohub";
3
- import { computeArrowFrame, computeDrawBounds } from "@neta-art/cohub/board";
4
- import { BOARD_DOMAIN_INPUT_MAX_BYTES, readBoardJsonObject, } from "../../board-command-support.js";
5
- import { handleHttp, json, jsonRequested, ok, table } from "../../output.js";
6
- import { readInput, readOptions, resolvedBoard, withJson, } from "./context.js";
7
- const baseVersion = (value, fallback) => {
8
- if (value === undefined)
9
- return fallback;
10
- const parsed = Number(value);
11
- if (!Number.isSafeInteger(parsed) || parsed < 0) {
12
- throw new Error("base version must be a non-negative integer");
13
- }
14
- return parsed;
15
- };
16
- async function execute(boards, target, command, options) {
17
- const board = await resolvedBoard(boards, target);
18
- const snapshot = await board.summary();
19
- const mutation = {
20
- mutationId: options.mutationId?.trim() || randomUUID(),
21
- baseVersion: baseVersion(options.baseVersion, snapshot.board.version),
22
- dryRun: Boolean(options.dryRun),
23
- commands: [command],
24
- };
25
- // Server-side validation: schema, version, references, cascade rules — the
26
- // same checks the real write would run, just without persisting anything.
27
- const receipt = await board.mutateSemantic(mutation);
28
- if (jsonRequested(options))
29
- return json(receipt);
30
- if (options.dryRun) {
31
- ok(`Validated against Board version ${receipt.board.version}; no changes written`);
32
- return;
33
- }
34
- ok(`${receipt.replayed ? "Replayed" : "Applied"} mutation at Board version ${receipt.board.version}`);
35
- }
36
- function mutationOptions(command) {
37
- return withJson(command)
38
- .option("--base-version <version>", "Expected Board version; defaults to latest")
39
- .option("--mutation-id <id>", "Stable id for safe retries")
40
- .option("--dry-run", "Validate on the server (references, version, cascade) without writing");
41
- }
42
- function itemLayout(item) {
43
- if ("position" in item) {
44
- const size = "size" in item ? item.size : undefined;
45
- return { x: item.position.x, y: item.position.y, width: size?.width ?? "", height: size?.height ?? "" };
46
- }
47
- if (item.type === "draw") {
48
- const points = item.props.points;
49
- const strokeWidth = item.style?.strokeWidth ?? 4;
50
- const bounds = computeDrawBounds(points, strokeWidth);
51
- return { x: bounds.x, y: bounds.y, width: bounds.width, height: bounds.height };
52
- }
53
- const bounds = computeArrowFrame({
54
- start: item.props.start,
55
- end: item.props.end,
56
- bend: item.props.bend,
57
- size: item.style?.strokeWidth ?? 2.5,
58
- });
59
- return { x: bounds.x, y: bounds.y, width: bounds.width, height: bounds.height };
60
- }
61
- export function registerBoardItemCommands(boards) {
62
- const items = boards.command("items").description("Author Board items with semantic JSON");
63
- readOptions(withJson(items.command("list <board>").alias("ls").description("List semantic Board items")))
64
- .action(async (target, options) => {
65
- try {
66
- const board = await resolvedBoard(boards, target);
67
- const snapshot = await board.authoring(readInput(options, "items"));
68
- const items = snapshot.items ?? [];
69
- if (jsonRequested(options))
70
- return json(items);
71
- table(items.map((item) => ({
72
- id: item.id,
73
- type: item.type,
74
- ...itemLayout(item),
75
- })), [
76
- { key: "id", label: "ID" },
77
- { key: "type", label: "TYPE" },
78
- { key: "x", label: "X" },
79
- { key: "y", label: "Y" },
80
- { key: "width", label: "WIDTH" },
81
- { key: "height", label: "HEIGHT" },
82
- ]);
83
- }
84
- catch (cause) {
85
- handleHttp(cause);
86
- }
87
- });
88
- withJson(items.command("get <board> <item-id>").description("Get one complete Board item"))
89
- .action(async (target, itemId, options) => {
90
- try {
91
- const board = await resolvedBoard(boards, target);
92
- const snapshot = await board.authoring({ include: ["items"], itemIds: [itemId] });
93
- const item = snapshot.items?.[0];
94
- if (!item)
95
- throw new Error(`Item not found: ${itemId}`);
96
- if (jsonRequested(options))
97
- return json(item);
98
- table([{
99
- id: item.id,
100
- type: item.type,
101
- ...itemLayout(item),
102
- }], [
103
- { key: "id", label: "ID" },
104
- { key: "type", label: "TYPE" },
105
- { key: "x", label: "X" },
106
- { key: "y", label: "Y" },
107
- { key: "width", label: "WIDTH" },
108
- { key: "height", label: "HEIGHT" },
109
- ]);
110
- }
111
- catch (cause) {
112
- handleHttp(cause);
113
- }
114
- });
115
- mutationOptions(items.command("create <board>")
116
- .description("Create one item")
117
- .requiredOption("-i, --input <file>", "Board Item JSON; use - for stdin")
118
- .addHelpText("after", `
119
- Minimal text item:
120
- {"id":"title","type":"text","position":{"x":120,"y":80},"size":{"width":320,"height":48},"props":{"text":"Launch plan","fontSize":32},"style":{"color":"brand"}}`))
121
- .action(async (target, options) => {
122
- try {
123
- const value = await readBoardJsonObject(options.input, BOARD_DOMAIN_INPUT_MAX_BYTES);
124
- await execute(boards, target, {
125
- type: "item.create",
126
- item: BoardAuthoringItemSchema.parse(value),
127
- }, options);
128
- }
129
- catch (cause) {
130
- handleHttp(cause);
131
- }
132
- });
133
- mutationOptions(items.command("patch <board> <item-id>")
134
- .description("Recursively merge item fields")
135
- .requiredOption("-i, --input <file>", "Board Item patch JSON; use - for stdin")
136
- .addHelpText("after", `
137
- Objects merge recursively, arrays replace, and null clears optional fields.
138
- Move and rename a text item without replacing its size or font:
139
- {"position":{"x":160,"y":120},"props":{"text":"Updated"}}`))
140
- .action(async (target, itemId, options) => {
141
- try {
142
- const value = await readBoardJsonObject(options.input, BOARD_DOMAIN_INPUT_MAX_BYTES);
143
- await execute(boards, target, {
144
- type: "item.patch",
145
- itemId,
146
- patch: BoardItemPatchSchema.parse(value),
147
- }, options);
148
- }
149
- catch (cause) {
150
- handleHttp(cause);
151
- }
152
- });
153
- mutationOptions(items.command("replace <board> <item-id>")
154
- .description("Replace one complete item")
155
- .requiredOption("-i, --input <file>", "Complete Board Item JSON; use - for stdin"))
156
- .action(async (target, itemId, options) => {
157
- try {
158
- const value = await readBoardJsonObject(options.input, BOARD_DOMAIN_INPUT_MAX_BYTES);
159
- await execute(boards, target, {
160
- type: "item.replace",
161
- itemId,
162
- item: BoardAuthoringItemSchema.parse(value),
163
- }, options);
164
- }
165
- catch (cause) {
166
- handleHttp(cause);
167
- }
168
- });
169
- mutationOptions(items.command("delete <board> <item-id>").alias("rm")
170
- .description("Delete one item")
171
- .option("--cascade", "Atomically remove relations, effects, and animation references"))
172
- .action(async (target, itemId, options) => {
173
- try {
174
- await execute(boards, target, {
175
- type: "item.delete",
176
- itemId,
177
- cascade: Boolean(options.cascade),
178
- }, options);
179
- }
180
- catch (cause) {
181
- handleHttp(cause);
182
- }
183
- });
184
- }
@@ -1,12 +0,0 @@
1
- import type { BoardTransactionRecord } from "@neta-art/cohub";
2
- import type { Command } from "commander";
3
- /** Compact `type×count` summary, e.g. `node.patch×3 connection.create`. */
4
- export declare function summarizeOperations(operations: BoardTransactionRecord["operations"]): string;
5
- export declare function transactionRows(transactions: BoardTransactionRecord[]): {
6
- version: number;
7
- createdAt: string;
8
- actor: string;
9
- via: import("@neta-art/cohub/board").BoardReplayActorKind;
10
- changes: string;
11
- }[];
12
- export declare function registerBoardTransactionCommands(boards: Command): void;
@@ -1,69 +0,0 @@
1
- import { boardReplayActorKind } from "@neta-art/cohub/board";
2
- import { handleHttp, json, jsonRequested, table } from "../../output.js";
3
- import { finite, resolvedBoard, withJson } from "./context.js";
4
- const columns = [
5
- { key: "version", label: "VERSION" },
6
- { key: "createdAt", label: "AT" },
7
- { key: "actor", label: "ACTOR" },
8
- { key: "via", label: "VIA" },
9
- { key: "changes", label: "CHANGES" },
10
- ];
11
- /** Compact `type×count` summary, e.g. `node.patch×3 connection.create`. */
12
- export function summarizeOperations(operations) {
13
- const counts = new Map();
14
- for (const operation of operations)
15
- counts.set(operation.type, (counts.get(operation.type) ?? 0) + 1);
16
- return [...counts.entries()].map(([type, count]) => (count > 1 ? `${type}×${count}` : type)).join(" ");
17
- }
18
- export function transactionRows(transactions) {
19
- return transactions.map((transaction) => ({
20
- version: transaction.version,
21
- createdAt: transaction.createdAt,
22
- actor: transaction.actorId,
23
- via: boardReplayActorKind(transaction.source),
24
- changes: summarizeOperations(transaction.operations),
25
- }));
26
- }
27
- export function registerBoardTransactionCommands(boards) {
28
- withJson(boards
29
- .command("transactions <board>")
30
- .alias("history")
31
- .description("List the Board transaction log, newest first")
32
- .option("--before <version>", "Only transactions below this version")
33
- .option("--limit <count>", "Page size (max 500)", "50")
34
- .option("--operations", "Include full operations and inverses in --json output")
35
- .addHelpText("after", `
36
- Every applied mutation is one transaction. --json prints the page summary; add
37
- --operations for the full payloads, inverses and (on the newest page) the current
38
- node and connection rows, which is what the web replay view consumes.`)).action(async (target, options) => {
39
- try {
40
- const board = await resolvedBoard(boards, target);
41
- // The snapshot is only ever printed in full --json --operations output;
42
- // every other mode would fetch the whole Board just to drop it.
43
- const full = jsonRequested(options) && Boolean(options.operations);
44
- const page = await board.transactions({
45
- ...(options.before !== undefined ? { before: finite(options.before, "--before") } : {}),
46
- limit: finite(options.limit, "--limit", 50),
47
- snapshot: full,
48
- });
49
- if (jsonRequested(options)) {
50
- return json(full
51
- ? page
52
- : {
53
- ...page,
54
- transactions: page.transactions.map(({ operations, ...transaction }) => ({
55
- ...transaction,
56
- operationCount: operations.length,
57
- })),
58
- });
59
- }
60
- table(transactionRows(page.transactions), columns);
61
- if (page.nextBefore !== null) {
62
- console.log(`\nOlder transactions: --before ${page.nextBefore}`);
63
- }
64
- }
65
- catch (cause) {
66
- handleHttp(cause);
67
- }
68
- });
69
- }