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:
@ -37,12 +37,24 @@ Key APIs:
|
||||
Use `runCommand()` only after preconditions are satisfied. `ownerAgentId` must be
|
||||
a real agent id when work belongs to an agent workflow.
|
||||
|
||||
`runCommand()` is project/workspace scoped. Its `cwd` option is a relative path
|
||||
under the project root, and `command`/`args` are not resolved against the
|
||||
calling plugin's package. The SDK does not currently provide a public
|
||||
`pluginRoot` or package-path resolver for runtime command handlers. Packaged
|
||||
scripts cannot be launched through `runCommand()` by referring to their
|
||||
package-relative path.
|
||||
`runCommand()` keeps its `cwd` project/workspace scoped: `cwd` must be a relative
|
||||
path under the project root. The host does not implicitly resolve `command` or
|
||||
`args` against the plugin package. Use the absolute `ctx.pluginRoot` supplied at
|
||||
activation time to construct an explicit path to a packaged script, and pass
|
||||
that path as `command` or as an argument to its interpreter. Treat package files
|
||||
as read-only.
|
||||
|
||||
```ts
|
||||
const script = `${ctx.pluginRoot.replace(/[\\/]+$/, "")}/scripts/check.mjs`;
|
||||
await ctx.services.tasks.runCommand({
|
||||
projectId,
|
||||
ownerAgentId,
|
||||
label: "Run packaged check",
|
||||
command: "node",
|
||||
args: [script],
|
||||
cwd: "."
|
||||
});
|
||||
```
|
||||
|
||||
## Tooling
|
||||
|
||||
|
||||
Reference in New Issue
Block a user