@orkestrel/console 0.0.8 → 0.0.9
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/dist/src/browser/index.js.map +1 -0
- package/dist/src/core/index.cjs +2 -2
- package/dist/src/core/index.cjs.map +1 -0
- package/dist/src/core/index.d.cts +2 -2
- package/dist/src/core/index.d.ts +2 -2
- package/dist/src/core/index.js +2 -2
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/server/index.cjs +42 -11
- package/dist/src/server/index.cjs.map +1 -0
- package/dist/src/server/index.d.cts +11 -2
- package/dist/src/server/index.d.ts +11 -2
- package/dist/src/server/index.js +42 -11
- package/dist/src/server/index.js.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/browser/constants.ts","../../../src/browser/helpers.ts","../../../src/browser/factories.ts"],"sourcesContent":["import type { Color } from '@src/core'\nimport { ATTRIBUTE_CODES, ESC } from '@src/core'\n\n// The SGR → CSS translation DATA the browser sink maps ANSI runs through (the C-f branch).\n// The core `src/core/console` is the source of truth for the SGR NUMBERS (which code is which\n// color / attribute); this module owns only the BROWSER-side mapping — a named-color → hex\n// palette and the attribute CSS declarations. The live translator resolves color SGR numbers\n// through core's code maps and then reads this named palette, so no second number→CSS table drifts.\n// The SGR-scan pattern is built from core's `ESC` so no control-character literal appears in\n// source. UPPER_SNAKE, deeply `Object.freeze`d, every member exported (AGENTS §5).\n\n/**\n * Each named {@link Color}'s hex value — the 16 standard terminal colors a browser DevTools\n * console renders the SAME {@link Color} names as. The source of truth for the BROWSER color\n * axis: the ANSI renderer maps a `Color` name to an SGR number, and this maps the same name to\n * the CSS color the `%c` sink paints with, so a browser shows the same 16 colors a terminal does.\n *\n * @remarks\n * The conventional VGA/xterm 16-color palette (the base 8 plus their bright variants); `default`\n * is intentionally absent (it leaves the console's own ink and emits no CSS). Deeply frozen.\n */\nexport const COLOR_HEX: Readonly<Record<Exclude<Color, 'default'>, string>> = Object.freeze({\n\tblack: '#000000',\n\tred: '#cd0000',\n\tgreen: '#00cd00',\n\tyellow: '#cdcd00',\n\tblue: '#0000ee',\n\tmagenta: '#cd00cd',\n\tcyan: '#00cdcd',\n\twhite: '#e5e5e5',\n\tbrightBlack: '#7f7f7f',\n\tbrightRed: '#ff0000',\n\tbrightGreen: '#00ff00',\n\tbrightYellow: '#ffff00',\n\tbrightBlue: '#5c5cff',\n\tbrightMagenta: '#ff00ff',\n\tbrightCyan: '#00ffff',\n\tbrightWhite: '#ffffff',\n})\n\n/**\n * Each text-{@link Attribute}'s SGR \"on\" number → its equivalent CSS declaration — the browser\n * counterpart to the terminal's SGR text effects (`bold` 1 → `font-weight:bold`, `dim` 2 →\n * `opacity:0.6`, `italic` 3 → `font-style:italic`, `underline` 4 → `text-decoration:underline`,\n * `inverse` 7 → best-effort, `strikethrough` 9 → `text-decoration:line-through`). Keyed by the SGR\n * NUMBER (derived from core's {@link ATTRIBUTE_CODES}) so the sink looks a parameter up directly\n * while scanning a run.\n *\n * @remarks\n * `inverse` (SGR 7) has no faithful single-declaration CSS equivalent (it swaps the fore/back inks,\n * which depends on the live colors); it maps to a best-effort `filter:invert(100%)` — documented as\n * approximate, never silently dropped. Deeply frozen.\n */\nexport const ATTRIBUTE_CSS: Readonly<Record<number, string>> = Object.freeze({\n\t[ATTRIBUTE_CODES.bold]: 'font-weight:bold',\n\t[ATTRIBUTE_CODES.dim]: 'opacity:0.6',\n\t[ATTRIBUTE_CODES.italic]: 'font-style:italic',\n\t[ATTRIBUTE_CODES.underline]: 'text-decoration:underline',\n\t[ATTRIBUTE_CODES.inverse]: 'filter:invert(100%)',\n\t[ATTRIBUTE_CODES.strikethrough]: 'text-decoration:line-through',\n})\n\n/**\n * The browser console directive that switches the active style — one `%c` prefixes every styled run\n * in the {@link import('./types.js').ConsoleOutput} format string, consuming the next entry of the\n * parallel CSS array. The single source of truth for the directive token.\n */\nexport const DIRECTIVE = '%c'\n\n/**\n * Matches one SGR sequence (`ESC[ <params> m`) and CAPTURES its `;`-separated numeric parameters —\n * the subset of ANSI {@link import('@src/core').strip} cares about that carries STYLE (color /\n * attribute / reset), as opposed to cursor / erase / OSC sequences. Global, so the scanner walks\n * every SGR run in a string; built from core's {@link ESC} so no control-character literal appears\n * in source (the codebase idiom). The capture group is the parameter list (`''` for a bare `ESC[m`,\n * which the spec treats as a reset).\n *\n * @remarks\n * A global `RegExp` carries a mutable `lastIndex`; a scan builds a FRESH `RegExp` from this one's\n * `source` + `flags` rather than reuse this instance, so concurrent scans never collide. This is the\n * canonical definition, not a shared scanner.\n */\nexport const SGR_PATTERN = new RegExp(`${ESC}\\\\[([0-9;]*)m`, 'g')\n","import type { BrowserPalette, ConsoleOutput, StyleAccumulator } from './types.js'\nimport {\n\tATTRIBUTE_CODES,\n\tATTRIBUTES,\n\tBACKGROUND_CODES,\n\tCOLORS,\n\tFOREGROUND_CODES,\n\tRESET_CODE,\n} from '@src/core'\nimport { ATTRIBUTE_CSS, COLOR_HEX, DIRECTIVE, SGR_PATTERN } from './constants.js'\n\n// The pure, browser-only translation behind the `%c` console sink (the C-f branch). The core\n// styler / Logger / Reporter emit ANSI-styled STRINGS; a DevTools console can't render ANSI but\n// can style via `console.log('%ctext', 'css')`, so `ansiToConsole` parses the SGR runs in the\n// incoming text and re-emits them as a `%c`-ready format string + parallel CSS array — the\n// translation happens at the OUTPUT boundary, leaving the core unchanged. Pure + total + `%`-safe.\n// `ansiToConsole` carries immutable style snapshots while its local arrays assemble the final\n// `%c` output; only the standalone, reusable `escapePercent` / `parseParameters` utilities are\n// exported alongside it.\n\n/**\n * Translate an ANSI-styled string into a browser `console.log`-ready {@link ConsoleOutput} — a\n * `%c`-segmented format string and the parallel array of CSS declarations, so a DevTools console\n * renders the SAME styling a terminal would (the C-f sink calls `console[method](format, ...styles)`).\n *\n * @remarks\n * - **SGR runs → `%c` segments.** The text is scanned for SGR sequences ({@link SGR_PATTERN} —\n * `ESC[…m`); each delimits a run. A run carrying VISIBLE text emits one `%c` directive plus that\n * text into `format` and the run's accumulated CSS into `styles`, so the browser switches style at\n * each `%c`. Foreground / background / attribute codes accumulate; the reset code (`0`, or a bare\n * `ESC[m`) clears the accumulated style back to none. A later color of the same channel REPLACES\n * the earlier one; an attribute is added once. Non-SGR escapes (cursor / erase / OSC) are not style\n * and are left in the text verbatim.\n * - **`%`-safe.** Every LITERAL `%` in the text is doubled to `%%` so the console never treats it as\n * a directive — only the `%c`s this function inserts are real directives. So `format`'s real `%c`\n * count always equals `styles.length`, and `console.log(format, ...styles)` lines up exactly.\n * - **Plain text short-circuits.** A string with NO SGR sequence yields `{ format: <escaped text>,\n * styles: [] }` — no `%c`, no styles (the text is still `%`-escaped).\n * - **Partial palette.** A supplied palette overrides only its named colors and attributes. Every\n * omitted entry resolves through {@link COLOR_HEX} or {@link ATTRIBUTE_CSS}, so defaults and\n * unrelated entries stay byte-identical.\n * - **Pure + total.** Same input → same output; it never throws on any string (adversarial escapes,\n * lone `ESC`, unterminated sequences all fall through as literal text).\n *\n * @param text - Any string, ANSI-styled or plain\n * @param palette - Optional partial browser CSS overrides\n * @returns The `%c` format string + parallel CSS array ({@link ConsoleOutput})\n *\n * @example\n * ```ts\n * ansiToConsole('\\x1b[31mred\\x1b[0m') // { format: '%cred', styles: ['color:#cd0000'] }\n * ansiToConsole('plain') // { format: 'plain', styles: [] }\n * ansiToConsole('50%') // { format: '50%%', styles: [] }\n * ```\n */\nexport function ansiToConsole(text: string, palette?: BrowserPalette): ConsoleOutput {\n\tconst scanner = new RegExp(SGR_PATTERN.source, SGR_PATTERN.flags)\n\t// The accumulated active style across a run — a separate foreground / background declaration\n\t// (each channel REPLACEABLE) plus an ordered, de-duplicated list of attribute declarations. An\n\t// SGR reset empties all three. Serialized to a `;`-joined CSS string per emitted run.\n\tlet active: StyleAccumulator = Object.freeze({\n\t\tforeground: '',\n\t\tbackground: '',\n\t\tattributes: Object.freeze([]),\n\t})\n\tconst segments: string[] = []\n\tconst styles: string[] = []\n\tlet cursor = 0\n\tlet pending = ''\n\tlet match: RegExpExecArray | null = scanner.exec(text)\n\tif (match === null) return { format: escapePercent(text), styles: [] }\n\n\t// A null match is the final text boundary, so every visible run passes through one flush path.\n\twhile (true) {\n\t\tconst boundary = match === null ? text.length : match.index\n\t\tpending += escapePercent(text.slice(cursor, boundary))\n\t\tif (pending !== '') {\n\t\t\tsegments.push(`${DIRECTIVE}${pending}`)\n\t\t\tconst declarations = [...active.attributes]\n\t\t\tif (active.foreground !== '') declarations.push(active.foreground)\n\t\t\tif (active.background !== '') declarations.push(active.background)\n\t\t\tstyles.push(declarations.join(';'))\n\t\t\tpending = ''\n\t\t}\n\t\tif (match === null) break\n\n\t\t// Apply one SGR sequence by replacing the readonly accumulator. A reset clears every channel;\n\t\t// colors replace their channel; attributes accumulate once; unknown extensions are ignored.\n\t\tfor (const code of parseParameters(match[1] ?? '')) {\n\t\t\tif (code === RESET_CODE) {\n\t\t\t\tactive = Object.freeze({\n\t\t\t\t\tforeground: '',\n\t\t\t\t\tbackground: '',\n\t\t\t\t\tattributes: Object.freeze([]),\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst foreground = COLORS.find((color) => FOREGROUND_CODES[color] === code)\n\t\t\tif (foreground !== undefined) {\n\t\t\t\tconst color = palette?.color?.[foreground] ?? COLOR_HEX[foreground]\n\t\t\t\tactive = Object.freeze({ ...active, foreground: `color:${color}` })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst background = COLORS.find((color) => BACKGROUND_CODES[color] === code)\n\t\t\tif (background !== undefined) {\n\t\t\t\tconst color = palette?.color?.[background] ?? COLOR_HEX[background]\n\t\t\t\tactive = Object.freeze({ ...active, background: `background:${color}` })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst name = ATTRIBUTES.find((attribute) => ATTRIBUTE_CODES[attribute] === code)\n\t\t\tconst attribute =\n\t\t\t\tname === undefined ? undefined : (palette?.attribute?.[name] ?? ATTRIBUTE_CSS[code])\n\t\t\tif (attribute !== undefined && !active.attributes.includes(attribute)) {\n\t\t\t\tactive = Object.freeze({\n\t\t\t\t\t...active,\n\t\t\t\t\tattributes: Object.freeze([...active.attributes, attribute]),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tcursor = match.index + match[0].length\n\t\tmatch = scanner.exec(text)\n\t}\n\treturn { format: segments.join(''), styles }\n}\n\n/**\n * Double every literal `%` in `text` to `%%` — the `%`-escape that keeps a browser console from\n * reading a stray `%` (e.g. in `50%` or `%s`) as a format directive. The single escape the\n * {@link ansiToConsole} translation applies to every text segment before assembling the format\n * string (so only the `%c`s it inserts are real directives).\n *\n * @param text - A literal text segment (no inserted directives)\n * @returns `text` with each `%` doubled\n *\n * @example\n * ```ts\n * escapePercent('100% done') // '100%% done'\n * ```\n */\nexport function escapePercent(text: string): string {\n\treturn text.replace(/%/g, '%%')\n}\n\n/**\n * Parse an SGR parameter list (the `;`-separated numeric string captured by {@link SGR_PATTERN})\n * into its numeric codes — `'1;31'` → `[1, 31]`. An EMPTY list (a bare `ESC[m`) yields `[0]`, since\n * the SGR spec treats a parameterless sequence as a reset; an empty field within a list (`'1;;4'`)\n * likewise counts as a `0` reset, matching the spec.\n *\n * @param parameters - The raw `;`-separated parameter string (the regex capture)\n * @returns The parsed SGR codes (a parameterless / empty field becoming `0`)\n *\n * @example\n * ```ts\n * parseParameters('1;31') // [1, 31]\n * parseParameters('') // [0]\n * ```\n */\nexport function parseParameters(parameters: string): readonly number[] {\n\tif (parameters === '') return [RESET_CODE]\n\treturn parameters.split(';').map((field) => (field === '' ? RESET_CODE : Number(field)))\n}\n","import type { LogLevel, SinkInterface } from '@src/core'\nimport type { BrowserSinkOptions } from './types.js'\nimport { ansiToConsole } from './helpers.js'\n\n// The browser `%c` console sink (the C-f branch) — the platform-bound backend that satisfies core's\n// `SinkInterface` in a browser DevTools console. The core styler / Logger / Reporter emit ANSI-styled\n// STRINGS; a DevTools console can't render ANSI but CAN style via `console.log('%ctext', 'css')`, so\n// this sink translates the incoming ANSI runs into a `%c` call at the OUTPUT boundary (the env-split\n// rule: core owns the contract + universal logic, the browser provides the platform backend). A thin\n// stateless adapter, so a frozen-object factory — like core's `createConsoleSink` — not a class\n// (AGENTS §5). `SinkInterface` / `LogLevel` are IMPORTED from `@src/core`, never redeclared.\n\n/**\n * Create the browser `%c` {@link SinkInterface} — the C-f browser output backend. `write(text, level?)`\n * translates the ANSI-styled `text` into a browser `console` call (`console[method](format, ...styles)`)\n * via {@link ansiToConsole}, so a DevTools console renders the SAME styling a terminal does. Drop it in\n * as a logger / reporter / spinner sink (`createLogger({ sink: createBrowserSink() })`) to retarget the\n * core output to the browser console with no change to the core.\n *\n * @param options - See {@link BrowserSinkOptions}\n * @returns A browser `%c` {@link SinkInterface}\n *\n * @remarks\n * - **ANSI → `%c` at the sink.** The core produces ANSI strings; this sink parses the SGR runs and\n * re-emits them as a `console.log`-ready `%c` format string + parallel CSS array ({@link ansiToConsole}\n * — pure, total, and `%`-safe), so the styling survives the trip to a console that can't render ANSI.\n * `options.palette` supplies partial named color and attribute overrides to that translation.\n * - **Routes by level.** `error` → `console.error`, `warn` → `console.warn`, every other level (and an\n * omitted level) → `console.log` — the SAME routing as core's `createConsoleSink`, so a logger's level\n * reaches the matching DevTools stream.\n * - **Animation degrade (locked).** A browser console cannot overwrite a line, so a `text` beginning with\n * a carriage return `\\r` (a spinner / progress redraw) has the leading `\\r` STRIPPED and is written as a\n * fresh, non-overwriting line — the locked browser degrade. Only a LEADING `\\r` is stripped; an interior\n * one is left to the console.\n * - **Snapshotted — no capture loop.** It captures `console.log` / `console.warn` / `console.error` AT\n * CREATION and writes through those references, so a later `Capture` that PATCHES `console.*` can never\n * feed this sink's output back into itself (the no-capture-loop principle, AGENTS / the core sink's\n * precedent). Create the sink (or the logger) BEFORE installing a capture.\n *\n * @example\n * ```ts\n * import { createLogger } from '@src/core'\n * import { createBrowserSink } from '@src/browser'\n *\n * const logger = createLogger({ name: 'app', sink: createBrowserSink() })\n * logger.error('boom') // → console.error('%c…', 'color:#cd0000;…') in DevTools\n * ```\n */\nexport function createBrowserSink(options?: BrowserSinkOptions): SinkInterface {\n\t// Snapshot the three console writers NOW — bound to their `console` receiver — so a later patch of\n\t// `console.*` (by Capture) can never reach this sink's output (no capture loop), exactly as core's\n\t// `createConsoleSink` does.\n\tconst log = console.log.bind(console)\n\tconst warn = console.warn.bind(console)\n\tconst error = console.error.bind(console)\n\treturn {\n\t\twrite(text: string, level?: LogLevel): void {\n\t\t\t// Degrade the animation redraw first: a leading `\\r` can't overwrite a line in a browser\n\t\t\t// console, so drop it and write a fresh, non-overwriting line (the locked decision).\n\t\t\tconst line = text.startsWith('\\r') ? text.slice(1) : text\n\t\t\tconst { format, styles } = ansiToConsole(line, options?.palette)\n\t\t\tif (level === 'error') {\n\t\t\t\terror(format, ...styles)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (level === 'warn') {\n\t\t\t\twarn(format, ...styles)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlog(format, ...styles)\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,IAAa,YAAiE,OAAO,OAAO;CAC3F,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,aAAa;CACb,WAAW;CACX,aAAa;CACb,cAAc;CACd,YAAY;CACZ,eAAe;CACf,YAAY;CACZ,aAAa;AACd,CAAC;;;;;;;;;;;;;;AAeD,IAAa,gBAAkD,OAAO,OAAO;EAC3E,gBAAgB,OAAO;EACvB,gBAAgB,MAAM;EACtB,gBAAgB,SAAS;EACzB,gBAAgB,YAAY;EAC5B,gBAAgB,UAAU;EAC1B,gBAAgB,gBAAgB;AAClC,CAAC;;;;;;AAOD,IAAa,YAAY;;;;;;;;;;;;;;AAezB,IAAa,cAAc,IAAI,OAAO,GAAG,IAAI,gBAAgB,GAAG;;;;;;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AAK,WAAW,IAAI,IAAI,KAAK,MAAM,CAAC,IAAI,MACN,SAAS,OAAO;EAC/D,IAAI,UAAU,SAAS;GACtB,MAAM,QAAQ,GAAG,MAAM;GACvB;EACD;EACA,IAAI,UAAU,QAAQ;GACrB,KAAK,QAAQ,GAAG,MAAM;GACtB;EACD;EACA,IAAI,QAAQ,GAAG,MAAM;CACtB,EACD;AACD"}
|
package/dist/src/core/index.cjs
CHANGED
|
@@ -1626,8 +1626,8 @@ var Reporter = class {
|
|
|
1626
1626
|
* - **Self-driving but deterministically testable.** `start()` arms a `setInterval` that calls
|
|
1627
1627
|
* {@link tick} each `interval`; each {@link tick} builds the styled `glyph + message` line for the
|
|
1628
1628
|
* current frame, emits it on `frame`, writes `'\r' + line` to the sink, then advances the frame
|
|
1629
|
-
* index (wrapping). A test drives frames by calling {@link tick} directly
|
|
1630
|
-
* the timer arms / clears
|
|
1629
|
+
* index (wrapping). A test drives frames by calling {@link tick} directly, or arms a real short
|
|
1630
|
+
* `interval` and proves the timer arms / clears through the sink it writes to.
|
|
1631
1631
|
* - **Leak-free timer.** The interval is ALWAYS cleared on {@link success} / {@link failure} /
|
|
1632
1632
|
* {@link stop} / {@link destroy} — `#handle` is the single source of `active`, set on arm and unset
|
|
1633
1633
|
* on clear, so a spinner never leaks a running interval.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["#emitter","#levels","#mirror","#sink","#limit","#messages","#buckets","#originals","#active","#captureCall","#intercept","#capture","#retain","#push","#codes","#loggers","#level","#sink","#styler","#theme","#format","#limit","#silent","#emitter","#total","#width","#fill","#empty","#sink","#styler","#theme","#message","#active","#completed","#current","#advance","#paint","#sink","#styler","#theme","#width","#resolveStyle","#emitter","#frames","#interval","#sink","#styler","#theme","#message","#handle","#paint","#line","#index","#finish","#renderer","#enabled","#style","#render","#foregroundSurface","#attributeSurface","#isSurface","#merge","#foreground","#attribute","#emitter","#level","#sink","#styler","#theme","#format","#limit","#silent","#entries","#log","#record","#retain"],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/Capture.ts","../../../src/core/helpers.ts","../../../src/core/ANSIRenderer.ts","../../../src/core/LoggerManager.ts","../../../src/core/Progress.ts","../../../src/core/Reporter.ts","../../../src/core/Spinner.ts","../../../src/core/Styler.ts","../../../src/core/factories.ts","../../../src/core/Logger.ts"],"sourcesContent":["import type {\n\tAlignment,\n\tAttribute,\n\tBorderChars,\n\tBorderStyle,\n\tCaptureLevel,\n\tColor,\n\tLogLevel,\n\tStyle,\n\tStatusLevel,\n\tTheme,\n} from './types.js'\n\n// The SGR (Select Graphic Rendition) code data the ANSI renderer maps style DATA\n// through, plus the reset terminator and the ANSI-strip pattern. UPPER_SNAKE,\n// `Object.freeze`d, every member exported (AGENTS §5). These are the standard SGR\n// numbers (ECMA-48) — a fixed external spec, so the literals ARE the source of truth.\n// `default` carries no code (it leaves the target's own ink) and so is absent from the\n// color maps — the renderer emits a code only for a present, non-`default` color.\n\n/**\n * Each {@link Color}'s SGR FOREGROUND parameter — the 8 base colors at 30–37 and their\n * bright variants at 90–97. `default` is intentionally absent (it emits no code).\n */\nexport const FOREGROUND_CODES: Readonly<Record<Exclude<Color, 'default'>, number>> = Object.freeze({\n\tblack: 30,\n\tred: 31,\n\tgreen: 32,\n\tyellow: 33,\n\tblue: 34,\n\tmagenta: 35,\n\tcyan: 36,\n\twhite: 37,\n\tbrightBlack: 90,\n\tbrightRed: 91,\n\tbrightGreen: 92,\n\tbrightYellow: 93,\n\tbrightBlue: 94,\n\tbrightMagenta: 95,\n\tbrightCyan: 96,\n\tbrightWhite: 97,\n})\n\n/**\n * Each {@link Color}'s SGR BACKGROUND parameter — the 8 base colors at 40–47 and their\n * bright variants at 100–107. `default` is intentionally absent (it emits no code).\n */\nexport const BACKGROUND_CODES: Readonly<Record<Exclude<Color, 'default'>, number>> = Object.freeze({\n\tblack: 40,\n\tred: 41,\n\tgreen: 42,\n\tyellow: 43,\n\tblue: 44,\n\tmagenta: 45,\n\tcyan: 46,\n\twhite: 47,\n\tbrightBlack: 100,\n\tbrightRed: 101,\n\tbrightGreen: 102,\n\tbrightYellow: 103,\n\tbrightBlue: 104,\n\tbrightMagenta: 105,\n\tbrightCyan: 106,\n\tbrightWhite: 107,\n})\n\n/**\n * Each {@link Attribute}'s SGR \"on\" parameter — `bold` 1, `dim` 2, `italic` 3,\n * `underline` 4, `inverse` 7, `strikethrough` 9. The renderer composes several by\n * joining their codes with `;` in one SGR sequence.\n */\nexport const ATTRIBUTE_CODES: Readonly<Record<Attribute, number>> = Object.freeze({\n\tbold: 1,\n\tdim: 2,\n\titalic: 3,\n\tunderline: 4,\n\tinverse: 7,\n\tstrikethrough: 9,\n})\n\n/**\n * The EMPTY {@link Style} — no foreground, no background, no attributes — frozen. The\n * neutral starting point a base styler builds from, and what a renderer passes through\n * unchanged (it carries no codes). Deeply frozen, so it is safe to share as the base.\n */\nexport const EMPTY_STYLE: Style = Object.freeze({ attributes: Object.freeze([]) })\n\n/**\n * Every named {@link Color} except `default`, frozen — the colors the styler exposes as\n * chainable accessors. The source of truth for the color axis; the styler drives its\n * accessors from this array so the literals live in one place.\n */\nexport const COLORS: ReadonlyArray<Exclude<Color, 'default'>> = Object.freeze([\n\t'black',\n\t'red',\n\t'green',\n\t'yellow',\n\t'blue',\n\t'magenta',\n\t'cyan',\n\t'white',\n\t'brightBlack',\n\t'brightRed',\n\t'brightGreen',\n\t'brightYellow',\n\t'brightBlue',\n\t'brightMagenta',\n\t'brightCyan',\n\t'brightWhite',\n])\n\n/**\n * Every {@link Attribute}, frozen — the attributes the styler exposes as chainable\n * accessors. The source of truth for the attribute axis.\n */\nexport const ATTRIBUTES: readonly Attribute[] = Object.freeze([\n\t'bold',\n\t'dim',\n\t'italic',\n\t'underline',\n\t'inverse',\n\t'strikethrough',\n])\n\n/** The SGR RESET parameter (0) — terminates a styled run, clearing all colors and attributes. */\nexport const RESET_CODE = 0\n\n/**\n * The ESC control character (`U+001B`) that begins every ANSI escape sequence. Built\n * with `String.fromCharCode` so no raw control character appears in source.\n */\nexport const ESC = String.fromCharCode(27)\n\n/** The BEL control character (`U+0007`) that can terminate an OSC sequence. */\nexport const BEL = String.fromCharCode(7)\n\n/** The Control Sequence Introducer (`ESC[`) that opens every SGR sequence. */\nexport const CSI = `${ESC}[`\n\n/** The full SGR reset sequence (`ESC[0m`) appended after a styled run. */\nexport const RESET = `${CSI}${RESET_CODE}m`\n\n/**\n * Matches any ANSI/VT escape sequence — CSI (SGR color/style plus cursor/erase/scroll,\n * including colon-parameterized SGR), OSC / DCS / PM / APC / SOS string sequences\n * (titles, hyperlinks, device strings), the `nF` charset-select family, and the\n * two-byte `Fp` / `Fe` / `Fs` sequences (e.g. `ESC 7`, `ESC D`, `ESC c` RIS). Global, so\n * `strip` removes every occurrence.\n *\n * @remarks\n * A global `RegExp` carries a mutable `lastIndex`; a scan must build a FRESH `RegExp`\n * from this one's `source` + `flags` rather than reuse this instance's `lastIndex`. This\n * is the canonical definition, not a shared scanner. The alternation is ORDERED so the\n * CSI / string-family arms (which can start with a byte a later single-byte arm would\n * also match) win first; every arm uses disjoint, non-nested character classes, so the\n * match is linear in input length — no catastrophic backtracking (ReDoS-safe) even on an\n * adversarial run of digits inside an unterminated CSI. Built from `String.fromCharCode`\n * so no control-character literal appears in a regex source (the codebase idiom).\n */\nexport const ANSI_PATTERN = new RegExp(\n\t`${ESC}(?:` +\n\t\t`\\\\[[0-?]*[ -/]*[@-~]` +\n\t\t`|\\\\][^${BEL}${ESC}]*(?:${BEL}|${ESC}\\\\\\\\)` +\n\t\t`|[P^_X][^${BEL}${ESC}]*(?:${BEL}|${ESC}\\\\\\\\)` +\n\t\t`|[ -/]+[0-~]` +\n\t\t`|[0-?]` +\n\t\t`|[@-OQ-WYZ\\\\\\\\]` +\n\t\t`|[\\`-~]` +\n\t\t`)`,\n\t'g',\n)\n\n/**\n * Matches every C0 control character EXCEPT `\\t` / `\\n` / `\\r` (which are meaningful\n * whitespace), plus DEL (`0x7F`) — the non-printing bytes {@link\n * import('./helpers.js').stripControls} removes. Global, ASCII-only source (no raw\n * control-character literal), so a scan builds a fresh `RegExp` the same way as\n * {@link ANSI_PATTERN} to avoid a mutated `lastIndex`.\n *\n * @remarks\n * Deliberately SEPARATE from {@link ANSI_PATTERN}: `strip()` must stay pure ANSI-escape\n * removal (width / alignment computations depend on it leaving raw C0 bytes alone), while\n * C0-stripping is an ADDITIONAL, orthogonal pass a non-TTY output sink applies on top.\n */\nexport const CONTROL_PATTERN = new RegExp(\n\t`[${String.fromCharCode(0)}-${String.fromCharCode(8)}${String.fromCharCode(11)}${String.fromCharCode(12)}${String.fromCharCode(14)}-${String.fromCharCode(31)}${String.fromCharCode(127)}]`,\n\t'g',\n)\n\n// Structured-logging constants — the severity order the level gate compares through, the\n// default colors a level renders in (styling is ORTHOGONAL to level — a level → color map,\n// not a level), and the default bounded-retention cap. UPPER_SNAKE, `Object.freeze`d, every\n// member exported (AGENTS §5).\n\n/**\n * Each {@link LogLevel}'s numeric SEVERITY — the ascending order the level gate compares\n * through (`debug` 0 < `info` 1 < `warn` 2 < `error` 3). A record is kept when its level's\n * severity is at or above the logger's threshold. The source of truth for level ordering.\n */\nexport const LEVEL_SEVERITY: Readonly<Record<LogLevel, number>> = Object.freeze({\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n})\n\n/**\n * Each {@link LogLevel}'s default label {@link Color} — the level's VISUAL treatment, which\n * is a styling choice ORTHOGONAL to the level itself (never a separate pseudo-level). The\n * logger colors the level label through its styler with these; swapping a color never\n * changes leveling. `debug` is cyan, `info` blue, `warn` yellow, `error` red.\n *\n * @remarks\n * Excludes `default` so each value indexes a real styler accessor (the styler exposes a\n * getter per non-`default` {@link Color}) — a level always renders in a concrete color.\n */\nexport const LEVEL_COLORS: Readonly<Record<LogLevel, Exclude<Color, 'default'>>> = Object.freeze({\n\tdebug: 'cyan',\n\tinfo: 'blue',\n\twarn: 'yellow',\n\terror: 'red',\n})\n\n/**\n * The default bounded-retention cap for a {@link import('./types.js').LoggerInterface} — at\n * most this many recent records are kept (oldest dropped first). Retention is ALWAYS bounded\n * (never the unbounded buffer scsr leaked); a consumer overrides it via `options.limit`.\n */\nexport const DEFAULT_LOG_LIMIT = 1000\n\n/** The default {@link LogLevel} threshold a logger gates at when none is supplied — `info`. */\nexport const DEFAULT_LOG_LEVEL: LogLevel = 'info'\n\n/**\n * Every {@link LogLevel}, in ascending severity order — the levels a logger exposes as\n * methods and the manager fans out to. The source of truth for the level axis (drives\n * exhaustive tests); aligned with {@link LEVEL_SEVERITY}.\n */\nexport const LEVELS: readonly LogLevel[] = Object.freeze(['debug', 'info', 'warn', 'error'])\n\n// Narrative-rendering constants — the box-drawing junction sets the renderers frame with, the\n// status icons + colors a `Reporter.status` outcome shows, the tree connectors, and the default\n// widths / paddings / glyphs. UPPER_SNAKE, deeply `Object.freeze`d DATA, every member exported\n// (AGENTS §5). The box-drawing glyphs are the standard Unicode set (U+2500 block) — a fixed\n// external spec, so the literals ARE the source of truth.\n\n/**\n * The complete {@link BorderChars} junction set for each {@link BorderStyle} — the standard\n * Unicode box-drawing glyphs at the four line weights. The renderers ({@link\n * import('./helpers.js').renderBox} / {@link import('./helpers.js').renderTable}) look the\n * style up here, so no glyph literal lives in a renderer. Deeply frozen.\n *\n * @remarks\n * `round` shares `single`'s edges and tees — only its corners differ (the rounded `╭╮╰╯`).\n */\nexport const BORDER_CHARS: Readonly<Record<BorderStyle, BorderChars>> = Object.freeze({\n\tsingle: Object.freeze({\n\t\thorizontal: '─',\n\t\tvertical: '│',\n\t\ttopLeft: '┌',\n\t\ttopRight: '┐',\n\t\tbottomLeft: '└',\n\t\tbottomRight: '┘',\n\t\tcross: '┼',\n\t\tteeDown: '┬',\n\t\tteeUp: '┴',\n\t\tteeRight: '├',\n\t\tteeLeft: '┤',\n\t}),\n\tdouble: Object.freeze({\n\t\thorizontal: '═',\n\t\tvertical: '║',\n\t\ttopLeft: '╔',\n\t\ttopRight: '╗',\n\t\tbottomLeft: '╚',\n\t\tbottomRight: '╝',\n\t\tcross: '╬',\n\t\tteeDown: '╦',\n\t\tteeUp: '╩',\n\t\tteeRight: '╠',\n\t\tteeLeft: '╣',\n\t}),\n\tround: Object.freeze({\n\t\thorizontal: '─',\n\t\tvertical: '│',\n\t\ttopLeft: '╭',\n\t\ttopRight: '╮',\n\t\tbottomLeft: '╰',\n\t\tbottomRight: '╯',\n\t\tcross: '┼',\n\t\tteeDown: '┬',\n\t\tteeUp: '┴',\n\t\tteeRight: '├',\n\t\tteeLeft: '┤',\n\t}),\n\theavy: Object.freeze({\n\t\thorizontal: '━',\n\t\tvertical: '┃',\n\t\ttopLeft: '┏',\n\t\ttopRight: '┓',\n\t\tbottomLeft: '┗',\n\t\tbottomRight: '┛',\n\t\tcross: '╋',\n\t\tteeDown: '┳',\n\t\tteeUp: '┻',\n\t\tteeRight: '┣',\n\t\tteeLeft: '┫',\n\t}),\n})\n\n/**\n * Each {@link StatusLevel}'s icon glyph — the leading mark a {@link\n * import('./types.js').ReporterInterface.status} outcome line shows: `success` ✔, `error` ✖,\n * `warn` ⚠, `info` ℹ. The narrative-outcome counterpart to a log level's label; frozen.\n */\nexport const STATUS_ICONS: Readonly<Record<StatusLevel, string>> = Object.freeze({\n\tsuccess: '✔',\n\terror: '✖',\n\twarn: '⚠',\n\tinfo: 'ℹ',\n})\n\n/**\n * Each {@link StatusLevel}'s {@link Color} — the icon + message color a `status` line renders\n * in (`success` green, `error` red, `warn` yellow, `info` blue). The VISUAL treatment of a\n * narrative outcome, colored through the reporter's styler; orthogonal to leveling, like\n * {@link LEVEL_COLORS}. Excludes `default` so each value indexes a real styler accessor.\n */\nexport const STATUS_COLORS: Readonly<Record<StatusLevel, Exclude<Color, 'default'>>> =\n\tObject.freeze({\n\t\tsuccess: 'green',\n\t\terror: 'red',\n\t\twarn: 'yellow',\n\t\tinfo: 'blue',\n\t})\n\n/**\n * Every {@link StatusLevel}, frozen — the outcomes a `status` line supports (drives exhaustive\n * tests). The source of truth for the status axis; aligned with {@link STATUS_ICONS} /\n * {@link STATUS_COLORS}.\n */\nexport const STATUS_LEVELS: readonly StatusLevel[] = Object.freeze([\n\t'success',\n\t'error',\n\t'warn',\n\t'info',\n])\n\n/**\n * The default visible column width for the width-aware renderers — the separator rule and a\n * {@link import('./helpers.js').renderBox} with no explicit `width`, and the reporter's\n * `section` rule. A sane terminal default (80 columns); a caller overrides it per-call or via\n * {@link import('./types.js').ReporterOptions}`.width`.\n */\nexport const DEFAULT_WIDTH = 80\n\n/** The default horizontal padding inside a box's edges ({@link import('./helpers.js').renderBox}) — one cell. */\nexport const DEFAULT_PADDING = 1\n\n/** The default {@link BorderStyle} the box / table renderers frame with when none is given — `single`. */\nexport const DEFAULT_BORDER: BorderStyle = 'single'\n\n/** The default cell {@link Alignment} a {@link import('./types.js').ColumnSpec} uses when none is given — `left`. */\nexport const DEFAULT_ALIGN: Alignment = 'left'\n\n/** The default fill character {@link import('./helpers.js').renderSeparator} draws its rule with — `─`. */\nexport const SEPARATOR_FILL = '─'\n\n/**\n * The single padding cell on each side of a separator's embedded title (` title `) — keeps the\n * title from butting against the rule. One space.\n */\nexport const SEPARATOR_TITLE_GAP = ' '\n\n/**\n * The number of milliseconds at or above which {@link import('./helpers.js').formatDuration}\n * (and so `Reporter.timing`) switches from a `…ms` rendering to a `…s` (seconds, 2 d.p.)\n * rendering — exactly one second.\n */\nexport const SECOND_MS = 1000\n\n// Console-interception constants — the default set of `console.*` methods a Capture patches, the\n// default bounded-buffer cap, and the CaptureLevel → LogLevel projection the optional sink forward\n// routes through. UPPER_SNAKE, `Object.freeze`d, every member exported (AGENTS §5). The five level\n// names ARE the universal `console.*` method names — a fixed external surface, so the literals are\n// the source of truth.\n\n/**\n * Every {@link CaptureLevel}, frozen — the `console.*` methods a {@link\n * import('./types.js').CaptureInterface} intercepts by default (and the source of truth for the\n * capture-level axis; drives exhaustive tests). The universal console methods: `log`, `info`,\n * `warn`, `error`, `debug`.\n */\nexport const CAPTURE_LEVELS: readonly CaptureLevel[] = Object.freeze([\n\t'log',\n\t'info',\n\t'warn',\n\t'error',\n\t'debug',\n])\n\n/**\n * The default set of {@link CaptureLevel}s a Capture patches when `options.levels` is omitted —\n * all five universal `console.*` methods ({@link CAPTURE_LEVELS}). A consumer narrows it (e.g. just\n * `['warn', 'error']`) via `options.levels`.\n */\nexport const DEFAULT_CAPTURE_LEVELS: readonly CaptureLevel[] = CAPTURE_LEVELS\n\n/**\n * The default bounded-buffer cap for a {@link import('./types.js').CaptureInterface} — at most this\n * many recent {@link CapturedMessage}s are retained per buffer (the total buffer AND each by-level\n * bucket; oldest dropped first). Capture retention is ALWAYS bounded so a long-running capture can\n * never grow without bound (the same retention precedent as {@link DEFAULT_LOG_LIMIT}); a consumer\n * overrides it via `options.limit`.\n */\nexport const DEFAULT_CAPTURE_LIMIT = 1000\n\n/**\n * Each {@link CaptureLevel}'s {@link LogLevel} for the optional sink forward — the projection the\n * Capture routes through when writing an intercepted call to a {@link\n * import('./types.js').SinkInterface} (`sink.write(text, CAPTURE_LEVEL_MAP[level])`). `warn` /\n * `error` / `debug` / `info` map to their matching {@link LogLevel}; `log` maps to `info` (a plain\n * console log is informational — the default stream), so a stream-aware sink routes `warn` / `error`\n * captures to the right stream. The source of truth for the capture-to-log projection.\n */\nexport const CAPTURE_LEVEL_MAP: Readonly<Record<CaptureLevel, LogLevel>> = Object.freeze({\n\tlog: 'info',\n\tinfo: 'info',\n\twarn: 'warn',\n\terror: 'error',\n\tdebug: 'debug',\n})\n\n// Live-animation constants — the spinner's glyph frame set + default timer period, and the\n// determinate bar's fill / empty glyphs + default track width. UPPER_SNAKE, `Object.freeze`d, every\n// member exported (AGENTS §5). The braille spinner frames + the block bar glyphs are the standard\n// Unicode sets (the braille-patterns block U+2800 / the block-elements `█` U+2588 / `░` U+2591) — a\n// fixed external glyph spec, so the literals ARE the source of truth. scsr shipped THREE spinners +\n// THREE bars; this is the ONE of each.\n\n/**\n * The default spinner frame cycle a {@link import('./types.js').SpinnerInterface} advances through —\n * the ten braille-pattern glyphs (U+2800 block) that read as a smoothly rotating dot, the universal\n * terminal-spinner convention. Frozen; a consumer swaps the whole cycle via `options.frames`.\n *\n * @remarks\n * Braille glyphs are single visible cells, so every frame occupies one column — the spinner glyph\n * never shifts the message beside it as it advances. The source of truth for the default frame axis.\n */\nexport const SPINNER_FRAMES: readonly string[] = Object.freeze([\n\t'⠋',\n\t'⠙',\n\t'⠹',\n\t'⠸',\n\t'⠼',\n\t'⠴',\n\t'⠦',\n\t'⠧',\n\t'⠇',\n\t'⠏',\n])\n\n/**\n * The default timer period in milliseconds between a {@link import('./types.js').SpinnerInterface}'s\n * frames — the `setInterval` interval `start()` arms. Eighty milliseconds (≈12.5 frames/second) is\n * the conventional spinner cadence: fast enough to read as motion, slow enough not to thrash a\n * terminal. A consumer overrides it via `options.interval`.\n */\nexport const DEFAULT_SPINNER_INTERVAL = 80\n\n/**\n * The default FILLED-cell glyph {@link import('./helpers.js').renderBar} draws the completed run of a\n * progress bar with — the full block `█` (U+2588). A single visible cell; a consumer overrides it via\n * {@link import('./types.js').ProgressBarOptions}`.fill`.\n */\nexport const BAR_FILL = '█'\n\n/**\n * The default EMPTY-cell glyph {@link import('./helpers.js').renderBar} draws the remaining run of a\n * progress bar with — the light-shade block `░` (U+2591). A single visible cell; a consumer overrides\n * it via {@link import('./types.js').ProgressBarOptions}`.empty`.\n */\nexport const BAR_EMPTY = '░'\n\n/**\n * The default visible cell count of a progress-bar TRACK — the glyph run {@link\n * import('./helpers.js').renderBar} fills (and a {@link import('./types.js').ProgressInterface} sizes\n * its bar to). Thirty cells is a compact, terminal-friendly default; a consumer overrides it via\n * `options.width`. Distinct from {@link DEFAULT_WIDTH} (the renderers' 80-column line width) — a bar\n * track is one inline element, not a full-width rule.\n */\nexport const DEFAULT_BAR_WIDTH = 30\n\n// The default theme — the semantic style vocabulary every entity speaks unless a consumer\n// supplies its own. ASSEMBLED from the constants above (LEVEL_COLORS / STATUS_ICONS /\n// STATUS_COLORS), never restating them: a level's color, a status's icon + color each keep\n// ONE source, and the theme is the shape that binds them to a role. UPPER_SNAKE, deeply\n// `Object.freeze`d DATA (AGENTS §5).\n\n/**\n * The default {@link Theme} — every role bound to its default {@link Style}, deeply frozen.\n * The base {@link import('./factories.js').createTheme} merges over, and the theme every\n * entity uses when none is supplied.\n *\n * @remarks\n * - `levels` — each {@link LogLevel} label in its {@link LEVEL_COLORS} color, no attributes.\n * - `statuses` — each {@link StatusLevel}'s {@link STATUS_ICONS} glyph in its\n * {@link STATUS_COLORS} color.\n * - `accent` — `cyan`: the spinner glyph, the progress fill, a step prefix.\n * - `chrome` — `dim`: separators, box / table / tree frames, and a log line's timestamp /\n * name / data surround. A color-free attribute, so chrome recedes on any background.\n */\nexport const DEFAULT_THEME: Theme = Object.freeze({\n\tlevels: Object.freeze({\n\t\tdebug: Object.freeze({ foreground: LEVEL_COLORS.debug, attributes: EMPTY_STYLE.attributes }),\n\t\tinfo: Object.freeze({ foreground: LEVEL_COLORS.info, attributes: EMPTY_STYLE.attributes }),\n\t\twarn: Object.freeze({ foreground: LEVEL_COLORS.warn, attributes: EMPTY_STYLE.attributes }),\n\t\terror: Object.freeze({ foreground: LEVEL_COLORS.error, attributes: EMPTY_STYLE.attributes }),\n\t}),\n\tstatuses: Object.freeze({\n\t\tsuccess: Object.freeze({\n\t\t\ticon: STATUS_ICONS.success,\n\t\t\tstyle: Object.freeze({\n\t\t\t\tforeground: STATUS_COLORS.success,\n\t\t\t\tattributes: EMPTY_STYLE.attributes,\n\t\t\t}),\n\t\t}),\n\t\terror: Object.freeze({\n\t\t\ticon: STATUS_ICONS.error,\n\t\t\tstyle: Object.freeze({ foreground: STATUS_COLORS.error, attributes: EMPTY_STYLE.attributes }),\n\t\t}),\n\t\twarn: Object.freeze({\n\t\t\ticon: STATUS_ICONS.warn,\n\t\t\tstyle: Object.freeze({ foreground: STATUS_COLORS.warn, attributes: EMPTY_STYLE.attributes }),\n\t\t}),\n\t\tinfo: Object.freeze({\n\t\t\ticon: STATUS_ICONS.info,\n\t\t\tstyle: Object.freeze({ foreground: STATUS_COLORS.info, attributes: EMPTY_STYLE.attributes }),\n\t\t}),\n\t}),\n\taccent: Object.freeze({ foreground: 'cyan', attributes: EMPTY_STYLE.attributes }),\n\tchrome: Object.freeze({ attributes: Object.freeze<readonly Attribute[]>(['dim']) }),\n})\n","import type { ConsoleErrorCode } from './types.js'\n\n// AGENTS §12: an internal invariant / unreachable-guard violation `throw`s, always a\n// `ConsoleError` carrying a machine-readable `code` so a `catch` branches on\n// `error.code` instead of parsing the message.\n\n/**\n * An error thrown by the console layer.\n *\n * @remarks\n * Carries a {@link ConsoleErrorCode} and an optional `context` bag. Thrown for: an\n * internal invariant violated at a defensive, structurally-unreachable guard\n * (`INVARIANT`) — the one throw site in this codebase today.\n */\nexport class ConsoleError extends Error {\n\treadonly code: ConsoleErrorCode\n\treadonly context?: Readonly<Record<string, unknown>>\n\n\tconstructor(\n\t\tcode: ConsoleErrorCode,\n\t\tmessage: string,\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'ConsoleError'\n\t\tthis.code = code\n\t\tif (context !== undefined) this.context = context\n\t}\n}\n\n/**\n * Narrow an unknown caught value to a {@link ConsoleError}.\n *\n * @param value - The value to test (typically a `catch` binding)\n * @returns `true` when `value` is a {@link ConsoleError}\n *\n * @example\n * ```ts\n * try {\n * \tcreateStyler().style\n * } catch (error) {\n * \tif (isConsoleError(error) && error.code === 'INVARIANT') report(error)\n * }\n * ```\n */\nexport function isConsoleError(value: unknown): value is ConsoleError {\n\treturn value instanceof ConsoleError\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tCaptureEventMap,\n\tCaptureInterface,\n\tCaptureLevel,\n\tCaptureOptions,\n\tCapturedMessage,\n\tSinkInterface,\n\tConsoleMethod,\n} from './types.js'\nimport { Emitter } from '@orkestrel/emitter'\nimport { CAPTURE_LEVEL_MAP, DEFAULT_CAPTURE_LEVELS, DEFAULT_CAPTURE_LIMIT } from './constants.js'\nimport { formatArgs } from './helpers.js'\n\n/**\n * An observable console interceptor (AGENTS §13) — it takes control of the global `console.*` on\n * the READ side. While `active`, every configured `console.x` call is captured as a frozen\n * {@link CapturedMessage}, buffered (total + by level, bounded), emitted on `capture`, and — per\n * options — mirrored to the real console and/or forwarded to a {@link SinkInterface}.\n *\n * @remarks\n * - **Snapshot-at-start (the no-capture-loop principle).** `start()` snapshots the CURRENT\n * `console[level]` for each configured {@link CaptureLevel}, then installs the wrappers. The\n * mirror writes through that snapshot — so our OWN console sink output (the Logger / Reporter,\n * which snapshot the real `console` at creation) is never recaptured: `Capture` catches\n * THIRD-PARTY `console.*`, not our writes. Create your loggers BEFORE installing a capture.\n * - **Idempotent + PROCESS-GLOBAL + NON-REENTRANT.** `start()` while already `active` is a no-op\n * (never double-patches); `stop()` while inactive is a no-op. It patches the ONE global\n * `console`, so at most ONE capture may be active at a time — running two concurrently\n * interleaves their buffers and clobbers each other's restore.\n * - **Bounded buffers.** `messages()` / `messages(level)` — the total buffer and each by-level\n * bucket are each capped at `limit`\n * (oldest dropped first), never unbounded — the same retention precedent as {@link Logger}.\n * - **Lifecycle (§10).** `start` / `stop` toggle interception (emitting `start` / `stop`);\n * `destroy()` stops (restoring `console`) then destroys the emitter.\n *\n * @example\n * ```ts\n * const capture = new Capture({ levels: ['warn', 'error'], mirror: true })\n * capture.start()\n * console.warn('third-party noise') // captured AND mirrored to the real console\n * capture.messages('warn') // [{ level: 'warn', text: 'third-party noise', time: … }]\n * capture.stop() // console.warn restored\n * ```\n */\nexport class Capture implements CaptureInterface {\n\t// The PUSH observation surface (§13) — owned, never inherited. The emitter isolates a listener\n\t// throw (routing it to the `error` handler), so a buggy `capture` listener can never escape into\n\t// the underlying program's `console.*` call.\n\treadonly #emitter: Emitter<CaptureEventMap>\n\treadonly #levels: readonly CaptureLevel[]\n\treadonly #mirror: boolean\n\treadonly #sink: SinkInterface | undefined\n\treadonly #limit: number\n\t// The bounded total buffer — every captured message, oldest first, capped at #limit.\n\treadonly #messages: CapturedMessage[] = []\n\t// The bounded per-level buckets — one capped buffer per configured CaptureLevel.\n\treadonly #buckets = new Map<CaptureLevel, CapturedMessage[]>()\n\t// The snapshot-original console methods, captured at start() and restored at stop(); empty\n\t// while inactive. The presence of an entry is what `active` reads.\n\treadonly #originals = new Map<CaptureLevel, ConsoleMethod>()\n\t#active = false\n\n\tconstructor(options?: CaptureOptions) {\n\t\tthis.#emitter = new Emitter<CaptureEventMap>({\n\t\t\t...(options?.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options?.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t\tthis.#levels = options?.levels ?? DEFAULT_CAPTURE_LEVELS\n\t\tthis.#mirror = options?.mirror ?? false\n\t\tthis.#sink = options?.sink\n\t\tthis.#limit = options?.limit ?? DEFAULT_CAPTURE_LIMIT\n\t\tfor (const level of this.#levels) this.#buckets.set(level, [])\n\t}\n\n\tget emitter(): EmitterInterface<CaptureEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget active(): boolean {\n\t\treturn this.#active\n\t}\n\n\tstart(): void {\n\t\t// Idempotent — never double-patch an already-active capture (that would snapshot the\n\t\t// wrappers as the \"originals\" and break restore).\n\t\tif (this.#active) return\n\t\tthis.#active = true\n\t\tconst target: Record<CaptureLevel, ConsoleMethod> = console\n\t\tfor (const level of this.#levels) {\n\t\t\t// Snapshot the CURRENT method reference BEFORE replacing it — stop() restores EXACTLY this\n\t\t\t// reference, leaving `console` pristine (the wrapper is never snapshotted as the original).\n\t\t\tconst original = target[level]\n\t\t\tthis.#originals.set(level, original)\n\t\t\t// The mirror target is the snapshot original BOUND to `console`, computed once here — so a\n\t\t\t// mirrored call reaches the real method with its proper receiver, through the snapshot and\n\t\t\t// never the live (patched) `console` (no capture loop). The restore reference stays the\n\t\t\t// pristine unbound `original` above; only the mirror uses the bound form.\n\t\t\tconst mirror = original.bind(console)\n\t\t\ttarget[level] = this.#captureCall.bind(this, level, mirror)\n\t\t}\n\t\tthis.#emitter.emit('start')\n\t}\n\n\tstop(): void {\n\t\t// Safe when not active — nothing to restore.\n\t\tif (!this.#active) return\n\t\tthis.#active = false\n\t\tconst target: Record<CaptureLevel, ConsoleMethod> = console\n\t\tfor (const [level, original] of this.#originals) target[level] = original\n\t\tthis.#originals.clear()\n\t\tthis.#emitter.emit('stop')\n\t}\n\n\tmessages(): readonly CapturedMessage[]\n\tmessages(level: CaptureLevel): readonly CapturedMessage[]\n\tmessages(level?: CaptureLevel): readonly CapturedMessage[] {\n\t\tif (level === undefined) return [...this.#messages]\n\t\treturn [...(this.#buckets.get(level) ?? [])]\n\t}\n\n\tclear(): void {\n\t\tthis.#messages.length = 0\n\t\tfor (const bucket of this.#buckets.values()) bucket.length = 0\n\t}\n\n\tdestroy(): void {\n\t\tthis.stop()\n\t\tthis.#emitter.destroy()\n\t}\n\n\t// Adapt the patched console's variadic call shape to the captured argument collection consumed\n\t// by #intercept. Binding level and mirror in start() leaves the exact ConsoleMethod signature.\n\t#captureCall(level: CaptureLevel, mirror: ConsoleMethod, ...args: unknown[]): void {\n\t\tthis.#intercept(level, args, mirror)\n\t}\n\n\t// The wrapper body behind every patched `console.x`: build the frozen message, buffer it\n\t// (total + by level, bounded), emit `capture`, then — per options — mirror to the real console\n\t// and forward to the sink. `mirror` is the snapshot original bound to `console` (computed at\n\t// start()); the program's own call is replayed through it (with its proper receiver) only when\n\t// the `mirror` option is set.\n\t#intercept(level: CaptureLevel, args: unknown[], mirror: ConsoleMethod): void {\n\t\tconst message = this.#capture(level, args)\n\t\tthis.#retain(message)\n\t\tthis.#emitter.emit('capture', message)\n\t\tif (this.#mirror) mirror(...args)\n\t\t// The wrapper NEVER throws into the patched global — a misbehaving sink is best-effort\n\t\t// and swallowed, never allowed to break the underlying program's own console.* call.\n\t\tif (this.#sink !== undefined) {\n\t\t\ttry {\n\t\t\t\tthis.#sink.write(message.text, CAPTURE_LEVEL_MAP[level])\n\t\t\t} catch {\n\t\t\t\t// Swallowed — see comment above.\n\t\t\t}\n\t\t}\n\t}\n\n\t// Build the immutable, serializable captured message — args stringified to one line (total,\n\t// never throws — see formatArgs), stamped with the capture instant. Frozen so a consumer (or\n\t// the `capture` listener) can never mutate it after the fact.\n\t#capture(level: CaptureLevel, args: readonly unknown[]): CapturedMessage {\n\t\treturn Object.freeze({ level, text: formatArgs(args), time: Date.now() })\n\t}\n\n\t// Push onto the total buffer and the level's bucket, evicting the oldest of each when at\n\t// capacity — both stay capped at #limit, never growing without bound.\n\t#retain(message: CapturedMessage): void {\n\t\tthis.#push(this.#messages, message)\n\t\tconst bucket = this.#buckets.get(message.level)\n\t\tif (bucket !== undefined) this.#push(bucket, message)\n\t}\n\n\t// Bounded push — append, then drop the oldest while over the cap.\n\t#push(buffer: CapturedMessage[], message: CapturedMessage): void {\n\t\tbuffer.push(message)\n\t\tif (buffer.length > this.#limit) buffer.shift()\n\t}\n}\n","import type {\n\tAlignment,\n\tBoxOptions,\n\tCaptureOptions,\n\tCaptureResult,\n\tLogLevel,\n\tLogRecord,\n\tProgressBarOptions,\n\tSeparatorOptions,\n\tStyle,\n\tStylerInterface,\n\tTableOptions,\n\tTreeNode,\n\tTreeOptions,\n\tTheme,\n} from './types.js'\nimport {\n\tANSI_PATTERN,\n\tBAR_EMPTY,\n\tBAR_FILL,\n\tBORDER_CHARS,\n\tCONTROL_PATTERN,\n\tDEFAULT_ALIGN,\n\tDEFAULT_BAR_WIDTH,\n\tDEFAULT_BORDER,\n\tDEFAULT_PADDING,\n\tDEFAULT_WIDTH,\n\tLEVEL_SEVERITY,\n\tSECOND_MS,\n\tSEPARATOR_FILL,\n\tSEPARATOR_TITLE_GAP,\n} from './constants.js'\nimport { Capture } from './Capture.js'\n\n// Pure, universal string helpers for the console / terminal system. `strip` removes\n// ANSI escapes; `width` is the visible length (strip then count). Both are needed later\n// by the box / table / progress layout — kept here, environment-agnostic, so every\n// surface shares one implementation (AGENTS §5). Every function exported (AGENTS §5).\n// The logging helpers (`meetsLevel`, `formatTime`, `formatRecord`) are likewise pure and\n// shared — the level gate's comparison and the styled-line layout, kept off the impl class.\n// `withCapture` sits here too: it RUNS a function under a scoped `Capture` and returns that\n// function's value, so it produces no entity and is reusable infrastructure, not a factory.\n\n/**\n * Remove every ANSI escape sequence from `text`, returning the plain visible string.\n *\n * @remarks\n * Strips SGR color/style codes AND other CSI controls (cursor, erase) plus OSC\n * sequences (titles, hyperlinks) — see {@link ANSI_PATTERN}. A FRESH `RegExp` is built\n * per call from the canonical pattern's `source` + `flags`, so the shared global\n * pattern's `lastIndex` is never mutated across calls (re-entrant and deterministic).\n *\n * @param text - Any string, styled or plain\n * @returns `text` with all ANSI escapes removed\n *\n * @example\n * ```ts\n * strip('\\x1b[31mred\\x1b[0m') // 'red'\n * ```\n */\nexport function strip(text: string): string {\n\treturn text.replace(new RegExp(ANSI_PATTERN.source, ANSI_PATTERN.flags), '')\n}\n\n/**\n * Remove every non-printing C0 control character from `text` EXCEPT `\\t` / `\\n` / `\\r`\n * (meaningful whitespace), plus DEL — returning the sanitized string.\n *\n * @remarks\n * Deliberately SEPARATE from {@link strip} (ANSI-escape removal only, so `width` /\n * `align` stay untouched) — this is the additional pass a non-TTY output sink applies\n * on top of `strip`, so a captured `\\x07` bell or stray `\\x00` never reaches a log file\n * / non-terminal target. A FRESH `RegExp` is built per call from {@link CONTROL_PATTERN}'s\n * `source` + `flags`, the same re-entrant idiom as `strip`.\n *\n * @param text - Any string, possibly carrying raw control bytes\n * @returns `text` with C0 controls (other than tab/newline/CR) and DEL removed\n *\n * @example\n * ```ts\n * stripControls('a\\x07b\\nc') // 'ab\\nc'\n * ```\n */\nexport function stripControls(text: string): string {\n\treturn text.replace(new RegExp(CONTROL_PATTERN.source, CONTROL_PATTERN.flags), '')\n}\n\n/**\n * The visible width of `text` — its length after ANSI escapes are stripped, counted in\n * Unicode code points (so an astral character such as an emoji counts as one, not the\n * two UTF-16 units `String.length` would report).\n *\n * @remarks\n * The basis for terminal layout (box / table / progress alignment): the column count a\n * styled string occupies, independent of its escape codes. It does NOT account for\n * wide (CJK / fullwidth) glyphs occupying two cells — a deliberate, documented\n * simplification at this layer; callers needing east-asian width handle it above.\n *\n * @param text - Any string, styled or plain\n * @returns The count of visible code points\n *\n * @example\n * ```ts\n * width('\\x1b[1mhi\\x1b[0m') // 2\n * ```\n */\nexport function width(text: string): number {\n\treturn [...strip(text)].length\n}\n\n/**\n * Snapshot and deeply freeze one {@link Style} value.\n *\n * @param style - The caller-owned style to snapshot\n * @returns A frozen style record with an independently frozen attributes list\n *\n * @remarks\n * The record spread captures accessor values once and preserves each present color channel.\n * Copying `attributes` prevents later mutation of a caller-owned list from changing the result.\n *\n * @example\n * ```ts\n * freezeStyle({ foreground: 'red', attributes: ['bold'] })\n * ```\n */\nexport function freezeStyle(style: Style): Style {\n\treturn Object.freeze({ ...style, attributes: Object.freeze([...style.attributes]) })\n}\n\n/**\n * Whether a record at `level` passes a logger gated at `threshold` — i.e. its severity is\n * at or above the threshold's.\n *\n * @remarks\n * The level gate (AGENTS §5 — the comparison lives here, not inlined in the logger). Reads\n * the ascending {@link LEVEL_SEVERITY} order: `meetsLevel('warn', 'error')` is `true`\n * (error ≥ warn), `meetsLevel('warn', 'info')` is `false` (info < warn).\n *\n * @param threshold - The logger's configured minimum {@link LogLevel}\n * @param level - The record's {@link LogLevel}\n * @returns `true` when `level` is at least as severe as `threshold`\n *\n * @example\n * ```ts\n * meetsLevel('info', 'error') // true\n * meetsLevel('error', 'warn') // false\n * ```\n */\nexport function meetsLevel(threshold: LogLevel, level: LogLevel): boolean {\n\treturn LEVEL_SEVERITY[level] >= LEVEL_SEVERITY[threshold]\n}\n\n/**\n * Format a {@link LogRecord}'s `time` (epoch milliseconds) as an ISO-8601 timestamp string.\n *\n * @remarks\n * Deterministic and serializable — `new Date(time).toISOString()`, e.g.\n * `1716900000000 → '2024-05-28T12:40:00.000Z'`. The timestamp portion of the formatted log\n * line; kept a pure helper so the line layout and the logger stay decoupled.\n *\n * @param time - Epoch milliseconds (a record's `time`)\n * @returns The ISO-8601 timestamp\n */\nexport function formatTime(time: number): string {\n\treturn new Date(time).toISOString()\n}\n\n/**\n * Format a {@link LogRecord} into a single styled line — the default human line layout a\n * {@link import('./types.js').LoggerInterface} writes to its sink.\n *\n * @remarks\n * Layout: `{time} {LEVEL} {[name]} {message}{ data}` — the ISO timestamp (dimmed), the\n * upper-cased level label (rendered through the theme's level role),\n * the originating logger's `name` in brackets (omitted when absent), the message, and the\n * structured `data` appended as compact JSON (omitted when absent / empty). Coloring flows\n * through the injected `styler`, so a disabled styler yields a plain line and a browser\n * `%c` styler (C-f) retargets it — the layout never changes. Pure: same record + styler →\n * same line.\n *\n * @param record - The {@link LogRecord} to render\n * @param styler - The {@link StylerInterface} the labels are colored through\n * @param theme - The {@link Theme} supplying the level and chrome roles\n * @returns The formatted, styled line (no trailing newline — the sink's target adds it)\n *\n * @example\n * ```ts\n * formatRecord(\n * \t{ level: 'warn', message: 'low disk', time: 0, name: 'fs' },\n * \tcreateStyler(),\n * \tDEFAULT_THEME,\n * )\n * // '<dim>1970-01-01T00:00:00.000Z</> <yellow>WARN</> [fs] low disk'\n * ```\n */\nexport function formatRecord(record: LogRecord, styler: StylerInterface, theme: Theme): string {\n\tconst time = styler.render(theme.chrome, formatTime(record.time))\n\tconst label = styler.render(theme.levels[record.level], record.level.toUpperCase())\n\tconst name =\n\t\trecord.name === undefined ? '' : ` ${styler.render(theme.chrome, `[${record.name}]`)}`\n\tconst data =\n\t\trecord.data === undefined || Object.keys(record.data).length === 0\n\t\t\t? ''\n\t\t\t: ` ${styler.render(theme.chrome, JSON.stringify(record.data))}`\n\treturn `${time} ${label}${name} ${record.message}${data}`\n}\n\n/**\n * Pad (or, when over budget, truncate) `text` to exactly `target` VISIBLE columns, positioning\n * it by `alignment`. The width primitive the box / table renderers align every cell with.\n *\n * @remarks\n * Measures with {@link width} (visible code points, ANSI-aware), so a styled string aligns by\n * its visible content, not its escape codes. When `width(text) < target`, the deficit is added\n * as spaces — all trailing (`left`), all leading (`right`), or split with the extra space on\n * the right (`center`). When `width(text) > target`, the VISIBLE characters are sliced to\n * `target` (a defensive guard — the renderers size columns to fit, so this is rarely hit; it\n * slices the stripped text, so it never bisects an escape sequence into a broken half).\n *\n * @param text - The cell content (may be styled)\n * @param target - The visible column count to fit `text` into\n * @param alignment - Where to position `text` within the width; defaults to `left`\n * @returns `text` fitted to exactly `target` visible columns\n *\n * @example\n * ```ts\n * align('hi', 5) // 'hi '\n * align('hi', 5, 'right') // ' hi'\n * align('hi', 5, 'center') // ' hi '\n * ```\n */\nexport function align(text: string, target: number, alignment: Alignment = DEFAULT_ALIGN): string {\n\tconst visible = width(text)\n\tif (visible > target) return [...strip(text)].slice(0, target).join('')\n\tconst deficit = target - visible\n\tif (alignment === 'right') return `${' '.repeat(deficit)}${text}`\n\tif (alignment === 'center') {\n\t\tconst left = Math.floor(deficit / 2)\n\t\treturn `${' '.repeat(left)}${text}${' '.repeat(deficit - left)}`\n\t}\n\treturn `${text}${' '.repeat(deficit)}`\n}\n\n/**\n * Format a millisecond duration as a compact human string — `…ms` below one second, `…s`\n * (seconds to 2 decimal places) at or above one second. The timing rendering behind\n * {@link import('./types.js').ReporterInterface.timing}.\n *\n * @remarks\n * `999 → '999ms'`, `1000 → '1.00s'`, `1230 → '1.23s'` (the threshold is {@link SECOND_MS}).\n * Pure and deterministic; kept a shared helper so the layout and the reporter stay decoupled.\n *\n * @param ms - The duration in milliseconds\n * @returns The formatted duration (`'<n>ms'` or `'<n>s'`)\n */\nexport function formatDuration(ms: number): string {\n\treturn ms < SECOND_MS ? `${ms}ms` : `${(ms / SECOND_MS).toFixed(2)}s`\n}\n\n/**\n * Color `text` through `styler`, or return it verbatim when `styler` is `undefined` — the\n * single optional-styling primitive every renderer applies to its border / title / connector\n * glyphs (AGENTS §5 — the ONE styler seam, shared, never re-hand-rolled per renderer).\n *\n * @remarks\n * The renderers all take an OPTIONAL `styler`: present ⇒ glyphs are colored, absent ⇒ plain.\n * Folding that `styler === undefined ? text : styler(text)` ternary into one exported helper\n * keeps the renderers terse and the styling decision in one tested place. A disabled styler\n * (`enabled: false`) is still a styler — it returns its text verbatim — so passing one paints\n * a no-op, exactly as omitting it does.\n *\n * @param styler - The {@link StylerInterface} to color with, or `undefined` for no styling\n * @param text - The glyphs / text to color\n * @param style - An optional {@link Style} to render by value instead of the styler's chain\n * @returns `styler(text)` when a styler is given, else `text` unchanged\n */\nexport function paint(styler: StylerInterface | undefined, text: string, style?: Style): string {\n\tif (styler === undefined) return text\n\treturn style === undefined ? styler(text) : styler.render(style, text)\n}\n\n/**\n * Repeat `unit` until it fills exactly `count` VISIBLE columns, trimming a trailing partial\n * unit so the run is never over-wide — the fill primitive the separator + box edges draw with.\n *\n * @remarks\n * Counts in code points ({@link width}-consistent), so a multi-cell or astral `unit` is laid\n * down whole and the result is sliced to exactly `count` visible columns. `count <= 0` (or an\n * empty / zero-width `unit`) yields `''`.\n *\n * @param unit - The (possibly multi-character) fill unit\n * @param count - The visible column count to fill\n * @returns `unit` tiled to exactly `count` visible columns\n *\n * @example\n * ```ts\n * repeatTo('─', 4) // '────'\n * repeatTo('=-', 5) // '=-=-='\n * ```\n */\nexport function repeatTo(unit: string, count: number): string {\n\tif (count <= 0) return ''\n\tconst per = width(unit)\n\tif (per === 0) return ''\n\tconst built = unit.repeat(Math.ceil(count / per))\n\treturn [...built].slice(0, count).join('')\n}\n\n/**\n * The cell at `index` of a (possibly ragged) row — `''` when the row is shorter than the\n * column count, so a short row pads out instead of throwing (the ragged-row guard\n * {@link renderTable} reads every cell through).\n *\n * @param row - The row's cells\n * @param index - The column index to read\n * @returns The cell text, or `''` when the row has no cell at `index`\n */\nexport function cellAt(row: readonly string[], index: number): string {\n\treturn row[index] ?? ''\n}\n\n/**\n * Render a horizontal rule — an optional centered title embedded in a line of fill characters,\n * to a fixed visible width. Pure: same {@link SeparatorOptions} → same string.\n *\n * @remarks\n * - **Plain rule.** With no `title`, returns `fill` repeated to `width` visible columns.\n * - **Titled rule.** With a `title`, centers ` title ` (one {@link SEPARATOR_TITLE_GAP} each\n * side) in the line, splitting the remaining fill between the two sides (the extra column,\n * when the remainder is odd, goes to the right). The visible width stays exactly `width`,\n * even when the title is styled (the title's escape codes don't count toward the budget) —\n * a title at least as wide as `width` yields just the gapped title (no fill).\n * - **Styling.** When `options.styler` is given, the fill runs (and the embedded title) are\n * colored through it; the layout is identical with or without color, since width is measured\n * on the visible content (AGENTS — width-aware via {@link width}).\n *\n * @param options - See {@link SeparatorOptions}\n * @returns The rule line (no trailing newline)\n *\n * @example\n * ```ts\n * renderSeparator({ width: 10 }) // '──────────'\n * renderSeparator({ title: 'Build', width: 13 }) // '── Build ──' (centered)\n * ```\n */\nexport function renderSeparator(options: SeparatorOptions): string {\n\tconst total = options.width ?? DEFAULT_WIDTH\n\tconst fill = options.fill ?? SEPARATOR_FILL\n\tif (options.title === undefined)\n\t\treturn paint(options.styler, repeatTo(fill, total), options.style)\n\tconst gapped = `${SEPARATOR_TITLE_GAP}${paint(options.styler, options.title, options.style)}${SEPARATOR_TITLE_GAP}`\n\tconst room = total - width(options.title) - SEPARATOR_TITLE_GAP.length * 2\n\tif (room <= 0) return gapped\n\tconst left = Math.floor(room / 2)\n\treturn `${paint(options.styler, repeatTo(fill, left), options.style)}${gapped}${paint(options.styler, repeatTo(fill, room - left), options.style)}`\n}\n\n/**\n * Render `content` framed in box-drawing characters, optionally captioned, width-aware so\n * styled content stays aligned inside the frame. Pure: same {@link BoxOptions} → same string.\n *\n * @remarks\n * - **Lines.** `content` is split on `\\n`; each line is padded (left-aligned) to the inner\n * width by {@link align} — measured on VISIBLE width, so a styled line never breaks the\n * right edge. The inner width is the widest line's visible width (or `width − borders −\n * 2·padding` when an explicit `width` is given and is wider), plus `padding` blank cells\n * inside each {@link BorderChars.vertical} edge.\n * - **Title.** An optional `title` is embedded in the TOP border (` title `), the remaining\n * top edge drawn as fill; a title wider than the inner width widens the box to fit it.\n * - **Border + styling.** The {@link BorderStyle} (`options.border`, default\n * {@link DEFAULT_BORDER}) selects the glyph set from {@link BORDER_CHARS}; `options.styler`\n * colors the frame + title when given (content cells are written as supplied).\n * - **Multi-line result.** Returns the box as `\\n`-joined rows (top, one row per content line,\n * bottom) with no trailing newline.\n *\n * @param options - See {@link BoxOptions}\n * @returns The framed box (multiple lines joined by `\\n`)\n */\nexport function renderBox(options: BoxOptions): string {\n\tconst chars = BORDER_CHARS[options.border ?? DEFAULT_BORDER]\n\tconst padding = Math.max(0, Math.trunc(options.padding ?? DEFAULT_PADDING))\n\tconst styler = options.styler\n\tconst lines = options.content.split('\\n')\n\t// The inner content width: the widest line, the title (when present), and any explicit\n\t// `width` budget (minus the two edges and the two padding gutters) all compete — the\n\t// widest wins, so nothing is ever clipped and an explicit width only ever pads outward.\n\t// The title's claim is its EMBEDDED form ` title ` (a gap each side) plus one lead fill\n\t// glyph, all spanning `inner + 2·padding` — so the top edge stays exactly as wide as the\n\t// rest of the box (the frame is always rectangular) and a long title widens the box.\n\tconst titleRoom =\n\t\toptions.title === undefined\n\t\t\t? 0\n\t\t\t: width(options.title) + SEPARATOR_TITLE_GAP.length * 2 + 1 - padding * 2\n\tconst budget = options.width === undefined ? 0 : options.width - 2 - padding * 2\n\tconst inner = lines.reduce(\n\t\t(max, line) => Math.max(max, width(line)),\n\t\tMath.max(0, titleRoom, budget),\n\t)\n\tconst gutter = ' '.repeat(padding)\n\tconst bar = paint(styler, chars.vertical, options.style)\n\t// The top border — the two corners with the horizontal run between, optionally carrying a\n\t// leading ` title ` embedded in the run. `span` is the full inner run (`inner + 2·padding`):\n\t// with no `title` the whole run is fill between the corners; with one, ` title ` sits after a\n\t// single leading fill glyph, the remainder drawn as fill — its VISIBLE width stays `span` (the\n\t// title's escape codes don't count).\n\tconst span = inner + padding * 2\n\tlet top: string\n\tif (options.title === undefined) {\n\t\ttop = paint(\n\t\t\tstyler,\n\t\t\t`${chars.topLeft}${repeatTo(chars.horizontal, span)}${chars.topRight}`,\n\t\t\toptions.style,\n\t\t)\n\t} else {\n\t\tconst caption = `${SEPARATOR_TITLE_GAP}${options.title}${SEPARATOR_TITLE_GAP}`\n\t\tconst room = span - width(caption)\n\t\tconst lead = paint(styler, repeatTo(chars.horizontal, 1), options.style)\n\t\tconst rest =\n\t\t\troom - 1 <= 0 ? '' : paint(styler, repeatTo(chars.horizontal, room - 1), options.style)\n\t\ttop = `${paint(styler, chars.topLeft, options.style)}${lead}${paint(styler, caption, options.style)}${rest}${paint(styler, chars.topRight, options.style)}`\n\t}\n\tconst bottom = paint(\n\t\tstyler,\n\t\t`${chars.bottomLeft}${repeatTo(chars.horizontal, inner + padding * 2)}${chars.bottomRight}`,\n\t\toptions.style,\n\t)\n\tconst body = lines.map((line) => `${bar}${gutter}${align(line, inner)}${gutter}${bar}`)\n\treturn [top, ...body, bottom].join('\\n')\n}\n\n/**\n * Render a bordered grid of `columns` + `rows` with per-column alignment and width-aware\n * column sizing. Pure: same {@link TableOptions} → same string.\n *\n * @remarks\n * - **Column sizing — visible width.** Each column is sized to the widest VISIBLE width\n * ({@link width}) among its header label and its cells, so an already-styled cell never\n * breaks the column (its escape codes don't count toward the width).\n * - **Ragged rows.** A row shorter than the column count is padded with empty cells; a longer\n * row is truncated to the column count — a ragged input never throws.\n * - **Alignment.** Each cell is positioned by its column's {@link ColumnSpec.align} (default\n * {@link DEFAULT_ALIGN}) via {@link align}.\n * - **Frame.** The {@link BorderStyle} (`options.border`, default {@link DEFAULT_BORDER})\n * draws the outer frame, the header rule (a `teeRight … cross … teeLeft` line), and the\n * `vertical` column separators; `options.styler` colors the frame + header labels when\n * given. Returns the table as `\\n`-joined rows (top, header, rule, one row per data row,\n * bottom), no trailing newline.\n *\n * @param options - See {@link TableOptions}\n * @returns The rendered table (multiple lines joined by `\\n`)\n */\nexport function renderTable(options: TableOptions): string {\n\tconst chars = BORDER_CHARS[options.border ?? DEFAULT_BORDER]\n\tconst styler = options.styler\n\tconst columns = options.columns\n\t// Each column's visible width: the max of its header label and every cell it holds.\n\tconst widths = columns.map((column, index) =>\n\t\toptions.rows.reduce(\n\t\t\t(max, row) => Math.max(max, width(cellAt(row, index))),\n\t\t\twidth(column.label),\n\t\t),\n\t)\n\tconst aligns = columns.map((column) => column.align ?? DEFAULT_ALIGN)\n\tconst rows = [\n\t\tcolumns.map((column) => paint(styler, column.label, options.style)),\n\t\t...options.rows.map((row) => columns.map((_column, index) => cellAt(row, index))),\n\t]\n\t// Frame the header and every body row in one pass: align each cell to its column width, add\n\t// one-space gutters, and join with the painted vertical separator.\n\tconst renderedRows = rows.map((cells) => {\n\t\tconst bar = paint(styler, chars.vertical, options.style)\n\t\tconst inner = cells\n\t\t\t.map(\n\t\t\t\t(cell, index) =>\n\t\t\t\t\t` ${align(cell, widths[index] ?? width(cell), aligns[index] ?? DEFAULT_ALIGN)} `,\n\t\t\t)\n\t\t\t.join(bar)\n\t\treturn `${bar}${inner}${bar}`\n\t})\n\tconst segments = widths.map((columnWidth) => repeatTo(chars.horizontal, columnWidth + 2))\n\tconst top = paint(\n\t\tstyler,\n\t\t`${chars.topLeft}${segments.join(chars.teeDown)}${chars.topRight}`,\n\t\toptions.style,\n\t)\n\tconst rule = paint(\n\t\tstyler,\n\t\t`${chars.teeRight}${segments.join(chars.cross)}${chars.teeLeft}`,\n\t\toptions.style,\n\t)\n\tconst bottom = paint(\n\t\tstyler,\n\t\t`${chars.bottomLeft}${segments.join(chars.teeUp)}${chars.bottomRight}`,\n\t\toptions.style,\n\t)\n\treturn [top, ...renderedRows.slice(0, 1), rule, ...renderedRows.slice(1), bottom].join('\\n')\n}\n\n/**\n * Render a nested {@link TreeNode} tree with box-drawing connectors. Pure: same\n * {@link TreeOptions} → same string.\n *\n * @remarks\n * The `root` label is the unindented first line; its descendants are drawn beneath it with\n * {@link BORDER_CHARS} — `├─ ` before each child but the last, `└─ ` before the last, and the\n * carried prefix using `│ ` under an ancestor that still has later siblings or ` ` under a\n * last ancestor (so the guides line up exactly under the branch they descend from). Node\n * labels are written as given (an already-styled label is honored); `options.styler` colors\n * the connectors when supplied. Returns the tree as `\\n`-joined lines, no trailing newline.\n *\n * @param options - See {@link TreeOptions}\n * @returns The rendered tree (multiple lines joined by `\\n`)\n *\n * @example\n * ```ts\n * renderTree({ root: { label: 'root', children: [{ label: 'a' }, { label: 'b' }] } })\n * // root\n * // ├─ a\n * // └─ b\n * ```\n */\nexport function renderTree(options: TreeOptions): string {\n\tconst border = options.border ?? DEFAULT_BORDER\n\treturn [\n\t\toptions.root.label,\n\t\t...renderTreeChildren(options.root.children ?? [], '', { ...options, border }),\n\t].join('\\n')\n}\n\n/**\n * Render the connector-prefixed lines for a {@link TreeNode} list — the recursive core\n * behind {@link renderTree}. Each child is drawn as `prefix` + its connector (`├─ ` for\n * any but the last, `└─ ` for the last) + its label, with its own descendants recursed\n * beneath under the carried guide (`│ ` under a non-last node, ` ` under the last).\n *\n * @remarks\n * A centralized, exported recursion branch (AGENTS §5) so it is directly testable and\n * reusable outside {@link renderTree}'s top-level `root.label` framing.\n *\n * @param nodes - The sibling {@link TreeNode}s to render at this depth\n * @param prefix - The guide/gap string carried in from the ancestor chain (`''` at the root)\n * @param options - The required `border` selection plus optional connector `styler` and\n * by-value `style`\n * @returns The rendered lines for `nodes` and all their descendants\n *\n * @example\n * ```ts\n * renderTreeChildren([{ label: 'a' }, { label: 'b' }], '', { border: 'single' })\n * // ['├─ a', '└─ b']\n * ```\n */\nexport function renderTreeChildren(\n\tnodes: readonly TreeNode[],\n\tprefix: string,\n\toptions: Required<Pick<TreeOptions, 'border'>> & Pick<TreeOptions, 'style' | 'styler'>,\n): readonly string[] {\n\tconst chars = BORDER_CHARS[options.border]\n\tconst branch = `${chars.teeRight}${chars.horizontal} `\n\tconst corner = `${chars.bottomLeft}${chars.horizontal} `\n\tconst guide = `${chars.vertical} `\n\tconst lines: string[] = []\n\tnodes.forEach((node, index) => {\n\t\tconst last = index === nodes.length - 1\n\t\tlines.push(\n\t\t\t`${prefix}${paint(options.styler, last ? corner : branch, options.style)}${node.label}`,\n\t\t)\n\t\tconst carry = `${prefix}${paint(options.styler, last ? ' ' : guide, options.style)}`\n\t\tlines.push(...renderTreeChildren(node.children ?? [], carry, options))\n\t})\n\treturn lines\n}\n\n/**\n * Stringify ONE captured console argument into a line fragment — the per-argument rule behind\n * {@link formatArgs}: an `Error` → `name: message`, a plain object / array → circular-safe JSON,\n * anything else (string, number, boolean, `null`, `undefined`, symbol, function) → `String(value)`.\n *\n * @remarks\n * - **Total + never throws.** Like a guard (§14), this never throws on adversarial input — a value\n * carrying a circular reference, a `BigInt`, or a throwing `toJSON` is rendered, not raised. The\n * `JSON.stringify` runs with a circular-guard replacer (a seen-set drops a back-reference as\n * `'[Circular]'`); should `JSON.stringify` still throw (e.g. a `BigInt`), the value falls back to\n * `String(value)`. So a `Capture` can never crash the program whose `console.*` it intercepts.\n * - **`Error` first.** An `Error` renders as `name: message` (e.g. `TypeError: bad`) — the useful\n * one-line form, since `JSON.stringify(error)` is `{}` (its fields are non-enumerable).\n * - **Objects → JSON.** A non-null `object` (including an array) is `JSON.stringify`d; a primitive\n * (or `null` / `undefined` / `function` / `symbol`) goes through `String`.\n *\n * @param value - One console argument (any value)\n * @returns The argument's one-line string form\n *\n * @example\n * ```ts\n * stringifyValue('hi') // 'hi'\n * stringifyValue({ a: 1 }) // '{\"a\":1}'\n * stringifyValue(new TypeError('bad')) // 'TypeError: bad'\n * const cycle: Record<string, unknown> = {}\n * cycle.self = cycle\n * stringifyValue(cycle) // '{\"self\":\"[Circular]\"}'\n * ```\n */\nexport function stringifyValue(value: unknown): string {\n\tif (value instanceof Error) return `${value.name}: ${value.message}`\n\tif (value === null || typeof value !== 'object') return String(value)\n\t// A circular-safe replacer — a seen-set drops any back-reference so a cyclic graph serializes\n\t// instead of throwing (total, like a guard §14). A residual throw (e.g. a BigInt field) falls\n\t// back to String(value), so this helper is total on every input.\n\tconst seen = new WeakSet<object>()\n\ttry {\n\t\treturn JSON.stringify(value, (_key, nested: unknown) => {\n\t\t\tif (nested !== null && typeof nested === 'object') {\n\t\t\t\tif (seen.has(nested)) return '[Circular]'\n\t\t\t\tseen.add(nested)\n\t\t\t}\n\t\t\treturn nested\n\t\t})\n\t} catch {\n\t\treturn String(value)\n\t}\n}\n\n/**\n * Stringify a captured `console.*` argument list into ONE line — the text of a {@link\n * import('./types.js').CapturedMessage}. Each argument is rendered by {@link stringifyValue} and\n * the parts are space-joined, mirroring how a console concatenates its arguments.\n *\n * @remarks\n * Total and never throws (it composes {@link stringifyValue}, which is total) — a `Capture` builds\n * every message through this, so intercepting `console.*` can never crash the underlying program.\n * An empty argument list yields `''` (an empty `console.log()` is captured as a blank line).\n *\n * @param args - The arguments a `console.*` method was called with\n * @returns The arguments stringified and space-joined into one line\n *\n * @example\n * ```ts\n * formatArgs(['count', 3, { ok: true }]) // 'count 3 {\"ok\":true}'\n * formatArgs([]) // ''\n * ```\n */\nexport function formatArgs(args: readonly unknown[]): string {\n\treturn args.map(stringifyValue).join(' ')\n}\n\n/**\n * Render a determinate progress bar string — a filled / empty glyph track followed by the percentage\n * and the `(current/total)` count (`█████░░░░░ 50% (5/10)`). Pure: same {@link ProgressBarOptions} →\n * same string. The animation-layer sibling of the C-c `render*` renderers (box / table / tree /\n * separator), shared so a {@link import('./types.js').ProgressInterface} and any direct caller draw\n * the ONE bar — never a second, hand-rolled one (AGENTS §5; scsr shipped three).\n *\n * @remarks\n * - **Fill fraction, clamped.** The filled cell count is `round((current / total) · width)` with\n * `current` clamped to `[0, total]`, so an overrun never over-fills and a negative never under-fills.\n * A `total <= 0` renders a FULL track (there is nothing to fill toward — the work is trivially done).\n * - **Width-aware track.** The filled run is `fill` tiled to the filled cell count and the empty run\n * `empty` tiled to the remainder, each via {@link repeatTo} — so the TRACK is exactly `width` VISIBLE\n * columns even for a multi-cell glyph (its escape codes / extra cells never break the width).\n * - **Styling.** `options.styler` colors the FILLED run only (the empty run + the trailing\n * `percent (count)` label stay plain), through {@link paint}; the layout is identical with or\n * without color, since the track is measured on visible width.\n * - **Label.** The percentage is the rounded `current / total` (e.g. `50%`); the count is the CLAMPED\n * `current` over `total` (`(5/10)`), a single space separating the track, the percent, and the count.\n *\n * @param options - See {@link ProgressBarOptions}\n * @returns The rendered bar line (no trailing newline)\n *\n * @example\n * ```ts\n * renderBar({ current: 5, total: 10, width: 10 }) // '█████░░░░░ 50% (5/10)'\n * renderBar({ current: 10, total: 10, width: 4 }) // '████ 100% (10/10)'\n * ```\n */\nexport function renderBar(options: ProgressBarOptions): string {\n\tconst track = options.width ?? DEFAULT_BAR_WIDTH\n\tconst fill = options.fill ?? BAR_FILL\n\tconst empty = options.empty ?? BAR_EMPTY\n\t// Clamp `current` into [0, total], and treat a non-positive `total` as already complete (a full\n\t// track) — so the fraction is always a sound [0, 1] and an overrun / negative never breaks the bar.\n\tconst current = options.total <= 0 ? 0 : Math.max(0, Math.min(options.total, options.current))\n\tconst fraction = options.total <= 0 ? 1 : current / options.total\n\tconst filledCells = Math.round(fraction * track)\n\tconst bar = `${paint(options.styler, repeatTo(fill, filledCells), options.style)}${repeatTo(empty, track - filledCells)}`\n\tconst percent = Math.round(fraction * 100)\n\treturn `${bar} ${percent}% (${current}/${options.total})`\n}\n\n// Run `fn` under a fresh, scoped console capture — the ergonomic form of {@link createCapture}.\n// A sync `fn` returning T yields { value, messages }; an async `fn` returning Promise<T> yields a\n// Promise of the same. The capture starts before `fn`, stops in a finally (so console is always\n// restored, even on throw), and is discarded — only the buffered messages are returned.\nexport function withCapture<T>(\n\tfn: () => Promise<T>,\n\toptions?: CaptureOptions,\n): Promise<CaptureResult<T>>\nexport function withCapture<T>(fn: () => T, options?: CaptureOptions): CaptureResult<T>\n/**\n * Run `fn` with the global `console.*` captured for its duration, returning the function's `value`\n * plus the {@link import('./types.js').CapturedMessage}s it logged — the scoped, self-restoring\n * ergonomic form of {@link createCapture}.\n *\n * @param fn - The function to run under capture; may be sync (returns `T`) or async (returns\n * `Promise<T>`)\n * @param options - See {@link CaptureOptions} (`levels` / `mirror` / `sink` / `limit` / `on` /\n * `error`); the capture is started for the duration of `fn` regardless\n * @returns For a sync `fn`, a {@link CaptureResult}`<T>` (`{ value, messages }`); for an async\n * `fn`, a `Promise<CaptureResult<T>>` (awaited, then console restored)\n *\n * @remarks\n * - **Always restores.** `start()` runs before `fn`; `stop()` runs in a `finally`, so `console` is\n * restored even if `fn` throws / rejects (the throw / rejection still propagates). The capture\n * is local — created, used, and destroyed within the call.\n * - **Sync vs async.** A `fn` returning a `Promise` is detected and AWAITED before `stop()`, so\n * captures during the async work are included; a plain `fn` stops synchronously. The return type\n * follows `fn`'s (overloaded).\n * - **PROCESS-GLOBAL caveat.** Like {@link createCapture}, this patches the one global `console`.\n * Concurrent `withCapture` calls (or a `withCapture` around other capturing code) INTERLEAVE —\n * each captures every `console.*` call in flight, and the inner `stop()` restores whatever the\n * outer had installed. Use it for sequential, scoped capture, not overlapping captures.\n *\n * @example\n * ```ts\n * import { withCapture } from '@src/core'\n *\n * const { value, messages } = withCapture(() => {\n * \tconsole.log('working')\n * \treturn 42\n * })\n * value // 42\n * messages.map((m) => m.text) // ['working']\n *\n * // Async — awaited before console is restored.\n * const out = await withCapture(async () => {\n * \tconsole.warn('async noise')\n * \treturn 'done'\n * })\n * out.value // 'done'\n * ```\n */\nexport function withCapture<T>(\n\tfn: () => T | Promise<T>,\n\toptions?: CaptureOptions,\n): CaptureResult<T> | Promise<CaptureResult<T>> {\n\tconst capture = new Capture(options)\n\tcapture.start()\n\ttry {\n\t\tconst result = fn()\n\t\tif (result instanceof Promise) {\n\t\t\treturn result.then(\n\t\t\t\t(value) => {\n\t\t\t\t\tconst messages = capture.messages()\n\t\t\t\t\tcapture.destroy()\n\t\t\t\t\treturn { value, messages }\n\t\t\t\t},\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tcapture.destroy()\n\t\t\t\t\tthrow error\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst messages = capture.messages()\n\t\tcapture.destroy()\n\t\treturn { value: result, messages }\n\t} catch (error) {\n\t\t// A SYNC throw — restore console before rethrowing (the async rejection path is handled above).\n\t\tcapture.destroy()\n\t\tthrow error\n\t}\n}\n","import type { RendererInterface, Style } from './types.js'\nimport { ATTRIBUTE_CODES, BACKGROUND_CODES, CSI, FOREGROUND_CODES, RESET } from './constants.js'\n\n/**\n * The cross-environment default {@link RendererInterface} — renders style DATA as ANSI\n * SGR escape codes, exactly as `Scheduler` is the `setTimeout` default for its seam. It\n * is the single styling output the whole console / terminal system uses in a terminal;\n * the browser `%c` / CSS renderer (the C-f branch) implements the SAME contract over\n * the SAME {@link Style}, so retargeting changes the renderer, never the style model.\n *\n * @remarks\n * - **Style is DATA in, SGR string out.** It reads the style's `foreground` /\n * `background` / `attributes` and emits one `ESC[…m` sequence whose parameters are the\n * mapped SGR numbers (foreground 30–37 / 90–97, background 40–47 / 100–107, attributes\n * 1 / 2 / 3 / 4 / 7 / 9), followed by `text`, terminated by the reset `ESC[0m`.\n * - **Multiple attributes compose** — their codes join with `;` in a single sequence\n * (`ESC[1;4;31m` for bold + underline + red), so one open and one reset wrap the run.\n * - **`default` and unset colors emit no code** — a `default` (or absent) `foreground` /\n * `background` leaves the terminal's own ink.\n * - **The empty style and the empty string pass through** — when there is nothing to\n * apply (no colors, no attributes) or `text` is `''`, `text` is returned VERBATIM with\n * no escape codes, so an unstyled render never injects a stray reset.\n * - **Stateless and event-free** — no fields, no events; safe to share one instance.\n */\nexport class ANSIRenderer implements RendererInterface {\n\t/**\n\t * Wrap `text` in the SGR codes for `style`. Returns `text` unchanged when the style\n\t * is empty or `text` is `''`.\n\t */\n\trender(style: Style, text: string): string {\n\t\tif (text === '') return text\n\t\tconst codes = this.#codes(style)\n\t\tif (codes.length === 0) return text\n\t\treturn `${CSI}${codes.join(';')}m${text}${RESET}`\n\t}\n\n\t// Collect the SGR parameters for a style, in a stable order — attributes first (in\n\t// their `attributes` order), then foreground, then background. A `default` or absent\n\t// color contributes nothing; an empty result signals \"no wrapping\" to `render`.\n\t#codes(style: Style): readonly number[] {\n\t\tconst codes: number[] = []\n\t\tfor (const attribute of style.attributes) codes.push(ATTRIBUTE_CODES[attribute])\n\t\tif (style.foreground !== undefined && style.foreground !== 'default') {\n\t\t\tcodes.push(FOREGROUND_CODES[style.foreground])\n\t\t}\n\t\tif (style.background !== undefined && style.background !== 'default') {\n\t\t\tcodes.push(BACKGROUND_CODES[style.background])\n\t\t}\n\t\treturn codes\n\t}\n}\n","import type {\n\tLoggerInterface,\n\tLoggerManagerInterface,\n\tLoggerManagerOptions,\n\tLoggerOptions,\n} from './types.js'\nimport { isArray } from '@orkestrel/contract'\nimport { Logger } from './Logger.js'\n\n/**\n * An event-free registry of named {@link Logger}s plus a convenience fan-out — the §9\n * manager over the logging layer (a registry, never observable itself; each {@link Logger}\n * owns its own `emitter`).\n *\n * @remarks\n * - **Registry (§9).** Loggers live in an insertion-ordered `Map` keyed by `name`.\n * `register(name, options?)` mints a {@link Logger} named `name` — the manager's default\n * `level` / `sink` / `styler` / `theme` / `format` / `limit` / `silent` flow in unless\n * `options` OVERRIDES them\n * (`name` is always the registry key, so any `options.name` is ignored) — stores it (a\n * re-`register` of the same name OVERWRITES, last write wins), and returns it. `count` is\n * the map size, `logger(name)` looks one up, `loggers()` lists them in insertion order.\n * - **Removal (§9.2).** `remove()` clears ALL, `remove(name)` drops ONE (`true` if present),\n * `remove(names)` drops a batch (`true` if any was removed).\n * (Removal does NOT `destroy` the returned loggers — a caller still holding one keeps using\n * it; the manager simply stops tracking it.)\n * - **Fan-out.** `debug` / `info` / `warn` / `error(message, data?)` forward the one call to\n * every registered logger in insertion order; each gates / emits / writes per its own `level`\n * and `sink`. A formatter throw is a programmer error and propagates, stopping the remaining\n * loggers for that call. A fan-out over an empty registry is a no-op.\n * - **Event-free.** No emitter, no events — the manager is a pure registry; observability is\n * per-{@link Logger}.\n *\n * @example\n * ```ts\n * const manager = new LoggerManager({ level: 'warn' })\n * manager.register('http') // inherits the `warn` default\n * manager.register('db', { level: 'debug' }) // overrides to `debug`\n * manager.warn('slow', { ms: 900 }) // fans out to both loggers\n * manager.count // 2\n * ```\n */\nexport class LoggerManager implements LoggerManagerInterface {\n\treadonly #loggers = new Map<string, LoggerInterface>()\n\t// The defaults flowed into every logger `register` mints (a per-register override wins).\n\treadonly #level: LoggerManagerOptions['level']\n\treadonly #sink: LoggerManagerOptions['sink']\n\treadonly #styler: LoggerManagerOptions['styler']\n\treadonly #theme: LoggerManagerOptions['theme']\n\treadonly #format: LoggerManagerOptions['format']\n\treadonly #limit: LoggerManagerOptions['limit']\n\treadonly #silent: LoggerManagerOptions['silent']\n\n\tconstructor(options?: LoggerManagerOptions) {\n\t\tthis.#level = options?.level\n\t\tthis.#sink = options?.sink\n\t\tthis.#styler = options?.styler\n\t\tthis.#theme = options?.theme\n\t\tthis.#format = options?.format\n\t\tthis.#limit = options?.limit\n\t\tthis.#silent = options?.silent\n\t}\n\n\tget count(): number {\n\t\treturn this.#loggers.size\n\t}\n\n\tregister(name: string, options?: LoggerOptions): LoggerInterface {\n\t\t// The manager's defaults flow in first; the per-register `options` override them; `name`\n\t\t// is forced last so it always keys the registry (an `options.name` can't desync the key).\n\t\tconst logger = new Logger({\n\t\t\t...(this.#level !== undefined ? { level: this.#level } : {}),\n\t\t\t...(this.#sink !== undefined ? { sink: this.#sink } : {}),\n\t\t\t...(this.#styler !== undefined ? { styler: this.#styler } : {}),\n\t\t\t...(this.#theme !== undefined ? { theme: this.#theme } : {}),\n\t\t\t...(this.#format !== undefined ? { format: this.#format } : {}),\n\t\t\t...(this.#limit !== undefined ? { limit: this.#limit } : {}),\n\t\t\t...(this.#silent !== undefined ? { silent: this.#silent } : {}),\n\t\t\t...options,\n\t\t\tname,\n\t\t})\n\t\tthis.#loggers.set(name, logger)\n\t\treturn logger\n\t}\n\n\tlogger(name: string): LoggerInterface | undefined {\n\t\treturn this.#loggers.get(name)\n\t}\n\n\tloggers(): readonly LoggerInterface[] {\n\t\treturn [...this.#loggers.values()]\n\t}\n\n\tdebug(message: string, data?: Record<string, unknown>): void {\n\t\tfor (const logger of this.#loggers.values()) logger.debug(message, data)\n\t}\n\n\tinfo(message: string, data?: Record<string, unknown>): void {\n\t\tfor (const logger of this.#loggers.values()) logger.info(message, data)\n\t}\n\n\twarn(message: string, data?: Record<string, unknown>): void {\n\t\tfor (const logger of this.#loggers.values()) logger.warn(message, data)\n\t}\n\n\terror(message: string, data?: Record<string, unknown>): void {\n\t\tfor (const logger of this.#loggers.values()) logger.error(message, data)\n\t}\n\n\t// §9.2: ALL / one / batch under one verb — the array overload declared FIRST by the project\n\t// convention (a `name` is a string, never an array, so the two never overlap).\n\tremove(names: readonly string[]): boolean\n\tremove(name: string): boolean\n\tremove(): void\n\tremove(names?: string | readonly string[]): void | boolean {\n\t\tif (names === undefined) {\n\t\t\tthis.#loggers.clear()\n\t\t\treturn\n\t\t}\n\t\tif (isArray(names)) {\n\t\t\tlet removed = false\n\t\t\tfor (const name of names) {\n\t\t\t\tif (this.#loggers.delete(name)) removed = true\n\t\t\t}\n\t\t\treturn removed\n\t\t}\n\t\treturn this.#loggers.delete(names)\n\t}\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tProgressEventMap,\n\tProgressInterface,\n\tProgressOptions,\n\tSinkInterface,\n\tStylerInterface,\n\tTheme,\n} from './types.js'\nimport { Emitter } from '@orkestrel/emitter'\nimport { DEFAULT_BAR_WIDTH, DEFAULT_THEME } from './constants.js'\nimport { createConsoleSink, createStyler } from './factories.js'\nimport { renderBar } from './helpers.js'\n\n/**\n * An update-driven, observable progress bar (AGENTS §13) — {@link update} recomputes the bar via\n * {@link renderBar}, writes `\\r` + bar to its {@link SinkInterface}, and emits the `{ current, total }`\n * on `update`. The leading `\\r` is what an overwrite-capable sink (the C-g TTY sink) redraws on; a\n * plain sink (C-f) degrades to a fresh, non-overwriting line — the line-OVERWRITE is the SINK's job.\n * UNIVERSAL — the one {@link StylerInterface} + the one {@link SinkInterface}, no `node:*`, no\n * `process.stdout`. NO self-timer (unlike {@link import('./Spinner.js').Spinner}) — the caller drives it.\n *\n * @remarks\n * - **Update-driven.** Each {@link update} clamps `current` to `[0, total]`, renders the bar (filled\n * to `current / total`, with the trailing `percent (current/total)` + message) via {@link renderBar},\n * emits `update`, and writes `'\\r' + bar`. Progress advances only when the caller reports it.\n * - **Outcome lines.** {@link complete} renders a FULL bar (`current = total`) + message, terminated by\n * a newline, emits a final `update` then `complete`, and marks `completed`. {@link failure} renders the\n * bar at its CURRENT fill + message + newline and routes to the sink's error stream (no `complete` —\n * the work did not finish). Both are terminal: a later {@link update} is ignored once `active` is false.\n * - **Bounded.** `current` is always clamped to `[0, total]`; {@link completed} reports whether\n * {@link complete} has run; {@link active} is `true` until a {@link complete} / {@link failure}.\n * - **Lifecycle (§10).** {@link destroy} destroys the emitter (there is no timer to clear).\n *\n * @example\n * ```ts\n * const progress = new Progress({ total: 100, message: 'downloading' })\n * progress.update(40) // ████████████░░░░░░░░░░░░░░░░░░ 40% (40/100) downloading\n * progress.update(80, 'almost there')\n * progress.complete('done') // a full bar, committed with a newline\n * ```\n */\nexport class Progress implements ProgressInterface {\n\t// The PUSH observation surface (§13) — owned, never inherited. The emitter isolates a listener\n\t// throw (routing it to the `error` handler), so a buggy `update` listener can never escape a report.\n\treadonly #emitter: Emitter<ProgressEventMap>\n\treadonly #total: number\n\treadonly #width: number\n\treadonly #fill: ProgressOptions['fill']\n\treadonly #empty: ProgressOptions['empty']\n\treadonly #sink: SinkInterface\n\treadonly #styler: StylerInterface\n\treadonly #theme: Theme\n\t#message: string\n\t#current = 0\n\t#active = true\n\t#completed = false\n\n\tconstructor(options: ProgressOptions) {\n\t\tthis.#emitter = new Emitter<ProgressEventMap>({\n\t\t\t...(options.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t\tthis.#total = options.total\n\t\tthis.#width = options.width ?? DEFAULT_BAR_WIDTH\n\t\tthis.#fill = options.fill\n\t\tthis.#empty = options.empty\n\t\tthis.#sink = options.sink ?? createConsoleSink()\n\t\tthis.#styler = options.styler ?? createStyler()\n\t\tthis.#theme = options.theme ?? DEFAULT_THEME\n\t\tthis.#message = options.message ?? ''\n\t}\n\n\tget emitter(): EmitterInterface<ProgressEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget active(): boolean {\n\t\treturn this.#active\n\t}\n\n\tget completed(): boolean {\n\t\treturn this.#completed\n\t}\n\n\tget current(): number {\n\t\treturn this.#current\n\t}\n\n\tget total(): number {\n\t\treturn this.#total\n\t}\n\n\tupdate(current: number, message?: string): void {\n\t\t// Terminal bars ignore further updates — a complete()/failure() has committed the final line.\n\t\tif (!this.#active) return\n\t\tthis.#advance(current, message)\n\t\tthis.#paint(false)\n\t}\n\n\tcomplete(message?: string): void {\n\t\tif (!this.#active) return\n\t\t// Finish FULL — drive to `total`, commit the line, then signal completion.\n\t\tthis.#advance(this.#total, message)\n\t\tthis.#active = false\n\t\tthis.#completed = true\n\t\tthis.#paint(true)\n\t\tthis.#emitter.emit('complete')\n\t}\n\n\tfailure(message?: string): void {\n\t\tif (!this.#active) return\n\t\t// Finish at the CURRENT fill (the work stopped short) — commit to the error stream, NO complete.\n\t\t// #advance emits a final `update` at the current fill (identical current/total), same as complete().\n\t\tthis.#advance(this.#current, message)\n\t\tthis.#active = false\n\t\tthis.#paint(true, 'error')\n\t}\n\n\tdestroy(): void {\n\t\tthis.#emitter.destroy()\n\t}\n\n\t// Clamp `current` into [0, total], adopt the optional message, and emit the `update` progress —\n\t// the shared state-advance behind update()/complete() (AGENTS §5). The clamp keeps `current`\n\t// bounded regardless of the value the caller reports (an overrun saturates, a negative floors).\n\t#advance(current: number, message?: string): void {\n\t\tthis.#current = Math.max(0, Math.min(this.#total, current))\n\t\tif (message !== undefined) this.#message = message\n\t\tthis.#emitter.emit('update', { current: this.#current, total: this.#total })\n\t}\n\n\t// Render the bar at the current state and write `\\r` + bar to the sink — the leading `\\r` an\n\t// overwrite-capable sink redraws on. `final` appends a newline that commits the line (a finished\n\t// bar is not overwritten); `level` routes a failure() write to the error stream. The single render\n\t// path shared by update()/complete()/failure().\n\t#paint(final: boolean, level?: 'error'): void {\n\t\tconst bar = renderBar({\n\t\t\tcurrent: this.#current,\n\t\t\ttotal: this.#total,\n\t\t\twidth: this.#width,\n\t\t\t...(this.#fill === undefined ? {} : { fill: this.#fill }),\n\t\t\t...(this.#empty === undefined ? {} : { empty: this.#empty }),\n\t\t\tstyler: this.#styler,\n\t\t\tstyle: this.#theme.accent,\n\t\t})\n\t\tconst line = this.#message === '' ? bar : `${bar} ${this.#message}`\n\t\tthis.#sink.write(`\\r${line}${final ? '\\n' : ''}`, level)\n\t}\n}\n","import type {\n\tBoxOptions,\n\tReporterInterface,\n\tReporterOptions,\n\tSinkInterface,\n\tStatusLevel,\n\tStepPosition,\n\tStylerInterface,\n\tTableOptions,\n\tTheme,\n\tTreeOptions,\n} from './types.js'\nimport { DEFAULT_THEME, DEFAULT_WIDTH } from './constants.js'\nimport { createConsoleSink, createStyler } from './factories.js'\nimport { formatDuration, renderBox, renderSeparator, renderTable, renderTree } from './helpers.js'\n\n/**\n * A lean, event-free narrative reporter (AGENTS §13) — the composable verb set for human /\n * build-run output. Each verb FORMATS its line through the shared {@link StylerInterface} and\n * the pure layout renderers ({@link renderSeparator} / {@link renderBox} / {@link renderTable}\n * / {@link renderTree}) and WRITES it to a {@link SinkInterface} — the SAME styler + sink\n * substrate the logger uses, never a second colorizer.\n *\n * @remarks\n * - **A SMALL set, not a grab-bag.** `section` / `step` / `timing` / `status` / `table` /\n * `tree` / `box` / `line` / `blank`. No spinner / bar (the animation chunk), no buffering /\n * capture (the capture chunk), no level retention (the logger). Just format + write.\n * - **`status` is a narrative OUTCOME, not a log level.** Its {@link StatusLevel} (`success` /\n * `error` / `warn` / `info`) is distinct from {@link import('./types.js').LogLevel}: an icon\n * supplied theme status icon + style, with `error` routed to the sink's\n * error stream (the `level` hint forwarded to {@link SinkInterface.write}) — there is no\n * gating and no severity ordering.\n * - **Width-aware.** `section` (and a `box` with no explicit `width`) lay out to the reporter's\n * `#width`; the renderers measure on VISIBLE width (ANSI-aware), so styled content aligns.\n * - **Event-free (§13).** No `#emitter` — a pure formatting front-end with no observable\n * lifecycle (like the renderers and `Scheduler`). It is reusable and holds no per-call state.\n *\n * @example\n * ```ts\n * const reporter = new Reporter()\n * reporter.section('Build')\n * reporter.step('compiling', { index: 1, total: 3 }) // [1/3] compiling\n * reporter.timing('bundle', 1234) // bundle … 1.23s\n * reporter.status('success', 'done') // ✔ done\n * ```\n */\nexport class Reporter implements ReporterInterface {\n\treadonly #sink: SinkInterface\n\treadonly #styler: StylerInterface\n\treadonly #theme: Theme\n\treadonly #width: number\n\n\tconstructor(options?: ReporterOptions) {\n\t\tthis.#sink = options?.sink ?? createConsoleSink()\n\t\tthis.#styler = options?.styler ?? createStyler()\n\t\tthis.#theme = options?.theme ?? DEFAULT_THEME\n\t\tthis.#width = options?.width ?? DEFAULT_WIDTH\n\t}\n\n\tsection(title: string): void {\n\t\t// The theme's chrome role styles the rule and title through the shared styler.\n\t\tthis.#sink.write(\n\t\t\trenderSeparator({\n\t\t\t\ttitle,\n\t\t\t\twidth: this.#width,\n\t\t\t\tstyler: this.#styler,\n\t\t\t\tstyle: this.#theme.chrome,\n\t\t\t}),\n\t\t)\n\t}\n\n\tstep(message: string, position?: StepPosition): void {\n\t\tconst prefix =\n\t\t\tposition === undefined\n\t\t\t\t? ''\n\t\t\t\t: `${this.#styler.render(this.#theme.accent, `[${position.index}/${position.total}]`)} `\n\t\tthis.#sink.write(`${prefix}${message}`)\n\t}\n\n\ttiming(label: string, ms: number): void {\n\t\tthis.#sink.write(\n\t\t\t`${label} ${this.#styler.render(this.#theme.chrome, `… ${formatDuration(ms)}`)}`,\n\t\t)\n\t}\n\n\tstatus(level: StatusLevel, message: string): void {\n\t\tconst status = this.#theme.statuses[level]\n\t\tconst line = `${this.#styler.render(status.style, status.icon)} ${this.#styler.render(status.style, message)}`\n\t\t// `error` is the one outcome that routes to the sink's error stream; the rest write plain.\n\t\tthis.#sink.write(line, level === 'error' ? 'error' : undefined)\n\t}\n\n\ttable(options: TableOptions): void {\n\t\tthis.#sink.write(renderTable(this.#resolveStyle(options)))\n\t}\n\n\ttree(options: TreeOptions): void {\n\t\tthis.#sink.write(renderTree(this.#resolveStyle(options)))\n\t}\n\n\tbox(options: BoxOptions): void {\n\t\t// Default the box width here; explicit options win.\n\t\tthis.#sink.write(renderBox(this.#resolveStyle({ width: this.#width, ...options })))\n\t}\n\n\tline(text: string): void {\n\t\tthis.#sink.write(text)\n\t}\n\n\tblank(count = 1): void {\n\t\tfor (let index = 0; index < count; index += 1) this.#sink.write('')\n\t}\n\n\t// Use theme chrome only when the caller supplied neither half of the styling decision. The\n\t// reporter's base styler still renders a caller's by-value style when no caller styler exists.\n\t#resolveStyle<T extends BoxOptions | TableOptions | TreeOptions>(options: T): T {\n\t\treturn {\n\t\t\tstyler: this.#styler,\n\t\t\t...(options.styler === undefined && options.style === undefined\n\t\t\t\t? { style: this.#theme.chrome }\n\t\t\t\t: {}),\n\t\t\t...options,\n\t\t}\n\t}\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tSinkInterface,\n\tSpinnerEventMap,\n\tSpinnerInterface,\n\tSpinnerOptions,\n\tStylerInterface,\n\tTheme,\n} from './types.js'\nimport { Emitter } from '@orkestrel/emitter'\nimport { DEFAULT_SPINNER_INTERVAL, DEFAULT_THEME, SPINNER_FRAMES } from './constants.js'\nimport { createConsoleSink, createStyler } from './factories.js'\n\n/**\n * A self-driving, observable activity spinner (AGENTS §13) — a glyph cycle that advances on a\n * periodic timer, writing each `\\r` + frame line to its {@link SinkInterface} and emitting it on\n * `frame`. The leading `\\r` is what an overwrite-capable sink (the C-g TTY sink) redraws on; a plain\n * sink (C-f) degrades to a fresh, non-overwriting line — the line-OVERWRITE is the SINK's job, never\n * the spinner's. UNIVERSAL — `setInterval` + the one {@link StylerInterface} + the one\n * {@link SinkInterface}, no `node:*`, no `process.stdout`.\n *\n * @remarks\n * - **Self-driving but deterministically testable.** `start()` arms a `setInterval` that calls\n * {@link tick} each `interval`; each {@link tick} builds the styled `glyph + message` line for the\n * current frame, emits it on `frame`, writes `'\\r' + line` to the sink, then advances the frame\n * index (wrapping). A test drives frames by calling {@link tick} directly, or arms a real short\n * `interval` and proves the timer arms / clears through the sink it writes to.\n * - **Leak-free timer.** The interval is ALWAYS cleared on {@link success} / {@link failure} /\n * {@link stop} / {@link destroy} — `#handle` is the single source of `active`, set on arm and unset\n * on clear, so a spinner never leaks a running interval.\n * - **Idempotent `start`.** A {@link start} while already `active` is a no-op (it never arms a second\n * timer).\n * - **Outcome lines.** {@link success} / {@link failure} clear the timer then write + emit a FINAL line —\n * the supplied theme status icon + style (`✔` / `✖` by default) + the message — terminated\n * by a newline (the activity is over; the line is committed, not overwritten). {@link failure} routes to\n * the sink's error stream.\n * - **Lifecycle (§10).** {@link stop} clears the timer and LEAVES the current line; {@link destroy}\n * stops then destroys the emitter. {@link update} swaps the message and re-renders immediately when\n * `active`.\n *\n * @example\n * ```ts\n * const spinner = new Spinner({ message: 'building' })\n * spinner.start() // arms the timer, paints the first frame to the sink\n * spinner.update('bundling') // message changes, re-rendered at once\n * spinner.success('built in 1.2s') // ✔ built in 1.2s — timer cleared, line committed\n * ```\n */\nexport class Spinner implements SpinnerInterface {\n\t// The PUSH observation surface (§13) — owned, never inherited. The emitter isolates a listener\n\t// throw (routing it to the `error` handler), so a buggy `frame` listener can never escape the tick.\n\treadonly #emitter: Emitter<SpinnerEventMap>\n\treadonly #frames: readonly string[]\n\treadonly #interval: number\n\treadonly #sink: SinkInterface\n\treadonly #styler: StylerInterface\n\treadonly #theme: Theme\n\t#message: string\n\t// The running interval handle — undefined while inactive. Its presence IS `active`; the timer is\n\t// armed in start() and cleared everywhere the spinner stops, so it is never leaked.\n\t#handle: ReturnType<typeof setInterval> | undefined\n\t// The current frame index into #frames — advanced (wrapping) after each rendered tick.\n\t#index = 0\n\n\tconstructor(options?: SpinnerOptions) {\n\t\tthis.#emitter = new Emitter<SpinnerEventMap>({\n\t\t\t...(options?.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options?.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t\t// An explicitly-EMPTY `frames` array falls back to the default cycle too — an empty cycle\n\t\t// would divide by zero on every wrap in tick() (AGENTS §16 hardening).\n\t\tconst frames = options?.frames ?? SPINNER_FRAMES\n\t\tthis.#frames = frames.length === 0 ? SPINNER_FRAMES : frames\n\t\tthis.#interval = options?.interval ?? DEFAULT_SPINNER_INTERVAL\n\t\tthis.#sink = options?.sink ?? createConsoleSink()\n\t\tthis.#styler = options?.styler ?? createStyler()\n\t\tthis.#theme = options?.theme ?? DEFAULT_THEME\n\t\tthis.#message = options?.message ?? ''\n\t}\n\n\tget emitter(): EmitterInterface<SpinnerEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget active(): boolean {\n\t\treturn this.#handle !== undefined\n\t}\n\n\tget message(): string {\n\t\treturn this.#message\n\t}\n\n\tstart(): void {\n\t\t// Idempotent — never arm a second interval over a running one (that would leak the first handle).\n\t\tif (this.#handle !== undefined) return\n\t\tthis.#handle = setInterval(() => this.tick(), this.#interval)\n\t\tthis.#emitter.emit('start')\n\t\t// Paint the first frame immediately so the spinner shows at once, not only after one interval.\n\t\tthis.tick()\n\t}\n\n\ttick(): void {\n\t\t// Render the CURRENT frame, then advance — so the first tick() shows frame 0.\n\t\tthis.#paint(this.#line())\n\t\tthis.#index = (this.#index + 1) % this.#frames.length\n\t}\n\n\tupdate(message: string): void {\n\t\tthis.#message = message\n\t\t// Re-render the CURRENT frame (no advance) so the new message shows without waiting for a tick.\n\t\tif (this.#handle !== undefined) this.#paint(this.#line())\n\t}\n\n\tsuccess(message?: string): void {\n\t\tthis.#finish('success', message)\n\t}\n\n\tfailure(message?: string): void {\n\t\tthis.#finish('error', message)\n\t}\n\n\tstop(): void {\n\t\t// Clear the timer and leave the current line untouched — a no-op when not active.\n\t\tif (this.#handle === undefined) return\n\t\tclearInterval(this.#handle)\n\t\tthis.#handle = undefined\n\t\tthis.#emitter.emit('stop')\n\t}\n\n\tdestroy(): void {\n\t\tthis.stop()\n\t\tthis.#emitter.destroy()\n\t}\n\n\t// Stop the timer (emitting `stop` when it was running) and write + emit the FINAL outcome line —\n\t// the status icon + message, colored through the styler, terminated by a newline (the activity is\n\t// over, so the line is committed, not overwritten). `error` routes to the sink's error stream. The\n\t// shared body of success()/failure() (AGENTS §5 — single home for the outcome path).\n\t#finish(level: 'success' | 'error', message?: string): void {\n\t\tthis.stop()\n\t\tconst text = message ?? this.#message\n\t\tif (message !== undefined) this.#message = message\n\t\tconst status = this.#theme.statuses[level]\n\t\tconst line = `${this.#styler.render(status.style, status.icon)} ${this.#styler.render(status.style, text)}`\n\t\tthis.#emitter.emit('frame', line)\n\t\t// The trailing newline commits the line; `error` is the one outcome routed to the error stream.\n\t\tthis.#sink.write(`\\r${line}\\n`, level === 'error' ? 'error' : undefined)\n\t}\n\n\t// Build the styled frame line for the CURRENT index — the colored spinner glyph, then the message\n\t// when present (a bare glyph otherwise). Kept off the public surface (a render fragment, AGENTS §5).\n\t#line(): string {\n\t\tconst glyph = this.#styler.render(this.#theme.accent, this.#frames[this.#index] ?? '')\n\t\treturn this.#message === '' ? glyph : `${glyph} ${this.#message}`\n\t}\n\n\t// Emit the frame line and write it to the sink with the leading `\\r` an overwrite-capable sink\n\t// redraws on — the SAME line both places, the `\\r` added only on the write (the event carries the\n\t// bare line). The single per-tick render path shared by tick() and update().\n\t#paint(line: string): void {\n\t\tthis.#emitter.emit('frame', line)\n\t\tthis.#sink.write(`\\r${line}`)\n\t}\n}\n","import type { Attribute, Color, RendererInterface, Style, StylerInterface } from './types.js'\nimport { ATTRIBUTES, COLORS } from './constants.js'\nimport { ConsoleError } from './errors.js'\n\n/**\n * The fluent, composable styler — the consumer-facing API over the style engine. It\n * builds a {@link Style} (style as DATA) and renders it through an injected\n * {@link RendererInterface} (the ANSI default, or a browser `%c` renderer at C-f). Each\n * color / attribute accessor is immutable copy-on-write: it returns a NEW styler's\n * surface with the token added, so `styler.red.bold('hi')` composes without mutating,\n * and a base styler is freely reusable.\n *\n * @remarks\n * - **Callable surface.** A `Styler` is not itself callable; its {@link surface} getter\n * returns the {@link StylerInterface} — a render FUNCTION carrying the chainable\n * accessors. The accessors are installed as LAZY getters (`Object.defineProperties`),\n * so a chain materializes only the stylers it actually walks — never the full tree —\n * and the recursion terminates. The factory returns that surface; this class is the\n * engine behind it.\n * - **Immutable.** `#foreground` and `#attribute` return a fresh `Styler` (the style is\n * rebuilt, never mutated). A later color of the same channel WINS (last write); a\n * repeated attribute is idempotent (de-duplicated, order preserved).\n * - **Styling by value.** `render(style, text)` merges a {@link Style} over the accumulated\n * one and renders that — the same precedence a chain applies, reached with DATA instead of\n * accessor names. It is how a {@link import('./types.js').Theme} role is drawn.\n * - **`enabled` switch.** When `false`, the render function returns text VERBATIM — no\n * renderer call, no escape codes (for a non-TTY / `NO_COLOR` / piped output).\n * - **Event-free** — a pure styling primitive (AGENTS §13), like `Scheduler`.\n */\nexport class Styler {\n\treadonly #renderer: RendererInterface\n\treadonly #enabled: boolean\n\treadonly #style: Style\n\n\tconstructor(renderer: RendererInterface, enabled: boolean, style: Style) {\n\t\tthis.#renderer = renderer\n\t\tthis.#enabled = enabled\n\t\tthis.#style = style\n\t}\n\n\t/** The accumulated style DATA — the empty style on a base styler. */\n\tget style(): Style {\n\t\treturn this.#style\n\t}\n\n\t/** Whether styling is applied; when `false`, the surface returns text unchanged. */\n\tget enabled(): boolean {\n\t\treturn this.#enabled\n\t}\n\n\t/**\n\t * The fluent {@link StylerInterface} value — a render function (`text => string`) with\n\t * `style`, `enabled`, and every {@link Color} / {@link Attribute} as a LAZY accessor\n\t * (each computes the next styler's surface only when read). This is what consumers\n\t * hold and call.\n\t *\n\t * @remarks\n\t * The accessors are defined as getters (not eagerly-merged values), so accessing one\n\t * builds exactly one child styler — the tree is never fully materialized and the\n\t * construction terminates. The assembled function is then narrowed to\n\t * {@link StylerInterface} through {@link #isSurface} (a real structural check), so no\n\t * type assertion is used (AGENTS §1 / §14 — narrow, never assert).\n\t */\n\tget surface(): StylerInterface {\n\t\tconst callable = this.#render.bind(this)\n\t\tconst descriptors: PropertyDescriptorMap = {\n\t\t\tstyle: { value: this.#style, enumerable: true },\n\t\t\tenabled: { value: this.#enabled, enumerable: true },\n\t\t\trender: { value: this.render.bind(this), enumerable: true },\n\t\t}\n\t\tfor (const color of COLORS) {\n\t\t\tdescriptors[color] = {\n\t\t\t\tget: this.#foregroundSurface.bind(this, color),\n\t\t\t\tenumerable: true,\n\t\t\t}\n\t\t}\n\t\tfor (const attribute of ATTRIBUTES) {\n\t\t\tdescriptors[attribute] = {\n\t\t\t\tget: this.#attributeSurface.bind(this, attribute),\n\t\t\t\tenumerable: true,\n\t\t\t}\n\t\t}\n\t\tconst surface = Object.defineProperties(callable, descriptors)\n\t\tif (this.#isSurface(surface)) return surface\n\t\t// Unreachable: the descriptors above install every accessor the guard checks for.\n\t\tthrow new ConsoleError('INVARIANT', 'console: styler surface construction is incomplete')\n\t}\n\n\t/**\n\t * Render `text` in `style` merged OVER the accumulated style — the by-value door beside\n\t * the accessor chain, and how a {@link import('./types.js').Theme} role is applied.\n\t *\n\t * @param style - The style to overlay; its colors win over the accumulated ones and its\n\t * attributes join them (de-duplicated, the accumulated ones first)\n\t * @param text - The text to wrap\n\t * @returns The rendered text — verbatim when `enabled` is `false`, and (by the\n\t * {@link RendererInterface} contract) when the merged style or `text` is empty\n\t *\n\t * @example\n\t * ```ts\n\t * import { createStyler, DEFAULT_THEME } from '@src/core'\n\t *\n\t * const styler = createStyler()\n\t * styler.render(DEFAULT_THEME.levels.warn, 'WARN') // yellow\n\t * styler.bold.render(DEFAULT_THEME.chrome, '│') // dim, over the accumulated bold\n\t * ```\n\t */\n\trender(style: Style, text: string): string {\n\t\treturn this.#enabled ? this.#renderer.render(this.#merge(style), text) : text\n\t}\n\n\t// Render through the configured target, or pass text through when styling is disabled.\n\t#render(text: string): string {\n\t\treturn this.#enabled ? this.#renderer.render(this.#style, text) : text\n\t}\n\n\t// Overlay `style` on the accumulated style: a set color of either channel WINS (last\n\t// write, as in a chain), and the attribute sets union — accumulated order first, the\n\t// overlay's new ones appended, each carried once. Frozen, like every style this engine\n\t// builds; the caller's value is read, never touched.\n\t#merge(style: Style): Style {\n\t\tconst attributes: Attribute[] = [...this.#style.attributes]\n\t\tfor (const attribute of style.attributes) {\n\t\t\tif (!attributes.includes(attribute)) attributes.push(attribute)\n\t\t}\n\t\treturn Object.freeze({\n\t\t\t...this.#style,\n\t\t\t...style,\n\t\t\tattributes: Object.freeze(attributes),\n\t\t})\n\t}\n\n\t// Resolve one lazy foreground accessor to the next immutable styler surface.\n\t#foregroundSurface(color: Color): StylerInterface {\n\t\treturn this.#foreground(color).surface\n\t}\n\n\t// Resolve one lazy attribute accessor to the next immutable styler surface.\n\t#attributeSurface(attribute: Attribute): StylerInterface {\n\t\treturn this.#attribute(attribute).surface\n\t}\n\n\t// Structurally confirm an assembled value is a usable styler surface — callable, with\n\t// the data members and a representative color/attribute accessor present. A genuine\n\t// runtime narrowing (AGENTS §14), not a cast: it lets `surface` return `StylerInterface`\n\t// without `as`/`!`.\n\t#isSurface(value: ((text: string) => string) & object): value is StylerInterface {\n\t\treturn (\n\t\t\ttypeof value === 'function' &&\n\t\t\t'style' in value &&\n\t\t\t'enabled' in value &&\n\t\t\t'render' in value &&\n\t\t\t'red' in value &&\n\t\t\t'bold' in value\n\t\t)\n\t}\n\n\t// A new styler with `color` as the foreground — last write wins (replaces any prior\n\t// foreground); background and attributes carried forward unchanged.\n\t#foreground(color: Color): Styler {\n\t\treturn new Styler(\n\t\t\tthis.#renderer,\n\t\t\tthis.#enabled,\n\t\t\tObject.freeze({ ...this.#style, foreground: color }),\n\t\t)\n\t}\n\n\t// A new styler with `attribute` added to the set — de-duplicated and order-stable, so\n\t// a repeated attribute is idempotent.\n\t#attribute(attribute: Attribute): Styler {\n\t\tif (this.#style.attributes.includes(attribute)) return this\n\t\treturn new Styler(\n\t\t\tthis.#renderer,\n\t\t\tthis.#enabled,\n\t\t\tObject.freeze({\n\t\t\t\t...this.#style,\n\t\t\t\tattributes: Object.freeze([...this.#style.attributes, attribute]),\n\t\t\t}),\n\t\t)\n\t}\n}\n","import type {\n\tCaptureInterface,\n\tCaptureOptions,\n\tLoggerInterface,\n\tLoggerManagerInterface,\n\tLoggerManagerOptions,\n\tLoggerOptions,\n\tLogLevel,\n\tProgressInterface,\n\tProgressOptions,\n\tRendererInterface,\n\tReporterInterface,\n\tReporterOptions,\n\tSinkInterface,\n\tSpinnerInterface,\n\tSpinnerOptions,\n\tStylerInterface,\n\tStylerOptions,\n\tTheme,\n\tThemeOptions,\n} from './types.js'\nimport { ANSIRenderer } from './ANSIRenderer.js'\nimport { Capture } from './Capture.js'\nimport { DEFAULT_THEME, EMPTY_STYLE, LEVELS, STATUS_LEVELS } from './constants.js'\nimport { freezeStyle } from './helpers.js'\nimport { Logger } from './Logger.js'\nimport { LoggerManager } from './LoggerManager.js'\nimport { Progress } from './Progress.js'\nimport { Reporter } from './Reporter.js'\nimport { Spinner } from './Spinner.js'\nimport { Styler } from './Styler.js'\n\n/**\n * Create the cross-environment default {@link RendererInterface} — the ANSI / SGR\n * renderer that turns style DATA into terminal escape codes. The default behind\n * {@link createStyler}; construct one directly to render a {@link import('./types.js').Style}\n * without the fluent surface, or to share one instance across stylers.\n *\n * @returns A stateless ANSI {@link RendererInterface}\n *\n * @example\n * ```ts\n * import { createANSIRenderer } from '@src/core'\n *\n * const renderer = createANSIRenderer()\n * renderer.render({ foreground: 'red', attributes: ['bold'] }, 'alert') // '\\x1b[1;31malert\\x1b[0m'\n * ```\n */\nexport function createANSIRenderer(): RendererInterface {\n\treturn new ANSIRenderer()\n}\n\n/**\n * Create the fluent, composable {@link StylerInterface} — the consumer-facing styling\n * API. It builds a {@link import('./types.js').Style} under the hood and renders it\n * through a {@link RendererInterface} (the ANSI default), so `styler.red.bold('hi')`\n * yields styled text. Chains are immutable, so a base styler is freely reusable.\n *\n * @param options - See {@link StylerOptions}\n * @returns A base {@link StylerInterface}\n *\n * @remarks\n * - `options.renderer` swaps the output target without touching the style model — pass a\n * browser `%c` / CSS renderer (the C-f branch) to retarget; defaults to the ANSI\n * renderer (the cross-environment default).\n * - `options.enabled` is the no-color switch: when `false`, the styler returns text\n * VERBATIM (for a non-TTY, `NO_COLOR`, or piped output); defaults to `true`.\n *\n * @example\n * ```ts\n * import { createStyler } from '@src/core'\n *\n * const style = createStyler()\n * style.red.bold('error') // bold red\n * style.red(style.underline('link')) // composes either way\n *\n * // Disable for a non-TTY — every call returns its text unchanged.\n * const plain = createStyler({ enabled: false })\n * plain.green('ok') // 'ok'\n * ```\n */\nexport function createStyler(options?: StylerOptions): StylerInterface {\n\tconst renderer = options?.renderer ?? new ANSIRenderer()\n\tconst enabled = options?.enabled ?? true\n\treturn new Styler(renderer, enabled, EMPTY_STYLE).surface\n}\n\n/**\n * Create a {@link Theme} — the app-wide semantic style vocabulary, merged role by role over\n * {@link DEFAULT_THEME}. Hand one theme to a logger / reporter / spinner / progress and every\n * surface speaks it; omit `options` for the defaults.\n *\n * @param options - See {@link ThemeOptions}\n * @returns A frozen {@link Theme}\n *\n * @remarks\n * - **Merges per ROLE, not per theme.** An omitted role keeps its default, and `levels` /\n * `statuses` merge per ENTRY — `{ levels: { warn: … } }` restyles the `warn` label and\n * leaves `debug` / `info` / `error` untouched.\n * - **Frozen and shareable.** The factory snapshots and deep-freezes every style leaf. The\n * returned theme and its `levels` / `statuses` records are frozen. Each status record is also\n * copied and frozen. One theme is therefore safely shared across every entity.\n *\n * @example\n * ```ts\n * import { createStyler, createTheme } from '@src/core'\n *\n * const styler = createStyler()\n * const theme = createTheme({\n * \tlevels: { warn: styler.brightYellow.bold.style }, // only the warn label changes\n * \taccent: styler.magenta.style, // spinner glyph, progress fill, step prefix\n * })\n * theme.levels.error // still the default red\n * ```\n */\nexport function createTheme(options?: ThemeOptions): Theme {\n\tconst levels = { ...DEFAULT_THEME.levels }\n\tfor (const level of LEVELS) {\n\t\tlevels[level] = freezeStyle(options?.levels?.[level] ?? DEFAULT_THEME.levels[level])\n\t}\n\tconst statuses = { ...DEFAULT_THEME.statuses }\n\tfor (const status of STATUS_LEVELS) {\n\t\tconst source = options?.statuses?.[status] ?? DEFAULT_THEME.statuses[status]\n\t\tstatuses[status] = Object.freeze({ icon: source.icon, style: freezeStyle(source.style) })\n\t}\n\treturn Object.freeze({\n\t\tlevels: Object.freeze(levels),\n\t\tstatuses: Object.freeze(statuses),\n\t\taccent: freezeStyle(options?.accent ?? DEFAULT_THEME.accent),\n\t\tchrome: freezeStyle(options?.chrome ?? DEFAULT_THEME.chrome),\n\t})\n}\n\n/**\n * Create the default {@link SinkInterface} — a console sink that routes by level and writes\n * through the `console` methods SNAPSHOTTED at creation. The default output target behind\n * {@link createLogger}.\n *\n * @returns A console {@link SinkInterface}\n *\n * @remarks\n * - **Snapshotted — no capture loop.** It captures `console.log` / `console.warn` /\n * `console.error` AT CALL TIME and writes through those references. So when a later\n * `Capture` (C-d) PATCHES `console.*`, this sink still reaches the REAL streams — the\n * writer and the capturer never feed each other (the no-capture-loop principle). Create\n * the sink (or the logger) BEFORE installing a capture for this to hold.\n * - **Routes by level.** `error` → the snapshotted `console.error`, `warn` →\n * `console.warn`, every other level → `console.log`. The `level` is supplied by the\n * logger; an omitted `level` goes to `console.log`.\n *\n * @example\n * ```ts\n * import { createConsoleSink } from '@src/core'\n *\n * const sink = createConsoleSink() // snapshots console.* now\n * sink.write('boom', 'error') // → the real console.error, even after a later console patch\n * ```\n */\nexport function createConsoleSink(): SinkInterface {\n\t// Snapshot the three console writers NOW — bound to their `console` receiver — so a later\n\t// patch of `console.*` (by Capture) can never reach this sink's output (no capture loop).\n\tconst log = console.log.bind(console)\n\tconst warn = console.warn.bind(console)\n\tconst error = console.error.bind(console)\n\treturn {\n\t\twrite(text: string, level?: LogLevel): void {\n\t\t\tif (level === 'error') {\n\t\t\t\terror(text)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (level === 'warn') {\n\t\t\t\twarn(text)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlog(text)\n\t\t},\n\t}\n}\n\n/**\n * Create an observable, leveled {@link LoggerInterface} — the entry point into structured\n * logging. Each `debug` / `info` / `warn` / `error` call builds a frozen\n * {@link import('./types.js').LogRecord}, gates it by severity, retains a bounded tail,\n * ALWAYS emits it on `entry` (the transport seam), and — unless `silent` — writes a styled\n * line to its sink.\n *\n * @param options - See {@link LoggerOptions}\n * @returns A {@link LoggerInterface}\n *\n * @remarks\n * - **Record + event = transport (§13).** Subscribe `logger.emitter.on('entry', …)` to tee\n * records to a file / JSON / remote transport; the event fires for every accepted record,\n * even when `silent` (silence suppresses only the SINK WRITE).\n * - **Bounded retention.** `entries()` returns the recent records, capped at `options.limit`\n * (default {@link DEFAULT_LOG_LIMIT}); never unbounded.\n * - **Sink + styler defaults.** `options.sink` defaults to {@link createConsoleSink} (the\n * snapshotted, level-routing console sink); `options.styler` to {@link createStyler} (ANSI).\n * Styling is orthogonal to level — a level only chooses a label color.\n *\n * @example\n * ```ts\n * import { createLogger } from '@src/core'\n *\n * const logger = createLogger({ name: 'http', level: 'info' })\n * logger.info('request', { method: 'GET', path: '/' })\n * logger.debug('verbose') // dropped — below the info threshold\n * ```\n */\nexport function createLogger(options?: LoggerOptions): LoggerInterface {\n\treturn new Logger(options)\n}\n\n/**\n * Create an event-free {@link LoggerManagerInterface} — a §9 registry of named loggers plus\n * a convenience fan-out. It mints + stores {@link LoggerInterface}s keyed by name (its\n * defaults flowing into each), looks them up, removes them, and broadcasts a one-off log to\n * every registered logger.\n *\n * @param options - See {@link LoggerManagerOptions}\n * @returns A {@link LoggerManagerInterface}\n *\n * @remarks\n * - **Defaults flow in.** `options.level` / `sink` / `styler` / `limit` / `silent` are the\n * defaults flowed into every `register`ed logger unless that call's options override them.\n * - **Event-free.** The manager carries NO emitter (each registered logger owns its own\n * observable `emitter`) — it is a pure registry.\n *\n * @example\n * ```ts\n * import { createLoggerManager } from '@src/core'\n *\n * const loggers = createLoggerManager({ level: 'warn' })\n * loggers.register('http')\n * loggers.register('db', { level: 'debug' }) // overrides the default\n * loggers.warn('slow', { ms: 900 }) // fans out to both\n * ```\n */\nexport function createLoggerManager(options?: LoggerManagerOptions): LoggerManagerInterface {\n\treturn new LoggerManager(options)\n}\n\n/**\n * Create a lean, event-free {@link ReporterInterface} — the entry point into narrative\n * reporting. Each verb (`section` / `step` / `timing` / `status` / `table` / `tree` / `box` /\n * `line` / `blank`) formats through the shared styler + the pure layout renderers and writes to\n * the sink — human / build-run narration over the SAME substrate the logger uses.\n *\n * @param options - See {@link ReporterOptions}\n * @returns A {@link ReporterInterface}\n *\n * @remarks\n * - **One styler, one sink.** `options.styler` defaults to {@link createStyler} (ANSI) and\n * `options.sink` to {@link createConsoleSink} (the snapshotted, level-routing console sink) —\n * no second colorizer. A `status('error', …)` routes to the sink's error stream.\n * - **Width-aware.** `options.width` (default {@link DEFAULT_WIDTH}) sizes `section` and a\n * `box` with no explicit width; the renderers align on VISIBLE width so styled content keeps\n * its columns.\n * - **Event-free (§13).** The reporter carries no emitter — a pure formatting front-end, like\n * the renderers and `Scheduler`. Reach for a {@link createLogger} when you need observable,\n * leveled, transportable records instead.\n *\n * @example\n * ```ts\n * import { createReporter } from '@src/core'\n *\n * const reporter = createReporter()\n * reporter.section('Build')\n * reporter.step('bundling', { index: 2, total: 5 }) // [2/5] bundling\n * reporter.status('success', 'built in 1.2s') // ✔ built in 1.2s\n *\n * // Disable color (a non-TTY) — every line is plain.\n * const plain = createReporter({ styler: createStyler({ enabled: false }) })\n * ```\n */\nexport function createReporter(options?: ReporterOptions): ReporterInterface {\n\treturn new Reporter(options)\n}\n\n/**\n * Create an observable {@link CaptureInterface} — console interception on the READ side. While\n * `active`, every configured `console.*` call is captured as a frozen\n * {@link import('./types.js').CapturedMessage}, buffered (total + by level, bounded), emitted on\n * `capture`, and — per options — mirrored to the real console and/or forwarded to a\n * {@link SinkInterface}.\n *\n * @param options - See {@link CaptureOptions}\n * @returns A {@link CaptureInterface} (inactive until `start()`)\n *\n * @remarks\n * - **Snapshot-at-start — no capture loop.** `start()` snapshots the CURRENT `console[level]` per\n * configured level, then patches; the mirror writes through that snapshot. Our OWN console sink\n * output (the Logger / Reporter, which snapshot `console` at creation) is never recaptured —\n * `Capture` catches THIRD-PARTY `console.*`, not our writes. Create your loggers FIRST.\n * - **PROCESS-GLOBAL + NON-REENTRANT.** It patches the one global `console`, so at most ONE\n * capture may be active at a time; two concurrent captures interleave and clobber each other's\n * restore. Prefer {@link withCapture} for a scoped, self-restoring capture.\n * - **Bounded.** `options.limit` (default {@link import('./constants.js').DEFAULT_CAPTURE_LIMIT})\n * caps both the total buffer and each by-level bucket; never unbounded.\n *\n * @example\n * ```ts\n * import { createCapture } from '@src/core'\n *\n * const capture = createCapture({ levels: ['warn', 'error'] })\n * capture.start()\n * console.error('boom') // captured, NOT mirrored (mirror defaults to false)\n * capture.messages('error') // [{ level: 'error', text: 'boom', time: … }]\n * capture.stop()\n * ```\n */\nexport function createCapture(options?: CaptureOptions): CaptureInterface {\n\treturn new Capture(options)\n}\n\n/**\n * Create a self-driving, observable {@link SpinnerInterface} — a live activity spinner. `start()`\n * arms a periodic timer that advances a glyph cycle, writing each `\\r` + frame line to its sink and\n * emitting it on `frame`; `success` / `failure` commit a final `✔` / `✖` line. The leading `\\r` is the\n * sink's to redraw on — a TTY sink (C-g) overwrites for a smooth animation, a plain sink (C-f)\n * degrades to a fresh line.\n *\n * @param options - See {@link SpinnerOptions}\n * @returns A {@link SpinnerInterface} (inactive until `start()`)\n *\n * @remarks\n * - **Universal + leak-free.** Built on `setInterval` + the one styler + the one sink (no `node:*`,\n * no `process.stdout`); the timer is ALWAYS cleared on `success` / `failure` / `stop` / `destroy`, so\n * it never leaks. `start()` is idempotent (no second timer while `active`).\n * - **Observable (§13).** Subscribe `spinner.emitter.on('frame', …)` to mirror the animation without\n * a terminal; `start` / `stop` bracket the timer lifecycle. `options.sink` defaults to\n * {@link createConsoleSink}, `options.styler` to {@link createStyler} (ANSI).\n *\n * @example\n * ```ts\n * import { createSpinner } from '@src/core'\n *\n * const spinner = createSpinner({ message: 'building' })\n * spinner.start()\n * spinner.success('built in 1.2s') // ✔ built in 1.2s — timer cleared, line committed\n * ```\n */\nexport function createSpinner(options?: SpinnerOptions): SpinnerInterface {\n\treturn new Spinner(options)\n}\n\n/**\n * Create an update-driven, observable {@link ProgressInterface} — a live progress bar. Each\n * `update(current)` recomputes the bar, writes `\\r` + bar to its sink, and emits `{ current, total }`\n * on `update`; `complete` / `failure` commit a final line. The leading `\\r` is the sink's to redraw on —\n * a TTY sink (C-g) overwrites, a plain sink (C-f) degrades to a fresh line. NO self-timer — the caller\n * drives the bar.\n *\n * @param options - See {@link ProgressOptions} (`total` is required)\n * @returns A {@link ProgressInterface}\n *\n * @remarks\n * - **Universal + update-driven.** Built on the one styler + the one sink (no `node:*`, no\n * `process.stdout`); progress advances only when the caller reports it. `current` is always clamped\n * to `[0, total]`. `options.sink` defaults to {@link createConsoleSink}, `options.styler` to\n * {@link createStyler} (ANSI).\n * - **Observable (§13).** Subscribe `progress.emitter.on('update', …)` to mirror progress without a\n * terminal; `complete` signals a successful finish.\n *\n * @example\n * ```ts\n * import { createProgress } from '@src/core'\n *\n * const progress = createProgress({ total: 100, message: 'downloading' })\n * progress.update(40)\n * progress.complete('done')\n * ```\n */\nexport function createProgress(options: ProgressOptions): ProgressInterface {\n\treturn new Progress(options)\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tLoggerEventMap,\n\tLogFormatFunction,\n\tLoggerInterface,\n\tLoggerOptions,\n\tLogLevel,\n\tLogRecord,\n\tSinkInterface,\n\tStylerInterface,\n\tTheme,\n} from './types.js'\nimport { Emitter } from '@orkestrel/emitter'\nimport { DEFAULT_LOG_LEVEL, DEFAULT_LOG_LIMIT, DEFAULT_THEME } from './constants.js'\nimport { createConsoleSink, createStyler } from './factories.js'\nimport { formatRecord, meetsLevel } from './helpers.js'\n\n/**\n * An observable, leveled logger (AGENTS §13) — the entry point into the structured-logging\n * pipeline. Each `debug` / `info` / `warn` / `error` call builds a frozen {@link LogRecord},\n * gates it by severity, retains a bounded tail of accepted records, ALWAYS emits it on\n * `entry` (the transport seam), and — unless `silent` — formats it into a styled line and\n * writes it to its {@link SinkInterface}.\n *\n * @remarks\n * - **Record + event = transport (§13).** An accepted record is frozen and emitted on\n * `entry` BEFORE anything else observable — every file / JSON / remote transport rides\n * `emitter.on('entry')`. The event fires even when `silent`: silence suppresses only the\n * SINK WRITE, never the record or the event, so transports keep flowing.\n * - **Leveled gate.** A record whose {@link LogLevel} is below the logger's `level` threshold\n * is dropped ENTIRELY — no record built past the level check, no event, no retention, no\n * write (see {@link meetsLevel}).\n * - **Bounded retention.** Accepted records accrue in a ring capped at `limit` (default\n * {@link DEFAULT_LOG_LIMIT}); the oldest is dropped when full. `entries()` returns a copy,\n * oldest first; `clear()` empties it. NEVER unbounded (scsr's leak).\n * - **Styled write, orthogonal to level.** The line ({@link formatRecord}) is colored through\n * the injected `styler` (the ANSI default, or a browser `%c` styler at C-f) — a level only\n * chooses a label color; styling is not a level. A disabled styler yields a plain line.\n * - **Snapshotted sink.** The default {@link createConsoleSink} writes to the `console`\n * methods captured at creation, so a later `Capture` patching `console` can't loop the\n * sink's output back into itself.\n *\n * @example\n * ```ts\n * const logger = new Logger({ name: 'http', level: 'info' })\n * logger.emitter.on('entry', (record) => archive(record)) // transport hook\n * logger.info('request', { method: 'GET', path: '/' }) // styled line to the console sink\n * logger.debug('verbose') // dropped — below the `info` threshold\n * logger.entries() // [the info record]\n * ```\n */\nexport class Logger implements LoggerInterface {\n\t// The PUSH observation surface (§13) — owned, never inherited. The emitter isolates a\n\t// listener throw (routing it to the `error` handler), so a buggy transport can never\n\t// escape into a log call.\n\treadonly #emitter: Emitter<LoggerEventMap>\n\treadonly #level: LogLevel\n\treadonly #sink: SinkInterface\n\treadonly #styler: StylerInterface\n\treadonly #theme: Theme\n\treadonly #format: LogFormatFunction\n\treadonly #limit: number\n\treadonly #silent: boolean\n\t// The bounded retention ring — accepted records, oldest first, capped at #limit.\n\treadonly #entries: LogRecord[] = []\n\treadonly name?: string\n\n\tconstructor(options?: LoggerOptions) {\n\t\tthis.#emitter = new Emitter<LoggerEventMap>({\n\t\t\t...(options?.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options?.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t\tthis.#level = options?.level ?? DEFAULT_LOG_LEVEL\n\t\tif (options?.name !== undefined) this.name = options.name\n\t\tthis.#sink = options?.sink ?? createConsoleSink()\n\t\tthis.#styler = options?.styler ?? createStyler()\n\t\tthis.#theme = options?.theme ?? DEFAULT_THEME\n\t\tthis.#format = options?.format ?? formatRecord\n\t\tthis.#limit = options?.limit ?? DEFAULT_LOG_LIMIT\n\t\tthis.#silent = options?.silent ?? false\n\t}\n\n\tget emitter(): EmitterInterface<LoggerEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget level(): LogLevel {\n\t\treturn this.#level\n\t}\n\n\tdebug(message: string, data?: Record<string, unknown>): void {\n\t\tthis.#log('debug', message, data)\n\t}\n\n\tinfo(message: string, data?: Record<string, unknown>): void {\n\t\tthis.#log('info', message, data)\n\t}\n\n\twarn(message: string, data?: Record<string, unknown>): void {\n\t\tthis.#log('warn', message, data)\n\t}\n\n\terror(message: string, data?: Record<string, unknown>): void {\n\t\tthis.#log('error', message, data)\n\t}\n\n\tentries(): readonly LogRecord[] {\n\t\treturn [...this.#entries]\n\t}\n\n\tclear(): void {\n\t\tthis.#entries.length = 0\n\t}\n\n\tdestroy(): void {\n\t\tthis.#entries.length = 0\n\t\tthis.#emitter.destroy()\n\t}\n\n\t// The single log path behind every level method: gate by severity, then for an accepted\n\t// record build it frozen, retain it (bounded), emit `entry` ALWAYS, and write the styled\n\t// line unless silent. A dropped (below-threshold) record does nothing observable.\n\t#log(level: LogLevel, message: string, data: Record<string, unknown> | undefined): void {\n\t\tif (!meetsLevel(this.#level, level)) return\n\t\tconst record = this.#record(level, message, data)\n\t\tthis.#retain(record)\n\t\t// The transport seam — fires even when silent (silence suppresses only the write).\n\t\tthis.#emitter.emit('entry', record)\n\t\tif (this.#silent) return\n\t\t// Pass the level so a stream-aware sink (the default console sink, the C-g TTY sink)\n\t\t// can route error/warn to the right stream; a plain sink ignores it.\n\t\tthis.#sink.write(this.#format(record, this.#styler, this.#theme), level)\n\t}\n\n\t// Build the immutable, serializable record — `name` / `data` omitted when absent so the\n\t// frozen value carries only what was supplied. Frozen so a consumer (or transport) can\n\t// never mutate it after the fact.\n\t#record(level: LogLevel, message: string, data: Record<string, unknown> | undefined): LogRecord {\n\t\treturn Object.freeze({\n\t\t\tlevel,\n\t\t\tmessage,\n\t\t\ttime: Date.now(),\n\t\t\t...(this.name === undefined ? {} : { name: this.name }),\n\t\t\t...(data === undefined ? {} : { data: Object.freeze({ ...data }) }),\n\t\t})\n\t}\n\n\t// Push onto the bounded ring, evicting the oldest when at capacity — the retention stays\n\t// capped at #limit, never growing without bound.\n\t#retain(record: LogRecord): void {\n\t\tthis.#entries.push(record)\n\t\tif (this.#entries.length > this.#limit) this.#entries.shift()\n\t}\n}\n"],"mappings":";;;;;;;;AAwBA,IAAa,mBAAwE,OAAO,OAAO;CAClG,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,aAAa;CACb,WAAW;CACX,aAAa;CACb,cAAc;CACd,YAAY;CACZ,eAAe;CACf,YAAY;CACZ,aAAa;AACd,CAAC;;;;;AAMD,IAAa,mBAAwE,OAAO,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AAKC,QAAQ,KAAK,GAAG;EACrC,MAAM,SAAS,KAAKS,QAAQ,OAAO,SAAS,IAAI;EAChD,KAAKC,QAAQ,MAAM;EAEnB,KAAKX,SAAS,KAAK,SAAS,MAAM;EAClC,IAAI,KAAKO,SAAS;EAGlB,KAAKL,MAAM,MAAM,KAAKG,QAAQ,QAAQ,KAAKF,SAAS,KAAKC,MAAM,GAAG,KAAK;CACxE;CAKA,QAAQ,OAAiB,SAAiB,MAAsD;EAC/F,OAAO,OAAO,OAAO;GACpB;GACA;GACA,MAAM,KAAK,IAAI;GACf,GAAI,KAAK,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK;GACrD,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,OAAO,OAAO,EAAE,GAAG,KAAK,CAAC,EAAE;EAClE,CAAC;CACF;CAIA,QAAQ,QAAyB;EAChC,KAAKI,SAAS,KAAK,MAAM;EACzB,IAAI,KAAKA,SAAS,SAAS,KAAKF,QAAQ,KAAKE,SAAS,MAAM;CAC7D;AACD"}
|
|
@@ -1927,8 +1927,8 @@ export declare interface SinkInterface {
|
|
|
1927
1927
|
* - **Self-driving but deterministically testable.** `start()` arms a `setInterval` that calls
|
|
1928
1928
|
* {@link tick} each `interval`; each {@link tick} builds the styled `glyph + message` line for the
|
|
1929
1929
|
* current frame, emits it on `frame`, writes `'\r' + line` to the sink, then advances the frame
|
|
1930
|
-
* index (wrapping). A test drives frames by calling {@link tick} directly
|
|
1931
|
-
* the timer arms / clears
|
|
1930
|
+
* index (wrapping). A test drives frames by calling {@link tick} directly, or arms a real short
|
|
1931
|
+
* `interval` and proves the timer arms / clears through the sink it writes to.
|
|
1932
1932
|
* - **Leak-free timer.** The interval is ALWAYS cleared on {@link success} / {@link failure} /
|
|
1933
1933
|
* {@link stop} / {@link destroy} — `#handle` is the single source of `active`, set on arm and unset
|
|
1934
1934
|
* on clear, so a spinner never leaks a running interval.
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -1927,8 +1927,8 @@ export declare interface SinkInterface {
|
|
|
1927
1927
|
* - **Self-driving but deterministically testable.** `start()` arms a `setInterval` that calls
|
|
1928
1928
|
* {@link tick} each `interval`; each {@link tick} builds the styled `glyph + message` line for the
|
|
1929
1929
|
* current frame, emits it on `frame`, writes `'\r' + line` to the sink, then advances the frame
|
|
1930
|
-
* index (wrapping). A test drives frames by calling {@link tick} directly
|
|
1931
|
-
* the timer arms / clears
|
|
1930
|
+
* index (wrapping). A test drives frames by calling {@link tick} directly, or arms a real short
|
|
1931
|
+
* `interval` and proves the timer arms / clears through the sink it writes to.
|
|
1932
1932
|
* - **Leak-free timer.** The interval is ALWAYS cleared on {@link success} / {@link failure} /
|
|
1933
1933
|
* {@link stop} / {@link destroy} — `#handle` is the single source of `active`, set on arm and unset
|
|
1934
1934
|
* on clear, so a spinner never leaks a running interval.
|
package/dist/src/core/index.js
CHANGED
|
@@ -1625,8 +1625,8 @@ var Reporter = class {
|
|
|
1625
1625
|
* - **Self-driving but deterministically testable.** `start()` arms a `setInterval` that calls
|
|
1626
1626
|
* {@link tick} each `interval`; each {@link tick} builds the styled `glyph + message` line for the
|
|
1627
1627
|
* current frame, emits it on `frame`, writes `'\r' + line` to the sink, then advances the frame
|
|
1628
|
-
* index (wrapping). A test drives frames by calling {@link tick} directly
|
|
1629
|
-
* the timer arms / clears
|
|
1628
|
+
* index (wrapping). A test drives frames by calling {@link tick} directly, or arms a real short
|
|
1629
|
+
* `interval` and proves the timer arms / clears through the sink it writes to.
|
|
1630
1630
|
* - **Leak-free timer.** The interval is ALWAYS cleared on {@link success} / {@link failure} /
|
|
1631
1631
|
* {@link stop} / {@link destroy} — `#handle` is the single source of `active`, set on arm and unset
|
|
1632
1632
|
* on clear, so a spinner never leaks a running interval.
|