@lunora/cli 1.0.0-alpha.4 → 1.0.0-alpha.400
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/LICENSE.md +33 -0
- package/README.md +3 -1
- package/__assets__/package-og.svg +1 -1
- package/dist/bin.mjs +2 -10
- package/dist/index.d.mts +1161 -372
- package/dist/index.d.ts +1161 -372
- package/dist/index.mjs +1 -19
- package/dist/packem_chunks/dispatch.mjs +1 -0
- package/dist/packem_chunks/handler.mjs +1 -78
- package/dist/packem_chunks/handler10.mjs +1 -22
- package/dist/packem_chunks/handler11.mjs +1 -192
- package/dist/packem_chunks/handler12.mjs +1 -131
- package/dist/packem_chunks/handler13.mjs +3 -65
- package/dist/packem_chunks/handler14.mjs +1 -58
- package/dist/packem_chunks/handler15.mjs +1 -79
- package/dist/packem_chunks/handler16.mjs +1 -43
- package/dist/packem_chunks/handler17.mjs +7 -105
- package/dist/packem_chunks/handler18.mjs +1 -172
- package/dist/packem_chunks/handler19.mjs +1 -89
- package/dist/packem_chunks/handler2.mjs +1 -114
- package/dist/packem_chunks/handler20.mjs +3 -94
- package/dist/packem_chunks/handler21.mjs +3 -311
- package/dist/packem_chunks/handler22.mjs +1 -0
- package/dist/packem_chunks/handler23.mjs +2 -0
- package/dist/packem_chunks/handler24.mjs +99 -0
- package/dist/packem_chunks/handler25.mjs +2 -0
- package/dist/packem_chunks/handler26.mjs +9 -0
- package/dist/packem_chunks/handler27.mjs +1 -0
- package/dist/packem_chunks/handler3.mjs +1 -204
- package/dist/packem_chunks/handler4.mjs +3 -33
- package/dist/packem_chunks/handler5.mjs +1 -49
- package/dist/packem_chunks/handler6.mjs +1 -91
- package/dist/packem_chunks/handler7.mjs +1 -42
- package/dist/packem_chunks/handler8.mjs +2 -174
- package/dist/packem_chunks/handler9.mjs +1 -16
- package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
- package/dist/packem_chunks/runDeployCommand.mjs +11 -504
- package/dist/packem_chunks/runDevCommand.mjs +2 -0
- package/dist/packem_chunks/runInitCommand.mjs +1176 -576
- package/dist/packem_chunks/runResetCommand.mjs +1 -41
- package/dist/packem_chunks/runRpcCommand.mjs +1 -68
- package/dist/packem_shared/COMMANDS-aSTSMwZS.mjs +1 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-CyIsI3S1.mjs +1 -0
- package/dist/packem_shared/EXIT_CODE-D_XCixv8.mjs +1 -0
- package/dist/packem_shared/admin-token-VdUnvnKW.mjs +1 -0
- package/dist/packem_shared/admin-url-DJB8P6Jh.mjs +1 -0
- package/dist/packem_shared/api-spec-lYyq4vL6.mjs +1 -0
- package/dist/packem_shared/binding-manifest-file-CQ1eQYy1.mjs +2 -0
- package/dist/packem_shared/buildRegistryIndex-Dc8D8AR6.mjs +1 -0
- package/dist/packem_shared/cap-error-body-YBKO32BF.mjs +1 -0
- package/dist/packem_shared/catalog-CahzmDLV.mjs +1 -0
- package/dist/packem_shared/cli-CFsmCYWp.mjs +2 -0
- package/dist/packem_shared/cli-manifest-DoQ_3bzs.mjs +1 -0
- package/dist/packem_shared/cloudflare-credentials-BVmZnDZk.mjs +1 -0
- package/dist/packem_shared/codegen-error-AmH54ofi.mjs +3 -0
- package/dist/packem_shared/command-BgjsvUFg.mjs +1 -0
- package/dist/packem_shared/commands-DvSfLvyt.mjs +13 -0
- package/dist/packem_shared/createLogger-4TujevyB.mjs +2 -0
- package/dist/packem_shared/createRecordingSpawner-Ch7zuQQE.mjs +1 -0
- package/dist/packem_shared/deploy-target-resolve-BTCW1Iv4.mjs +1 -0
- package/dist/packem_shared/diffSnapshots-htqNZT8Q.mjs +7 -0
- package/dist/packem_shared/docker-AqLAkOyY.mjs +1 -0
- package/dist/packem_shared/health-probe-Bw9JFfIy.mjs +1 -0
- package/dist/packem_shared/import-BRM1hs7j.mjs +12 -0
- package/dist/packem_shared/index-oHZBGBwB.mjs +1 -0
- package/dist/packem_shared/insertSchemaExtension-DuiV6cba.mjs +8 -0
- package/dist/packem_shared/lint-ignore-report-DKZagpqk.mjs +2 -0
- package/dist/packem_shared/mcp-config-file-CcDTeXIq.mjs +2 -0
- package/dist/packem_shared/open-url-EnKy--w-.mjs +1 -0
- package/dist/packem_shared/output-format-DWe_tkTR.mjs +2 -0
- package/dist/packem_shared/parseManifest-CwPTKdtS.mjs +1 -0
- package/dist/packem_shared/path-containment-CgxYZggb.mjs +1 -0
- package/dist/packem_shared/plan-DVfi3TrN.mjs +5 -0
- package/dist/packem_shared/planDevCommand-IglbXy5A.mjs +1 -0
- package/dist/packem_shared/platform-diagnostics-Cn2g6Jh-.mjs +4 -0
- package/dist/packem_shared/prompt-cancelled-BvsNxg_Q.mjs +1 -0
- package/dist/packem_shared/render-lunora-error-C3OJY5wk.mjs +2 -0
- package/dist/packem_shared/resolve-Bdc9KEUv.mjs +5 -0
- package/dist/packem_shared/resolve-target-C_ZloTvd.mjs +1 -0
- package/dist/packem_shared/runAddCommand-BChdJQ5L.mjs +1 -0
- package/dist/packem_shared/runExportCommand-slAq5BCF.mjs +5 -0
- package/dist/packem_shared/runMigrateGenerateCommand-BwemPIOz.mjs +11 -0
- package/dist/packem_shared/schemaIrToSnapshot-BHuNOfgs.mjs +1 -0
- package/dist/packem_shared/secret-key-8DPOH98z.mjs +1 -0
- package/dist/packem_shared/shared-D-zCOmgY.mjs +1 -0
- package/dist/packem_shared/storage-DNzYhXR-.mjs +1 -0
- package/dist/packem_shared/tui-prompts-B3YwUhGw.mjs +4 -0
- package/dist/packem_shared/variables-CPYyJtsL.mjs +1 -0
- package/dist/packem_shared/wrangler-name-Dsk5K1f-.mjs +1 -0
- package/dist/packem_shared/wrangler-secrets-CTQPpalP.mjs +1 -0
- package/package.json +41 -19
- package/skills/README.md +35 -17
- package/skills/lunora/SKILL.md +154 -64
- package/skills/lunora-create-package/SKILL.md +97 -84
- package/skills/lunora-deploy/SKILL.md +175 -105
- package/skills/lunora-functions/SKILL.md +362 -56
- package/skills/lunora-migration-helper/SKILL.md +162 -137
- package/skills/lunora-performance-audit/SKILL.md +137 -95
- package/skills/lunora-quickstart/SKILL.md +137 -136
- package/skills/lunora-realtime/SKILL.md +140 -99
- package/skills/lunora-setup-auth/SKILL.md +162 -102
- package/skills/lunora-setup-hyperdrive/SKILL.md +130 -109
- package/skills/lunora-setup-hyperdrive-global/SKILL.md +93 -90
- package/skills/lunora-setup-mail/SKILL.md +85 -113
- package/skills/lunora-setup-scheduler/SKILL.md +132 -96
- package/skills/lunora-setup-storage/SKILL.md +189 -91
- package/dist/packem_chunks/planDevCommand.mjs +0 -543
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +0 -397
- package/dist/packem_shared/COMMANDS-CHw4zOZ9.mjs +0 -922
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +0 -244
- package/dist/packem_shared/admin-url-4UzT-CI4.mjs +0 -19
- package/dist/packem_shared/api-spec-CtA6ilu4.mjs +0 -13
- package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +0 -38
- package/dist/packem_shared/command-BDXcJCCJ.mjs +0 -14
- package/dist/packem_shared/commands-SUPdjsu5.mjs +0 -787
- package/dist/packem_shared/createLogger-CHPNjFw2.mjs +0 -73
- package/dist/packem_shared/defaultSpawner-DxI3mebw.mjs +0 -43
- package/dist/packem_shared/diffSnapshots-RR2ZE8Ya.mjs +0 -161
- package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
- package/dist/packem_shared/features-ocSSpZtS.mjs +0 -24
- package/dist/packem_shared/insertSchemaExtension-BuzF6-t2.mjs +0 -59
- package/dist/packem_shared/open-url-Dfq6fAyT.mjs +0 -41
- package/dist/packem_shared/output-format-7gyGR3h8.mjs +0 -17
- package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
- package/dist/packem_shared/parseManifest--vZf2FY1.mjs +0 -94
- package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +0 -16
- package/dist/packem_shared/runAddCommand-Txwh1Xw1.mjs +0 -4
- package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
- package/dist/packem_shared/schemaIrToSnapshot-aBTo7TM5.mjs +0 -43
- package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/cli",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"description": "The Lunora CLI: init, dev, deploy, codegen,
|
|
3
|
+
"version": "1.0.0-alpha.400",
|
|
4
|
+
"description": "The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-skills",
|
|
7
7
|
"cli",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"lunora": "./dist/bin.mjs"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
|
-
"dist",
|
|
33
|
+
"./dist",
|
|
34
34
|
"__assets__",
|
|
35
35
|
"skills",
|
|
36
36
|
"README.md",
|
|
@@ -51,25 +51,47 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@bomb.sh/tab": "0.0.
|
|
55
|
-
"@lunora/
|
|
56
|
-
"@lunora/
|
|
57
|
-
"@lunora/
|
|
58
|
-
"@lunora/
|
|
59
|
-
"@lunora/
|
|
60
|
-
"@lunora/
|
|
61
|
-
"@lunora/
|
|
62
|
-
"@lunora/
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"@visulima/
|
|
66
|
-
"@visulima/
|
|
67
|
-
"@visulima/
|
|
68
|
-
"
|
|
54
|
+
"@bomb.sh/tab": "0.0.22",
|
|
55
|
+
"@lunora/advisor": "1.0.0-alpha.235",
|
|
56
|
+
"@lunora/bindings": "1.0.0-alpha.123",
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.326",
|
|
58
|
+
"@lunora/config": "1.0.0-alpha.375",
|
|
59
|
+
"@lunora/container": "1.0.0-alpha.82",
|
|
60
|
+
"@lunora/d1": "1.0.0-alpha.190",
|
|
61
|
+
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
62
|
+
"@lunora/mcp": "1.0.0-alpha.242",
|
|
63
|
+
"@lunora/runtime": "1.0.0-alpha.219",
|
|
64
|
+
"@lunora/seed": "1.0.0-alpha.237",
|
|
65
|
+
"@visulima/cerebro": "3.1.2",
|
|
66
|
+
"@visulima/error": "6.1.0",
|
|
67
|
+
"@visulima/fs": "6.0.29",
|
|
68
|
+
"@visulima/pail": "5.0.0",
|
|
69
|
+
"@visulima/path": "4.0.0",
|
|
70
|
+
"@visulima/spinner": "1.0.1",
|
|
71
|
+
"@visulima/tui": "4.0.29",
|
|
72
|
+
"@visulima/tui-kit": "1.0.32",
|
|
73
|
+
"adm-zip": "0.6.1",
|
|
74
|
+
"csv-parse": "7.0.3",
|
|
75
|
+
"giget": "3.3.1",
|
|
69
76
|
"jsonc-parser": "^3.3.1",
|
|
70
|
-
"magic-string": "^
|
|
77
|
+
"magic-string": "^1.4.2",
|
|
78
|
+
"react": "^19.3.0",
|
|
79
|
+
"react-reconciler": "^0.33.0",
|
|
80
|
+
"smol-toml": "1.9.0",
|
|
71
81
|
"ts-morph": "^28.0.0"
|
|
72
82
|
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"mysql2": "*",
|
|
85
|
+
"pg": "*"
|
|
86
|
+
},
|
|
87
|
+
"peerDependenciesMeta": {
|
|
88
|
+
"mysql2": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"pg": {
|
|
92
|
+
"optional": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
73
95
|
"engines": {
|
|
74
96
|
"node": "^22.15.0 || >=24.11.0"
|
|
75
97
|
}
|
package/skills/README.md
CHANGED
|
@@ -9,21 +9,39 @@ framework correctly. They ship inside `@lunora/cli` and are discovered by the
|
|
|
9
9
|
Each skill is a `SKILL.md` with YAML frontmatter (`name`, `description`) in its
|
|
10
10
|
own directory:
|
|
11
11
|
|
|
12
|
-
| Skill
|
|
13
|
-
|
|
|
14
|
-
| `lunora`
|
|
15
|
-
| `lunora-quickstart`
|
|
16
|
-
| `lunora-functions`
|
|
17
|
-
| `lunora-realtime`
|
|
18
|
-
| `lunora-setup-auth`
|
|
19
|
-
| `lunora-setup-mail`
|
|
20
|
-
| `lunora-setup-storage`
|
|
21
|
-
| `lunora-setup-scheduler`
|
|
22
|
-
| `lunora-
|
|
23
|
-
| `lunora-
|
|
24
|
-
| `lunora-
|
|
25
|
-
| `lunora-
|
|
12
|
+
| Skill | Use for |
|
|
13
|
+
| -------------------------------- | ---------------------------------------------------------------------------- |
|
|
14
|
+
| `lunora` | Router — start here, then switch to the matching skill below. |
|
|
15
|
+
| `lunora-quickstart` | `lunora init` / adding Lunora to an app + first round-trip. |
|
|
16
|
+
| `lunora-functions` | Core authoring rules — schema, validators, query/mutation/action, `ctx.db`. |
|
|
17
|
+
| `lunora-realtime` | Client reactivity — live hooks, optimistic updates, `@lunora/db`. |
|
|
18
|
+
| `lunora-setup-auth` | Authentication via `lunora registry add auth` (+ providers). |
|
|
19
|
+
| `lunora-setup-mail` | Transactional email via `lunora registry add mail` — `sendEmail` actions. |
|
|
20
|
+
| `lunora-setup-storage` | R2 file storage via `lunora registry add storage` — signed upload/download. |
|
|
21
|
+
| `lunora-setup-scheduler` | Deferred (`ctx.scheduler`) + cron jobs (`lunora registry add crons`). |
|
|
22
|
+
| `lunora-setup-hyperdrive` | Existing Postgres/MySQL from an action — `ctx.sql`, non-reactive. |
|
|
23
|
+
| `lunora-setup-hyperdrive-global` | Postgres/MySQL as a reactive `.global()` backend; D1 → Hyperdrive migration. |
|
|
24
|
+
| `lunora-create-package` | Building a reusable registry item or `@lunora/*` package. |
|
|
25
|
+
| `lunora-migration-helper` | Schema/data migrations, `.global()` DDL flow, the drift gate. |
|
|
26
|
+
| `lunora-deploy` | Deploying to Cloudflare — wrangler bindings, secrets, the gate. |
|
|
27
|
+
| `lunora-performance-audit` | `lunora insights`, scans, indexes, OCC conflicts, sharding/`.global()`. |
|
|
26
28
|
|
|
27
|
-
These are mirrored into `.agents/skills/` and `.claude/skills
|
|
28
|
-
so agents working inside this repo pick them up directly
|
|
29
|
-
|
|
29
|
+
These are mirrored (via symlinks) into `.agents/skills/` and `.claude/skills/`,
|
|
30
|
+
so agents working inside this repo pick them up directly, and into
|
|
31
|
+
`plugins/lunora/skills/`, the payload of the Claude Code / Codex plugin. The
|
|
32
|
+
source of truth lives here so the published `@lunora/cli` tarball carries them —
|
|
33
|
+
`lunora rules install` copies this directory into a consumer project.
|
|
34
|
+
|
|
35
|
+
**Adding a skill?** Create it here, then mirror it through all three hops:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
ln -s ../../packages/cli/skills/<name> .agents/skills/<name>
|
|
39
|
+
ln -s ../../.agents/skills/<name> .claude/skills/<name>
|
|
40
|
+
ln -s ../../../packages/cli/skills/<name> plugins/lunora/skills/<name>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`scripts/check-skill-mirrors.js` (run on every `pnpm install`) fails if a mirror
|
|
44
|
+
is missing, dangling, or has become a real directory — a copied directory keeps
|
|
45
|
+
resolving while it silently drifts from the source, so it is treated as an
|
|
46
|
+
error rather than a warning. Forget a hop and it prints the exact `ln -s` for
|
|
47
|
+
the one you missed, so `pnpm install` is the shortest path to the right command.
|
package/skills/lunora/SKILL.md
CHANGED
|
@@ -1,83 +1,173 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lunora
|
|
3
|
-
description: Routes general Lunora requests to the right
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
description: Routes general Lunora requests to the right Lunora skill and gives the
|
|
4
|
+
shared mental model (codegen loop, generated `api`/`internal` references,
|
|
5
|
+
review commands, add-on capabilities, the `@lunora/mcp` server). Use when the
|
|
6
|
+
user asks which Lunora skill to use, gives an underspecified task in a project
|
|
7
|
+
with a `lunora/` directory or `lunorash`/`@lunora/*` dependencies, asks to
|
|
8
|
+
review or audit Lunora code, asks about an add-on without its own skill
|
|
9
|
+
(queues, workflows, agents, AI, flags, payments, notifications), or wants to
|
|
10
|
+
expose a deployment to an AI agent over MCP.
|
|
7
11
|
---
|
|
8
12
|
|
|
9
13
|
# Lunora
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
Lunora is a type-safe, real-time backend on Cloudflare Workers + Durable
|
|
16
|
+
Objects. Functions are chainable `query` / `mutation` / `action` builders; state
|
|
17
|
+
lives in one `ShardDO` per app by default (SQLite, OCC, hibernated WebSocket
|
|
18
|
+
subscriptions). `.shardBy(key)` partitions a table across many DOs and
|
|
19
|
+
`.global()` replicates it to D1 (or Postgres/MySQL over Hyperdrive) for
|
|
20
|
+
cross-region reads. Codegen produces the types the client and server share.
|
|
12
21
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
lives in a per-app `ShardDO` (SQLite, OCC, hibernated WebSocket subscriptions)
|
|
16
|
-
by default; `.shardBy(key)` partitions it across many DOs and `.global()`
|
|
17
|
-
replicates a table to D1 for low-latency cross-region reads. A Vite plugin
|
|
18
|
-
drives codegen and end-to-end type sync.
|
|
22
|
+
If a project-level `AGENTS.md` / `CLAUDE.md` exists, read it first; it overrides
|
|
23
|
+
these defaults. If a more specific Lunora skill matches, switch to it.
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## Start Here
|
|
23
|
-
|
|
24
|
-
Before writing or changing any `lunora/` code, make sure the generated types are
|
|
25
|
-
current — they are the contract the client and server share.
|
|
25
|
+
## The feedback loop
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
lunora codegen
|
|
28
|
+
lunora codegen # regenerate lunora/_generated/ from lunora/schema.ts + function files
|
|
29
|
+
lunora verify # wrangler config + codegen dry-run + tsc --noEmit; writes nothing
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
`
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
these defaults.
|
|
32
|
+
`lunora codegen` writes `lunora/_generated/` (`api.ts`, `internal.ts`,
|
|
33
|
+
`server.ts`, `dataModel.ts`, `shard.ts`, `app.ts`, `openapi.ts`, …; it prints
|
|
34
|
+
the exact list) and reports schema advisories and platform diagnostics. It does
|
|
35
|
+
not run `tsc`, so use `lunora verify` as the check that the code you wrote is
|
|
36
|
+
done. Its `tsc --noEmit` step runs only when the project has a `tsconfig.json`
|
|
37
|
+
(otherwise it warns and skips) and is turned off by `--no-typecheck`. `lunora dev` re-runs codegen on save, and `lunora deploy` runs it too.
|
|
38
|
+
Scaffolded projects gitignore `lunora/_generated/`; never hand-edit it.
|
|
39
39
|
|
|
40
|
-
## Route to the
|
|
41
|
-
|
|
42
|
-
After codegen is green, use the most specific Lunora skill for the task:
|
|
40
|
+
## Route to the right skill
|
|
43
41
|
|
|
44
42
|
- New project, or adding Lunora to an existing app: `lunora-quickstart`
|
|
45
43
|
- Writing or reviewing schema + functions (the core authoring rules):
|
|
46
44
|
`lunora-functions`
|
|
47
45
|
- Wiring live data into a client (hooks, optimistic updates): `lunora-realtime`
|
|
48
|
-
- Authentication
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- Building a reusable capability
|
|
46
|
+
- Authentication (email/password, OAuth, magic link, OTP): `lunora-setup-auth`
|
|
47
|
+
- Transactional email: `lunora-setup-mail`
|
|
48
|
+
- R2 file storage (signed upload/download): `lunora-setup-storage`
|
|
49
|
+
- Deferred work (`ctx.scheduler`) and cron jobs: `lunora-setup-scheduler`
|
|
50
|
+
- Querying an existing Postgres/MySQL database from an action (`ctx.sql`,
|
|
51
|
+
non-reactive): `lunora-setup-hyperdrive`
|
|
52
|
+
- Postgres/MySQL as a reactive `.global()` backend, or migrating a D1
|
|
53
|
+
`.global()` dataset onto it: `lunora-setup-hyperdrive-global`
|
|
54
|
+
- Building a reusable capability (registry item or `@lunora/*` package):
|
|
57
55
|
`lunora-create-package`
|
|
58
|
-
-
|
|
59
|
-
- Deploying
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
56
|
+
- Schema/data migrations: `lunora-migration-helper`
|
|
57
|
+
- Deploying (wrangler, bindings, secrets, the drift gate): `lunora-deploy`
|
|
58
|
+
- Slow queries, scans, write conflicts: `lunora-performance-audit`
|
|
59
|
+
|
|
60
|
+
### Reviewing existing `lunora/` code
|
|
61
|
+
|
|
62
|
+
There is no review skill because two commands do the mechanical part. Run them
|
|
63
|
+
before reading code by hand:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
lunora verify # does it build and typecheck
|
|
67
|
+
lunora advisor # static + runtime lint set, scored per procedure
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`lunora advisor` covers RLS coverage, ownership and identity checks, fail-open
|
|
71
|
+
guards, input validators, unindexed reads, non-deterministic calls in queries,
|
|
72
|
+
SQL interpolation and leaked secrets. It prints each finding's lint id and
|
|
73
|
+
category, so read its output rather than guessing rule names. `--entry
|
|
74
|
+
<file>#<export>` inspects one procedure; `--min-score` / `--baseline` gate CI.
|
|
75
|
+
Once it is clean, a by-hand pass against `lunora-functions` is worth the tokens.
|
|
76
|
+
|
|
77
|
+
## Core mental model
|
|
78
|
+
|
|
79
|
+
- Functions live in `lunora/**/*.ts` and import their builders from the
|
|
80
|
+
generated server module: `query` (reactive read), `mutation` (transactional
|
|
81
|
+
write), `action` (side effects, `fetch`, no direct db). `internalQuery` /
|
|
82
|
+
`internalMutation` / `internalAction` are not callable from clients.
|
|
83
|
+
- Schema lives in `lunora/schema.ts` (`defineSchema` + `defineTable`, validators
|
|
84
|
+
from `v.*`), imported from `lunorash/server` or `@lunora/server`.
|
|
85
|
+
- Function references mirror the folder tree: `lunora/billing/invoices.ts`
|
|
86
|
+
exporting `create` is `api.billing.invoices.create`. Public references come
|
|
87
|
+
from `_generated/api`, internal ones from `_generated/internal` (kept separate
|
|
88
|
+
so client bundles never carry internal names). A reference is a plain
|
|
89
|
+
`{ __lunoraRef: "billing_invoices:create" }` object; there is no `anyApi`
|
|
90
|
+
proxy.
|
|
91
|
+
- Reads go through indexes: declare `.index("by_x", ["x"])` and query with
|
|
92
|
+
`ctx.db.query("t").withIndex("by_x", (q) => q.eq("x", value))`, not
|
|
93
|
+
`.filter(...)`.
|
|
94
|
+
- Clients subscribe over WebSocket; `useQuery` re-renders when a mutation
|
|
95
|
+
changes the queried rows. Subscriptions run under the socket's verified
|
|
96
|
+
identity, so `rls()` and `ctx.auth` apply to live updates too.
|
|
97
|
+
|
|
98
|
+
## Capabilities without a dedicated skill
|
|
99
|
+
|
|
100
|
+
Most add-ons install as a registry item: `lunora add <feature>` (or
|
|
101
|
+
`lunora registry add <item>`) scaffolds the `lunora/` glue, wrangler bindings
|
|
102
|
+
and `.dev.vars` entries, then prints post-install steps. Browse with
|
|
103
|
+
`lunora registry list`, preview with `lunora registry view <item>`. Read the
|
|
104
|
+
installed item's README and the package's `docs/` for the API.
|
|
105
|
+
|
|
106
|
+
| Goal | Install / package |
|
|
107
|
+
| --------------------------------------------- | ---------------------------------------------------------- |
|
|
108
|
+
| Background jobs on Cloudflare Queues | `lunora add queue` → `@lunora/queue` (`ctx.queues`) |
|
|
109
|
+
| Durable multi-step workflows | `lunora add workflow` → `@lunora/workflow` (`ctx.runStep`) |
|
|
110
|
+
| Durable AI agents (tool loops, HITL, memory) | `@lunora/agent` (`defineAgent`) |
|
|
111
|
+
| Workers AI / RAG | `lunora add ai` → `@lunora/ai` (`ctx.ai`, `defineRag`) |
|
|
112
|
+
| Feature flags (OpenFeature) | `lunora add flags` → `@lunora/flags` (`ctx.flags`) |
|
|
113
|
+
| Payments (Stripe / Polar) | `lunora add payment` → `@lunora/payment` |
|
|
114
|
+
| Agent payments (x402) | `@lunora/x402` |
|
|
115
|
+
| Push / in-app / webhook notifications | `@lunora/notify` (`ctx.notify`, `ctx.push`) |
|
|
116
|
+
| Rate limiting | `lunora add ratelimit` → `@lunora/ratelimit` |
|
|
117
|
+
| Headless browser (action-only) | `lunora add browser` → `@lunora/browser` (`ctx.browser`) |
|
|
118
|
+
| Cloudflare Containers | `@lunora/container` (`defineContainer`, `ctx.containers`) |
|
|
119
|
+
| Presence / who's-here | `lunora add presence` |
|
|
120
|
+
| Cloudflare Access (Zero Trust) identity | `lunora add cloudflare-access` |
|
|
121
|
+
| Backup / restore | `lunora add backup` |
|
|
122
|
+
| Testing (in-memory harness, agent doubles) | `@lunora/testing` (`lunoraTest`) |
|
|
123
|
+
| Deterministic seed data | `@lunora/seed` + `lunora seed` |
|
|
124
|
+
| Local-first replica / offline mirror | `@lunora/replica` |
|
|
125
|
+
| Exposing the deployment to AI agents over MCP | `@lunora/mcp` (below) |
|
|
126
|
+
|
|
127
|
+
Inside the Lunora monorepo, `vis generate lunora-<kind>` scaffolds code:
|
|
128
|
+
`query`, `mutation`, `action`, `http-route`, `table`, `cron`, `container`,
|
|
129
|
+
`workflow`, `queue`, `step`, `agent`, `package`, plus the no-name singletons
|
|
130
|
+
`flags`, `auth-do` and `collections` (`vis generate --list` for the set). Pass
|
|
131
|
+
names as `--name=value`: vis parses `--name foo` as `--name=true` plus a stray
|
|
132
|
+
positional.
|
|
133
|
+
|
|
134
|
+
## Exposing a deployment over MCP
|
|
135
|
+
|
|
136
|
+
Two entry points:
|
|
137
|
+
|
|
138
|
+
- `lunora mcp install` wires an editor (Claude Code, Cursor, …) to the hosted
|
|
139
|
+
docs server plus this project's dev server; `lunora mcp serve` is the stdio
|
|
140
|
+
server those entries spawn (`--allow-writes`, `--token` opt into more).
|
|
141
|
+
- The `lunora-mcp` binary from `@lunora/mcp` fronts a deployed Worker. It needs
|
|
142
|
+
`LUNORA_URL` and `LUNORA_ADMIN_TOKEN`. Every tool reads admin-gated routes, so
|
|
143
|
+
the token cannot be scoped down; safety comes from the gates below.
|
|
144
|
+
|
|
145
|
+
Always advertised: `lunora_list_functions`, `lunora_list_tables` (`.global()`
|
|
146
|
+
tables with row counts), `lunora_get_function_schema`, `lunora_run_query`
|
|
147
|
+
(read-only), and `lunora_explain_error`, which explains an error `code` or
|
|
148
|
+
message from the catalog compiled into `@lunora/errors` and needs no
|
|
149
|
+
deployment. Use it before guessing what a Lunora error means.
|
|
150
|
+
|
|
151
|
+
Everything else sits behind an env gate that both hides the tool and refuses it
|
|
152
|
+
at dispatch. All default to off; enable one only when the answer to "may a model
|
|
153
|
+
see this?" is yes.
|
|
154
|
+
|
|
155
|
+
- `LUNORA_MCP_ALLOW_WRITES` → `lunora_run_mutation`, `lunora_run_action`.
|
|
156
|
+
- `LUNORA_MCP_ALLOW_OBSERVABILITY` → the five `lunora_get_*` tools (logs,
|
|
157
|
+
issues, advisories, query insights, migration status). Read-only, but they
|
|
158
|
+
return production log lines and error messages, which then reach the model
|
|
159
|
+
provider.
|
|
160
|
+
- `LUNORA_MCP_ALLOW_DATA_READS` → `lunora_find_related`. It returns raw rows
|
|
161
|
+
read through the admin writer, with RLS and column masks bypassed. It is kept
|
|
162
|
+
separate from observability so enabling logs never also hands over rows.
|
|
163
|
+
- `LUNORA_MCP_ALLOW_AGENTS` (with `LUNORA_MCP_AGENTS="name:description;…"`) →
|
|
164
|
+
the `agent_<name>` tools and `lunora_agent_status`.
|
|
165
|
+
|
|
166
|
+
Writes are a two-step handshake. The first `lunora_run_mutation` /
|
|
167
|
+
`lunora_run_action` call does not execute; it returns `status:
|
|
168
|
+
"action_required"` with `proposedAction`, an `actionDigest`, and an `expiresAt`
|
|
169
|
+
ten minutes out. The client shows that to a human, then repeats the call with
|
|
170
|
+
identical `functionPath`, `args` and `shardKey` plus `confirmed: true` and the
|
|
171
|
+
digest. Any edit needs a fresh proposal, and an expired digest is refused. The
|
|
172
|
+
digest proves the write that runs is the one proposed; it does not prove a human
|
|
173
|
+
saw it, so enabling writes means trusting the client to ask.
|
|
@@ -1,47 +1,36 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lunora-create-package
|
|
3
|
-
description: Builds a reusable Lunora capability
|
|
4
|
-
`lunora registry add
|
|
5
|
-
|
|
3
|
+
description: Builds a reusable Lunora capability, either as a registry item that
|
|
4
|
+
`lunora add` / `lunora registry add` copies into an app's `lunora/`, or as a
|
|
5
|
+
publishable `@lunora/*` workspace package in the Lunora monorepo. Use when the
|
|
6
|
+
user wants to package schema + functions + wrangler bindings + env vars for
|
|
7
|
+
other apps, add or edit an item under `registry/<name>/` (`registry.json`),
|
|
8
|
+
run `vis generate lunora-package`, or wire a new `ctx.*` capability into
|
|
9
|
+
codegen.
|
|
6
10
|
---
|
|
7
11
|
|
|
8
12
|
# Lunora Create Package
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
**imported as a dependency**.
|
|
14
|
+
Pick the shape by whether the code is copied into the user's `lunora/` or
|
|
15
|
+
imported as a dependency:
|
|
13
16
|
|
|
14
|
-
| Shape
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
17
|
+
| Shape | Distribution | Use for |
|
|
18
|
+
| ------------- | -------------------------------- | ------------------------------------------------ |
|
|
19
|
+
| Registry item | `lunora registry add <name>` | App-owned code (schema/functions) the user edits |
|
|
20
|
+
| Workspace pkg | `import … from "@lunora/<name>"` | Library code consumed as a versioned dependency |
|
|
18
21
|
|
|
19
|
-
Many capabilities use
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
and `storage` all follow this pattern.
|
|
22
|
+
Many capabilities use both: a `@lunora/<name>` package holds the runtime and a
|
|
23
|
+
registry item scaffolds the glue (files under `lunora/<name>/`, bindings, env
|
|
24
|
+
vars). `auth`, `mail`, `ratelimit` and `storage` follow this pattern.
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
Skip this skill for a one-off feature in a single app (write it in `lunora/`),
|
|
27
|
+
or when the capability already exists (`lunora registry list`).
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
- Authoring a new capability (presence, search, payments, …) for other apps.
|
|
28
|
-
- Adding a new item to this repo's `registry/`.
|
|
29
|
+
## Path A: registry item
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
- The capability already exists as a registry item or `@lunora/*` package — use
|
|
34
|
-
it (`lunora registry list` to browse).
|
|
35
|
-
|
|
36
|
-
## Path A: Registry Item
|
|
37
|
-
|
|
38
|
-
A registry item is a directory under `registry/<name>/` with three files:
|
|
39
|
-
|
|
40
|
-
- `registry.json` — the manifest (deps, bindings, env vars, files, requires).
|
|
41
|
-
- `index.ts` (and any siblings) — the code copied into the user's project.
|
|
42
|
-
- `README.md` — install + configuration docs.
|
|
43
|
-
|
|
44
|
-
### Manifest shape
|
|
31
|
+
An item is a directory `registry/<name>/` holding `registry.json`, the source
|
|
32
|
+
files it copies, and a `README.md`. Validate against
|
|
33
|
+
`registry/schema/registry-item.schema.json`.
|
|
45
34
|
|
|
46
35
|
```jsonc
|
|
47
36
|
// registry/<name>/registry.json
|
|
@@ -50,80 +39,104 @@ A registry item is a directory under `registry/<name>/` with three files:
|
|
|
50
39
|
"name": "<name>",
|
|
51
40
|
"title": "Human Title",
|
|
52
41
|
"description": "One-paragraph summary shown in `lunora registry list`.",
|
|
53
|
-
"docs": "Post-install steps
|
|
54
|
-
"requires": [], // other
|
|
42
|
+
"docs": "Post-install steps printed after `lunora registry add`.",
|
|
43
|
+
"requires": [], // other items, installed first (e.g. auth-clerk requires auth)
|
|
55
44
|
"deps": { "@lunora/server": "workspace:*" },
|
|
45
|
+
"devDependencies": {},
|
|
56
46
|
"bindings": [
|
|
57
|
-
//
|
|
47
|
+
// structural edits applied to wrangler.jsonc
|
|
58
48
|
{ "path": ["d1_databases"], "value": [{ "binding": "DB", "database_name": "REPLACE_ME-db", "database_id": "<replace-with-d1-create-id>" }] },
|
|
59
49
|
],
|
|
60
50
|
"envVars": [{ "name": "MY_SECRET", "description": "What it is and how to generate it.", "secret": true }],
|
|
61
|
-
"files": [
|
|
51
|
+
"files": [
|
|
52
|
+
{ "from": "schema.ts", "to": "lunora/<name>/schema.ts", "merge": "schema-extension" },
|
|
53
|
+
{ "from": "<name>.ts", "to": "lunora/<name>/index.ts", "merge": "create-or-skip" },
|
|
54
|
+
],
|
|
62
55
|
}
|
|
63
56
|
```
|
|
64
57
|
|
|
65
|
-
- `files[].merge
|
|
66
|
-
`
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
- `files[].merge`: `create-or-skip` writes whole files and never clobbers a file
|
|
59
|
+
the user edited; `schema-extension` AST-merges into `lunora/schema.ts`.
|
|
60
|
+
- `envVars` land in `.dev.vars`. Non-secret vars get their `value`; secrets get
|
|
61
|
+
an empty placeholder plus a `wrangler secret put <NAME>` reminder.
|
|
62
|
+
- `entrypointReexports` (`[{ "module": "_generated/workflows" }]`) injects
|
|
63
|
+
`export * from './lunora/<module>'` into the worker entry of framework
|
|
64
|
+
(class B/C) projects, for items whose generated classes the worker must
|
|
65
|
+
export. No shipped item uses it yet.
|
|
66
|
+
- Function files import builders from `#lunora/_generated/server.js`, the
|
|
67
|
+
module codegen emits in a consumer project. `registry/tsconfig.json` stubs
|
|
68
|
+
that module so the item typechecks here.
|
|
69
|
+
- `deps` ranges are copied verbatim into the user's `package.json`. Use
|
|
70
|
+
`workspace:*` for `@lunora/*` (resolved at publish); any other range must
|
|
71
|
+
admit the version the workspace resolves, or `pnpm install` fails
|
|
72
|
+
(`scripts/check-registry-catalog-ranges.js`).
|
|
73
|
+
|
|
74
|
+
Verify:
|
|
74
75
|
|
|
75
76
|
```bash
|
|
76
|
-
lunora registry build
|
|
77
|
-
lunora registry build --check
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
lunora registry build --from ./registry # regenerate registry/index.json from the item dirs
|
|
78
|
+
lunora registry build --from ./registry --check # CI: index is current
|
|
79
|
+
pnpm run lint:types:registry # tsc over every item (builds packages first)
|
|
80
|
+
pnpm run lint:registry:items # manifest + generated-deps tests
|
|
81
|
+
lunora registry view <name> --from <repo>/registry # preview
|
|
82
|
+
lunora registry add <name> --from <repo>/registry --dry-run # in a scratch app
|
|
80
83
|
```
|
|
81
84
|
|
|
82
|
-
|
|
85
|
+
`registry/index.json` is generated; do not hand-edit it.
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
`--name=value` form):
|
|
87
|
+
## Path B: workspace package (Lunora monorepo)
|
|
86
88
|
|
|
87
89
|
```bash
|
|
88
|
-
vis generate lunora-package --name=search --description='Typed full-text search over Lunora tables'
|
|
90
|
+
vis generate lunora-package --name=search --description='Typed full-text search over Lunora tables' --category=add-on
|
|
89
91
|
```
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
`
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
Pass every option as `--name=value`; vis reads `--name search` as
|
|
94
|
+
`--name=true` plus a stray positional.
|
|
95
|
+
|
|
96
|
+
This writes `packages/search/` with `package.json` (ESM-only,
|
|
97
|
+
`"sideEffects": false`, catalog versions), `src/index.ts`, `tsconfig.json`,
|
|
98
|
+
`vitest.config.ts`, `packem.config.ts`, `eslint.config.js`,
|
|
99
|
+
`prettier.config.js`, `project.json` (tags `type:package` +
|
|
100
|
+
`category:<category>`), `.releaserc.json` and `README.md`. It does not create
|
|
101
|
+
`__tests__/` or `LICENSE.md`. Then:
|
|
95
102
|
|
|
96
|
-
|
|
103
|
+
1. `cp packages/config/LICENSE.md packages/search/LICENSE.md` (packem and
|
|
104
|
+
`files` expect it).
|
|
105
|
+
2. Add a row to `.agents/docs/packages.md`, and list the directory in one tier
|
|
106
|
+
of `scripts/api-snapshot.js` and the matching tier in `ROADMAP.md`. The
|
|
107
|
+
`pnpm install` postinstall checks (`check-agents-md-packages`,
|
|
108
|
+
`check-roadmap-tiers`) fail until both are done.
|
|
109
|
+
3. `pnpm install`, then add tests under `__tests__/`.
|
|
97
110
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
more than one export.
|
|
102
|
-
- **Use the dependency catalogs** in `pnpm-workspace.yaml` (`catalog:test`,
|
|
103
|
-
`catalog:lint`, …) — never hard-code a version that lives in a catalog.
|
|
104
|
-
- Tag `project.json` with `type:package` and a `category:<slug>`.
|
|
111
|
+
Repo conventions: relative imports without `.js`, named exports only (a
|
|
112
|
+
`default` only as a file's sole export), dependency versions via `catalog:*`
|
|
113
|
+
from `pnpm-workspace.yaml`.
|
|
105
114
|
|
|
106
|
-
|
|
115
|
+
Verify:
|
|
107
116
|
|
|
108
117
|
```bash
|
|
118
|
+
pnpm --filter "@lunora/search..." run build
|
|
109
119
|
pnpm --filter "@lunora/search" run lint:types
|
|
110
120
|
pnpm --filter "@lunora/search" run test
|
|
121
|
+
pnpm run lint:package-json
|
|
122
|
+
pnpm run api:update # writes api-snapshots/search.api.md from the fresh build; commit it
|
|
111
123
|
```
|
|
112
124
|
|
|
113
|
-
##
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
## Wiring a `ctx.*` capability into codegen
|
|
126
|
+
|
|
127
|
+
Codegen decides which `ctx.*` fields exist by detecting usage, so a new
|
|
128
|
+
binding-backed helper is a literal row in `CAPABILITY_ROWS`
|
|
129
|
+
(`packages/codegen/src/capabilities.ts`; `CAPABILITIES` is a read-only view of
|
|
130
|
+
it): its package, `ctx` property, tier
|
|
131
|
+
(`"every"` or `"action"`-only), ctx type fragment, ShardDO binding, and
|
|
132
|
+
`defineApp` method. Rate the feature for every target in the
|
|
133
|
+
`PlatformCapabilities` matrices in `@lunora/platform`
|
|
134
|
+
(`packages/platform/src/capabilities/`) as `native`, `emulated` or
|
|
135
|
+
`unsupported` in the same change. A feature a target leaves unrated is dropped
|
|
136
|
+
from that target's generated surface with a diagnostic. Declaration-gated
|
|
137
|
+
surfaces (flags, notify, containers, workflows, queues, agents) also have their
|
|
138
|
+
own emitters; some of them (flags, notify, containers, workflows) keep a row too,
|
|
139
|
+
for usage probing, so a row and a dedicated emitter can coexist.
|
|
140
|
+
|
|
141
|
+
Document in the README any `lunora/*.ts` declaration the user must add for
|
|
142
|
+
codegen to emit the typed surface.
|