@plumbus/core 0.1.1 → 0.1.3

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.
Files changed (146) hide show
  1. package/README.md +163 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/ai/ai-service.d.ts.map +1 -1
  4. package/dist/ai/ai-service.js +1 -0
  5. package/dist/ai/ai-service.js.map +1 -1
  6. package/dist/api/index.d.ts +1 -1
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/route-generator.d.ts +5 -1
  9. package/dist/api/route-generator.d.ts.map +1 -1
  10. package/dist/api/route-generator.js +2 -1
  11. package/dist/api/route-generator.js.map +1 -1
  12. package/dist/cli/__tests__/cli.test.js +90 -1
  13. package/dist/cli/__tests__/cli.test.js.map +1 -1
  14. package/dist/cli/__tests__/create.test.js +22 -0
  15. package/dist/cli/__tests__/create.test.js.map +1 -1
  16. package/dist/cli/__tests__/generate.test.js +219 -1
  17. package/dist/cli/__tests__/generate.test.js.map +1 -1
  18. package/dist/cli/__tests__/init.test.js +9 -0
  19. package/dist/cli/__tests__/init.test.js.map +1 -1
  20. package/dist/cli/__tests__/start.test.d.ts +2 -0
  21. package/dist/cli/__tests__/start.test.d.ts.map +1 -0
  22. package/dist/cli/__tests__/start.test.js +91 -0
  23. package/dist/cli/__tests__/start.test.js.map +1 -0
  24. package/dist/cli/__tests__/utils.test.js +70 -2
  25. package/dist/cli/__tests__/utils.test.js.map +1 -1
  26. package/dist/cli/cli.d.ts.map +1 -1
  27. package/dist/cli/cli.js +16 -1
  28. package/dist/cli/cli.js.map +1 -1
  29. package/dist/cli/commands/create.d.ts.map +1 -1
  30. package/dist/cli/commands/create.js +28 -2
  31. package/dist/cli/commands/create.js.map +1 -1
  32. package/dist/cli/commands/generate.d.ts +26 -1
  33. package/dist/cli/commands/generate.d.ts.map +1 -1
  34. package/dist/cli/commands/generate.js +195 -4
  35. package/dist/cli/commands/generate.js.map +1 -1
  36. package/dist/cli/commands/index.d.ts +3 -0
  37. package/dist/cli/commands/index.d.ts.map +1 -1
  38. package/dist/cli/commands/index.js +5 -0
  39. package/dist/cli/commands/index.js.map +1 -1
  40. package/dist/cli/commands/init.d.ts.map +1 -1
  41. package/dist/cli/commands/init.js +20 -21
  42. package/dist/cli/commands/init.js.map +1 -1
  43. package/dist/cli/commands/run.d.ts +3 -0
  44. package/dist/cli/commands/run.d.ts.map +1 -0
  45. package/dist/cli/commands/run.js +147 -0
  46. package/dist/cli/commands/run.js.map +1 -0
  47. package/dist/cli/commands/start.d.ts +25 -0
  48. package/dist/cli/commands/start.d.ts.map +1 -0
  49. package/dist/cli/commands/start.js +125 -0
  50. package/dist/cli/commands/start.js.map +1 -0
  51. package/dist/cli/commands/translation.d.ts +3 -0
  52. package/dist/cli/commands/translation.d.ts.map +1 -0
  53. package/dist/cli/commands/translation.js +277 -0
  54. package/dist/cli/commands/translation.js.map +1 -0
  55. package/dist/cli/commands/ui.d.ts +8 -2
  56. package/dist/cli/commands/ui.d.ts.map +1 -1
  57. package/dist/cli/commands/ui.js +13 -5
  58. package/dist/cli/commands/ui.js.map +1 -1
  59. package/dist/cli/discover.d.ts +2 -0
  60. package/dist/cli/discover.d.ts.map +1 -1
  61. package/dist/cli/discover.js +11 -1
  62. package/dist/cli/discover.js.map +1 -1
  63. package/dist/cli/index.d.ts +3 -3
  64. package/dist/cli/index.d.ts.map +1 -1
  65. package/dist/cli/index.js +3 -3
  66. package/dist/cli/index.js.map +1 -1
  67. package/dist/cli/templates/resources.d.ts +1 -0
  68. package/dist/cli/templates/resources.d.ts.map +1 -1
  69. package/dist/cli/templates/resources.js +16 -0
  70. package/dist/cli/templates/resources.js.map +1 -1
  71. package/dist/cli/utils.d.ts +15 -0
  72. package/dist/cli/utils.d.ts.map +1 -1
  73. package/dist/cli/utils.js +47 -0
  74. package/dist/cli/utils.js.map +1 -1
  75. package/dist/config/loader.d.ts +2 -0
  76. package/dist/config/loader.d.ts.map +1 -1
  77. package/dist/config/loader.js.map +1 -1
  78. package/dist/data/__tests__/registry.test.js +15 -0
  79. package/dist/data/__tests__/registry.test.js.map +1 -1
  80. package/dist/data/__tests__/repository.test.js +33 -0
  81. package/dist/data/__tests__/repository.test.js.map +1 -1
  82. package/dist/data/registry.d.ts +2 -0
  83. package/dist/data/registry.d.ts.map +1 -1
  84. package/dist/data/registry.js +1 -0
  85. package/dist/data/registry.js.map +1 -1
  86. package/dist/data/repository.d.ts +2 -0
  87. package/dist/data/repository.d.ts.map +1 -1
  88. package/dist/data/repository.js +3 -3
  89. package/dist/data/repository.js.map +1 -1
  90. package/dist/define/__tests__/defineTranslation.test.d.ts +2 -0
  91. package/dist/define/__tests__/defineTranslation.test.d.ts.map +1 -0
  92. package/dist/define/__tests__/defineTranslation.test.js +90 -0
  93. package/dist/define/__tests__/defineTranslation.test.js.map +1 -0
  94. package/dist/define/defineTranslation.d.ts +21 -0
  95. package/dist/define/defineTranslation.d.ts.map +1 -0
  96. package/dist/define/defineTranslation.js +67 -0
  97. package/dist/define/defineTranslation.js.map +1 -0
  98. package/dist/define/index.d.ts +1 -0
  99. package/dist/define/index.d.ts.map +1 -1
  100. package/dist/define/index.js +1 -0
  101. package/dist/define/index.js.map +1 -1
  102. package/dist/execution/context-factory.d.ts +2 -0
  103. package/dist/execution/context-factory.d.ts.map +1 -1
  104. package/dist/execution/context-factory.js +5 -0
  105. package/dist/execution/context-factory.js.map +1 -1
  106. package/dist/fields/index.d.ts +1 -0
  107. package/dist/fields/index.d.ts.map +1 -1
  108. package/dist/fields/index.js +1 -0
  109. package/dist/fields/index.js.map +1 -1
  110. package/dist/index.d.ts +3 -1
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +15 -6
  113. package/dist/index.js.map +1 -1
  114. package/dist/server/bootstrap.d.ts.map +1 -1
  115. package/dist/server/bootstrap.js +7 -2
  116. package/dist/server/bootstrap.js.map +1 -1
  117. package/dist/testing/context.js +2 -2
  118. package/dist/testing/context.js.map +1 -1
  119. package/dist/testing/index.d.ts +3 -3
  120. package/dist/testing/index.d.ts.map +1 -1
  121. package/dist/testing/index.js +1 -1
  122. package/dist/testing/index.js.map +1 -1
  123. package/dist/translations/__tests__/translation-resolver.test.d.ts +2 -0
  124. package/dist/translations/__tests__/translation-resolver.test.d.ts.map +1 -0
  125. package/dist/translations/__tests__/translation-resolver.test.js +140 -0
  126. package/dist/translations/__tests__/translation-resolver.test.js.map +1 -0
  127. package/dist/translations/index.d.ts +40 -0
  128. package/dist/translations/index.d.ts.map +1 -0
  129. package/dist/translations/index.js +144 -0
  130. package/dist/translations/index.js.map +1 -0
  131. package/dist/types/context.d.ts +13 -7
  132. package/dist/types/context.d.ts.map +1 -1
  133. package/dist/types/fields.d.ts +1 -0
  134. package/dist/types/fields.d.ts.map +1 -1
  135. package/dist/types/flow.d.ts +2 -0
  136. package/dist/types/flow.d.ts.map +1 -1
  137. package/dist/types/index.d.ts +1 -0
  138. package/dist/types/index.d.ts.map +1 -1
  139. package/dist/types/translation.d.ts +28 -0
  140. package/dist/types/translation.d.ts.map +1 -0
  141. package/dist/types/translation.js +6 -0
  142. package/dist/types/translation.js.map +1 -0
  143. package/instructions/cli.md +24 -0
  144. package/instructions/deployment.md +332 -0
  145. package/instructions/translations.md +78 -0
  146. 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