@snaptrude/plugin-client 0.0.8 → 0.0.9

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 (3) hide show
  1. package/AGENTS.md +92 -0
  2. package/CLAUDE.md +11 -0
  3. package/package.json +2 -2
package/AGENTS.md ADDED
@@ -0,0 +1,92 @@
1
+ # Plugin Client — Agent Guide
2
+
3
+ This package implements the plugin-core API for the **worker side** (plugin runtime).
4
+ Plugins import `snaptrude` from this package to interact with the Snaptrude host.
5
+
6
+ ## Relationship to plugin-core
7
+
8
+ > Source of truth: [`packages/plugin-core/AGENTS.md`](../plugin-core/AGENTS.md)
9
+
10
+ This package **extends** every abstract class defined in `@snaptrude/plugin-core`.
11
+ When plugin-core changes, this package must be updated to match.
12
+
13
+ ## What this package contains
14
+
15
+ - `src/api/` — Concrete implementations of all plugin-core abstract APIs
16
+ - `src/host-api.ts` — Comlink RPC wrapper (`HostApi.call()`) for host API calls
17
+ - `src/plugin-worker.ts` — `PluginWorker` base class (lifecycle, UI messaging, Comlink exposure)
18
+ - `src/index.ts` — Exports the `snaptrude` singleton (`ClientPluginApi` instance)
19
+
20
+ ## Quick commands
21
+
22
+ ```bash
23
+ pnpm check-types # typecheck (no emit)
24
+ pnpm build # tsup build (ESM + CJS)
25
+ pnpm dev # tsup watch mode
26
+ ```
27
+
28
+ ## Implementation patterns
29
+
30
+ ### Pure math/geometry (sync, local)
31
+
32
+ Methods on `core.math.*` and `core.geom.*` are implemented directly — they inherit
33
+ the base class implementation or override with equivalent logic. No RPC involved.
34
+
35
+ ```typescript
36
+ // Example: ClientVec3Api inherits PluginVec3Api directly
37
+ export class ClientVec3Api extends PluginVec3Api {}
38
+ ```
39
+
40
+ ### Host API calls (async, RPC)
41
+
42
+ Methods on `entity.*`, `tools.*`, and `units.*` marshal calls to the host via Comlink:
43
+
44
+ ```typescript
45
+ public async createRectangular(args: PluginSpaceCreateRectangularArgs) {
46
+ const hostApi = getHostApi()
47
+ return hostApi.call({
48
+ method: "entity.space.createRectangular",
49
+ args,
50
+ })
51
+ }
52
+ ```
53
+
54
+ The `method` string must match the dot-separated path from `PluginApiMethod` (auto-inferred
55
+ from the class hierarchy in `plugin-core/src/host-utils.ts`).
56
+
57
+ ## When to update this package
58
+
59
+ - **plugin-core adds a new abstract method**: Add the concrete implementation here
60
+ - **plugin-core removes a method**: Remove the implementation here
61
+ - **plugin-core changes a signature**: Update the method signature + call args here
62
+ - **plugin-core adds a new API module**: Create a matching file under `src/api/`, wire
63
+ into the parent barrel (`index.ts`), and add to `ClientPluginApi`
64
+
65
+ After making changes, always run `pnpm check-types` to verify everything compiles.
66
+
67
+ ## File mapping (plugin-core -> plugin-client)
68
+
69
+ | plugin-core | plugin-client |
70
+ | ------------------------------------- | ------------------------------------------ |
71
+ | `src/api/core/math/vec3.ts` | `src/api/core/math/vec3.ts` |
72
+ | `src/api/core/math/quat.ts` | `src/api/core/math/quat.ts` |
73
+ | `src/api/core/geom/line.ts` | `src/api/core/geom/line.ts` |
74
+ | `src/api/core/geom/arc.ts` | `src/api/core/geom/arc.ts` |
75
+ | `src/api/core/geom/curve.ts` | `src/api/core/geom/curve.ts` |
76
+ | `src/api/core/geom/profile.ts` | `src/api/core/geom/profile.ts` |
77
+ | `src/api/entity/space.ts` | `src/api/entity/space.ts` |
78
+ | `src/api/entity/story.ts` | `src/api/entity/story.ts` |
79
+ | `src/api/entity/referenceLine.ts` | `src/api/entity/referenceLine.ts` |
80
+ | `src/api/entity/department.ts` | `src/api/entity/department.ts` |
81
+ | `src/api/tools/selection.ts` | `src/api/tools/selection.ts` |
82
+ | `src/api/tools/transform.ts` | `src/api/tools/transform.ts` |
83
+ | `src/api/units/index.ts` | `src/api/units/index.ts` |
84
+ | `src/api/index.ts` (`PluginApi`) | `src/api/index.ts` (`ClientPluginApi`) |
85
+
86
+ ## Downstream consumers
87
+
88
+ Changes to this package's **public exports** affect:
89
+ - Internal plugins under `plugins/`
90
+ - Example plugins under `examples/`
91
+
92
+ If you change or remove an export, search these directories for usage.
package/CLAUDE.md ADDED
@@ -0,0 +1,11 @@
1
+ # CLAUDE.md
2
+
3
+ > **All coding standards, checks, and guidance live in [`AGENTS.md`](AGENTS.md).**
4
+ > `CLAUDE.md` is a pointer only — add all new rules, patterns, and instructions to `AGENTS.md`.
5
+
6
+ See [AGENTS.md](AGENTS.md) for:
7
+
8
+ - Implementation patterns (sync math vs async RPC)
9
+ - File mapping from plugin-core to plugin-client
10
+ - When and how to update this package in response to plugin-core changes
11
+ - Downstream consumer notes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snaptrude/plugin-client",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "comlink": "^4.4.2",
21
- "@snaptrude/plugin-core": "0.0.8"
21
+ "@snaptrude/plugin-core": "0.0.9"
22
22
  },
23
23
  "devDependencies": {
24
24
  "tsup": "^8.5.1",