@sleepy-hollow/framework 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to Sleepy Hollow are documented in this file.
4
4
 
5
+ ## 0.3.3 - 2026-08-21
6
+
7
+ ### Changed: Node/Bun documentation and scaffold alignment
8
+
9
+ The framework documentation and Sleepy Hollow skill now describe the runtime's
10
+ object-shaped route security metadata, case-sensitive endpoint requirement
11
+ headings, the `sgad-application/v0.2` application format, and the current
12
+ framework 0.3.3 testing workflow. `hollow create` now emits the matching
13
+ application metadata, Node/Bun TypeScript configuration, and Node typings.
14
+
15
+ The framework's route evidence and fixtures were aligned with the same security
16
+ shape, while retained Deno-era verification records are explicitly marked as
17
+ historical migration evidence.
18
+
5
19
  ## 0.3.2 - 2026-08-20
6
20
 
7
21
  ### Fixed: global `hollow` executable
package/README.md CHANGED
@@ -51,7 +51,7 @@ export default defineRoute({
51
51
  params: z.object({ id: z.string() }).strict(),
52
52
  responses: { 200: z.object({ id: z.string(), url: z.string() }).strict() },
53
53
  },
54
- security: { authentication: "none" },
54
+ security: { authentication: { mode: "none" } },
55
55
  contract: { summary: "Return one bookmark" },
56
56
  handler: ({ params }) => Response.json({ id: params.id, url: "https://example.com" }),
57
57
  },
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  redactSecurityData
3
- } from "./chunk-DGTHFZPZ.js";
3
+ } from "./chunk-LZ2HLHDW.js";
4
4
  import {
5
5
  z
6
- } from "./chunk-CAPFDC25.js";
6
+ } from "./chunk-JRFHLLLF.js";
7
7
  import {
8
8
  platform
9
- } from "./chunk-53TZY5YP.js";
9
+ } from "./chunk-S3Z6CO7J.js";
10
10
 
11
11
  // core/config/types.ts
12
12
  var RUNTIME_MODES = [
@@ -426,4 +426,4 @@ export {
426
426
  createJsonLogger,
427
427
  createOperationalRoutes
428
428
  };
429
- //# sourceMappingURL=chunk-BJONRVDG.js.map
429
+ //# sourceMappingURL=chunk-4PPSJ2LE.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRouter
3
- } from "./chunk-53TZY5YP.js";
3
+ } from "./chunk-S3Z6CO7J.js";
4
4
 
5
5
  // core/validation/mod.ts
6
6
  import { z as z2 } from "zod";
@@ -595,4 +595,4 @@ export {
595
595
  createValidatedRouter,
596
596
  z2 as z
597
597
  };
598
- //# sourceMappingURL=chunk-CAPFDC25.js.map
598
+ //# sourceMappingURL=chunk-JRFHLLLF.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createValidatedRouter
3
- } from "./chunk-CAPFDC25.js";
3
+ } from "./chunk-JRFHLLLF.js";
4
4
  import {
5
5
  platform
6
- } from "./chunk-53TZY5YP.js";
6
+ } from "./chunk-S3Z6CO7J.js";
7
7
 
8
8
  // core/security/declaration.ts
9
9
  import { isAbsolute, resolve, sep } from "path";
@@ -827,4 +827,4 @@ export {
827
827
  composeProjectSecurity,
828
828
  createMemoryRateLimiter
829
829
  };
830
- //# sourceMappingURL=chunk-DGTHFZPZ.js.map
830
+ //# sourceMappingURL=chunk-LZ2HLHDW.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-BAKXP7IR.js";
4
4
  import {
5
5
  composeProjectSecurity
6
- } from "./chunk-DGTHFZPZ.js";
6
+ } from "./chunk-LZ2HLHDW.js";
7
7
  import {
8
8
  __commonJS,
9
9
  __toESM
@@ -4582,4 +4582,4 @@ export {
4582
4582
  * LICENSE file in the root directory of this source tree.
4583
4583
  *)
4584
4584
  */
4585
- //# sourceMappingURL=chunk-D4U3ZY4O.js.map
4585
+ //# sourceMappingURL=chunk-M4D63YC7.js.map
@@ -467,4 +467,4 @@ export {
467
467
  discoverRoutes,
468
468
  createRouter
469
469
  };
470
- //# sourceMappingURL=chunk-53TZY5YP.js.map
470
+ //# sourceMappingURL=chunk-S3Z6CO7J.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../core/routing/define_route.ts","../runtime/platform.ts","../core/routing/discover.ts","../core/routing/types.ts","../core/routing/router.ts"],"sourcesContent":["import type {\n HttpMethod,\n RouteHandlerContext,\n RouteOperation,\n} from \"./types.ts\";\n\ntype MethodMap = Partial<Record<HttpMethod, unknown>>;\n\ntype DefinedRoute<\n Schemas extends MethodMap,\n Security extends { readonly [Method in keyof Schemas]: unknown },\n Contract extends { readonly [Method in keyof Schemas]: unknown },\n> = {\n readonly [Method in keyof Schemas]: RouteOperation<\n Schemas[Method],\n Security[Method],\n Contract[Method]\n >;\n};\n\n/**\n * Declares the operations a route file answers, one per HTTP method.\n *\n * The call is an identity function at runtime; its work is done in the type\n * system, where the schemas you pass become the types of `params`, `query`,\n * `headers`, and `body` inside each handler, and the declared authentication\n * mode determines whether `principal` can be `null`.\n *\n * ```ts\n * import { defineRoute } from \"@sleepy-hollow/framework/routing\";\n * import { z } from \"@sleepy-hollow/framework/validation\";\n *\n * export default defineRoute({\n * GET: {\n * schemas: {\n * params: z.object({ id: z.string() }).strict(),\n * responses: { 200: z.object({ id: z.string() }).strict() },\n * },\n * security: { authentication: { mode: \"none\" } },\n * contract: { summary: \"Return one widget\" },\n * handler: ({ params }) => Response.json({ id: params.id }),\n * },\n * });\n * ```\n *\n * @param route The operations this file answers, keyed by HTTP method.\n * @returns The same declaration, typed so handlers infer their inputs.\n */\nexport function defineRoute<\n const Schemas extends MethodMap,\n const Security extends { readonly [Method in keyof Schemas]: unknown },\n const Contract extends { readonly [Method in keyof Schemas]: unknown },\n>(\n route: {\n readonly [Method in keyof Schemas]: {\n readonly schemas: Schemas[Method];\n readonly security: Security[Method];\n readonly contract: Contract[Method];\n readonly handler: (\n context: RouteHandlerContext<Schemas[Method], Security[Method]>,\n ) => Response | Promise<Response>;\n };\n },\n): DefinedRoute<Schemas, Security, Contract> {\n return route;\n}\n","import { spawn as spawnChild } from \"child_process\";\nimport {\n copyFile,\n lstat,\n mkdir,\n mkdtemp,\n readFile,\n readdir,\n realpath,\n rename,\n rm,\n stat,\n writeFile,\n} from \"fs/promises\";\nimport { readdirSync, watch, type FSWatcher } from \"fs\";\nimport { symlink } from \"fs/promises\";\nimport { Readable } from \"stream\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\nimport { serve as nodeServe, type FetchHandler } from \"./server.ts\";\n\nexport interface PlatformDirEntry {\n readonly name: string;\n readonly isFile: boolean;\n readonly isDirectory: boolean;\n readonly isSymlink: boolean;\n}\n\nexport interface PlatformCommandOutput {\n readonly code: number;\n readonly success: boolean;\n readonly stdout: Uint8Array;\n readonly stderr: Uint8Array;\n}\n\nclass NotFound extends Error {\n constructor(path?: string) {\n super(path ? `Not found: ${path}` : \"Not found\");\n this.name = \"NotFound\";\n }\n}\n\nfunction normalizeFilesystemError(error: unknown, path?: string): never {\n if (typeof error === \"object\" && error !== null && \"code\" in error &&\n (error as { readonly code?: unknown }).code === \"ENOENT\") {\n throw new NotFound(path);\n }\n throw error;\n}\n\nasync function filesystem<T>(operation: Promise<T>, path?: string): Promise<T> {\n try {\n return await operation;\n } catch (error) {\n return normalizeFilesystemError(error, path);\n }\n}\n\ninterface CommandOptions {\n readonly args?: readonly string[];\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string>>;\n readonly clearEnv?: boolean;\n readonly stdin?: \"null\" | \"piped\";\n readonly stdout?: \"piped\" | \"null\";\n readonly stderr?: \"piped\" | \"null\";\n}\n\nexport class Command {\n readonly #command: string;\n readonly #options: CommandOptions;\n\n constructor(command: string, options: CommandOptions = {}) {\n this.#command = command;\n this.#options = options;\n }\n\n async output(): Promise<PlatformCommandOutput> {\n const child = spawnChild(this.#command, this.#options.args ?? [], {\n cwd: this.#options.cwd,\n env: this.#options.clearEnv ? this.#options.env : { ...process.env, ...this.#options.env },\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n const stdout: Buffer[] = [];\n const stderr: Buffer[] = [];\n child.stdout.on(\"data\", (chunk: Buffer) => stdout.push(chunk));\n child.stderr.on(\"data\", (chunk: Buffer) => stderr.push(chunk));\n const code = await new Promise<number>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"close\", (status) => resolve(status ?? 1));\n });\n return { code, success: code === 0, stdout: Buffer.concat(stdout), stderr: Buffer.concat(stderr) };\n }\n\n spawn() {\n const child = spawnChild(this.#command, this.#options.args ?? [], {\n cwd: this.#options.cwd,\n env: this.#options.clearEnv ? this.#options.env : { ...process.env, ...this.#options.env },\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n return {\n stdout: Readable.toWeb(child.stdout) as ReadableStream<Uint8Array>,\n stderr: Readable.toWeb(child.stderr) as ReadableStream<Uint8Array>,\n status: new Promise<{ code: number; success: boolean }>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"close\", (code) => {\n const resolved = code ?? 1;\n resolve({ code: resolved, success: resolved === 0 });\n });\n }),\n kill: (signal?: NodeJS.Signals) => child.kill(signal),\n };\n }\n}\n\nclass Watcher implements AsyncIterable<{ readonly paths: readonly string[] }> {\n readonly #watcher: FSWatcher;\n #closed = false;\n #pending: Array<{ readonly paths: readonly string[] }> = [];\n #resolve?: (event: IteratorResult<{ readonly paths: readonly string[] }>) => void;\n #reject?: (reason: unknown) => void;\n #failure?: unknown;\n\n constructor(root: string) {\n this.#watcher = watch(root, { recursive: true }, (_event, filename) => {\n const event = { paths: [join(root, String(filename ?? \"\"))] };\n if (this.#resolve) {\n this.#resolve({ done: false, value: event });\n this.#resolve = undefined;\n } else this.#pending.push(event);\n });\n this.#watcher.on(\"error\", (error) => {\n if (this.#closed) return;\n this.#failure = error;\n this.#closed = true;\n this.#reject?.(error);\n this.#resolve = undefined;\n this.#reject = undefined;\n });\n }\n\n close(): void {\n this.#closed = true;\n this.#watcher.close();\n this.#resolve?.({ done: true, value: undefined });\n this.#resolve = undefined;\n this.#reject = undefined;\n }\n\n [Symbol.asyncIterator](): AsyncIterator<{ readonly paths: readonly string[] }> {\n return {\n next: () => {\n const value = this.#pending.shift();\n if (value) return Promise.resolve({ done: false, value });\n if (this.#failure) return Promise.reject(this.#failure);\n if (this.#closed) return Promise.resolve({ done: true, value: undefined });\n return new Promise((resolve, reject) => {\n this.#resolve = resolve;\n this.#reject = reject;\n });\n },\n };\n }\n}\n\nexport const platform = Object.freeze({\n args: process.argv.slice(2),\n cwd: () => process.cwd(),\n exit: (code?: number) => process.exit(code),\n execPath: () => process.execPath,\n env: Object.freeze({\n get: (name: string) => process.env[name],\n toObject: () => ({ ...process.env }),\n }),\n errors: Object.freeze({\n NotFound,\n AddrInUse: class AddrInUse extends Error {},\n PermissionDenied: class PermissionDenied extends Error {},\n }),\n isNotFound: (error: unknown) =>\n error instanceof NotFound ||\n (typeof error === \"object\" && error !== null &&\n \"code\" in error && (error as { readonly code?: unknown }).code === \"ENOENT\"),\n readTextFile: async (path: string) => filesystem(readFile(path, \"utf8\"), path),\n readFile: async (path: string) => filesystem(readFile(path), path),\n writeTextFile: async (path: string, text: string, options?: { readonly createNew?: boolean }) =>\n writeFile(path, text, options?.createNew ? { flag: \"wx\" } : undefined),\n stat: (path: string) => filesystem(stat(path), path),\n lstat: (path: string) => filesystem(lstat(path), path),\n mkdir,\n rename,\n remove: (path: string, options?: { readonly recursive?: boolean }) => rm(path, { recursive: options?.recursive, force: true }),\n realPath: (path: string) => filesystem(realpath(path), path),\n copyFile: (source: string, target: string) => filesystem(copyFile(source, target), source),\n symlink: (target: string, path: string) => filesystem(symlink(target, path), path),\n readDirSync: (path: string) => readdirSync(path, { withFileTypes: true }).map((entry) => ({ name: entry.name, isFile: entry.isFile(), isDirectory: entry.isDirectory(), isSymlink: entry.isSymbolicLink() })),\n makeTempDir: async (options?: { readonly prefix?: string; readonly dir?: string }) =>\n mkdtemp(join(options?.dir ?? tmpdir(), options?.prefix ?? \"sleepy-hollow-\")),\n async *readDir(path: string): AsyncIterable<PlatformDirEntry> {\n for (const entry of await readdir(path, { withFileTypes: true })) {\n yield { name: entry.name, isFile: entry.isFile(), isDirectory: entry.isDirectory(), isSymlink: entry.isSymbolicLink() };\n }\n },\n watchFs: (root: string, _options?: { readonly recursive?: boolean }) => new Watcher(root),\n addSignalListener: (signal: NodeJS.Signals, listener: () => void) => process.on(signal, listener),\n removeSignalListener: (signal: NodeJS.Signals, listener: () => void) => process.off(signal, listener),\n serve: (options: { readonly port?: number; readonly hostname?: string }, handler: FetchHandler) => nodeServe(handler, options),\n Command,\n});\n","import { platform, type PlatformDirEntry } from \"#platform\";\nimport { dirname, relative, resolve, sep } from \"path\";\nimport { fileURLToPath, pathToFileURL } from \"url\";\n\nimport {\n HTTP_METHODS,\n type HttpMethod,\n type NormalizedRoute,\n RouteDiscoveryError,\n type RouteModule,\n type RouteOperation,\n type RoutingDiagnostic,\n} from \"./types.ts\";\n\nconst dynamicSegment = /^\\[([^\\]]+)\\]$/;\nconst parameterName = /^[A-Za-z_][A-Za-z0-9_]*$/;\nconst methods = new Set<string>(HTTP_METHODS);\n\ninterface RouteFile {\n readonly path: string;\n readonly segments: readonly string[];\n readonly routePath: string;\n readonly conflictPath: string;\n readonly parameterNames: readonly string[];\n}\n\nconst portablePath = (path: string) => path.split(sep).join(\"/\");\n\nasync function collectRouteFiles(directory: string): Promise<string[]> {\n const files: string[] = [];\n const entries: PlatformDirEntry[] = [];\n\n for await (const entry of platform.readDir(directory)) entries.push(entry);\n entries.sort((left, right) => left.name.localeCompare(right.name));\n\n for (const entry of entries) {\n const path = resolve(directory, entry.name);\n if (entry.isDirectory) files.push(...await collectRouteFiles(path));\n if (entry.isFile && entry.name === \"route.ts\") files.push(path);\n }\n\n return files;\n}\n\nfunction normalizeRouteFile(\n apiRoot: string,\n path: string,\n): RouteFile | RoutingDiagnostic {\n const segments = portablePath(relative(apiRoot, dirname(path))).split(\"/\")\n .filter(Boolean);\n const routeSegments: string[] = [];\n const conflictSegments: string[] = [];\n const parameterNames: string[] = [];\n\n for (const segment of segments) {\n const match = segment.match(dynamicSegment);\n if (!match) {\n if (segment.includes(\"[\") || segment.includes(\"]\")) {\n return invalidSegment(path, segment);\n }\n routeSegments.push(segment);\n conflictSegments.push(segment);\n continue;\n }\n\n const name = match[1];\n if (!parameterName.test(name)) return invalidSegment(path, segment);\n if (parameterNames.includes(name)) {\n return {\n code: \"SH_ROUTE_INVALID_SEGMENT\",\n summary: `Dynamic parameter '${name}' is repeated in one route`,\n files: [portablePath(path)],\n correction: \"Use a unique parameter name for every dynamic segment.\",\n };\n }\n\n parameterNames.push(name);\n routeSegments.push(`:${name}`);\n conflictSegments.push(\":parameter\");\n }\n\n return {\n path: portablePath(path),\n segments,\n routePath: `/${routeSegments.join(\"/\")}`,\n conflictPath: `/${conflictSegments.join(\"/\")}`,\n parameterNames,\n };\n}\n\nfunction invalidSegment(path: string, segment: string): RoutingDiagnostic {\n return {\n code: \"SH_ROUTE_INVALID_SEGMENT\",\n summary: `Invalid dynamic route segment '${segment}'`,\n files: [portablePath(path)],\n correction:\n \"Use [name] with a TypeScript identifier as the parameter name.\",\n };\n}\n\nfunction validateModule(\n value: unknown,\n file: RouteFile,\n): RoutingDiagnostic | RouteModule {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return invalidModule(\n file.path,\n \"The default export must be created with defineRoute\",\n );\n }\n\n const entries = Object.entries(value);\n if (entries.length === 0) {\n return invalidModule(\n file.path,\n \"The route must declare at least one HTTP method\",\n );\n }\n\n for (const [method, operation] of entries) {\n if (!methods.has(method)) {\n return invalidModule(file.path, `Unsupported HTTP method '${method}'`);\n }\n if (!isOperation(operation)) {\n return invalidModule(\n file.path,\n `${method} must declare schemas, security, contract, and a handler`,\n );\n }\n }\n\n return value as RouteModule;\n}\n\nfunction isOperation(value: unknown): value is RouteOperation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n const operation = value as Record<string, unknown>;\n return Object.hasOwn(operation, \"schemas\") &&\n Object.hasOwn(operation, \"security\") &&\n Object.hasOwn(operation, \"contract\") &&\n typeof operation.handler === \"function\";\n}\n\nfunction invalidModule(path: string, summary: string): RoutingDiagnostic {\n return {\n code: \"SH_ROUTE_INVALID_MODULE\",\n summary,\n files: [portablePath(path)],\n correction:\n \"Default-export one defineRoute method map with complete operations.\",\n };\n}\n\nfunction findConflicts(files: readonly RouteFile[]): RoutingDiagnostic[] {\n const groups = Map.groupBy(files, (file) => file.conflictPath);\n const diagnostics: RoutingDiagnostic[] = [];\n\n for (const [route, group] of groups) {\n if (group.length < 2) continue;\n diagnostics.push({\n code: \"SH_ROUTE_CONFLICT\",\n summary: `Ambiguous route definitions normalize to '${route}'`,\n files: group.map((file) => file.path).sort(),\n route,\n correction: \"Keep only one dynamic sibling at each route depth.\",\n });\n }\n\n return diagnostics.sort((left, right) =>\n (left.route ?? \"\").localeCompare(right.route ?? \"\")\n );\n}\n\n/**\n * Walks a directory and derives the route table from the file layout.\n *\n * Each `route.ts` becomes one route whose URL path is its position in the\n * tree, and each method it exports becomes one entry. Faults are collected\n * across the whole tree and thrown together as a\n * {@linkcode RouteDiscoveryError}, so one run reports every correction rather\n * than stopping at the first.\n *\n * @param apiRoot Directory to walk, as a path or a `file:` URL.\n * @returns Every discovered route, one entry per method.\n * @throws {RouteDiscoveryError} When any route in the tree is malformed.\n */\nexport async function discoverRoutes(\n apiRoot: URL | string,\n): Promise<readonly NormalizedRoute[]> {\n const root = resolve(\n apiRoot instanceof URL ? fileURLToPath(apiRoot) : apiRoot,\n );\n const diagnostics: RoutingDiagnostic[] = [];\n const routeFiles: RouteFile[] = [];\n\n for (const path of await collectRouteFiles(root)) {\n const normalized = normalizeRouteFile(root, path);\n if (\"code\" in normalized) diagnostics.push(normalized);\n else routeFiles.push(normalized);\n }\n\n diagnostics.push(...findConflicts(routeFiles));\n\n const routes: NormalizedRoute[] = [];\n for (const file of routeFiles) {\n try {\n const imported = await import(pathToFileURL(file.path).href);\n const routeModule = validateModule(imported.default, file);\n if (\"code\" in routeModule) {\n diagnostics.push(routeModule);\n continue;\n }\n\n for (const [method, operation] of Object.entries(routeModule)) {\n routes.push({\n method: method as HttpMethod,\n path: file.routePath,\n source: file.path,\n parameterNames: file.parameterNames,\n operation,\n });\n }\n } catch (error) {\n diagnostics.push(invalidModule(\n file.path,\n `Route module could not be loaded: ${\n error instanceof Error ? error.message : String(error)\n }`,\n ));\n }\n }\n\n if (diagnostics.length > 0) {\n diagnostics.sort((left, right) =>\n `${left.code}:${left.files.join(\":\")}`.localeCompare(\n `${right.code}:${right.files.join(\":\")}`,\n )\n );\n throw new RouteDiscoveryError(diagnostics);\n }\n\n return routes.sort((left, right) =>\n left.path.localeCompare(right.path) ||\n left.method.localeCompare(right.method)\n );\n}\n","/** The HTTP methods a route module may export an operation for. */\nexport const HTTP_METHODS = [\n \"DELETE\",\n \"GET\",\n \"HEAD\",\n \"OPTIONS\",\n \"PATCH\",\n \"POST\",\n \"PUT\",\n] as const;\n\n/** One of the {@linkcode HTTP_METHODS} a route operation may answer. */\nexport type HttpMethod = (typeof HTTP_METHODS)[number];\n\ntype SchemaOutput<Schema, Fallback> = Schema extends {\n readonly _zod: { readonly output: infer Output };\n} ? Output\n : Schema extends { readonly _output: infer Output } ? Output\n : Fallback;\n\ntype ReadonlyOutput<Output> = Output extends object ? Readonly<Output> : Output;\n\ntype LocationOutput<\n Schemas,\n Location extends PropertyKey,\n Fallback,\n> = Schemas extends { readonly [Key in Location]: infer Schema }\n ? ReadonlyOutput<SchemaOutput<Schema, Fallback>>\n : Fallback;\n\ntype BodyOutput<Schemas> = Schemas extends {\n readonly body: { readonly schema: infer Schema };\n} ? ReadonlyOutput<SchemaOutput<Schema, unknown>>\n : undefined;\n\n/**\n * The authenticated caller a handler runs on behalf of.\n *\n * Present only on routes whose security declares authentication; a route\n * declaring `\"none\"` receives `null` instead, and the type reflects that so a\n * handler cannot read a principal it was never given.\n */\nexport interface RoutePrincipal {\n /** Stable identifier for the caller, unique within its {@linkcode type}. */\n readonly id: string;\n /** What kind of caller this is, as named by the authentication provider. */\n readonly type: string;\n /** Additional claims the provider asserted about the caller. */\n readonly claims?: Readonly<Record<string, unknown>>;\n}\n\ntype SecurityPrincipal<Security> = Security extends {\n readonly authentication: { readonly mode: \"required\" };\n} ? RoutePrincipal\n : Security extends {\n readonly authentication: { readonly mode: \"none\" };\n } ? null\n : RoutePrincipal | null;\n\n/**\n * What a route handler receives.\n *\n * Each validated location is typed from the route's own schemas, so `params`,\n * `query`, `headers`, and `body` arrive already parsed rather than as raw\n * strings the handler has to re-check.\n */\nexport interface RouteHandlerContext<Schemas = unknown, Security = unknown> {\n /** The incoming request, unmodified. */\n readonly request: Request;\n /** Path parameters, parsed by the route's `params` schema. */\n readonly params: LocationOutput<\n Schemas,\n \"params\",\n Readonly<Record<string, string>>\n >;\n /** Query string values, parsed by the route's `query` schema. */\n readonly query: LocationOutput<\n Schemas,\n \"query\",\n Readonly<Record<string, unknown>>\n >;\n /** Request headers, parsed by the route's `headers` schema. */\n readonly headers: LocationOutput<\n Schemas,\n \"headers\",\n Readonly<Record<string, unknown>>\n >;\n /** The parsed request body, or `undefined` when the route declares none. */\n readonly body: BodyOutput<Schemas>;\n /** Aborts when the client disconnects or the request times out. */\n readonly signal: AbortSignal;\n /** The authenticated caller, or `null` on an unauthenticated route. */\n readonly principal: SecurityPrincipal<Security>;\n /** Correlates this request across logs and captured evidence. */\n readonly requestId: string;\n}\n\n/**\n * One method's implementation within a route module: its schemas, its security,\n * its documented contract, and the handler that answers it.\n */\nexport interface RouteOperation<\n Schemas = unknown,\n Security = unknown,\n Contract = unknown,\n> {\n /** Validation schemas for each request location and each response status. */\n readonly schemas: Schemas;\n /** Authentication and authorization requirements for this operation. */\n readonly security: Security;\n /** Documentation for this operation, such as its summary. */\n readonly contract: Contract;\n /** Answers the request once validation and security have passed. */\n readonly handler: (\n context: RouteHandlerContext<Schemas, Security>,\n ) => Response | Promise<Response>;\n}\n\n/** A route file's default export: one operation per method it answers. */\nexport type RouteModule = Partial<\n Record<HttpMethod, RouteOperation<unknown, unknown, unknown>>\n>;\n\n/**\n * One method of one route after discovery, with its URL path derived from the\n * file's position in the tree. This is what the router dispatches against.\n */\nexport interface NormalizedRoute {\n /** The method this entry answers. */\n readonly method: HttpMethod;\n /** The URL path, with parameters as `[name]` segments. */\n readonly path: string;\n /** Path of the file this route was discovered from. */\n readonly source: string;\n /** Names of the path parameters, in the order they appear. */\n readonly parameterNames: readonly string[];\n /** The operation to invoke for this method. */\n readonly operation: RouteOperation<unknown, unknown, unknown>;\n}\n\n/** One reason discovery refused a route tree. */\nexport interface RoutingDiagnostic {\n /** Stable machine-readable identifier for this kind of fault. */\n readonly code: string;\n /** What is wrong, in one sentence. */\n readonly summary: string;\n /** The files this diagnostic was raised against. */\n readonly files: readonly string[];\n /** The route path concerned, when the fault is specific to one. */\n readonly route?: string;\n /** What to change to resolve it. */\n readonly correction?: string;\n}\n\n/**\n * Thrown when a route tree cannot be discovered.\n *\n * Discovery reports every fault it found rather than the first, so one run\n * surfaces the whole set of corrections.\n */\nexport class RouteDiscoveryError extends Error {\n /**\n * Builds an error whose message lists every diagnostic, one per line.\n *\n * @param diagnostics Every fault discovery found, in the order detected.\n */\n constructor(readonly diagnostics: readonly RoutingDiagnostic[]) {\n super(\n diagnostics.map((diagnostic) =>\n `${diagnostic.code}: ${diagnostic.summary}`\n ).join(\"\\n\"),\n );\n this.name = \"RouteDiscoveryError\";\n }\n}\n","import { platform } from \"#platform\";\nimport type { NormalizedRoute } from \"./types.ts\";\n\ninterface Match {\n readonly route: NormalizedRoute;\n readonly params: Readonly<Record<string, string>>;\n}\n\nfunction splitPath(path: string): readonly string[] | undefined {\n try {\n return path.split(\"/\").filter(Boolean).map(decodeURIComponent);\n } catch {\n return undefined;\n }\n}\n\nfunction matchRoute(\n route: NormalizedRoute,\n requestSegments: readonly string[],\n): Match | undefined {\n const routeSegments = route.path.split(\"/\").filter(Boolean);\n if (routeSegments.length !== requestSegments.length) return undefined;\n\n const params: Record<string, string> = {};\n for (let index = 0; index < routeSegments.length; index += 1) {\n const expected = routeSegments[index];\n const actual = requestSegments[index];\n if (expected.startsWith(\":\")) params[expected.slice(1)] = actual;\n else if (expected !== actual) return undefined;\n }\n\n return { route, params };\n}\n\nfunction compareSpecificity(left: Match, right: Match): number {\n const leftSegments = left.route.path.split(\"/\").filter(Boolean);\n const rightSegments = right.route.path.split(\"/\").filter(Boolean);\n\n for (let index = 0; index < leftSegments.length; index += 1) {\n const leftDynamic = leftSegments[index].startsWith(\":\");\n const rightDynamic = rightSegments[index].startsWith(\":\");\n if (leftDynamic !== rightDynamic) return leftDynamic ? 1 : -1;\n }\n\n return left.route.path.localeCompare(right.route.path);\n}\n\nfunction problem(\n status: number,\n title: string,\n instance: string,\n headers?: HeadersInit,\n): Response {\n return new Response(\n JSON.stringify({ type: \"about:blank\", title, status, instance }),\n {\n status,\n headers: {\n \"content-type\": \"application/problem+json\",\n ...headers,\n },\n },\n );\n}\n\n/**\n * Builds a request handler that dispatches to a discovered route table.\n *\n * The returned object exposes `fetch`, so it can be passed to `platform.serve`\n * directly. An unmatched path answers 404 and an unmatched method answers 405,\n * both as problem-details responses.\n *\n * ```ts\n * import { createRouter, discoverRoutes } from \"@sleepy-hollow/framework\";\n *\n * const router = createRouter(await discoverRoutes(\"./api\"));\n * platform.serve(router.fetch);\n * ```\n *\n * @param routes The route table, normally from {@linkcode discoverRoutes}.\n * @returns A handler suitable for `platform.serve`.\n */\nexport function createRouter(\n routes: readonly NormalizedRoute[],\n): { fetch(request: Request): Promise<Response> } {\n const inventory = [...routes];\n\n return {\n async fetch(request: Request): Promise<Response> {\n const url = new URL(request.url);\n const requestSegments = splitPath(url.pathname);\n if (!requestSegments) return problem(404, \"Not Found\", url.pathname);\n\n const matches = inventory\n .map((route) => matchRoute(route, requestSegments))\n .filter((match): match is Match => match !== undefined)\n .sort(compareSpecificity);\n\n if (matches.length === 0) return problem(404, \"Not Found\", url.pathname);\n\n const selectedPath = matches[0].route.path;\n const pathMatches = matches.filter((match) =>\n match.route.path === selectedPath\n );\n const method = request.method.toUpperCase();\n const selected = pathMatches.find((match) =>\n match.route.method === method\n );\n if (!selected) {\n const allowed = [\n ...new Set(pathMatches.map((match) => match.route.method)),\n ]\n .sort();\n return problem(405, \"Method Not Allowed\", url.pathname, {\n allow: allowed.join(\", \"),\n });\n }\n\n return await selected.route.operation.handler({\n request,\n params: selected.params,\n query: Object.freeze({}),\n headers: Object.freeze({}),\n body: undefined,\n signal: request.signal,\n principal: null,\n requestId: \"\",\n });\n },\n };\n}\n"],"mappings":";;;;;AAgDO,SAAS,YAKd,OAU2C;AAC3C,SAAO;AACT;;;ACjEA,SAAS,SAAS,kBAAkB;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,aAA6B;AACnD,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,YAAY;AAiBrB,IAAM,WAAN,cAAuB,MAAM;AAAA,EAC3B,YAAY,MAAe;AACzB,UAAM,OAAO,cAAc,IAAI,KAAK,WAAW;AAC/C,SAAK,OAAO;AAAA,EACd;AACF;AAEA,SAAS,yBAAyB,OAAgB,MAAsB;AACtE,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAC1D,MAAsC,SAAS,UAAU;AAC1D,UAAM,IAAI,SAAS,IAAI;AAAA,EACzB;AACA,QAAM;AACR;AAEA,eAAe,WAAc,WAAuB,MAA2B;AAC7E,MAAI;AACF,WAAO,MAAM;AAAA,EACf,SAAS,OAAO;AACd,WAAO,yBAAyB,OAAO,IAAI;AAAA,EAC7C;AACF;AAYO,IAAM,UAAN,MAAc;AAAA,EACV;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,UAA0B,CAAC,GAAG;AACzD,SAAK,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,MAAM,SAAyC;AAC7C,UAAM,QAAQ,WAAW,KAAK,UAAU,KAAK,SAAS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 +307,7 @@ interface CliDependencies {
307
307
  */
308
308
 
309
309
  /** Version of the CLI, reported by `hollow --version`. */
310
- declare const VERSION = "0.3.2";
310
+ declare const VERSION = "0.3.3";
311
311
  /**
312
312
  * Runs one CLI invocation against caller-supplied I/O.
313
313
  *
package/dist/cli.js CHANGED
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  resolveConfiguration
4
- } from "./chunk-BJONRVDG.js";
4
+ } from "./chunk-4PPSJ2LE.js";
5
5
  import {
6
6
  createTraceabilityReport,
7
7
  selectAffectedTests
8
- } from "./chunk-D4U3ZY4O.js";
8
+ } from "./chunk-M4D63YC7.js";
9
9
  import "./chunk-BAKXP7IR.js";
10
10
  import {
11
11
  composeProjectSecurity
12
- } from "./chunk-DGTHFZPZ.js";
12
+ } from "./chunk-LZ2HLHDW.js";
13
13
  import {
14
14
  normalizeRoutes
15
- } from "./chunk-CAPFDC25.js";
15
+ } from "./chunk-JRFHLLLF.js";
16
16
  import {
17
17
  discoverRoutes,
18
18
  platform
19
- } from "./chunk-53TZY5YP.js";
19
+ } from "./chunk-S3Z6CO7J.js";
20
20
  import "./chunk-LNJDFJGT.js";
21
21
  import "./chunk-5WRI5ZAA.js";
22
22
 
@@ -1006,7 +1006,7 @@ var CreationError = class extends Error {
1006
1006
  };
1007
1007
 
1008
1008
  // cli/create/create.ts
1009
- var VERSION = "0.3.2";
1009
+ var VERSION = "0.3.3";
1010
1010
  var NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
1011
1011
  function files(name) {
1012
1012
  return {
@@ -1090,7 +1090,33 @@ test("capture artifact is persisted", async () => { await persist(); });
1090
1090
  engines: { node: ">=24" },
1091
1091
  scripts: { check: "tsc --noEmit", test: "vitest run", verify: "npm run check && npm run test && node .sleepyhollow/verify.ts" },
1092
1092
  dependencies: { "@sleepy-hollow/framework": `^${FRAMEWORK_VERSION}` },
1093
- devDependencies: { typescript: "5.9.3", vitest: "4.1.11" }
1093
+ devDependencies: { "@types/node": "26.2.0", typescript: "5.9.3", vitest: "4.1.11" }
1094
+ },
1095
+ null,
1096
+ 2
1097
+ ) + "\n",
1098
+ "tsconfig.json": JSON.stringify(
1099
+ {
1100
+ compilerOptions: {
1101
+ target: "ES2024",
1102
+ module: "NodeNext",
1103
+ moduleResolution: "NodeNext",
1104
+ strict: true,
1105
+ noEmit: true,
1106
+ allowImportingTsExtensions: true,
1107
+ verbatimModuleSyntax: true,
1108
+ skipLibCheck: true,
1109
+ types: ["node", "vitest/globals"]
1110
+ },
1111
+ include: [
1112
+ ".sleepyhollow/**/*.ts",
1113
+ "api/**/*.ts",
1114
+ "models/**/*.ts",
1115
+ "tests/**/*.ts",
1116
+ "sleepyhollow.config.ts",
1117
+ "vitest.config.ts"
1118
+ ],
1119
+ exclude: ["generated", "node_modules"]
1094
1120
  },
1095
1121
  null,
1096
1122
  2
@@ -1102,15 +1128,20 @@ export default defineConfig({ test: { globals: true, include: ["**/*_test.ts", "
1102
1128
  "generated/.gitkeep": "",
1103
1129
  "models/.gitkeep": "",
1104
1130
  "requirements/application.req.md": `---
1105
- schema: sleepy-hollow-application/v0.1
1131
+ schema: sgad-application/v0.2
1132
+ id: ${name}-application
1106
1133
  title: ${name}
1107
1134
  status: draft
1135
+ risk: standard
1136
+ depends_on: []
1137
+ owners:
1138
+ - application owner
1108
1139
  ---
1109
1140
 
1110
1141
  # Application requirements
1111
1142
 
1112
- Use the official Sleepy Hollow skill to plan actors, behavior, data, security,
1113
- operations, and acceptance criteria before generating endpoints.
1143
+ Use the official Sleepy Hollow skill to replace this planning placeholder with
1144
+ the complete application requirements before generating endpoints.
1114
1145
  `,
1115
1146
  "sleepyhollow.config.ts": `import { defineProject } from "./.sleepyhollow/project.ts";
1116
1147
 
@@ -1142,7 +1173,7 @@ async function pathExists(path) {
1142
1173
  throw error;
1143
1174
  }
1144
1175
  }
1145
- var FRAMEWORK_VERSION = "0.3.2";
1176
+ var FRAMEWORK_VERSION = "0.3.3";
1146
1177
  async function createProject(options) {
1147
1178
  if (!NAME.test(options.name) || options.name.length > 64) {
1148
1179
  throw creationError(
@@ -2880,7 +2911,7 @@ function renderArtifacts(inventory2) {
2880
2911
  ];
2881
2912
  const manifestContent = canonicalJson({
2882
2913
  schema: "sleepy-hollow-generated-manifest/v1",
2883
- generatorVersion: "0.3.2",
2914
+ generatorVersion: "0.3.3",
2884
2915
  serviceId: normalized.serviceId,
2885
2916
  inputDigest: digest2(input),
2886
2917
  artifacts: Object.fromEntries(
@@ -3154,7 +3185,7 @@ function inventoryFromRoutes(routes2, options) {
3154
3185
  return {
3155
3186
  serviceId: options.serviceId,
3156
3187
  title: options.title ?? options.serviceId,
3157
- version: options.version ?? "0.3.2",
3188
+ version: options.version ?? "0.3.3",
3158
3189
  ...options.description ? { description: options.description } : {},
3159
3190
  operations,
3160
3191
  securitySchemes: options.securitySchemes ?? {}
@@ -4008,7 +4039,7 @@ var CLI_COMMANDS = [
4008
4039
  "generate",
4009
4040
  "deploy"
4010
4041
  ];
4011
- var CLI_VERSION = "0.3.2";
4042
+ var CLI_VERSION = "0.3.3";
4012
4043
  var commandMetadata = {
4013
4044
  create: {
4014
4045
  description: "Create one deterministic Sleepy Hollow project.",
@@ -5578,7 +5609,8 @@ function declaredStatuses(schemas) {
5578
5609
  function authenticationOf(security2) {
5579
5610
  if (typeof security2 !== "object" || security2 === null) return "none";
5580
5611
  const declared = security2.authentication;
5581
- return declared === "required" ? "required" : "none";
5612
+ if (typeof declared !== "object" || declared === null) return "none";
5613
+ return declared.mode === "required" ? "required" : "none";
5582
5614
  }
5583
5615
  async function routes(project, artifact2) {
5584
5616
  const roots = project.services.length > 0 ? project.services.map((service) => ({