rubrkit 0.1.0 → 0.3.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 CHANGED
@@ -1,126 +1,417 @@
1
- # Rubrkit CLI
2
-
3
- Local v1 package for pulling Rubrkit artifact-bundle files into agent projects and testing artifacts from local projects or CI.
4
-
5
- The package folder is `tools/rubrkit-cli`, but the intended published package name and executable are `rubrkit` so users can run:
6
-
7
- ```bash
8
- npx rubrkit pull [all|<artifact-bundle-or-artifact-selector>]
9
- npx rubrkit validate <path|glob>
10
- npx rubrkit test <path|glob|artifact-bundle-or-artifact-selector>
11
- npx rubrkit audit <artifact-bundle-or-selector>
12
- npx rubrkit eval <artifact-bundle-or-selector>
13
- npx rubrkit report <job-or-run-id>
14
- ```
15
-
16
- ## Auth
17
-
18
- Use a Rubrkit API key for pull commands and remote checks. Prefer a pull key scoped to `artifacts:pull`. For `rubrkit test <path> --remote`, use a testing key scoped to the existing composed API flow: `artifact_bundles:write`, `files:write`, `audits:run`, `jobs:read`, and `credits:read`.
19
-
20
- ```bash
21
- RUBRKIT_API_KEY=... rubrkit pull all --yes
22
- ```
23
-
24
- `--api-key` is also supported for secret-manager wrappers. API keys are never written to `.rubrkit/manifest.json`, local reports, fixtures, or snapshots.
25
-
26
- ## Pull Examples
27
-
28
- ```bash
29
- rubrkit pull
30
- rubrkit pull all --yes
31
- rubrkit pull team-agent-kit --destination .
32
- rubrkit pull --artifact-bundle team-agent-kit --artifact AGENTS.md --yes
33
- rubrkit pull all --yes --dry-run
34
- ```
35
-
36
- Useful flags:
37
-
38
- ```text
39
- --destination <path>
40
- --agent <auto|codex|claude|generic>
41
- --artifact-bundle <id-or-name>
42
- --artifact <id-or-path>
43
- --rubric <rubric-id-or-path>
44
- --format <text|json|junit>
45
- --output <path>
46
- --fail-under <score>
47
- --fail-on <critical|high|medium|low>
48
- --ci
49
- --local
50
- --remote
51
- --no-ai
52
- --watch
53
- --changed
54
- --all
55
- --yes
56
- --dry-run
57
- --force
58
- --prune
59
- --update-only
60
- --config <path>
61
- --api-url <url>
62
- --api-key <key>
63
- ```
64
-
65
- ## Testing Examples
66
-
67
- Local validation runs without network access or credits where possible:
68
-
69
- ```bash
70
- rubrkit validate docs/example.rubr_flow
71
- rubrkit test "prompts/**/*.md" --local --format json
72
- ```
73
-
74
- Remote checks use the public `/api/v1` API, create async jobs, and poll `/jobs/{jobId}`. Local-file remote tests create or select an artifact bundle, upload the local text files, then start an audit job:
75
-
76
- ```bash
77
- RUBRKIT_API_KEY=... rubrkit test team-agent-kit --remote --format json
78
- RUBRKIT_API_KEY=... rubrkit audit team-agent-kit --fail-under 85 --ci
79
- RUBRKIT_API_KEY=... rubrkit eval team-agent-kit --format junit --output rubrkit-junit.xml
80
- RUBRKIT_API_KEY=... rubrkit report <job-id>
81
- ```
82
-
83
- Use `--dry-run --remote` to inspect the remote request shape without calling the API.
84
-
85
- Exit codes:
86
-
87
- - `0`: checks passed.
88
- - `1`: checks completed and failed validation or quality gates.
89
- - `2`: invalid CLI usage or invalid config.
90
- - `3`: authentication or authorization failure.
91
- - `4`: credit, usage-limit, or circuit-breaker block.
92
- - `5`: network, provider, or server failure.
93
-
94
- ## SDK
95
-
96
- The current local package exports the SDK from `rubrkit` while final package naming awaits owner approval.
97
-
98
- ```js
99
- import { Rubrkit } from 'rubrkit';
100
-
101
- const client = new Rubrkit({ apiKey: process.env.RUBRKIT_API_KEY });
102
- const started = await client.artifacts.test({ artifactBundleId: 'team-agent-kit' });
103
- const job = await client.jobs.wait(started.jobId);
104
- ```
105
-
106
- ## Placement
107
-
108
- - Codex primary artifacts are placed as `AGENTS.md`; supporting files go under `.rubrkit/artifacts/<bundle>/`.
109
- - Claude primary artifacts are placed as `CLAUDE.md`, or `.claude/CLAUDE.md` when that file already exists; supporting files go under `.rubrkit/artifacts/<bundle>/`.
110
- - Generic placement preserves artifact paths under `.rubrkit/artifacts/<bundle>/`.
111
-
112
- The CLI protects existing local files unless they were previously managed by Rubrkit and match the local manifest. Use `--force` to overwrite after reviewing the plan.
113
-
114
- ## Postinstall
115
-
116
- Rubrkit does not run network sync from its own package lifecycle. Consuming projects can opt in:
117
-
118
- ```json
119
- {
120
- "scripts": {
121
- "postinstall": "rubrkit pull all --yes"
122
- }
123
- }
124
- ```
125
-
126
- Postinstall commands should use `RUBRKIT_API_KEY` and an unambiguous selector.
1
+ # Rubrkit CLI
2
+
3
+ Pull Rubrkit artifact bundles into agent projects and validate/test artifacts locally or remotely.
4
+
5
+ ```bash
6
+ npx rubrkit pull [all|<artifact-bundle-or-artifact-selector>] [options]
7
+ npx rubrkit validate <path|glob> [options]
8
+ npx rubrkit test <path|glob|artifact-bundle-or-artifact-selector> [options]
9
+ npx rubrkit audit <artifact-bundle-or-selector> [options]
10
+ npx rubrkit eval <artifact-bundle-or-selector> [options]
11
+ npx rubrkit report <job-or-run-id> [options]
12
+ ```
13
+
14
+ ## Commands
15
+
16
+ ### pull
17
+
18
+ Downloads artifact bundles from Rubrkit and writes them to your local project.
19
+
20
+ **Syntax:**
21
+ ```bash
22
+ rubrkit pull [all|<bundle>] [options]
23
+ ```
24
+
25
+ **Examples:**
26
+ ```bash
27
+ rubrkit pull # Interactive mode
28
+ rubrkit pull all --yes # Pull all bundles without confirmation
29
+ rubrkit pull team-agent-kit # Pull one bundle
30
+ rubrkit pull --artifact-bundle team-agent-kit --artifact AGENTS.md # Pull specific artifact
31
+ rubrkit pull --label prod --yes # Pull every bundle carrying a label
32
+ rubrkit pull all --yes --dry-run # Preview what would be written
33
+ ```
34
+
35
+ **Requires:** `RUBRKIT_API_KEY` environment variable or `--api-key` flag. Use a key scoped to `artifacts:pull`.
36
+
37
+ ### validate
38
+
39
+ Checks artifact syntax and structure locally (no API calls, no credits).
40
+
41
+ **Syntax:**
42
+ ```bash
43
+ rubrkit validate <path|glob> [options]
44
+ ```
45
+
46
+ **Examples:**
47
+ ```bash
48
+ rubrkit validate docs/example.rubr_flow
49
+ rubrkit validate "prompts/**/*.md" --format json
50
+ ```
51
+
52
+ ### test
53
+
54
+ Validates artifacts locally or submits them to Rubrkit for remote testing and quality scoring.
55
+
56
+ **Syntax:**
57
+ ```bash
58
+ rubrkit test <path|glob|artifact-bundle-or-artifact-selector> [options]
59
+ ```
60
+
61
+ **Examples:**
62
+ ```bash
63
+ rubrkit test "prompts/**/*.md" --local --format json # Local only, no API
64
+ RUBRKIT_API_KEY=... rubrkit test team-agent-kit --remote # Remote test with scoring
65
+ ```
66
+
67
+ ### audit
68
+
69
+ Submits artifacts to Rubrkit and runs audit checks with quality gates.
70
+
71
+ **Syntax:**
72
+ ```bash
73
+ rubrkit audit <artifact-bundle-or-selector> [options]
74
+ ```
75
+
76
+ **Examples:**
77
+ ```bash
78
+ RUBRKIT_API_KEY=... rubrkit audit team-agent-kit --fail-under 85 --ci
79
+ RUBRKIT_API_KEY=... rubrkit audit team-agent-kit --no-cache # Force a fresh run
80
+ ```
81
+
82
+ **Deterministic results (caching):** Audit results are cached per account by a content hash of the inputs (artifact contents, rubric, artifact type, and the scoring engine/model version). Re-running an audit on unchanged inputs returns the identical stored result instantly, charges no credits, and creates no job — so repeated CI runs are reproducible. The result is reported as cached (the text output prints `Cached: yes`; JSON/JUnit payloads carry a `cached` field). Changing any input — or a server-side engine/model version bump — produces a fresh result automatically. Use `--no-cache` to bypass the cache and force a fresh run.
83
+
84
+ **Requires:** `RUBRKIT_API_KEY` environment variable or `--api-key` flag. Use a key scoped to: `artifact_bundles:write`, `files:write`, `audits:run`, `jobs:read`, `credits:read`.
85
+
86
+ ### eval
87
+
88
+ Evaluates artifacts against rubrics with detailed scoring and reporting.
89
+
90
+ **Syntax:**
91
+ ```bash
92
+ rubrkit eval <artifact-bundle-or-selector> [options]
93
+ ```
94
+
95
+ **Examples:**
96
+ ```bash
97
+ RUBRKIT_API_KEY=... rubrkit eval team-agent-kit --format junit --output rubrkit-junit.xml
98
+ ```
99
+
100
+ **Requires:** API key with testing scope (same as `audit`).
101
+
102
+ ### report
103
+
104
+ Fetches results from a completed async job.
105
+
106
+ **Syntax:**
107
+ ```bash
108
+ rubrkit report <job-id> [options]
109
+ ```
110
+
111
+ **Examples:**
112
+ ```bash
113
+ RUBRKIT_API_KEY=... rubrkit report job-abc-123 --format json
114
+ ```
115
+
116
+ **Requires:** API key with `jobs:read` scope.
117
+
118
+ ---
119
+
120
+ ## Flags
121
+
122
+ ### Output & Formatting
123
+
124
+ **`--format <text|json|junit>`**
125
+ Output format for test/audit/eval results. Defaults to `text`.
126
+ - `text`: Human-readable summary
127
+ - `json`: Structured JSON for parsing
128
+ - `junit`: JUnit XML for CI systems
129
+
130
+ **`--output <path>`**
131
+ Write results to a file instead of stdout.
132
+
133
+ ### Artifact Selection
134
+
135
+ **`--artifact-bundle <id-or-name>`**
136
+ Select a specific artifact bundle to pull or test.
137
+
138
+ **`--artifact <id-or-path>`**
139
+ Select a specific artifact file within a bundle.
140
+
141
+ **`--label <name>`**
142
+ Pull every artifact in all bundles carrying this label. Repeatable and comma-separated, with **OR** semantics — a bundle matches if it has ANY of the given labels (`--label prod --label api` or `--label prod,api`). Cannot be combined with a positional selector, `--artifact-bundle`, or `--artifact`. Create and attach labels in the Rubrkit dashboard.
143
+
144
+ **`--rubric <rubric-id-or-path>`**
145
+ Select a specific evaluation rubric for audits.
146
+
147
+ **`--all`**
148
+ Pull all available bundles (requires `--yes` for safety). Equivalent to `rubrkit pull all`.
149
+
150
+ ### Quality Gates
151
+
152
+ **`--fail-under <score>`**
153
+ Exit with code 1 if the quality score falls below this threshold (0-100). Only applies to test/audit/eval.
154
+
155
+ **`--fail-on <critical|high|medium|low>`**
156
+ Exit with code 1 if any findings at this severity level or higher are detected.
157
+
158
+ ### Execution Mode
159
+
160
+ **`--local`**
161
+ Run checks locally without making API calls or consuming credits. Cannot be combined with `--remote`.
162
+
163
+ **`--remote`**
164
+ Submit artifacts to Rubrkit for remote testing. Requires API key. Cannot be combined with `--local`. Default for `test`/`audit`/`eval` without `--local`.
165
+
166
+ **`--ci`**
167
+ Run in CI mode: non-interactive, structured output, appropriate exit codes.
168
+
169
+ **`--no-ai`**
170
+ Skip AI-powered analysis (reduces cost, available for some commands).
171
+
172
+ **`--no-cache`**
173
+ Bypass the per-account audit result cache and force a fresh run, even when an identical prior result exists. Applies to `audit` (and `test`, which composes an audit). The fresh result becomes the new cached result for those inputs. Without this flag, identical inputs return the stored result instantly at no credit cost.
174
+
175
+ ### Pull-Specific Flags
176
+
177
+ **`--agent <auto|codex|claude|generic>`**
178
+ Target agent type for placement decisions. `auto` detects from project structure.
179
+
180
+ **`--destination <path>`**
181
+ Target directory for pulling artifacts. Defaults to current directory.
182
+
183
+ **`--force`**
184
+ Overwrite protected local changes. By default, `pull` stops if existing files differ from tracked versions.
185
+
186
+ **`--prune`**
187
+ Remove manifest-tracked files that are no longer selected.
188
+
189
+ **`--update-only`**
190
+ Only update files already tracked in `.rubrkit/manifest.json`. Skip new files.
191
+
192
+ **`--yes` or `-y`**
193
+ Skip interactive confirmation for unambiguous pulls.
194
+
195
+ ### Testing & Debugging
196
+
197
+ **`--dry-run`**
198
+ Preview planned actions without changing files or making API calls. Useful with `--remote` to inspect request payloads.
199
+
200
+ **`--watch`**
201
+ Re-run checks when local files change (development mode).
202
+
203
+ **`--changed`**
204
+ Only test files changed since last run.
205
+
206
+ ### Configuration
207
+
208
+ **`--config <path>`**
209
+ Load options from a JSON config file. API keys are not allowed in config files; use environment variables instead.
210
+
211
+ **`--api-url <url>`**
212
+ Override the Rubrkit API endpoint. Defaults to `RUBRKIT_API_URL` env var or `https://rubrkit.com/api/v1`.
213
+
214
+ **`--api-key <key>`**
215
+ Provide the API key explicitly (use `RUBRKIT_API_KEY` env var for security).
216
+
217
+ ### Help
218
+
219
+ **`--help` or `-h`**
220
+ Show command help.
221
+
222
+ **`--version` or `-v`**
223
+ Show CLI version.
224
+
225
+ ---
226
+
227
+ ## Authentication
228
+
229
+ Rubrkit requires API keys for `pull`, `test`, `audit`, `eval`, and `report` commands.
230
+
231
+ **Set the key via environment variable (recommended):**
232
+ ```bash
233
+ export RUBRKIT_API_KEY=your_api_key_here
234
+ rubrkit pull all --yes
235
+ ```
236
+
237
+ **Or pass it directly (avoid in scripts/CI):**
238
+ ```bash
239
+ rubrkit pull all --yes --api-key your_api_key_here
240
+ ```
241
+
242
+ **API key scopes:**
243
+ - **Pull:** `artifacts:pull`
244
+ - **Test/Audit/Eval/Report:** `artifact_bundles:write`, `files:write`, `audits:run`, `jobs:read`, `credits:read`
245
+
246
+ Keys are never saved to `.rubrkit/manifest.json`, logs, or client bundles.
247
+
248
+ ---
249
+
250
+ ## Artifact Placement
251
+
252
+ Artifacts are placed based on your agent type (`--agent auto|codex|claude|generic`):
253
+
254
+ | Agent | Primary Artifact | Supporting Files | Auto-Detect |
255
+ |-------|------------------|------------------|------------|
256
+ | **codex** | `AGENTS.md` | `.rubrkit/artifacts/<bundle>/` | Looks for `AGENTS.md` |
257
+ | **claude** | `CLAUDE.md` (or `.claude/CLAUDE.md` if exists) | `.rubrkit/artifacts/<bundle>/` | Looks for `CLAUDE.md` or `.claude/` |
258
+ | **generic** | Preserves original paths | `.rubrkit/artifacts/<bundle>/` | Default fallback |
259
+ | **auto** | Detects from project structure | `.rubrkit/artifacts/<bundle>/` | Recommended for new projects |
260
+
261
+ Pull creates a `.rubrkit/manifest.json` to track managed files. Existing files are protected unless they match the manifest or you use `--force`.
262
+
263
+ ---
264
+
265
+ ## Exit Codes
266
+
267
+ - **0:** Success. Checks passed or command completed without errors.
268
+ - **1:** Validation/quality checks failed (threshold not met, findings detected, etc.).
269
+ - **2:** Invalid CLI usage or configuration error.
270
+ - **3:** Authentication or authorization failure (missing or invalid API key).
271
+ - **4:** Rate limited, usage blocked, or circuit breaker active.
272
+ - **5:** Network, API, or server failure.
273
+
274
+ ---
275
+
276
+ ## Examples
277
+
278
+ ### Pull artifacts
279
+ ```bash
280
+ # Interactive: prompts for bundle and artifact selection
281
+ rubrkit pull
282
+
283
+ # Pull all bundles non-interactively
284
+ RUBRKIT_API_KEY=my_key rubrkit pull all --yes
285
+
286
+ # Pull one bundle to a custom location
287
+ RUBRKIT_API_KEY=my_key rubrkit pull team-agent-kit --destination ./my-agents
288
+
289
+ # Preview without writing
290
+ RUBRKIT_API_KEY=my_key rubrkit pull all --yes --dry-run
291
+
292
+ # Update only already-tracked files, skip new ones
293
+ RUBRKIT_API_KEY=my_key rubrkit pull --update-only --yes
294
+
295
+ # Pull every bundle carrying a label (OR across multiple labels)
296
+ RUBRKIT_API_KEY=my_key rubrkit pull --label prod --label api --yes
297
+ ```
298
+
299
+ ### Validate artifacts locally
300
+ ```bash
301
+ # Check syntax
302
+ rubrkit validate docs/example.rubr_flow
303
+
304
+ # Batch validate with glob
305
+ rubrkit validate "prompts/**/*.md" --format json
306
+ ```
307
+
308
+ ### Test artifacts
309
+ ```bash
310
+ # Local validation (no API, no cost)
311
+ rubrkit test "prompts/**/*.md" --local --format json
312
+
313
+ # Remote test with scoring (requires API key)
314
+ RUBRKIT_API_KEY=my_key rubrkit test team-agent-kit --remote
315
+
316
+ # Remote with quality gates
317
+ RUBRKIT_API_KEY=my_key rubrkit test team-agent-kit --remote --fail-under 80
318
+ ```
319
+
320
+ ### Audit with CI output
321
+ ```bash
322
+ # Generate JUnit XML for GitHub Actions / GitLab CI
323
+ RUBRKIT_API_KEY=my_key rubrkit audit team-agent-kit \
324
+ --format junit \
325
+ --output test-results.xml \
326
+ --ci \
327
+ --fail-under 85
328
+ ```
329
+
330
+ ### Postinstall hook
331
+ ```json
332
+ {
333
+ "scripts": {
334
+ "postinstall": "rubrkit pull all --yes"
335
+ }
336
+ }
337
+ ```
338
+
339
+ ---
340
+
341
+ ## SDK
342
+
343
+ Import the Rubrkit SDK for programmatic use:
344
+
345
+ ```js
346
+ import { Rubrkit } from 'rubrkit';
347
+
348
+ const client = new Rubrkit({ apiKey: process.env.RUBRKIT_API_KEY });
349
+
350
+ // Test an artifact bundle
351
+ const started = await client.artifacts.test({ artifactBundleId: 'team-agent-kit' });
352
+ const job = await client.jobs.wait(started.jobId);
353
+
354
+ // Get job results
355
+ const results = await client.jobs.get(job.jobId);
356
+ console.log(results.score, results.findings);
357
+ ```
358
+
359
+ ---
360
+
361
+ ## Configuration File
362
+
363
+ Create `.rubrkit/config.json` (or pass `--config path/to/config.json`):
364
+
365
+ ```json
366
+ {
367
+ "destination": ".",
368
+ "agent": "claude",
369
+ "format": "json",
370
+ "failUnder": 85,
371
+ "failOn": "high"
372
+ }
373
+ ```
374
+
375
+ **Note:** API keys are not allowed in config files. Always use `RUBRKIT_API_KEY` environment variable for security.
376
+
377
+ ---
378
+
379
+ ## Common Patterns
380
+
381
+ ### CI/CD Integration
382
+ ```bash
383
+ # GitHub Actions
384
+ - name: Pull Rubrkit artifacts
385
+ env:
386
+ RUBRKIT_API_KEY: ${{ secrets.RUBRKIT_API_KEY }}
387
+ run: npx rubrkit pull all --yes
388
+
389
+ - name: Audit artifacts
390
+ env:
391
+ RUBRKIT_API_KEY: ${{ secrets.RUBRKIT_API_KEY }}
392
+ run: npx rubrkit audit team-agent-kit --ci --format junit --output results.xml --fail-under 80
393
+ ```
394
+
395
+ ### Development Workflow
396
+ ```bash
397
+ # Watch for changes and re-validate
398
+ rubrkit test "prompts/**/*.md" --local --watch
399
+
400
+ # Or in package.json
401
+ "scripts": {
402
+ "validate": "rubrkit validate docs/CLAUDE.md",
403
+ "test": "rubrkit test docs/CLAUDE.md --local"
404
+ }
405
+ ```
406
+
407
+ ---
408
+
409
+ ## Troubleshooting
410
+
411
+ **Missing API key:** Set `RUBRKIT_API_KEY` or pass `--api-key` for commands requiring authentication.
412
+
413
+ **Local file conflicts:** Use `--dry-run` to preview, then `--force` to overwrite, or manually resolve and retry.
414
+
415
+ **Slow remote tests:** Use `--local` for quick validation, `--remote --no-ai` to skip expensive analysis.
416
+
417
+ **Rate limited:** Wait and retry. Consider using `--ci` to reduce request overhead in high-volume scenarios.
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "rubrkit",
3
- "version": "0.1.0",
4
- "type": "module",
5
- "description": "Rubrkit CLI for pulling artifact bundles into local agent projects.",
6
- "bin": {
7
- "rubrkit": "./bin/rubrkit.js"
8
- },
9
- "exports": {
10
- ".": {
11
- "types": "./src/index.d.ts",
12
- "default": "./src/sdk.js"
13
- }
14
- },
15
- "types": "./src/index.d.ts",
16
- "files": [
17
- "bin",
18
- "src",
19
- "README.md",
20
- "package.json"
21
- ],
22
- "engines": {
23
- "node": ">=22"
24
- },
25
- "scripts": {
26
- "test": "node --test \"test/**/*.test.js\""
27
- }
28
- }
1
+ {
2
+ "name": "rubrkit",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "description": "Rubrkit CLI for pulling artifact bundles into local agent projects.",
6
+ "bin": {
7
+ "rubrkit": "./bin/rubrkit.js"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./src/index.d.ts",
12
+ "default": "./src/sdk.js"
13
+ }
14
+ },
15
+ "types": "./src/index.d.ts",
16
+ "files": [
17
+ "bin",
18
+ "src",
19
+ "README.md",
20
+ "package.json"
21
+ ],
22
+ "engines": {
23
+ "node": ">=22"
24
+ },
25
+ "scripts": {
26
+ "test": "node --test \"test/**/*.test.js\""
27
+ }
28
+ }