@wolfstar/schema 0.3.0 → 0.4.0

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.
@@ -0,0 +1,750 @@
1
+ import { Diagnostic } from "nostics";
2
+ import { EventEmitter } from "node:events";
3
+ //#region src/config/validator.d.ts
4
+ /** Validates raw `stars.config` values, throwing a `configDiagnostics` diagnostic grounded in the configuration file. */
5
+ declare class Validator {
6
+ private readonly file;
7
+ constructor(file: string | null);
8
+ private get sources();
9
+ error<Handle extends (params: any) => Diagnostic>(handle: Handle, params: Parameters<Handle>[0]): Diagnostic;
10
+ knownKeys(value: object, path: string, keys: readonly string[]): void;
11
+ string(value: unknown, path: string): string | undefined;
12
+ boolean(value: unknown, path: string): boolean | undefined;
13
+ /** A plain object passed through as-is (e.g. raw `vite`/`tsdown` config merged into the project's own). */
14
+ plainObject(value: unknown, path: string): Record<string, unknown> | undefined;
15
+ stringArray(value: unknown, path: string): string[] | undefined;
16
+ nonNegativeNumber(value: unknown, path: string): number | undefined;
17
+ stringRecord(value: unknown, path: string): Record<string, string> | undefined;
18
+ /** A generic "wrong type" diagnostic. `fix` defaults to the standard "set it or remove it" wording. */
19
+ typeError(path: string, expected: string, value: unknown, fix?: string): Diagnostic;
20
+ }
21
+ //#endregion
22
+ //#region src/config/compatibility.d.ts
23
+ interface ResolvedFutureConfig {
24
+ readonly compatibilityVersion: StarsCompatibilityVersion;
25
+ }
26
+ declare const LEGACY_COMPATIBILITY_VERSION = 3;
27
+ declare const LATEST_COMPATIBILITY_VERSION = 5;
28
+ /** The version a project without `future.compatibilityVersion` runs on: today, the latest one. */
29
+ declare const DEFAULT_COMPATIBILITY_VERSION = 5;
30
+ /** Versions still accepted but scheduled for removal in the next major. */
31
+ declare const EOL_COMPATIBILITY_VERSIONS: ReadonlySet<number>;
32
+ /** From this version on, `tsdown` is configured from `stars.config` alone and auto imports are on by default. */
33
+ declare const STARS_CONFIG_TSDOWN_VERSION = 4;
34
+ /** From this version on, `env` is registered automatically in the built entry. */
35
+ declare const AUTO_ENV_VERSION = 5;
36
+ //#endregion
37
+ //#region src/config/env.d.ts
38
+ interface ResolvedEnvConfig {
39
+ /** Whether the built entry registers the environment before any other module. */
40
+ readonly enabled: boolean;
41
+ /** The options handed to `setup()` from `@wolfstar/env-utilities`, as written by the user. */
42
+ readonly options: Readonly<StarsEnvSetupOptions>;
43
+ }
44
+ /**
45
+ * Resolves the `env` block. It is on by default from {@link AUTO_ENV_VERSION} on, but only when the project depends on
46
+ * `@wolfstar/env-utilities` (the module the built entry imports) and does not build through Nitro, whose serverless
47
+ * presets have no `.env` files to load. `true`, `enabled: true` or any option at all is an explicit opt-in, which
48
+ * does require the dependency.
49
+ */
50
+ declare function resolveEnv(config: StarsConfig['env'], packageJson: PackageJsonLike | null, future: ResolvedFutureConfig, experimental: ResolvedExperimentalConfig, validator: Validator): ResolvedEnvConfig;
51
+ //#endregion
52
+ //#region src/config/hooks.d.ts
53
+ type AnyHook = StarsHooks[StarsHookName];
54
+ /** Every hook of `stars.config`, flattened to its full name, with its callbacks in declaration order. */
55
+ type ResolvedHooksConfig = Readonly<Partial<Record<StarsHookName, readonly AnyHook[]>>>;
56
+ declare const STARS_HOOK_NAMES: readonly ["config:resolved", "env:options", "prepare:before", "prepare:done", "builder:created", "tsdown:options", "build:before", "build:done", "dev:start", "dev:restart", "dev:close"];
57
+ /**
58
+ * Flattens and validates `hooks`. `hookable`'s own `flatHooks` is not used: it would split an array of callbacks into
59
+ * `name:0`, `name:1` and silently drop anything that is not a function, while a typo in a hook name here should fail
60
+ * loudly rather than register a hook that never runs.
61
+ */
62
+ declare function resolveHooks(config: StarsHooksConfig | undefined, validator: Validator): ResolvedHooksConfig;
63
+ //#endregion
64
+ //#region src/config/resolve.d.ts
65
+ interface PackageJsonLike {
66
+ name?: string;
67
+ /** `tsdown` reads its options from here as well as from a `tsdown.config.*`. */
68
+ tsdown?: unknown;
69
+ version?: string;
70
+ main?: string;
71
+ type?: string;
72
+ scripts?: Record<string, string>;
73
+ dependencies?: Record<string, string>;
74
+ devDependencies?: Record<string, string>;
75
+ }
76
+ interface ResolvedBuildConfig {
77
+ readonly tool: StarsBuildTool;
78
+ /** Absolute output directory. */
79
+ readonly outDir: string;
80
+ /** Absolute `tsconfig.json` used by `tsc`, `null` for the other tools. */
81
+ readonly tsconfig: string | null;
82
+ /** Absolute path of the file `node` runs, i.e. the built entry (or the entry itself when `tool` is `none`). */
83
+ readonly output: string;
84
+ /**
85
+ * Absolute path of the build tool's own configuration file (`tsdown.config.*`, `vite.config.*`), `null` when the
86
+ * tool has none — which is always the case for `tsdown` from `future.compatibilityVersion` 4 on, where the build is
87
+ * configured from `stars.config` alone.
88
+ */
89
+ readonly configFile: string | null;
90
+ }
91
+ interface ResolvedTypecheckConfig {
92
+ readonly enabled: boolean;
93
+ /** Absolute `tsconfig.json` the type checker runs against, `null` when it could not be found. */
94
+ readonly tsconfig: string | null;
95
+ /** The type checker to run, with `'auto'` already resolved. */
96
+ readonly checker: StarsTypechecker;
97
+ }
98
+ type ResolvedTunnelConfig = {
99
+ readonly mode: 'off';
100
+ } |
101
+ /** A `cloudflared` quick tunnel, whose hostname is only known once it is up. */
102
+ {
103
+ readonly mode: 'quick';
104
+ readonly path: string;
105
+ readonly updateEndpoint: boolean;
106
+ } |
107
+ /** An https URL the user already serves. */
108
+ {
109
+ readonly mode: 'url';
110
+ readonly url: string;
111
+ readonly path: string;
112
+ readonly updateEndpoint: boolean;
113
+ };
114
+ interface ResolvedDevConfig {
115
+ readonly banner: readonly string[] | false | null;
116
+ readonly watch: readonly string[];
117
+ readonly ignore: readonly string[];
118
+ readonly debounce: number;
119
+ readonly env: Readonly<Record<string, string>>;
120
+ readonly nodeArgs: readonly string[];
121
+ readonly args: readonly string[];
122
+ readonly url: string | null;
123
+ readonly health: string | null;
124
+ readonly killTimeout: number;
125
+ readonly typecheck: ResolvedTypecheckConfig;
126
+ readonly tunnel: ResolvedTunnelConfig;
127
+ /** Absolute path of the file the dev session's logs are mirrored into, `null` when disabled. */
128
+ readonly logFile: string | null;
129
+ }
130
+ interface ResolvedNitroConfig {
131
+ readonly [option: string]: unknown;
132
+ readonly preset: string;
133
+ }
134
+ interface ResolvedExperimentalConfig {
135
+ readonly enableVite: boolean;
136
+ readonly enableExternalVite: boolean;
137
+ readonly enableNitro: boolean;
138
+ readonly nitro: ResolvedNitroConfig;
139
+ }
140
+ interface ResolvedImportsConfig {
141
+ readonly enabled: boolean;
142
+ /** Directory glob patterns, relative to the project root (the way `unimport` scans them). */
143
+ readonly dirs: readonly string[];
144
+ readonly presets: readonly string[];
145
+ readonly exclude: readonly string[];
146
+ /** Absolute path of the generated declaration file. */
147
+ readonly dts: string;
148
+ }
149
+ interface ResolvedI18nCodegenConfig {
150
+ readonly locales: string;
151
+ readonly output: string;
152
+ }
153
+ interface ResolvedCodegenConfig {
154
+ readonly i18n: ResolvedI18nCodegenConfig | null;
155
+ }
156
+ interface ResolvedStarsConfig {
157
+ /** Absolute path of the configuration file, `null` when running on defaults. */
158
+ readonly configFile: string | null;
159
+ /** The directory the CLI was invoked from. */
160
+ readonly cwd: string;
161
+ /** Absolute project root. */
162
+ readonly root: string;
163
+ readonly packageJson: PackageJsonLike | null;
164
+ /** Absolute source entry. */
165
+ readonly entry: string;
166
+ readonly build: ResolvedBuildConfig;
167
+ readonly dev: ResolvedDevConfig;
168
+ readonly codegen: ResolvedCodegenConfig;
169
+ readonly imports: ResolvedImportsConfig;
170
+ readonly env: ResolvedEnvConfig;
171
+ /** The `hooks` block, flattened to full hook names (`build:done`). */
172
+ readonly hooks: ResolvedHooksConfig;
173
+ readonly experimental: ResolvedExperimentalConfig;
174
+ readonly future: ResolvedFutureConfig;
175
+ /** Raw options merged into `vite.config.*`. */
176
+ readonly vite: Readonly<Record<string, unknown>>;
177
+ /** The `tsdown` build's options: merged over `tsdown.config.*` at compatibility version 3, the whole build from 4 on. */
178
+ readonly tsdown: Readonly<Record<string, unknown>>;
179
+ /** Non-fatal diagnostics (e.g. an end-of-life compatibility version), for the host to report. */
180
+ readonly warnings: readonly Diagnostic[];
181
+ }
182
+ interface ResolveConfigOptions {
183
+ cwd: string;
184
+ configFile: string | null;
185
+ config: StarsConfig;
186
+ env?: NodeJS.ProcessEnv;
187
+ /**
188
+ * The variables the bot will load, when the host resolved them itself (e.g. through `varlock load`). Used instead
189
+ * of the project's env files for the defaults read from them, such as the `dev.url` port.
190
+ */
191
+ projectEnv?: Readonly<Record<string, string>>;
192
+ }
193
+ /**
194
+ * Applies defaults, validates every option and resolves all paths to absolute ones.
195
+ *
196
+ * @throws {Diagnostic} (from `nostics`, via {@link configDiagnostics}) with an actionable `fix` on the first invalid option.
197
+ */
198
+ declare function resolveStarsConfig(options: ResolveConfigOptions): ResolvedStarsConfig;
199
+ /**
200
+ * Presents an absolute path relative to `root` when possible, for display purposes.
201
+ */
202
+ declare function displayPath(root: string, path: string): string;
203
+ /**
204
+ * Reads the project's environment layers from `src/.env*` and `.env*` into a plain object, the way `stars dev` and
205
+ * `stars commands` need it:
206
+ * these files are only loaded into `process.env` by the bot itself once it starts (see `@wolfstar/env-utilities`),
207
+ * so by the time the CLI runs they are not there yet. This is a minimal line reader, not a full dotenv
208
+ * implementation — quoting is stripped, but expansion (`dotenv-expand`) is not. Earlier files win, matching
209
+ * dotenv's own precedence.
210
+ */
211
+ declare function readProjectEnvFiles(root: string, environment?: string, options?: {
212
+ path?: string;
213
+ }): Record<string, string>;
214
+ //#endregion
215
+ //#region src/types/builder.d.ts
216
+ type BuilderLogLevel = 'debug' | 'info' | 'success' | 'warn' | 'error';
217
+ interface BuildOutcome {
218
+ ok: boolean;
219
+ durationMs: number;
220
+ /** A one-line summary, e.g. the first error. */
221
+ message: string | null;
222
+ }
223
+ interface BuilderEvents {
224
+ start: [];
225
+ /** Coarse, real lifecycle milestones, not an estimate of compiler work remaining. */
226
+ progress: [fraction: number, message: string];
227
+ success: [outcome: BuildOutcome];
228
+ failure: [outcome: BuildOutcome];
229
+ log: [level: BuilderLogLevel, text: string];
230
+ }
231
+ /**
232
+ * Turns project sources into the runnable output, once or continuously.
233
+ * Implementations report progress through {@link BuilderEvents}.
234
+ */
235
+ interface Builder extends EventEmitter<BuilderEvents> {
236
+ readonly tool: StarsBuildTool;
237
+ /** Runs a single build. Compilation failures are reported in the outcome; dependency loading may throw. */
238
+ build(): Promise<BuildOutcome>;
239
+ /** Starts watching. Resolves once the watcher is set up; builds are reported through events. */
240
+ watch(): Promise<void>;
241
+ /** Stops watching. */
242
+ close(): Promise<void>;
243
+ }
244
+ /** Services supplied by the host; server integrations never import the CLI. */
245
+ interface BuilderContext {
246
+ /** Resolve build dependencies from the consuming project and report missing dependencies. */
247
+ importFromProject<T>(root: string, id: string, hint: string): Promise<T>;
248
+ /** Create the host's entry transformation for installed plugin registrations. */
249
+ pluginRegistrations(config: ResolvedStarsConfig): object;
250
+ }
251
+ //#endregion
252
+ //#region src/types/hooks.d.ts
253
+ type HookResult = void | Promise<void>;
254
+ /** Why `stars dev` (re)started the bot. */
255
+ type StarsRestartReason = 'initial' | 'build' | 'manual' | 'crash';
256
+ /** What `stars prepare` generated. */
257
+ interface PrepareProjectResult {
258
+ /** Absolute path of the generated auto imports declaration file, `null` when auto imports are off. */
259
+ readonly dts: string | null;
260
+ readonly status: 'written' | 'up-to-date' | 'outdated' | null;
261
+ }
262
+ /**
263
+ * Lifecycle hooks of the `stars` CLI, registered through `hooks` in `stars.config` and run with
264
+ * [`hookable`](https://github.com/unjs/hookable). They run in the CLI process, never in the bot: use `env:options`
265
+ * to change what the bot receives.
266
+ */
267
+ interface StarsHooks {
268
+ /** The configuration was loaded and validated. */
269
+ 'config:resolved': (config: ResolvedStarsConfig) => HookResult;
270
+ /** The `env` options about to be written into the built entry. Mutate `options` to change them. */
271
+ 'env:options': (options: StarsEnvSetupOptions, config: ResolvedStarsConfig) => HookResult;
272
+ /** Before `.stars/` is generated. */
273
+ 'prepare:before': (config: ResolvedStarsConfig) => HookResult;
274
+ /** After `.stars/` is generated. */
275
+ 'prepare:done': (config: ResolvedStarsConfig, result: PrepareProjectResult) => HookResult;
276
+ /** The builder for `build.tool` exists but has not built yet. */
277
+ 'builder:created': (builder: Builder, config: ResolvedStarsConfig) => HookResult;
278
+ /** The options about to be handed to `tsdown.build()`. Mutate `options` to change them. */
279
+ 'tsdown:options': (options: Record<string, unknown>, config: ResolvedStarsConfig) => HookResult;
280
+ /** A build (or, in `stars dev`, a rebuild) starts. */
281
+ 'build:before': (config: ResolvedStarsConfig) => HookResult;
282
+ /** A build (or rebuild) finished, successfully or not — see `outcome.ok`. */
283
+ 'build:done': (outcome: BuildOutcome, config: ResolvedStarsConfig) => HookResult;
284
+ /** `stars dev` is watching. */
285
+ 'dev:start': (config: ResolvedStarsConfig) => HookResult;
286
+ /** `stars dev` is about to (re)start the bot. */
287
+ 'dev:restart': (reason: StarsRestartReason, config: ResolvedStarsConfig) => HookResult;
288
+ /** `stars dev` is shutting down. */
289
+ 'dev:close': (config: ResolvedStarsConfig) => HookResult;
290
+ }
291
+ type StarsHookName = keyof StarsHooks;
292
+ type HookOrList<Callback> = Callback | readonly Callback[];
293
+ type NamespaceOf<Name> = Name extends `${infer Namespace}:${string}` ? Namespace : never;
294
+ type StarsHookNamespace = NamespaceOf<StarsHookName>;
295
+ /**
296
+ * The `hooks` block of `stars.config`: each hook keyed by its full name (`'build:done'`) or nested under its namespace
297
+ * (`{ build: { done() {} } }`), as a function or an array of functions.
298
+ */
299
+ type StarsHooksConfig = { [Name in StarsHookName]?: HookOrList<StarsHooks[Name]>; } & { [Namespace in StarsHookNamespace]?: { [Name in StarsHookName as Name extends `${Namespace}:${infer Rest}` ? Rest : never]?: HookOrList<StarsHooks[Name]>; }; };
300
+ //#endregion
301
+ //#region src/types/config.d.ts
302
+ /**
303
+ * The build tool used to turn the project sources into runnable JavaScript.
304
+ *
305
+ * - `tsdown`: run the project's own `tsdown` programmatically, configured from {@link StarsConfig.tsdown} (and, with
306
+ * {@link StarsFutureConfig.compatibilityVersion} `3`, from the project's `tsdown.config.*` too).
307
+ * - `tsc`: run the project's `tsc -b` on the configured `tsconfig`.
308
+ * - `vite`: run the project's own `vite` (configuration file included), requires `experimental.enableVite`.
309
+ * - `none`: the entry is runnable as-is (JavaScript projects), no build step.
310
+ * - `auto`: detect from the project (default).
311
+ */
312
+ type StarsBuildTool = 'tsdown' | 'tsc' | 'none' | 'vite';
313
+ interface StarsBuildConfig {
314
+ /**
315
+ * The build tool to use.
316
+ * @default 'auto'
317
+ */
318
+ tool?: StarsBuildTool | 'auto';
319
+ /**
320
+ * The directory, relative to {@link StarsConfig.root}, the build writes into.
321
+ * @default 'dist', or '.output' when `experimental.enableNitro` is on (Nitro's own convention)
322
+ */
323
+ outDir?: string;
324
+ /**
325
+ * The `tsconfig.json` the `tsc` and `tsdown` build tools use, relative to {@link StarsConfig.root}.
326
+ * @default 'src/tsconfig.json' when it exists, 'tsconfig.json' otherwise
327
+ */
328
+ tsconfig?: string;
329
+ }
330
+ /**
331
+ * Raw options merged into the project's own `vite.config.*`, the way `vite: {}` in a Nuxt config is merged into
332
+ * Nuxt's own Vite config. Kept as `unknown` here (the CLI, not the framework, depends on `vite`'s types) and passed
333
+ * to Vite's `mergeConfig` as-is.
334
+ */
335
+ type StarsViteConfig = Record<string, unknown>;
336
+ /**
337
+ * Options for `tsdown`, the bundler `stars build` uses by default.
338
+ *
339
+ * From {@link StarsFutureConfig.compatibilityVersion} `4` on these replace `tsdown.config.*` outright: the build is
340
+ * derived from `stars.config` (the entry's directory, `build.outDir`, `build.tsconfig`) and these options are layered
341
+ * on top, so a project keeps one configuration file instead of two. With `3` the project's own `tsdown.config.*` is
342
+ * still loaded and these are merged over it, the way `vite: {}` in a Nuxt config is merged into the project's own
343
+ * Vite config: values here win, and `plugins` are appended rather than replaced.
344
+ *
345
+ * The options named below are the ones a bot usually reaches for. Every other `tsdown` option is accepted as-is —
346
+ * the framework does not depend on `tsdown`, so they stay loosely typed here and `tsdown`'s own `UserConfig` is the
347
+ * reference.
348
+ */
349
+ interface StarsTsdownConfig {
350
+ /** Entry files or glob patterns, relative to the project root. Defaults to every source file next to `entry`. */
351
+ entry?: string | readonly string[] | Record<string, string>;
352
+ /** @default 'esm' */
353
+ format?: 'esm' | 'cjs' | 'iife' | 'umd' | readonly string[] | Record<string, unknown>;
354
+ /** @default 'node' */
355
+ platform?: 'node' | 'neutral' | 'browser';
356
+ target?: string | readonly string[] | false;
357
+ /**
358
+ * Emits one output file per source file instead of a single bundle, so pieces stay loadable from `dist/commands`
359
+ * and friends at runtime.
360
+ * @default true
361
+ */
362
+ unbundle?: boolean;
363
+ /** Rolldown plugins. Appended to the ones `stars` adds (auto imports) and to those of a `tsdown.config.*`. */
364
+ plugins?: readonly unknown[];
365
+ alias?: Record<string, string>;
366
+ define?: Record<string, string>;
367
+ external?: unknown;
368
+ noExternal?: unknown;
369
+ deps?: Record<string, unknown>;
370
+ /** @default () => ({ js: extname(build.output) }) */
371
+ outExtensions?: unknown;
372
+ /** @default true */
373
+ sourcemap?: boolean | 'inline' | 'hidden';
374
+ minify?: unknown;
375
+ /** @default false — a bot is not a library, so no declaration files are emitted. */
376
+ dts?: boolean | Record<string, unknown>;
377
+ /** @default true */
378
+ clean?: boolean | readonly string[];
379
+ treeshake?: boolean;
380
+ copy?: unknown;
381
+ hooks?: Record<string, unknown>;
382
+ [option: string]: unknown;
383
+ }
384
+ /**
385
+ * The build-default generation the project runs on. Version 5 is current and version 4 remains supported.
386
+ * Version 3 is end-of-life: it still resolves, with a warning, and is removed in the next major.
387
+ */
388
+ type StarsCompatibilityVersion = 3 | 4 | 5;
389
+ /**
390
+ * Nuxt-style compatibility block. New projects need not set it; version 4 stays available, and version 3 is kept only
391
+ * as an end-of-life migration escape hatch for projects that still use a standalone `tsdown.config.*`.
392
+ */
393
+ interface StarsFutureConfig {
394
+ /**
395
+ * The major whose defaults apply.
396
+ *
397
+ * `5` is the default: everything in `4`, plus `env` registered automatically in the built entry
398
+ * (see {@link StarsConfig.env}) when the project depends on `@wolfstar/env-utilities`.
399
+ *
400
+ * `4`:
401
+ * - auto imports are on by default with the `tsdown` build tool ({@link StarsImportsConfig}), and the
402
+ * `autoImports()` plugin is wired into the build by `stars` itself.
403
+ * - `tsdown` is configured from {@link StarsConfig.tsdown} only. A `tsdown.config.*` in the project root is
404
+ * rejected rather than silently ignored, so a build never loses the plugins it declares.
405
+ * - `build.tool: 'auto'` resolves to `tsdown` for any TypeScript entry, without looking for a `tsdown.config.*`
406
+ * or a `tsdown` dependency first.
407
+ * - `env` is opt-in.
408
+ *
409
+ * `3` (**end-of-life**) keeps the legacy behaviour: auto imports off unless asked for, and a `tsdown.config.*`
410
+ * loaded and merged with {@link StarsConfig.tsdown}. It prints a warning and is removed in the next major.
411
+ * @default 5
412
+ */
413
+ compatibilityVersion?: StarsCompatibilityVersion;
414
+ }
415
+ /**
416
+ * The type checker `stars dev` runs next to the bot.
417
+ *
418
+ * - `tsc`: the project's own TypeScript, in watch mode.
419
+ * - `golar`: the project's `golar`, forwarding to TypeScript (`golar tsc`), in watch mode.
420
+ * - `tsz`: the project's `tsz` (or `try-tsz`). It has no watch mode, so it is re-run after every build instead.
421
+ * - `auto`: `golar` when the project depends on it, `tsc` otherwise (default).
422
+ */
423
+ type StarsTypechecker = 'tsc' | 'golar' | 'tsz';
424
+ interface StarsTypecheckConfig {
425
+ /**
426
+ * The `tsconfig.json` the type checker runs against, relative to {@link StarsConfig.root}.
427
+ * @default the build tool's tsconfig, 'src/tsconfig.json' or 'tsconfig.json'
428
+ */
429
+ tsconfig?: string;
430
+ /**
431
+ * Which type checker to run.
432
+ * @default 'auto'
433
+ */
434
+ checker?: StarsTypechecker | 'auto';
435
+ }
436
+ interface StarsTunnelConfig {
437
+ /**
438
+ * An https URL you already serve; when unset a `cloudflared` quick tunnel is opened instead.
439
+ */
440
+ url?: string;
441
+ /**
442
+ * Writes the tunnel's URL to the Discord application's `interactions_endpoint_url` when it changes.
443
+ *
444
+ * This edits a live Discord application, so it is opt-in: it needs `DISCORD_TOKEN` and `DISCORD_APPLICATION_ID`
445
+ * (or `APPLICATION_ID`) in the environment or the project's `.env`.
446
+ * @default false
447
+ */
448
+ updateEndpoint?: boolean;
449
+ /**
450
+ * The path the interactions endpoint is served on, appended to the tunnel URL.
451
+ * @default '/'
452
+ */
453
+ path?: string;
454
+ }
455
+ interface StarsDevConfig {
456
+ /** Custom terminal wordmark (one or more lines), or `false` to hide it. Defaults to the Stars wordmark. */
457
+ banner?: string | readonly string[] | false;
458
+ /**
459
+ * Extra paths to watch, relative to {@link StarsConfig.root}. Only used when
460
+ * the build tool is `none`; `tsdown` and `tsc` watch through their own build.
461
+ * @default [dirname(entry)]
462
+ */
463
+ watch?: string[];
464
+ /**
465
+ * Glob patterns or paths to ignore while watching, relative to {@link StarsConfig.root}.
466
+ * @default ['**\/node_modules/**', '**\/dist/**', '**\/.git/**']
467
+ */
468
+ ignore?: string[];
469
+ /**
470
+ * Milliseconds to wait after a change before restarting the bot.
471
+ * @default 150
472
+ */
473
+ debounce?: number;
474
+ /**
475
+ * Environment variables added to the bot process.
476
+ */
477
+ env?: Record<string, string>;
478
+ /**
479
+ * Arguments passed to `node` before the entry file.
480
+ * @default ['--enable-source-maps']
481
+ */
482
+ nodeArgs?: string[];
483
+ /**
484
+ * Arguments passed to the bot after the entry file.
485
+ * @default []
486
+ */
487
+ args?: string[];
488
+ /**
489
+ * The URL the bot listens on, shown in the dev UI's status line and used for {@link StarsDevConfig.health}.
490
+ *
491
+ * Resolved automatically, the way Vite's and Nuxt's dev servers do, from (in order) `dev.env.HTTP_PORT`, the
492
+ * process's `HTTP_PORT`, the project's `src/.env*`/`.env*` (`HTTP_PORT` or `PORT`), or `3000`. `stars dev` also
493
+ * resolves whether `localhost` should be shown as `127.0.0.1` instead, the same DNS-order check Vite does, so the
494
+ * printed URL is always the one that is actually reachable.
495
+ * @default `http://localhost:3000` (or whichever port is found)
496
+ */
497
+ url?: string;
498
+ /**
499
+ * A path, relative to {@link StarsDevConfig.url}, polled to report the bot's health in the dev UI.
500
+ * When unset the dev UI only reports process state.
501
+ */
502
+ health?: string;
503
+ /**
504
+ * Milliseconds to wait for the bot to exit after `SIGTERM` before killing it.
505
+ * @default 5000
506
+ */
507
+ killTimeout?: number;
508
+ /**
509
+ * Runs a type checker next to the bot and reports type errors on the dev UI's `tsc` channel, without blocking
510
+ * builds or restarts. `true` uses the project's own tsconfig and type checker, an object picks either
511
+ * ({@link StarsTypecheckConfig.checker}).
512
+ * @default false
513
+ */
514
+ typecheck?: boolean | StarsTypecheckConfig;
515
+ /**
516
+ * Exposes the bot's HTTP interactions endpoint publicly while `stars dev` runs, so Discord can reach it.
517
+ *
518
+ * `true` opens a `cloudflared` quick tunnel (its hostname changes on every run), a string is an https URL you
519
+ * already serve yourself (named tunnel, reverse proxy, …) that the CLI only checks for reachability.
520
+ * @default false
521
+ */
522
+ tunnel?: boolean | string | StarsTunnelConfig;
523
+ /**
524
+ * The file `stars dev` mirrors its logs into, relative to {@link StarsConfig.root}, so a session can be read back
525
+ * after the terminal UI is gone. `false` disables it.
526
+ * @default '.stars/dev.log'
527
+ */
528
+ logFile?: string | false;
529
+ }
530
+ interface StarsI18nCodegenConfig {
531
+ /**
532
+ * The base locale directory, relative to {@link StarsConfig.root}.
533
+ * @default 'src/locales/en-US'
534
+ */
535
+ locales?: string;
536
+ /**
537
+ * The generated declaration file, relative to {@link StarsConfig.root}.
538
+ * @default 'src/@types/i18next.d.ts'
539
+ */
540
+ output?: string;
541
+ }
542
+ interface StarsCodegenConfig {
543
+ /**
544
+ * i18next type generation through `@wolfstar/i18next-type-generator`.
545
+ * `false` disables it, an object enables it, unset auto-detects from the presence of the locales directory.
546
+ */
547
+ i18n?: StarsI18nCodegenConfig | false;
548
+ }
549
+ interface StarsImportsConfig {
550
+ /**
551
+ * Whether auto imports are enabled. Requires the `tsdown` build tool: the imports are injected at build time by
552
+ * the `autoImports()` plugin from `@wolfstar/http-framework/auto-imports`, which the other tools cannot run.
553
+ * @default true when the build tool is 'tsdown', false otherwise
554
+ */
555
+ enabled?: boolean;
556
+ /**
557
+ * Directories, relative to {@link StarsConfig.root}, whose exported values are auto-importable. Entries are glob
558
+ * path patterns: `'src/lib'` scans only the files directly inside it, `'src/lib/**'` scans recursively.
559
+ * @default ['src/lib/**', 'src/utils/**']
560
+ */
561
+ dirs?: string[];
562
+ /**
563
+ * Packages whose exports are auto-importable. Packages that are not installed are skipped.
564
+ * @default ['@wolfstar/http-framework', '@wolfstar/decorators', '@wolfstar/env-utilities']
565
+ */
566
+ presets?: string[];
567
+ /**
568
+ * Export names excluded from auto imports, e.g. to avoid clashes with project-local names.
569
+ * @default []
570
+ */
571
+ exclude?: string[];
572
+ /**
573
+ * The generated declaration file that types the auto imports, relative to {@link StarsConfig.root}.
574
+ * Include it in the project's tsconfig and add its directory to .gitignore.
575
+ * @default '.stars/imports.d.ts'
576
+ */
577
+ dts?: string;
578
+ }
579
+ /**
580
+ * The [Nitro preset](https://nitro.build/deploy) `stars build` targets, only reachable once
581
+ * {@link StarsExperimentalConfig.enableNitro} (itself gated on {@link StarsExperimentalConfig.enableVite}) is `true`
582
+ * — see {@link StarsExperimentalConfig}.
583
+ */
584
+ interface StarsNitroConfig {
585
+ /** Additional Nitro options (routeRules, runtimeConfig, storage, publicAssets, hooks, etc.).
586
+ * Use `defineNitroConfig` from `@wolfstar/nitro-server` for upstream option completion.
587
+ * Stars owns rootDir, serverEntry, output.dir and the reserved virtual entry.
588
+ */
589
+ [option: string]: unknown;
590
+ /**
591
+ * `'node-server'` (the default, runs locally with plain `node`), `'cloudflare-module'`, `'aws-lambda'`,
592
+ * `'vercel'`, `'netlify'`, `'bun'`, `'deno-deploy'`, and more — see Nitro's own preset list.
593
+ * @default 'node-server'
594
+ */
595
+ preset?: string;
596
+ }
597
+ /**
598
+ * Opt-in flags for work that is still landing, in the shape Nuxt's own `experimental` block has: every flag is a
599
+ * boolean, defaults to `false`, and is documented with what it changes and what it still needs. A flag stays here
600
+ * until the behaviour it guards is the default (or is dropped), so enabling one is a statement that breakage is
601
+ * acceptable in exchange for the feature.
602
+ *
603
+ * `enableExternalVite`, `enableNitro` and `nitro` build on `enableVite` (and `nitro` on `enableNitro` too): the type
604
+ * only accepts them once their prerequisite is `true`, so turning one on without the other is a type error here
605
+ * instead of a diagnostic at load time.
606
+ */
607
+ type StarsExperimentalConfig = {
608
+ enableVite?: false;
609
+ enableExternalVite?: false;
610
+ enableNitro?: false;
611
+ } | {
612
+ /**
613
+ * Uses Vite as the project's build tool, in place of `tsdown`. `build.tool` may then be set to `'vite'`
614
+ * (and `'auto'` detects a `vite.config.*`); the bot keeps calling `client.listen()` and running as a
615
+ * plain `node:http` process, restarted on every change — this only swaps the bundler.
616
+ */
617
+ enableVite: true;
618
+ /**
619
+ * Runs the bot through Vite itself, the way `nuxt dev` runs on Vite's own dev server: instead of
620
+ * building then restarting a child `node` process on every change, `stars dev` loads the entry through
621
+ * Vite's SSR module graph and serves it — through `Client#fetch` — from one long-lived process,
622
+ * invalidating and re-evaluating just the entry's module graph on a change instead of restarting.
623
+ *
624
+ * With this on, the entry's default export must be the `Client` instance (already `load()`ed, not
625
+ * `listen()`ed) rather than a script that calls `client.listen()` itself — `stars dev` owns the socket.
626
+ * @default false
627
+ */
628
+ enableExternalVite?: boolean;
629
+ enableNitro?: false;
630
+ } | {
631
+ enableVite: true;
632
+ enableExternalVite?: boolean;
633
+ /**
634
+ * Builds the bot through [Nitro](https://nitro.build) instead of a `node:http` server, so `stars build`
635
+ * produces a server deployable to any of Nitro's presets (`node-server` locally, `cloudflare-module`,
636
+ * `aws-lambda`, `vercel`, `netlify`, `bun`, `deno-deploy`, and more). Nitro v3 is itself a Vite plugin, so
637
+ * this builds through the project's own `vite.config.*`/{@link StarsConfig.vite} the same way `build.tool:
638
+ * 'vite'` does, with a generated server entry that wraps the entry's default export (the `Client`
639
+ * instance, already `load()`ed rather than `listen()`ed — `stars build`/`stars dev` own the socket) in a
640
+ * call to `Client#fetch` — no per-preset adapter to maintain.
641
+ *
642
+ * Output goes to `.output/` (Nitro's own convention) instead of `build.outDir`. `stars dev` rebuilds and
643
+ * restarts on every change, the same as the other build tools.
644
+ */
645
+ enableNitro: true;
646
+ /** Nitro-specific options, reachable only with `enableNitro: true`. */
647
+ nitro?: StarsNitroConfig;
648
+ };
649
+ /**
650
+ * The serializable subset of `@wolfstar/env-utilities`' `EnvSetupOptions`. These options are written into the built
651
+ * entry as JSON, which is why `path` is a string only and `processEnv` is not available. A type test in
652
+ * `@wolfstar/env-utilities` keeps the two in sync.
653
+ */
654
+ interface StarsEnvSetupOptions {
655
+ /**
656
+ * A custom `.env` path. Kept relative: `@wolfstar/env-utilities` resolves it against the bot's working directory
657
+ * at runtime, so the build output does not depend on the machine it was built on.
658
+ * @default `src/.env*`, then `.env*`
659
+ */
660
+ path?: string;
661
+ /** A custom environment name, when `NODE_ENV` is not sufficient. */
662
+ env?: string;
663
+ /** Only keep the variables starting with this prefix (e.g. `BOT_`). */
664
+ prefix?: string;
665
+ /**
666
+ * **Experimental.** `'varlock'` resolves the environment through [varlock](https://varlock.dev) instead of dotenv.
667
+ * @default 'dotenv'
668
+ */
669
+ loader?: 'dotenv' | 'varlock';
670
+ /** Logs every file loaded and every prefix match. */
671
+ debug?: boolean;
672
+ /**
673
+ * The encoding of the `.env` files.
674
+ * @default 'utf8'
675
+ */
676
+ encoding?: string;
677
+ }
678
+ /**
679
+ * The environment `stars` registers in the built entry before any other module runs, the way a hand-written
680
+ * `setup()` from `@wolfstar/env-utilities` would. On by default from `future.compatibilityVersion: 5` when the project
681
+ * depends on `@wolfstar/env-utilities`, except with `experimental.enableNitro`.
682
+ */
683
+ interface StarsEnvConfig extends StarsEnvSetupOptions {
684
+ /** `false` turns the automatic registration off while keeping the options (e.g. for `stars dev`'s port lookup). */
685
+ enabled?: boolean;
686
+ }
687
+ interface StarsConfig {
688
+ /**
689
+ * The project root. Relative paths are resolved from the configuration file.
690
+ * @default dirname(configFile)
691
+ */
692
+ root?: string;
693
+ /**
694
+ * The source entry point of the bot, relative to {@link StarsConfig.root}.
695
+ * @default the first of 'src/main.ts', 'src/main.js', 'src/index.ts', 'src/index.js' that exists
696
+ */
697
+ entry?: string;
698
+ build?: StarsBuildConfig;
699
+ dev?: StarsDevConfig;
700
+ codegen?: StarsCodegenConfig;
701
+ /**
702
+ * Nuxt-style auto imports of the framework's exports and the project's own modules.
703
+ * `false` disables them, `true` forces them on (requires the `tsdown` build tool). On by default with
704
+ * `future.compatibilityVersion` 4 and later.
705
+ */
706
+ imports?: StarsImportsConfig | boolean;
707
+ /**
708
+ * `@wolfstar/env-utilities` options, registered automatically before the bot's own modules run.
709
+ * `false` disables the automatic registration, `true` forces it on with defaults.
710
+ */
711
+ env?: StarsEnvConfig | boolean;
712
+ /**
713
+ * Lifecycle hooks of the `stars` CLI (see `StarsHooks`), keyed by full name (`'build:done'`) or nested under
714
+ * their namespace (`{ build: { done() {} } }`). Each value is a function or an array of functions.
715
+ */
716
+ hooks?: StarsHooksConfig;
717
+ /** Opt-in flags for behaviour that is still landing. */
718
+ experimental?: StarsExperimentalConfig;
719
+ /** Build-default compatibility. Omit for version 5; version 3 is end-of-life and only meant for migrating a standalone tsdown config. */
720
+ future?: StarsFutureConfig;
721
+ /**
722
+ * Raw options merged into `vite.config.*`, the way `vite: {}` in a Nuxt config is merged into Nuxt's own Vite
723
+ * config. Only used with `build.tool: 'vite'` (see `experimental.enableVite`).
724
+ */
725
+ vite?: StarsViteConfig;
726
+ /**
727
+ * The project's `tsdown` build. Replaces `tsdown.config.*` from `future.compatibilityVersion: 4` on, and is merged
728
+ * over it with `3`. Only used with `build.tool: 'tsdown'`.
729
+ */
730
+ tsdown?: StarsTsdownConfig;
731
+ }
732
+ //#endregion
733
+ //#region src/config.d.ts
734
+ /**
735
+ * Typed helper for `stars.config.{ts,mts,cts,js,mjs,cjs}` files.
736
+ *
737
+ * @example
738
+ * ```ts
739
+ * import { defineConfig } from '@wolfstar/http-framework/config';
740
+ *
741
+ * export default defineConfig({
742
+ * entry: 'src/main.ts',
743
+ * build: { tool: 'tsdown' }
744
+ * });
745
+ * ```
746
+ */
747
+ declare function defineConfig(config: StarsConfig): StarsConfig;
748
+ //#endregion
749
+ export { EOL_COMPATIBILITY_VERSIONS as $, BuilderLogLevel as A, ResolvedStarsConfig as B, StarsHooks as C, Builder as D, BuildOutcome as E, ResolvedDevConfig as F, resolveStarsConfig as G, ResolvedTypecheckConfig as H, ResolvedExperimentalConfig as I, resolveHooks as J, ResolvedHooksConfig as K, ResolvedI18nCodegenConfig as L, ResolveConfigOptions as M, ResolvedBuildConfig as N, BuilderContext as O, ResolvedCodegenConfig as P, DEFAULT_COMPATIBILITY_VERSION as Q, ResolvedImportsConfig as R, StarsHookNamespace as S, StarsRestartReason as T, displayPath as U, ResolvedTunnelConfig as V, readProjectEnvFiles as W, resolveEnv as X, ResolvedEnvConfig as Y, AUTO_ENV_VERSION as Z, StarsTypecheckConfig as _, StarsCompatibilityVersion as a, PrepareProjectResult as b, StarsEnvConfig as c, StarsFutureConfig as d, LATEST_COMPATIBILITY_VERSION as et, StarsI18nCodegenConfig as f, StarsTunnelConfig as g, StarsTsdownConfig as h, StarsCodegenConfig as i, PackageJsonLike as j, BuilderEvents as k, StarsEnvSetupOptions as l, StarsNitroConfig as m, StarsBuildConfig as n, ResolvedFutureConfig as nt, StarsConfig as o, StarsImportsConfig as p, STARS_HOOK_NAMES as q, StarsBuildTool as r, STARS_CONFIG_TSDOWN_VERSION as rt, StarsDevConfig as s, defineConfig as t, LEGACY_COMPATIBILITY_VERSION as tt, StarsExperimentalConfig as u, StarsTypechecker as v, StarsHooksConfig as w, StarsHookName as x, StarsViteConfig as y, ResolvedNitroConfig as z };
750
+ //# sourceMappingURL=config-Ctpk84fx.d.ts.map