@wolfstar/http-framework 3.4.0-next-20260903210435 → 3.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.
package/README.md CHANGED
@@ -460,6 +460,87 @@ client.on(Events.HmrPieceReloaded, async (piece) => {
460
460
  > registered exactly once. HMR does not push the updated commands to Discord on its own, subscribe to the events above
461
461
  > if you want that behaviour.
462
462
 
463
+ ### Project configuration (`stars.config.*`)
464
+
465
+ `@wolfstar/http-framework` owns the typed project configuration consumed by the [`stars` CLI](../cli) — the
466
+ `defineConfig` helper and the config loader live here, not in the CLI, so any tool can resolve a project's
467
+ configuration without pulling in `@wolfstar/cli`.
468
+
469
+ ```typescript
470
+ // stars.config.ts
471
+ import { defineConfig } from '@wolfstar/http-framework/config';
472
+
473
+ export default defineConfig({
474
+ entry: 'src/main.ts',
475
+ build: { tool: 'tsdown' }
476
+ });
477
+ ```
478
+
479
+ `@wolfstar/http-framework/config` has no side effects — importing it (or a `stars.config.ts` that imports it) never
480
+ starts the bot. `loadStarsConfig` discovers `stars.config.{ts,mts,cts,js,mjs,cjs}` from a directory, applies defaults,
481
+ validates every option and resolves all paths to absolute ones.
482
+
483
+ `dev.url`, the URL `stars dev` shows and health-checks the bot on, needs no configuration either: it is detected the
484
+ way Vite's and Nuxt's dev servers are, from `HTTP_PORT` (env var, `.env.local`/`.env`, or `dev.env`) or `3000`, and
485
+ `localhost` is swapped for `127.0.0.1` at runtime if that is what is actually reachable. Set `dev.url` explicitly only
486
+ to override it, e.g. for a LAN address: `dev: { url: 'http://192.168.1.5:3000' }`.
487
+
488
+ `dev` also carries the three options that round out the dev loop:
489
+
490
+ ```typescript
491
+ export default defineConfig({
492
+ entry: 'src/main.ts',
493
+ build: { tool: 'tsdown' },
494
+ dev: {
495
+ // A type checker next to the bot, reported on the dev UI's `tsc` channel. Never blocks a build.
496
+ // `checker` is 'tsc' | 'golar' | 'tsz' | 'auto' (default: golar when installed, tsc otherwise).
497
+ typecheck: { checker: 'golar' },
498
+ // A cloudflared quick tunnel so Discord can reach the interactions endpoint, or an https URL you serve.
499
+ tunnel: true,
500
+ // Where the session's logs are mirrored, so a run can be read after the terminal UI is gone.
501
+ logFile: '.stars/dev.log'
502
+ }
503
+ });
504
+ ```
505
+
506
+ `tunnel.updateEndpoint` writes the public URL to the Discord application's `interactions_endpoint_url`; it is opt-in
507
+ because it edits a live application, and needs `DISCORD_TOKEN` in the environment or the project's `.env`.
508
+
509
+ ### Experimental flags
510
+
511
+ `experimental` is the same kind of block Nuxt's own `experimental` is: opt-in booleans, all `false` by default, each
512
+ guarding work that is still landing.
513
+
514
+ ```typescript
515
+ export default defineConfig({
516
+ entry: 'src/main.ts',
517
+ // `build.tool: 'vite'` is only accepted with `enableVite`, and `'auto'` only then detects a vite.config.*
518
+ build: { tool: 'vite' },
519
+ experimental: {
520
+ // Vite as the build tool and the HTTP server, in place of tsdown plus the framework's node:http listener.
521
+ enableVite: true,
522
+ // The project runs Vite itself: `stars dev` only watches the output and restarts the bot.
523
+ enableExternalVite: false,
524
+ // Build and serve through Nitro. Needs the framework's Fetch adapter, so `stars dev`/`stars build` still
525
+ // refuse it with an actionable error for now.
526
+ enableNitro: false
527
+ }
528
+ });
529
+ ```
530
+
531
+ The resolved configuration is also available programmatically:
532
+
533
+ ```typescript
534
+ import { loadStarsConfig } from '@wolfstar/http-framework/config';
535
+
536
+ const config = await loadStarsConfig({ cwd: process.cwd() });
537
+ console.log(config.entry, config.build.output);
538
+ ```
539
+
540
+ Invalid options raise a `ConfigError` with a stable `code`, the offending option `path`, the `file` it came from, and
541
+ an actionable `hint`. See the [`@wolfstar/cli` README](../cli#configuration) for the full option reference and how the
542
+ `stars` commands (`dev`, `build`, `info`, `codegen`, `prepare`, `commands`) use it.
543
+
463
544
  ### ApplicationCommandRegistry
464
545
 
465
546
  The `ApplicationCommandRegistry` is `@wolfstar/http-framework`'s centralized registry and uses [`@discordjs/rest`] to register them in Discord.