forked from 1b-agent/opencadstudio-upstream
Merge pull request #1423 from felixriestra:pr/python-host-model
The bundled `opencad.python` plugin drives OCS through plugin API v7: all 43 canvas entity kinds, the drawing tables, and OCS's own commands run step by step. RustPython stays in the plugin process — the plugin crate is outside the workspace with its own lock file, so the application's own dependencies are unchanged. Reconciled with the plugin command work that landed as #1425, which the branch was written before: - Both added `impl Drop for PluginProcessInteractiveAdapter`, which git merges silently into two impls that do not compile. One body now cancels the command and then drops it from the runner, in that order: a plugin waiting on a step has to be released before the runner forgets the command. - `execute_command` (#1425) and `run_command` (#1423) are both routes from a script to the command line, and only the second was guarded. The SCRIPTCOMMANDS switch and the denylist are shared now, so neither route is the unguarded one. - `run_command` dispatched with plugin dispatch still enabled, so a script naming a plugin command re-entered the plugin that was blocked waiting for it. It sets the suppression flag for the length of the dispatch, as `execute_command` does. The denylist read the command as typed, while the dispatcher resolves aliases: a user-defined `Q` for `QUIT` (ALIASEDIT writes those) walked past it. It resolves the alias first. Also: the active-command comparison ran on every message, a mouse move included, allocating two strings for names that are already `&'static str`; SCRIPTCOMMANDS' own messages go through the translation macros; and `docs/.DS_Store` (now ignored) and an unrelated RTF note about constraint commands are out of the tree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
commit
41ecc0c458
72 files changed
+30614
-91
No files matched your search
@@ -9,7 +9,7 @@ cheaply. The runtime host surface is enabled by the `host` feature.
|
||||
## Plugin Architecture
|
||||
|
||||
OCS is scriptable and extensible through a versioned plugin API. The API
|
||||
supports four major generations: **V2**, **V3**, **V4**, and **V5**. Each
|
||||
supports five major generations: **V2**, **V3**, **V4**, **V5**, and **V6**. Each
|
||||
generation keeps the previous ABI stable by appending new vtable entries and new
|
||||
enum variants at the end, so older plugins continue to load on newer hosts.
|
||||
|
||||
@@ -19,10 +19,11 @@ enum variants at the end, so older plugins continue to load on newer hosts.
|
||||
| **V3** | Out-of-process runner | Local cached `document()`/`document_mut()` + shared-memory `DocumentReader`/`document_view` for large reads | New vtable entries appended; new `PluginRequest`/`PluginResponse` variants appended |
|
||||
| **V4** | Out-of-process runner over a multiplexed local socket | Full-duplex notifications + asynchronous REPL `ExecuteCode` | New `HostToPluginV4`/`PluginToHostV4` frame layer; `BuiltinPlugin::on_notification` and `start_execute_code` appended to trait |
|
||||
| **V5** | V4 multiplexed runner | One-shot initialization + tab-keyed document paths | `BuiltinPlugin::on_load` and `HostApi::document_path` appended to the traits |
|
||||
| **V6** | V4 multiplexed runner | Read and write supported host system variables | `HostApi::system_variable` and `HostApi::set_system_variable` appended to the trait; request/response variants appended |
|
||||
|
||||
The host controls which generations are accepted at runtime through
|
||||
`OCS_PLUGIN_MAX_API_VERSION` (e.g. `2` for V2-only mode, `4` to disable V5). The
|
||||
current host advertises [`API_VERSION = 5`](src/manifest.rs) and supports plugins
|
||||
`OCS_PLUGIN_MAX_API_VERSION` (e.g. `2` for V2-only mode, `5` to disable V6). The
|
||||
current host advertises [`API_VERSION = 6`](src/manifest.rs) and supports plugins
|
||||
back to `API_VERSION_MIN_SUPPORTED = 2`.
|
||||
|
||||
V5 calls `BuiltinPlugin::on_load` once after the runner connects and before the
|
||||
@@ -30,6 +31,10 @@ first user command. Plugins can cache `HostApi::plugin_request_sender()` there
|
||||
for worker-thread access. A panic in the callback fails plugin loading.
|
||||
`HostApi::document_path(tab_id)` returns the saved path for a document tab.
|
||||
|
||||
V6 adds a typed system-variable interface. This fork currently implements
|
||||
`CLAYER` (current drawing layer) and `SNAPANG` (snap-angle degrees). Unknown
|
||||
variables return an error rather than silently accepting a value.
|
||||
|
||||
### High-level layout
|
||||
|
||||
```mermaid
|
||||
|
||||
Reference in new issue
Block a user