@lunora/config 1.0.0-alpha.3 → 1.0.0-alpha.300

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 (119) hide show
  1. package/LICENSE.md +135 -0
  2. package/README.md +3 -3
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/cloudflare/index.d.mts +1205 -0
  5. package/dist/cloudflare/index.d.ts +1205 -0
  6. package/dist/cloudflare/index.mjs +1 -0
  7. package/dist/index.d.mts +1176 -802
  8. package/dist/index.d.ts +1176 -802
  9. package/dist/index.mjs +1 -20
  10. package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
  11. package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
  12. package/dist/packem_shared/AGENT_RULES_DIR-C54Ta_vz.mjs +1 -0
  13. package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
  14. package/dist/packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs +1 -0
  15. package/dist/packem_shared/CLOUDFLARE_DRIVER-Ci3VIqnk.mjs +1 -0
  16. package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-Grzfm5p1.mjs +1 -0
  17. package/dist/packem_shared/CODEGEN_ENV-ZsCxV1kP.mjs +1 -0
  18. package/dist/packem_shared/COMPOSED_WORKER_ENTRY-C69wqbSP.mjs +1 -0
  19. package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-CfoV0tDu.mjs +1 -0
  20. package/dist/packem_shared/DEFAULT_OBSERVABILITY-bN6UkTMx.mjs +1 -0
  21. package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs +4 -0
  22. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
  23. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-DwGANZVw.mjs +1 -0
  24. package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
  25. package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
  26. package/dist/packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs +1 -0
  27. package/dist/packem_shared/LUNORA_IGNORED_PATHS-B0-PPvRp.mjs +19 -0
  28. package/dist/packem_shared/LUNORA_TAG-CiQM3BkI.mjs +1 -0
  29. package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
  30. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-De7gLGIy.mjs +1 -0
  31. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-0QiGKazX.mjs +1 -0
  32. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DioKi8jL.mjs +1 -0
  33. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-Bv07Q3v8.mjs +1 -0
  34. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Dbt0faMd.mjs +1 -0
  35. package/dist/packem_shared/SEED_ENDPOINT-2B56PN_H.mjs +1 -0
  36. package/dist/packem_shared/STUDIO_PATH-BZI8go9A.mjs +1 -0
  37. package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-s6wTR8W1.mjs +1 -0
  38. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
  39. package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
  40. package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
  41. package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
  42. package/dist/packem_shared/applyAdditiveEdit-CH0VhMJ2.mjs +6 -0
  43. package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
  44. package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
  45. package/dist/packem_shared/assertWranglerSatisfiesSchema-BBQ2zkZy.mjs +3 -0
  46. package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
  47. package/dist/packem_shared/buildPackageSecretsBlock-yv9mjKEW.mjs +19 -0
  48. package/dist/packem_shared/celld-config-D-L6uskI.mjs +3 -0
  49. package/dist/packem_shared/classifyPolicyEdit-D8NwrHxR.mjs +24 -0
  50. package/dist/packem_shared/collectExportGaps-qqrrR5x_.mjs +2 -0
  51. package/dist/packem_shared/collectWranglerSecretVariables-D-usPfT8.mjs +1 -0
  52. package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
  53. package/dist/packem_shared/describePreservedCrons-7gaDLxWx.mjs +1 -0
  54. package/dist/packem_shared/detectFramework-CUiVEHDQ.mjs +1 -0
  55. package/dist/packem_shared/discover-info-Vj9d4qYt.mjs +1 -0
  56. package/dist/packem_shared/discoverAgentInfo-CTdCSfYM.mjs +1 -0
  57. package/dist/packem_shared/discoverContainerInfo-EhZtEBQs.mjs +1 -0
  58. package/dist/packem_shared/discoverSchemaInfo-BguahM6z.mjs +1 -0
  59. package/dist/packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs +1 -0
  60. package/dist/packem_shared/infer-bindings-B-BFynp2.mjs +1 -0
  61. package/dist/packem_shared/infer-bindings.d-BH0tk-TR.d.mts +421 -0
  62. package/dist/packem_shared/infer-bindings.d-BH0tk-TR.d.ts +421 -0
  63. package/dist/packem_shared/inferLunoraBindings-CzvNvl9y.mjs +1 -0
  64. package/dist/packem_shared/interpretRemote-C9yJC_ZK.mjs +1 -0
  65. package/dist/packem_shared/lunora-manifest-v90ZUbVp.mjs +6 -0
  66. package/dist/packem_shared/materializeServiceDevConfigs-VcqRp-kv.mjs +1 -0
  67. package/dist/packem_shared/mergeWranglerEnvironment-DXiB-HcS.mjs +1 -0
  68. package/dist/packem_shared/package-secrets-registry-DvtTiK4b.mjs +1 -0
  69. package/dist/packem_shared/parseDevVariable-teAAahVD.mjs +1 -0
  70. package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
  71. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
  72. package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
  73. package/dist/packem_shared/reconcile-services-3dn35zgy.mjs +1 -0
  74. package/dist/packem_shared/reconcileBindingsSafely-BRyb_65W.mjs +1 -0
  75. package/dist/packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs +1 -0
  76. package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
  77. package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
  78. package/dist/packem_shared/runPostCodegenHook-B0T1q2YI.mjs +1 -0
  79. package/dist/packem_shared/serveJsonHandler-Dv0EdCb9.mjs +1 -0
  80. package/dist/packem_shared/startCelldDevSession-BLFsd6jG.mjs +1 -0
  81. package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
  82. package/dist/packem_shared/validate-bindings-DFAcr5wA.mjs +1 -0
  83. package/dist/packem_shared/withTailConsumer-BZqzeKYh.mjs +1 -0
  84. package/dist/packem_shared/worker-entry-checks-9Vdz4d2f.mjs +1 -0
  85. package/dist/packem_shared/wranglerToAlchemy-CBO2ucRm.mjs +6 -0
  86. package/dist/packem_shared/write-atomic-9d9xs5ON.mjs +1 -0
  87. package/dist/studio-host/index.d.mts +314 -110
  88. package/dist/studio-host/index.d.ts +314 -110
  89. package/dist/studio-host/index.mjs +1 -7
  90. package/package.json +17 -7
  91. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  92. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  93. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  94. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CySy5vR_.mjs +0 -62
  95. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-Dd1suoit.mjs +0 -476
  96. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  97. package/dist/packem_shared/buildPackageSecretsBlock-S74dgmwy.mjs +0 -187
  98. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  99. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
  100. package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
  101. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  102. package/dist/packem_shared/discoverSchemaInfo-DWtypqpP.mjs +0 -25
  103. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  104. package/dist/packem_shared/findWranglerFile-DwSuC-Kn.mjs +0 -25
  105. package/dist/packem_shared/formatLunoraEvent-D2fDeGB6.mjs +0 -86
  106. package/dist/packem_shared/handlePolicyScaffoldRequest-CiC2IGKx.mjs +0 -103
  107. package/dist/packem_shared/handleSchemaEditRequest-Df-Wrix-.mjs +0 -99
  108. package/dist/packem_shared/handleSeedRequest-DVCjaGO-.mjs +0 -61
  109. package/dist/packem_shared/inferLunoraBindings-0W3eRdIP.mjs +0 -302
  110. package/dist/packem_shared/injectRemoteFlags-C-WZAKLY.mjs +0 -105
  111. package/dist/packem_shared/interpretRemote-CtcIcB5-.mjs +0 -34
  112. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
  113. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  114. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
  115. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
  116. package/dist/packem_shared/reconcileWranglerBindings-ByJk3yLU.mjs +0 -277
  117. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  118. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
  119. package/dist/packem_shared/studioAssetsStamp-Csk5RS4E.mjs +0 -28
package/dist/index.d.ts CHANGED
@@ -1,82 +1,303 @@
1
- import { ContainerIR, WorkflowIR } from '@lunora/codegen';
2
- export type { ContainerIR, WorkflowIR } from '@lunora/codegen';
3
- import 'ts-morph';
4
- export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-DCmwn7zQ.js";
5
- /**
6
- * Project-relative directory the Lunora agent skills ("rules") install into.
7
- * This is the portable [Agent Skills](https://tanstack.com/intent/latest/docs/registry)
8
- * location — Cursor, Claude Code, and GitHub Copilot all discover skills here.
9
- */
1
+ import { AgentIR, ContainerIR, WorkflowIR, CodegenResult } from '@lunora/codegen';
2
+ export type { AgentIR, ContainerIR, WorkflowIR } from '@lunora/codegen';
3
+ import { ChildProcess } from 'node:child_process';
4
+ import { Writable } from 'node:stream';
5
+ import { T as ToolchainCommand, D as DeployDriver, P as ProjectionPurpose } from "./packem_shared/infer-bindings.d-BH0tk-TR.js";
6
+ export { C as COMPOSED_WORKER_ENTRY, type a as DeployRequest, type b as DevRequest, type c as DiscoverSchemaInfoResult, type d as DriverToolchain, e as GENERATED_CLASS_MODULES, type G as GeneratedClassModule, type f as InferOptions, type g as InferredAgent, type I as InferredBindings, type h as InferredContainer, type i as InferredWorkflow, type j as ProjectedConfig, type S as SchemaInfo, type k as SecretRequest, type l as TailRequest, m as discoverSchemaInfo, n as inferLunoraBindings, p as packageNamesFromBindings } from "./packem_shared/infer-bindings.d-BH0tk-TR.js";
7
+ export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, r as resolveServerModule, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-D2H4_G01.js";
8
+ interface DiscoverAgentInfoResult {
9
+ /** Discovered agent definitions; `[]` when none are declared or parsing failed. */
10
+ agents: ReadonlyArray<AgentIR>;
11
+ /** Parse error message, when `lunora/agents.ts` exists but could not be analyzed. */
12
+ error?: string;
13
+ }
14
+ /**
15
+ * Discover the project's `defineAgent` declarations. Returns `{ agents: [] }`
16
+ * when the project has no `lunora/agents.ts` (not an error), or
17
+ * `{ agents: [], error }` when the file exists but could not be parsed — callers
18
+ * decide whether that is a warning (validator) or ignorable (inference).
19
+ */
20
+ declare const discoverAgentInfo: (projectRoot: string, schemaDirectory: string) => DiscoverAgentInfoResult;
21
+ interface DiscoverContainerInfoResult {
22
+ /** Discovered container definitions; `[]` when none are declared or parsing failed. */
23
+ containers: ReadonlyArray<ContainerIR>;
24
+ /** Parse error message, when `lunora/containers.ts` exists but could not be analyzed. */
25
+ error?: string;
26
+ }
27
+ /**
28
+ * Discover the project's `defineContainer` declarations. Returns
29
+ * `{ containers: [] }` when the project has no `lunora/containers.ts` (not an
30
+ * error), or `{ containers: [], error }` when the file exists but could not be
31
+ * parsed — callers decide whether that is a warning (validator) or ignorable
32
+ * (inference).
33
+ */
34
+ declare const discoverContainerInfo: (projectRoot: string, schemaDirectory: string) => DiscoverContainerInfoResult;
35
+ interface DiscoverWorkflowInfoResult {
36
+ /** Parse error message, when `lunora/workflows.ts` exists but could not be analyzed. */
37
+ error?: string;
38
+ /** Discovered workflow definitions; `[]` when none are declared or parsing failed. */
39
+ workflows: ReadonlyArray<WorkflowIR>;
40
+ }
41
+ /**
42
+ * Discover the project's `defineWorkflow` declarations. Returns
43
+ * `{ workflows: [] }` when the project has no `lunora/workflows.ts` (not an
44
+ * error), or `{ workflows: [], error }` when the file exists but could not be
45
+ * parsed — callers decide whether that is a warning (validator) or ignorable
46
+ * (inference).
47
+ */
48
+ declare const discoverWorkflowInfo: (projectRoot: string, schemaDirectory: string) => DiscoverWorkflowInfoResult;
49
+ /** Minimal env shape — `process.env` structurally, injectable for tests. */
50
+ type EnvLike = Readonly<Record<string, string | undefined>>;
51
+ /** One detected agent: which tool, and which env var gave it away. */
52
+ interface AgentDetection {
53
+ /** Human-readable agent name, for the "agent detected" log line. */
54
+ name: string;
55
+ /** The environment variable that matched. */
56
+ variable: string;
57
+ }
58
+ /** Env var that forces agent mode on (`1`/`true`) or off (`0`/`false`), overriding detection. */
59
+ declare const AGENT_MODE_ENV = "LUNORA_AGENT_MODE";
60
+ /**
61
+ * Detect the AI agent driving this process, or `undefined` when none is.
62
+ * `LUNORA_AGENT_MODE` wins over `@visulima/find-ai-runner`'s marker table in
63
+ * both directions. Pure — pass a custom `env` in tests.
64
+ */
65
+ declare const detectAiAgent: (env?: EnvLike) => AgentDetection | undefined;
66
+ /**
67
+ * Project-relative directory the Lunora agent skills ("rules") install into.
68
+ * This is the portable [Agent Skills](https://tanstack.com/intent/latest/docs/registry)
69
+ * location — Cursor, Claude Code, and GitHub Copilot all discover skills here.
70
+ */
10
71
  declare const AGENT_RULES_DIR = ".agents/skills";
11
72
  /** Env var the once-per-process-tree hint guard ({@link claimAgentRulesHint}) sets. */
12
73
  declare const AGENT_RULES_HINT_ENV = "LUNORA_RULES_HINT_SHOWN";
13
74
  /**
14
- * The Lunora agent skills shipped by `@lunora/cli`. The first entry (`lunora`)
15
- * is the router skill — its presence is what {@link detectAgentRules} treats as
16
- * "rules installed", since every other skill is reachable through it.
17
- */
75
+ * The Lunora agent skills shipped by `@lunora/cli`. The first entry (`lunora`)
76
+ * is the router skill — its presence is what {@link detectAgentRules} treats as
77
+ * "rules installed", since every other skill is reachable through it.
78
+ *
79
+ * `lunora rules install` enumerates `@lunora/cli`'s `skills/` directory rather
80
+ * than reading this list, so a skill missing here still installs — but
81
+ * `lunora rules check` counts against it, and reported "9/9 skills" with an
82
+ * empty "Missing:" line for a project holding all 14. The CLI's rules test
83
+ * pins the two together, since this package cannot see that directory.
84
+ */
18
85
  declare const LUNORA_SKILL_NAMES: ReadonlyArray<string>;
19
86
  /** The router skill whose presence marks the rule set as installed. */
20
87
  declare const ROOT_SKILL_NAME = "lunora";
21
88
  /**
22
- * The single "rules not installed" message shared by every surface (the CLI
23
- * `lunora dev` summary and the Vite dev plugin), so the wording and the
24
- * pointer at `lunora rules install` stay identical wherever it appears.
25
- */
89
+ * The single "rules not installed" message shared by every surface (the CLI
90
+ * `lunora dev` summary and the Vite dev plugin), so the wording and the
91
+ * pointer at `lunora rules install` stay identical wherever it appears.
92
+ */
26
93
  declare const AGENT_RULES_HINT = "Lunora AI rules not installed — run `lunora rules install` so your coding agent knows how to use Lunora.";
27
94
  /**
28
- * Process-tree guard so the hint is emitted at most once. The first surface to
29
- * print it sets {@link AGENT_RULES_HINT_ENV} on `process.env`; later surfaces (a
30
- * Vite dev-server restart, or a child process that inherited the env) read it
31
- * and stay quiet. Returns `true` the first time, `false` afterwards.
32
- */
95
+ * Process-tree guard so the hint is emitted at most once. The first surface to
96
+ * print it sets {@link AGENT_RULES_HINT_ENV} on `process.env`; later surfaces (a
97
+ * Vite dev-server restart, or a child process that inherited the env) read it
98
+ * and stay quiet. Returns `true` the first time, `false` afterwards.
99
+ */
33
100
  declare const claimAgentRulesHint: () => boolean;
34
101
  interface AgentRulesStatus {
35
102
  /**
36
- * True when the `lunora` router skill is installed. We key on the router
37
- * (not "all nine present") so a project that intentionally trims the set
38
- * still counts as installed and isn't nagged.
39
- */
103
+ * True when the `lunora` router skill is installed. We key on the router
104
+ * (not "all nine present") so a project that intentionally trims the set
105
+ * still counts as installed and isn't nagged.
106
+ */
40
107
  readonly installed: boolean;
41
- /** Skill names with no `SKILL.md` under `&lt;root>/.agents/skills/&lt;name>/`. */
108
+ /** Skill names with no `SKILL.md` under `<root>/.agents/skills/<name>/`. */
42
109
  readonly missing: ReadonlyArray<string>;
43
- /** Skill names found under `&lt;root>/.agents/skills/&lt;name>/SKILL.md`. */
110
+ /** Skill names found under `<root>/.agents/skills/<name>/SKILL.md`. */
44
111
  readonly present: ReadonlyArray<string>;
45
112
  }
46
113
  /**
47
- * Detect whether the Lunora agent skills are installed in `projectRoot` by
48
- * checking the skills folder for each `SKILL.md`. Pure filesystem reads, safe to
49
- * call on every dev-server / CLI startup — the CLI, the Vite plugin, and the
50
- * studio host all use it to decide whether to surface the "rules not installed"
51
- * hint.
52
- */
114
+ * Detect whether the Lunora agent skills are installed in `projectRoot` by
115
+ * checking the skills folder for each `SKILL.md`. Pure filesystem reads, safe to
116
+ * call on every dev-server / CLI startup — the CLI, the Vite plugin, and the
117
+ * studio host all use it to decide whether to surface the "rules not installed"
118
+ * hint.
119
+ */
53
120
  declare const detectAgentRules: (projectRoot: string) => AgentRulesStatus;
54
- interface DiscoverContainerInfoResult {
55
- /** Discovered container definitions; `[]` when none are declared or parsing failed. */
56
- containers: ReadonlyArray<ContainerIR>;
57
- /** Parse error message, when `lunora/containers.ts` exists but could not be analyzed. */
58
- error?: string;
121
+ /** Spawns the process — injectable so tests run without the binary. */
122
+ type DevProcessSpawner = (command: string, args: ReadonlyArray<string>, options: {
123
+ cwd: string;
124
+ shell: boolean;
125
+ }) => ChildProcess;
126
+ interface DevProcessOptions {
127
+ args: ReadonlyArray<string>;
128
+ command: string;
129
+ cwd: string;
130
+ /** Names the process in errors, e.g. `wrangler dev`. */
131
+ label: string;
132
+ /** The error when `command` is not on PATH, naming the fix. */
133
+ notFound: string;
134
+ /** One line of output; the remainder after the last newline is flushed when the stream ends. */
135
+ onLine: (line: string, stream: "stderr" | "stdout") => void;
136
+ port: number;
137
+ readyTimeoutMs: number;
138
+ /** Windows `.cmd` shims only launch through a shell. */
139
+ shell?: boolean;
140
+ /** Aborting it stops the process while it is still starting; the start then rejects. */
141
+ signal?: AbortSignal;
142
+ spawn?: DevProcessSpawner;
59
143
  }
144
+ interface DevProcess {
145
+ /** Resolves with the exit code when the process exits without {@link DevProcess.stop} asking it to. */
146
+ crashed: Promise<number>;
147
+ /** Terminate it; resolves once it has exited. */
148
+ stop: () => Promise<void>;
149
+ }
150
+ /** `true` once something accepts a TCP connection on `port`. */
151
+ declare const acceptsConnection: (port: number) => Promise<boolean>;
60
152
  /**
61
- * Discover the project's `defineContainer` declarations. Returns
62
- * `{ containers: [] }` when the project has no `lunora/containers.ts` (not an
63
- * error), or `{ containers: [], error }` when the file exists but could not be
64
- * parsed — callers decide whether that is a warning (validator) or ignorable
65
- * (inference).
66
- */
67
- declare const discoverContainerInfo: (projectRoot: string, schemaDirectory: string) => DiscoverContainerInfoResult;
153
+ * Spawn the process and resolve once it accepts connections on `port`; reject,
154
+ * with the process stopped, when it cannot be spawned, exits first, or misses
155
+ * the deadline. The caller checks the port is free beforehand: the probe cannot
156
+ * tell this process from another one already listening there.
157
+ */
158
+ declare const startDevProcess: (options: DevProcessOptions) => Promise<DevProcess>;
159
+ /**
160
+ * Where a line came from: `celld` (the app, and the session's own notices) or
161
+ * `celld:<worker>`, and `stderr` for a session notice that reports a failure.
162
+ */
163
+ interface CelldLineOrigin {
164
+ stream: "stderr" | "stdout";
165
+ tag: string;
166
+ }
167
+ interface CelldDevSessionOptions {
168
+ /** Prints one non-empty line of the session's output. */
169
+ log: (line: string, origin: CelldLineOrigin) => void;
170
+ /** Port the app serves on. */
171
+ port: number;
172
+ projectRoot: string;
173
+ spawn?: DevProcessSpawner;
174
+ }
175
+ interface CelldDevSession {
176
+ /**
177
+ * Resolves with an exit code once the app is gone without {@link CelldDevSession.stop}
178
+ * asking: its `celld dev` crashed, or did not come back after a restart.
179
+ */
180
+ exited: Promise<number>;
181
+ /** Stop watching, cut short a restart in flight, then stop the app. */
182
+ stop: () => Promise<void>;
183
+ }
184
+ /**
185
+ * Start the session: register every service, run the app, then watch the
186
+ * service folders. Resolves once the app accepts connections; rejects, with
187
+ * nothing left running, when a service or the app cannot start — including an
188
+ * app `celld dev` cannot run at all (a Vite virtual `main`).
189
+ */
190
+ declare const startCelldDevSession: (options: CelldDevSessionOptions) => Promise<CelldDevSession>;
191
+ /**
192
+ * The environment switch that turns codegen off — the other spelling of
193
+ * `lunora dev --no-codegen`.
194
+ *
195
+ * The flag alone could not reach the Vite flavors: there the codegen watch lives
196
+ * in `@lunora/vite`, inside the framework dev server the CLI spawns as a separate
197
+ * process, which re-parses its own argv and never sees it. So the flag travels as
198
+ * this variable, and both the plugin and the CLI's own watcher read it — one
199
+ * switch, one meaning, every flavor.
200
+ *
201
+ * It is a DEV switch. `vite build` ignores it deliberately: skipping generation
202
+ * there would also skip the ERROR-level advisory gate that fails the build.
203
+ *
204
+ * One-directional, like `LUNORA_REMOTE`: it can turn codegen off, nothing turns
205
+ * it back on. Settable by hand for a project that runs its framework dev script
206
+ * directly rather than through `lunora dev`.
207
+ */
208
+ /** Env var that turns codegen off when it spells `0` / `false`. Unset means on. */
209
+ declare const CODEGEN_ENV = "LUNORA_CODEGEN";
210
+ /**
211
+ * Whether a {@link CODEGEN_ENV} value spells an explicit "off".
212
+ *
213
+ * Takes the VALUE, not the environment, mirroring `isRemoteEnvEnabled` in
214
+ * `./cloudflare/remote-bindings` — the same package's existing answer to the same
215
+ * question, with the opposite polarity.
216
+ */
217
+ declare const isCodegenDisabled: (value: string | undefined) => boolean;
218
+ /** Severity a container output line is surfaced at: `stderr` → `error`, `stdout` → `info`. */
219
+ type ContainerLogLevel = "error" | "info";
220
+ /** One declared container to follow, identified by the names codegen lifts from `defineContainer`. */
221
+ interface ContainerLogSource {
222
+ /** Generated Durable Object class name, e.g. `TranscoderContainer`. Wrangler's dev image is `cloudflare-dev/<lowercased>`. */
223
+ className: string;
224
+ /** The `lunora/containers.ts` export name, e.g. `transcoder` — used as the display tag. */
225
+ exportName: string;
226
+ }
227
+ /** A single line of container output handed back to the caller. */
228
+ interface ContainerLogLine {
229
+ /** `"error"` for the container's stderr, `"info"` for its stdout. */
230
+ level: ContainerLogLevel;
231
+ /** The container's export name (`transcoder`), for tagging the line. */
232
+ name: string;
233
+ /** One output line, with the trailing newline (and any `\r`) stripped. */
234
+ text: string;
235
+ }
236
+ interface ContainerLogStreamOptions {
237
+ /** The declared containers to follow. An empty list yields an inert handle. */
238
+ containers: ReadonlyArray<ContainerLogSource>;
239
+ /** Injected Docker client — defaults to a real lazily-imported `dockerode` instance. Tests pass a stub. */
240
+ docker?: DockerLike;
241
+ /** Called once per container output line. */
242
+ onLine: (line: ContainerLogLine) => void;
243
+ /** Called once when the Docker engine can't be reached (re-armed after it recovers). Defaults to silent. */
244
+ onUnavailable?: (message: string) => void;
245
+ /** Poll interval override, in ms. */
246
+ pollIntervalMs?: number;
247
+ }
248
+ /** Handle controlling a running log stream. */
249
+ interface ContainerLogStreamHandle {
250
+ /** Stop polling and tear down every attached log stream. Idempotent. */
251
+ close: () => void;
252
+ }
253
+ /** The minimal structural slice of a `dockerode` log stream this module consumes. */
254
+ interface DockerLogStream {
255
+ destroy: () => void;
256
+ on: (event: "data" | "end" | "error", listener: (chunk?: Buffer) => void) => void;
257
+ }
258
+ /** The minimal structural slice of a `dockerode` instance this module consumes. */
259
+ interface DockerLike {
260
+ getContainer: (id: string) => {
261
+ logs: (options: {
262
+ follow: true;
263
+ stderr: true;
264
+ stdout: true;
265
+ tail: "all";
266
+ timestamps: false;
267
+ }) => Promise<DockerLogStream>;
268
+ };
269
+ listContainers: (options: {
270
+ filters: {
271
+ status: ["running"];
272
+ };
273
+ }) => Promise<{
274
+ Id: string;
275
+ Image: string;
276
+ }[]>;
277
+ modem: {
278
+ demuxStream: (stream: DockerLogStream, stdout: Writable, stderr: Writable) => void;
279
+ };
280
+ }
281
+ /**
282
+ * Follow the local Docker logs of every declared container, emitting each output
283
+ * line through `onLine` tagged with its export name. Polls for containers (they
284
+ * start lazily on first request and may be replaced on restart), attaches once
285
+ * per container id, and drops streams whose container has gone. Returns
286
+ * immediately with a `close()` handle; all work happens asynchronously.
287
+ */
288
+ declare const streamContainerLogs: (options: ContainerLogStreamOptions) => ContainerLogStreamHandle;
68
289
  /**
69
- * The meta-frameworks Lunora can compose with, plus `"none"` for a standalone
70
- * SPA / SSR-less project (the current default). Mirrors PLAN4 §2.4.
71
- */
72
- type DetectedFramework = "astro" | "none" | "nuxt" | "react-router" | "solid-start" | "sveltekit" | "tanstack-start" | "tanstack-start-solid";
73
- /**
74
- * void's class model (PLAN4 §3). Class A is Vite-native and Lunora owns the
75
- * worker entry (`createWorker({ httpRouter })`). Class B frameworks own their own
76
- * Cloudflare adapter, so Lunora injects its worker composition into the
77
- * framework's server entry via hooks (PLAN4 M4). Class C is non-CF / SSR-less —
78
- * ship the client adapter + a standalone Lunora worker (today's default).
79
- */
290
+ * The meta-frameworks Lunora can compose with, plus `"none"` for a standalone
291
+ * SPA / SSR-less project (the current default). Mirrors PLAN4 §2.4.
292
+ */
293
+ type DetectedFramework = "astro" | "none" | "nuxt" | "react-router" | "solid-start" | "sveltekit" | "tanstack-start" | "tanstack-start-solid" | "vinext";
294
+ /**
295
+ * void's class model (PLAN4 §3). Class A is Vite-native and Lunora owns the
296
+ * worker entry (`createWorker({ httpRouter })`). Class B frameworks own their own
297
+ * Cloudflare adapter, so Lunora injects its worker composition into the
298
+ * framework's server entry via hooks (PLAN4 M4). Class C is non-CF / SSR-less —
299
+ * ship the client adapter + a standalone Lunora worker (today's default).
300
+ */
80
301
  type FrameworkClass = "A" | "B" | "C";
81
302
  interface FrameworkDetection {
82
303
  /** void's composition class for the detected framework. */
@@ -85,152 +306,341 @@ interface FrameworkDetection {
85
306
  framework: DetectedFramework;
86
307
  }
87
308
  /**
88
- * Detect which meta-framework a project uses by inspecting its `package.json`
89
- * dependencies, and classify it under void's class-A/B/C model (PLAN4 §3).
90
- *
91
- * Pure and best-effort: never throws. An unknown / missing / malformed
92
- * `package.json` yields `{ framework: "none", class: "C" }` so the standalone
93
- * SPA flow is preserved.
94
- */
309
+ * Read and parse the project `package.json`, returning its merged
310
+ * `dependencies` + `devDependencies` name set (empty on any failure). Public
311
+ * so sibling consumers (e.g. the CLI's Vite-project detection) share one
312
+ * best-effort reader instead of re-parsing `package.json` themselves.
313
+ */
314
+ declare const readProjectDependencyNames: (root: string) => ReadonlySet<string>;
315
+ /**
316
+ * Whether the project depends on the unscoped `lunorash` umbrella rather than
317
+ * the granular `@lunora/*` packages.
318
+ *
319
+ * Every generator that writes an import INTO the user's project has to ask:
320
+ * an umbrella-only install — the default for every starter template — never
321
+ * installs `@lunora/server`, so under pnpm's strict layout a scaffolded
322
+ * `from "@lunora/server"` is unresolvable and the worker stops bundling.
323
+ * Codegen answers the same question from its own dependency set
324
+ * (`dependencies.has("lunorash")`); this is that answer for every consumer
325
+ * that has only a project root.
326
+ */
327
+ declare const projectUsesUmbrella: (root: string) => boolean;
328
+ /**
329
+ * Detect which meta-framework a project uses by inspecting its `package.json`
330
+ * dependencies, and classify it under void's class-A/B/C model (PLAN4 §3).
331
+ *
332
+ * Pure and best-effort: never throws. An unknown / missing / malformed
333
+ * `package.json` yields `{ framework: "none", class: "C" }` so the standalone
334
+ * SPA flow is preserved.
335
+ */
95
336
  declare const detectFramework: (root: string) => FrameworkDetection;
337
+ /** Directory holding per-checkout Lunora state (gitignored by convention). */
338
+ declare const DEV_STATE_DIR = ".lunora";
339
+ /** The dev-server state filename, relative to the project root. */
340
+ declare const DEV_STATE_FILE: string;
341
+ /** Log file a backgrounded dev server's output is captured to, relative to the project root. */
342
+ declare const DEV_LOG_FILE: string;
343
+ /**
344
+ * Where `lunora dev` writes the binding manifest by default, relative to the
345
+ * project root.
346
+ *
347
+ * A fixed path so a supervisor can read it without being told one, and next to
348
+ * the state record because the two are read together: this says what the Worker
349
+ * needs and where it will serve, `dev.json` says whether it is serving yet.
350
+ */
351
+ declare const DEV_BINDINGS_FILE: string;
352
+ /**
353
+ * Marker env `lunora dev --background` sets on the detached server process
354
+ * (the daemon `lunora dev` or `vite dev`), so it records itself as
355
+ * `background: true` — and, for the CLI daemon, never re-detects an agent and
356
+ * recurses into background mode again.
357
+ */
358
+ declare const DEV_DAEMON_ENV = "LUNORA_DEV_DAEMON";
359
+ /** Env carrying the capture-log path into the detached server, recorded in the state file. */
360
+ declare const DEV_LOG_FILE_ENV = "LUNORA_DEV_LOG_FILE";
96
361
  /**
97
- * The `.dev.vars` line grammar — one owner, shared by every reader/writer of the
98
- * file so the format can't drift between packages. `@lunora/cli`'s `env`
99
- * command (parse/serialize) and `@lunora/config`'s scaffolder (comment-
100
- * preserving rewrite) do different *transforms*, but they agree on these
101
- * primitives: the filename, what a `KEY` looks like, how lines split, and how
102
- * quotes strip.
103
- */
362
+ * Env carrying the PID of a parent that holds a *provisional* state record it
363
+ * expects the child dev server to supersede. The CLI claims `.lunora/dev.json`
364
+ * with its own PID before spawning the real server (closing the duplicate-start
365
+ * race for the vite flavor and the wrangler daemon), then hands its PID down
366
+ * via this variable; the child's claim (see {@link claimDevServerState}'s
367
+ * `supersedePid`) may replace exactly that record with the authoritative
368
+ * URL + PID.
369
+ */
370
+ declare const DEV_HANDOFF_ENV = "LUNORA_DEV_HANDOFF_PID";
371
+ /** How the recorded dev server runs. */
372
+ type DevServerMode = "cli" | "vite";
373
+ /** The state record persisted to `.lunora/dev.json`. */
374
+ interface DevServerState {
375
+ /** Whether the server was detached into the background (`lunora dev --background`). */
376
+ background?: boolean;
377
+ /** Absolute path of the log file capturing the server's output, when captured. */
378
+ logFile?: string;
379
+ /** `"cli"` for the `lunora dev` wrangler orchestration, `"vite"` for a Vite dev server. */
380
+ mode: DevServerMode;
381
+ /** PID of the process to signal for shutdown (the orchestrating CLI or the Vite process). */
382
+ pid: number;
383
+ /**
384
+ * ISO-8601 stamp marking when the server at {@link DevServerState.url} was
385
+ * first observed accepting requests — absent until then.
386
+ *
387
+ * The rest of this record exists as soon as the server is STARTING: `url` is
388
+ * the origin it intends to serve on and `pid` is a process that exists, both
389
+ * written before anything is listening. That is enough to find and stop a
390
+ * server, and not enough for a task runner deciding when to start the next
391
+ * thing — which is what this field is for. Poll it rather than sleeping.
392
+ *
393
+ * Deliberately a claim about `url` and nothing else. `lunora dev` observes it
394
+ * by probing; `@lunora/vite` observes it from the listen callback, since its
395
+ * record is only written once Vite has resolved that URL. Both are honest
396
+ * about the one origin this record advertises — neither says anything about a
397
+ * sidecar on another port.
398
+ *
399
+ * Absent forever is a legitimate outcome: a server that never binds, or one
400
+ * slower than the probe was willing to wait. Treat missing as "not ready
401
+ * yet", never as "will never be ready".
402
+ */
403
+ readyAt?: string;
404
+ /** ISO-8601 stamp written at startup, purely informational (drives `status` uptime). */
405
+ startedAt?: string;
406
+ /** The embedded studio server's URL, when it runs. */
407
+ studioUrl?: string;
408
+ /**
409
+ * The public quick-tunnel URL `lunora dev --tunnel` was assigned, once
410
+ * cloudflared reports it — absent without `--tunnel`, before the URL
411
+ * arrives, and after the tunnel closes. Lets a `--background` start and
412
+ * `lunora dev status` show a URL that otherwise only reaches the log.
413
+ */
414
+ tunnelUrl?: string;
415
+ /** The primary URL serving the worker/app. */
416
+ url: string;
417
+ }
418
+ /**
419
+ * True when a process with `pid` is currently alive AND signalable by this
420
+ * user. Signal `0` performs the existence check without delivering anything.
421
+ *
422
+ * `EPERM` ("alive but another user's process") deliberately counts as NOT
423
+ * alive here: every dev server this module tracks was spawned by the current
424
+ * user, so a PID we cannot signal is by definition a recycled PID — treating
425
+ * it as running would wedge the lockfile permanently and aim `dev stop`'s
426
+ * kill escalation at an innocent process.
427
+ */
428
+ declare const isProcessAlive: (pid: number) => boolean;
429
+ /**
430
+ * True when the record's PID verifiably still refers to the dev server that
431
+ * wrote the record — not merely "some process exists with that number".
432
+ * Guards against PID reuse: a server process necessarily starts BEFORE its
433
+ * record is written, so a process that started after `startedAt` (+ skew) is
434
+ * a recycled PID wearing the corpse's number. The start-time check runs only
435
+ * where the platform exposes it (Linux); elsewhere liveness alone decides.
436
+ */
437
+ declare const isRecordedProcessCurrent: (state: DevServerState) => boolean;
438
+ /**
439
+ * Read the state record from `.lunora/dev.json`, or `undefined` when there is
440
+ * no usable record. Best-effort; performs NO liveness check — use
441
+ * {@link readLiveDevServerState} for "is a dev server actually running".
442
+ */
443
+ declare const readDevServerState: (projectRoot: string) => DevServerState | undefined;
444
+ /**
445
+ * Write the state record to `.lunora/dev.json`, creating the `.lunora/`
446
+ * directory when absent. Returns the absolute path written, or `undefined`
447
+ * when the write failed (state is convenience metadata — a read-only checkout
448
+ * must never crash dev startup).
449
+ */
450
+ declare const writeDevServerState: (projectRoot: string, state: DevServerState) => string | undefined;
451
+ /**
452
+ * Merge `patch` into the existing state record, when one exists. Used by the
453
+ * CLI to stamp `background`/`logFile` onto the record the Vite plugin wrote.
454
+ * Returns the merged record, or `undefined` when there was nothing to update.
455
+ *
456
+ * Pass `expectedPid` to patch only while the record still belongs to that
457
+ * process — the counterpart to {@link clearDevServerState}'s guard, and needed
458
+ * by any patch that can land LATE. A readiness stamp is the case in point: this
459
+ * process's server can answer after a newer one has replaced the record, and an
460
+ * unguarded merge would mark that newer server ready on the old one's behalf.
461
+ */
462
+ declare const updateDevServerState: (projectRoot: string, patch: Partial<DevServerState>, options?: {
463
+ expectedPid?: number;
464
+ }) => DevServerState | undefined;
465
+ /**
466
+ * Whether a record reports a server that is accepting requests, as opposed to
467
+ * one that has merely started. Lives here so the CLI's `status`, its JSON
468
+ * output, and any future reader cannot each invent their own answer.
469
+ */
470
+ declare const isDevServerReady: (state: Pick<DevServerState, "readyAt"> | undefined) => boolean;
471
+ /**
472
+ * Remove `.lunora/dev.json`. Idempotent and never throws. When `expectedPid`
473
+ * is given, the file is only removed while it still records that PID — so a
474
+ * shutting-down server can't clobber the record a newer server just wrote.
475
+ */
476
+ declare const clearDevServerState: (projectRoot: string, expectedPid?: number) => void;
477
+ /**
478
+ * The state record of a dev server that is verifiably running right now, or
479
+ * `undefined`. A record whose PID is dead — or recycled onto a different
480
+ * process (see {@link isRecordedProcessCurrent}) — is stale: it is cleared on
481
+ * the spot so subsequent starts don't keep re-reading a corpse.
482
+ */
483
+ declare const readLiveDevServerState: (projectRoot: string) => DevServerState | undefined;
484
+ /** Result of {@link claimDevServerState}: claimed, or lost to the live server already recorded. */
485
+ interface ClaimDevServerStateResult {
486
+ /** The live record that won the race, when `ok` is `false`. */
487
+ existing?: DevServerState;
488
+ /** Whether this process now owns the record. */
489
+ ok: boolean;
490
+ }
491
+ declare const claimDevServerState: (projectRoot: string, state: DevServerState, options?: {
492
+ supersedePid?: number;
493
+ }) => ClaimDevServerStateResult;
104
494
  /** The conventional filename for local Cloudflare dev secrets (gitignored). */
105
495
  declare const DEV_VARS_FILE: string;
106
496
  /** Its committed, secret-free counterpart that scaffolding reads from. */
107
497
  declare const DEV_VARS_EXAMPLE_FILE: string;
108
- /** A bare `KEY` identifier — the part left of `=` in a `.dev.vars` line. */
498
+ /**
499
+ * A bare `KEY` identifier accepted on the **write** path — `lunora env set`,
500
+ * `env unset`, `env generate`, and {@link upsertDevVariableLine}'s line
501
+ * targeting. Deliberately stricter than what the reader accepts: dotenv keys
502
+ * are `[\w.-]+`, but a key we *write* stays a conventional env-var name so it
503
+ * needs no quoting and round-trips through every consumer. Never use this to
504
+ * decide whether a line in an existing file counts — that is the reader's job.
505
+ */
109
506
  declare const DEV_VARS_KEY_PATTERN: RegExp;
110
- /** Splits file content into lines on either newline style. */
111
-
112
- /**
113
- * Parse `.dev.vars` content into its `{ key, value }` entries, in file order,
114
- * with values unquoted and comments/blank/invalid lines dropped. The canonical
115
- * read of the whole file — callers that just want the variables (rather than a
116
- * comment-preserving rewrite) use this instead of hand-rolling the split loop.
117
- */
507
+ /**
508
+ * Parse `.dev.vars` content into its `{ key, value }` entries, in file order.
509
+ *
510
+ * Delegates to dotenv's own `parse()` — the literal function `wrangler dev` /
511
+ * `@cloudflare/vite-plugin` run over this file before handing the variables to
512
+ * the worker. Using the library rather than a compatible reimplementation is
513
+ * the point: every line the worker sees, Lunora reads identically, including
514
+ * `export `-prefixed lines, dotted/dashed keys, `KEY: value` separators,
515
+ * quote stripping (single/double/backtick), `\n`/`\r` expansion inside double
516
+ * quotes, `#` comments ending unquoted values, and multi-line quoted values.
517
+ * Duplicate keys resolve last-wins, at the key's first position — dotenv
518
+ * returns an object, so a repeated key overwrites in place.
519
+ *
520
+ * The canonical read of the whole file: every reader of `.dev.vars` (and of
521
+ * `.dev.vars.example`) goes through here or through {@link
522
+ * parseDevVariableLine} below, so the format cannot drift between packages.
523
+ */
118
524
  declare const parseDevVariableEntries: (content: string) => {
119
525
  key: string;
120
526
  value: string;
121
527
  }[];
122
- interface DiscoverWorkflowInfoResult {
123
- /** Parse error message, when `lunora/workflows.ts` exists but could not be analyzed. */
124
- error?: string;
125
- /** Discovered workflow definitions; `[]` when none are declared or parsing failed. */
126
- workflows: ReadonlyArray<WorkflowIR>;
127
- }
128
528
  /**
129
- * Discover the project's `defineWorkflow` declarations. Returns
130
- * `{ workflows: [] }` when the project has no `lunora/workflows.ts` (not an
131
- * error), or `{ workflows: [], error }` when the file exists but could not be
132
- * parsed — callers decide whether that is a warning (validator) or ignorable
133
- * (inference).
134
- */
135
- declare const discoverWorkflowInfo: (projectRoot: string, schemaDirectory: string) => DiscoverWorkflowInfoResult;
136
- interface DurableObjectSpec {
137
- binding: string;
138
- className: string;
139
- }
529
+ * Escape a runtime string for safe literal interpolation into a `RegExp`
530
+ * source. The one canonical implementation — `@lunora/config`'s own
531
+ * `infer-bindings.ts` (type-only-export detection) and `@lunora/cli`'s `env`
532
+ * command both need this and used to carry their own (functionally
533
+ * identical) copy; grammar this fundamental gets one owner like everything
534
+ * else in this module.
535
+ */
536
+ declare const escapeRegExp: (value: string) => string;
140
537
  /**
141
- * A `defineContainer` declaration plus whether its generated DO class is
142
- * exported by the worker entry. Only exported containers are safe to
143
- * provision — wrangler rejects a `containers[].class_name` (and its Durable
144
- * Object binding) that the worker doesn't export.
145
- */
146
- interface InferredContainer extends ContainerIR {
147
- exported: boolean;
148
- }
538
+ * Surgically upsert a single `KEY="value"` line in raw `.dev.vars` content,
539
+ * leaving every comment, blank line, and untouched entry verbatim. Rebuilding
540
+ * the whole file from the parsed entry map (an earlier approach) silently
541
+ * dropped all `# …` comments and blank lines — including the documentation the
542
+ * registry installer and scaffolder write — and re-quoted lines the user never
543
+ * touched. If the key already has a line it is replaced in place; otherwise the
544
+ * new line is appended with a single trailing newline. Always quotes the value
545
+ * to preserve a whitespace round-trip; callers (`env set`, `env generate --set`,
546
+ * `deploy`'s minted-secret disclosure) reject newline/`"`/`\` up front so the
547
+ * verbatim quote is safe.
548
+ *
549
+ * Duplicate lines for the key are collapsed down to exactly one. The shared
550
+ * read path is last-wins — dotenv overwrites the key as it walks the file — so
551
+ * replacing only the first match would leave a later, untouched duplicate
552
+ * still winning at read time, i.e. a `set` that silently didn't take effect.
553
+ */
554
+ declare const upsertDevVariableLine: (content: string, key: string, value: string) => string;
149
555
  /**
150
- * A `defineWorkflow` declaration plus whether its generated
151
- * `WorkflowEntrypoint` class is exported by the worker entry. Only exported
152
- * workflows are safe to provision — wrangler rejects a `workflows[].class_name`
153
- * the worker doesn't export. Workflows are NOT Durable Objects, so this never
154
- * implies a `durable_objects` binding or migration.
155
- */
156
- interface InferredWorkflow extends WorkflowIR {
157
- exported: boolean;
158
- }
159
- interface InferredBindings {
160
- /** Containers declared in `lunora/containers.ts` (exported or not — see {@link InferredContainer.exported}). */
161
- containers: InferredContainer[];
162
- /** Durable Objects the worker entry exports → safe to bind. */
163
- durableObjects: DurableObjectSpec[];
164
- /** Schema declares a `.global()` table → needs the `DB` D1 binding. */
165
- needsD1: boolean;
166
- /** Human-readable provenance for each inferred binding / hint, for logging. */
167
- signals: string[];
168
- /** `@lunora/ai` is imported or `env.AI` is used → needs the `ai` Workers AI binding. */
169
- usesAi: boolean;
170
- /** `@lunora/analytics` is imported → self-describing `analytics_engine_datasets` binding (auto-writeable). */
171
- usesAnalytics: boolean;
172
- /** `@lunora/auth` is imported (sessions may be D1- or `SessionDO`-backed). */
173
- usesAuth: boolean;
174
- /** `@lunora/browser` is imported → self-describing `browser` binding (auto-writeable). */
175
- usesBrowser: boolean;
176
- /** `@lunora/hyperdrive` is imported (binding needs an un-mintable remote `id`; hint-only). */
177
- usesHyperdrive: boolean;
178
- /** `@lunora/images` is imported → self-describing `images` binding (auto-writeable). */
179
- usesImages: boolean;
180
- /** `@lunora/kv` is imported (namespace binding name + id are user-defined; hint-only). */
181
- usesKv: boolean;
182
- /** `@lunora/mail` is imported (Resend API key must be set in `.dev.vars`; no binding). */
183
- usesMail: boolean;
184
- /** `@lunora/payment` is imported (provider secrets must be set in `.dev.vars`; no binding). */
185
- usesPayment: boolean;
186
- /** `@lunora/pipelines` is imported (binding needs an un-mintable remote pipeline name; hint-only). */
187
- usesPipelines: boolean;
188
- /** `@lunora/scheduler` is imported. */
189
- usesScheduler: boolean;
190
- /** `@lunora/storage` is imported (R2 bucket binding name is user-defined). */
191
- usesStorage: boolean;
192
- /** Workflows declared in `lunora/workflows.ts` (exported or not — see {@link InferredWorkflow.exported}). */
193
- workflows: InferredWorkflow[];
194
- }
195
- interface InferOptions {
196
- projectRoot: string;
197
- /** Directories (relative to root) to scan. Defaults to `lunora` + `src`. */
198
- scanDirs?: ReadonlyArray<string>;
199
- /** Lunora source directory holding `schema.ts`. Defaults to `lunora`. */
200
- schemaDir?: string;
556
+ * Surgically remove every `.dev.vars` line defining `key` (and its own line
557
+ * terminator), preserving all other lines, comments, and blanks verbatim.
558
+ * Backs `lunora env unset`.
559
+ */
560
+ declare const removeDevVariableLine: (content: string, key: string) => string;
561
+ /**
562
+ * Worker env var the dev tooling sets so the Lunora runtime recognises a
563
+ * development deployment (`@lunora/do`'s `isDevEnvironment`) and therefore
564
+ * streams every RPC dispatch summary to the terminal, keeps argument/error
565
+ * detail unredacted, and runs the studio security audit with `dev: true`.
566
+ */
567
+ declare const DEV_WORKER_ENV_VAR = "WORKER_ENV";
568
+ /** The value that flags a dev deployment. */
569
+ declare const DEV_WORKER_ENV_VALUE = "development";
570
+ /**
571
+ * Top up `.dev.vars` with the dev-environment flag unless the project already
572
+ * declares it (in `.dev.vars` itself, or in the wrangler config's `vars`).
573
+ */
574
+ declare const ensureDevWorkerEnv: (projectRoot: string, info: (message: string) => void) => void;
575
+ /** The default deploy target — today's behavior for every project. */
576
+ declare const DEFAULT_DEPLOY_TARGET = "cloudflare";
577
+ /** The ids a caller may select, for error messages and `--target` help text. */
578
+ declare const deployTargetIds: () => ReadonlyArray<string>;
579
+ /**
580
+ * Resolve a target name to its driver.
581
+ * @throws when `target` names no registered driver — never falls back to the default.
582
+ */
583
+ declare const resolveDeployDriver: (target?: string) => DeployDriver;
584
+ /**
585
+ * Whether `target`'s driver ships a `toolchain` — i.e. whether any tool can
586
+ * actually build, serve or deploy it, as opposed to merely generate for it.
587
+ *
588
+ * One predicate rather than one per caller: the CLI (`deploy`, `dev`) and the
589
+ * Vite plugin (`build`, `dev`) must refuse the same set, and a second copy
590
+ * fails silently — the tool that forgot runs the WRONG pipeline for the target
591
+ * instead of rejecting it.
592
+ * @param target A target id already resolved by `resolveTargetOrThrow`. Unknown
593
+ * ids answer `false` rather than throwing, so this is safe to ask about
594
+ * arbitrary input.
595
+ * @returns `true` when the target can be run.
596
+ */
597
+ declare const isRunnableTarget: (target: string) => boolean;
598
+ /**
599
+ * The subset of {@link deployTargetIds} that {@link isRunnableTarget} accepts,
600
+ * in the same (alphabetical) order.
601
+ * @returns every target id a tool can build, serve or deploy — used to name the
602
+ * alternatives when one is refused.
603
+ */
604
+ declare const runnableTargetIds: () => ReadonlyArray<string>;
605
+ /**
606
+ * Whether `lunora dev` serves `target`'s worker with the host's own dev server
607
+ * (`DriverToolchain.devServer === "own"`) instead of workerd. The CLI's flavor
608
+ * choice and the Vite plugin's warning both ask this, so it is answered once.
609
+ */
610
+ declare const targetRunsOwnDevServer: (target: string) => boolean;
611
+ /** A toolchain command planned against the driver's config projection, with nothing written yet. */
612
+ interface ToolchainInvocation {
613
+ command: ToolchainCommand;
614
+ /** Write the projection, if the driver has one. Call only once the command is going to run. */
615
+ commit: () => void;
616
+ /** The projection the command reads, and every key it left out — `undefined` when the host reads the project config as-is. */
617
+ projection: {
618
+ configPath: string;
619
+ dropped: ReadonlyArray<string>;
620
+ } | undefined;
201
621
  }
202
622
  /**
203
- * Scan a Lunora project and report which Cloudflare bindings its code implies.
204
- * Read-only: performs no writes. Binding provisioning is driven by the worker
205
- * entry's Durable Object exports plus the schema's D1 need; capability imports
206
- * surface as hints.
207
- */
208
- declare const inferLunoraBindings: (options: InferOptions) => Promise<InferredBindings>;
209
- /**
210
- * Derive the list of `@lunora/*` package names that are actively used by a
211
- * project, based on its already-resolved {@link InferredBindings}.
212
- *
213
- * This is the canonical bridge between binding inference and the package-aware
214
- * `.dev.vars.example` scaffolding in `scaffold-dev-variables.ts`. The result is
215
- * a stable, predictable slice of {@link CAPABILITY_SOURCES} source values,
216
- * filtered to the flags that are `true` in `bindings` — in CAPABILITY_SOURCES
217
- * declaration order.
218
- */
219
- declare const packageNamesFromBindings: (bindings: InferredBindings) => string[];
623
+ * Plan a toolchain call in the one safe order: project the config (in memory),
624
+ * build the argv against the projection's path — which is where a host refuses
625
+ * an option it cannot honour, so a refusal throws here — and only then offer the
626
+ * write. A refused command therefore leaves nothing on disk, and `configPath`
627
+ * is set on every request whose driver projects.
628
+ */
629
+ declare const planToolchainInvocation: (driver: DeployDriver, projectRoot: string, purpose: ProjectionPurpose, build: (configPath: string | undefined) => ToolchainCommand) => ToolchainInvocation;
220
630
  /** Directory holding per-checkout Lunora state (gitignored by convention). */
221
631
  declare const LINKED_PROJECT_DIR = ".lunora";
222
632
  /** The canonical link filename, relative to the project root. */
223
633
  declare const LINKED_PROJECT_FILE: string;
224
634
  /**
225
- * The link record persisted to `.lunora/project.json`. Every field is optional
226
- * so a partially-populated link (e.g. a worker name with no URL yet) still
227
- * round-trips. `linkedAt` is an ISO-8601 stamp written at link time, purely
228
- * informational.
229
- */
635
+ * The link record persisted to `.lunora/project.json`. Every field is optional
636
+ * so a partially-populated link (e.g. a worker name with no URL yet) still
637
+ * round-trips. `linkedAt` is an ISO-8601 stamp written at link time, purely
638
+ * informational.
639
+ */
230
640
  interface LinkedProject {
231
641
  /** Cloudflare account id the worker lives under, when known. */
232
642
  account?: string;
233
- /** Cloudflare environment name (`wrangler … --env &lt;env>`), when scoped. */
643
+ /** Cloudflare environment name (`wrangler … --env <env>`), when scoped. */
234
644
  env?: string;
235
645
  /** ISO-8601 timestamp recorded when the link was written. */
236
646
  linkedAt?: string;
@@ -240,34 +650,112 @@ interface LinkedProject {
240
650
  workerUrl?: string;
241
651
  }
242
652
  /**
243
- * Read the link record from `.lunora/project.json`, or `undefined` when there
244
- * is no usable link. Best-effort: a missing file, parse error, or unexpected
245
- * shape all collapse to `undefined`.
246
- */
653
+ * Read the link record from `.lunora/project.json`, or `undefined` when there
654
+ * is no usable link. Best-effort: a missing file, parse error, or unexpected
655
+ * shape all collapse to `undefined`.
656
+ */
247
657
  declare const readLinkedProject: (projectRoot: string) => LinkedProject | undefined;
248
658
  /**
249
- * Write the link record to `.lunora/project.json`, creating the `.lunora/`
250
- * directory when absent. Only defined fields are persisted (so an empty value
251
- * never clobbers a known one). Returns the absolute path written.
252
- */
659
+ * Write the link record to `.lunora/project.json`, creating the `.lunora/`
660
+ * directory when absent. Only defined fields are persisted (so an empty value
661
+ * never clobbers a known one). Returns the absolute path written.
662
+ */
253
663
  declare const writeLinkedProject: (projectRoot: string, link: LinkedProject) => string;
254
664
  /**
255
- * Shared formatter for the structured log events the Lunora runtime emits to the
256
- * worker's `console` during development. Both the CLI `dev` command and the Vite
257
- * plugin pipe worker output through `formatLunoraEvent` so a developer sees
258
- * attributed, readable lines instead of raw JSON.
259
- *
260
- * The runtime emits two event shapes, each a single `console` line tagged
261
- * `source: "lunora"` (see `@lunora/do`'s `request-log.ts`): a `type: "log"`
262
- * event per `ctx.log.*` call, and a `type: "request"` event per RPC dispatch
263
- * (opt-in for successful calls, always for errors).
264
- *
265
- * This module is intentionally dependency-free and colour-free: it returns the
266
- * severity plus a plain display string, leaving ANSI/level colouring to each
267
- * caller (the CLI routes through its `pail` logger; the Vite plugin dims inline).
268
- * Any line that is not a lunora event returns `undefined`, signalling the caller
269
- * to pass it through unchanged.
270
- */
665
+ * The generated and derived paths a linter or formatter should skip, in
666
+ * gitignore syntax relative to the project root.
667
+ *
668
+ * Committed-on-purpose entries are in here too, deliberately: being tracked by
669
+ * git says nothing about whether a human should be asked to reformat it.
670
+ */
671
+ declare const LUNORA_IGNORED_PATHS: ReadonlyArray<string>;
672
+ /** A linter or formatter this module knows how to configure. */
673
+ type LintTool = "biome" | "eslint" | "oxlint" | "prettier";
674
+ /**
675
+ * What happened to one tool's configuration.
676
+ *
677
+ * `"manual"` is not a failure — it means the change is correct but not safe to
678
+ * make automatically, and {@link LintIgnoreOutcome.snippet} carries what to
679
+ * paste. `"failed"` IS a failure, but only of this step: the command that
680
+ * triggered it had already done its real work, so it is reported rather than
681
+ * thrown.
682
+ */
683
+ type LintIgnoreStatus = "created" | "failed" | "manual" | "unchanged" | "updated";
684
+ interface LintIgnoreOutcome {
685
+ /** For `"failed"`: why the writer could not run. The command itself still succeeded. */
686
+ message?: string;
687
+ /** Config file that was written, or the one the user must edit for `"manual"`. */
688
+ path: string;
689
+ /** For `"manual"`: the exact text to add. */
690
+ snippet?: string;
691
+ status: LintIgnoreStatus;
692
+ tool: LintTool;
693
+ }
694
+ /**
695
+ * Which linters/formatters this project already uses, by declared dependency or
696
+ * config file on disk.
697
+ *
698
+ * Both signals matter: a dependency without a config is a tool about to be
699
+ * configured, and a config without a dependency is a tool installed globally or
700
+ * hoisted from a monorepo root. Missing either one means silently skipping a
701
+ * tool the project genuinely runs.
702
+ */
703
+ declare const detectLintTools: (projectRoot: string) => LintTool[];
704
+ /**
705
+ * Add {@link LUNORA_IGNORED_PATHS} to each tool's configuration.
706
+ *
707
+ * Idempotent: every writer appends only what is missing, so re-running after a
708
+ * `lunora add` neither duplicates entries nor disturbs a project's own rules.
709
+ * @param projectRoot The project to configure.
710
+ * @param tools Which tools to configure — normally {@link detectLintTools}'s result, or the user's selection at `init`.
711
+ * @returns one outcome per tool, in the order given.
712
+ */
713
+ declare const applyLintIgnores: (projectRoot: string, tools: ReadonlyArray<LintTool>) => LintIgnoreOutcome[];
714
+ /** The painted ` lunora ` badge, prepended to the plugin's branded log lines. */
715
+ declare const LUNORA_TAG: string;
716
+ /** Prefix a message with the Lunora badge (e.g. `lunoraLine("codegen done")`). */
717
+ declare const lunoraLine: (message: string) => string;
718
+ /**
719
+ * A branded schema-advisory line: the level-coloured badge (`warn`/`error`/`info`)
720
+ * — same badges the CLI reporter uses, so the dev server reads as one tool — then
721
+ * the rule name, the detail, and the remediation. Replaces the old dense
722
+ * `lunora-badge … schema advisory [WARN] …` line with the level-appropriate badge.
723
+ */
724
+ declare const advisoryLine: (level: "ERROR" | "INFO" | "WARN", name: string, detail: string, remediation: string) => string;
725
+ /** The three channels a bundler plugin reports through; `console` satisfies it, as does Rspack's `Logger`. */
726
+ interface FindingLogger {
727
+ error: (message: string) => void;
728
+ warn: (message: string) => void;
729
+ }
730
+ /**
731
+ * Print every schema advisory and platform-portability diagnostic a codegen run
732
+ * produced, each on its own level-appropriate channel.
733
+ *
734
+ * Codegen returns these without printing — each caller presents them through its
735
+ * own channel. Both bundler plugins present them identically, so this is that one
736
+ * presentation: severity → logger method, rendered by {@link advisoryLine}. It
737
+ * lives here rather than in either plugin because the loops were copied verbatim
738
+ * between them, and a copy is how `vite build` and `rspack build` start
739
+ * disagreeing about what a schema problem looks like.
740
+ *
741
+ * Reporting only — {@link blockingFindingsMessage} decides what BLOCKS.
742
+ */
743
+ declare const reportCodegenFindings: (result: Pick<CodegenResult, "advisories" | "platformDiagnostics">, logger: FindingLogger) => void;
744
+ /**
745
+ * The one aggregated line a bundler plugin fails a production build with, or
746
+ * `undefined` when nothing is ERROR-level.
747
+ *
748
+ * An ERROR advisory says a call throws at runtime; an `error` platform
749
+ * diagnostic says the emitted surface does not match the declared target. Both
750
+ * are wrong output, not style, so `vite build` / `rspack build` / `lunora deploy`
751
+ * all refuse them.
752
+ *
753
+ * The filter+dedup+sort behind it stays in `@lunora/codegen` (shared with the CLI
754
+ * gates); only the wording and the fold of the two categories live here, which is
755
+ * presentation — and presentation is what this module owns, which is also why
756
+ * this needs no `tag` parameter: {@link LUNORA_TAG} is right above it.
757
+ */
758
+ declare const blockingFindingsMessage: (result: Pick<CodegenResult, "advisories" | "platformDiagnostics">) => string | undefined;
271
759
  /** Severity a formatted line should be surfaced at, mapped onto the three logger channels. */
272
760
  type LunoraLineLevel = "error" | "info" | "warn";
273
761
  /** A formatted lunora event: the channel to surface it on, the display text, and which event produced it. */
@@ -282,39 +770,95 @@ interface LunoraFormattedLine {
282
770
  /** Stable `source` tag every lunora console event carries. Mirrors `REQUEST_LOG_EVENT_SOURCE` in `@lunora/do`. */
283
771
  declare const LUNORA_EVENT_SOURCE = "lunora";
284
772
  /**
285
- * Parse a single worker-output line and, when it is a lunora structured event,
286
- * return its severity plus display text. Returns `undefined` for anything else —
287
- * non-JSON lines, JSON that isn't a lunora event, or an unrecognised event type
288
- * — so the caller passes the original line through untouched. Pure and total.
289
- */
773
+ * Parse a single worker-output line and, when it is a lunora structured event,
774
+ * return its severity plus display text. Returns `undefined` for anything else —
775
+ * non-JSON lines, JSON that isn't a lunora event, or an unrecognised event type
776
+ * — so the caller passes the original line through untouched. Pure and total.
777
+ */
290
778
  declare const formatLunoraEvent: (line: string) => LunoraFormattedLine | undefined;
779
+ declare class LunoraReporter {
780
+ #private;
781
+ setStdout(stdout: NodeJS.WriteStream): void;
782
+ setStderr(stderr: NodeJS.WriteStream): void;
783
+ log(meta: unknown): void;
784
+ }
785
+ type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
786
+ /** True when `manager` is on PATH — probed by running `<manager> --version`. Injectable for tests. */
787
+ type PackageManagerProbe = (manager: PackageManager) => boolean;
788
+ /**
789
+ * The package managers actually installed on this machine, in preference order
790
+ * ({@link INSTALL_PREFERENCE} — pnpm > bun > yarn > npm). The first entry is the
791
+ * recommended default for the install prompt; the whole list is what the user
792
+ * picks from. Empty when none are found.
793
+ */
794
+ declare const detectInstalledManagers: (probe?: PackageManagerProbe) => PackageManager[];
795
+ /** The argv that installs a project's dependencies with `manager` (`<manager> install`). */
796
+ declare const installArgsFor: (manager: PackageManager) => {
797
+ args: string[];
798
+ command: string;
799
+ };
800
+ /**
801
+ * The argv that adds `packages` as new dependencies with `manager` — the
802
+ * counterpart to {@link installArgsFor}, which reinstalls what package.json
803
+ * already declares rather than adding something new to it.
804
+ *
805
+ * npm's dev flag is `--save-dev` (its own docs lead with the long form); bun's
806
+ * is the lowercase `-d` (uppercase `-D` is not one of its recognized flags);
807
+ * pnpm and yarn both take `-D`.
808
+ */
809
+ declare const addArgsFor: (manager: PackageManager, packages: ReadonlyArray<string>, options?: {
810
+ dev?: boolean;
811
+ }) => {
812
+ args: string[];
813
+ command: string;
814
+ };
815
+ /**
816
+ * Resolve the package manager to drive for the project rooted at (or above)
817
+ * `startDirectory`. Every step is a real signal — Lunora never blindly assumes a
818
+ * particular manager, and there is no hardcoded fallback:
819
+ *
820
+ * 1. `@visulima/package` — the nearest lock file (`pnpm-lock.yaml`, `yarn.lock`,
821
+ * `package-lock.json`, `bun.lockb`) or the `packageManager` field of the nearest
822
+ * `package.json`.
823
+ * 2. The manager that launched this CLI, read from `npm_config_user_agent` (so
824
+ * `pnpm dlx lunora …` / `npx lunora …` resolve to the right manager).
825
+ * 3. The first package manager actually installed on this machine
826
+ * ({@link detectInstalledManagers}).
827
+ *
828
+ * Throws when none of those resolve — i.e. there is no lock file / `packageManager`
829
+ * field, the CLI wasn't launched by a known manager, and none is on `PATH`.
830
+ * Surfacing that is better than silently guessing a manager that can't run.
831
+ */
832
+ declare const detectPackageManager: (startDirectory: string) => PackageManager;
833
+ /** Map a package manager to the argv pair that runs an installed CLI. */
834
+ declare const execArgsFor: (manager: PackageManager, command: string, args: ReadonlyArray<string>) => {
835
+ args: string[];
836
+ command: string;
837
+ };
291
838
  /**
292
- * Per-package secret-requirements registry for `.dev.vars` scaffolding.
293
- *
294
- * Each entry maps a `@lunora/*` package name → the secrets it requires at
295
- * runtime, expressed as `{ key, description, docsUrl }` records. The scaffolder
296
- * in {@link ./scaffold-dev-variables} reads this registry to emit package-aware
297
- * `.dev.vars.example` entries (placeholders + inline doc-pointer comments).
298
- *
299
- * ## Adding a new add-on
300
- *
301
- * When a new `@lunora/*` package requires runtime secrets, add one entry to
302
- * {@link PACKAGE_SECRETS_REGISTRY} keyed by its exact npm package name. Each
303
- * `SecretEntry` in the array needs:
304
- *
305
- * - `key` — the env-var name the package reads from `env` (e.g. `RESEND_API_KEY`).
306
- * - `description` — one line describing the secret and how to obtain it.
307
- * - `docsUrl` — a stable URL to the package/provider docs.
308
- *
309
- * The registry lives in `@lunora/config` so that add-ons themselves never need
310
- * to depend on it (no circular coupling). Add-ons document their secrets in
311
- * their own READMEs; the registry duplicates that knowledge in a machine-readable
312
- * form that the scaffolder can consume.
313
- *
314
- * **Never write a real secret value** in this file — `placeholderValue` entries
315
- * are the only allowed values (they must pass `isPlaceholderValue` from
316
- * scaffold-dev-variables).
317
- */
839
+ * The argv that runs a driver's {@link ToolchainCommand}: through the package
840
+ * manager for a project dependency, directly for a binary on `PATH`.
841
+ */
842
+ declare const toolchainExecArgs: (manager: PackageManager, command: ToolchainCommand) => {
843
+ args: string[];
844
+ command: string;
845
+ };
846
+ /**
847
+ * The argv that runs a project SCRIPT with `manager` — the counterpart to
848
+ * {@link execArgsFor}, which runs a BINARY.
849
+ *
850
+ * All four managers accept `<manager> run <script>`, so this is uniform. It is a
851
+ * separate function because reaching for `execArgsFor(manager, "run", [script])`
852
+ * silently produces something else entirely: `pnpm exec run <script>` fails with
853
+ * `Command "run" not found`, and `npx -- run <script>` resolves the registry
854
+ * PACKAGE named `run` and executes it.
855
+ */
856
+ declare const runScriptArgsFor: (manager: PackageManager, script: string) => {
857
+ args: string[];
858
+ command: string;
859
+ };
860
+ /** The shell command that runs a project script with `manager` (`pnpm dev`, `npm run dev`, …). */
861
+ declare const runScriptCommand: (manager: PackageManager, script: string) => string;
318
862
  /** A single secret variable required by a package. */
319
863
  interface SecretEntry {
320
864
  /** One sentence describing what this secret is and how to obtain it. */
@@ -324,87 +868,171 @@ interface SecretEntry {
324
868
  /** The env-var key as it appears in `.dev.vars`, e.g. `AUTH_SECRET`. */
325
869
  key: string;
326
870
  /**
327
- * The placeholder value written into `.dev.vars.example`.
328
- * Must pass `isPlaceholderValue` from scaffold-dev-variables so the
329
- * scaffolder regenerates it when generating `.dev.vars`. Use angle-bracket
330
- * conventions or a recognised marker like `replace-with-openssl-rand-hex-32`.
331
- * Non-secret env-vars (e.g. `AUTH_URL`) may carry a real default value.
332
- */
871
+ * The placeholder value written into `.dev.vars.example`.
872
+ * Must pass `isPlaceholderValue` from scaffold-dev-variables so the
873
+ * scaffolder regenerates it when generating `.dev.vars`. Use angle-bracket
874
+ * conventions or a recognised marker like `replace-with-openssl-rand-hex-32`.
875
+ * Non-secret env-vars (e.g. `AUTH_URL`) may carry a real default value.
876
+ */
333
877
  placeholderValue: string;
334
878
  }
335
879
  /**
336
- * The canonical registry of per-package secret requirements.
337
- *
338
- * Keys are exact npm package names (e.g. `"@lunora/auth"`). Values are
339
- * non-empty arrays of {@link SecretEntry} — one entry per required secret key.
340
- *
341
- * The scaffolder in `scaffold-dev-variables.ts` calls
342
- * {@link secretsForPackages} to resolve the applicable entries from this map
343
- * given the set of detected capability package names.
344
- */
880
+ * The canonical registry of per-package secret requirements.
881
+ *
882
+ * Keys are exact npm package names (e.g. `"@lunora/auth"`). Values are
883
+ * non-empty arrays of {@link SecretEntry} — one entry per required secret key.
884
+ *
885
+ * The scaffolder in `scaffold-dev-variables.ts` calls
886
+ * {@link secretsForPackages} to resolve the applicable entries from this map
887
+ * given the set of detected capability package names.
888
+ */
345
889
  declare const PACKAGE_SECRETS_REGISTRY: Readonly<Record<string, ReadonlyArray<SecretEntry>>>;
346
- /**
347
- * Collect all secret entries required by the given set of package names. The
348
- * order follows the order of `packageNames` (stable, predictable output), and
349
- * within each package the entries are returned in registry declaration order.
350
- *
351
- * Only packages present in {@link PACKAGE_SECRETS_REGISTRY} contribute entries;
352
- * unknown package names are silently ignored — this makes the call site resilient
353
- * to future capability flags whose packages have no secrets.
354
- */
355
890
  declare const secretsForPackages: (packageNames: ReadonlyArray<string>) => SecretEntry[];
356
- /** The canonical project-config filename probed at the project root. */
357
- declare const LUNORA_CONFIG_FILE = "lunora.json";
358
- /**
359
- * The parsed `remote` preference from `lunora.json`:
360
- *
361
- * - `true` / `false` — the boolean form: enable or explicitly disable remote dev.
362
- * - `undefined` — no usable preference (file absent, key absent, or malformed).
363
- *
364
- * The object form (scoping which binding kinds go remote) is reserved for a
365
- * future increment; for now an object value is treated as "enabled" (truthy
366
- * presence) so forward-written configs still turn remote on.
367
- */
368
- type RemotePreference = boolean | undefined;
369
- /** The structural slice of `lunora.json` Lunora reads. */
370
- interface LunoraProjectConfig {
371
- remote?: unknown;
891
+ /**
892
+ * The two channels this needs from a caller's logger. Deliberately structural
893
+ * and this small: the CLI's `Logger`, Vite's `server.config.logger` shim, and a
894
+ * two-line test double all satisfy it without any of them being imported here.
895
+ */
896
+ interface HookLogger {
897
+ error: (message: string) => void;
898
+ info: (message: string) => void;
899
+ }
900
+ /** What a spawner is handed. A superset-accepting spawner (the CLI's) satisfies this. */
901
+ interface HookSpawnDescriptor {
902
+ args: ReadonlyArray<string>;
903
+ command: string;
904
+ cwd?: string;
905
+ /**
906
+ * Route the child's stdout to the parent's stderr (fd 2). Set whenever the
907
+ * caller's own stdout is a machine-readable stream — `--format json`, or
908
+ * `lunora dev`'s NDJSON — since a `postcodegen` script that prints anything
909
+ * would otherwise interleave with and corrupt it.
910
+ */
911
+ stdoutToStderr?: boolean;
912
+ }
913
+ /** Run a child process and resolve with its exit code. Injectable so tests need no subprocess. */
914
+ type HookSpawner = (descriptor: HookSpawnDescriptor) => Promise<{
915
+ code: number;
916
+ }>;
917
+ interface PostCodegenHookResult {
918
+ /**
919
+ * The hook's failure message, when it ran and did not succeed.
920
+ *
921
+ * Already logged by the time a caller sees it — read it only to decide
922
+ * whether to ABORT, and to carry into a structured result. Logging it again
923
+ * double-reports.
924
+ */
925
+ error?: string;
926
+ /** True when a `postcodegen` script existed and was invoked. */
927
+ ran: boolean;
372
928
  }
373
929
  /**
374
- * Interpret a raw `remote` value into a tri-state preference. A boolean passes
375
- * through; an object is treated as enabled (the documented-but-not-yet-honored
376
- * scoping form is still an opt-in); anything else (string, number, null) is no
377
- * preference.
378
- */
930
+ * Run the project's `postcodegen` script, if it declares one.
931
+ *
932
+ * A failure is reported here and returned rather than thrown, so every caller
933
+ * gets identical reporting and is left with only the decision that actually
934
+ * differs between them: whether it blocks. `deploy` and `prepare` must abort —
935
+ * the whole point is not shipping output the project considers unfinished —
936
+ * while a dev watch loop must not, since the next edit is the chance to fix it.
937
+ *
938
+ * Reporting used to be the caller's job, and all three copied the same
939
+ * `logger.error(result.error)` line. That made "was this surfaced?" a convention
940
+ * rather than a guarantee, and a fourth caller had no way to know it owed one.
941
+ * @returns whether the hook ran, and its (already-logged) error message when it failed.
942
+ */
943
+ declare const runPostCodegenHook: (options: {
944
+ cwd: string;
945
+ logger: HookLogger;
946
+ spawner?: HookSpawner;
947
+ /** See {@link HookSpawnDescriptor.stdoutToStderr}. */
948
+ stdoutToStderr?: boolean;
949
+ }) => Promise<PostCodegenHookResult>;
950
+ /**
951
+ * The parsed `remote` preference from `lunora.config.*`:
952
+ *
953
+ * - `true` / `false` — the boolean form: enable or explicitly disable remote dev.
954
+ * - `undefined` — no usable preference (file absent, key absent, or malformed).
955
+ *
956
+ * The object form (scoping which binding kinds go remote) is reserved for a
957
+ * future increment; for now an object value is treated as "enabled" (truthy
958
+ * presence) so forward-written configs still turn remote on.
959
+ */
960
+ type RemotePreference = boolean | undefined;
961
+ /**
962
+ * Interpret a raw `remote` value into a tri-state preference. A boolean passes
963
+ * through; an object is treated as enabled (the documented-but-not-yet-honored
964
+ * scoping form is still an opt-in); anything else (string, number, null) is no
965
+ * preference.
966
+ */
379
967
  declare const interpretRemote: (value: unknown) => RemotePreference;
380
968
  /**
381
- * Read the project's `remote` preference from `lunora.json`, or `undefined` when
382
- * there's no usable preference. Best-effort: never throws — a missing file,
383
- * parse error, or unexpected shape all collapse to `undefined` so the caller
384
- * falls through to the env/flag layers.
385
- */
969
+ * Read the project's `remote` preference, or `undefined` when there is no
970
+ * usable one — the caller then falls through to the env/flag layers.
971
+ */
386
972
  declare const readProjectRemotePreference: (projectRoot: string) => RemotePreference;
387
973
  /**
388
- * Whether we can interactively prompt — stdin must be a TTY. In CI / piped
389
- * contexts this is false, and callers should fall back to a non-interactive
390
- * default (skip, or require an explicit `--yes`) rather than hang on a read.
391
- */
974
+ * Read the project's deploy `target` from `lunora.config.*`, or `undefined` when
975
+ * absent.
976
+ *
977
+ * Delegates to `@lunora/codegen` rather than re-reading the file here.
978
+ * `runCodegen` has to resolve the same key without this package (config
979
+ * depends on codegen, not the reverse), so the parser lives there and this is a
980
+ * re-export — two readers of one key is exactly the kind of copy that drifts.
981
+ */
982
+ declare const readProjectTarget: (projectRoot: string) => string | undefined;
983
+ /**
984
+ * Resolve the deploy target for a command: an explicit `--target` wins, then
985
+ * `lunora.config.*`, then the registry default.
986
+ *
987
+ * **This is the canonical resolution point, and the reason it is one place.**
988
+ * Codegen tailors the emitted `ctx.*` surface to a target while deploy picks
989
+ * the driver that ships it. Resolve those separately and they can disagree,
990
+ * producing an app that builds cleanly and fails at runtime with nothing in the
991
+ * build to explain it. Every caller — CLI commands, the Vite plugin,
992
+ * `runCodegen`'s own fallback — resolves through here or through
993
+ * {@link resolveTargetOrThrow}, so there is exactly one precedence order to
994
+ * reason about.
995
+ */
996
+ declare const resolveProjectTarget: (projectRoot: string, explicit?: string) => string;
997
+ /**
998
+ * Resolve the deploy target as {@link resolveProjectTarget} does, then reject
999
+ * one that no registered driver serves.
1000
+ *
1001
+ * Lives here rather than in `@lunora/cli` because nothing about it is
1002
+ * CLI-shaped and the Vite plugin needs the same guard — a validator only the
1003
+ * CLI could reach left `vite build` emitting the default surface for a
1004
+ * mis-declared target, silently.
1005
+ *
1006
+ * Callers that go on to resolve a driver get this for free; the ones that never
1007
+ * look a driver up — codegen, the Vite plugin — need it, because otherwise
1008
+ * nothing in their path ever rejects the name.
1009
+ * @param projectRoot Directory containing `lunora.config.*`.
1010
+ * @param explicit A caller-supplied target, if any.
1011
+ * @throws when the resolved target names no registered driver.
1012
+ * @returns the resolved, registered target id.
1013
+ */
1014
+ declare const resolveTargetOrThrow: (projectRoot: string, explicit?: string) => string;
1015
+ /**
1016
+ * Whether we can interactively prompt — stdin must be a TTY. In CI / piped
1017
+ * contexts this is false, and callers should fall back to a non-interactive
1018
+ * default (skip, or require an explicit `--yes`) rather than hang on a read.
1019
+ */
392
1020
  declare const isInteractive: () => boolean;
393
1021
  /**
394
- * Ask a yes/no question on stdin. With `defaultYes`, an empty answer (just
395
- * Enter) counts as yes and the prompt should read `[Y/n]`; otherwise empty is
396
- * no (`[y/N]`). Shared by the CLI (`reset`, `dev`) and the Vite dev server.
397
- */
1022
+ * Ask a yes/no question on stdin. With `defaultYes`, an empty answer (just
1023
+ * Enter) counts as yes and the prompt should read `[Y/n]`; otherwise empty is
1024
+ * no (`[y/N]`). Shared by the CLI (`reset`, `dev`) and the Vite dev server.
1025
+ */
398
1026
  declare const promptYesNo: (prompt: string, options?: {
399
1027
  defaultYes?: boolean;
400
1028
  }) => Promise<boolean>;
401
1029
  /**
402
- * Build a default-yes `confirm(message)` for the scaffolders' `ensureDevVariables`:
403
- * an interactive `[Y/n]` prompt (optionally prefixed, e.g. `"[lunora] "`) when
404
- * stdin is a TTY, or an immediate `false` otherwise — so CI declines silently
405
- * instead of blocking. Keeps the "non-interactive ⇒ decline" policy in one place
406
- * rather than re-stated at every call site.
407
- */
1030
+ * Build a default-yes `confirm(message)` for the scaffolders' `ensureDevVariables`:
1031
+ * an interactive `[Y/n]` prompt (optionally prefixed, e.g. `"[lunora] "`) when
1032
+ * stdin is a TTY, or an immediate `false` otherwise — so CI declines silently
1033
+ * instead of blocking. Keeps the "non-interactive ⇒ decline" policy in one place
1034
+ * rather than re-stated at every call site.
1035
+ */
408
1036
  declare const createConfirm: (prefix?: string) => ((message: string) => Promise<boolean>);
409
1037
  /** One choice in a {@link promptSelect} list. `value` is returned; `label` (and optional `description`) are shown. */
410
1038
  interface SelectOption<T extends string> {
@@ -413,261 +1041,87 @@ interface SelectOption<T extends string> {
413
1041
  value: T;
414
1042
  }
415
1043
  /**
416
- * Ask the user to pick one option from a numbered list on stdin. Accepts the
417
- * 1-based number or the option's `value`/`label` typed verbatim; an empty answer
418
- * (just Enter) takes `settings.default`. In a non-interactive context (CI /
419
- * piped — no TTY) it never reads and returns `settings.default` (or `undefined`),
420
- * mirroring {@link createConfirm}'s "non-interactive ⇒ fall back" policy so
421
- * automation never blocks.
422
- */
1044
+ * Ask the user to pick one option from a numbered list on stdin. Accepts the
1045
+ * 1-based number or the option's `value`/`label` typed verbatim; an empty answer
1046
+ * (just Enter) takes `settings.default`. In a non-interactive context (CI /
1047
+ * piped — no TTY) it never reads and returns `settings.default` (or `undefined`),
1048
+ * mirroring {@link createConfirm}'s "non-interactive ⇒ fall back" policy so
1049
+ * automation never blocks.
1050
+ */
423
1051
  declare const promptSelect: <T extends string>(message: string, options: ReadonlyArray<SelectOption<T>>, settings?: {
424
1052
  default?: T;
425
1053
  }) => Promise<T | undefined>;
1054
+ /**
1055
+ * Ask a free-text question on stdin, returning the trimmed answer. An empty
1056
+ * answer (just Enter) takes `settings.default`. In a non-interactive context
1057
+ * (CI / piped — no TTY) it never reads and returns `settings.default` (or
1058
+ * `undefined`), mirroring {@link promptSelect}'s "non-interactive ⇒ fall back"
1059
+ * policy so automation never blocks.
1060
+ */
1061
+ declare const promptText: (message: string, settings?: {
1062
+ default?: string;
1063
+ }) => Promise<string | undefined>;
426
1064
  /** One choice in a {@link promptMultiSelect} list. Identical shape to {@link SelectOption}; `value` is returned when picked. */
427
1065
  type MultiSelectOption<T extends string> = SelectOption<T>;
428
1066
  /**
429
- * Ask the user to pick zero or more options from a numbered list on stdin.
430
- * Accepts a comma- or space-separated list of 1-based numbers and/or option
431
- * `value`/`label`s typed verbatim; an empty answer (just Enter) takes
432
- * `settings.defaults`. In a non-interactive context (CI / piped — no TTY) it
433
- * never reads and returns `settings.defaults ?? []`, mirroring {@link promptSelect}'s
434
- * "non-interactive ⇒ fall back" policy so automation never blocks. Unknown
435
- * tokens are ignored; the returned list is de-duplicated and preserves option
436
- * order.
437
- */
1067
+ * Ask the user to pick zero or more options from a numbered list on stdin.
1068
+ * Accepts a comma- or space-separated list of 1-based numbers and/or option
1069
+ * `value`/`label`s typed verbatim; an empty answer (just Enter) takes
1070
+ * `settings.defaults`. In a non-interactive context (CI / piped — no TTY) it
1071
+ * never reads and returns `settings.defaults ?? []`, mirroring {@link promptSelect}'s
1072
+ * "non-interactive ⇒ fall back" policy so automation never blocks. Unknown
1073
+ * tokens are ignored; the returned list is de-duplicated and preserves option
1074
+ * order.
1075
+ */
438
1076
  declare const promptMultiSelect: <T extends string>(message: string, options: ReadonlyArray<MultiSelectOption<T>>, settings?: {
439
1077
  defaults?: ReadonlyArray<T>;
440
1078
  }) => Promise<T[]>;
441
1079
  /**
442
- * A container/workflow that is declared (so codegen emits its class) but the
443
- * worker entry never re-exports — the one wiring step the generators can't always
444
- * do for the developer. wrangler rejects a `class_name` the deployed worker
445
- * doesn't export, so a deploy fails late on this; surfacing it as structured data
446
- * lets the Vite plugin raise it in the dev error overlay (not just the console)
447
- * the moment the gap appears. The human-readable form is also folded into
448
- * {@link ReconcileBindingsResult.warnings}.
449
- */
450
- interface ExportGap {
451
- /** Generated class wrangler needs exported, e.g. `OrderPipelineWorkflow`. */
452
- className: string;
453
- /** The `lunora/{containers,workflows}.ts` export name, e.g. `orderPipeline`. */
454
- exportName: string;
455
- /** Which declaration is unexported. */
456
- kind: "container" | "workflow";
457
- /** The `_generated/{module}` to re-export from, e.g. `workflows`. */
458
- module: "containers" | "workflows";
459
- }
460
- interface ReconcileBindingsResult {
461
- /** Short labels for each binding written (e.g. `"SCHEDULER/SchedulerDO"`). */
462
- added: string[];
463
- /** `true` when `wrangler.jsonc` was rewritten. */
464
- changed: boolean;
465
- /**
466
- * Declared containers/workflows the worker entry doesn't re-export — the
467
- * structured form of the corresponding `warnings` entries, for the dev error
468
- * overlay. Empty when every declaration is wired.
469
- */
470
- exportGaps: ExportGap[];
471
- /** Reason reconciliation was skipped, for logging. */
472
- reason?: string;
473
- /** Non-fatal hints for capabilities that cannot be auto-provisioned. */
474
- warnings: string[];
475
- /** Resolved wrangler path, or `undefined` when none was found. */
476
- wranglerPath?: string;
477
- }
478
- /**
479
- * Reconcile inferred Durable Object / D1 bindings into `wrangler.jsonc`.
480
- *
481
- * Writes only when something is missing; returns `changed: false` when the
482
- * config already satisfies the inferred needs.
483
- */
484
- declare const reconcileWranglerBindings: (projectRoot: string, inferred: InferredBindings) => ReconcileBindingsResult;
485
- /**
486
- * The wrangler config sections Lunora can safely flip to remote mode in dev,
487
- * each with the human label used in logs and the structural `shape` the entry
488
- * lives in.
489
- *
490
- * `"array"` is a top-level array of binding objects (`d1_databases`,
491
- * `kv_namespaces`, `r2_buckets`, `vectorize`, `services`). `"producers"` is
492
- * `queues.producers[]` — consumers are NOT remoted (their schema has no `remote`
493
- * field) and the edit path is two levels deep. `"object"` is a single binding
494
- * object, not an array (`ai`), whose edit path targets the section key directly.
495
- *
496
- * Every kind here was confirmed against `wrangler/config-schema.json`: the
497
- * entry's schema declares a `remote` property. Deliberately omits
498
- * `durable_objects` (no CF remote-DO mode; shards stay local) and sections whose
499
- * schema has no `remote` field (`hyperdrive`, `analytics_engine_datasets`,
500
- * `secrets_store_secrets`, queue consumers, …). Widening further is a one-line
501
- * table edit.
502
- */
503
- declare const REMOTE_ELIGIBLE_KEYS: {
504
- readonly ai: {
505
- readonly label: "AI";
506
- readonly shape: "object";
507
- };
508
- readonly d1_databases: {
509
- readonly label: "D1";
510
- readonly shape: "array";
511
- };
512
- readonly kv_namespaces: {
513
- readonly label: "KV";
514
- readonly shape: "array";
515
- };
516
- readonly queues: {
517
- readonly label: "Queue";
518
- readonly shape: "producers";
519
- };
520
- readonly r2_buckets: {
521
- readonly label: "R2";
522
- readonly shape: "array";
523
- };
524
- readonly services: {
525
- readonly label: "Service";
526
- readonly shape: "array";
527
- };
528
- readonly vectorize: {
529
- readonly label: "Vectorize";
530
- readonly shape: "array";
531
- };
532
- };
533
- type RemoteEligibleKey = keyof typeof REMOTE_ELIGIBLE_KEYS;
534
- /** One binding object as it appears in any eligible section. */
535
- interface BindingEntry {
536
- binding?: string;
537
- remote?: boolean;
538
- }
539
- /** One binding entry we mark remote, with enough provenance to log + edit it. */
540
- interface RemoteBindingPlan {
541
- /** The binding name as declared in the config (e.g. `"DB"`, `"FILES"`). */
542
- binding: string;
543
- /** Short kind label for logging (`"D1"`, `"KV"`, `"R2"`, `"Vectorize"`, …). */
544
- kind: string;
545
- /**
546
- * The jsonc edit path within {@link RemoteBindingPlan.section}, relative to
547
- * the section key: `[index]` for an `"array"` section, `["producers", index]`
548
- * for a queue producer, or `[]` for the single-object `ai` section. The
549
- * materializer prepends the section key and appends `"remote"`.
550
- */
551
- path: ReadonlyArray<number | string>;
552
- /** The wrangler config key the entry lives under. */
553
- section: RemoteEligibleKey;
554
- }
555
- /** The structural slice of a wrangler config the remote planner reads. */
556
- interface RemoteWranglerShape {
557
- ai?: BindingEntry | null;
558
- d1_databases?: ReadonlyArray<BindingEntry | null | undefined>;
559
- kv_namespaces?: ReadonlyArray<BindingEntry | null | undefined>;
560
- queues?: {
561
- producers?: ReadonlyArray<BindingEntry | null | undefined>;
562
- } | null;
563
- r2_buckets?: ReadonlyArray<BindingEntry | null | undefined>;
564
- services?: ReadonlyArray<BindingEntry | null | undefined>;
565
- vectorize?: ReadonlyArray<BindingEntry | null | undefined>;
566
- }
567
- /**
568
- * Inspect a parsed wrangler config and list every eligible binding that should
569
- * be flipped to remote mode. Pure — no file-system access, no mutation. An
570
- * entry already carrying `"remote": true` is still reported (so logging is
571
- * complete) but the materializer's edit is a harmless no-op for it.
572
- */
573
- declare const planRemoteBindings: (parsed: RemoteWranglerShape) => RemoteBindingPlan[];
574
- /**
575
- * Inject `"remote": true` onto each planned binding in the config `text`,
576
- * comment-preservingly via jsonc edits. Pure string→string; the edits target
577
- * disjoint entries so applying them sequentially is safe. The edit path is
578
- * `[section, ...plan.path, "remote"]`, which resolves to the array element, the
579
- * `queues.producers[i]` entry, or the single `ai` object as the plan demands.
580
- */
581
- declare const injectRemoteFlags: (text: string, plans: ReadonlyArray<RemoteBindingPlan>) => string;
582
- interface MaterializeOptions {
583
- /** When `false`, the call is a no-op (returns `enabled: false`). */
584
- enabled: boolean;
585
- projectRoot: string;
586
- }
587
- interface MaterializeResult {
588
- /**
589
- * Removes the generated temp config file. Always present and always safe to
590
- * call: it is idempotent, a no-op when nothing was written (disabled /
591
- * fall-through cases), and never throws if the path is already gone. The dev
592
- * command calls this on every exit path (normal, signal, error).
593
- */
594
- cleanup: () => void;
595
- /**
596
- * Absolute path to the generated temp config to pass to
597
- * `wrangler dev --config`. `undefined` when remote mode is disabled, no
598
- * wrangler config was found, it failed to parse, or it declared no eligible
599
- * binding (nothing to remote — run plain local dev).
600
- */
601
- configPath?: string;
602
- /** Whether remote mode was requested at all. */
603
- enabled: boolean;
604
- /** Why no temp config was produced, for logging (only set when none was). */
605
- reason?: string;
606
- /** The bindings flipped to remote, for the dev banner. */
607
- remoteBindings: RemoteBindingPlan[];
608
- }
609
- /**
610
- * Produce a temporary wrangler config with `"remote": true` on every eligible
611
- * binding, so `lunora dev` can run `wrangler dev --config &lt;temp>` against the
612
- * deployed D1/KV/R2 without touching the user's file.
613
- *
614
- * The temp file is written as a sibling of the source `wrangler.jsonc` (in the
615
- * project root), NOT an OS temp dir: wrangler resolves a config's relative paths
616
- * (`main`, `assets`, `migrations_dir`, …) against the **config file's own
617
- * directory**, so a temp config in `/tmp` would make wrangler look for
618
- * `/tmp/src/server.ts` and fail to start the worker. Keeping it beside the real
619
- * config preserves those relative paths. Returns `configPath: undefined` (with a
620
- * `reason`) for every fall-through case so the caller degrades to plain local
621
- * dev instead of failing.
622
- */
623
- declare const materializeRemoteWranglerConfig: (options: MaterializeOptions) => MaterializeResult;
624
- /**
625
- * Parse a `LUNORA_REMOTE` env value into the on/off decision. Truthy when set to
626
- * `"1"` or `"true"` (case-insensitive); anything else — unset, `"0"`, `"false"`,
627
- * empty — is off. Mirrors the `"1" | "true"` convention used across the runtime.
628
- */
629
- declare const isRemoteEnvEnabled: (value: string | undefined) => boolean;
630
- /** The three inputs that can switch remote-binding dev on, in precedence order. */
631
- interface RemoteEnableInputs {
632
- /**
633
- * The `remote` preference from `lunora.json` (the lowest-priority signal).
634
- * `undefined` means "no project preference"; an explicit `false` here loses
635
- * to neither the flag nor the env when those are absent — it just stays off.
636
- */
637
- configPreference?: boolean;
638
- /** The raw `LUNORA_REMOTE` env value (parsed with {@link isRemoteEnvEnabled}). */
639
- envValue?: string;
640
- /** The explicit `--remote` CLI flag — `true` when passed, `undefined`/`false` otherwise. */
641
- flag?: boolean;
642
- }
1080
+ * The project's Lunora source directory (the plugin's `schemaDir`), read the way
1081
+ * `@lunora/vite` sees it: the `schemaDir` string literal passed to the `lunora()`
1082
+ * call in `vite.config.*`, else `"lunora"`. The CLI commands that scan the
1083
+ * project (`dev`, `deploy`, `doctor`, `env`, `codegen`) resolve it here, so a
1084
+ * project that moved its functions to `backend/` gets its `ctx.*` reads and
1085
+ * schema facts read from `backend/` instead of from a directory that does not
1086
+ * exist.
1087
+ *
1088
+ * Parsed, never evaluated: a CLI command must not run the project's build
1089
+ * config. A computed `schemaDir`, or a plugin reached any other way, is not seen
1090
+ * and falls back to the default — the same answer as before this was read.
1091
+ */
1092
+ declare const resolveSchemaDirectory: (projectRoot: string) => string;
1093
+ /** Core (always-scaffolded) secrets followed by the package-specific ones for the detected capabilities. */
1094
+ declare const requiredSecrets: (packageNames: ReadonlyArray<string>) => SecretEntry[];
643
1095
  /**
644
- * Resolve whether remote-binding dev is on, with a clear precedence:
645
- *
646
- * 1. an explicit `--remote` flag (highest — a deliberate per-invocation choice),
647
- * 2. then `LUNORA_REMOTE` in the environment,
648
- * 3. then the `remote` key in `lunora.json` (lowest — a project default).
649
- *
650
- * The flag and env are one-directional (they can only turn remote *on*); only
651
- * the config preference carries a meaningful `false`, and it applies solely when
652
- * neither stronger signal is present. So a project that sets `"remote": false`
653
- * is still overridable per-run by `--remote` or `LUNORA_REMOTE=1`.
654
- */
655
- declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
656
- /**
657
- * Whether an (already-unquoted) value looks like a fill-me-in placeholder —
658
- * empty, angle-bracketed, or containing a known marker — rather than a real
659
- * value. Used both when scaffolding (which values to regenerate) and by
660
- * `lunora env doctor` (which set values are still unfilled).
661
- */
1096
+ * Whether an (already-unquoted) value looks like a fill-me-in placeholder —
1097
+ * empty, angle-bracketed, or containing a known marker — rather than a real
1098
+ * value. Used both when scaffolding (which values to regenerate) and by
1099
+ * `lunora env doctor` (which set values are still unfilled).
1100
+ */
662
1101
  declare const isPlaceholderValue: (value: string) => boolean;
663
1102
  /**
664
- * The outcome of planning a scaffold — a discriminated union so the orchestrator
665
- * never has to re-derive whether `content` is present.
666
- *
667
- * `exists`: `.dev.vars` is already there; nothing to do.
668
- * `no-example`: nothing to scaffold from (stay silent — the project may not use secrets).
669
- * `generate`: write `content`, a copy of the example with secret-looking placeholders replaced by fresh random hex (`generatedKeys` lists which).
670
- */
1103
+ * True for a secret key the registry says Lunora can mint locally (a random
1104
+ * 32-byte hex, like `openssl rand -hex 32`) — `AUTH_SECRET`,
1105
+ * `LUNORA_ADMIN_TOKEN`, `STORAGE_SIGNING_SECRET`, …
1106
+ *
1107
+ * Registry membership, NOT the key's name shape, is the rule. A secret-looking
1108
+ * key nothing in the registry declares (`OPENAI_API_KEY`,
1109
+ * `GITHUB_CLIENT_SECRET`, a project's own `*_TOKEN`) is provider-issued as far
1110
+ * as Lunora knows, so minting for it would write a value the provider rejects at
1111
+ * runtime — over the developer's own half-filled `.dev.vars` — and hide the gap
1112
+ * from `lunora env doctor`, whose job is to report it as unfilled.
1113
+ */
1114
+ declare const isMintableSecretKey: (key: string) => boolean;
1115
+ /** Mint a fresh strong secret value — 64 hex chars (32 bytes), like `openssl rand -hex 32`. */
1116
+ declare const generateSecretValue: (randomHex?: (bytes: number) => string) => string;
1117
+ /**
1118
+ * The outcome of planning a scaffold — a discriminated union so the orchestrator
1119
+ * never has to re-derive whether `content` is present.
1120
+ *
1121
+ * `exists`: `.dev.vars` is already there; nothing to do.
1122
+ * `no-example`: nothing to scaffold from (stay silent — the project may not use secrets).
1123
+ * `generate`: write `content`, a copy of the example with secret-looking placeholders replaced by fresh random hex (`generatedKeys` lists which).
1124
+ */
671
1125
  type ScaffoldPlan = {
672
1126
  content: string;
673
1127
  generatedKeys: string[];
@@ -680,7 +1134,8 @@ type ScaffoldPlan = {
680
1134
  /** Decide whether (and what) to scaffold. Pure — given the current state of the two files. */
681
1135
  declare const planDevVariablesScaffold: (input: {
682
1136
  devVarsExists: boolean;
683
- exampleContent: string | undefined; /** Injectable for deterministic tests; defaults to `crypto.randomBytes`. */
1137
+ exampleContent: string | undefined;
1138
+ /** Injectable for deterministic tests; defaults to `crypto.randomBytes`. */
684
1139
  randomHex?: (bytes: number) => string;
685
1140
  }) => ScaffoldPlan;
686
1141
  interface AugmentPlan {
@@ -692,22 +1147,23 @@ interface AugmentPlan {
692
1147
  missingKeys: string[];
693
1148
  }
694
1149
  /**
695
- * Plan how to top up an existing `.dev.vars` from the example: every example key
696
- * not already present becomes an appended line (secret placeholders filled with
697
- * fresh random hex, other values copied). Pure — no I/O. Empty `missingKeys`
698
- * means the file is already complete.
699
- */
1150
+ * Plan how to top up an existing `.dev.vars` from the example: every example key
1151
+ * not already present becomes an appended line (secret placeholders filled with
1152
+ * fresh random hex, other values copied). Pure — no I/O. Empty `missingKeys`
1153
+ * means the file is already complete.
1154
+ */
700
1155
  declare const planDevVariablesAugment: (input: {
701
1156
  exampleContent: string;
702
- existingContent: string; /** Injectable for deterministic tests; defaults to `crypto.randomBytes`. */
1157
+ existingContent: string;
1158
+ /** Injectable for deterministic tests; defaults to `crypto.randomBytes`. */
703
1159
  randomHex?: (bytes: number) => string;
704
1160
  }) => AugmentPlan;
705
1161
  interface EnsureDevVariablesDeps {
706
1162
  /**
707
- * Ask the user to confirm generating the file. Return `true` to generate.
708
- * Consumers pass a TTY-aware prompt; in non-interactive contexts they should
709
- * resolve `false` (we then report `"declined"` and the caller can hint).
710
- */
1163
+ * Ask the user to confirm generating the file. Return `true` to generate.
1164
+ * Consumers pass a TTY-aware prompt; in non-interactive contexts they should
1165
+ * resolve `false` (we then report `"declined"` and the caller can hint).
1166
+ */
711
1167
  confirm: (message: string) => Promise<boolean>;
712
1168
  cwd: string;
713
1169
  /** Emit a human-facing line (success / hint). */
@@ -726,44 +1182,118 @@ interface EnsureDevVariablesResult {
726
1182
  status: EnsureDevVariablesStatus;
727
1183
  }
728
1184
  /**
729
- * Reconcile the project's `.dev.vars` with its `.dev.vars.example`:
730
- *
731
- * - file missing → offer to generate it (secret placeholders auto-filled);
732
- * - file present but missing keys the example lists → offer to append them;
733
- * - file present and complete → nothing to do.
734
- *
735
- * Prompts via `confirm` (skipped when `yes`); never overwrites existing values.
736
- * Returns what happened so the caller can tailor any follow-up. Shared by
737
- * `lunora dev` and the `@lunora/vite` dev server. All side effects funnel
738
- * through `confirm`/`info`/`randomHex`.
739
- */
1185
+ * Atomically (over)write a `.dev.vars`-shaped file, owner-only. For a file
1186
+ * holding secrets a torn write would destroy every other local value alongside
1187
+ * the new one, and the new value itself has no other recoverable copy if it
1188
+ * was never disclosed anywhere else (Cloudflare secrets are write-only).
1189
+ * Exported so a caller writing to a `.dev.vars`-shaped path outside this
1190
+ * module (`lunora deploy`'s minted-secret disclosure) reuses this instead of
1191
+ * hand-rolling another copy of the pattern.
1192
+ */
1193
+ declare const writeDevVariablesFileAtomically: (path: string, content: string) => void;
1194
+ /**
1195
+ * Reconcile the project's `.dev.vars` with its `.dev.vars.example`:
1196
+ *
1197
+ * - file missing → offer to generate it (secret placeholders auto-filled);
1198
+ * - file present but missing keys the example lists → offer to append them;
1199
+ * - file present and complete → nothing to do.
1200
+ *
1201
+ * Prompts via `confirm` (skipped when `yes`); never overwrites existing values.
1202
+ * Returns what happened so the caller can tailor any follow-up. Shared by
1203
+ * `lunora dev` and the `@lunora/vite` dev server. All side effects funnel
1204
+ * through `confirm`/`info`/`randomHex`.
1205
+ */
740
1206
  declare const ensureDevVariables: (deps: EnsureDevVariablesDeps) => Promise<EnsureDevVariablesResult>;
741
1207
  /**
742
- * Build the text that should be merged into `.dev.vars.example` for the given
743
- * set of package names. Only entries whose key is not already present in
744
- * `existingKeys` are included (additive / idempotent). Returns an empty string
745
- * when there is nothing to add.
746
- *
747
- * The output is grouped by package with a blank-line separator so the file
748
- * reads cleanly when multiple packages each contribute several keys.
749
- *
750
- * **Safety invariant:** this function never writes a real secret — every value
751
- * in the output is the entry's `placeholderValue`.
752
- */
1208
+ * Build the text that should be merged into `.dev.vars.example` for the given
1209
+ * set of package names. Only entries whose key is not already present in
1210
+ * `existingKeys` are included (additive / idempotent). Returns an empty string
1211
+ * when there is nothing to add.
1212
+ *
1213
+ * The output is grouped by package with a blank-line separator so the file
1214
+ * reads cleanly when multiple packages each contribute several keys.
1215
+ *
1216
+ * **Safety invariant:** this function never writes a real secret — every value
1217
+ * in the output is the entry's `placeholderValue`.
1218
+ */
753
1219
  declare const buildPackageSecretsBlock: (packageNames: ReadonlyArray<string>, existingKeys: ReadonlySet<string>) => string;
754
1220
  /**
755
- * Write (or update) `.dev.vars.example` so that it contains the secrets
756
- * required by `packageNames`. Existing lines are never removed or rewritten;
757
- * new entries are appended (with a blank-line separator after existing content).
758
- *
759
- * Idempotent: re-running with the same `packageNames` does not duplicate keys
760
- * already in the file. Returns the list of keys that were actually appended.
761
- *
762
- * **Safety invariant:** only placeholder values are written — no real secrets.
763
- */
1221
+ * Write (or update) `.dev.vars.example` so that it contains the secrets
1222
+ * required by `packageNames`. Existing lines are never removed or rewritten;
1223
+ * new entries are appended (with a blank-line separator after existing content).
1224
+ *
1225
+ * Idempotent: re-running with the same `packageNames` does not duplicate keys
1226
+ * already in the file. Returns the list of keys that were actually appended.
1227
+ *
1228
+ * **Safety invariant:** only placeholder values are written — no real secrets.
1229
+ */
764
1230
  declare const ensureDevVariablesExample: (cwd: string, packageNames: ReadonlyArray<string>) => string[];
1231
+ interface DevSecretsFillPlan {
1232
+ /** {@link CORE_SECRETS} keys appended because they were absent (each generated). */
1233
+ addedKeys: string[];
1234
+ /** The full new file content to write. */
1235
+ content: string;
1236
+ /** Existing empty/placeholder secret-keyed entries filled with fresh values. */
1237
+ filledKeys: string[];
1238
+ }
1239
+ /**
1240
+ * Plan the in-place generation of dev secrets for a `.dev.vars`. First, every
1241
+ * line whose key is {@link isMintableSecretKey mintable} — registry membership,
1242
+ * NOT the key's name shape — and whose value is empty or a placeholder gets a
1243
+ * freshly generated value, so a `lunora add`-scaffolded `.dev.vars` (which
1244
+ * writes each secret blank) becomes usable on `lunora dev` / `vite dev` without
1245
+ * the user running `openssl` by hand. A provider-issued key (`OPENAI_API_KEY`,
1246
+ * `STRIPE_SECRET_KEY`) is left verbatim so `lunora env doctor` can still report
1247
+ * it as unfilled. Second, any {@link CORE_SECRETS} key absent from
1248
+ * the file is appended (generated) — notably `LUNORA_ADMIN_TOKEN`, which the
1249
+ * local Studio needs to call the worker's admin gate in dev (without it the
1250
+ * Studio shows its login gate).
1251
+ *
1252
+ * Pure (given `randomHex`): real (non-placeholder) values are never touched, and
1253
+ * comments + non-secret entries are preserved verbatim.
1254
+ */
1255
+ declare const planDevSecretsFill: (input: {
1256
+ existingContent: string;
1257
+ randomHex?: (bytes: number) => string;
1258
+ }) => DevSecretsFillPlan;
1259
+ interface FillDevSecretsResult {
1260
+ /** Core secret keys appended (generated) because they were missing. */
1261
+ addedKeys: string[];
1262
+ /** Existing empty/placeholder secrets filled with generated values. */
1263
+ filledKeys: string[];
1264
+ /** `created` = no `.dev.vars` existed; `filled` = topped up an existing one; `unchanged` = nothing to do. */
1265
+ status: "created" | "filled" | "unchanged";
1266
+ }
1267
+ /**
1268
+ * Generate any missing/empty dev secrets in the project's `.dev.vars`, in place.
1269
+ *
1270
+ * Complements {@link ensureDevVariables} (which scaffolds `.dev.vars` from
1271
+ * `.dev.vars.example`). A `lunora add`-scaffolded project writes secrets blank
1272
+ * straight into `.dev.vars` (no example) and never includes `LUNORA_ADMIN_TOKEN`
1273
+ * — so the worker boots with empty secrets and the Studio shows its login gate.
1274
+ * This fills those gaps at dev startup, so both `lunora dev` and the
1275
+ * `@lunora/vite` dev server give a working project with zero manual `openssl`.
1276
+ *
1277
+ * Never overwrites a real (non-placeholder) value. The write is atomic + owner-
1278
+ * only (temp + rename, `mode: 0o600`), matching the other `.dev.vars` writers.
1279
+ */
1280
+ declare const fillDevSecrets: (deps: {
1281
+ cwd: string;
1282
+ info?: (message: string) => void;
1283
+ randomHex?: (bytes: number) => string;
1284
+ }) => FillDevSecretsResult;
1285
+ /** Storage backends `.global()` accepts. A closed union, so it is never free text. */
1286
+ type GlobalBackend = "d1" | "hyperdrive";
765
1287
  /** Add a new table to `defineSchema({ ... })`. */
766
1288
  interface AddTableEdit {
1289
+ /**
1290
+ * Mark the table `.global()`. Pass `{}` for the D1 default, or a backend for
1291
+ * an external store — `lunora introspect` uses `{ backend: "hyperdrive" }`
1292
+ * because the rows live in the database it read.
1293
+ */
1294
+ readonly global?: {
1295
+ readonly backend?: GlobalBackend;
1296
+ };
767
1297
  readonly kind: "addTable";
768
1298
  readonly table: string;
769
1299
  }
@@ -773,11 +1303,11 @@ interface AddOptionalColumnEdit {
773
1303
  readonly kind: "addOptionalColumn";
774
1304
  readonly table: string;
775
1305
  /**
776
- * Inner validator expression text WITHOUT the `v.optional(...)` wrapper, e.g.
777
- * `v.string()`. Always wrapped in `v.optional(...)` on apply, because only
778
- * optional columns are additive-safe (a required column needs a backfill
779
- * migration).
780
- */
1306
+ * Inner validator expression text WITHOUT the `v.optional(...)` wrapper, e.g.
1307
+ * `v.string()`. Always wrapped in `v.optional(...)` on apply, because only
1308
+ * optional columns are additive-safe (a required column needs a backfill
1309
+ * migration).
1310
+ */
781
1311
  readonly validator: string;
782
1312
  }
783
1313
  /** Add a secondary index to an existing table. */
@@ -791,9 +1321,9 @@ interface AddIndexEdit {
791
1321
  /** Additive edits — the only requests {@link applyAdditiveEdit} applies. */
792
1322
  type AdditiveEdit = AddIndexEdit | AddOptionalColumnEdit | AddTableEdit;
793
1323
  /**
794
- * Destructive edits — never applied directly; routed to the migration handoff
795
- * (plan 024 Item 5). Carried as data so the editor can describe the request.
796
- */
1324
+ * Destructive edits — never applied directly; routed to the migration handoff
1325
+ * (plan 024 Item 5). Carried as data so the editor can describe the request.
1326
+ */
797
1327
  interface DestructiveEdit {
798
1328
  readonly column?: string;
799
1329
  readonly kind: "changeColumnType" | "dropColumn" | "dropTable" | "makeRequired" | "renameColumn";
@@ -804,9 +1334,9 @@ interface DestructiveEdit {
804
1334
  /** Any edit the editor can request. */
805
1335
  type SchemaEdit = AdditiveEdit | DestructiveEdit;
806
1336
  /**
807
- * Classify an edit request. Additive edits ({@link AdditiveEdit}) apply
808
- * directly; everything else changes stored data and is destructive.
809
- */
1337
+ * Classify an edit request. Additive edits ({@link AdditiveEdit}) apply
1338
+ * directly; everything else changes stored data and is destructive.
1339
+ */
810
1340
  declare const classifyEdit: (edit: SchemaEdit) => "additive" | "destructive";
811
1341
  /** Failure reasons an additive edit can report. */
812
1342
  type ApplyFailureReason = "aliased-define-schema" | "destructive" | "duplicate-column" | "duplicate-index" | "duplicate-table" | "invalid-identifier" | "invalid-validator" | "no-define-schema" | "non-object-argument" | "unknown-table";
@@ -819,10 +1349,10 @@ type ApplyEditResult = {
819
1349
  text: string;
820
1350
  };
821
1351
  /**
822
- * Apply an **additive** edit to a schema source string, preserving formatting.
823
- * Destructive edits are refused with `{ ok: false, reason: "destructive" }`;
824
- * route them through the migration handoff (plan 024 Item 5).
825
- */
1352
+ * Apply an **additive** edit to a schema source string, preserving formatting.
1353
+ * Destructive edits are refused with `{ ok: false, reason: "destructive" }`;
1354
+ * route them through the migration handoff (plan 024 Item 5).
1355
+ */
826
1356
  declare const applyAdditiveEdit: (source: string, edit: SchemaEdit) => ApplyEditResult;
827
1357
  /** A single declared column: its name and the raw validator expression text. */
828
1358
  interface SchemaColumn {
@@ -861,215 +1391,59 @@ type ParseSchemaResult = {
861
1391
  tables: ReadonlyArray<SchemaTable>;
862
1392
  };
863
1393
  /**
864
- * Every `CallExpression` at or below a node. `getDescendantsOfKind` excludes the
865
- * node itself, but a table initializer often is the outermost call in the
866
- * `defineTable(...).global().index(...)` chain, so include it explicitly.
867
- */
868
-
869
- /**
870
- * Parse the tables (with typed columns + indexes) out of a `lunora/schema.ts`
871
- * source string. Returns a tagged result so callers can render a helpful
872
- * message per failure mode without throwing.
873
- */
1394
+ * Parse the tables (with typed columns + indexes) out of a `lunora/schema.ts`
1395
+ * source string. Returns a tagged result so callers can render a helpful
1396
+ * message per failure mode without throwing.
1397
+ */
874
1398
  declare const parseSchema: (source: string) => ParseSchemaResult;
875
- interface SchemaInfo {
876
- /** Whether the lunora schema declares any `.global()` table. */
877
- hasGlobalTable: boolean;
878
- /** Names of vector indexes declared via `.vectorize()` / `defineVectorIndex()`. */
879
- vectorIndexNames?: ReadonlyArray<string>;
880
- }
881
- interface DiscoverSchemaInfoResult {
882
- /** Parse error message, when the schema exists but could not be analyzed. */
883
- error?: string;
884
- /** Schema facts, or `undefined` when no `schema.ts` exists or parsing failed. */
885
- info: SchemaInfo | undefined;
886
- }
887
1399
  /**
888
- * Discover {@link SchemaInfo} for a project. Returns `{ info: undefined }` when
889
- * the project declares no `schema.ts` (not an error), or `{ info: undefined,
890
- * error }` when a present schema could not be parsed — callers decide whether a
891
- * parse failure is a warning (validator) or simply ignorable (inference).
892
- */
893
- declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string) => DiscoverSchemaInfoResult;
894
- /** Candidate wrangler config filenames, in the order every consumer probes them. */
895
- declare const WRANGLER_FILES: readonly ["wrangler.jsonc", "wrangler.json"];
896
- /** Locate the project's wrangler config, or `undefined` when none exists. */
897
- declare const findWranglerFile: (projectRoot: string) => string | undefined;
898
- interface ReadWranglerResult<T> {
899
- /** Parsed config, or `undefined` when the file was not valid JSONC. */
900
- parsed: T | undefined;
901
- /** Raw file text — needed for comment-preserving `modify`/`applyEdits`. */
1400
+ * A badge: the short colored label that prefixes a line. `bg`/`fg` are hex so the
1401
+ * same value drives both colorize's `bgHex().hex()` and the tui `<Text>` props.
1402
+ */
1403
+ interface BadgeSpec {
1404
+ bg: `#${string}`;
1405
+ fg: `#${string}`;
902
1406
  text: string;
903
1407
  }
1408
+ /** Lunora purple — the accent shared with the CLI prompt frames. */
1409
+ declare const ACCENT: `#${string}`;
1410
+ /** Standard log-level badge names (the restyled base output). */
1411
+ type LevelBadgeName = "debug" | "error" | "info" | "success" | "warn";
1412
+ /** Step-phase badge names (the create-astro-style flow transcript). */
1413
+ type StepBadgeName = "add" | "deps" | "dir" | "git" | "lunora" | "next" | "tmpl";
1414
+ type BadgeName = LevelBadgeName | StepBadgeName;
1415
+ /** The ordered step-phase names, used to register custom pail log types. */
1416
+ declare const STEP_BADGE_NAMES: ReadonlyArray<StepBadgeName>;
904
1417
  /**
905
- * Read and JSONC-parse a wrangler config file. Returns the raw `text` (for
906
- * structural edits) alongside `parsed`, which is `undefined` when the file is
907
- * not valid JSONC or does not parse to an object. Allows trailing commas, as
908
- * wrangler does.
909
- */
910
- declare const readWranglerJsonc: <T = unknown>(wranglerPath: string) => ReadWranglerResult<T>;
911
- declare const REQUIRED_COMPATIBILITY_DATE: string;
912
- declare const REQUIRED_FLAG: string;
913
- interface WranglerDurableObjectBinding {
914
- class_name?: string;
915
- name?: string;
916
- }
917
- /**
918
- * A `tail_consumers` entry: a Worker that receives this Worker's tail events
919
- * (logs, exceptions, fetch metadata) for forwarding to an external sink. See
920
- * `withTailConsumer` for the wiring helper.
921
- */
922
- interface TailConsumer {
923
- /** Optional Cloudflare environment of the consumer Worker. */
924
- environment?: string;
925
- /** Name of the Worker that consumes tail events. */
926
- service?: string;
927
- }
928
- /** A wrangler `containers[]` entry (parsed from untrusted JSONC). */
929
- interface WranglerContainerEntry {
930
- class_name?: string;
931
- image?: string;
932
- instance_type?: string | {
933
- disk_mb?: number;
934
- memory_mib?: number;
935
- vcpu?: number;
936
- };
937
- max_instances?: number;
938
- }
939
- /**
940
- * A wrangler `workflows[]` entry (parsed from untrusted JSONC). Unlike
941
- * containers, workflows are NOT Durable Objects — the entry stands alone (no
942
- * `durable_objects` binding, no migration class).
943
- */
944
- interface WranglerWorkflowEntry {
945
- binding?: string;
946
- class_name?: string;
947
- name?: string;
948
- }
949
- interface WranglerConfig {
950
- analytics_engine_datasets?: ReadonlyArray<{
951
- binding?: string;
952
- dataset?: string;
953
- } | null | undefined>;
954
- assets?: {
955
- binding?: string;
956
- directory?: string;
957
- html_handling?: string;
958
- not_found_handling?: string;
959
- };
960
- browser?: {
961
- binding?: string;
962
- };
963
- compatibility_date?: string;
964
- compatibility_flags?: ReadonlyArray<string>;
965
- containers?: ReadonlyArray<WranglerContainerEntry | null | undefined>;
966
- d1_databases?: ReadonlyArray<{
967
- binding?: string;
968
- }>;
969
- dispatch_namespaces?: ReadonlyArray<{
970
- binding?: string;
971
- namespace?: string;
972
- outbound?: unknown;
973
- } | null | undefined>;
974
- durable_objects?: {
975
- bindings?: ReadonlyArray<WranglerDurableObjectBinding>;
976
- };
977
- hyperdrive?: ReadonlyArray<{
978
- binding?: string;
979
- id?: string;
980
- localConnectionString?: string;
981
- } | null | undefined>;
982
- images?: {
983
- binding?: string;
984
- };
985
- kv_namespaces?: ReadonlyArray<{
986
- binding?: string;
987
- id?: string;
988
- } | null | undefined>;
989
- logpush?: boolean;
990
- migrations?: ReadonlyArray<{
991
- new_classes?: ReadonlyArray<string>;
992
- new_sqlite_classes?: ReadonlyArray<string>;
993
- } | null | undefined>;
994
- mtls_certificates?: ReadonlyArray<{
995
- binding?: string;
996
- certificate_id?: string;
997
- } | null | undefined>;
998
- observability?: {
999
- enabled?: boolean;
1000
- head_sampling_rate?: number;
1001
- logs?: {
1002
- enabled?: boolean;
1003
- head_sampling_rate?: number;
1004
- };
1005
- };
1006
- pipelines?: ReadonlyArray<{
1007
- binding?: string;
1008
- pipeline?: string;
1009
- } | null | undefined>;
1010
- placement?: {
1011
- mode?: string;
1012
- };
1013
- r2_buckets?: ReadonlyArray<{
1014
- binding?: string;
1015
- }>;
1016
- send_email?: ReadonlyArray<{
1017
- allowed_destination_addresses?: ReadonlyArray<string>;
1018
- destination_address?: string;
1019
- name?: string;
1020
- } | null | undefined>;
1021
- services?: ReadonlyArray<{
1022
- binding?: string;
1023
- entrypoint?: string;
1024
- environment?: string;
1025
- service?: string;
1026
- } | null | undefined>;
1027
- tail_consumers?: ReadonlyArray<TailConsumer | null | undefined>;
1028
- vars?: Record<string, unknown>;
1029
- vectorize?: ReadonlyArray<{
1030
- binding?: string;
1031
- index_name?: string;
1032
- } | null | undefined>;
1033
- workflows?: ReadonlyArray<WranglerWorkflowEntry | null | undefined>;
1034
- }
1035
- interface WranglerValidationReport {
1036
- errors: string[];
1037
- valid: boolean;
1038
- warnings: string[];
1039
- }
1418
+ * Every badge, keyed by name. Levels get their conventional colors (red/amber/
1419
+ * green/blue/grey); step phases follow create-astro's green→purple→cyan rhythm.
1420
+ */
1421
+ declare const BADGES: Record<BadgeName, BadgeSpec>;
1040
1422
  /**
1041
- * Return a new `WranglerConfig` with `consumer` present in `tail_consumers`,
1042
- * wiring this Worker to forward its tail events (logs/exceptions) to another
1043
- * Worker that fans them out to an external sink. Pure and idempotent: an
1044
- * existing entry with the same `service` + `environment` is left untouched
1045
- * rather than duplicated, so it is safe to call on every codegen/deploy.
1046
- */
1047
- declare const withTailConsumer: (wrangler: WranglerConfig, consumer: TailConsumer) => WranglerConfig;
1048
- /**
1049
- * Pure validator: given a parsed `WranglerConfig` object and an optional
1050
- * `SchemaInfo`, produce a structured report. Performs no I/O.
1051
- */
1052
- declare const validateWranglerConfig: (wrangler: WranglerConfig | undefined, schema?: SchemaInfo) => WranglerValidationReport;
1053
- /**
1054
- * Convenience alias matching the original task-spec signature
1055
- * `validateWrangler(wranglerJson, schema)` returning
1056
- * `{ valid, errors, warnings }`.
1057
- */
1058
- declare const validateWrangler: typeof validateWranglerConfig;
1059
- interface WranglerProjectValidationOptions {
1060
- projectRoot: string;
1061
- schemaDir?: string;
1062
- }
1063
- interface WranglerProjectValidationResult {
1064
- problems: ReadonlyArray<string>;
1065
- report: WranglerValidationReport;
1066
- wranglerPath: string | undefined;
1067
- }
1423
+ * Luna, the mascot: the folklore rabbit-in-the-moon — a bunny tucked inside the
1424
+ * moon disc. Pure ASCII so it renders the same everywhere (including piped logs).
1425
+ * The CLI signs off the `init` flow with it, the way create-astro closes with
1426
+ * Houston.
1427
+ */
1428
+ declare const LUNA_NAME = "Luna";
1429
+ declare const LUNA_SIGNOFF = "Safe travels, voyager.";
1430
+ declare const LUNA_BUNNY: string;
1068
1431
  /**
1069
- * File-system aware variant: reads `wrangler.jsonc`/`wrangler.json` from
1070
- * the given project root, discovers the schema (if any), and delegates to
1071
- * `validateWranglerConfig`. Returns the legacy
1072
- * `{ problems, wranglerPath }` shape plus the structured `report`.
1073
- */
1074
- declare const validateWranglerProject: (options: WranglerProjectValidationOptions) => WranglerProjectValidationResult;
1075
- export { AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, findWranglerFile, formatLunoraEvent, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, parseDevVariableEntries, parseSchema, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, resolveRemoteEnabled, secretsForPackages, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
1432
+ * {@link LUNA_BUNNY} with its leading newline stripped, ready to render inline
1433
+ * (beside the name + sign-off). Both render paths — the tui mascot frame and the
1434
+ * pail off-TTY fallback — use this so neither re-implements the strip.
1435
+ */
1436
+ declare const LUNA_ART: string;
1437
+ /** The colored part of a badge — the word with one space of padding each side. */
1438
+ declare const padBadge: (text: string) => string;
1439
+ /** Leading spaces that right-align a badge's box within the gutter. */
1440
+ declare const badgeLead: (text: string) => string;
1441
+ /** Total columns a rendered badge column occupies (lead + box), constant across badges. */
1442
+ declare const BADGE_COLUMN_WIDTH: number;
1443
+ /** Columns a rendered badge occupies — the gutter-aligned column width. */
1444
+ declare const badgeWidth: (_spec: BadgeSpec) => number;
1445
+ /** Paint a badge as an ANSI string (the non-tui path): right-aligning spaces + the colored box. */
1446
+ declare const paintBadge: (spec: BadgeSpec) => string;
1447
+ /** Dim continuation text (a step's chosen answer, shown under the question). */
1448
+ declare const paintAnswer: (text: string) => string;
1449
+ export { ACCENT, AGENT_MODE_ENV, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentDetection, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, CODEGEN_ENV, type CelldDevSession, type CelldDevSessionOptions, type CelldLineOrigin, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_DEPLOY_TARGET, DEV_BINDINGS_FILE, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, type DeployDriver, type DestructiveEdit, type DetectedFramework, type DevProcess, type DevProcessOptions, type DevProcessSpawner, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type FillDevSecretsResult, type FindingLogger, type FrameworkClass, type FrameworkDetection, type HookLogger, type HookSpawnDescriptor, type HookSpawner, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, LUNORA_SKILL_NAMES, LUNORA_TAG, type LevelBadgeName, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LunoraFormattedLine, type LunoraLineLevel, LunoraReporter, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type PackageManager, type PackageManagerProbe, type ParseSchemaResult, type PostCodegenHookResult, type ProjectionPurpose, ROOT_SKILL_NAME, type RemotePreference, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type ToolchainCommand, type ToolchainInvocation, acceptsConnection, addArgsFor, advisoryLine, applyAdditiveEdit, applyLintIgnores, badgeLead, badgeWidth, blockingFindingsMessage, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, deployTargetIds, detectAgentRules, detectAiAgent, detectFramework, detectInstalledManagers, detectLintTools, detectPackageManager, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, ensureDevWorkerEnv, escapeRegExp, execArgsFor, fillDevSecrets, formatLunoraEvent, generateSecretValue, installArgsFor, interpretRemote, isCodegenDisabled, isDevServerReady, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, isRunnableTarget, lunoraLine, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planToolchainInvocation, projectUsesUmbrella, promptMultiSelect, promptSelect, promptText, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readProjectTarget, removeDevVariableLine, reportCodegenFindings, requiredSecrets, resolveDeployDriver, resolveProjectTarget, resolveSchemaDirectory, resolveTargetOrThrow, runPostCodegenHook, runScriptArgsFor, runScriptCommand, runnableTargetIds, secretsForPackages, startCelldDevSession, startDevProcess, streamContainerLogs, targetRunsOwnDevServer, toolchainExecArgs, updateDevServerState, upsertDevVariableLine, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };