Skip to content

Commit 8e49595

Browse files
committed
refactor(plugin)!: restructure plugin architecture for better context management
BREAKING CHANGE: Plugin structure completely reorganized Split monolithic configuration into focused components following Claude Code plugin best practices for context optimization: Skills (3 files): - probitas-setup: CLI installation and project initialization - probitas-write: Scenario writing (delegates to agent) - probitas-run: Running and debugging scenarios Rules (6 files with paths: "**/*.probitas.ts"): - import: Import statements - pattern: Export pattern and scenario structure - assertions: expect() chaining - mistakes: Common mistakes (casting, null checks, specialized methods) - best-practices: Step naming, tags, cleanup - context: Step context (ctx) usage Agent: - scenario-writer: Enhanced with template, checklist, and comprehensive API reference links for all 13 clients Commands: - Updated documentation URLs to point to official docs - Fixed glob patterns (probitas/ → **/*.probitas.ts) - Added lint rules exclusion for JSR imports Why this structure: - Rules auto-load when editing *.probitas.ts (lazy loading) - Skills trigger on description keywords (proactive) - Agent runs in isolated context with full reference material - Eliminates duplication between components
1 parent 7b4603f commit 8e49595

File tree

18 files changed

+374
-273
lines changed

18 files changed

+374
-273
lines changed

plugins/probitas/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ scenario testing framework.
77

88
### Rules
99

10-
- **conventions** - File structure, naming, and coding conventions (always
11-
applied)
10+
Applied automatically when editing `*.probitas.ts` files:
11+
12+
- **import** - Import statements
13+
- **pattern** - Export pattern (single/multiple)
14+
- **assertions** - expect() chaining rules
15+
- **mistakes** - Common mistakes to avoid
16+
- **best-practices** - Best practices
17+
- **context** - Step context (ctx) usage
1218

1319
### Skills
1420

15-
- **probitas** - Scenario testing knowledge and patterns (on-demand)
21+
- **probitas-setup** - CLI installation and project setup
22+
- **probitas-write** - Scenario writing (delegates to agent)
23+
- **probitas-run** - Running and debugging scenarios
1624

1725
### Commands
1826

@@ -21,12 +29,11 @@ scenario testing framework.
2129
| `/probitas:init` | Initialize a Probitas project |
2230
| `/probitas:run [selector]` | Run scenarios |
2331
| `/probitas:new <type>` | Generate scenario template |
24-
| `/probitas:check` | Run syntax check |
32+
| `/probitas:check` | Run format, lint, type check |
2533

2634
### Agents
2735

28-
- **scenario-writer** - Specialized agent for creating integration test
29-
scenarios
36+
- **scenario-writer** - Create and edit `*.probitas.ts` files
3037

3138
## Installation
3239

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,67 @@
11
---
22
name: scenario-writer
3-
description: Create integration test scenarios. Use when user needs Probitas scenarios.
3+
description: Create and edit *.probitas.ts files. Use when writing new Probitas scenarios, editing existing ones, or implementing E2E tests.
44
---
55

6-
Expert Probitas scenario writer. Documentation-driven, best practices.
6+
## Template
7+
8+
```typescript
9+
import { client, expect, scenario } from "jsr:@probitas/probitas";
10+
11+
export default scenario("Test name", { tags: ["..."] })
12+
.resource("http", () =>
13+
client.http.createHttpClient({
14+
url: Deno.env.get("API_URL") ?? "http://localhost:8080",
15+
}))
16+
.step("Step name", async (ctx) => {
17+
const res = await ctx.resources.http.post("/endpoint", { body: {} });
18+
expect(res).toBeOk().toHaveStatus(200);
19+
return res.json<{ id: number }>()!;
20+
})
21+
.build();
22+
```
723

824
## Workflow
925

10-
1. **Before**: Fetch docs via WebFetch
11-
(https://jsr-probitas.github.io/documents/llms.txt)
12-
2. **During**: Use `probitas` skill patterns, follow conventions
13-
3. **After**: Run `/probitas:check`, fix issues
26+
1. Write scenario following template above
27+
2. Run `/probitas:check`, fix issues
28+
3. If unsure, fetch specific API docs from links below
1429

1530
## Checklist
1631

1732
- [ ] `export default` + `.build()`
1833
- [ ] Resources via `.resource()`
1934
- [ ] Setup returns cleanup function
2035
- [ ] Env vars for URLs
21-
- [ ] Specific assertions
36+
- [ ] Chain assertions with `expect()`
2237
- [ ] Tags for filtering
2338
- [ ] File: `probitas/{name}.probitas.ts`
2439

25-
## When Uncertain
40+
## Docs
2641

27-
Fetch specific docs:
42+
Guides:
2843

44+
- Scenario: https://jsr-probitas.github.io/documents/docs/scenario/index.md
2945
- Client: https://jsr-probitas.github.io/documents/docs/client/index.md
30-
- Assertions: https://jsr-probitas.github.io/documents/docs/expect/index.md
46+
- Expect: https://jsr-probitas.github.io/documents/docs/expect/index.md
47+
48+
API Reference (by client):
49+
50+
- HTTP: https://jsr-probitas.github.io/documents/api/client-http/index.md
51+
- gRPC: https://jsr-probitas.github.io/documents/api/client-grpc/index.md
52+
- ConnectRPC: https://jsr-probitas.github.io/documents/api/client-connectrpc/index.md
53+
- GraphQL: https://jsr-probitas.github.io/documents/api/client-graphql/index.md
54+
- PostgreSQL: https://jsr-probitas.github.io/documents/api/client-sql-postgres/index.md
55+
- MySQL: https://jsr-probitas.github.io/documents/api/client-sql-mysql/index.md
56+
- SQLite: https://jsr-probitas.github.io/documents/api/client-sql-sqlite/index.md
57+
- DuckDB: https://jsr-probitas.github.io/documents/api/client-sql-duckdb/index.md
58+
- Redis: https://jsr-probitas.github.io/documents/api/client-redis/index.md
59+
- MongoDB: https://jsr-probitas.github.io/documents/api/client-mongodb/index.md
60+
- Deno KV: https://jsr-probitas.github.io/documents/api/client-deno-kv/index.md
61+
- RabbitMQ: https://jsr-probitas.github.io/documents/api/client-rabbitmq/index.md
62+
- SQS: https://jsr-probitas.github.io/documents/api/client-sqs/index.md
63+
64+
Core API:
65+
66+
- Scenario: https://jsr-probitas.github.io/documents/api/scenario/index.md
67+
- Expect: https://jsr-probitas.github.io/documents/api/expect/index.md

plugins/probitas/commands/check.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ description: Run format, lint, and type check for scenarios
1010
4. **Fix** - If issues found, fix them and repeat
1111

1212
```bash
13-
deno fmt probitas/
14-
deno lint --rules-exclude=no-import-prefix,no-unversioned-import probitas/
15-
deno check probitas/**/*.probitas.ts
13+
deno fmt **/*.probitas.ts
14+
deno lint --rules-exclude=no-import-prefix,no-unversioned-import **/*.probitas.ts
15+
deno check **/*.probitas.ts
1616
```
1717

1818
Fix issues iteratively until all pass.

plugins/probitas/commands/init.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ ls -la probitas/
88
```
99

1010
If `probitas` command not found, fetch installation instructions from:
11-
https://jsr-probitas.github.io/documents/docs/index.md
11+
https://jsr-probitas.github.io/documents/docs/installation/index.md
1212

1313
Report created files to user.

plugins/probitas/commands/new.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ description: Generate scenario template (http, database, grpc, graphql)
44

55
## Workflow
66

7-
1. Fetch template info from
8-
https://jsr-probitas.github.io/documents/docs/scenario/index.md
9-
2. Generate template based on type argument
10-
3. Save to `probitas/{name}.probitas.ts`
11-
4. Run `deno check probitas/{name}.probitas.ts`
7+
1. Generate template based on type argument
8+
2. Save to `probitas/{name}.probitas.ts`
9+
3. Run `deno check **/*.probitas.ts`
1210

1311
## Templates
1412

@@ -45,3 +43,7 @@ export default scenario("Database Test", { tags: ["database"] })
4543
})
4644
.build();
4745
```
46+
47+
## Docs
48+
49+
https://jsr-probitas.github.io/documents/docs/scenario/index.md

plugins/probitas/commands/run.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ probitas run -s user # Match scenario name
2020
```
2121

2222
If `probitas` command not found, fetch installation instructions from:
23-
https://jsr-probitas.github.io/documents/docs/index.md
23+
https://jsr-probitas.github.io/documents/docs/installation/index.md
2424

2525
If failures occur, explain cause and suggest fixes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
paths: "**/*.probitas.ts"
3+
---
4+
5+
# Probitas Assertions
6+
7+
ALWAYS use `expect()`, ALWAYS chain.
8+
9+
```typescript
10+
// ❌ WRONG
11+
if (res.status !== 200) throw new Error("Failed");
12+
13+
// ✅ CORRECT
14+
expect(res)
15+
.toBeOk()
16+
.toHaveStatus(200)
17+
.toHaveJsonMatching({ id: 1 });
18+
19+
// Negation
20+
expect(res).not.toHaveStatus(404);
21+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
paths: "**/*.probitas.ts"
3+
---
4+
5+
# Probitas Best Practices
6+
7+
- Descriptive step names ("Create user" not "Step 1")
8+
- Return data for `ctx.previous`
9+
- Use tags for filtering (`{ tags: ["api", "slow"] }`)
10+
- One responsibility per step
11+
- Use `.setup()` with cleanup for fixtures
12+
- Register clients as `.resource()` for auto-cleanup
13+
- Use `toHaveJsonMatching()` / `toHaveDataMatching()` for partial matching

plugins/probitas/rules/context.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
paths: "**/*.probitas.ts"
3+
---
4+
5+
# Probitas Step Context
6+
7+
Available in `.resource()`, `.setup()`, and `.step()`:
8+
9+
- `ctx.previous` - Previous step's return value
10+
- `ctx.results` - All previous step results (tuple)
11+
- `ctx.resources` - Registered resources by name
12+
- `ctx.store` - Shared Map across steps
13+
- `ctx.signal` - AbortSignal for cancelable operations

plugins/probitas/rules/conventions.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)