okengine 0.2.1 → 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 (31) hide show
  1. package/README.md +8 -8
  2. package/package.json +2 -1
  3. package/src/cli/dev-app-runner.ts +6 -2
  4. package/src/cli/dev.ts +16 -9
  5. package/src/console/server/claim.test.ts +7 -4
  6. package/src/console/server/claim.ts +2 -7
  7. package/src/console/ui/dist/assets/index-B71Yl_SS.js +10 -0
  8. package/src/console/ui/dist/assets/panel-access-Dd37LU2c.js +64 -0
  9. package/src/console/ui/dist/assets/panel-ai-CC7LR6-J.js +1 -0
  10. package/src/console/ui/dist/assets/panel-architecture-B5b3iKCz.js +1 -0
  11. package/src/console/ui/dist/assets/panel-channels-CeNjTKXp.js +1 -0
  12. package/src/console/ui/dist/assets/panel-clock-DgFTLoHV.js +1 -0
  13. package/src/console/ui/dist/assets/panel-diff-DxehccqB.js +1 -0
  14. package/src/console/ui/dist/assets/panel-flows-BtrVn-Eg.js +45 -0
  15. package/src/console/ui/dist/assets/panel-gates-Z9MKRGdH.js +1 -0
  16. package/src/console/ui/dist/assets/panel-overview-Bd48d9km.js +1 -0
  17. package/src/console/ui/dist/assets/panel-plugins-DWd0TowH.js +1 -0
  18. package/src/console/ui/dist/assets/panel-runs-BwsWqKeB.js +1 -0
  19. package/src/console/ui/dist/assets/panel-signals-9najbZY2.js +1 -0
  20. package/src/console/ui/dist/assets/panel-store-OHkP2pDp.js +1 -0
  21. package/src/console/ui/dist/assets/panel-traces-tn2JoY8U.js +1 -0
  22. package/src/console/ui/dist/assets/panel-vault-BbfWdox0.js +1 -0
  23. package/src/console/ui/dist/assets/rolldown-runtime-CNC7AqOf.js +1 -0
  24. package/src/console/ui/dist/assets/style-Cnl7WLya.css +3 -0
  25. package/src/console/ui/dist/index.html +14 -0
  26. package/src/docs-origin.ts +19 -0
  27. package/src/kernel/errors.registry.test.ts +4 -2
  28. package/src/kernel/errors.ts +3 -1
  29. package/src/kernel/fx.test.ts +2 -2
  30. package/src/term.test.ts +51 -0
  31. package/src/term.ts +158 -0
package/README.md CHANGED
@@ -8,7 +8,7 @@
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) · **Docs:** [oke.dev](https://oke.dev) · **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
 
@@ -35,7 +35,7 @@ Eight elements cover what a backend needs. Ten exports are the whole public voca
35
35
  import { on, flow, signal, store, clock, gate, vault, channel, ai, plugin } from "okengine";
36
36
  ```
37
37
 
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: [oke.dev/docs](https://oke.dev/docs). Spec depth: [`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).
39
39
 
40
40
  ---
41
41
 
@@ -131,7 +131,7 @@ The rest of the scaffold is small and ordinary: `oke.config.ts` (drivers by prot
131
131
 
132
132
  ## How to learn (read in order)
133
133
 
134
- Start on the site if you want the handbook path: [Introduction](https://oke.dev/docs/get-started/introduction) → [Installation](https://oke.dev/docs/get-started/installation) → [Basic usage](https://oke.dev/docs/get-started/basic-usage).
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
135
 
136
136
  Each teaching app adds the smallest next set of ideas. Do not skip ahead.
137
137
 
@@ -153,8 +153,8 @@ Same path in the spec: [`docs/spec/four-applications.md`](docs/spec/four-applica
153
153
 
154
154
  ## Documentation
155
155
 
156
- - **Site** — [oke.dev](https://oke.dev) (landing) · [oke.dev/docs](https://oke.dev/docs) (handbook) · [changelog](https://oke.dev/changelog)
157
- - **Agents on the site** — [`/llms.txt`](https://oke.dev/llms.txt) index · [`/llms-full.txt`](https://oke.dev/llms-full.txt) full text · `/llms.mdx/docs/...` per-page markdown
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
158
  - **Docs MCP** — `:6536` · tools `oke.docs.search` / `oke.docs.get` (read-only; Host/Origin validated like the other surfaces)
159
159
  - **App MCP** — `:6535` · live Manifest, schemas, effects, traces, Console-safe actions (Bearer + confirmation for writes)
160
160
  - **Canonical specs in-repo** — [`docs/spec/`](docs/spec) (unified theory, four applications, Console)
@@ -204,7 +204,7 @@ flowchart TD
204
204
 
205
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.
206
206
 
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: [oke.dev/docs/console](https://oke.dev/docs/console/overview).
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).
208
208
 
209
209
  ---
210
210
 
@@ -348,11 +348,11 @@ Measured size and latency caps — see [`BUDGETS.md`](BUDGETS.md). Refresh with
348
348
 
349
349
  ## Status
350
350
 
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 [oke.dev](https://oke.dev). 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.
352
352
 
353
353
  | Resource | Path |
354
354
  |---|---|
355
- | Docs site | [oke.dev](https://oke.dev) · [handbook](https://oke.dev/docs) · [changelog](https://oke.dev/changelog) |
355
+ | Docs site | [okengine.vercel.app](https://okengine.vercel.app) · [handbook](https://okengine.vercel.app/docs) · [changelog](https://okengine.vercel.app/changelog) |
356
356
  | Unified theory | [`docs/spec/unified-theory.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/unified-theory.md) |
357
357
  | Four applications | [`docs/spec/four-applications.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/four-applications.md) |
358
358
  | Console | [`docs/spec/console.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/console.md) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "okengine",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "One law. Eight elements. Ten exports. One package. One manifest. Every backend need is derived, never added.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,6 +35,7 @@
35
35
  "test:mcp": "bun test src/mcp",
36
36
  "test:console:smoke": "bunx playwright test tests/console/smoke.spec.ts",
37
37
  "build:console": "bunx vite build --config src/console/ui/vite.config.ts",
38
+ "prepack": "bun run build:console",
38
39
  "bench:cold-start": "bun test ./src/runtime/cold-start.bench.ts",
39
40
  "bench:client": "bun test src/client/budget.test.ts",
40
41
  "bench:console": "bun test src/console/budget.test.ts",
@@ -17,6 +17,7 @@ import { resolve } from "node:path";
17
17
  import { pathToFileURL } from "node:url";
18
18
  import { createBunRuntime } from "../runtime/bun.ts";
19
19
  import { APP_PORT, type FetchApp } from "../runtime/types.ts";
20
+ import { formatAppReadyLine } from "../term.ts";
20
21
 
21
22
  /** Stable Bun.serve id so `--hot` reuses the socket across soft reloads. */
22
23
  export const DEV_APP_SERVE_ID = "oke-dev-app";
@@ -59,8 +60,11 @@ const handle = createBunRuntime().serve(mod.app, {
59
60
  id: DEV_APP_SERVE_ID,
60
61
  });
61
62
 
62
- const line = `oke app http://${formatHostForUrl(hostname)}:${handle.port}\n`;
63
- process.stdout.write(line);
63
+ process.stdout.write(
64
+ formatAppReadyLine(
65
+ `http://${formatHostForUrl(hostname)}:${handle.port}`,
66
+ ),
67
+ );
64
68
 
65
69
  if (readyPath !== undefined && readyPath.length > 0) {
66
70
  await Bun.write(readyPath, `${handle.port}\n`);
package/src/cli/dev.ts CHANGED
@@ -23,6 +23,11 @@ import {
23
23
  CONSOLE_PORT,
24
24
  MCP_PORT,
25
25
  } from "../runtime/types.ts";
26
+ import {
27
+ formatDevBanner,
28
+ formatServiceLine,
29
+ formatStatusLine,
30
+ } from "../term.ts";
26
31
  import { clientAdd } from "./client-add.ts";
27
32
  import { loadManifest, loadOkeConfig, resolveImages } from "./load-config.ts";
28
33
  import { mcpContextFromConsole } from "./mcp-from-console.ts";
@@ -258,7 +263,7 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
258
263
  }
259
264
  });
260
265
  await up(composeFiles, cwd);
261
- write(`oke dev: stack up (${stackRoles.join(", ")})\n`);
266
+ write(formatStatusLine(`stack up (${stackRoles.join(", ")})`));
262
267
  }
263
268
  }
264
269
 
@@ -272,10 +277,7 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
272
277
  stackEnv,
273
278
  };
274
279
 
275
- write(
276
- `oke dev: app :${appPort} · Console :${consolePort} · MCP :${mcpPort}\n`,
277
- );
278
- write("oke dev: watching — client types regenerate on save\n");
280
+ write(formatDevBanner());
279
281
 
280
282
  if (options.dryRun) return { code: 0, plan };
281
283
 
@@ -312,7 +314,12 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
312
314
  ? { manifest: seedManifest }
313
315
  : {}),
314
316
  });
315
- write(`oke Console http://127.0.0.1:${server.port}\n`);
317
+ write(
318
+ formatServiceLine(
319
+ "Console",
320
+ `http://127.0.0.1:${server.port}`,
321
+ ),
322
+ );
316
323
  return {
317
324
  console: server.console,
318
325
  port: server.port,
@@ -334,7 +341,7 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
334
341
  context: mcpOptions.context,
335
342
  now: mcpOptions.now,
336
343
  });
337
- write(`oke MCP http://127.0.0.1:${server.port}\n`);
344
+ write(formatServiceLine("MCP", `http://127.0.0.1:${server.port}`));
338
345
  return {
339
346
  port: server.port,
340
347
  url: server.url,
@@ -352,7 +359,7 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
352
359
  url: appUrl,
353
360
  out: resolve(cwd, "oke-client.d.ts"),
354
361
  });
355
- write("oke dev: regenerated oke-client.d.ts\n");
362
+ write(formatStatusLine("regenerated oke-client.d.ts"));
356
363
  } catch {
357
364
  // App may not be ready yet — ignore until next save.
358
365
  }
@@ -515,7 +522,7 @@ async function startAppHot(
515
522
  proc,
516
523
  APP_READY_TIMEOUT_MS,
517
524
  );
518
- // Child prints `oke app http://…` (again on each soft reload).
525
+ // Child prints the App ready line (again on each soft reload).
519
526
  const url = new URL(`http://${hostname}:${boundPort}/`);
520
527
  return { stop, port: boundPort, url };
521
528
  } catch (err) {
@@ -52,10 +52,13 @@ describe("claim code", () => {
52
52
 
53
53
  test("prints to boot log exactly once", () => {
54
54
  const state = mintClaimCode(() => 1);
55
- const lines: string[] = [];
56
- printClaimCodeOnce(state, (l) => lines.push(l));
57
- printClaimCodeOnce(state, (l) => lines.push(l));
58
- expect(lines.filter((l) => l.includes(state.code)).length).toBe(1);
55
+ const chunks: string[] = [];
56
+ printClaimCodeOnce(state, (l) => chunks.push(l));
57
+ printClaimCodeOnce(state, (l) => chunks.push(l));
58
+ const joined = chunks.join("");
59
+ expect(joined).toContain(state.code);
60
+ expect(joined).toContain("Claim code");
61
+ expect(chunks.length).toBe(1);
59
62
  });
60
63
 
61
64
  test("constantTimeEqual is length-safe", () => {
@@ -5,6 +5,7 @@
5
5
  * and rate-limited (console §2.5 · §10.4).
6
6
  */
7
7
 
8
+ import { formatClaimNote } from "../../term.ts";
8
9
  import {
9
10
  AUTH_RATE_LIMIT,
10
11
  AUTH_RATE_WINDOW_MS,
@@ -67,13 +68,7 @@ export function printClaimCodeOnce(
67
68
  ): void {
68
69
  if (state.printed) return;
69
70
  state.printed = true;
70
- write("");
71
- write("┌─────────────────────────────────────────────────────────┐");
72
- write("│ oke Console — first-admin claim code (expires 30 min) │");
73
- write(`│ ${state.code} │`);
74
- write("│ Whoever can read this log already owns the server. │");
75
- write("└─────────────────────────────────────────────────────────┘");
76
- write("");
71
+ write(formatClaimNote(state.code));
77
72
  }
78
73
 
79
74
  /** Result of {@link verifyClaimCode}. */