@kb-labs/qa-contracts 0.6.0

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.
package/LICENSE ADDED
@@ -0,0 +1,4 @@
1
+ This project is licensed under the same terms as the KB Labs Plugin Template root project.
2
+
3
+ See the root LICENSE file at the repository root for full details.
4
+
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @kb-labs/plugin-template-contracts
2
+
3
+ Lightweight public contracts package for the plugin: it describes guaranteed artifacts, commands, workflows, API payloads, and the version of these promises.
4
+
5
+ ## Why this package exists
6
+
7
+ Every KB Labs plugin is expected to publish a clear, lightweight “promise” to the rest of the ecosystem. This package is that promise: it contains only types, manifests, and validation helpers, so other teams (CLI, Workflow Engine, Studio, REST, marketplace tooling) can rely on a single source of truth without dragging in plugin runtime code.
8
+
9
+ ## Quick start checklist
10
+
11
+ 1. Clone this package as part of your plugin workspace (`packages/contracts`).
12
+ 2. Update `pluginContractsManifest` with your plugin ID and initial artifacts/commands.
13
+ 3. Adjust Zod schemas in `src/schema.ts` (or add new ones) to match your payloads.
14
+ 4. Bump `contractsVersion` whenever the public promise changes (SemVer rules below).
15
+ 5. Run `pnpm test` and `pnpm type-check` to ensure the manifest validates.
16
+ 6. Import the manifest in your CLI/REST/workflow code to avoid hard-coded IDs.
17
+
18
+ ### Renaming this package
19
+
20
+ When you turn the template into your own plugin:
21
+ - Change the npm name in `package.json` (e.g. `@kb-labs/my-plugin-contracts`).
22
+ - Update `pluginContractsManifest.pluginId` in `src/contract.ts`.
23
+ - Adjust aliases in `tsconfig.paths.json` and imports across the workspace (`@kb-labs/plugin-template-contracts` → your new name).
24
+ - Replace sample artifact IDs (`template.hello.*`) with your own naming scheme.
25
+
26
+ ## What's inside
27
+
28
+ - `pluginContractsManifest` — the single source of truth for the plugin's public capabilities
29
+ - TypeScript types (`src/types`) and Zod schemas (`src/schema`) for artifacts, commands, workflows, and API payloads
30
+ - `parsePluginContracts` utility for runtime validation of the manifest and third-party contracts
31
+
32
+ ## Versioning rules
33
+
34
+ - `contractsVersion` follows SemVer and is **independent** from the plugin's npm version.
35
+ - **MAJOR** — breaking changes (removing/renaming artifacts, changing payload formats).
36
+ - **MINOR** — backwards-compatible extensions (new artifacts, commands, fields).
37
+ - **PATCH** — documentation/metadata updates without altering payload formats.
38
+
39
+ ## Minimal manifest example
40
+
41
+ ```ts
42
+ import type { PluginContracts } from '@kb-labs/plugin-template-contracts';
43
+
44
+ export const pluginContractsManifest: PluginContracts = {
45
+ schema: 'kb.plugin.contracts/1',
46
+ pluginId: '@kb-labs/my-plugin',
47
+ contractsVersion: '1.0.0',
48
+ artifacts: {
49
+ 'my-plugin.result': {
50
+ id: 'my-plugin.result',
51
+ kind: 'json',
52
+ description: 'Primary output of the CLI command.'
53
+ }
54
+ }
55
+ // commands/workflows/api can be added later when needed
56
+ };
57
+ ```
58
+
59
+ ## Optional sections
60
+
61
+ All additional sections are **optional** — include only what your plugin actually supports:
62
+
63
+ - `commands` — define CLI or workflow commands that produce/consume artifacts.
64
+ - `workflows` — describe composed workflows and their steps.
65
+ - `api` — document REST (or future surfaces) when the plugin exposes them.
66
+
67
+ If your plugin only ships a CLI command, keep `commands` + `artifacts` and omit `workflows`/`api`. The Zod schema accepts missing sections.
68
+
69
+ ## Usage in plugin code
70
+
71
+ ```ts
72
+ import { pluginContractsManifest } from '@kb-labs/plugin-template-contracts';
73
+
74
+ const helloArtifactId = pluginContractsManifest.artifacts['template.hello.greeting'].id;
75
+ ```
76
+
77
+ Use the manifest to avoid magic strings, assert that required artifacts exist, or log which promises were fulfilled.
78
+
79
+ ## Who relies on the contract
80
+
81
+ - **Workflow Engine** — verifies allowed steps, required artifacts, and matches produced results with the contract.
82
+ - **Studio** — builds UI and hints based on declared artifacts and commands.
83
+ - **CLI / REST / other plugins** — reuse types and schemas as the source of truth, validate inputs/outputs.
84
+ - **Marketplace & QA tooling** — checks plugin compatibility and correctness before publishing.
85
+
86
+ ## Looking ahead
87
+
88
+ - Generate JSON Schema / OpenAPI from the `api` contract surface.
89
+ - Add automatic inspectors in Studio and validators for the marketplace.
90
+