feat(sdk): pluginRoot officiel exposé dans activate(ctx) — #285 (src/runtime: champ pluginRoot = racine du package installé; docs activation-context/commands-and-feedback/services/manifest réécrits du constat d'absence vers le contrat d'usage officiel — runCommand reste project-scoped, pluginRoot utilisable dans command/args, substitution manifest ${pluginRoot}/${appDataDir} inchangée pour mcpServers; exemple hello-plugin: script packagé scripts/hello-task.mjs consommé via ctx.pluginRoot, packaging étendu; QA verte: npm run check — build, typecheck:examples, package:hello-plugin, artefact zip vérifié)
This commit is contained in:
@ -6,7 +6,10 @@ The plugin entrypoint exports `activate(ctx)`.
|
||||
import type { ActivateContext, IdeAPluginModule } from "@idea/plugin-sdk";
|
||||
|
||||
export function activate(ctx: ActivateContext): void {
|
||||
ctx.logger.info("activated", { pluginId: ctx.pluginId });
|
||||
ctx.logger.info("activated", {
|
||||
pluginId: ctx.pluginId,
|
||||
pluginRoot: ctx.pluginRoot
|
||||
});
|
||||
}
|
||||
|
||||
export default { activate } satisfies IdeAPluginModule;
|
||||
@ -28,6 +31,7 @@ focused project at invocation/render time.
|
||||
## Context Fields
|
||||
|
||||
- `pluginId`: host-provided plugin identity.
|
||||
- `pluginRoot`: absolute host-local path to the active installed plugin package.
|
||||
- `logger`: `debug`, `info`, `warn`, `error`.
|
||||
- `subscriptions`: push disposables returned by command/layout/watch
|
||||
registrations.
|
||||
@ -41,11 +45,11 @@ focused project at invocation/render time.
|
||||
The context never exposes internal IdeA gateways or Tauri commands. Use
|
||||
`ctx.services` and the registration APIs instead.
|
||||
|
||||
`ActivateContext` does not expose the plugin installation directory, package
|
||||
root, archive root or a file URL that plugins can convert into a local path.
|
||||
Plugin runtime code must treat packaged files as unavailable to
|
||||
`ctx.services.tasks.runCommand()` unless a dedicated public SDK API documents
|
||||
otherwise. Workspace services resolve project-owned paths only.
|
||||
`pluginRoot` identifies the committed package currently loaded by IdeA. It is
|
||||
not the original source directory or archive path and may change after reinstall.
|
||||
Treat it as read-only, do not persist it, and resolve packaged scripts/assets
|
||||
under it only while the plugin is active. Workspace services remain confined to
|
||||
project-owned paths.
|
||||
|
||||
## Disposal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user