@pi-harness/plugin-api 0.1.27 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +14 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -43,6 +43,20 @@ The bare `import type {} from "@pi-harness/plugin-api"` is what applies the `Con
43
43
 
44
44
  `examples/plugin-hello` in the repository is this plugin with its tests.
45
45
 
46
+ ## Test a plugin against a real runtime
47
+
48
+ `@pi-harness/core/test-harness` boots the harness services a plugin injects - resources, session, tools and, with `createTestRuntimeContext`, the runtime - against a stub model provider, so a test can activate the plugin and call its tools without a network or an API key. Install `@pi-harness/core` as a `devDependency` to use it; the plugin itself still depends only on this package.
49
+
50
+ ```ts
51
+ import { createTestRuntimeServices } from "@pi-harness/core/test-harness";
52
+
53
+ const { context } = await createTestRuntimeServices([]);
54
+ await context.plugin(helloPlugin, {});
55
+ expect(context.piTools.snapshot().customTools.map((tool) => tool.name)).toContain("hello");
56
+ ```
57
+
58
+ The argument is the list of scripted model responses; pass `[]` for a plugin that never prompts the model, and use `createTestRuntimeContext` instead when the test needs the runtime to answer one. Every plugin under `packages/plugins` in the repository is tested this way.
59
+
46
60
  ## Exports
47
61
 
48
62
  - **Services** — the service interfaces the harness puts on the Cordis `Context` (`PiToolsSnapshot`, `PiSessionService`, `PiModelsService`, `PiRuntimeService`, `PiResourcesService`, `PiMcpService`, `PiTelemetryService`, `PiHarnessLaunch`), the `declare module` augmentation that attaches them, and the `PiToolRegistry` / `PiPluginUiRegistry` a test can construct directly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/plugin-api",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Public contract for authoring Pi Harness plugins: Cordis context services, plugin configuration helpers, and bounded workspace file access",
5
5
  "keywords": [
6
6
  "agent",