@kb-labs/qa-core 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/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # @kb-labs/plugin-template-cli
2
+
3
+ Reference CLI/REST/Studio plugin package for KB Labs Plugin Template.
4
+
5
+ ## Vision & Purpose
6
+
7
+ **@kb-labs/plugin-template-cli** is the canonical example plugin package used by `@kb-labs/plugin-template`.
8
+ It shows how to implement a plugin that exposes:
9
+
10
+ - a **CLI command** (Hello),
11
+ - a **REST handler**, and
12
+ - a **Studio widget**,
13
+
14
+ all driven by a single manifest and contracts package.
15
+
16
+ ## Package Status
17
+
18
+ - **Version**: 0.1.0
19
+ - **Stage**: Stable (template)
20
+ - **Status**: Reference Implementation ✅
21
+
22
+ ## Architecture
23
+
24
+ ### High-Level Overview
25
+
26
+ ```
27
+ plugin-cli
28
+
29
+ ├──► contracts (from @kb-labs/plugin-template-contracts)
30
+ ├──► shared (constants/helpers)
31
+ ├──► domain (Greeting entity and invariants)
32
+ ├──► application (use-cases: create greeting, etc.)
33
+ ├──► cli (Hello command wiring)
34
+ ├──► rest (Hello REST handler + schema)
35
+ └──► studio (Hello Studio widget)
36
+ ```
37
+
38
+ ### Key Components
39
+
40
+ - `src/domain/`: `Greeting` entity and domain rules
41
+ - `src/application/`: use-cases that orchestrate domain logic
42
+ - `src/cli/commands/hello/*`: CLI command implementation
43
+ - `src/rest/handlers/hello-handler.ts`: REST handler bound to manifest
44
+ - `src/studio/widgets/hello-widget.tsx`: Studio widget implementation
45
+ - `src/manifest.v2.ts`: Plugin manifest v2 (CLI/REST/Studio wiring)
46
+
47
+ ## Features
48
+
49
+ - **Single-source manifest** for CLI/REST/Studio surfaces
50
+ - **Layered architecture** (shared → domain → application → interface)
51
+ - **Type-safe contracts** via `@kb-labs/plugin-template-contracts`
52
+ - **Hello-world flow** demonstrating end-to-end plugin wiring
53
+
54
+ ## Exports
55
+
56
+ From `src/index.ts`:
57
+
58
+ - `manifest`: Plugin Manifest V2
59
+ - All public surfaces:
60
+ - CLI command exports
61
+ - domain/application/shared re-exports
62
+
63
+ ## Dependencies
64
+
65
+ ### Runtime
66
+
67
+ - `@kb-labs/setup-operations`: reusable setup operations
68
+ - `@kb-labs/plugin-manifest`: manifest types and helpers
69
+ - `@kb-labs/plugin-template-contracts`: public contracts for this template plugin
70
+ - `@kb-labs/shared-cli-ui`: shared CLI UI helpers
71
+ - `react`, `react-dom`, `zod`
72
+
73
+ ### Development
74
+
75
+ - `@kb-labs/devkit`: shared TS/ESLint/Vitest/TSUP presets
76
+ - `typescript`, `tsup`, `vitest`, `rimraf`
77
+
78
+ ## Scripts
79
+
80
+ From `kb-labs-plugin-template` repo root:
81
+
82
+ ```bash
83
+ pnpm install
84
+ pnpm --filter @kb-labs/plugin-template-cli build
85
+ pnpm --filter @kb-labs/plugin-template-cli test
86
+ ```
87
+
88
+ To run sandboxes, see the root `README.md` (`pnpm sandbox:cli`, `sandbox:rest`, `sandbox:studio`).
89
+
90
+ ## Command Implementation
91
+
92
+ This template demonstrates **three different approaches** to implementing CLI commands:
93
+
94
+ 1. **High-level wrapper (`defineCommand`)** - Recommended for most cases
95
+ 2. **Low-level atomic tools** - For maximum control
96
+ 3. **Hybrid approach** - Combining both
97
+
98
+ See [`COMMAND_IMPLEMENTATION_GUIDE.md`](./COMMAND_IMPLEMENTATION_GUIDE.md) for detailed explanations and examples.
99
+
100
+ ### Quick Start
101
+
102
+ The `template:hello` command in `src/cli/commands/hello/run.ts` shows all three approaches with working code examples. The default implementation uses Approach 1 (`defineCommand`), which provides:
103
+
104
+ - ✅ Zero-boilerplate flag validation
105
+ - ✅ Automatic analytics integration
106
+ - ✅ Structured logging
107
+ - ✅ Error handling
108
+ - ✅ Timing tracking
109
+ - ✅ JSON output mode
110
+
111
+ ## Customising for Your Plugin
112
+
113
+ When using this as a starting point:
114
+
115
+ - Rename the package in `package.json` (e.g. `@kb-labs/my-plugin-cli`)
116
+ - Update manifest IDs and the contracts package
117
+ - Replace the Hello flow with your own domain, use-cases, and surfaces
118
+ - Choose the command implementation approach that fits your needs (see `COMMAND_IMPLEMENTATION_GUIDE.md`)
119
+
120
+
@@ -0,0 +1,27 @@
1
+ import { BaselineSnapshot, QAResults, BaselineDiff } from '@kb-labs/qa-contracts';
2
+
3
+ /**
4
+ * Load baseline snapshot from disk.
5
+ */
6
+ declare function loadBaseline(rootDir: string): BaselineSnapshot | null;
7
+ /**
8
+ * Save baseline snapshot to disk.
9
+ */
10
+ declare function saveBaseline(rootDir: string, snapshot: BaselineSnapshot): void;
11
+
12
+ /**
13
+ * Create a baseline snapshot from QA results.
14
+ */
15
+ declare function createBaselineFromResults(results: QAResults, rootDir: string): BaselineSnapshot;
16
+ /**
17
+ * Run full QA and capture baseline.
18
+ */
19
+ declare function captureBaseline(rootDir: string): Promise<BaselineSnapshot>;
20
+
21
+ /**
22
+ * Compare current QA results with a baseline snapshot.
23
+ * Returns per-check-type diff with newFailures, fixed, stillFailing, delta.
24
+ */
25
+ declare function compareWithBaseline(results: QAResults, baseline: BaselineSnapshot): BaselineDiff;
26
+
27
+ export { captureBaseline, compareWithBaseline, createBaselineFromResults, loadBaseline, saveBaseline };