okengine 0.1.6 → 0.2.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.
Files changed (80) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +36 -29
  3. package/docs/spec/example.md +1187 -0
  4. package/docs/spec/unified-theory.md +1 -1
  5. package/package.json +20 -6
  6. package/src/cli/dev-app-runner.ts +6 -2
  7. package/src/cli/dev.ts +19 -10
  8. package/src/cli/doc-drift.ts +54 -21
  9. package/src/console/index.ts +25 -13
  10. package/src/console/server/app.ts +44 -7
  11. package/src/console/server/claim.test.ts +7 -4
  12. package/src/console/server/claim.ts +2 -7
  13. package/src/console/server/flows.ts +2 -6
  14. package/src/console/server/index.ts +2 -1
  15. package/src/console/server/lazy-panels.test.ts +27 -0
  16. package/src/console/server/panel-load.ts +28 -0
  17. package/src/console/server/plugin.ts +1 -1
  18. package/src/console/server/plugins.ts +7 -6
  19. package/src/console/server/public-flows.ts +12 -0
  20. package/src/console/server/state.ts +159 -122
  21. package/src/console/server/store.ts +13 -10
  22. package/src/console/ui/dist/assets/index-B71Yl_SS.js +10 -0
  23. package/src/console/ui/dist/assets/panel-access-Dd37LU2c.js +64 -0
  24. package/src/console/ui/dist/assets/panel-ai-CC7LR6-J.js +1 -0
  25. package/src/console/ui/dist/assets/panel-architecture-B5b3iKCz.js +1 -0
  26. package/src/console/ui/dist/assets/panel-channels-CeNjTKXp.js +1 -0
  27. package/src/console/ui/dist/assets/panel-clock-DgFTLoHV.js +1 -0
  28. package/src/console/ui/dist/assets/panel-diff-DxehccqB.js +1 -0
  29. package/src/console/ui/dist/assets/panel-flows-BtrVn-Eg.js +45 -0
  30. package/src/console/ui/dist/assets/panel-gates-Z9MKRGdH.js +1 -0
  31. package/src/console/ui/dist/assets/panel-overview-Bd48d9km.js +1 -0
  32. package/src/console/ui/dist/assets/panel-plugins-DWd0TowH.js +1 -0
  33. package/src/console/ui/dist/assets/panel-runs-BwsWqKeB.js +1 -0
  34. package/src/console/ui/dist/assets/panel-signals-9najbZY2.js +1 -0
  35. package/src/console/ui/dist/assets/panel-store-OHkP2pDp.js +1 -0
  36. package/src/console/ui/dist/assets/panel-traces-tn2JoY8U.js +1 -0
  37. package/src/console/ui/dist/assets/panel-vault-BbfWdox0.js +1 -0
  38. package/src/console/ui/dist/assets/rolldown-runtime-CNC7AqOf.js +1 -0
  39. package/src/console/ui/dist/assets/style-Cnl7WLya.css +3 -0
  40. package/src/console/ui/dist/index.html +14 -0
  41. package/src/docs-origin.ts +19 -0
  42. package/src/drivers/index.ts +1 -6
  43. package/src/drivers/vault-sops.ts +20 -1
  44. package/src/kernel/app.ts +1 -1
  45. package/src/kernel/boot-bind/ai.ts +31 -0
  46. package/src/kernel/boot-bind/channel.ts +27 -0
  47. package/src/kernel/boot-bind/clock.ts +74 -0
  48. package/src/kernel/boot-bind/gate.ts +28 -0
  49. package/src/kernel/boot-bind/runs.ts +28 -0
  50. package/src/kernel/boot-bind/signal.ts +68 -0
  51. package/src/kernel/boot-bind/store.ts +47 -0
  52. package/src/kernel/boot-bind/vault.ts +36 -0
  53. package/src/kernel/boot.test.ts +85 -1
  54. package/src/kernel/boot.ts +250 -212
  55. package/src/kernel/errors.registry.test.ts +4 -2
  56. package/src/kernel/errors.ts +3 -1
  57. package/src/kernel/fx.test.ts +2 -2
  58. package/src/kernel/index.ts +2 -0
  59. package/src/mcp/data.ts +1 -0
  60. package/src/mcp/docs-index.ts +252 -0
  61. package/src/mcp/docs-mcp.test.ts +176 -0
  62. package/src/mcp/docs-server.ts +233 -0
  63. package/src/mcp/docs-tools.ts +143 -0
  64. package/src/mcp/index.ts +29 -5
  65. package/src/mcp/protocol.ts +2 -1
  66. package/src/release/exports.test.ts +71 -0
  67. package/src/release/exports.ts +156 -0
  68. package/src/release/index.ts +21 -0
  69. package/src/release/limits.ts +9 -0
  70. package/src/release/measure.exports.test.ts +82 -0
  71. package/src/release/measure.ts +297 -14
  72. package/src/release/publish.ts +14 -3
  73. package/src/release/readme.test.ts +61 -0
  74. package/src/release/readme.ts +13 -0
  75. package/src/runtime/index.ts +1 -0
  76. package/src/runtime/security.test.ts +6 -1
  77. package/src/runtime/types.ts +6 -0
  78. package/src/term.test.ts +51 -0
  79. package/src/term.ts +158 -0
  80. package/src/test/create-test-app.ts +2 -0
package/AGENTS.md CHANGED
@@ -76,7 +76,7 @@ A regression fails the build. Claims we cannot measure, we do not make.
76
76
 
77
77
  Published packages:
78
78
  - `okengine` — framework. Subpath exports: `.`, `./client`, `./test`, `./config`, `./auth`, `./drivers/*`. `"sideEffects": false`. CLI binary: `oke`.
79
- - `create-oke` — scaffold CLI (`bunx create-oke@latest <name>`). Lives in `packages/create-oke`; templates are the `examples/*` trees.
79
+ - `create-oke` — scaffold CLI (`bunx create-oke@latest <name>`). Lives in `packages/create-oke`; clean starters are `templates/*`, teaching apps stay in `examples/*` (`--from-example`).
80
80
 
81
81
  Engine: Bun `>=1.3`.
82
82
 
package/README.md CHANGED
@@ -8,32 +8,15 @@
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
9
  [![Bun >=1.3](https://img.shields.io/badge/Bun-%3E%3D1.3-black.svg)](https://bun.sh)
10
10
 
11
- **Framework:** [`okengine`](https://www.npmjs.com/package/okengine) · **CLI:** `oke` · **Scaffold:** [`create-oke`](https://www.npmjs.com/package/create-oke) · **License:** MIT
11
+ **Framework:** [`okengine`](https://www.npmjs.com/package/okengine) · **CLI:** `oke` · **Scaffold:** [`create-oke`](https://www.npmjs.com/package/create-oke) · **Docs:** [okengine.vercel.app](https://okengine.vercel.app) · **License:** MIT
12
12
 
13
13
  ### Install
14
14
 
15
15
  ```bash
16
16
  bun add okengine # npm (recommended — ships the `oke` CLI)
17
17
  bunx jsr add @omqkhafi/okengine # JSR — library API only
18
- bunx create-oke@latest my-app # scaffold from npm
18
+ bunx create-oke@latest my-app --template hello # scaffold from npm
19
19
  ```
20
-
21
- | Package | npm | JSR |
22
- |---|---|---|
23
- | Framework | [`okengine`](https://www.npmjs.com/package/okengine) | [`@omqkhafi/okengine`](https://jsr.io/@omqkhafi/okengine) |
24
- | Scaffold | [`create-oke`](https://www.npmjs.com/package/create-oke) | [`@omqkhafi/create-oke`](https://jsr.io/@omqkhafi/create-oke) |
25
-
26
- ### npm vs JSR
27
-
28
- | Surface | npm | JSR |
29
- |---|---|---|
30
- | Library imports (`okengine`, `/client`, `/drivers`, …) | yes | yes |
31
- | Deep drivers (`okengine/drivers/postgres`, …) | yes | no — use `okengine/drivers`, or install from npm |
32
- | `oke` CLI | yes | no |
33
- | `create-oke` binary | yes | no — prefer `bunx create-oke@latest` from npm |
34
-
35
- JSR cannot rewrite the CLI’s dynamic imports of your app entry (`oke dev` / `oke start` / config load). Install `okengine` from npm when you need the binary. Deep driver subpaths use npm `exports` wildcards, which JSR does not support.
36
-
37
20
  ---
38
21
 
39
22
  ## Start here
@@ -52,14 +35,14 @@ Eight elements cover what a backend needs. Ten exports are the whole public voca
52
35
  import { on, flow, signal, store, clock, gate, vault, channel, ai, plugin } from "okengine";
53
36
  ```
54
37
 
55
- Batteries included for the Bun era: contract-first APIs, typed client, infrastructure primitives, Console, auth — pure TypeScript, MIT, self-hostable, no cloud lock-in. Detail and comparisons live in [`docs/spec/unified-theory.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/unified-theory.md).
38
+ Batteries included for the Bun era: contract-first APIs, typed client, infrastructure primitives, Console, auth — pure TypeScript, MIT, self-hostable, no cloud lock-in. Handbook: [handbook](https://okengine.vercel.app/docs). Spec depth: [`docs/spec/unified-theory.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/unified-theory.md).
56
39
 
57
40
  ---
58
41
 
59
42
  ## Run something in two minutes
60
43
 
61
44
  ```bash
62
- bunx create-oke@latest my-app
45
+ bunx create-oke@latest my-app --template hello
63
46
  cd my-app
64
47
  oke dev
65
48
  ```
@@ -68,9 +51,13 @@ oke dev
68
51
  |---|---|
69
52
  | `:6530` | your app |
70
53
  | `:6533` | Console |
71
- | `:6535` | MCP |
54
+ | `:6535` | MCP (your live Manifest, for agents) |
55
+
56
+ Mnemonic: **O·K·E = 6·5·3**. Docs MCP for the handbook is a separate surface on `:6536` (search/fetch only — see [Documentation](#documentation)).
57
+
58
+ That scaffolds the **hello** starter — one flow, no Store, the fastest true "it works" moment. Default without `--template` is **standard** (full recommended file layout, empty scaffolding). Open the Console — flows, contracts, effects, and an architecture diagram are already there. Derived, not configured.
72
59
 
73
- That scaffolds the **Notes** app (same tree as [`examples/notes`](https://github.com/omqkhafi/okengine/tree/main/examples/notes)). Open the Console — flows, contracts, effects, and an architecture diagram are already there. Derived, not configured.
60
+ Prefer a worked teaching app (business logic + comments)? Use `--from-example notes|linkly|provisions|skyport` instead.
74
61
 
75
62
  ### The idea, in one file
76
63
 
@@ -144,7 +131,9 @@ The rest of the scaffold is small and ordinary: `oke.config.ts` (drivers by prot
144
131
 
145
132
  ## How to learn (read in order)
146
133
 
147
- Each app adds the smallest next set of ideas. Do not skip ahead.
134
+ Start on the site if you want the handbook path: [Introduction](https://okengine.vercel.app/docs/get-started/introduction) [Installation](https://okengine.vercel.app/docs/get-started/installation) [Basic usage](https://okengine.vercel.app/docs/get-started/basic-usage).
135
+
136
+ Each teaching app adds the smallest next set of ideas. Do not skip ahead.
148
137
 
149
138
  1. **Notes** — `oke`, `on`, `flow`, `http`, `store.sql`, `fx`, typed errors, typed client
150
139
  → [`examples/notes`](examples/notes)
@@ -158,7 +147,17 @@ Each app adds the smallest next set of ideas. Do not skip ahead.
158
147
  4. **Skyport** — `ai`, multi-tenancy, SLOs, distributed topology, scaling axes
159
148
  → [`examples/skyport`](examples/skyport)
160
149
 
161
- Spec that teaches the same path: [`docs/spec/four-applications.md`](docs/spec/four-applications.md).
150
+ Same path in the spec: [`docs/spec/four-applications.md`](docs/spec/four-applications.md).
151
+
152
+ ---
153
+
154
+ ## Documentation
155
+
156
+ - **Site** — [okengine.vercel.app](https://okengine.vercel.app) (landing) · [handbook](https://okengine.vercel.app/docs) (handbook) · [changelog](https://okengine.vercel.app/changelog)
157
+ - **Agents on the site** — [`/llms.txt`](https://okengine.vercel.app/llms.txt) index · [`/llms-full.txt`](https://okengine.vercel.app/llms-full.txt) full text · `/llms.mdx/docs/...` per-page markdown
158
+ - **Docs MCP** — `:6536` · tools `oke.docs.search` / `oke.docs.get` (read-only; Host/Origin validated like the other surfaces)
159
+ - **App MCP** — `:6535` · live Manifest, schemas, effects, traces, Console-safe actions (Bearer + confirmation for writes)
160
+ - **Canonical specs in-repo** — [`docs/spec/`](docs/spec) (unified theory, four applications, Console)
162
161
 
163
162
  ---
164
163
 
@@ -205,7 +204,7 @@ flowchart TD
205
204
 
206
205
  Seventeen panels on `:6533` (app `:6530`, MCP `:6535`): Overview, Flows, Signals, Store, Clock, Gates, Vault, Channels, AI, Architecture, Traces, Runs, Manifest Diff, Access, Plugins — plus Privacy and Tenancy when those plugins are plugged.
207
206
 
208
- Operator and user planes stay separate. Every Console action is a real flow through `fx`, so the audit log is the trace. [`docs/spec/console.md`](docs/spec/console.md)
207
+ Operator and user planes stay separate. Every Console action is a real flow through `fx`, so the audit log is the trace. Spec: [`docs/spec/console.md`](docs/spec/console.md) · handbook: [console handbook](https://okengine.vercel.app/docs/console/overview).
209
208
 
210
209
  ---
211
210
 
@@ -327,7 +326,7 @@ Long form is canonical in docs; short form is convenience only. Shared letters f
327
326
 
328
327
  `.plug()` attaches a plugin. Scope is the attachment point: `app.plug()` app-wide, `unit.plug()` one unit, `flow.plug()` one flow. No `global: true`, no inheritance rule — [unified theory §14](docs/spec/unified-theory.md#14-plugins--the-extensibility-law).
329
328
 
330
- The Console is treated as internet-facing even on localhost. Host header validation, Origin validation, and authentication are mandatory on `:6530`, `:6533`, and `:6535` ([console.md §10](docs/spec/console.md#10-security-posture)): two-plane auth (operator vs user), capability-scoped tokens.
329
+ The Console is treated as internet-facing even on localhost. Host header validation, Origin validation, and authentication are mandatory on `:6530`, `:6533`, and `:6535` ([console.md §10](docs/spec/console.md#10-security-posture)): two-plane auth (operator vs user), capability-scoped tokens. Docs MCP `:6536` uses the same Host/Origin checks and stays read-only (no Bearer writes).
331
330
 
332
331
  ---
333
332
 
@@ -341,13 +340,21 @@ The Console is treated as internet-facing even on localhost. Host header validat
341
340
 
342
341
  ---
343
342
 
343
+ ## Budgets
344
+
345
+ Measured size and latency caps — see [`BUDGETS.md`](BUDGETS.md). Refresh with `bun run budgets`.
346
+
347
+ ---
348
+
344
349
  ## Status
345
350
 
346
- Pre-1.0. Published on [npm](https://www.npmjs.com/package/okengine) and [JSR](https://jsr.io/@omqkhafi/okengine) (`okengine` + `create-oke`, lockstep). MIT. No `CONTRIBUTING` yet — issues and PRs welcome.
351
+ Pre-1.0. Published on [npm](https://www.npmjs.com/package/okengine) and [JSR](https://jsr.io/@omqkhafi/okengine) (`okengine` + `create-oke`, lockstep). Docs at [okengine.vercel.app](https://okengine.vercel.app). MIT. No `CONTRIBUTING` yet — issues and PRs welcome.
347
352
 
348
- | Spec | Path |
353
+ | Resource | Path |
349
354
  |---|---|
355
+ | Docs site | [okengine.vercel.app](https://okengine.vercel.app) · [handbook](https://okengine.vercel.app/docs) · [changelog](https://okengine.vercel.app/changelog) |
350
356
  | Unified theory | [`docs/spec/unified-theory.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/unified-theory.md) |
351
357
  | Four applications | [`docs/spec/four-applications.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/four-applications.md) |
352
358
  | Console | [`docs/spec/console.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/console.md) |
353
359
  | Scaffold | [`packages/create-oke`](https://github.com/omqkhafi/okengine/tree/main/packages/create-oke) |
360
+ | Changelog source | [`docs/changelog.md`](docs/changelog.md) |