feat(plugins): add plugin run targets and interpreter routing

Цей коміт міститься в:
l0ng-ai committed 2026-11-09 07:47:24 +08:00
1 джерело 7a9baac475
коміт adc252ccd4
131 files changed
+1401 -84

No files matched your search

+56
Переглянути файл
@@ -495,6 +495,8 @@ then run `openidea-plugin check`.
| `host::reveal_view(view)` | `views.reveal` | Brings one of your declared `[[contributes.views]]` to the front in the calling window. |
| `host::post_view_message(view, text)` | `views.post-message` | To the script of the view's `html` body. |
| `host::open_terminal(title, program, args)` | `views.open-terminal` | A terminal tab in the invoking window running the approved `process:<program>` in the project root: output that keeps coming, interactive sessions. |
| `host::register_run_target(project, target)` | `run-targets.register` | API 1.4: project-scoped, read-only argv wrapper; requires its process grant, executable pin and project trust; remote projects run on the server. |
| `host::unregister_run_target(project, id)` | `run-targets.unregister` | Withdraw this plugin's target; remembered prompt answers remain. |
| `host::start_run(config, args, debug)` | `run.start` | API 1.4: start an owned configuration in this window's Run tool window; returns an id, followed by `run-exited`. Approved `process:` program; commands/events only. |
| `host::open_terminal_session(key, title, cmd)` | `views.open-terminal-session` | API 1.4: keyed, pinned terminal in this window, append-only env; returns its operation id and later `terminal-exited`. |
| `host::write_terminal(key, text)` | `views.write-terminal` | API 1.4: write only to this plugin's still-running terminal in this window; trusted project, commands/events only. |
@@ -2060,3 +2062,57 @@ one dismisses the balloon and runs the command in the receiving window with
its normal editor and project context. No capability is needed. Invalid or
undeclared actions reject the whole notification. Labels are limited to 256
bytes and arguments to 64 KiB. Plain `host::notify` behaves as before.
### Plugin-provided run targets (API 1.4)
`host::register_run_target(project, target)` registers or replaces a read-only,
project-scoped target owned by the plugin. `host::unregister_run_target(project,
id)` removes it. `PluginRunTarget` has `id`, `name`, a granted `process:` `program`,
`args`, `workdir_args`, optional `container_root`, and `commands` (pairs of tool
names and replacement argv). Targets appear in Settings › Run Targets and every
run configuration's Run on selector, labelled with their plugin. They survive
idle instance reclamation; stopping, disabling, reloading or uninstalling a plugin
withdraws them. Registrations and execution for remote projects are on the server.
A missing target fails the run rather than silently using the local tool.
For each launch the host checks project trust and the wrapper's current process
grant and executable pin, including per-project executable choices. Debugging on
plugin targets returns `invalid`; language servers are not run in these targets.
There are at most 32 targets per plugin/project, 64 unique command overrides and
256 arguments per prefix (16 KiB each, 256 KiB metadata per registration).
The host constructs argv directly, without a shell:
- No override: `program + args + workdir_args + command + command arguments`.
- Override matching `wrap::program_name(command)` (basename without `.exe`, `.cmd`
or `.bat`): `program + override + workdir_args + command arguments`. The override
replaces **both** the prefix and the command name and includes the tool itself.
DDEV, for example: `program = "ddev"`, `args = ["exec"]`,
`commands = [("composer", ["composer"])]` runs `php x.php` as
`ddev exec php x.php` and `composer install` as `ddev composer install`.
Local absolute tool paths outside the project use the tool basename.
When `container_root` is set, project paths in argv map under that root. Each
`workdir_args` element may contain `{cwd}`; for example `["--dir", "{cwd}"]`.
The host substitutes the configuration's working directory mapped under
`container_root`. It omits **all** workdir arguments when there is no container
root or the working directory is outside the project. Without `workdir_args`,
the wrapper manages its container directory itself. The wrapper process always
starts in the configuration's **local** working directory, so tools such as DDEV
can find their project. Configuration env and env files reach the local wrapper;
no generic env-forwarding flags are added. Container env is forwarded only if
the wrapper's own conventions allow it.
Registration never changes a selection. The first registration prompts the
project's windows: “Use <name> for running PHP / Node / Composer in this project?”
with **Use** / **Not now**. The first answer is remembered on the host per
project + plugin + target id. Use sets the project's default run target and its
PHP and Node run-target choices; Not now leaves settings alone. Interpreters
also have a Run in target choice in Settings (Default run target, Local machine,
or a named target). The `languages.php.runTarget` / `languages.node.runTarget`
settings store a selector id, empty for the default, or `local` for local execution. Code-created PHP/Node runs,
Composer/npm scripts, PHPUnit and Node tests use that choice through the normal
Run flow. Explicit per-configuration targets take precedence. Choosing Local
machine explicitly overrides defaults. Language servers, tool discovery/version
probes and external analysis helpers remain local to the host.
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
1fff539520d04708c37de01116f55f2453d638600cd879d0494d405427d7253e
ff03abdb82800057592e18466292e642ad18f644eab5855993cd67e00850698b
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
da99bca60545937b82fc6f88aeca392cd991c6d8f21bbd04fb25965c3cb24856
6429c38a0dbc856e4b992e4ec80148e75b54a87730c8e1b137169d259f3d6d54
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
334dc90682133da39fa190e0a95a85d32bbeeadba704c918122fe390d3989c6d
41c3f77d244a40c27a52cd66b1514dea9be0cb6cde85515d72f67cd1b8dabab1
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
d0886a4b074f2cdb119a8c74bf13b95592a3f4f4b1df80dffca92554560821dc
14f8678dd23d0dd9d6e25b4af27a6d964010eebd5715c6ea8fe49aff91811dbe
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
1aaa0540c035bcf93dc81756b771ebb77f70bebf63cf43cededc80a0688c1aac
765857e31af345347bda02016f4162e90cd5e3f4fc4d19957d867ea1a0d88b02
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
c062aec81853deafa036eac3174475935f41ff0fb75567aba570be64bb6dc4e2
f1b38b7bde8db372ef45077db017d2612712bc4ff1d3946136e3b3bc2c197a75
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
0a1a92812b92b7d62ec662d73316767cb8c0435c7b4823842ba873be7bfa771d
661638c93c0e695bf61b647289cf5f242c5d057fa1ebc176768166053254d364
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
e036b4f5dc4d6e072ebaa4d3be8072236c130a6ec3c5d303f2a0680245d4e223
ccbfb3bd2f763aaca519947d7205236108201919effd848f7963c850337f0773
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
2a48ef3332a70b6b71ebc0469dcb01e8ba8c56cdfc360af0fc75b27886d76577
d83934c41880875ac20ffa119dba61d9fc04339653df1cbcc2da9f6465360dcf
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
815f433e3a004079ab0cc2e9f07943488df17e933735b86875fc980d4ccff506
1f423f8744f7470b43b364ed3b42b283039a3700fa908b7052d163afe9fdb427
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
6e70e57bf86e2d65e0b299e8ec02f9e74323a6d5ca8507bae5b4ccd59dbcefe3
4f70b1ec6d7ba5e67d5d49607ba30185cd7c0842b229a732ad6f17bf32ebb24c