@bushscad/cli 0.3.0 → 0.3.1

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/package.json CHANGED
@@ -1,49 +1,50 @@
1
1
  {
2
- "name": "@bushscad/cli",
3
- "version": "0.3.0",
4
- "type": "module",
5
- "bin": {
6
- "bushscad": "./dist/index.js"
7
- },
8
- "exports": {
9
- ".": "./dist/index.js",
10
- "./protocol": "./src/dto/index.ts"
11
- },
12
- "scripts": {
13
- "build": "node scripts/build.mjs",
14
- "typecheck": "tsc --noEmit \u0026\u0026 tsc --noEmit -p tsconfig.test.json",
15
- "test": "vitest run",
16
- "prepack": "npm run build"
17
- },
18
- "dependencies": {
19
- "@bushscad/compiler": "^0.3.0",
20
- "@bushscad/ir": "^0.3.0",
21
- "opencascade.js": "\u003e=2.0.0-0"
22
- },
23
- "devDependencies": {
24
- "esbuild": "^0.28.0",
25
- "typescript": "^5.4.0",
26
- "vitest": "^4.1.5"
27
- },
28
- "license": "Apache-2.0",
29
- "description": "The command-line compiler and service interface for BushSCAD. The published package includes the bundled runtime and fonts; OpenCascade is installed as a package dependency.",
30
- "homepage": "https://bushscad.byaidan.com/",
31
- "repository": {
32
- "type": "git",
33
- "url": "git+https://github.com/AidanBoissonneault/BushSCAD-Language.git",
34
- "directory": "packages/cli"
35
- },
36
- "bugs": {
37
- "url": "https://github.com/AidanBoissonneault/BushSCAD-Language/issues"
38
- },
39
- "publishConfig": {
40
- "access": "public",
41
- "registry": "https://registry.npmjs.org/"
42
- },
43
- "files": [
44
- "dist/**",
45
- "src/dto/**",
46
- "LICENSE",
47
- "README.md"
48
- ]
2
+ "name": "@bushscad/cli",
3
+ "version": "0.3.1",
4
+ "type": "module",
5
+ "bin": {
6
+ "bushscad": "./dist/index.js"
7
+ },
8
+ "exports": {
9
+ ".": "./dist/index.js",
10
+ "./protocol": "./src/dto/index.ts"
11
+ },
12
+ "scripts": {
13
+ "build": "node scripts/build.mjs",
14
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
15
+ "test": "vitest run",
16
+ "prepack": "npm run build"
17
+ },
18
+ "dependencies": {
19
+ "@bushscad/compiler": "^0.3.0",
20
+ "@bushscad/ir": "^0.3.0",
21
+ "opencascade.js": ">=2.0.0-0"
22
+ },
23
+ "devDependencies": {
24
+ "esbuild": "^0.28.0",
25
+ "typescript": "^5.4.0",
26
+ "vitest": "^4.1.5"
27
+ },
28
+ "license": "Apache-2.0",
29
+ "description": "The command-line compiler and service interface for BushSCAD. The published package includes the bundled runtime and fonts; OpenCascade is installed as a package dependency.",
30
+ "homepage": "https://bushscad.byaidan.com/",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/AidanBoissonneault/BushSCAD-Language.git",
34
+ "directory": "packages/cli"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/AidanBoissonneault/BushSCAD-Language/issues"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "registry": "https://registry.npmjs.org/"
42
+ },
43
+ "files": [
44
+ "dist/**",
45
+ "src/dto/**",
46
+ "src/service/parallel/worker-protocol.ts",
47
+ "LICENSE",
48
+ "README.md"
49
+ ]
49
50
  }
@@ -0,0 +1,164 @@
1
+ /**
2
+ * @author Aidan Boissonneault
3
+ * @file worker-protocol.ts
4
+ * @purpose Provides worker protocol behavior for the service parallel in cli package.
5
+ * @last-edited October 6, 2026
6
+ */
7
+
8
+ import type {
9
+ CompileAssets,
10
+ DrawingProgram,
11
+ DrawingResult,
12
+ SourceSpan,
13
+ ExportFormat,
14
+ IRProgram,
15
+ InteractionSnapshot,
16
+ MeshData,
17
+ NativeBooleanBatchPlan,
18
+ OcctTraceEvent,
19
+ PreparedComponentArtifact,
20
+ ResolvedJointData,
21
+ ValidationResult,
22
+ } from '@bushscad/ir';
23
+
24
+ /**
25
+ * Parallel build task, including task id, part name, source index, auto color offset, and
26
+ * program.
27
+ */
28
+ export type ParallelBuildTask = {
29
+ taskId: number;
30
+ partName: string;
31
+ sourceIndex: number;
32
+ autoColorOffset: number;
33
+ program: IRProgram;
34
+ assets: CompileAssets;
35
+ trace: boolean;
36
+ drawingProgram?: DrawingProgram;
37
+ preparedComponents?: PreparedComponentArtifact[];
38
+ nativeBooleanPlan?: NativeBooleanBatchPlan;
39
+ nativeBooleanConcurrencyLimit?: number;
40
+ };
41
+
42
+ /**
43
+ * Parallel worker telemetry, including worker cpu milliseconds and worker rss bytes.
44
+ */
45
+ export type ParallelWorkerTelemetry = {
46
+ workerCpuMs: number;
47
+ workerRssBytes: number;
48
+ };
49
+
50
+ /**
51
+ * Derives `ParallelBuildOutput` from `ParallelWorkerTelemetry & { taskId: number; partName: string;
52
+ * sourceIndex: number; meshes: MeshData[]; drawings: DrawingResult[]; interaction?:
53
+ * InteractionSnapshot; validations: ValidationResult[]; joints: ResolvedJointData[]; traceEvents:
54
+ * OcctTraceEvent[]; elapsedMs: number; }` to preserve its type relationship in the service parallel
55
+ * layer.
56
+ */
57
+ export type ParallelBuildOutput = ParallelWorkerTelemetry & {
58
+ taskId: number;
59
+ partName: string;
60
+ sourceIndex: number;
61
+ meshes: MeshData[];
62
+ drawings: DrawingResult[];
63
+ interaction?: InteractionSnapshot;
64
+ validations: ValidationResult[];
65
+ joints: ResolvedJointData[];
66
+ traceEvents: OcctTraceEvent[];
67
+ elapsedMs: number;
68
+ };
69
+
70
+ /**
71
+ * Parallel component task, including task id, part name, source index, name, and recipe digest.
72
+ */
73
+ export type ParallelComponentTask = {
74
+ taskId: number;
75
+ partName: string;
76
+ sourceIndex: number;
77
+ name: string;
78
+ recipeDigest: string;
79
+ program: IRProgram;
80
+ assets: CompileAssets;
81
+ semanticConsumerIds: string[];
82
+ trace: boolean;
83
+ };
84
+
85
+ /**
86
+ * Derives `ParallelComponentOutput` from `ParallelWorkerTelemetry & { taskId: number; partName:
87
+ * string; sourceIndex: number; recipeDigest: string; artifact: PreparedComponentArtifact; traceEvents:
88
+ * OcctTraceEvent[]; startedAtMs: number; finishedAtMs: number; elapsedMs: number; }` to preserve its
89
+ * type relationship in the service parallel layer.
90
+ */
91
+ export type ParallelComponentOutput = ParallelWorkerTelemetry & {
92
+ taskId: number;
93
+ partName: string;
94
+ sourceIndex: number;
95
+ recipeDigest: string;
96
+ artifact: PreparedComponentArtifact;
97
+ traceEvents: OcctTraceEvent[];
98
+ startedAtMs: number;
99
+ finishedAtMs: number;
100
+ elapsedMs: number;
101
+ };
102
+
103
+ /**
104
+ * Parallel export task, including task id, program, assets, drawing program, and export format.
105
+ */
106
+ export type ParallelExportTask = {
107
+ taskId: number;
108
+ program: IRProgram;
109
+ assets: CompileAssets;
110
+ drawingProgram: DrawingProgram;
111
+ format: ExportFormat;
112
+ nativeBooleanPlan?: NativeBooleanBatchPlan;
113
+ };
114
+
115
+ /**
116
+ * Derives `ParallelExportOutput` from `ParallelWorkerTelemetry & { taskId: number; buffers: { name:
117
+ * string; data: ArrayBuffer }[]; drawings: DrawingResult[]; elapsedMs: number; }` to preserve its type
118
+ * relationship in the service parallel layer.
119
+ */
120
+ export type ParallelExportOutput = ParallelWorkerTelemetry & {
121
+ taskId: number;
122
+ buffers: { name: string; data: ArrayBuffer }[];
123
+ drawings: DrawingResult[];
124
+ elapsedMs: number;
125
+ };
126
+
127
+ /**
128
+ * Request to parallel worker is tagged by kind: 'build' carries task, 'prepare-component'
129
+ * carries task, 'export' carries task, and 'shutdown'.
130
+ */
131
+ export type ParallelWorkerRequest =
132
+ | { kind: 'build'; task: ParallelBuildTask }
133
+ | { kind: 'prepare-component'; task: ParallelComponentTask }
134
+ | { kind: 'export'; task: ParallelExportTask }
135
+ | { kind: 'shutdown' };
136
+
137
+ /**
138
+ * Message for parallel worker is tagged by kind: 'ready' carries startup duration, worker rss
139
+ * bytes, 'trace' carries task id, event, 'result' carries output, 'component-result' carries
140
+ * output, 'export-result' carries output, and 'error' carries task id, message, span.
141
+ */
142
+ export type ParallelWorkerMessage =
143
+ | { kind: 'ready'; startupMs: number; workerRssBytes: number }
144
+ | { kind: 'trace'; taskId: number; event: OcctTraceEvent }
145
+ | { kind: 'result'; output: ParallelBuildOutput }
146
+ | { kind: 'component-result'; output: ParallelComponentOutput }
147
+ | { kind: 'export-result'; output: ParallelExportOutput }
148
+ | { kind: 'error'; taskId: number; message: string; span?: SourceSpan };
149
+
150
+ /**
151
+ * Status of parallel pool, including current state, desired worker count, warming workers, ready
152
+ * worker count, and busy workers.
153
+ */
154
+ export type ParallelPoolStatus = {
155
+ state: 'warming' | 'ready' | 'busy' | 'degraded' | 'failed' | 'stopped';
156
+ desiredWorkers: number;
157
+ warmingWorkers: number;
158
+ readyWorkers: number;
159
+ busyWorkers: number;
160
+ failedWorkers: number;
161
+ startupMs: number;
162
+ aggregateWorkerRssBytes: number;
163
+ peakAggregateWorkerRssBytes: number;
164
+ };