@nectar-js/nectar 0.1.0 → 0.2.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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli-Ce-ZUj6M.js","names":["COMMAND_TYPE","OPTION_TYPE","indent","relative","fail","relative","info","info","info","info","note"],"sources":["../src/registration/targets.ts","../src/typegen/emit.ts","../src/autocomplete/compile.ts","../src/commands/validate.ts","../src/commands/compile.ts","../src/events/compile.ts","../src/compiler/chains.ts","../src/compiler/discover.ts","../src/compiler/identity.ts","../src/compiler/routes.ts","../src/compiler/graph.ts","../src/cli/ui.ts","../src/cli/compile.ts","../src/cli/io.ts","../src/cli/project.ts","../src/cli/build.ts","../src/cli/routes.ts","../src/cli/sync.ts","../src/dev/classify.ts","../src/dev/server.ts","../src/dev/watch.ts","../src/cli/dev.ts","../src/cli/manifest.ts","../src/cli/misc.ts","../src/cli/start.ts","../src/cli/index.ts"],"sourcesContent":["import type { NectarConfig } from \"../config.js\";\nimport type { Env } from \"../runtime/types.js\";\nimport type { Scope } from \"./remote.js\";\n\n/**\n * Where this environment registers commands. Development and test use `dev.guilds` only, so a\n * project without dev guilds registers nothing until some are configured. Production uses\n * `commands.target`, global by default.\n */\nexport function registrationScopes(\n config: Pick<NectarConfig, \"dev\" | \"commands\">,\n env: Env,\n): Scope[] {\n if (env !== \"production\") return (config.dev?.guilds ?? []).map((guild) => ({ guild }));\n const target = config.commands?.target ?? \"global\";\n return target === \"global\" ? [\"global\"] : target.map((guild) => ({ guild }));\n}\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { ApplicationCommandOptionType, ApplicationCommandType } from \"discord-api-types/v10\";\nimport type { RouteGraph } from \"../compiler/graph.js\";\nimport type { Route } from \"../compiler/routes.js\";\nimport { type NectarPlugin, PluginError, pluginGraph } from \"../plugins/index.js\";\n\nexport const TYPES_FILE = \"types.d.ts\";\n\nconst PACKAGE = \"@nectar-js/nectar\";\n\nconst COMMAND_TYPE: Record<number, string> = {\n [ApplicationCommandType.ChatInput]: \"chatInput\",\n [ApplicationCommandType.User]: \"user\",\n [ApplicationCommandType.Message]: \"message\",\n};\n\nconst OPTION_TYPE: Record<number, string> = {\n [ApplicationCommandOptionType.String]: \"string\",\n [ApplicationCommandOptionType.Integer]: \"integer\",\n [ApplicationCommandOptionType.Number]: \"number\",\n [ApplicationCommandOptionType.Boolean]: \"boolean\",\n [ApplicationCommandOptionType.User]: \"user\",\n [ApplicationCommandOptionType.Channel]: \"channel\",\n [ApplicationCommandOptionType.Role]: \"role\",\n [ApplicationCommandOptionType.Mentionable]: \"mentionable\",\n [ApplicationCommandOptionType.Attachment]: \"attachment\",\n};\n\n/**\n * Renders `types.d.ts`: a module augmentation of `@nectar-js/nectar` that lists every route with\n * its parameters, options, and the context its middleware chain adds. Handler and middleware\n * types are pulled in with `import()` type queries relative to `outDir`. Whatever a plugin's\n * `types` hook returns is appended after the augmentation.\n */\nexport function toTypes(\n graph: RouteGraph,\n outDir: string,\n plugins: readonly NectarPlugin[] = [],\n): string {\n const absoluteOut = path.resolve(outDir);\n const middlewareAliases = new Map<string, string>();\n const aliasFor = (file: string): string => {\n let alias = middlewareAliases.get(file);\n if (alias === undefined) {\n alias = `M${middlewareAliases.size}`;\n middlewareAliases.set(file, alias);\n }\n return alias;\n };\n const contextOf = (route: Route): string => {\n const files = graph.chains.get(route.file)?.middleware ?? [];\n return files.length === 0 ? \"{}\" : files.map(aliasFor).join(\" & \");\n };\n\n const commands: string[] = [];\n for (const command of [...graph.commands].sort((a, b) => a.name.localeCompare(b.name))) {\n for (const [key, route] of Object.entries(command.handlers)) {\n const options = Object.entries(optionsAt(command.payload, key))\n .map(([name, type]) => `${quote(name)}: ${quote(type)}`)\n .join(\"; \");\n commands.push(\n ` ${quote(route.path)}: { type: ${quote(COMMAND_TYPE[command.type] ?? \"chatInput\")}; options: {${options === \"\" ? \"\" : ` ${options} `}}; context: ${contextOf(route)} };`,\n );\n }\n }\n commands.sort();\n\n // The compiler allows one handler per component path, so each path has one kind.\n const components = [...graph.components]\n .sort((a, b) => a.path.localeCompare(b.path))\n .map((route) => {\n const params = route.params\n .map((name) => `${quote(name)}: ${name === route.catchAll ? \"string[]\" : \"string\"}`)\n .join(\"; \");\n const kind = route.kind === \"select\" ? `select:${route.selectKind}` : route.kind;\n return ` ${quote(route.path)}: { kind: ${quote(kind)}; params: {${params === \"\" ? \"\" : ` ${params} `}}; context: ${contextOf(route)} };`;\n });\n\n const events = graph.events.map((e) => ` ${quote(e.name)}: true;`);\n const autocomplete = graph.autocomplete\n .map((a) => ` ${quote(a.route.path)}: ${a.options.map(quote).join(\" | \") || \"never\"};`)\n .sort();\n\n const aliases = [...middlewareAliases].map(\n ([file, alias]) =>\n `type ${alias} = MiddlewareExtension<typeof import(${quote(importPath(absoluteOut, file))})>;`,\n );\n\n return [\n \"// Generated by Nectar. Do not edit.\",\n `import type { MiddlewareExtension } from ${quote(PACKAGE)};`,\n ...(aliases.length === 0 ? [] : [\"\", ...aliases]),\n \"\",\n `declare module ${quote(PACKAGE)} {`,\n \" interface NectarRoutes {\",\n \" commands: {\",\n ...commands.map(indent),\n \" };\",\n \" components: {\",\n ...components.map(indent),\n \" };\",\n \" events: {\",\n ...events.map(indent),\n \" };\",\n \" autocomplete: {\",\n ...autocomplete.map(indent),\n \" };\",\n \" }\",\n \"}\",\n \"\",\n \"export {};\",\n \"\",\n ...pluginTypes(graph, plugins),\n ].join(\"\\n\");\n}\n\nfunction pluginTypes(graph: RouteGraph, plugins: readonly NectarPlugin[]): string[] {\n const lines: string[] = [];\n for (const plugin of plugins) {\n if (plugin.types === undefined) continue;\n let extra: unknown;\n try {\n extra = plugin.types(pluginGraph(graph));\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n throw new PluginError(plugin.name, `types failed: ${detail}`);\n }\n if (typeof extra !== \"string\" || extra.trim() === \"\") continue;\n lines.push(`// From plugin ${JSON.stringify(plugin.name)}`, extra.trim(), \"\");\n }\n return lines;\n}\n\nexport function writeTypes(\n graph: RouteGraph,\n outDir: string,\n plugins: readonly NectarPlugin[] = [],\n): string {\n mkdirSync(outDir, { recursive: true });\n const file = path.join(outDir, TYPES_FILE);\n writeFileSync(file, toTypes(graph, outDir, plugins));\n return file;\n}\n\ninterface PayloadNode {\n name?: string;\n type?: number;\n options?: PayloadNode[];\n}\n\n/** Option name to option type name for one handler position of a command payload. */\nfunction optionsAt(payload: unknown, key: string): Record<string, string> {\n let options = (payload as PayloadNode).options;\n for (const part of key === \"\" ? [] : key.split(\"/\")) {\n options = options?.find((o) => o.name === part)?.options;\n }\n const out: Record<string, string> = {};\n for (const option of options ?? []) {\n const type = option.type === undefined ? undefined : OPTION_TYPE[option.type];\n if (option.name !== undefined && type !== undefined) out[option.name] = type;\n }\n return out;\n}\n\n/** `../app/middleware.ts` becomes `../app/middleware.js`, which NodeNext resolves back to the source. */\nfunction importPath(fromDir: string, file: string): string {\n const relative = path.relative(fromDir, file).split(path.sep).join(\"/\");\n const mapped = relative.replace(/\\.mts$/, \".mjs\").replace(/\\.ts$/, \".js\");\n return mapped.startsWith(\".\") ? mapped : `./${mapped}`;\n}\n\nfunction quote(value: string): string {\n return JSON.stringify(value);\n}\n\nfunction indent(line: string): string {\n return ` ${line}`;\n}\n","import path from \"node:path\";\nimport type { CompiledCommand } from \"../commands/compile.js\";\nimport { Diagnostics } from \"../compiler/diagnostics.js\";\nimport { loadModule } from \"../compiler/load.js\";\nimport type { Route, RouteTable } from \"../compiler/routes.js\";\n\nexport interface CompiledAutocomplete {\n /** The `autocomplete.ts` route. Shares its identity with the sibling `command.ts`. */\n route: Route;\n /** The command route these handlers serve. */\n command: Route;\n /** Option names with a handler, sorted. Each is a named export of the file. */\n options: string[];\n}\n\nexport interface CompiledAutocompletes {\n autocomplete: CompiledAutocomplete[];\n diagnostics: Diagnostics;\n}\n\n/**\n * Links every `autocomplete.ts` to its sibling command and checks that each named export\n * matches an option declared with `autocomplete: true`, and that no such option is left\n * without a handler.\n */\nexport async function compileAutocomplete(\n table: RouteTable,\n commands: CompiledCommand[],\n): Promise<CompiledAutocompletes> {\n const diagnostics = new Diagnostics();\n const routes = table.routes.filter((r) => r.kind === \"autocomplete\");\n\n const targets = new Map<string, { command: Route; options: Set<string> }>();\n for (const command of commands) {\n for (const [key, route] of Object.entries(command.handlers)) {\n targets.set(route.id, { command: route, options: autocompleteOptions(command, key) });\n }\n }\n\n const results = await Promise.all(\n routes.map(async (route): Promise<CompiledAutocomplete | null> => {\n const target = targets.get(route.id);\n if (target === undefined) {\n diagnostics.error(\n \"autocomplete-without-command\",\n `autocomplete.ts needs a command.ts in the same directory. None was found for \"${route.path}\".`,\n { file: route.file, route: route.id },\n );\n return null;\n }\n\n let module: Record<string, unknown>;\n try {\n module = await loadModule(route.file);\n } catch (error) {\n diagnostics.error(\n \"module-load-failed\",\n `Could not import this file: ${error instanceof Error ? error.message : String(error)}`,\n { file: route.file, route: route.id },\n );\n return null;\n }\n\n const exported = Object.keys(module)\n .filter((name) => name !== \"default\")\n .sort();\n let ok = true;\n\n for (const name of exported) {\n if (typeof module[name] !== \"function\") {\n diagnostics.error(\n \"autocomplete-export-not-function\",\n `Export \"${name}\" must be a function that answers autocomplete for the \"${name}\" option.`,\n { file: route.file, route: route.id },\n );\n ok = false;\n continue;\n }\n if (!target.options.has(name)) {\n diagnostics.error(\n \"autocomplete-unknown-option\",\n `Export \"${name}\" does not match an option with \\`autocomplete: true\\` in ${relative(target.command.file)}. ${expected(target.options)}`,\n { file: route.file, route: route.id },\n );\n ok = false;\n }\n }\n\n for (const name of [...target.options].sort()) {\n if (exported.includes(name)) continue;\n diagnostics.error(\n \"autocomplete-missing-handler\",\n `Option \"${name}\" has \\`autocomplete: true\\` but ${relative(route.file)} does not export a \"${name}\" function.`,\n { file: route.file, route: route.id },\n );\n ok = false;\n }\n\n return ok ? { route, command: target.command, options: exported } : null;\n }),\n );\n\n for (const [id, target] of targets) {\n if (target.options.size === 0 || routes.some((r) => r.id === id)) continue;\n diagnostics.error(\n \"autocomplete-missing-file\",\n `${[...target.options].map((o) => `\"${o}\"`).join(\", \")} ${target.options.size === 1 ? \"has\" : \"have\"} \\`autocomplete: true\\` but there is no autocomplete.ts next to this command.`,\n { file: target.command.file, route: id },\n );\n }\n\n return {\n autocomplete: results.filter((r): r is CompiledAutocomplete => r !== null),\n diagnostics,\n };\n}\n\n/** Names of the options with `autocomplete: true` for one handler position of a command. */\nfunction autocompleteOptions(command: CompiledCommand, key: string): Set<string> {\n let options = (command.payload as PayloadNode).options;\n for (const part of key === \"\" ? [] : key.split(\"/\")) {\n options = options?.find((o) => o.name === part)?.options;\n }\n return new Set(\n (options ?? []).filter((o) => o.autocomplete === true).map((o) => o.name as string),\n );\n}\n\n/** The parts of a registration payload the option walk needs. */\ninterface PayloadNode {\n name?: string;\n autocomplete?: boolean;\n options?: PayloadNode[];\n}\n\nfunction expected(options: Set<string>): string {\n return options.size === 0\n ? \"The command declares no autocomplete options.\"\n : `Expected one of: ${[...options].sort().join(\", \")}.`;\n}\n\nfunction relative(file: string): string {\n return path.relative(process.cwd(), file).split(path.sep).join(\"/\");\n}\n","import type { Diagnostics } from \"../compiler/diagnostics.js\";\nimport type { CommandMeta, CommandOption, CommandRouteMeta, OptionChoice } from \"./meta.js\";\n\nexport const COMMAND_NAME = /^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}$/u;\n\nconst OPTION_TYPES = new Set([\n \"string\",\n \"integer\",\n \"number\",\n \"boolean\",\n \"user\",\n \"channel\",\n \"role\",\n \"mentionable\",\n \"attachment\",\n]);\n\nconst COMMAND_TYPES = new Set([\"chatInput\", \"user\", \"message\"]);\n\nconst TOP_LEVEL_KEYS = [\n \"defaultMemberPermissions\",\n \"nsfw\",\n \"contexts\",\n \"integrationTypes\",\n] as const;\n\ninterface Ctx {\n diagnostics: Diagnostics;\n file: string;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Validates the `meta` export of a `command.ts`. Returns null after reporting when unusable. */\nexport function validateCommandMeta(\n value: unknown,\n file: string,\n diagnostics: Diagnostics,\n): CommandMeta | null {\n const ctx = { diagnostics, file };\n if (value === undefined) {\n diagnostics.error(\n \"missing-meta\",\n \"command.ts must export a `meta` object with at least a description.\",\n { file },\n );\n return null;\n }\n if (!isRecord(value)) {\n fail(ctx, \"invalid-meta\", \"`meta` must be an object.\");\n return null;\n }\n\n let ok = true;\n const type = value.type ?? \"chatInput\";\n if (typeof type !== \"string\" || !COMMAND_TYPES.has(type)) {\n ok = fail(ctx, \"invalid-meta\", '`meta.type` must be \"chatInput\", \"user\", or \"message\".');\n }\n\n if (value.name !== undefined)\n ok = checkName(ctx, value.name, \"meta.name\", type === \"chatInput\") && ok;\n\n if (type === \"chatInput\") {\n ok = checkDescription(ctx, value.description, \"meta.description\") && ok;\n if (value.options !== undefined) ok = checkOptions(ctx, value.options) && ok;\n } else {\n if (value.description !== undefined && value.description !== \"\") {\n ok = fail(\n ctx,\n \"invalid-meta\",\n \"Context menu commands cannot have a description. Remove `meta.description`.\",\n );\n }\n if (value.options !== undefined) {\n ok = fail(ctx, \"invalid-meta\", \"Context menu commands cannot have options.\");\n }\n }\n\n ok = checkLocalizations(ctx, value.nameLocalizations, \"meta.nameLocalizations\") && ok;\n ok =\n checkLocalizations(ctx, value.descriptionLocalizations, \"meta.descriptionLocalizations\") && ok;\n ok = checkTopLevel(ctx, value) && ok;\n\n return ok ? (value as unknown as CommandMeta) : null;\n}\n\n/** Validates the `meta` export of a `route.ts` under `commands/`. */\nexport function validateCommandRouteMeta(\n value: unknown,\n file: string,\n diagnostics: Diagnostics,\n): CommandRouteMeta | null {\n const ctx = { diagnostics, file };\n if (value === undefined) {\n diagnostics.error(\"missing-meta\", \"route.ts must export a `meta` object with a description.\", {\n file,\n });\n return null;\n }\n if (!isRecord(value)) {\n fail(ctx, \"invalid-meta\", \"`meta` must be an object.\");\n return null;\n }\n let ok = checkDescription(ctx, value.description, \"meta.description\");\n if (value.name !== undefined) ok = checkName(ctx, value.name, \"meta.name\", true) && ok;\n ok = checkLocalizations(ctx, value.nameLocalizations, \"meta.nameLocalizations\") && ok;\n ok =\n checkLocalizations(ctx, value.descriptionLocalizations, \"meta.descriptionLocalizations\") && ok;\n ok = checkTopLevel(ctx, value) && ok;\n return ok ? (value as unknown as CommandRouteMeta) : null;\n}\n\n/** Reports any top-level-only field so callers can reject them on nested commands. */\nexport function topLevelKeysUsed(meta: object): string[] {\n return TOP_LEVEL_KEYS.filter(\n (key) => key in meta && (meta as Record<string, unknown>)[key] !== undefined,\n );\n}\n\nfunction fail(ctx: Ctx, code: string, message: string): false {\n ctx.diagnostics.error(code, message, { file: ctx.file });\n return false;\n}\n\nfunction checkName(ctx: Ctx, name: unknown, label: string, chatInput: boolean): boolean {\n if (typeof name !== \"string\" || name.length === 0 || name.length > 32) {\n return fail(ctx, \"invalid-name\", `${label} must be a string of 1 to 32 characters.`);\n }\n if (chatInput) {\n if (!COMMAND_NAME.test(name) || name !== name.toLowerCase()) {\n return fail(\n ctx,\n \"invalid-name\",\n `${label} \"${name}\" is not a valid chat input command name. Discord requires lowercase letters, digits, hyphens, and underscores.`,\n );\n }\n }\n return true;\n}\n\nfunction checkDescription(ctx: Ctx, description: unknown, label: string): boolean {\n if (typeof description !== \"string\" || description.length === 0 || description.length > 100) {\n return fail(ctx, \"invalid-description\", `${label} must be a string of 1 to 100 characters.`);\n }\n return true;\n}\n\nfunction checkLocalizations(ctx: Ctx, value: unknown, label: string): boolean {\n if (value === undefined) return true;\n if (!isRecord(value))\n return fail(ctx, \"invalid-meta\", `${label} must be an object of locale to string.`);\n for (const [locale, text] of Object.entries(value)) {\n if (typeof text !== \"string\") {\n return fail(ctx, \"invalid-meta\", `${label}.${locale} must be a string.`);\n }\n }\n return true;\n}\n\nfunction checkTopLevel(ctx: Ctx, value: Record<string, unknown>): boolean {\n let ok = true;\n const perms = value.defaultMemberPermissions;\n if (\n perms !== undefined &&\n perms !== null &&\n typeof perms !== \"bigint\" &&\n typeof perms !== \"string\" &&\n typeof perms !== \"number\"\n ) {\n ok = fail(\n ctx,\n \"invalid-meta\",\n \"`meta.defaultMemberPermissions` must be a permission bitfield (bigint, string, or number) or null.\",\n );\n }\n if (value.nsfw !== undefined && typeof value.nsfw !== \"boolean\") {\n ok = fail(ctx, \"invalid-meta\", \"`meta.nsfw` must be a boolean.\");\n }\n ok = checkEnumArray(ctx, value.contexts, \"meta.contexts\", [0, 1, 2]) && ok;\n ok = checkEnumArray(ctx, value.integrationTypes, \"meta.integrationTypes\", [0, 1]) && ok;\n return ok;\n}\n\nfunction checkEnumArray(ctx: Ctx, value: unknown, label: string, allowed: number[]): boolean {\n if (value === undefined) return true;\n if (!Array.isArray(value) || value.some((v) => !allowed.includes(v))) {\n return fail(\n ctx,\n \"invalid-meta\",\n `${label} must be an array of ${allowed.join(\", \")}. Use the discord.js enum values.`,\n );\n }\n return true;\n}\n\nfunction checkOptions(ctx: Ctx, options: unknown): boolean {\n if (!Array.isArray(options))\n return fail(ctx, \"invalid-option\", \"`meta.options` must be an array.\");\n if (options.length > 25) {\n return fail(ctx, \"invalid-option\", \"A command can have at most 25 options.\");\n }\n let ok = true;\n const names = new Set<string>();\n let seenOptional = false;\n for (const [index, option] of options.entries()) {\n const label = `meta.options[${index}]`;\n if (!isRecord(option)) {\n ok = fail(ctx, \"invalid-option\", `${label} must be an object.`);\n continue;\n }\n const typedOk = checkOption(ctx, option, label);\n ok = typedOk && ok;\n if (!typedOk) continue;\n const typed = option as unknown as CommandOption;\n if (names.has(typed.name)) {\n ok = fail(ctx, \"invalid-option\", `${label}: option name \"${typed.name}\" is used twice.`);\n }\n names.add(typed.name);\n if (typed.required) {\n if (seenOptional) {\n ok = fail(\n ctx,\n \"invalid-option\",\n `${label}: required option \"${typed.name}\" comes after an optional one. Discord requires all required options first.`,\n );\n }\n } else {\n seenOptional = true;\n }\n }\n return ok;\n}\n\nfunction checkOption(ctx: Ctx, option: Record<string, unknown>, label: string): boolean {\n let ok = true;\n if (typeof option.type !== \"string\" || !OPTION_TYPES.has(option.type)) {\n return fail(\n ctx,\n \"invalid-option\",\n `${label}.type must be one of ${[...OPTION_TYPES].map((t) => `\"${t}\"`).join(\", \")}.`,\n );\n }\n ok = checkName(ctx, option.name, `${label}.name`, true) && ok;\n ok = checkDescription(ctx, option.description, `${label}.description`) && ok;\n if (option.required !== undefined && typeof option.required !== \"boolean\") {\n ok = fail(ctx, \"invalid-option\", `${label}.required must be a boolean.`);\n }\n ok = checkLocalizations(ctx, option.nameLocalizations, `${label}.nameLocalizations`) && ok;\n ok =\n checkLocalizations(ctx, option.descriptionLocalizations, `${label}.descriptionLocalizations`) &&\n ok;\n\n const type = option.type;\n const numeric = type === \"integer\" || type === \"number\";\n const choosable = type === \"string\" || numeric;\n\n for (const key of [\n \"choices\",\n \"autocomplete\",\n \"minLength\",\n \"maxLength\",\n \"minValue\",\n \"maxValue\",\n \"channelTypes\",\n ]) {\n if (option[key] === undefined) continue;\n const allowed =\n (key === \"choices\" || key === \"autocomplete\") && choosable\n ? true\n : (key === \"minLength\" || key === \"maxLength\") && type === \"string\"\n ? true\n : (key === \"minValue\" || key === \"maxValue\") && numeric\n ? true\n : key === \"channelTypes\" && type === \"channel\";\n if (!allowed) {\n ok = fail(ctx, \"invalid-option\", `${label}.${key} is not valid for a \"${type}\" option.`);\n }\n }\n\n if (option.autocomplete !== undefined && typeof option.autocomplete !== \"boolean\") {\n ok = fail(ctx, \"invalid-option\", `${label}.autocomplete must be a boolean.`);\n }\n if (option.choices !== undefined) {\n if (option.autocomplete === true) {\n ok = fail(ctx, \"invalid-option\", `${label} cannot have both choices and autocomplete.`);\n }\n ok = checkChoices(ctx, option.choices, `${label}.choices`, type === \"string\") && ok;\n }\n for (const key of [\"minLength\", \"maxLength\", \"minValue\", \"maxValue\"]) {\n const v = option[key];\n if (v !== undefined && typeof v !== \"number\") {\n ok = fail(ctx, \"invalid-option\", `${label}.${key} must be a number.`);\n }\n }\n if (typeof option.minLength === \"number\" && (option.minLength < 0 || option.minLength > 6000)) {\n ok = fail(ctx, \"invalid-option\", `${label}.minLength must be between 0 and 6000.`);\n }\n if (typeof option.maxLength === \"number\" && (option.maxLength < 1 || option.maxLength > 6000)) {\n ok = fail(ctx, \"invalid-option\", `${label}.maxLength must be between 1 and 6000.`);\n }\n if (option.channelTypes !== undefined) {\n if (\n !Array.isArray(option.channelTypes) ||\n option.channelTypes.some((c) => typeof c !== \"number\")\n ) {\n ok = fail(\n ctx,\n \"invalid-option\",\n `${label}.channelTypes must be an array of ChannelType values.`,\n );\n }\n }\n return ok;\n}\n\nfunction checkChoices(ctx: Ctx, choices: unknown, label: string, isString: boolean): boolean {\n if (!Array.isArray(choices)) return fail(ctx, \"invalid-option\", `${label} must be an array.`);\n if (choices.length > 25)\n return fail(ctx, \"invalid-option\", `${label} can have at most 25 entries.`);\n let ok = true;\n for (const [index, choice] of choices.entries()) {\n const at = `${label}[${index}]`;\n if (!isRecord(choice)) {\n ok = fail(ctx, \"invalid-option\", `${at} must be an object with name and value.`);\n continue;\n }\n const typed = choice as Partial<OptionChoice>;\n if (typeof typed.name !== \"string\" || typed.name.length === 0 || typed.name.length > 100) {\n ok = fail(ctx, \"invalid-option\", `${at}.name must be a string of 1 to 100 characters.`);\n }\n if (isString) {\n if (typeof typed.value !== \"string\" || typed.value.length === 0 || typed.value.length > 100) {\n ok = fail(ctx, \"invalid-option\", `${at}.value must be a string of 1 to 100 characters.`);\n }\n } else if (typeof typed.value !== \"number\") {\n ok = fail(ctx, \"invalid-option\", `${at}.value must be a number.`);\n }\n ok = checkLocalizations(ctx, typed.nameLocalizations, `${at}.nameLocalizations`) && ok;\n }\n return ok;\n}\n","import path from \"node:path\";\nimport {\n ApplicationCommandOptionType,\n ApplicationCommandType,\n type RESTPostAPIApplicationCommandsJSONBody,\n} from \"discord-api-types/v10\";\nimport { Diagnostics } from \"../compiler/diagnostics.js\";\nimport { loadModule } from \"../compiler/load.js\";\nimport type { Boundary, Route, RouteTable } from \"../compiler/routes.js\";\nimport { formatSegment } from \"../compiler/segments.js\";\nimport { checkDeclaredRoute } from \"../components/compile.js\";\nimport type { CommandMeta, CommandOption, CommandRouteMeta, TopLevelMeta } from \"./meta.js\";\nimport { topLevelKeysUsed, validateCommandMeta, validateCommandRouteMeta } from \"./validate.js\";\n\nexport interface CompiledCommand {\n name: string;\n type: ApplicationCommandType;\n /**\n * Handler routes keyed by their position inside the command, using the registered names:\n * `\"\"` for a plain command, `\"ban\"` for a subcommand, `\"group/sub\"` inside a subcommand group.\n */\n handlers: Record<string, Route>;\n payload: RESTPostAPIApplicationCommandsJSONBody;\n /** Every file that contributed to this command. */\n files: string[];\n}\n\nexport interface CompiledCommands {\n commands: CompiledCommand[];\n diagnostics: Diagnostics;\n}\n\nconst OPTION_TYPE: Record<CommandOption[\"type\"], ApplicationCommandOptionType> = {\n string: ApplicationCommandOptionType.String,\n integer: ApplicationCommandOptionType.Integer,\n number: ApplicationCommandOptionType.Number,\n boolean: ApplicationCommandOptionType.Boolean,\n user: ApplicationCommandOptionType.User,\n channel: ApplicationCommandOptionType.Channel,\n role: ApplicationCommandOptionType.Role,\n mentionable: ApplicationCommandOptionType.Mentionable,\n attachment: ApplicationCommandOptionType.Attachment,\n};\n\nconst COMMAND_TYPE = {\n chatInput: ApplicationCommandType.ChatInput,\n user: ApplicationCommandType.User,\n message: ApplicationCommandType.Message,\n} as const;\n\ninterface LoadedRoute {\n route: Route;\n parts: string[];\n meta: CommandMeta;\n}\n\ninterface LoadedRouteMeta {\n boundary: Boundary;\n meta: CommandRouteMeta;\n used: boolean;\n}\n\n/** Compiles the command routes of a route table into Discord command definitions. */\nexport async function compileCommands(table: RouteTable): Promise<CompiledCommands> {\n const diagnostics = new Diagnostics();\n const commands: CompiledCommand[] = [];\n\n const [loaded, routeMetas] = await Promise.all([\n loadRoutes(table.routes, diagnostics),\n loadRouteMetas(table.boundaries, diagnostics),\n ]);\n\n const byTopLevel = new Map<string, LoadedRoute[]>();\n for (const entry of loaded) {\n const top = entry.parts[0] as string;\n byTopLevel.set(top, [...(byTopLevel.get(top) ?? []), entry]);\n }\n\n for (const [top, entries] of [...byTopLevel].sort(([a], [b]) => a.localeCompare(b))) {\n const command = compileTopLevel(top, entries, routeMetas, diagnostics);\n if (command !== null) commands.push(command);\n }\n\n for (const entry of routeMetas.values()) {\n if (!entry.used) {\n diagnostics.warn(\n \"unused-route-meta\",\n \"This route.ts does not describe a command with subcommands and has no effect.\",\n { file: entry.boundary.file },\n );\n }\n }\n\n detectDuplicateNames(commands, diagnostics);\n commands.sort((a, b) => a.type - b.type || a.name.localeCompare(b.name));\n return { commands, diagnostics };\n}\n\nasync function loadRoutes(routes: Route[], diagnostics: Diagnostics): Promise<LoadedRoute[]> {\n const commandRoutes = routes.filter((r) => r.kind === \"command\");\n const results = await Promise.all(\n commandRoutes.map(async (route): Promise<LoadedRoute | null> => {\n const module = await importOrReport(route.file, diagnostics);\n if (module === null) return null;\n if (!checkDeclaredRoute(module, route, diagnostics)) return null;\n const meta = validateCommandMeta(module.meta, route.file, diagnostics);\n if (meta === null) return null;\n return { route, parts: route.path.split(\"/\"), meta };\n }),\n );\n return results.filter((r): r is LoadedRoute => r !== null);\n}\n\nasync function loadRouteMetas(\n boundaries: Boundary[],\n diagnostics: Diagnostics,\n): Promise<Map<string, LoadedRouteMeta>> {\n const map = new Map<string, LoadedRouteMeta>();\n const relevant = boundaries.filter((b) => b.kind === \"route\" && b.category === \"command\");\n await Promise.all(\n relevant.map(async (boundary) => {\n const key = boundary.segments\n .filter((s) => s.type !== \"group\")\n .map(formatSegment)\n .join(\"/\");\n if (key === \"\") {\n diagnostics.error(\n \"route-meta-without-path\",\n \"route.ts must live inside a command directory. At the commands root it describes nothing.\",\n { file: boundary.file },\n );\n return;\n }\n const module = await importOrReport(boundary.file, diagnostics);\n if (module === null) return;\n const meta = validateCommandRouteMeta(module.meta, boundary.file, diagnostics);\n if (meta === null) return;\n map.set(key, { boundary, meta, used: false });\n }),\n );\n return map;\n}\n\nasync function importOrReport(\n file: string,\n diagnostics: Diagnostics,\n): Promise<Record<string, unknown> | null> {\n try {\n return await loadModule(file);\n } catch (error) {\n diagnostics.error(\n \"module-load-failed\",\n `Could not import this file: ${error instanceof Error ? error.message : String(error)}`,\n { file },\n );\n return null;\n }\n}\n\nfunction compileTopLevel(\n top: string,\n entries: LoadedRoute[],\n routeMetas: Map<string, LoadedRouteMeta>,\n diagnostics: Diagnostics,\n): CompiledCommand | null {\n const direct = entries.filter((e) => e.parts.length === 1);\n const nested = entries.filter((e) => e.parts.length > 1);\n\n if (direct.length > 0 && nested.length > 0) {\n for (const entry of nested) {\n diagnostics.error(\n \"mixed-command-and-subcommands\",\n `\"${top}\" has its own command.ts and also subcommands. Discord does not allow both. Either remove ${relative(direct[0]?.route.file)} or move this handler out of ${top}/.`,\n { file: entry.route.file, route: entry.route.id },\n );\n }\n return null;\n }\n\n const tooDeep = nested.filter((e) => e.parts.length > 3);\n if (tooDeep.length > 0) {\n for (const entry of tooDeep) {\n diagnostics.error(\n \"command-too-deep\",\n `Commands can nest at most three levels (command / group / subcommand). \"${entry.route.path}\" has ${entry.parts.length}.`,\n { file: entry.route.file, route: entry.route.id },\n );\n }\n return null;\n }\n\n if (direct.length === 1) return compilePlainCommand(direct[0] as LoadedRoute, diagnostics);\n\n return compileParentCommand(top, nested, routeMetas, diagnostics);\n}\n\nfunction compilePlainCommand(entry: LoadedRoute, diagnostics: Diagnostics): CompiledCommand | null {\n const { route, meta } = entry;\n const name = meta.name ?? route.path;\n const type = COMMAND_TYPE[meta.type ?? \"chatInput\"];\n\n if (type === ApplicationCommandType.ChatInput && !isValidChatInputName(name)) {\n reportDirectoryName(route, name, diagnostics);\n return null;\n }\n\n const payload: Record<string, unknown> = {\n name,\n type,\n ...localizations(meta),\n ...topLevelPayload(meta),\n };\n if (type === ApplicationCommandType.ChatInput) {\n payload.description = meta.description;\n if (meta.options !== undefined) payload.options = meta.options.map(optionPayload);\n }\n\n return {\n name,\n type,\n handlers: { \"\": route },\n payload: compact(payload) as unknown as RESTPostAPIApplicationCommandsJSONBody,\n files: [route.file],\n };\n}\n\nfunction compileParentCommand(\n top: string,\n nested: LoadedRoute[],\n routeMetas: Map<string, LoadedRouteMeta>,\n diagnostics: Diagnostics,\n): CompiledCommand | null {\n const parent = requireRouteMeta(top, nested[0] as LoadedRoute, routeMetas, diagnostics);\n if (parent === null) return null;\n const name = parent.meta.name ?? top;\n if (!isValidChatInputName(name)) {\n reportDirectoryName(nested[0]?.route as Route, name, diagnostics, parent.boundary.file);\n return null;\n }\n\n const handlers: Record<string, Route> = {};\n const files = [parent.boundary.file];\n const options: Record<string, unknown>[] = [];\n let ok = true;\n\n const bySecond = new Map<string, LoadedRoute[]>();\n for (const entry of nested) {\n const second = entry.parts[1] as string;\n bySecond.set(second, [...(bySecond.get(second) ?? []), entry]);\n }\n\n if (bySecond.size > 25) {\n diagnostics.error(\n \"too-many-subcommands\",\n `\"${top}\" has ${bySecond.size} subcommands and groups. Discord allows at most 25.`,\n { file: parent.boundary.file },\n );\n ok = false;\n }\n\n for (const [second, entries] of [...bySecond].sort(([a], [b]) => a.localeCompare(b))) {\n const subs = entries.filter((e) => e.parts.length === 2);\n const grouped = entries.filter((e) => e.parts.length === 3);\n\n if (subs.length > 0 && grouped.length > 0) {\n for (const entry of grouped) {\n diagnostics.error(\n \"mixed-subcommand-and-group\",\n `\"${top}/${second}\" is both a subcommand (${relative(subs[0]?.route.file)}) and a subcommand group. Discord does not allow both.`,\n { file: entry.route.file, route: entry.route.id },\n );\n }\n ok = false;\n continue;\n }\n\n if (subs.length === 1) {\n const sub = compileSubcommand(subs[0] as LoadedRoute, diagnostics);\n if (sub === null) {\n ok = false;\n continue;\n }\n handlers[sub.name] = sub.route;\n files.push(sub.route.file);\n options.push(sub.payload);\n continue;\n }\n\n const groupKey = `${top}/${second}`;\n const group = requireRouteMeta(groupKey, grouped[0] as LoadedRoute, routeMetas, diagnostics);\n if (group === null) {\n ok = false;\n continue;\n }\n const groupName = group.meta.name ?? second;\n if (!isValidChatInputName(groupName)) {\n reportDirectoryName(grouped[0]?.route as Route, groupName, diagnostics, group.boundary.file);\n ok = false;\n continue;\n }\n const extra = topLevelKeysUsed(group.meta);\n if (extra.length > 0) {\n diagnostics.error(\n \"top-level-field-on-group\",\n `${extra.map((k) => `meta.${k}`).join(\", \")} only applies to top-level commands. Move it to ${relative(parent.boundary.file)}.`,\n { file: group.boundary.file },\n );\n ok = false;\n continue;\n }\n if (grouped.length > 25) {\n diagnostics.error(\n \"too-many-subcommands\",\n `Group \"${groupKey}\" has ${grouped.length} subcommands. Discord allows at most 25.`,\n { file: group.boundary.file },\n );\n ok = false;\n continue;\n }\n files.push(group.boundary.file);\n const groupOptions: Record<string, unknown>[] = [];\n for (const entry of grouped.sort((a, b) => a.route.path.localeCompare(b.route.path))) {\n const sub = compileSubcommand(entry, diagnostics);\n if (sub === null) {\n ok = false;\n continue;\n }\n handlers[`${groupName}/${sub.name}`] = sub.route;\n files.push(sub.route.file);\n groupOptions.push(sub.payload);\n }\n options.push(\n compact({\n type: ApplicationCommandOptionType.SubcommandGroup,\n name: groupName,\n description: group.meta.description,\n ...localizations(group.meta),\n options: groupOptions,\n }),\n );\n }\n\n if (!ok) return null;\n\n const payload = compact({\n name,\n type: ApplicationCommandType.ChatInput,\n description: parent.meta.description,\n ...localizations(parent.meta),\n ...topLevelPayload(parent.meta),\n options,\n }) as RESTPostAPIApplicationCommandsJSONBody;\n\n return { name, type: ApplicationCommandType.ChatInput, handlers, payload, files };\n}\n\nfunction compileSubcommand(\n entry: LoadedRoute,\n diagnostics: Diagnostics,\n): { name: string; route: Route; payload: Record<string, unknown> } | null {\n const { route, meta } = entry;\n if (meta.type !== undefined && meta.type !== \"chatInput\") {\n diagnostics.error(\n \"context-menu-nested\",\n `Context menu commands cannot be subcommands. Move ${relative(route.file)} to the top of commands/.`,\n { file: route.file, route: route.id },\n );\n return null;\n }\n const extra = topLevelKeysUsed(meta);\n if (extra.length > 0) {\n diagnostics.error(\n \"top-level-field-on-subcommand\",\n `${extra.map((k) => `meta.${k}`).join(\", \")} only applies to top-level commands. Move it to the route.ts of \"${entry.parts[0]}\".`,\n { file: route.file, route: route.id },\n );\n return null;\n }\n const name = meta.name ?? (entry.parts.at(-1) as string);\n if (!isValidChatInputName(name)) {\n reportDirectoryName(route, name, diagnostics);\n return null;\n }\n const payload = compact({\n type: ApplicationCommandOptionType.Subcommand,\n name,\n description: meta.description,\n ...localizations(meta),\n options: meta.options?.map(optionPayload),\n });\n return { name, route, payload };\n}\n\nfunction requireRouteMeta(\n key: string,\n child: LoadedRoute,\n routeMetas: Map<string, LoadedRouteMeta>,\n diagnostics: Diagnostics,\n): LoadedRouteMeta | null {\n const entry = routeMetas.get(key);\n if (entry !== undefined) {\n entry.used = true;\n return entry;\n }\n const dir = directoryForPath(child.route, key.split(\"/\").length);\n diagnostics.error(\n \"missing-route-meta\",\n `\"${key}\" has subcommands but no route.ts. Discord needs a description for it. Add ${path.join(dir, \"route.ts\")} exporting \\`meta\\` with a description.`,\n { file: child.route.file, route: child.route.id },\n );\n return null;\n}\n\n/** Directory of the Nth non-group segment of a route, walking up from the handler file. */\nfunction directoryForPath(route: Route, depth: number): string {\n let seen = 0;\n let index = route.segments.length;\n for (let i = 0; i < route.segments.length; i++) {\n if (route.segments[i]?.type === \"group\") continue;\n seen++;\n if (seen === depth) {\n index = i;\n break;\n }\n }\n const levelsUp = route.segments.length - index - 1;\n let dir = path.dirname(route.file);\n for (let i = 0; i < levelsUp; i++) dir = path.dirname(dir);\n return dir;\n}\n\nfunction isValidChatInputName(name: string): boolean {\n return /^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}$/u.test(name) && name === name.toLowerCase();\n}\n\nfunction reportDirectoryName(route: Route, name: string, diagnostics: Diagnostics, file?: string) {\n diagnostics.error(\n \"invalid-name\",\n `\"${name}\" is not a valid chat input command name. Discord requires lowercase letters, digits, hyphens, and underscores, 1 to 32 characters. Rename the directory or set \\`meta.name\\`.`,\n { file: file ?? route.file, route: route.id },\n );\n}\n\nfunction detectDuplicateNames(commands: CompiledCommand[], diagnostics: Diagnostics): void {\n const seen = new Map<string, CompiledCommand>();\n for (const command of commands) {\n const key = `${command.type}:${command.name}`;\n const existing = seen.get(key);\n if (existing === undefined) {\n seen.set(key, command);\n continue;\n }\n diagnostics.error(\n \"duplicate-command-name\",\n `Two commands register as \"${command.name}\": ${relative(existing.files[0])} and ${relative(command.files[0])}. Check \\`meta.name\\` overrides.`,\n { file: command.files[0] as string },\n );\n }\n}\n\nfunction optionPayload(option: CommandOption): Record<string, unknown> {\n const base: Record<string, unknown> = {\n type: OPTION_TYPE[option.type],\n name: option.name,\n description: option.description,\n required: option.required,\n ...localizations(option),\n };\n switch (option.type) {\n case \"string\":\n base.choices = option.choices?.map(choicePayload);\n base.autocomplete = option.autocomplete;\n base.min_length = option.minLength;\n base.max_length = option.maxLength;\n break;\n case \"integer\":\n case \"number\":\n base.choices = option.choices?.map(choicePayload);\n base.autocomplete = option.autocomplete;\n base.min_value = option.minValue;\n base.max_value = option.maxValue;\n break;\n case \"channel\":\n base.channel_types = option.channelTypes;\n break;\n }\n return compact(base);\n}\n\nfunction choicePayload(choice: {\n name: string;\n value: string | number;\n nameLocalizations?: unknown;\n}) {\n return compact({\n name: choice.name,\n value: choice.value,\n name_localizations: choice.nameLocalizations,\n });\n}\n\nfunction localizations(meta: { nameLocalizations?: unknown; descriptionLocalizations?: unknown }) {\n return {\n name_localizations: meta.nameLocalizations,\n description_localizations: meta.descriptionLocalizations,\n };\n}\n\nfunction topLevelPayload(meta: TopLevelMeta): Record<string, unknown> {\n const perms = meta.defaultMemberPermissions;\n return {\n default_member_permissions:\n perms === undefined ? undefined : perms === null ? null : String(perms),\n nsfw: meta.nsfw,\n contexts: meta.contexts,\n integration_types: meta.integrationTypes,\n };\n}\n\nfunction compact<T extends Record<string, unknown>>(object: T): T {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(object)) {\n if (value !== undefined) out[key] = value;\n }\n return out as T;\n}\n\nfunction relative(file: string | undefined): string {\n return file === undefined ? \"?\" : path.relative(process.cwd(), file).split(path.sep).join(\"/\");\n}\n","import { Events } from \"discord.js\";\nimport { Diagnostics } from \"../compiler/diagnostics.js\";\nimport { loadModule } from \"../compiler/load.js\";\nimport type { Route, RouteTable } from \"../compiler/routes.js\";\nimport { formatSegment } from \"../compiler/segments.js\";\nimport { checkDeclaredRoute } from \"../components/compile.js\";\n\n/** `export const meta` in an `event.ts`. Every field is optional. */\nexport interface EventMeta {\n /** Remove the listener after the first call. */\n once?: boolean;\n /** Handlers of the same event run in ascending order. Ties break on route identity. Defaults to 0. */\n order?: number;\n /**\n * How the handlers of this event run relative to each other. Every handler that sets it\n * must agree. Defaults to `\"sequential\"`.\n */\n mode?: EventMode;\n}\n\nexport type EventMode = \"sequential\" | \"concurrent\";\n\nexport interface EventHandler {\n route: Route;\n once: boolean;\n order: number;\n}\n\nexport interface CompiledEvent {\n /** discord.js event name, for example `guildMemberAdd`. */\n name: string;\n mode: EventMode;\n /** In execution order. */\n handlers: EventHandler[];\n}\n\nexport interface CompiledEvents {\n events: CompiledEvent[];\n diagnostics: Diagnostics;\n}\n\nconst EVENT_NAMES: ReadonlySet<string> = new Set(Object.values(Events));\n\n/** Renamed events whose old name still shows up in older discord.js code. */\nconst RENAMED: Record<string, string> = {\n ready: Events.ClientReady,\n};\n\ninterface LoadedHandler extends EventHandler {\n name: string;\n mode: EventMode | undefined;\n}\n\n/** Groups event routes by discord.js event and validates their names and `meta`. */\nexport async function compileEvents(table: RouteTable): Promise<CompiledEvents> {\n const diagnostics = new Diagnostics();\n const routes = table.routes.filter((r) => r.kind === \"event\");\n\n const loaded = await Promise.all(routes.map((route) => loadHandler(route, diagnostics)));\n\n const byName = new Map<string, LoadedHandler[]>();\n for (const handler of loaded) {\n if (handler === null) continue;\n byName.set(handler.name, [...(byName.get(handler.name) ?? []), handler]);\n }\n\n const events: CompiledEvent[] = [];\n for (const [name, handlers] of [...byName].sort(([a], [b]) => a.localeCompare(b))) {\n const modes = new Set(handlers.map((h) => h.mode).filter((m) => m !== undefined));\n if (modes.size > 1) {\n for (const handler of handlers) {\n if (handler.mode === undefined) continue;\n diagnostics.error(\n \"event-mode-conflict\",\n `Handlers of \"${name}\" disagree on \\`meta.mode\\`: ${[...modes].map((m) => `\"${m}\"`).join(\" and \")}. All handlers of one event share a mode; set it on one file or make them agree.`,\n { file: handler.route.file, route: handler.route.id },\n );\n }\n continue;\n }\n handlers.sort((a, b) => a.order - b.order || a.route.id.localeCompare(b.route.id));\n events.push({\n name,\n mode: modes.values().next().value ?? \"sequential\",\n handlers: handlers.map(({ route, once, order }) => ({ route, once, order })),\n });\n }\n\n return { events, diagnostics };\n}\n\nasync function loadHandler(route: Route, diagnostics: Diagnostics): Promise<LoadedHandler | null> {\n const name = eventName(route, diagnostics);\n if (name === null) return null;\n\n let module: Record<string, unknown>;\n try {\n module = await loadModule(route.file);\n } catch (error) {\n diagnostics.error(\n \"module-load-failed\",\n `Could not import this file: ${error instanceof Error ? error.message : String(error)}`,\n { file: route.file, route: route.id },\n );\n return null;\n }\n\n if (!checkDeclaredRoute(module, route, diagnostics, name)) return null;\n const meta = validateEventMeta(module.meta, route, diagnostics);\n if (meta === null) return null;\n return { route, name, once: meta.once ?? false, order: meta.order ?? 0, mode: meta.mode };\n}\n\nfunction eventName(route: Route, diagnostics: Diagnostics): string | null {\n const statics = route.segments.filter((s) => s.type !== \"group\");\n const first = statics[0];\n if (first === undefined || first.type !== \"static\") return null;\n\n if (statics.length > 1) {\n diagnostics.error(\n \"event-nested-path\",\n `Event handlers live directly under events/<eventName>/. \"${route.path}\" adds ${statics.slice(1).map(formatSegment).join(\"/\")} below the event name. Use a route group like (${statics[1]?.name}) to keep several handlers apart.`,\n { file: route.file, route: route.id },\n );\n return null;\n }\n\n const name = first.name;\n if (EVENT_NAMES.has(name)) return name;\n\n const renamed = RENAMED[name];\n const hint =\n renamed !== undefined\n ? `discord.js renamed it to \"${renamed}\".`\n : closest(name)\n ? `Did you mean \"${closest(name)}\"?`\n : \"Event names are the lowerCamelCase values of discord.js's `Events` enum.\";\n diagnostics.error(\n \"unknown-event\",\n `\"${name}\" is not a discord.js event. ${hint} Rename the directory.`,\n { file: route.file, route: route.id },\n );\n return null;\n}\n\nfunction validateEventMeta(\n value: unknown,\n route: Route,\n diagnostics: Diagnostics,\n): EventMeta | null {\n if (value === undefined) return {};\n const fail = (message: string) => {\n diagnostics.error(\"invalid-meta\", message, { file: route.file, route: route.id });\n return null;\n };\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return fail(\"`meta` must be an object.\");\n }\n const meta = value as Record<string, unknown>;\n if (meta.once !== undefined && typeof meta.once !== \"boolean\") {\n return fail(\"`meta.once` must be a boolean.\");\n }\n if (\n meta.order !== undefined &&\n (typeof meta.order !== \"number\" || !Number.isFinite(meta.order))\n ) {\n return fail(\"`meta.order` must be a finite number.\");\n }\n if (meta.mode !== undefined && meta.mode !== \"sequential\" && meta.mode !== \"concurrent\") {\n return fail('`meta.mode` must be \"sequential\" or \"concurrent\".');\n }\n return meta as EventMeta;\n}\n\n/** Case-insensitive match against known events, to catch `GuildMemberAdd` or `guildmemberadd`. */\nfunction closest(name: string): string | null {\n const lower = name.toLowerCase();\n for (const known of EVENT_NAMES) if (known.toLowerCase() === lower) return known;\n return null;\n}\n","import type { Boundary, Route } from \"./routes.js\";\nimport type { Segment } from \"./segments.js\";\n\nexport interface RouteChains {\n /** Middleware files from the app root down to the route's directory, in execution order. */\n middleware: string[];\n /** Error boundary files from the route's directory up to the app root, nearest first. */\n errors: string[];\n}\n\n/**\n * Picks the boundaries that apply to a route: everything at the app root, plus every\n * boundary in the route's category whose directory is an ancestor of (or equal to) the\n * route's directory. Route groups count as directories here, so a middleware inside\n * `(admin)/` covers only that group.\n */\nexport function resolveChains(route: Route, boundaries: readonly Boundary[]): RouteChains {\n const applicable = boundaries.filter(\n (b) =>\n (b.category === null || b.category === route.category) &&\n isPrefix(b.segments, route.segments),\n );\n const byDepth = (a: Boundary, b: Boundary) => depth(a) - depth(b);\n\n return {\n // Event handlers take discord.js's arguments, not an interaction context, so the runtime\n // runs no middleware for them.\n middleware:\n route.category === \"event\"\n ? []\n : applicable\n .filter((b) => b.kind === \"middleware\")\n .sort(byDepth)\n .map((b) => b.file),\n errors: applicable\n .filter((b) => b.kind === \"error\")\n .sort(byDepth)\n .reverse()\n .map((b) => b.file),\n };\n}\n\n/** Root boundaries sit above the category directory, so they sort before category-level ones. */\nfunction depth(boundary: Boundary): number {\n return boundary.category === null ? -1 : boundary.segments.length;\n}\n\nfunction isPrefix(prefix: readonly Segment[], segments: readonly Segment[]): boolean {\n if (prefix.length > segments.length) return false;\n return prefix.every((s, i) => s.type === segments[i]?.type && s.name === segments[i]?.name);\n}\n","import { readdirSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport type FileKind =\n | \"command\"\n | \"autocomplete\"\n | \"button\"\n | \"select\"\n | \"modal\"\n | \"event\"\n | \"middleware\"\n | \"error\"\n | \"route\";\n\nexport interface SourceFile {\n kind: FileKind;\n /** Absolute path. */\n file: string;\n /** Directory names from the app root down to the file's directory. */\n dirs: string[];\n}\n\nconst RESERVED: Record<string, FileKind> = {\n command: \"command\",\n autocomplete: \"autocomplete\",\n button: \"button\",\n select: \"select\",\n modal: \"modal\",\n event: \"event\",\n middleware: \"middleware\",\n error: \"error\",\n route: \"route\",\n};\n\nconst EXTENSIONS = new Set([\".ts\", \".js\", \".mts\", \".mjs\"]);\n\n/** The route file kind a filename denotes, or `undefined` for ordinary application code. */\nexport function reservedKind(fileName: string): FileKind | undefined {\n const ext = path.extname(fileName);\n if (!EXTENSIONS.has(ext)) return undefined;\n const base = fileName.slice(0, -ext.length);\n if (base.endsWith(\".test\") || base.endsWith(\".spec\")) return undefined;\n return RESERVED[base];\n}\n\n/**\n * Walks the app directory and returns every reserved file, sorted by path.\n * Anything that is not a reserved filename is ordinary application code and is skipped.\n */\nexport function discover(appDir: string): SourceFile[] {\n const files: SourceFile[] = [];\n walk(path.resolve(appDir), [], files);\n files.sort((a, b) => (a.file < b.file ? -1 : a.file > b.file ? 1 : 0));\n return files;\n}\n\nfunction walk(dir: string, dirs: string[], out: SourceFile[]): void {\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n walk(full, [...dirs, entry.name], out);\n continue;\n }\n if (!entry.isFile()) continue;\n const kind = reservedKind(entry.name);\n if (kind === undefined) continue;\n out.push({ kind, file: full, dirs });\n }\n}\n","import { createHash } from \"node:crypto\";\n\n/**\n * Short, stable identifier used inside custom IDs.\n * First 6 base36 characters of the SHA-256 of the canonical route identity.\n */\nexport function shortId(routeId: string): string {\n const hex = createHash(\"sha256\").update(routeId).digest(\"hex\").slice(0, 16);\n return BigInt(`0x${hex}`).toString(36).padStart(6, \"0\").slice(0, 6);\n}\n","import path from \"node:path\";\nimport { Diagnostics } from \"./diagnostics.js\";\nimport { discover, type FileKind, type SourceFile } from \"./discover.js\";\nimport { shortId } from \"./identity.js\";\nimport { formatSegment, parseSegment, type Segment } from \"./segments.js\";\n\nexport type RouteCategory = \"command\" | \"component\" | \"event\";\n\nexport type RouteKind = \"command\" | \"autocomplete\" | \"button\" | \"select\" | \"modal\" | \"event\";\n\nexport interface Route {\n /** Canonical identity, `<category>:<path>`. */\n id: string;\n /** Six character hash of `id`, used in custom IDs. */\n shortId: string;\n category: RouteCategory;\n kind: RouteKind;\n /** Segments joined by `/`. Groups are stripped, except for events where they keep handlers distinct. */\n path: string;\n /** Every segment below the category directory, groups included. */\n segments: Segment[];\n /** Dynamic and catch-all parameter names, in route order. */\n params: string[];\n /** Absolute path of the handler file. */\n file: string;\n}\n\nexport type BoundaryKind = \"middleware\" | \"error\" | \"route\";\n\nexport interface Boundary {\n kind: BoundaryKind;\n /** `null` at the app root, otherwise the category the boundary lives under. */\n category: RouteCategory | null;\n /** Segments below the category directory, groups included. Empty at the category root. */\n segments: Segment[];\n file: string;\n}\n\nexport interface RouteTable {\n routes: Route[];\n boundaries: Boundary[];\n diagnostics: Diagnostics;\n}\n\nconst CATEGORY_DIRS: Record<string, RouteCategory> = {\n commands: \"command\",\n components: \"component\",\n events: \"event\",\n};\n\nconst HANDLER_KINDS: Record<RouteCategory, ReadonlySet<FileKind>> = {\n command: new Set([\"command\", \"autocomplete\"]),\n component: new Set([\"button\", \"select\", \"modal\"]),\n event: new Set([\"event\"]),\n};\n\nconst BOUNDARY_KINDS: ReadonlySet<FileKind> = new Set([\"middleware\", \"error\", \"route\"]);\n\n/** Discovers the app directory and builds the route table. */\nexport function buildRouteTable(appDir: string): RouteTable {\n return buildRouteTableFromFiles(discover(appDir));\n}\n\nexport function buildRouteTableFromFiles(files: SourceFile[]): RouteTable {\n const diagnostics = new Diagnostics();\n const routes: Route[] = [];\n const boundaries: Boundary[] = [];\n\n for (const source of files) {\n const [categoryDir, ...rest] = source.dirs;\n\n if (categoryDir === undefined) {\n if (source.kind === \"middleware\" || source.kind === \"error\") {\n boundaries.push({ kind: source.kind, category: null, segments: [], file: source.file });\n } else {\n diagnostics.error(\n \"file-outside-category\",\n `${path.basename(source.file)} must live under commands/, components/, or events/. Only middleware and error files may sit at the app root.`,\n { file: source.file },\n );\n }\n continue;\n }\n\n const category = CATEGORY_DIRS[categoryDir];\n if (category === undefined) {\n diagnostics.error(\n \"unknown-category\",\n `\"${categoryDir}/\" is not a route area. Reserved files must live under commands/, components/, or events/.`,\n { file: source.file },\n );\n continue;\n }\n\n const segments = parseSegments(rest, source, diagnostics);\n if (segments === null) continue;\n\n if (BOUNDARY_KINDS.has(source.kind)) {\n boundaries.push({\n kind: source.kind as BoundaryKind,\n category,\n segments,\n file: source.file,\n });\n continue;\n }\n\n if (!HANDLER_KINDS[category].has(source.kind)) {\n diagnostics.error(\n \"file-in-wrong-category\",\n `${path.basename(source.file)} does not belong under ${categoryDir}/. Expected one of: ${[...HANDLER_KINDS[category]].map((k) => `${k}.ts`).join(\", \")}.`,\n { file: source.file },\n );\n continue;\n }\n\n const route = makeRoute(category, source.kind as RouteKind, segments, source.file, diagnostics);\n if (route !== null) routes.push(route);\n }\n\n detectDuplicates(routes, diagnostics);\n\n return { routes, boundaries, diagnostics };\n}\n\nfunction parseSegments(\n dirs: string[],\n source: SourceFile,\n diagnostics: Diagnostics,\n): Segment[] | null {\n const segments: Segment[] = [];\n for (const dir of dirs) {\n const result = parseSegment(dir);\n if (!result.ok) {\n diagnostics.error(\"invalid-segment\", result.reason, { file: source.file });\n return null;\n }\n segments.push(result.segment);\n }\n return segments;\n}\n\nfunction makeRoute(\n category: RouteCategory,\n kind: RouteKind,\n segments: Segment[],\n file: string,\n diagnostics: Diagnostics,\n): Route | null {\n if (segments.length === 0) {\n diagnostics.error(\n \"route-without-path\",\n `${path.basename(file)} needs a named directory. Files directly inside ${category}s/ have no route path.`,\n { file },\n );\n return null;\n }\n\n const params: string[] = [];\n for (const [index, segment] of segments.entries()) {\n if (segment.type === \"dynamic\" || segment.type === \"catchAll\") {\n if (category !== \"component\") {\n diagnostics.error(\n \"dynamic-segment-not-allowed\",\n `${formatSegment(segment)} is a dynamic segment, but ${category} routes cannot carry parameters. Only component routes can.`,\n { file },\n );\n return null;\n }\n if (params.includes(segment.name)) {\n diagnostics.error(\n \"duplicate-param\",\n `Parameter \"${segment.name}\" appears twice in the same route.`,\n { file },\n );\n return null;\n }\n if (segment.type === \"catchAll\" && index !== segments.length - 1) {\n diagnostics.error(\n \"catch-all-not-last\",\n `${formatSegment(segment)} must be the last segment of the route.`,\n { file },\n );\n return null;\n }\n params.push(segment.name);\n }\n }\n\n const routePath = segments\n .filter((segment) => segment.type !== \"group\" || category === \"event\")\n .map(formatSegment)\n .join(\"/\");\n\n if (routePath === \"\") {\n diagnostics.error(\n \"route-without-path\",\n `${path.basename(file)} sits only inside route groups. Groups do not contribute to the route, so this route has no path.`,\n { file },\n );\n return null;\n }\n\n const id = `${category}:${routePath}`;\n return { id, shortId: shortId(id), category, kind, path: routePath, segments, params, file };\n}\n\n/**\n * A command and its autocomplete share an ID. A component route has exactly one handler of any\n * kind, since the handler's types come from the path alone.\n */\nfunction detectDuplicates(routes: Route[], diagnostics: Diagnostics): void {\n const seen = new Map<string, Route>();\n for (const route of routes) {\n const key = route.category === \"component\" ? route.id : `${route.id}#${route.kind}`;\n const existing = seen.get(key);\n if (existing === undefined) {\n seen.set(key, route);\n continue;\n }\n diagnostics.error(\n \"duplicate-route\",\n existing.kind === route.kind\n ? `Route ${route.id} is defined twice: ${existing.file} and ${route.file}. Route groups do not make paths distinct.`\n : `Route ${route.id} has two handlers: ${existing.file} and ${route.file}. A component route takes one button.ts, select.ts, or modal.ts. Move one into its own directory.`,\n { file: route.file, route: route.id },\n );\n }\n}\n","import path from \"node:path\";\nimport { type CompiledAutocomplete, compileAutocomplete } from \"../autocomplete/compile.js\";\nimport { type CompiledCommand, compileCommands } from \"../commands/compile.js\";\nimport { type ComponentRoute, compileComponents } from \"../components/compile.js\";\nimport { type CompiledEvent, compileEvents } from \"../events/compile.js\";\nimport { type RouteChains, resolveChains } from \"./chains.js\";\nimport { Diagnostics } from \"./diagnostics.js\";\nimport { type Boundary, buildRouteTable, type Route } from \"./routes.js\";\n\n/**\n * Everything the compiler knows about an app, after every category has been validated.\n * The manifest is a serialization of this.\n */\nexport interface RouteGraph {\n /** Absolute path of the app directory. */\n appDir: string;\n /** Every handler route, in discovery order. */\n routes: Route[];\n boundaries: Boundary[];\n /** Middleware and error chains keyed by the route's handler file. */\n chains: Map<string, RouteChains>;\n commands: CompiledCommand[];\n components: ComponentRoute[];\n events: CompiledEvent[];\n autocomplete: CompiledAutocomplete[];\n /** Plugin names that changed a route's chains, keyed by handler file. Filled by `applyPlugins`. */\n plugins: Map<string, string[]>;\n /** Diagnostics from every stage, in pipeline order. */\n diagnostics: Diagnostics;\n}\n\n/** Runs the whole compiler pipeline on an app directory. */\nexport async function buildGraph(appDir: string): Promise<RouteGraph> {\n const absolute = path.resolve(appDir);\n const table = buildRouteTable(absolute);\n const diagnostics = new Diagnostics();\n diagnostics.items.push(...table.diagnostics.items);\n\n const [commands, components, events] = await Promise.all([\n compileCommands(table),\n compileComponents(table),\n compileEvents(table),\n ]);\n const autocomplete = await compileAutocomplete(table, commands.commands);\n\n for (const stage of [commands, components, events, autocomplete]) {\n diagnostics.items.push(...stage.diagnostics.items);\n }\n\n const chains = new Map<string, RouteChains>();\n for (const route of table.routes) chains.set(route.file, resolveChains(route, table.boundaries));\n\n return {\n appDir: absolute,\n routes: table.routes,\n boundaries: table.boundaries,\n chains,\n commands: commands.commands,\n components: components.routes,\n events: events.events,\n autocomplete: autocomplete.autocomplete,\n plugins: new Map(),\n diagnostics,\n };\n}\n","import { styleText } from \"node:util\";\n\n/**\n * Terminal formatting for the CLI and dev server. Colors are off until the bin turns them on\n * for a TTY, so tests and piped output see plain text with the same glyphs.\n */\nlet colors = false;\n\nexport function setColors(enabled: boolean): void {\n colors = enabled;\n}\n\ntype Style = Parameters<typeof styleText>[0];\n\nconst paint =\n (style: Style) =>\n (text: string): string =>\n colors ? styleText(style, text) : text;\n\nexport const c = {\n bold: paint(\"bold\"),\n dim: paint(\"dim\"),\n red: paint(\"red\"),\n green: paint(\"green\"),\n yellow: paint(\"yellow\"),\n cyan: paint(\"cyan\"),\n magenta: paint(\"magenta\"),\n underline: paint(\"underline\"),\n};\n\nexport const ok = (text: string): string => `${c.green(\"✔\")} ${text}`;\nexport const fail = (text: string): string => `${c.red(\"✖\")} ${text}`;\nexport const warn = (text: string): string => `${c.yellow(\"▲\")} ${text}`;\nexport const info = (text: string): string => `${c.cyan(\"›\")} ${text}`;\nexport const link = (url: string): string => c.underline(c.cyan(url));\n\nexport const PORTAL_URL = \"https://discord.com/developers/applications\";\n\nexport function indent(lines: readonly string[], by = 2): string[] {\n return lines.map((line) => (line === \"\" ? \"\" : `${\" \".repeat(by)}${line}`));\n}\n\n/** A headline followed by indented detail lines, as one multi-line string. */\nexport function block(head: string, details: readonly string[] = []): string {\n return details.length === 0 ? head : [head, \"\", ...indent(details)].join(\"\\n\");\n}\n\n/** Two-column rows with dim keys, aligned on the widest key. */\nexport function table(rows: readonly (readonly [string, string])[]): string[] {\n const width = Math.max(0, ...rows.map(([key]) => key.length));\n return rows.map(([key, value]) => `${c.dim(key.padEnd(width))} ${value}`);\n}\n\n/** `HH:MM:SS`, dimmed. Prefix for dev server lines that happen while it runs. */\nexport function stamp(): string {\n return c.dim(new Date().toTimeString().slice(0, 8));\n}\n\n/** How to supply a credential, shared by every command that needs one. */\nexport function credentialHint(kind: \"token\" | \"applicationId\", configName: string): string[] {\n const variable = kind === \"token\" ? \"DISCORD_TOKEN\" : \"DISCORD_APPLICATION_ID\";\n const where =\n kind === \"token\"\n ? \"your application → Bot → Reset Token\"\n : \"your application → General Information → Application ID\";\n return [\n `Put ${c.bold(`${variable}=...`)} in ${c.bold(\".env\")} next to ${configName}, or export it.`,\n `The config reads it with ${c.bold(`${kind}: process.env.${variable}`)}; without that line the`,\n \"variable is used directly.\",\n `Get it from the Developer Portal under ${where}:`,\n link(PORTAL_URL),\n ];\n}\n","import path from \"node:path\";\nimport type { Diagnostic } from \"../compiler/diagnostics.js\";\nimport { buildGraph, type RouteGraph } from \"../compiler/graph.js\";\nimport { checkIntents } from \"../events/index.js\";\nimport { applyPlugins } from \"../plugins/index.js\";\nimport type { CliIo } from \"./io.js\";\nimport type { Project } from \"./project.js\";\nimport { c, fail, indent, warn } from \"./ui.js\";\n\n/**\n * Compiles the app, runs plugin transforms, and prints every diagnostic. Returns `null` when\n * any is an error.\n */\nexport async function compileProject(project: Project, io: CliIo): Promise<RouteGraph | null> {\n const graph = await buildGraph(project.appDir);\n graph.diagnostics.items.push(\n ...checkIntents(graph.events, project.config.intents, path.basename(project.configFile)),\n );\n if (!graph.diagnostics.hasErrors) await applyPlugins(graph, project.config.plugins ?? []);\n for (const diagnostic of graph.diagnostics.items) {\n io.err(formatDiagnostic(diagnostic, project.root));\n }\n if (graph.diagnostics.hasErrors) {\n const errors = graph.diagnostics.items.filter((d) => d.severity === \"error\").length;\n io.err(fail(`${errors} error${errors === 1 ? \"\" : \"s\"}. Fix the files above and run again.`));\n return null;\n }\n return graph;\n}\n\n/**\n * One diagnostic as a headline and an indented message:\n *\n * ✖ error invalid-name app/commands/Bad Name/command.ts\n * Command names must be lowercase ...\n */\nexport function formatDiagnostic(diagnostic: Diagnostic, root: string): string {\n const mark = diagnostic.severity === \"error\" ? fail(c.red(\"error\")) : warn(c.yellow(\"warning\"));\n const where = diagnostic.file === undefined ? \"\" : ` ${relative(root, diagnostic.file)}`;\n return [`${mark} ${c.dim(diagnostic.code)}${where}`, ...indent([diagnostic.message])].join(\"\\n\");\n}\n\nexport function relative(root: string, file: string): string {\n return path.relative(root, file).split(path.sep).join(\"/\");\n}\n\nexport function summary(graph: RouteGraph): string {\n const n = (count: number, noun: string) => `${count} ${noun}${count === 1 ? \"\" : \"s\"}`;\n return [\n n(graph.commands.length, \"command\"),\n n(graph.components.length, \"component route\"),\n n(graph.events.length, \"event\"),\n ].join(\", \");\n}\n","import type { Client } from \"discord.js\";\nimport type { NectarConfig } from \"../config.js\";\nimport type { CommandRest } from \"../registration/index.js\";\n\n/** What a CLI command can touch. The bin passes the real process; tests pass buffers. */\nexport interface CliIo {\n cwd: string;\n env: NodeJS.ProcessEnv;\n out(line: string): void;\n err(line: string): void;\n /** Builds the REST client `sync` talks to. Tests swap in a fake. */\n rest?: (token: string) => Promise<CommandRest>;\n /** Builds the discord.js client `dev` and `start` run. Tests swap in a fake that never logs in. */\n client?: (config: NectarConfig) => Client;\n}\n\nexport const EXIT_OK = 0;\nexport const EXIT_FAILURE = 1;\nexport const EXIT_USAGE = 2;\n\n/**\n * A problem the user can fix. Printed without a stack trace: the message as the headline,\n * then `details` indented under it (what went wrong in full, and what to do about it).\n */\nexport class CliError extends Error {\n readonly code: number;\n readonly details: readonly string[];\n\n constructor(message: string, options: { code?: number; details?: readonly string[] } = {}) {\n super(message);\n this.name = \"CliError\";\n this.code = options.code ?? EXIT_FAILURE;\n this.details = options.details ?? [];\n }\n}\n","import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { loadModule } from \"../compiler/load.js\";\nimport { ConfigError, configFor, type NectarConfig, validateConfig } from \"../config.js\";\nimport type { Env } from \"../runtime/types.js\";\nimport { CliError } from \"./io.js\";\nimport { c } from \"./ui.js\";\n\nexport const CONFIG_FILES = [\"nectar.config.ts\", \"nectar.config.js\"];\n\nexport interface Project {\n /** Directory holding the config file. Every relative config path resolves against it. */\n root: string;\n configFile: string;\n /** With the overrides for `env` applied. */\n config: NectarConfig;\n appDir: string;\n outDir: string;\n env: Env;\n}\n\n/** Finds and validates `nectar.config.ts` in `cwd`. */\nexport async function loadProject(cwd: string, env: NodeJS.ProcessEnv): Promise<Project> {\n const configFile = CONFIG_FILES.map((name) => path.join(cwd, name)).find((f) => existsSync(f));\n if (configFile === undefined) {\n throw new CliError(`No ${CONFIG_FILES[0]} in ${cwd}.`, {\n details: [\n \"Run nectar from the directory that holds your config file.\",\n `Starting fresh? ${c.bold(\"npm create @nectar-js\")} sets up a project.`,\n ],\n });\n }\n const name = path.basename(configFile);\n let loaded: NectarConfig;\n try {\n const module = await loadModule(configFile);\n loaded = validateConfig(module.default, name);\n } catch (error) {\n if (error instanceof ConfigError) {\n throw new CliError(`${name} is not valid.`, { details: [error.detail] });\n }\n throw new CliError(`Could not load ${name}.`, { details: [describe(error)] });\n }\n const projectEnv = loaded.env ?? envFrom(env.NODE_ENV);\n const config = configFor(loaded, projectEnv);\n const root = path.dirname(configFile);\n const appDir = path.resolve(root, config.appDir ?? \"app\");\n if (!existsSync(appDir)) {\n throw new CliError(`App directory ${path.relative(root, appDir) || \".\"}/ does not exist.`, {\n details: [`Create it, or point ${c.bold(\"appDir\")} in ${name} at the right place.`],\n });\n }\n return {\n root,\n configFile,\n config,\n appDir,\n outDir: path.resolve(root, config.outDir ?? \".nectar\"),\n env: projectEnv,\n };\n}\n\nexport function envFrom(value: string | undefined): Env {\n return value === \"production\" || value === \"test\" ? value : \"development\";\n}\n\nexport function describe(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n","import { writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { toManifest, writeManifest } from \"../manifest/index.js\";\nimport { writeTypes } from \"../typegen/index.js\";\nimport { compileProject, relative, summary } from \"./compile.js\";\nimport { type CliIo, EXIT_FAILURE, EXIT_OK } from \"./io.js\";\nimport { loadProject, type Project } from \"./project.js\";\nimport { c, ok, warn } from \"./ui.js\";\n\n/** `.mjs` so it loads as ESM whatever the project's `package.json` says, and PM2 imports it. */\nconst START_FILE = \"start.mjs\";\n\n/** `nectar build`: compile, then write the manifest, generated types, and `start.mjs` into `outDir`. */\nexport async function build(io: CliIo): Promise<number> {\n const project = await loadProject(io.cwd, io.env);\n const graph = await compileProject(project, io);\n if (graph === null) return EXIT_FAILURE;\n\n const manifestFile = writeManifest(toManifest(graph, project.outDir), project.outDir);\n const typesFile = writeTypes(graph, project.outDir, project.config.plugins);\n const startFile = writeStart(project);\n io.out(ok(`Built ${summary(graph)}.`));\n for (const file of [manifestFile, typesFile, startFile]) {\n io.out(` ${c.dim(relative(project.root, file))}`);\n }\n return EXIT_OK;\n}\n\n/**\n * `node .nectar/start.mjs` does what `nectar start` does, from any working directory. It is the\n * file to hand a ShardingManager or cluster manager: each shard loads the manifest itself and\n * none of them registers commands.\n */\nfunction writeStart(project: Project): string {\n const root = path.relative(project.outDir, project.root).split(path.sep).join(\"/\");\n const file = path.join(project.outDir, START_FILE);\n writeFileSync(\n file,\n [\n \"// Written by nectar build. Runs the bot from this build, like `nectar start`.\",\n 'import { start } from \"@nectar-js/nectar/start\";',\n \"\",\n `await start(new URL(${JSON.stringify(`${root || \".\"}/`)}, import.meta.url));`,\n \"\",\n ].join(\"\\n\"),\n );\n return file;\n}\n\n/** `nectar check`: compile and report, writing nothing. */\nexport async function check(io: CliIo): Promise<number> {\n const project = await loadProject(io.cwd, io.env);\n const graph = await compileProject(project, io);\n if (graph === null) return EXIT_FAILURE;\n const warnings = graph.diagnostics.items.length;\n io.out(\n warnings === 0\n ? ok(\n `No problems. ${summary(graph)} in ${path.relative(project.root, project.appDir) || \".\"}/.`,\n )\n : warn(`${warnings} warning${warnings === 1 ? \"\" : \"s\"}, no errors.`),\n );\n return EXIT_OK;\n}\n","import path from \"node:path\";\nimport { ApplicationCommandType } from \"discord-api-types/v10\";\nimport type { RouteGraph } from \"../compiler/graph.js\";\nimport type { Route } from \"../compiler/routes.js\";\nimport type { ComponentRoute } from \"../components/compile.js\";\nimport { compileProject, relative } from \"./compile.js\";\nimport { type CliIo, EXIT_FAILURE, EXIT_OK } from \"./io.js\";\nimport { loadProject } from \"./project.js\";\nimport { c } from \"./ui.js\";\n\n/** `nectar routes`: print the app tree with what every file and directory means. */\nexport async function routes(io: CliIo): Promise<number> {\n const project = await loadProject(io.cwd, io.env);\n const graph = await compileProject(project, io);\n if (graph === null) return EXIT_FAILURE;\n io.out(renderRoutes(graph, project.root));\n return EXIT_OK;\n}\n\ninterface Node {\n name: string;\n notes: string[];\n children: Map<string, Node>;\n /** Files sort before directories. */\n file: boolean;\n}\n\n/**\n * A directory tree of the app. Handler files annotate their directory; middleware, error, and\n * route files appear as leaves so the scope of each is where it sits in the tree.\n */\nexport function renderRoutes(graph: RouteGraph, root: string): string {\n const tree: Node = {\n name: relative(root, graph.appDir) || \".\",\n notes: [],\n children: new Map(),\n file: false,\n };\n const nodeFor = (file: string, asFile: boolean): Node => {\n const parts = relative(graph.appDir, asFile ? file : path.dirname(file)).split(\"/\");\n let node = tree;\n for (const part of parts.filter((p) => p !== \"\" && p !== \".\")) {\n let child = node.children.get(part);\n if (child === undefined) {\n child = { name: part, notes: [], children: new Map(), file: false };\n node.children.set(part, child);\n }\n node = child;\n }\n node.file = asFile;\n return node;\n };\n const annotate = (route: Route, note: string) => nodeFor(route.file, false).notes.push(note);\n\n for (const command of graph.commands) {\n for (const [position, route] of Object.entries(command.handlers)) {\n annotate(route, commandLabel(command.type, command.name, position));\n }\n }\n for (const entry of graph.autocomplete) {\n annotate(entry.route, `autocomplete: ${entry.options.join(\", \")}`);\n }\n for (const route of graph.components) annotate(route, componentLabel(route));\n for (const event of graph.events) {\n for (const handler of event.handlers) {\n const flags = [handler.once ? \"once\" : null, event.handlers.length > 1 ? event.mode : null];\n annotate(handler.route, `event ${event.name}${suffix(flags)}`);\n }\n }\n for (const boundary of graph.boundaries) {\n const node = nodeFor(boundary.file, true);\n if (boundary.kind === \"route\") {\n node.notes.push(\"command metadata\");\n continue;\n }\n const covered = graph.routes.filter((r) => {\n const chain = graph.chains.get(r.file);\n return (boundary.kind === \"middleware\" ? chain?.middleware : chain?.errors)?.includes(\n boundary.file,\n );\n }).length;\n node.notes.push(\n `${boundary.kind === \"middleware\" ? \"middleware\" : \"error boundary\"} for ${covered} route${covered === 1 ? \"\" : \"s\"}`,\n );\n }\n\n const lines: [string, string][] = [];\n print(tree, \"\", true, true, lines);\n const width = Math.max(...lines.map(([left]) => left.length));\n return lines\n .map(([left, right]) => (right === \"\" ? left : `${left.padEnd(width)} ${c.dim(right)}`))\n .join(\"\\n\");\n}\n\nfunction print(\n node: Node,\n prefix: string,\n last: boolean,\n isRoot: boolean,\n out: [string, string][],\n) {\n const branch = isRoot ? \"\" : last ? \"└── \" : \"├── \";\n out.push([`${prefix}${branch}${node.name}`, node.notes.join(\" · \")]);\n const children = [...node.children.values()].sort(\n (a, b) => Number(b.file) - Number(a.file) || a.name.localeCompare(b.name),\n );\n const childPrefix = isRoot ? \"\" : `${prefix}${last ? \" \" : \"│ \"}`;\n children.forEach((child, i) => {\n print(child, childPrefix, i === children.length - 1, false, out);\n });\n}\n\nfunction commandLabel(type: ApplicationCommandType, name: string, position: string): string {\n if (type === ApplicationCommandType.User) return `user context menu \"${name}\"`;\n if (type === ApplicationCommandType.Message) return `message context menu \"${name}\"`;\n return `/${[name, ...position.split(\"/\").filter((p) => p !== \"\")].join(\" \")}`;\n}\n\nfunction componentLabel(route: ComponentRoute): string {\n const kind = route.kind === \"select\" ? `select (${route.selectKind})` : route.kind;\n const pattern = [\n `n:${route.shortId}`,\n ...route.params.map((p) => (p === route.catchAll ? `<...${p}>` : `<${p}>`)),\n ].join(\":\");\n return `${kind} ${pattern}`;\n}\n\nfunction suffix(flags: (string | null)[]): string {\n const present = flags.filter((f): f is string => f !== null);\n return present.length === 0 ? \"\" : ` (${present.join(\", \")})`;\n}\n","import type { RouteGraph } from \"../compiler/graph.js\";\nimport {\n type CommandRest,\n RegistrationError,\n registrationScopes,\n type ScopeSync,\n type SyncResult,\n scopeKey,\n syncCommands,\n UnsafeSyncError,\n} from \"../registration/index.js\";\nimport type { LoginError } from \"../runtime/index.js\";\nimport { compileProject } from \"./compile.js\";\nimport { CliError, type CliIo, EXIT_FAILURE, EXIT_OK } from \"./io.js\";\nimport { describe, loadProject, type Project } from \"./project.js\";\nimport { c, credentialHint, info, link, ok, PORTAL_URL, warn } from \"./ui.js\";\n\nexport const TOKEN_VAR = \"DISCORD_TOKEN\";\nexport const APPLICATION_ID_VAR = \"DISCORD_APPLICATION_ID\";\n\n/** `nectar sync [--dry-run] [--force]`: register the compiled commands with Discord. */\nexport async function sync(io: CliIo, dryRun: boolean, force: boolean): Promise<number> {\n const project = await loadProject(io.cwd, io.env);\n const graph = await compileProject(project, io);\n if (graph === null) return EXIT_FAILURE;\n if (registrationScopes(project.config, project.env).length === 0) {\n throw new CliError(`No registration target for ${project.env}.`, {\n details: registrationHint(project),\n });\n }\n const result = await registerCommands(project, graph, io, { dryRun, force });\n for (const scope of result.scopes) io.out(describeScope(scope, dryRun));\n if (result.unsafe.length > 0) {\n io.err(warn(force ? \"Forced past the safety guard:\" : \"The safety guard would refuse this:\"));\n for (const reason of result.unsafe) io.err(` ${reason}`);\n }\n return EXIT_OK;\n}\n\n/**\n * Registers a compiled graph's commands in this environment's scopes. Missing credentials,\n * the safety guard, and Discord validation failures all surface as `CliError`.\n */\nexport async function registerCommands(\n project: Project,\n graph: RouteGraph,\n io: CliIo,\n options: { dryRun?: boolean; force?: boolean } = {},\n): Promise<SyncResult> {\n const token = credential(project, io, \"token\");\n const applicationId = credential(project, io, \"applicationId\");\n const rest = await (io.rest ?? discordRest)(token);\n try {\n return await syncCommands({\n rest,\n applicationId,\n commands: graph.commands.map((cmd) => cmd.payload),\n scopes: registrationScopes(project.config, project.env),\n cacheDir: project.outDir,\n dryRun: options.dryRun ?? false,\n force: options.force ?? false,\n });\n } catch (error) {\n if (error instanceof UnsafeSyncError) {\n throw new CliError(\"Refusing to register commands: this looks destructive.\", {\n details: [\n ...error.reasons,\n \"\",\n `If that is what you want, run again with ${c.bold(\"--force\")}.`,\n ],\n });\n }\n if (error instanceof RegistrationError) {\n throw new CliError(`Discord rejected the ${scopeKey(error.scope)} command registration.`, {\n details: error.problems.map(\n (p) =>\n `${c.bold(p.command ?? \"(request)\")}${p.field === \"\" ? \"\" : ` ${c.dim(p.field)}`}: ${p.message}`,\n ),\n });\n }\n throw error;\n }\n}\n\n/** One line per scope: what changed there and whether it was written. */\nexport function describeScope({ scope, diff, applied }: ScopeSync, dryRun = false): string {\n const key = c.bold(scopeKey(scope));\n if (diff === null) return ok(`${key}: unchanged since last sync.`);\n if (!diff.hasChanges) return ok(`${key}: up to date, ${diff.unchanged.length} command(s).`);\n const parts = [\n ...diff.added.map((n) => c.green(`+${n}`)),\n ...diff.changed.map((n) => c.yellow(`~${n}`)),\n ...diff.removed.map((n) => c.red(`-${n}`)),\n ].join(\" \");\n if (dryRun) return info(`${key}: ${parts} ${c.dim(\"(would apply)\")}`);\n return applied\n ? ok(`${key}: ${parts} ${c.dim(\"(applied)\")}`)\n : warn(`${key}: ${parts} ${c.dim(\"(not applied)\")}`);\n}\n\nexport type Credential = \"token\" | \"applicationId\";\n\nexport const CREDENTIAL_VARS: Record<Credential, string> = {\n token: TOKEN_VAR,\n applicationId: APPLICATION_ID_VAR,\n};\n\n/** The config field wins; the env var is the fallback. Empty strings count as unset. */\nexport function findCredential(project: Project, io: CliIo, kind: Credential): string | null {\n const value = project.config[kind] || io.env[CREDENTIAL_VARS[kind]];\n return value === undefined || value === \"\" ? null : value;\n}\n\nexport function credential(project: Project, io: CliIo, kind: Credential): string {\n const value = findCredential(project, io, kind);\n if (value === null) {\n throw new CliError(`${CREDENTIAL_VARS[kind]} is not set.`, {\n details: credentialHint(kind, projectConfigName(project)),\n });\n }\n return value;\n}\n\n/** A failed login as something to fix: the token, or the connection to Discord. */\nexport function loginFailure(error: LoginError, project: Project): CliError {\n if (!error.invalidToken) {\n return new CliError(\"Could not log in to Discord.\", { details: [describe(error.cause)] });\n }\n const source = project.config.token\n ? `${c.bold(\"token\")} in ${projectConfigName(project)}`\n : c.bold(TOKEN_VAR);\n return new CliError(\"Discord rejected the bot token.\", {\n details: [\n `The token from ${source} is wrong, or it was reset.`,\n \"Get a new one from the Developer Portal under your application → Bot → Reset Token:\",\n link(PORTAL_URL),\n ],\n });\n}\n\nexport function registrationHint(project: Project): string[] {\n return [\n `Add your test server's ID to ${c.bold(\"dev.guilds\")} in ${projectConfigName(project)}.`,\n \"Find it in Discord: Server Settings → Widget → Server ID, or right-click the server\",\n \"with Developer Mode on and choose Copy Server ID.\",\n ];\n}\n\nasync function discordRest(token: string): Promise<CommandRest> {\n const { REST } = await import(\"discord.js\");\n return new REST().setToken(token);\n}\n\nexport function projectConfigName(project: Project): string {\n return project.configFile.split(/[\\\\/]/).at(-1) ?? \"nectar.config.ts\";\n}\n","import path from \"node:path\";\nimport { reservedKind } from \"../compiler/discover.js\";\nimport { stableStringify } from \"../manifest/emit.js\";\nimport type { Manifest } from \"../manifest/schema.js\";\n\n/**\n * What a changed path means for the dev server, decided from the path alone.\n *\n * - `config`: the config file. The runtime restarts.\n * - `route`: a reserved file or a directory under the app directory. The app recompiles and\n * the manifest diff decides what else follows.\n * - `dependency`: any other source file. Every module evaluates again on next use, since\n * nothing tracks who imports it.\n * - `ignored`: build output, `node_modules`, `.git`, tests, non-source files.\n */\nexport type ChangeKind = \"config\" | \"route\" | \"dependency\" | \"ignored\";\n\nexport interface ProjectPaths {\n configFile: string;\n appDir: string;\n outDir: string;\n}\n\nconst SOURCE_EXTENSIONS = new Set([\".ts\", \".js\", \".mts\", \".mjs\", \".cts\", \".cjs\", \".json\"]);\n\nexport function classifyPath(file: string, project: ProjectPaths): ChangeKind {\n const absolute = path.resolve(file);\n if (absolute === path.resolve(project.configFile)) return \"config\";\n const parts = absolute.split(path.sep);\n if (\n parts.includes(\"node_modules\") ||\n parts.includes(\".git\") ||\n within(project.outDir, absolute)\n ) {\n return \"ignored\";\n }\n const name = path.basename(absolute);\n if (within(project.appDir, absolute)) {\n // No extension: a directory was created, renamed, or removed. Its files may not report.\n if (path.extname(name) === \"\" || reservedKind(name) !== undefined) return \"route\";\n }\n if (!SOURCE_EXTENSIONS.has(path.extname(name))) return \"ignored\";\n if (/\\.(test|spec)\\.[cm]?[jt]s$/.test(name)) return \"ignored\";\n return \"dependency\";\n}\n\nfunction within(dir: string, file: string): boolean {\n const rel = path.relative(path.resolve(dir), file);\n return rel !== \"\" && !rel.startsWith(\"..\") && !path.isAbsolute(rel);\n}\n\n/** What a recompile changed, and therefore what the running app must do about it. */\nexport interface ManifestDelta {\n /** Routes, chains, events, or handler positions differ. Dispatch tables must be rebuilt. */\n structure: boolean;\n /** Registration payloads differ. Dev guild commands must be re-registered. */\n commands: boolean;\n}\n\nexport function diffManifests(before: Manifest, after: Manifest): ManifestDelta {\n const payloads = (m: Manifest) => stableStringify(m.commands.map((c) => c.payload));\n const shape = (m: Manifest) =>\n stableStringify({\n routes: m.routes,\n events: m.events,\n commands: m.commands.map(({ payload: _payload, ...rest }) => rest),\n });\n return {\n structure: shape(before) !== shape(after),\n commands: payloads(before) !== payloads(after),\n };\n}\n","import { existsSync } from \"node:fs\";\nimport { type Client, Events } from \"discord.js\";\nimport { compileProject, relative, summary } from \"../cli/compile.js\";\nimport { CliError, type CliIo } from \"../cli/io.js\";\nimport { loadProject, type Project } from \"../cli/project.js\";\nimport { renderRoutes } from \"../cli/routes.js\";\nimport {\n APPLICATION_ID_VAR,\n credential,\n describeScope,\n findCredential,\n loginFailure,\n projectConfigName,\n registerCommands,\n registrationHint,\n} from \"../cli/sync.js\";\nimport { block, c, credentialHint, fail, indent, info, ok, stamp, warn } from \"../cli/ui.js\";\nimport type { RouteGraph } from \"../compiler/graph.js\";\nimport { enableModuleReloading, invalidateModuleGraph } from \"../compiler/load.js\";\nimport { type Manifest, toManifest, writeManifest } from \"../manifest/index.js\";\nimport { registrationScopes, scopeKey } from \"../registration/index.js\";\nimport {\n createLogger,\n createRuntime,\n createSignals,\n HandlerLoadError,\n type Logger,\n LoginError,\n type LogSink,\n manifestFiles,\n type Runtime,\n} from \"../runtime/index.js\";\nimport { writeTypes } from \"../typegen/index.js\";\nimport { classifyPath, diffManifests } from \"./classify.js\";\n\nexport interface DevServerOptions {\n /** Print the full route tree and discord.js warnings. */\n verbose?: boolean;\n}\n\nexport interface DevServer {\n /** Compiles, registers dev guild commands, and starts the bot. Waits for a fix if the app does not compile. */\n start(): Promise<void>;\n /** Reacts to a batch of changed paths: reload handlers, rebuild routes, re-register, or restart. */\n apply(files: string[]): Promise<void>;\n stop(): Promise<void>;\n}\n\n/**\n * The state behind `nectar dev`: the compiled manifest and the runtime serving it. Changes are\n * handled in the smallest way that keeps the running bot correct, and the gateway connection\n * survives everything but a config change.\n */\nexport function createDevServer(\n project: Project,\n io: CliIo,\n options: DevServerOptions = {},\n): DevServer {\n const verbose = options.verbose ?? false;\n let current = project;\n let manifest: Manifest | null = null;\n let runtime: Runtime | null = null;\n let token = \"\";\n let started = false;\n const warned = new Set<string>();\n\n /** Lines printed while the server is running carry a timestamp; startup lines do not. */\n const say = (line: string) => io.out(started ? `${stamp()} ${line}` : line);\n const complain = (line: string) => io.err(started ? `${stamp()} ${line}` : line);\n\n /** Framework log records in the dev server's format. The default when the config has no sink. */\n const print: LogSink = ({ level, message, fields }) => {\n if (level === \"debug\") {\n const pairs = Object.entries(fields)\n .filter(([key, value]) => key !== \"error\" && value !== undefined && value !== null)\n .map(([key, value]) => `${key}=${String(value)}`);\n say(c.dim([message, ...pairs].join(\" \")));\n } else if (level === \"info\") {\n say(info(message));\n } else if (level === \"warn\") {\n complain(warn(message));\n } else {\n const [head = \"\", ...rest] = message.split(\"\\n\");\n const stack = fields.error === undefined ? [] : describeError(fields.error);\n // block() indents the details itself. Strip only the report's own two spaces, so\n // continuation lines stay aligned with the column above them.\n complain(block(fail(c.bold(head)), [...rest.map((l) => l.replace(/^ {2}/, \"\")), ...stack]));\n }\n };\n /** The config's `logger`, with `--verbose` lowering the level to debug. */\n const loggerFor = ({ config }: Project): Logger =>\n createLogger({\n level: verbose ? \"debug\" : (config.logger?.level ?? \"info\"),\n sink: config.logger?.sink ?? print,\n });\n\n // Both fresh per boot, so a reloaded config's `logger` applies and its `observe` is\n // subscribed once.\n let logger = loggerFor(current);\n let signals = createSignals(logger);\n\n function warnOnce(head: string, details: string[] = []): void {\n if (warned.has(head)) return;\n warned.add(head);\n complain(block(warn(head), details));\n }\n\n function emit(graph: RouteGraph): Manifest {\n const next = toManifest(graph, current.outDir);\n writeManifest(next, current.outDir);\n writeTypes(graph, current.outDir, current.config.plugins);\n return next;\n }\n\n async function register(graph: RouteGraph): Promise<void> {\n const scopes = registrationScopes(current.config, current.env);\n if (scopes.length === 0) {\n warnOnce(\"Commands are not registered anywhere yet.\", registrationHint(current));\n return;\n }\n if (findCredential(current, io, \"applicationId\") === null) {\n warnOnce(\n `Commands are not registered: ${APPLICATION_ID_VAR} is not set.`,\n credentialHint(\"applicationId\", projectConfigName(current)),\n );\n return;\n }\n signals.emit({ type: \"registration:start\", scopes: scopes.map(scopeKey) });\n const startedAt = Date.now();\n try {\n const result = await registerCommands(current, graph, io);\n signals.emit({\n type: \"registration:complete\",\n scopes: result.scopes.map((s) => ({ scope: scopeKey(s.scope), applied: s.applied })),\n duration: Date.now() - startedAt,\n });\n for (const scope of result.scopes) {\n if (scope.diff !== null || verbose) say(describeScope(scope));\n }\n } catch (error) {\n if (!(error instanceof CliError)) throw error;\n complain(\n block(\n fail(error.message),\n error.details.map((line) => line.replace(\"run again with\", \"run nectar sync with\")),\n ),\n );\n }\n }\n\n async function launch(): Promise<void> {\n if (manifest === null) return;\n const next = createRuntime({\n manifest,\n appDir: current.appDir,\n config: current.config,\n env: current.env,\n logger,\n signals,\n ...(io.client === undefined ? {} : { client: io.client(current.config) }),\n });\n watchConnection(next.client);\n runtime = next;\n try {\n await next.start({ token, signals: false });\n } catch (error) {\n throw error instanceof LoginError ? loginFailure(error, current) : error;\n }\n }\n\n function watchConnection(client: Client): void {\n client.once(Events.ClientReady, (ready) => say(ok(`Logged in as ${c.bold(ready.user.tag)}.`)));\n client.on(Events.ShardDisconnect, (event) => {\n complain(warn(`Disconnected from the gateway ${c.dim(`(code ${event.code})`)}.`));\n });\n client.on(Events.ShardReconnecting, () => say(info(\"Reconnecting to the gateway.\")));\n client.on(Events.ShardResume, () => say(ok(\"Gateway connection resumed.\")));\n client.on(Events.Error, (error) => complain(fail(`Gateway error: ${error.message}`)));\n if (verbose) client.on(Events.Warn, (message) => complain(warn(`discord.js: ${message}`)));\n }\n\n /** Full start: compile, write output, print routes, register, run. */\n async function boot(): Promise<void> {\n logger = loggerFor(current);\n signals = createSignals(logger);\n const graph = await compileProject(current, io);\n if (graph === null) {\n complain(warn(\"Waiting for changes.\"));\n return;\n }\n manifest = emit(graph);\n say(ok(`${summary(graph)} in ${c.bold(appLabel())}`));\n if (verbose)\n for (const line of indent(renderRoutes(graph, current.root).split(\"\\n\"))) say(line);\n await register(graph);\n await launch();\n }\n\n async function stopRuntime(): Promise<void> {\n const running = runtime;\n runtime = null;\n manifest = null;\n if (running !== null) await running.stop();\n }\n\n async function restart(): Promise<void> {\n await stopRuntime();\n try {\n current = await loadProject(io.cwd, io.env);\n } catch (error) {\n if (!(error instanceof CliError)) throw error;\n complain(block(fail(error.message), error.details));\n complain(warn(\"Waiting for changes.\"));\n return;\n }\n say(info(`Restarting with the new ${c.bold(projectConfigName(current))}.`));\n await boot();\n }\n\n /** Imports files now so a broken module shows up here, not on the next interaction. */\n async function preload(files: string[]): Promise<void> {\n if (runtime === null) return;\n const results = await Promise.allSettled(files.map((file) => runtime?.modules.load(file)));\n for (const result of results) {\n if (result.status === \"fulfilled\") continue;\n const error: unknown = result.reason;\n complain(\n error instanceof HandlerLoadError\n ? block(fail(`${c.bold(relative(current.root, error.file))} failed to load.`), [\n error.detail,\n ])\n : fail(String(error)),\n );\n }\n }\n\n function appLabel(): string {\n return `${relative(current.root, current.appDir) || \".\"}/`;\n }\n\n return {\n async start() {\n token = credential(current, io, \"token\");\n enableModuleReloading(current.root);\n await boot();\n started = true;\n },\n\n async apply(files) {\n const kinds = new Map(files.map((file) => [file, classifyPath(file, current)] as const));\n const changed = files.filter((file) => kinds.get(file) !== \"ignored\");\n if (changed.length === 0) return;\n for (const file of changed) {\n const gone = !existsSync(file);\n say(`${gone ? c.red(\"-\") : c.yellow(\"~\")} ${relative(current.root, file)}`);\n }\n\n if (changed.some((file) => kinds.get(file) === \"config\")) {\n await restart();\n return;\n }\n const dependency = changed.some((file) => kinds.get(file) === \"dependency\");\n if (dependency) invalidateModuleGraph();\n\n if (runtime === null || manifest === null) {\n await boot();\n return;\n }\n\n const graph = await compileProject(current, io);\n if (graph === null) {\n complain(warn(\"Keeping the previous routes until this is fixed.\"));\n return;\n }\n const next = toManifest(graph, current.outDir);\n const delta = diffManifests(manifest, next);\n const done: string[] = [];\n if (delta.structure || delta.commands) manifest = emit(graph);\n if (delta.structure) {\n runtime.update(manifest);\n done.push(`routes rebuilt ${c.dim(`(${summary(graph)})`)}`);\n if (verbose) {\n for (const line of indent(renderRoutes(graph, current.root).split(\"\\n\"))) say(line);\n }\n }\n if (delta.commands) await register(graph);\n\n const all = manifestFiles(manifest, current.appDir);\n const stale = dependency ? [...all] : changed.filter((file) => all.has(file));\n runtime.modules.invalidate(dependency ? undefined : stale);\n await preload(stale);\n if (dependency) done.push(\"every module reloaded\");\n else if (stale.length > 0) {\n done.push(`${stale.length} handler module${stale.length === 1 ? \"\" : \"s\"} reloaded`);\n }\n\n say(done.length === 0 ? info(\"Nothing to reload.\") : ok(`${capitalize(done.join(\", \"))}.`));\n },\n\n stop: stopRuntime,\n };\n}\n\nfunction capitalize(text: string): string {\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n\nfunction describeError(error: unknown): string[] {\n const text = error instanceof Error ? (error.stack ?? error.message) : String(error);\n return text.split(\"\\n\").map((line) => c.dim(line));\n}\n","import { type FSWatcher, watch } from \"node:fs\";\nimport path from \"node:path\";\n\nexport interface Watcher {\n close(): void;\n}\n\nexport interface WatchOptions {\n /** Milliseconds to wait for more events before reporting a batch. Defaults to 80. */\n debounce?: number;\n onError?: (error: Error) => void;\n}\n\n/**\n * Watches a directory tree and reports changed paths in debounced batches. Editors write a\n * file in several steps and `fs.watch` reports each one, so a batch collapses them to one\n * change and lets several files saved together be handled together.\n */\nexport function watchTree(\n root: string,\n onChange: (files: string[]) => void,\n options: WatchOptions = {},\n): Watcher {\n const { debounce = 80, onError } = options;\n const pending = new Set<string>();\n let timer: NodeJS.Timeout | null = null;\n\n const flush = () => {\n timer = null;\n const files = [...pending];\n pending.clear();\n onChange(files);\n };\n\n const watcher: FSWatcher = watch(root, { recursive: true }, (_event, filename) => {\n if (filename === null) return;\n pending.add(path.join(root, filename.toString()));\n if (timer !== null) clearTimeout(timer);\n timer = setTimeout(flush, debounce);\n });\n if (onError !== undefined) watcher.on(\"error\", onError);\n\n return {\n close() {\n if (timer !== null) clearTimeout(timer);\n watcher.close();\n },\n };\n}\n","import { createDevServer } from \"../dev/server.js\";\nimport { watchTree } from \"../dev/watch.js\";\nimport { version } from \"../version.js\";\nimport { relative } from \"./compile.js\";\nimport { CliError, type CliIo, EXIT_OK } from \"./io.js\";\nimport { describe, loadProject } from \"./project.js\";\nimport { block, c, fail, info, stamp } from \"./ui.js\";\n\n/** `nectar dev [--verbose]`: compile, register dev guild commands, run, and react to file changes. */\nexport async function dev(io: CliIo, verbose: boolean): Promise<number> {\n io.out(`${c.bold(\"nectar dev\")} ${c.dim(`v${version}`)}`);\n io.out(\"\");\n const project = await loadProject(io.cwd, io.env);\n const server = createDevServer(project, io, { verbose });\n await server.start();\n io.out(\n info(\n `Watching ${c.bold(`${relative(project.root, project.appDir) || \".\"}/`)}, ${c.bold(relative(project.root, project.configFile))}, and the files they import. ${c.dim(\"Ctrl+C stops.\")}`,\n ),\n );\n\n // Batches are handled one at a time, in order, so a rebuild never races a reload.\n let queue = Promise.resolve();\n const watcher = watchTree(\n project.root,\n (files) => {\n queue = queue\n .then(() => server.apply(files))\n .catch((error: unknown) => {\n io.err(\n `${stamp()} ${error instanceof CliError ? block(fail(error.message), error.details) : fail(describe(error))}`,\n );\n });\n },\n { onError: (error) => io.err(`${stamp()} ${fail(`Watcher error: ${error.message}`)}`) },\n );\n\n await new Promise<void>((resolve) => {\n process.once(\"SIGINT\", () => resolve());\n process.once(\"SIGTERM\", () => resolve());\n });\n io.out(\"\");\n io.out(info(\"Stopping.\"));\n watcher.close();\n await queue;\n await server.stop();\n return EXIT_OK;\n}\n","import {\n type Manifest,\n type ManifestRoute,\n stableStringify,\n toManifest,\n} from \"../manifest/index.js\";\nimport { compileProject } from \"./compile.js\";\nimport { CliError, type CliIo, EXIT_FAILURE, EXIT_OK } from \"./io.js\";\nimport { loadProject } from \"./project.js\";\n\n/** `nectar manifest [--route <id>]`: print the compiled manifest, or everything about one route. */\nexport async function manifest(io: CliIo, route: string | undefined): Promise<number> {\n const project = await loadProject(io.cwd, io.env);\n const graph = await compileProject(project, io);\n if (graph === null) return EXIT_FAILURE;\n const compiled = toManifest(graph, project.outDir);\n\n if (route === undefined) {\n io.out(stableStringify(compiled));\n return EXIT_OK;\n }\n const matches = compiled.routes.filter((r) => r.id === route || r.path === route);\n if (matches.length === 0) {\n const known = [...new Set(compiled.routes.map((r) => r.id))].sort();\n throw new CliError(`No route \"${route}\".`, {\n details: [\"Known routes:\", ...known.map((id) => ` ${id}`)],\n });\n }\n io.out(stableStringify(matches.map((r) => describeRoute(r, compiled))));\n return EXIT_OK;\n}\n\n/** The route record plus what the manifest links it to: its command payload, custom ID, or event. */\nexport function describeRoute(route: ManifestRoute, compiled: Manifest): Record<string, unknown> {\n const detail: Record<string, unknown> = { ...route };\n if (route.kind === \"command\" || route.kind === \"autocomplete\") {\n for (const command of compiled.commands) {\n const position = Object.entries(command.handlers).find(([, id]) => id === route.id)?.[0];\n if (position === undefined) continue;\n detail.command = { name: command.name, position, payload: command.payload };\n if (route.kind === \"autocomplete\") {\n detail.commandRoute = compiled.routes.find(\n (r) => r.kind === \"command\" && r.id === route.id,\n )?.file;\n }\n }\n } else if (route.kind === \"event\") {\n const event = compiled.events.find((e) => e.name === route.event);\n if (event !== undefined) detail.eventHandlers = { mode: event.mode, handlers: event.handlers };\n } else {\n detail.customId = [\n `n:${route.shortId}`,\n ...route.params.map((p) => (p === route.catchAll ? `<...${p}>` : `<${p}>`)),\n ].join(\":\");\n }\n return detail;\n}\n","import { existsSync, rmSync } from \"node:fs\";\nimport { registrationScopes, scopeKey } from \"../registration/index.js\";\nimport { version } from \"../version.js\";\nimport { relative } from \"./compile.js\";\nimport { CliError, type CliIo, EXIT_OK } from \"./io.js\";\nimport { loadProject } from \"./project.js\";\nimport { APPLICATION_ID_VAR, findCredential, TOKEN_VAR } from \"./sync.js\";\nimport { c, info as note, ok, table } from \"./ui.js\";\n\n/** `nectar clean`: delete the build output directory. */\nexport async function clean(io: CliIo): Promise<number> {\n const project = await loadProject(io.cwd, io.env);\n const label = `${relative(project.root, project.outDir)}/`;\n if (!existsSync(project.outDir)) {\n io.out(note(`Nothing to remove, ${c.bold(label)} does not exist.`));\n return EXIT_OK;\n }\n rmSync(project.outDir, { recursive: true, force: true });\n io.out(ok(`Removed ${c.bold(label)}`));\n return EXIT_OK;\n}\n\n/** `nectar info`: versions, environment, and the config values that decide runtime behaviour. */\nexport async function info(io: CliIo): Promise<number> {\n const rows: [string, string][] = [\n [\"nectar\", version],\n [\"node\", process.version],\n [\"discord.js\", await discordVersion()],\n [\"platform\", `${process.platform} ${process.arch}`],\n ];\n\n try {\n const project = await loadProject(io.cwd, io.env);\n const { config } = project;\n const scopes = registrationScopes(config, project.env);\n rows.push(\n [TOKEN_VAR, present(findCredential(project, io, \"token\"))],\n [APPLICATION_ID_VAR, present(findCredential(project, io, \"applicationId\"))],\n [\"config\", relative(project.root, project.configFile)],\n [\"env\", project.env],\n [\"appDir\", relative(project.root, project.appDir) || \".\"],\n [\"outDir\", relative(project.root, project.outDir)],\n [\"intents\", describeBitfield(config.intents)],\n [\"partials\", config.partials === undefined ? \"none\" : String(config.partials.length)],\n [\"eager\", String(config.eager ?? project.env === \"production\")],\n [\"registration\", scopes.length === 0 ? c.yellow(\"none\") : scopes.map(scopeKey).join(\", \")],\n [\"plugins\", (config.plugins ?? []).map((p) => p.name).join(\", \") || \"none\"],\n );\n } catch (error) {\n if (!(error instanceof CliError)) throw error;\n rows.push(\n [TOKEN_VAR, present(io.env[TOKEN_VAR] || null)],\n [APPLICATION_ID_VAR, present(io.env[APPLICATION_ID_VAR] || null)],\n [\"config\", c.yellow(error.message)],\n );\n }\n\n for (const line of table(rows)) io.out(line);\n return EXIT_OK;\n}\n\nasync function discordVersion(): Promise<string> {\n try {\n const { version: v } = await import(\"discord.js\");\n return v;\n } catch {\n return c.yellow(\"not installed\");\n }\n}\n\nfunction present(value: string | null): string {\n return value === null || value === \"\" ? c.yellow(\"not set\") : c.green(\"set\");\n}\n\nfunction describeBitfield(value: unknown): string {\n if (Array.isArray(value)) return value.length === 0 ? \"none\" : value.map(String).join(\", \");\n return String(value);\n}\n","import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Client } from \"discord.js\";\nimport { loadManifest, MANIFEST_FILE } from \"../manifest/index.js\";\nimport { createRuntime, LoginError } from \"../runtime/index.js\";\nimport { relative } from \"./compile.js\";\nimport { CliError, type CliIo, EXIT_OK } from \"./io.js\";\nimport { loadProject } from \"./project.js\";\nimport { credential, loginFailure } from \"./sync.js\";\nimport { c, ok } from \"./ui.js\";\n\n/** `nectar start`: run the bot from the last `nectar build`. No source discovery happens here. */\nexport async function start(io: CliIo): Promise<number> {\n const project = await loadProject(io.cwd, io.env);\n const manifestFile = path.join(project.outDir, MANIFEST_FILE);\n if (!existsSync(manifestFile)) {\n throw new CliError(`${relative(project.root, manifestFile)} not found.`, {\n details: [`Run ${c.bold(\"nectar build\")} first, then ${c.bold(\"nectar start\")} again.`],\n });\n }\n const token = credential(project, io, \"token\");\n\n const { manifest, appDir } = loadManifest(manifestFile);\n const runtime = createRuntime({\n manifest,\n appDir,\n config: project.config,\n env: project.env,\n ...(io.client === undefined ? {} : { client: io.client(project.config) }),\n });\n runtime.client.once(\"clientReady\", (client) => {\n io.out(ok(`Logged in as ${c.bold(client.user.tag)} (${project.env}${shards(client)}).`));\n });\n try {\n await runtime.start({ token });\n } catch (error) {\n throw error instanceof LoginError ? loginFailure(error, project) : error;\n }\n return EXIT_OK;\n}\n\n/** `, shard 2 of 4` when the bot is sharded, so each shard process's line says which it is. */\nfunction shards(client: Client): string {\n const { shards: ids, shardCount } = client.options;\n if (!Array.isArray(ids) || shardCount === undefined || shardCount < 2) return \"\";\n return `, shard${ids.length === 1 ? \"\" : \"s\"} ${ids.join(\", \")} of ${shardCount}`;\n}\n","import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { PluginError } from \"../plugins/index.js\";\nimport { version } from \"../version.js\";\nimport { build, check } from \"./build.js\";\nimport { dev } from \"./dev.js\";\nimport { CliError, type CliIo, EXIT_FAILURE, EXIT_OK, EXIT_USAGE } from \"./io.js\";\nimport { manifest } from \"./manifest.js\";\nimport { clean, info } from \"./misc.js\";\nimport { CONFIG_FILES, describe, loadProject } from \"./project.js\";\nimport { routes } from \"./routes.js\";\nimport { start } from \"./start.js\";\nimport { sync } from \"./sync.js\";\nimport { block, c, fail, indent, setColors } from \"./ui.js\";\n\nexport type { CliIo } from \"./io.js\";\nexport { EXIT_FAILURE, EXIT_OK, EXIT_USAGE } from \"./io.js\";\n\ninterface Command {\n usage: string;\n description: string;\n options?: Record<string, { type: \"boolean\" | \"string\"; description: string }>;\n run(io: CliIo, flags: Record<string, string | boolean | undefined>): Promise<number>;\n}\n\nconst COMMANDS: Record<string, Command> = {\n dev: {\n usage: \"dev [--verbose]\",\n description: \"Compile, register dev guild commands, run the bot, and reload on changes.\",\n options: {\n verbose: { type: \"boolean\", description: \"Print the route tree and discord.js warnings.\" },\n },\n run: (io, flags) => dev(io, flags.verbose === true),\n },\n build: {\n usage: \"build\",\n description: \"Compile the app and write the manifest and types.\",\n run: (io) => build(io),\n },\n check: {\n usage: \"check\",\n description: \"Compile and report problems without writing anything.\",\n run: (io) => check(io),\n },\n routes: {\n usage: \"routes\",\n description: \"Show the app tree: commands, components, events, middleware, error boundaries.\",\n run: (io) => routes(io),\n },\n manifest: {\n usage: \"manifest [--route <id>]\",\n description: \"Print the compiled manifest, or everything about one route.\",\n options: {\n route: { type: \"string\", description: \"Route ID or path, e.g. command:moderation/ban.\" },\n },\n run: (io, flags) => manifest(io, flags.route as string | undefined),\n },\n sync: {\n usage: \"sync [--dry-run] [--force]\",\n description: \"Register commands with Discord, writing only scopes that changed.\",\n options: {\n \"dry-run\": { type: \"boolean\", description: \"Show the diff without changing anything.\" },\n force: { type: \"boolean\", description: \"Proceed even when the change looks destructive.\" },\n },\n run: (io, flags) => sync(io, flags[\"dry-run\"] === true, flags.force === true),\n },\n start: {\n usage: \"start\",\n description: \"Run the bot from the last build.\",\n run: (io) => start(io),\n },\n clean: {\n usage: \"clean\",\n description: \"Delete the build output directory.\",\n run: (io) => clean(io),\n },\n info: {\n usage: \"info\",\n description: \"Show versions, environment, and the effective config.\",\n run: (io) => info(io),\n },\n};\n\n/**\n * Commands contributed by the config's plugins. Loading the config can fail; for help that is\n * silent, for a command it is the error the user needs to see.\n */\nasync function pluginCommands(io: CliIo, tolerant: boolean): Promise<Record<string, Command>> {\n if (!CONFIG_FILES.some((file) => existsSync(path.join(io.cwd, file)))) return {};\n const commands: Record<string, Command> = {};\n try {\n const project = await loadProject(io.cwd, io.env);\n for (const plugin of project.config.plugins ?? []) {\n for (const command of plugin.commands ?? []) {\n const options = command.options ?? {};\n const usage = [\n command.name,\n ...Object.entries(options).map(\n ([key, opt]) => `[--${key}${opt.type === \"string\" ? \" <value>\" : \"\"}]`,\n ),\n ].join(\" \");\n commands[command.name] = {\n usage,\n description: command.description,\n options,\n run: async (io, flags) => command.run({ project, flags, out: io.out, err: io.err }),\n };\n }\n }\n } catch (error) {\n if (!tolerant || !(error instanceof CliError)) throw error;\n }\n return commands;\n}\n\n/** Runs `run` for this process: loads `cwd/.env`, colors a TTY, prints to the console. */\nexport async function main(argv: string[], cwd: string): Promise<number> {\n const envFile = path.join(cwd, \".env\");\n if (existsSync(envFile)) process.loadEnvFile(envFile);\n\n const wantsColor = process.env.NO_COLOR === undefined || process.env.NO_COLOR === \"\";\n setColors(process.env.FORCE_COLOR !== undefined || (wantsColor && process.stdout.isTTY === true));\n\n return run(argv, {\n cwd,\n env: process.env,\n out: (line) => console.log(line),\n err: (line) => console.error(line),\n });\n}\n\n/** Runs one CLI invocation. `argv` excludes the node and script entries. */\nexport async function run(argv: string[], io: CliIo): Promise<number> {\n const [name, ...rest] = argv;\n if (name === undefined || name === \"--help\" || name === \"-h\" || name === \"help\") {\n io.out(help(await pluginCommands(io, true)));\n return name === undefined ? EXIT_USAGE : EXIT_OK;\n }\n if (name === \"--version\" || name === \"-v\") {\n io.out(version);\n return EXIT_OK;\n }\n let command = COMMANDS[name];\n if (command === undefined) {\n try {\n command = (await pluginCommands(io, false))[name];\n } catch (error) {\n if (!(error instanceof CliError)) throw error;\n io.err(block(fail(error.message), error.details));\n return error.code;\n }\n }\n if (command === undefined) {\n io.err(\n block(fail(`Unknown command ${c.bold(`\"${name}\"`)}.`), [\n `Run ${c.bold(\"nectar --help\")} to see the commands.`,\n ]),\n );\n return EXIT_USAGE;\n }\n\n let flags: Record<string, string | boolean | undefined>;\n try {\n const parsed = parseArgs({\n args: rest,\n options: {\n ...Object.fromEntries(\n Object.entries(command.options ?? {}).map(([key, opt]) => [key, { type: opt.type }]),\n ),\n help: { type: \"boolean\" },\n },\n strict: true,\n allowPositionals: false,\n });\n flags = parsed.values;\n } catch (error) {\n io.err(fail(describe(error)));\n io.err(\"\");\n io.err(commandHelp(command));\n return EXIT_USAGE;\n }\n if (flags.help === true) {\n io.out(commandHelp(command));\n return EXIT_OK;\n }\n\n try {\n return await command.run(io, flags);\n } catch (error) {\n if (error instanceof CliError) {\n io.err(block(fail(error.message), error.details));\n return error.code;\n }\n if (error instanceof PluginError) {\n io.err(block(fail(error.message), [`Fix or remove the plugin in your config.`]));\n return EXIT_FAILURE;\n }\n io.err(\n block(fail(\"Something went wrong inside Nectar.\"), [\n \"This is a bug in Nectar, not in your app. The details:\",\n \"\",\n ...(error instanceof Error ? (error.stack ?? error.message) : String(error))\n .split(\"\\n\")\n .map((line) => c.dim(line)),\n ]),\n );\n return EXIT_FAILURE;\n }\n}\n\nfunction help(plugins: Record<string, Command>): string {\n const all = [...Object.values(COMMANDS), ...Object.values(plugins)];\n const width = Math.max(...all.map((cmd) => cmd.usage.length));\n const row = (cmd: Command) => ` ${c.cyan(cmd.usage.padEnd(width))} ${c.dim(cmd.description)}`;\n return [\n `${c.bold(\"nectar\")} ${c.dim(`v${version}`)} A filesystem-based meta-framework for discord.js.`,\n \"\",\n `${c.bold(\"Usage:\")} nectar <command> [options]`,\n \"\",\n c.bold(\"Commands:\"),\n ...Object.values(COMMANDS).map(row),\n ...(Object.keys(plugins).length === 0\n ? []\n : [\"\", c.bold(\"Plugin commands:\"), ...Object.values(plugins).map(row)]),\n \"\",\n c.bold(\"Options:\"),\n ` ${c.cyan(\"--help, -h\".padEnd(width))} ${c.dim(\"Show help for nectar or a command.\")}`,\n ` ${c.cyan(\"--version, -v\".padEnd(width))} ${c.dim(\"Print the version.\")}`,\n ].join(\"\\n\");\n}\n\nfunction commandHelp(command: Command): string {\n const options = Object.entries(command.options ?? {});\n const lines = [`${c.bold(\"Usage:\")} nectar ${command.usage}`, \"\", command.description];\n if (options.length > 0) {\n const width = Math.max(...options.map(([key]) => key.length));\n lines.push(\n \"\",\n c.bold(\"Options:\"),\n ...indent(\n options.map(\n ([key, opt]) => `${c.cyan(`--${key.padEnd(width)}`)} ${c.dim(opt.description)}`,\n ),\n ),\n );\n }\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA,SAAgB,mBACd,QACA,KACS;CACT,IAAI,QAAQ,cAAc,QAAQ,OAAO,KAAK,UAAU,CAAC,EAAA,CAAG,KAAK,WAAW,EAAE,MAAM,EAAE;CACtF,MAAM,SAAS,OAAO,UAAU,UAAU;CAC1C,OAAO,WAAW,WAAW,CAAC,QAAQ,IAAI,OAAO,KAAK,WAAW,EAAE,MAAM,EAAE;AAC7E;;;ACTA,MAAa,aAAa;AAE1B,MAAM,UAAU;AAEhB,MAAMA,iBAAuC;EAC1C,uBAAuB,YAAY;EACnC,uBAAuB,OAAO;EAC9B,uBAAuB,UAAU;AACpC;AAEA,MAAMC,gBAAsC;EACzC,6BAA6B,SAAS;EACtC,6BAA6B,UAAU;EACvC,6BAA6B,SAAS;EACtC,6BAA6B,UAAU;EACvC,6BAA6B,OAAO;EACpC,6BAA6B,UAAU;EACvC,6BAA6B,OAAO;EACpC,6BAA6B,cAAc;EAC3C,6BAA6B,aAAa;AAC7C;;;;;;;AAQA,SAAgB,QACd,OACA,QACA,UAAmC,CAAC,GAC5B;CACR,MAAM,cAAc,KAAK,QAAQ,MAAM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K,QAAQ,EAAE,GAAG,EAAE,IAAI,IAAI,SAAS,EAAE;EAC5C;EACA,GAAG,EAAE,KAAK,QAAQ,EAAE;EACpB;EACA,EAAE,KAAK,WAAW;EAClB,GAAG,OAAO,OAAO,QAAQ,CAAC,CAAC,IAAI,GAAG;EAClC,GAAI,OAAO,KAAK,OAAO,CAAC,CAAC,WAAW,IAChC,CAAC,IACD;GAAC;GAAI,EAAE,KAAK,kBAAkB;GAAG,GAAG,OAAO,OAAO,OAAO,CAAC,CAAC,IAAI,GAAG;EAAC;EACvE;EACA,EAAE,KAAK,UAAU;EACjB,KAAK,EAAE,KAAK,aAAa,OAAO,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,oCAAoC;EACtF,KAAK,EAAE,KAAK,gBAAgB,OAAO,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,oBAAoB;CAC3E,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAS,YAAY,SAA0B;CAC7C,MAAM,UAAU,OAAO,QAAQ,QAAQ,WAAW,CAAC,CAAC;CACpD,MAAM,QAAQ;EAAC,GAAG,EAAE,KAAK,QAAQ,EAAE,UAAU,QAAQ;EAAS;EAAI,QAAQ;CAAW;CACrF,IAAI,QAAQ,SAAS,GAAG;EACtB,MAAM,QAAQ,KAAK,IAAI,GAAG,QAAQ,KAAK,CAAC,SAAS,IAAI,MAAM,CAAC;EAC5D,MAAM,KACJ,IACA,EAAE,KAAK,UAAU,GACjB,GAAG,OACD,QAAQ,KACL,CAAC,KAAK,SAAS,GAAG,EAAE,KAAK,KAAK,IAAI,OAAO,KAAK,GAAG,EAAE,IAAI,EAAE,IAAI,IAAI,WAAW,GAC/E,CACF,CACF;CACF;CACA,OAAO,MAAM,KAAK,IAAI;AACxB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins-CGvM19v9.js","names":["describe"],"sources":["../src/version.ts","../src/components/customId.ts","../src/compiler/diagnostics.ts","../src/compiler/load.ts","../src/compiler/segments.ts","../src/components/params.ts","../src/components/compile.ts","../src/components/registry.ts","../src/manifest/emit.ts","../src/plugins/transform.ts","../src/plugins/index.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\n/** From package.json, which sits one level up from both `src/` and `dist/`. */\nexport const { version } = createRequire(import.meta.url)(\"../package.json\") as {\n version: string;\n};\n","/** Discord rejects custom IDs longer than this. */\nexport const MAX_CUSTOM_ID_LENGTH = 100;\n\nconst PREFIX = \"n:\";\nconst SHORT_ID_LENGTH = 6;\n\n/** Characters a route with no parameters uses: the prefix and the short ID. */\nexport const BASE_OVERHEAD = PREFIX.length + SHORT_ID_LENGTH;\n\nexport class CustomIdTooLongError extends Error {\n constructor(\n readonly customId: string,\n readonly routeId: string,\n ) {\n super(\n `Custom ID for ${routeId} is ${customId.length} characters, Discord allows ${MAX_CUSTOM_ID_LENGTH}. Encode a shorter identifier instead of the full value.`,\n );\n this.name = \"CustomIdTooLongError\";\n }\n}\n\n/**\n * Builds `n:<shortId>:<v1>:<v2>...`. Values are escaped so they may contain `:` and `\\`.\n * Throws when the result is longer than Discord allows; it never truncates.\n */\nexport function encodeCustomId(shortId: string, values: readonly string[], routeId = shortId) {\n let out = PREFIX + shortId;\n for (const value of values) out += `:${escapeValue(value)}`;\n if (out.length > MAX_CUSTOM_ID_LENGTH) throw new CustomIdTooLongError(out, routeId);\n return out;\n}\n\nexport type DecodedCustomId =\n | { ok: true; shortId: string; values: string[] }\n | { ok: false; reason: \"not-nectar\" | \"malformed\" };\n\n/**\n * Splits a raw custom ID back into its short ID and positional values.\n * IDs without the Nectar prefix are reported as `not-nectar` so hand-built components pass through.\n */\nexport function decodeCustomId(raw: string): DecodedCustomId {\n if (!raw.startsWith(PREFIX)) return { ok: false, reason: \"not-nectar\" };\n\n const shortId = raw.slice(PREFIX.length, PREFIX.length + SHORT_ID_LENGTH);\n if (!/^[0-9a-z]{6}$/.test(shortId)) return { ok: false, reason: \"malformed\" };\n\n const values: string[] = [];\n let index = PREFIX.length + SHORT_ID_LENGTH;\n if (index === raw.length) return { ok: true, shortId, values };\n if (raw[index] !== \":\") return { ok: false, reason: \"malformed\" };\n index++;\n\n let current = \"\";\n while (index < raw.length) {\n const char = raw[index] as string;\n if (char === \"\\\\\") {\n const next = raw[index + 1];\n if (next !== \"\\\\\" && next !== \":\") return { ok: false, reason: \"malformed\" };\n current += next;\n index += 2;\n continue;\n }\n if (char === \":\") {\n values.push(current);\n current = \"\";\n index++;\n continue;\n }\n current += char;\n index++;\n }\n values.push(current);\n return { ok: true, shortId, values };\n}\n\nfunction escapeValue(value: string): string {\n return value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll(\":\", \"\\\\:\");\n}\n","export type Severity = \"error\" | \"warning\";\n\nexport interface Diagnostic {\n code: string;\n severity: Severity;\n message: string;\n /** Absolute path of the file or directory that caused the diagnostic. */\n file?: string;\n /** Canonical route identity, when the diagnostic is about a specific route. */\n route?: string;\n}\n\ninterface DiagnosticLocation {\n file?: string;\n route?: string;\n}\n\nexport class Diagnostics {\n readonly items: Diagnostic[] = [];\n\n error(code: string, message: string, location: DiagnosticLocation = {}): void {\n this.push(\"error\", code, message, location);\n }\n\n warn(code: string, message: string, location: DiagnosticLocation = {}): void {\n this.push(\"warning\", code, message, location);\n }\n\n get hasErrors(): boolean {\n return this.items.some((d) => d.severity === \"error\");\n }\n\n private push(\n severity: Severity,\n code: string,\n message: string,\n location: DiagnosticLocation,\n ): void {\n const item: Diagnostic = { code, severity, message };\n if (location.file !== undefined) item.file = location.file;\n if (location.route !== undefined) item.route = location.route;\n this.items.push(item);\n }\n}\n","import { createHash } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { registerHooks } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\n/**\n * Imports an application module by absolute path.\n *\n * Relies on Node's native TypeScript type stripping (unflagged since 22.18), so handler\n * files must use erasable syntax only: no enums, namespaces, or parameter properties.\n *\n * With reloading enabled (see `enableModuleReloading`) the URL carries a version query, so a\n * changed file evaluates again on the next import instead of coming back from the ESM cache.\n */\nexport async function loadModule(file: string): Promise<Record<string, unknown>> {\n const url = pathToFileURL(file).href;\n return (await import(reloading === null ? url : versioned(url))) as Record<string, unknown>;\n}\n\ninterface Reloading {\n /** Project root; only files under it (outside `node_modules`) are versioned. */\n root: string;\n /** Bumped by `invalidateModuleGraph` so every project module evaluates again. */\n generation: number;\n}\n\nlet reloading: Reloading | null = null;\n\n/**\n * Turns on cache busting for project files. Used by `nectar dev` only.\n *\n * Every import of a file under `root` gets `?nectar=<content hash>-<generation>` appended, the\n * direct ones here and the transitive ones through a resolve hook. A handler whose content\n * changed therefore gets a new URL and a fresh evaluation; its unchanged imports keep their\n * URL and are shared. Old instances stay in the ESM cache until the process exits.\n */\nexport function enableModuleReloading(root: string): void {\n if (reloading !== null) return;\n reloading = { root: path.resolve(root), generation: 0 };\n registerHooks({\n resolve(specifier, context, next) {\n const result = next(specifier, context);\n return { ...result, url: versioned(result.url) };\n },\n });\n}\n\n/**\n * Makes every project module evaluate again on its next import. For changes to files the\n * compiler does not track (helpers a handler imports), since nothing knows who imports them.\n */\nexport function invalidateModuleGraph(): void {\n if (reloading !== null) reloading.generation += 1;\n}\n\nfunction versioned(url: string): string {\n if (reloading === null || !url.startsWith(\"file:\") || url.includes(\"?\") || url.includes(\"#\")) {\n return url;\n }\n const file = fileURLToPath(url);\n const inside = !path.relative(reloading.root, file).startsWith(\"..\");\n if (!inside || file.split(path.sep).includes(\"node_modules\")) return url;\n let hash: string;\n try {\n hash = createHash(\"sha1\").update(readFileSync(file)).digest(\"base64url\").slice(0, 10);\n } catch {\n return url;\n }\n return `${url}?nectar=${hash}-${reloading.generation}`;\n}\n","export type Segment =\n | { type: \"static\"; name: string }\n | { type: \"dynamic\"; name: string }\n | { type: \"catchAll\"; name: string }\n | { type: \"group\"; name: string };\n\nexport type SegmentParseResult = { ok: true; segment: Segment } | { ok: false; reason: string };\n\nconst STATIC_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;\nconst PARAM_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * Parses one directory name into a route segment.\n *\n * `name` static\n * `[name]` dynamic\n * `[...name]` catch-all\n * `(name)` group, organizational only\n */\nexport function parseSegment(dirName: string): SegmentParseResult {\n if (dirName.startsWith(\"[\") || dirName.endsWith(\"]\")) {\n if (!dirName.startsWith(\"[\") || !dirName.endsWith(\"]\")) {\n return fail(`\"${dirName}\" has an unmatched bracket. Dynamic segments look like [name].`);\n }\n const inner = dirName.slice(1, -1);\n const isCatchAll = inner.startsWith(\"...\");\n const name = isCatchAll ? inner.slice(3) : inner;\n if (!PARAM_NAME.test(name)) {\n return fail(\n `\"${dirName}\" is not a valid parameter name. Use letters, digits, and underscores, and do not start with a digit.`,\n );\n }\n return ok({ type: isCatchAll ? \"catchAll\" : \"dynamic\", name });\n }\n\n if (dirName.startsWith(\"(\") || dirName.endsWith(\")\")) {\n if (!dirName.startsWith(\"(\") || !dirName.endsWith(\")\")) {\n return fail(`\"${dirName}\" has an unmatched parenthesis. Route groups look like (name).`);\n }\n const name = dirName.slice(1, -1);\n if (!STATIC_NAME.test(name)) {\n return fail(\n `\"${dirName}\" is not a valid group name. Use letters, digits, hyphens, and underscores.`,\n );\n }\n return ok({ type: \"group\", name });\n }\n\n if (!STATIC_NAME.test(dirName)) {\n return fail(\n `\"${dirName}\" is not a valid segment name. Use letters, digits, hyphens, and underscores, and start with a letter or digit.`,\n );\n }\n return ok({ type: \"static\", name: dirName });\n}\n\n/** Renders a segment back into its directory form. Groups render as their directory name. */\nexport function formatSegment(segment: Segment): string {\n switch (segment.type) {\n case \"static\":\n return segment.name;\n case \"dynamic\":\n return `[${segment.name}]`;\n case \"catchAll\":\n return `[...${segment.name}]`;\n case \"group\":\n return `(${segment.name})`;\n }\n}\n\nfunction ok(segment: Segment): SegmentParseResult {\n return { ok: true, segment };\n}\n\nfunction fail(reason: string): SegmentParseResult {\n return { ok: false, reason };\n}\n","/**\n * A Standard Schema (https://standardschema.dev) validator, which zod, valibot, and arktype\n * all produce. Only the result's `issues` are looked at: a schema that transforms the value\n * does not change what the handler receives.\n */\nexport interface StandardSchemaLike<V = unknown> {\n \"~standard\": {\n validate(\n value: V,\n ):\n | { issues?: ReadonlyArray<unknown> | undefined }\n | Promise<{ issues?: ReadonlyArray<unknown> | undefined }>;\n };\n}\n\n/**\n * Checks one custom ID parameter. A function passes by returning anything but `false` and\n * fails by returning `false` or throwing. A schema fails by reporting issues.\n */\nexport type ParamValidator<V = string | string[]> = ((value: V) => unknown) | StandardSchemaLike<V>;\n\nexport type ParamValidators = Record<string, ParamValidator>;\n\n/**\n * Reads the validators `defineComponent` attached to a handler and checks them against the\n * route's parameters. Throws with a developer-facing message when the shape is wrong; the\n * compiler reports it as a diagnostic and the runtime as a load error.\n */\nexport function paramValidatorsOf(\n handler: unknown,\n route: { params: readonly string[] },\n): ParamValidators {\n const declared = (handler as { params?: unknown }).params;\n if (declared === undefined) return {};\n if (typeof declared !== \"object\" || declared === null || Array.isArray(declared)) {\n throw new Error(`\\`params\\` must be an object of validators, got ${typeof declared}.`);\n }\n const validators: ParamValidators = {};\n for (const [name, validator] of Object.entries(declared)) {\n if (!route.params.includes(name)) {\n throw new Error(\n `\\`params\\` validates \"${name}\", which is not a parameter of this route. ${\n route.params.length === 0 ? \"It has none.\" : `It has: ${route.params.join(\", \")}.`\n }`,\n );\n }\n if (!isValidator(validator)) {\n throw new Error(\n `\\`params.${name}\\` must be a function or a Standard Schema, got ${typeof validator}.`,\n );\n }\n validators[name] = validator;\n }\n return validators;\n}\n\nfunction isValidator(value: unknown): value is ParamValidator {\n if (typeof value === \"function\") return true;\n if (typeof value !== \"object\" || value === null) return false;\n const standard = (value as Record<string, unknown>)[\"~standard\"];\n return (\n typeof standard === \"object\" &&\n standard !== null &&\n typeof (standard as Record<string, unknown>).validate === \"function\"\n );\n}\n\n/**\n * Runs every validator against the decoded parameters. Resolves to the first parameter that\n * failed, or `null` when all passed. A validator that throws counts as a failure; the\n * caller decides what to log, so the value never leaves this function.\n */\nexport async function findInvalidParam(\n validators: ParamValidators,\n params: Record<string, string | string[]>,\n): Promise<string | null> {\n for (const [name, validator] of Object.entries(validators)) {\n const value = params[name];\n if (value === undefined) return name;\n try {\n if (typeof validator === \"function\") {\n if ((await validator(value)) === false) return name;\n continue;\n }\n const result = await validator[\"~standard\"].validate(value);\n if (result.issues !== undefined && result.issues.length > 0) return name;\n } catch {\n return name;\n }\n }\n return null;\n}\n","import path from \"node:path\";\nimport { Diagnostics } from \"../compiler/diagnostics.js\";\nimport { loadModule } from \"../compiler/load.js\";\nimport type { Route, RouteTable } from \"../compiler/routes.js\";\nimport { formatSegment } from \"../compiler/segments.js\";\nimport { BASE_OVERHEAD, encodeCustomId, MAX_CUSTOM_ID_LENGTH } from \"./customId.js\";\nimport { paramValidatorsOf } from \"./params.js\";\n\nexport type ComponentKind = \"button\" | \"select\" | \"modal\";\n\nexport type SelectKind = \"string\" | \"user\" | \"role\" | \"channel\" | \"mentionable\";\n\nconst SELECT_KINDS: ReadonlySet<string> = new Set([\n \"string\",\n \"user\",\n \"role\",\n \"channel\",\n \"mentionable\",\n]);\n\nexport interface ComponentRoute extends Route {\n category: \"component\";\n kind: ComponentKind;\n /** The `kind` export of a `select.ts`. `null` for buttons and modals. */\n selectKind: SelectKind | null;\n /** Name of the trailing catch-all parameter, if the route has one. */\n catchAll: string | null;\n /** Characters of the encoded custom ID taken by the prefix, short ID, and separators. */\n overhead: number;\n}\n\nexport interface CompiledComponents {\n routes: ComponentRoute[];\n diagnostics: Diagnostics;\n}\n\n/** Values for one route's parameters. A catch-all parameter takes an array. */\nexport type ComponentParams = Record<string, string | readonly string[]>;\n\n/** Validates the component routes of a route table and resolves their select kinds. */\nexport async function compileComponents(table: RouteTable): Promise<CompiledComponents> {\n const diagnostics = new Diagnostics();\n const candidates = table.routes.filter((r) => r.category === \"component\");\n\n // Each route reports into its own list, so diagnostics come out in route order rather than\n // in whatever order the imports finish.\n const results = await Promise.all(\n candidates.map(async (route) => {\n const own = new Diagnostics();\n return { route: await compileRoute(route, own), diagnostics: own };\n }),\n );\n const routes: ComponentRoute[] = [];\n for (const result of results) {\n diagnostics.items.push(...result.diagnostics.items);\n if (result.route !== null) routes.push(result.route);\n }\n\n detectShortIdCollisions(routes, diagnostics);\n detectDuplicatePatterns(routes, diagnostics);\n\n return { routes, diagnostics };\n}\n\n/** What the encoder needs from a route. Compiled, manifest, and registered routes all satisfy it. */\nexport interface EncodableRoute {\n id: string;\n shortId: string;\n params: string[];\n catchAll: string | null;\n}\n\n/**\n * Encodes a custom ID for a compiled route. Throws when a parameter is missing, a value is not\n * a string, or the result exceeds Discord's limit.\n */\nexport function customIdFor(route: EncodableRoute, params: ComponentParams = {}): string {\n const values: string[] = [];\n for (const name of route.params) {\n const value = params[name];\n if (name === route.catchAll) {\n if (value === undefined) continue;\n if (typeof value === \"string\") {\n values.push(value);\n continue;\n }\n values.push(...value);\n continue;\n }\n if (typeof value !== \"string\") {\n throw new TypeError(\n `Route ${route.id} needs a string for parameter \"${name}\", got ${describe(value)}.`,\n );\n }\n values.push(value);\n }\n for (const name of Object.keys(params)) {\n if (!route.params.includes(name)) {\n throw new TypeError(\n `Route ${route.id} has no parameter \"${name}\". ${route.params.length === 0 ? \"It takes none.\" : `It takes: ${route.params.join(\", \")}.`}`,\n );\n }\n }\n return encodeCustomId(route.shortId, values, route.id);\n}\n\nasync function compileRoute(\n route: Route,\n diagnostics: Diagnostics,\n): Promise<ComponentRoute | null> {\n const kind = route.kind as ComponentKind;\n const last = route.segments.at(-1);\n const catchAll = last?.type === \"catchAll\" ? last.name : null;\n const overhead = BASE_OVERHEAD + route.params.length;\n\n if (catchAll !== null) {\n diagnostics.warn(\n \"catch-all-route\",\n `${formatSegment(last as NonNullable<typeof last>)} accepts any number of values. Every value counts against Discord's ${MAX_CUSTOM_ID_LENGTH} character custom ID limit, and generation throws when it is exceeded.`,\n { file: route.file, route: route.id },\n );\n }\n\n let module: Record<string, unknown>;\n try {\n module = await loadModule(route.file);\n } catch (error) {\n diagnostics.error(\n \"module-load-failed\",\n `Could not import this file: ${error instanceof Error ? error.message : String(error)}`,\n { file: route.file, route: route.id },\n );\n return null;\n }\n\n if (!checkDeclaredRoute(module, route, diagnostics)) return null;\n try {\n paramValidatorsOf(module.default, route);\n } catch (error) {\n diagnostics.error(\n \"invalid-param-validator\",\n `${error instanceof Error ? error.message : String(error)} Pass validators as defineComponent's third argument: { params: { name: (value) => ... } }.`,\n { file: route.file, route: route.id },\n );\n return null;\n }\n\n let selectKind: SelectKind | null = null;\n if (kind === \"select\") {\n selectKind = validateSelectKind(module, route, diagnostics);\n if (selectKind === null) return null;\n }\n\n return { ...route, category: \"component\", kind, selectKind, catchAll, overhead };\n}\n\n/** A handler made with `defineComponent(path, ...)` must name the route its file sits in. */\nexport function checkDeclaredRoute(\n module: Record<string, unknown>,\n route: Route,\n diagnostics: Diagnostics,\n expected = route.path,\n): boolean {\n const handler = module.default;\n if (typeof handler !== \"function\") return true;\n const declared = (handler as { route?: unknown }).route;\n if (declared === undefined || declared === expected) return true;\n diagnostics.error(\n \"route-mismatch\",\n `This file is the route \"${expected}\" but its handler declares \"${String(declared)}\". Update the string or move the file.`,\n { file: route.file, route: route.id },\n );\n return false;\n}\n\nfunction validateSelectKind(\n module: Record<string, unknown>,\n route: Route,\n diagnostics: Diagnostics,\n): SelectKind | null {\n const kind = module.kind;\n if (kind === undefined) {\n diagnostics.error(\n \"missing-select-kind\",\n 'select.ts must export `kind`: \"string\", \"user\", \"role\", \"channel\", or \"mentionable\".',\n { file: route.file, route: route.id },\n );\n return null;\n }\n if (typeof kind !== \"string\" || !SELECT_KINDS.has(kind)) {\n diagnostics.error(\n \"invalid-select-kind\",\n `\\`kind\\` is ${describe(kind)}. Expected \"string\", \"user\", \"role\", \"channel\", or \"mentionable\".`,\n { file: route.file, route: route.id },\n );\n return null;\n }\n return kind as SelectKind;\n}\n\nfunction detectShortIdCollisions(routes: ComponentRoute[], diagnostics: Diagnostics): void {\n const seen = new Map<string, ComponentRoute>();\n for (const route of routes) {\n const existing = seen.get(route.shortId);\n if (existing === undefined || existing.id === route.id) {\n seen.set(route.shortId, route);\n continue;\n }\n diagnostics.error(\n \"short-id-collision\",\n `${route.id} and ${existing.id} hash to the same short ID \"${route.shortId}\", so their custom IDs would be indistinguishable. Rename one of the directories.`,\n { file: route.file, route: route.id },\n );\n }\n}\n\n/**\n * Two routes of the same kind whose paths differ only in parameter names, like\n * `tickets/[id]/close` and `tickets/[ticketId]/close`, would both claim the same custom IDs.\n */\nfunction detectDuplicatePatterns(routes: ComponentRoute[], diagnostics: Diagnostics): void {\n const seen = new Map<string, ComponentRoute>();\n for (const route of routes) {\n const shape = route.segments\n .filter((s) => s.type !== \"group\")\n .map((s) => (s.type === \"static\" ? s.name : s.type === \"dynamic\" ? \"[]\" : \"[...]\"))\n .join(\"/\");\n const key = `${route.kind}#${shape}`;\n const existing = seen.get(key);\n if (existing === undefined) {\n seen.set(key, route);\n continue;\n }\n if (existing.id === route.id) continue;\n diagnostics.error(\n \"duplicate-component-pattern\",\n `${route.id} has the same shape as ${existing.id} (${relative(existing.file)}). Parameter names do not make routes distinct.`,\n { file: route.file, route: route.id },\n );\n }\n}\n\nfunction describe(value: unknown): string {\n return typeof value === \"string\" ? JSON.stringify(value) : typeof value;\n}\n\nfunction relative(file: string): string {\n return path.relative(process.cwd(), file).split(path.sep).join(\"/\");\n}\n","import { type ComponentParams, customIdFor, type EncodableRoute } from \"./compile.js\";\n\nexport interface RegisteredComponentRoute extends EncodableRoute {\n path: string;\n}\n\n/**\n * Component routes the running app knows about, keyed by path. The runtime fills this from\n * the manifest before any handler runs, so `customId()` never needs the manifest itself.\n */\nconst routes = new Map<string, RegisteredComponentRoute>();\n\nexport function registerComponentRoutes(list: Iterable<RegisteredComponentRoute>): void {\n routes.clear();\n for (const route of list) routes.set(route.path, route);\n}\n\nexport function encodeComponentRoute(path: string, params: ComponentParams): string {\n const route = routes.get(path);\n if (route === undefined) {\n throw new Error(\n routes.size === 0\n ? `customId(\"${path}\") was called before the runtime registered any routes. Call it from a handler, or from code that runs after start().`\n : `No component route \"${path}\". Check the directory name under components/.`,\n );\n }\n return customIdFor(route, params);\n}\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { RouteGraph } from \"../compiler/graph.js\";\nimport type { Route } from \"../compiler/routes.js\";\nimport { version } from \"../version.js\";\nimport { MANIFEST_VERSION, type Manifest, type ManifestRoute } from \"./schema.js\";\n\nexport const MANIFEST_FILE = \"manifest.json\";\n\n/** Serializes a route graph. `outDir` is where the manifest will live; paths are made relative to it. */\nexport function toManifest(graph: RouteGraph, outDir: string): Manifest {\n const rel = (file: string) => posix(path.relative(graph.appDir, file));\n const base = (route: Route) => {\n const chains = graph.chains.get(route.file) ?? { middleware: [], errors: [] };\n return {\n id: route.id,\n category: route.category,\n path: route.path,\n file: rel(route.file),\n middleware: chains.middleware.map(rel),\n errors: chains.errors.map(rel),\n plugins: graph.plugins.get(route.file) ?? [],\n };\n };\n\n const routes: ManifestRoute[] = [];\n for (const command of graph.commands) {\n for (const route of Object.values(command.handlers))\n routes.push({ ...base(route), kind: \"command\" });\n }\n for (const entry of graph.autocomplete) {\n routes.push({ ...base(entry.route), kind: \"autocomplete\", options: entry.options });\n }\n for (const route of graph.components) {\n routes.push({\n ...base(route),\n kind: route.kind,\n shortId: route.shortId,\n params: route.params,\n catchAll: route.catchAll,\n selectKind: route.selectKind,\n overhead: route.overhead,\n });\n }\n for (const event of graph.events) {\n for (const handler of event.handlers) {\n routes.push({\n ...base(handler.route),\n kind: \"event\",\n event: event.name,\n once: handler.once,\n order: handler.order,\n });\n }\n }\n routes.sort((a, b) => a.kind.localeCompare(b.kind) || a.id.localeCompare(b.id));\n\n return {\n version: MANIFEST_VERSION,\n nectar: version,\n appDir: posix(path.relative(path.resolve(outDir), graph.appDir)),\n routes,\n commands: graph.commands.map((c) => ({\n name: c.name,\n type: c.type,\n payload: c.payload,\n handlers: Object.fromEntries(Object.entries(c.handlers).map(([k, r]) => [k, r.id])),\n })),\n events: graph.events.map((e) => ({\n name: e.name,\n mode: e.mode,\n handlers: e.handlers.map((h) => h.route.id),\n })),\n };\n}\n\n/** Writes `manifest.json` into `outDir` with sorted keys, so identical graphs give identical bytes. */\nexport function writeManifest(manifest: Manifest, outDir: string): string {\n mkdirSync(outDir, { recursive: true });\n const file = path.join(outDir, MANIFEST_FILE);\n writeFileSync(file, `${stableStringify(manifest)}\\n`);\n return file;\n}\n\nexport function stableStringify(value: unknown): string {\n return JSON.stringify(value, (_key, v: unknown) => (isPlainObject(v) ? sortKeys(v) : v), 2);\n}\n\nfunction sortKeys(object: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(object).sort()) out[key] = object[key];\n return out;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction posix(file: string): string {\n return file.split(path.sep).join(\"/\");\n}\n","import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { RouteGraph } from \"../compiler/graph.js\";\nimport { toManifest } from \"../manifest/emit.js\";\nimport type { NectarPlugin, PluginChange, PluginGraph } from \"./index.js\";\n\n/** A frozen copy of the graph in manifest shape, with absolute file paths. */\nexport function pluginGraph(graph: RouteGraph): PluginGraph {\n const manifest = toManifest(graph, graph.appDir);\n const absolute = (file: string) => path.join(graph.appDir, ...file.split(\"/\"));\n // Cloned because the manifest shares arrays and payloads with the graph itself.\n return deepFreeze(\n structuredClone({\n appDir: graph.appDir,\n routes: manifest.routes.map((route) => ({\n ...route,\n file: absolute(route.file),\n middleware: route.middleware.map(absolute),\n errors: route.errors.map(absolute),\n })),\n commands: manifest.commands,\n events: manifest.events,\n }),\n );\n}\n\n/**\n * Runs every plugin's `transform` in config order and applies the returned changes to the\n * graph. Problems become diagnostics; a plugin never mutates the graph directly.\n */\nexport async function applyPlugins(\n graph: RouteGraph,\n plugins: readonly NectarPlugin[],\n): Promise<void> {\n for (const plugin of plugins) {\n if (plugin.transform === undefined) continue;\n let changes: PluginChange[];\n try {\n changes = (await plugin.transform(pluginGraph(graph))) ?? [];\n } catch (error) {\n graph.diagnostics.error(\n \"plugin-failed\",\n `Plugin \"${plugin.name}\" threw while transforming routes: ${describe(error)}`,\n );\n continue;\n }\n if (!Array.isArray(changes)) {\n graph.diagnostics.error(\n \"plugin-invalid-change\",\n `Plugin \"${plugin.name}\" returned ${typeof changes} from transform. Return an array of changes, or nothing.`,\n );\n continue;\n }\n for (const change of changes) apply(graph, plugin.name, change);\n }\n}\n\nfunction apply(graph: RouteGraph, plugin: string, change: PluginChange): void {\n const type: unknown = isRecord(change) ? change.type : undefined;\n if (type !== \"middleware\" && type !== \"diagnostic\") {\n graph.diagnostics.error(\n \"plugin-invalid-change\",\n `Plugin \"${plugin}\" returned a change of type ${JSON.stringify(type)}. Known types: middleware, diagnostic.`,\n );\n return;\n }\n if (change.type === \"diagnostic\") {\n const { severity, code, message, file, route } = change;\n const where = {\n ...(file === undefined ? {} : { file }),\n ...(route === undefined ? {} : { route }),\n };\n if (severity === \"error\") graph.diagnostics.error(code, message, where);\n else graph.diagnostics.warn(code, message, where);\n return;\n }\n\n const routes = graph.routes.filter(\n (r) => r.id === change.route && (change.kind === undefined || r.kind === change.kind),\n );\n const target = change.kind === undefined ? change.route : `${change.route} (${change.kind})`;\n if (routes.length === 0) {\n graph.diagnostics.error(\n \"plugin-unknown-route\",\n `Plugin \"${plugin}\" adds middleware to route \"${target}\", which does not exist.`,\n );\n return;\n }\n if (routes.some((r) => r.category === \"event\")) {\n graph.diagnostics.error(\n \"plugin-invalid-change\",\n `Plugin \"${plugin}\" adds middleware to route \"${target}\", but event handlers don't run middleware.`,\n { route: change.route },\n );\n return;\n }\n if (\n typeof change.file !== \"string\" ||\n !path.isAbsolute(change.file) ||\n !existsSync(change.file)\n ) {\n graph.diagnostics.error(\n \"plugin-missing-file\",\n `Plugin \"${plugin}\" adds middleware from ${JSON.stringify(change.file)}, which is not an absolute path to an existing file.`,\n { route: change.route },\n );\n return;\n }\n const file = path.normalize(change.file);\n for (const route of routes) {\n const chains = graph.chains.get(route.file);\n if (chains === undefined || chains.middleware.includes(file)) continue;\n if (change.position === \"inner\") chains.middleware.push(file);\n else chains.middleware.unshift(file);\n const touched = graph.plugins.get(route.file) ?? [];\n if (!touched.includes(plugin)) graph.plugins.set(route.file, [...touched, plugin]);\n }\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value === \"object\" && value !== null && !Object.isFrozen(value)) {\n Object.freeze(value);\n for (const inner of Object.values(value)) deepFreeze(inner);\n }\n return value;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction describe(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n","import type { Client } from \"discord.js\";\nimport type { Project } from \"../cli/project.js\";\nimport type { Severity } from \"../compiler/diagnostics.js\";\nimport type { RouteKind } from \"../compiler/routes.js\";\nimport type { NectarServices } from \"../index.js\";\nimport type {\n Manifest,\n ManifestCommand,\n ManifestEvent,\n ManifestRoute,\n} from \"../manifest/schema.js\";\nimport type { SignalEmitter } from \"../runtime/signals.js\";\nimport type { Env, Logger } from \"../runtime/types.js\";\n\n/**\n * A plugin takes part in compilation and the runtime lifecycle. A library that only exports\n * functions for handlers to call does not need to be one.\n */\nexport interface NectarPlugin {\n /** Unique among the configured plugins. Named in diagnostics and in the manifest. */\n name: string;\n version?: string;\n /**\n * Runs after the route graph is validated and before the manifest is written. The graph is\n * frozen; return changes and the compiler applies and checks them. Plugins run in config\n * order, each seeing the changes of the ones before it.\n */\n transform?(graph: PluginGraph): Maybe<PluginChange[]> | Promise<Maybe<PluginChange[]>>;\n /** Declarations appended to `.nectar/types.d.ts`. */\n types?(graph: PluginGraph): Maybe<string>;\n /** Extra `nectar <name>` commands. */\n commands?: PluginCommand[];\n /**\n * Runs when the runtime starts, before any handler is imported and before login. A sharded\n * bot runs it in every process. Returned services land on `ctx.services` for every handler\n * and middleware.\n */\n start?(app: PluginApp): Maybe<Partial<NectarServices>> | Promise<Maybe<Partial<NectarServices>>>;\n /** Runs on shutdown, after in-flight interactions drain and before the client is destroyed. */\n stop?(app: PluginApp): void | Promise<void>;\n /**\n * Runs once per application, in the process that runs shard 0, after every `start`. For work\n * that must not repeat per shard process: a scheduled job, a web server, posting stats.\n */\n startGlobal?(app: PluginApp): void | Promise<void>;\n /** Runs on shutdown in the process that ran `startGlobal`, before any `stop`. */\n stopGlobal?(app: PluginApp): void | Promise<void>;\n}\n\n/** A hook may return nothing, so a body without `return` type-checks. */\n// biome-ignore lint/suspicious/noConfusingVoidType: that is the point\ntype Maybe<T> = T | undefined | void;\n\nexport type PluginChange =\n | {\n type: \"middleware\";\n /** Route ID, `<category>:<path>`. */\n route: string;\n /**\n * Only the route of this kind. A command and its autocomplete share an ID; without\n * `kind`, both get the middleware, as they would from a `middleware.ts`.\n */\n kind?: RouteKind;\n /** Absolute path of a module whose default export is a middleware. */\n file: string;\n /** `outer` (default) runs before the app's own middleware, `inner` right before the handler. */\n position?: \"outer\" | \"inner\";\n }\n | {\n type: \"diagnostic\";\n severity: Severity;\n code: string;\n message: string;\n file?: string;\n route?: string;\n };\n\ntype DeepReadonly<T> = T extends (infer U)[]\n ? readonly DeepReadonly<U>[]\n : T extends object\n ? { readonly [K in keyof T]: DeepReadonly<T[K]> }\n : T;\n\n/** The compiled app as a plugin sees it: the manifest shape with absolute file paths, frozen. */\nexport interface PluginGraph {\n readonly appDir: string;\n readonly routes: DeepReadonly<ManifestRoute[]>;\n readonly commands: DeepReadonly<ManifestCommand[]>;\n readonly events: DeepReadonly<ManifestEvent[]>;\n}\n\nexport interface PluginApp {\n readonly client: Client;\n readonly env: Env;\n readonly logger: Logger;\n readonly signals: SignalEmitter;\n readonly manifest: Manifest;\n}\n\nexport interface PluginCommand {\n name: string;\n description: string;\n options?: Record<string, { type: \"boolean\" | \"string\"; description: string }>;\n /** Returns the exit code. */\n run(ctx: PluginCommandContext): number | Promise<number>;\n}\n\nexport interface PluginCommandContext {\n project: Project;\n flags: Record<string, string | boolean | undefined>;\n out(line: string): void;\n err(line: string): void;\n}\n\nexport function definePlugin(plugin: NectarPlugin): NectarPlugin {\n return plugin;\n}\n\n/** A plugin misbehaved: threw from a hook, or provided something that clashes. */\nexport class PluginError extends Error {\n constructor(\n readonly plugin: string,\n readonly detail: string,\n ) {\n super(`Plugin \"${plugin}\": ${detail}`);\n this.name = \"PluginError\";\n }\n}\n\nexport { applyPlugins, pluginGraph } from \"./transform.js\";\n"],"mappings":";;;;;;;AAGA,MAAa,EAAE,YAAY,cAAc,YAAY,GAAG,CAAC,CAAC,iBAAiB;;;;ACF3E,MAAa,uBAAuB;AAEpC,MAAM,SAAS;AAMf,IAAa,uBAAb,cAA0C,MAAM;CAEnC;CACA;CAFX,YACE,UACA,SACA;EACA,MACE,iBAAiB,QAAQ,MAAM,SAAS,OAAO,wFACjD;EALS,KAAA,WAAA;EACA,KAAA,UAAA;EAKT,KAAK,OAAO;CACd;AACF;;;;;AAMA,SAAgB,eAAe,SAAiB,QAA2B,UAAU,SAAS;CAC5F,IAAI,MAAM,SAAS;CACnB,KAAK,MAAM,SAAS,QAAQ,OAAO,IAAI,YAAY,KAAK;CACxD,IAAI,IAAI,SAAA,KAA+B,MAAM,IAAI,qBAAqB,KAAK,OAAO;CAClF,OAAO;AACT;;;;;AAUA,SAAgB,eAAe,KAA8B;CAC3D,IAAI,CAAC,IAAI,WAAW,MAAM,GAAG,OAAO;EAAE,IAAI;EAAO,QAAQ;CAAa;CAEtE,MAAM,UAAU,IAAI,MAAM,GAAe,CAA+B;CACxE,IAAI,CAAC,gBAAgB,KAAK,OAAO,GAAG,OAAO;EAAE,IAAI;EAAO,QAAQ;CAAY;CAE5E,MAAM,SAAmB,CAAC;CAC1B,IAAI,QAAQ;CACZ,IAAI,UAAU,IA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