feat(sdk,plugins): ajoute capability tooling et services runtime publics (workspace/terminal/tasks)

- capability manifeste tooling supportée backend + transport runtime catalog
- ctx.services publique côté SDK/runtime, gated par tooling
- surface honnête: workspace, terminal, et tasks en observation/contrôle uniquement
- docs/exemple/tests mis à jour
- QA PASS sur feature/sdk-plugin-tooling-build-debug-surface
This commit is contained in:
2026-08-02 00:31:15 +02:00
parent efaeb31a38
commit 033e9a86d5
21 changed files with 748 additions and 10 deletions

View File

@ -178,6 +178,68 @@ describe("loadPlugins", () => {
expect(registry.get("com.example.hello-plugin")).toBeUndefined();
});
it("does not inject the public plugin services facade without the tooling capability", async () => {
const bundle = dataUrl(`
export function activate(ctx) {
globalThis.__servicesWithoutTooling = ctx.services;
}
`);
const { failures } = await loadPlugins(
[entry({ id: "dev.acme.no-services", displayName: "No Services", bundleUrl: bundle })],
gateways,
);
expect(failures).toEqual([]);
expect((globalThis as Record<string, unknown>).__servicesWithoutTooling).toBeUndefined();
});
it("injects the public plugin services facade for plugins declaring tooling", async () => {
const bundle = dataUrl(`
export function activate(ctx) {
globalThis.__serviceKeys = Object.keys(ctx.services).sort();
globalThis.__workspaceServiceKeys = Object.keys(ctx.services.workspace).sort();
globalThis.__taskServiceKeys = Object.keys(ctx.services.tasks).sort();
globalThis.__terminalServiceKeys = Object.keys(ctx.services.terminal).sort();
}
`);
const { failures } = await loadPlugins(
[
entry({
id: "dev.acme.services",
displayName: "Services",
capabilities: ["tooling"],
bundleUrl: bundle,
}),
],
gateways,
);
expect(failures).toEqual([]);
expect((globalThis as Record<string, unknown>).__serviceKeys).toEqual([
"tasks",
"terminal",
"workspace",
]);
expect((globalThis as Record<string, unknown>).__workspaceServiceKeys).toEqual([
"getCurrentProject",
"getProjectRoot",
"readProjectContext",
"updateProjectContext",
]);
expect((globalThis as Record<string, unknown>).__taskServiceKeys).toEqual([
"attachOutput",
"cancel",
"getStatus",
"list",
"retry",
]);
expect((globalThis as Record<string, unknown>).__terminalServiceKeys).toEqual([
"close",
"open",
"reattach",
]);
});
it("loads the hello-plugin command and layout contribution shape", async () => {
const bundle = dataUrl(`
export function activate(ctx) {