@plumbus/core 0.1.1 → 0.1.2
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 +163 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/route-generator.d.ts +5 -1
- package/dist/api/route-generator.d.ts.map +1 -1
- package/dist/api/route-generator.js +2 -1
- package/dist/api/route-generator.js.map +1 -1
- package/dist/cli/__tests__/create.test.js +22 -0
- package/dist/cli/__tests__/create.test.js.map +1 -1
- package/dist/cli/__tests__/generate.test.js +219 -1
- package/dist/cli/__tests__/generate.test.js.map +1 -1
- package/dist/cli/__tests__/utils.test.js +70 -2
- package/dist/cli/__tests__/utils.test.js.map +1 -1
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +14 -1
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/commands/create.d.ts.map +1 -1
- package/dist/cli/commands/create.js +28 -2
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/generate.d.ts +26 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +195 -4
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +2 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/run.d.ts +3 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +147 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils.d.ts +15 -0
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/cli/utils.js +47 -0
- package/dist/cli/utils.js.map +1 -1
- package/dist/data/__tests__/registry.test.js +15 -0
- package/dist/data/__tests__/registry.test.js.map +1 -1
- package/dist/data/__tests__/repository.test.js +33 -0
- package/dist/data/__tests__/repository.test.js.map +1 -1
- package/dist/data/registry.d.ts +2 -0
- package/dist/data/registry.d.ts.map +1 -1
- package/dist/data/registry.js +1 -0
- package/dist/data/registry.js.map +1 -1
- package/dist/data/repository.d.ts +2 -0
- package/dist/data/repository.d.ts.map +1 -1
- package/dist/data/repository.js +3 -3
- package/dist/data/repository.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/server/bootstrap.d.ts.map +1 -1
- package/dist/server/bootstrap.js +7 -2
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.js.map +1 -1
- package/instructions/cli.md +24 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# @plumbus/core
|
|
2
|
+
|
|
3
|
+
**AI-native, contract-driven TypeScript application framework.**
|
|
4
|
+
|
|
5
|
+
Define your application through five composable primitives — Entities, Capabilities, Flows, Events, and Prompts — and get deny-by-default security, advisory governance, audit trails, and managed AI integration out of the box.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @plumbus/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install the CLI globally
|
|
17
|
+
pnpm add -g @plumbus/core
|
|
18
|
+
|
|
19
|
+
# Scaffold a new project
|
|
20
|
+
plumbus create my-app --auth jwt --ai openai --compliance GDPR
|
|
21
|
+
|
|
22
|
+
cd my-app
|
|
23
|
+
plumbus dev
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## The Five Primitives
|
|
27
|
+
|
|
28
|
+
### Capabilities — atomic business operations
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { defineCapability } from "@plumbus/core";
|
|
32
|
+
import { z } from "zod";
|
|
33
|
+
|
|
34
|
+
export const getUser = defineCapability({
|
|
35
|
+
name: "getUser",
|
|
36
|
+
kind: "query",
|
|
37
|
+
domain: "users",
|
|
38
|
+
input: z.object({ userId: z.string().uuid() }),
|
|
39
|
+
output: z.object({ id: z.string(), name: z.string(), email: z.string() }),
|
|
40
|
+
access: { roles: ["admin", "user"], scopes: ["users:read"] },
|
|
41
|
+
handler: async (ctx, input) => {
|
|
42
|
+
const user = await ctx.data.User.findById(input.userId);
|
|
43
|
+
if (!user) throw ctx.errors.notFound("User not found");
|
|
44
|
+
return user;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Entities — data models with field-level classification
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { defineEntity, field } from "@plumbus/core";
|
|
53
|
+
|
|
54
|
+
export const User = defineEntity({
|
|
55
|
+
name: "User",
|
|
56
|
+
tenantScoped: true,
|
|
57
|
+
fields: {
|
|
58
|
+
id: field.id(),
|
|
59
|
+
name: field.string({ classification: "personal" }),
|
|
60
|
+
email: field.string({ classification: "personal", maskedInLogs: true }),
|
|
61
|
+
role: field.enum({ values: ["admin", "user", "guest"] }),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Flows — multi-step workflows
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { defineFlow } from "@plumbus/core";
|
|
70
|
+
|
|
71
|
+
export const refundApproval = defineFlow({
|
|
72
|
+
name: "refundApproval",
|
|
73
|
+
domain: "billing",
|
|
74
|
+
trigger: { type: "event", event: "refund.requested" },
|
|
75
|
+
steps: [
|
|
76
|
+
{ name: "validate", capability: "validateRefund" },
|
|
77
|
+
{ name: "decide", type: "conditional", condition: "ctx.state.amount > 100",
|
|
78
|
+
ifTrue: "managerApproval", ifFalse: "autoApprove" },
|
|
79
|
+
{ name: "notify", capability: "sendRefundNotification" },
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Events — domain facts
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { defineEvent } from "@plumbus/core";
|
|
88
|
+
import { z } from "zod";
|
|
89
|
+
|
|
90
|
+
export const orderPlaced = defineEvent({
|
|
91
|
+
name: "order.placed",
|
|
92
|
+
schema: z.object({ orderId: z.string(), customerId: z.string(), total: z.number() }),
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Prompts — structured AI interactions
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { definePrompt } from "@plumbus/core";
|
|
100
|
+
import { z } from "zod";
|
|
101
|
+
|
|
102
|
+
export const classifyTicket = definePrompt({
|
|
103
|
+
name: "classifyTicket",
|
|
104
|
+
model: "gpt-4o-mini",
|
|
105
|
+
input: z.object({ ticketText: z.string() }),
|
|
106
|
+
output: z.object({
|
|
107
|
+
category: z.enum(["billing", "technical", "general"]),
|
|
108
|
+
priority: z.enum(["low", "medium", "high"]),
|
|
109
|
+
}),
|
|
110
|
+
systemPrompt: "Classify the support ticket and return structured JSON.",
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Subpath Exports
|
|
115
|
+
|
|
116
|
+
| Import | Purpose |
|
|
117
|
+
|--------|---------|
|
|
118
|
+
| `@plumbus/core` | SDK surface — define functions, types, runtime |
|
|
119
|
+
| `@plumbus/core/testing` | Test utilities — `runCapability`, `simulateFlow`, `mockAI`, `createTestContext` |
|
|
120
|
+
| `@plumbus/core/zod` | Re-exported Zod (consumers should not install Zod separately) |
|
|
121
|
+
| `@plumbus/core/vitest` | Vitest config helpers |
|
|
122
|
+
|
|
123
|
+
## CLI
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
plumbus create <app> # Scaffold a new project
|
|
127
|
+
plumbus dev # Start dev server with hot reload
|
|
128
|
+
plumbus doctor # Check environment readiness
|
|
129
|
+
plumbus generate # Regenerate artifacts from contracts
|
|
130
|
+
plumbus verify # Run governance rules
|
|
131
|
+
plumbus certify <profile> # Run compliance assessment (GDPR, PCI-DSS, etc.)
|
|
132
|
+
plumbus migrate generate # Generate database migration
|
|
133
|
+
plumbus migrate apply # Apply pending migrations
|
|
134
|
+
plumbus init --agent all # Generate AI agent wiring files
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## AI Agent Instructions
|
|
138
|
+
|
|
139
|
+
This package ships instruction files that teach AI coding agents (Copilot, Cursor, etc.) how to use the framework:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
node_modules/@plumbus/core/instructions/
|
|
143
|
+
├── framework.md # Core abstractions and project structure
|
|
144
|
+
├── capabilities.md # Capability definitions and handlers
|
|
145
|
+
├── entities.md # Entity fields and classifications
|
|
146
|
+
├── events.md # Event emission and outbox pattern
|
|
147
|
+
├── flows.md # Workflow steps and retry logic
|
|
148
|
+
├── ai.md # AI prompts, RAG, cost tracking
|
|
149
|
+
├── security.md # Access policies and tenant isolation
|
|
150
|
+
├── governance.md # Advisory rules and compliance
|
|
151
|
+
├── testing.md # Test utilities and patterns
|
|
152
|
+
└── patterns.md # Naming conventions and best practices
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Wire them up with `plumbus init --agent all`.
|
|
156
|
+
|
|
157
|
+
## Documentation
|
|
158
|
+
|
|
159
|
+
Full documentation: [github.com/plumbus-framework/plumbus/docs](https://github.com/plumbus-framework/plumbus/tree/main/docs)
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT
|