@oh-my-pi/pi-utils 15.1.1 → 15.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Try to parse JSON, returning null on failure.
3
+ */
4
+ export declare function tryParseJson<T = unknown>(content: string): T | null;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Replace the active log transports. Pass `console: true, file: false` for
3
+ * long-running services (the auth broker, etc.) that want their structured
4
+ * logs piped into a process supervisor instead of the rotating file.
5
+ */
6
+ export declare function setTransports(opts: {
7
+ console?: boolean;
8
+ file?: boolean | string;
9
+ }): void;
10
+ /**
11
+ * Log an error message.
12
+ * @param message - The message to log.
13
+ * @param context - The context to log.
14
+ */
15
+ export declare function error(message: string, context?: Record<string, unknown>): void;
16
+ /**
17
+ * Log a warning message.
18
+ * @param message - The message to log.
19
+ * @param context - The context to log.
20
+ */
21
+ export declare function warn(message: string, context?: Record<string, unknown>): void;
22
+ /**
23
+ * Log an informational message.
24
+ * @param message - The message to log.
25
+ * @param context - The context to log.
26
+ */
27
+ export declare function info(message: string, context?: Record<string, unknown>): void;
28
+ /**
29
+ * Log a debug message.
30
+ * @param message - The message to log.
31
+ * @param context - The context to log.
32
+ */
33
+ export declare function debug(message: string, context?: Record<string, unknown>): void;
34
+ /**
35
+ * Print collected timings as an indented tree.
36
+ * Each span shows wall duration; parents with children also show "(self)" for unattributed time.
37
+ * Sibling spans are sorted by start time. Spans whose intervals overlap with siblings ran in parallel.
38
+ */
39
+ export declare function printTimings(): void;
40
+ /**
41
+ * Begin recording startup timings under a new root span.
42
+ * Idempotent: a second call while already recording is a no-op so that side-effect
43
+ * starters (see module-timer.ts) and explicit starters (main.ts) can coexist.
44
+ */
45
+ export declare function startTiming(): void;
46
+ /**
47
+ * Record an externally-measured span as a leaf child of the active span (or root
48
+ * when no span is active). Used by the module-load timing plugin to splice load
49
+ * events into the tree retroactively.
50
+ */
51
+ export declare function recordModuleLoadSpan(path: string, start: number, durationMs: number): void;
52
+ /**
53
+ * End timing window and clear buffers.
54
+ */
55
+ export declare function endTiming(): void;
56
+ /**
57
+ * Time a span. Three forms:
58
+ * time(op) — point event (zero-duration breadcrumb)
59
+ * time(op, fn, ...args) — wrap fn in a span; returns fn's return value (sync or Promise)
60
+ *
61
+ * Spans nest hierarchically via AsyncLocalStorage: a child started inside another span's fn
62
+ * (even across awaits) becomes that span's child. Parallel children are recorded as siblings
63
+ * with overlapping intervals.
64
+ */
65
+ export declare function time(op: string): void;
66
+ export declare function time<T, A extends unknown[]>(op: string, fn: (...args: A) => T, ...args: A): T;
@@ -0,0 +1,11 @@
1
+ import { type AsciiRenderOptions } from "beautiful-mermaid";
2
+ export type { AsciiRenderOptions as MermaidAsciiRenderOptions };
3
+ export declare function renderMermaidAscii(source: string, options?: AsciiRenderOptions): string;
4
+ export declare function renderMermaidAsciiSafe(source: string, options?: AsciiRenderOptions): string | null;
5
+ /**
6
+ * Extract mermaid code blocks from markdown text.
7
+ */
8
+ export declare function extractMermaidBlocks(markdown: string): {
9
+ source: string;
10
+ hash: bigint | number;
11
+ }[];
@@ -0,0 +1,29 @@
1
+ export declare const SUPPORTED_IMAGE_MIME_TYPES: Set<string>;
2
+ export type ImageMetadata = {
3
+ mimeType: "image/png";
4
+ width?: number;
5
+ height?: number;
6
+ channels?: number;
7
+ hasAlpha?: boolean;
8
+ } | {
9
+ mimeType: "image/jpeg";
10
+ width?: number;
11
+ height?: number;
12
+ channels?: number;
13
+ hasAlpha?: false;
14
+ } | {
15
+ mimeType: "image/gif";
16
+ width?: number;
17
+ height?: number;
18
+ channels?: 3;
19
+ hasAlpha?: never;
20
+ } | {
21
+ mimeType: "image/webp";
22
+ width?: number;
23
+ height?: number;
24
+ channels?: number;
25
+ hasAlpha?: boolean;
26
+ };
27
+ export declare function parseImageMetadata(header: Uint8Array): ImageMetadata | null;
28
+ export declare function readImageMetadataSync(filePath: string, maxBytes?: number): ImageMetadata | null;
29
+ export declare function readImageMetadata(filePath: string, maxBytes?: number): Promise<ImageMetadata | null>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Synchronously reads up to `maxBytes` from the start of `filePath` and returns `op(header)`.
3
+ * If the file is shorter, `header` is only the bytes actually read.
4
+ */
5
+ export declare function peekFileSync<T>(filePath: string, maxBytes: number, op: (header: Uint8Array) => T): T;
6
+ /**
7
+ * Like {@link peekFileSync} but uses async I/O.
8
+ */
9
+ export declare function peekFile<T>(filePath: string, maxBytes: number, op: (header: Uint8Array) => T): Promise<T>;
@@ -0,0 +1,29 @@
1
+ export declare enum Reason {
2
+ PRE_EXIT = "pre_exit",// Pre-exit phase (not used by default)
3
+ EXIT = "exit",// Normal process exit
4
+ SIGINT = "sigint",// Ctrl-C or SIGINT
5
+ SIGTERM = "sigterm",// SIGTERM
6
+ SIGHUP = "sighup",// SIGHUP
7
+ UNCAUGHT_EXCEPTION = "uncaught_exception",// Fatal exception
8
+ UNHANDLED_REJECTION = "unhandled_rejection",// Unhandled promise rejection
9
+ MANUAL = "manual"
10
+ }
11
+ /**
12
+ * Register a process cleanup callback, to be run on shutdown, signal, or fatal error.
13
+ *
14
+ * Returns a Callback instance that can be used to cancel (unregister) or manually clean up.
15
+ * If register is called after cleanup already began, invokes callback on a microtask.
16
+ */
17
+ export declare function register(id: string, callback: (reason: Reason) => void | Promise<void>): () => void;
18
+ /**
19
+ * Runs all cleanup callbacks without exiting.
20
+ * Use this in workers or when you need to clean up but continue execution.
21
+ */
22
+ export declare function cleanup(): Promise<void>;
23
+ /**
24
+ * Runs all cleanup callbacks and exits.
25
+ *
26
+ * In main thread: waits for stdout drain, then calls process.exit().
27
+ * In workers: runs cleanup only (process.exit would kill entire process).
28
+ */
29
+ export declare function quit(code?: number): Promise<void>;
@@ -0,0 +1,35 @@
1
+ import type { Subprocess } from "bun";
2
+ export interface ShellConfig {
3
+ shell: string;
4
+ args: string[];
5
+ env: Record<string, string>;
6
+ prefix: string | undefined;
7
+ }
8
+ /**
9
+ * Strip disabled macOS malloc-stack-logging vars from `process.env` in place.
10
+ *
11
+ * macOS leaves `MallocStackLogging=0` (or similar) inherited by debug-attached
12
+ * shells. Bun's libc init then prints `MallocStackLogging: can't turn off
13
+ * malloc stack logging because it was not enabled.` to stderr for every
14
+ * subprocess. Scrubbing once at startup means every child we spawn — bash,
15
+ * bun subagents, plugin installs, ptree commands — inherits a clean env.
16
+ */
17
+ export declare function scrubProcessEnv(): void;
18
+ /**
19
+ * Resolve a basic shell (bash or sh) as fallback.
20
+ */
21
+ export declare function resolveBasicShell(): string | undefined;
22
+ /**
23
+ * Get shell configuration based on platform.
24
+ * Resolution order:
25
+ * 1. User-specified shellPath in settings.json
26
+ * 2. On Windows: Git Bash in known locations, then bash on PATH
27
+ * 3. On Unix: $SHELL if bash/zsh, then fallback paths
28
+ * 4. Fallback: sh
29
+ */
30
+ export declare function getShellConfig(customShellPath?: string): ShellConfig;
31
+ /**
32
+ * Check if a process is running.
33
+ */
34
+ export declare function isPidRunning(pid: number | Subprocess): boolean;
35
+ export declare function onProcessExit(proc: Subprocess | number, abortSignal?: AbortSignal): Promise<boolean>;
@@ -0,0 +1,18 @@
1
+ import type { HelperDelegate, HelperOptions, Template, TemplateDelegate } from "handlebars";
2
+ export type { HelperDelegate, HelperOptions, Template, TemplateDelegate };
3
+ export type PromptRenderPhase = "pre-render" | "post-render";
4
+ export interface PromptFormatOptions {
5
+ renderPhase?: PromptRenderPhase;
6
+ replaceAsciiSymbols?: boolean;
7
+ normalizeRfc2119?: boolean;
8
+ }
9
+ export declare function format(content: string, options?: PromptFormatOptions): string;
10
+ export interface TemplateContext extends Record<string, unknown> {
11
+ args?: string[];
12
+ ARGUMENTS?: string;
13
+ arguments?: string;
14
+ }
15
+ export declare function registerHelper(name: string, fn: HelperDelegate): void;
16
+ export declare function registerPartial(name: string, fn: Template): void;
17
+ export declare function compile(template: string): (context: TemplateContext) => string;
18
+ export declare function render(template: string, context?: TemplateContext): string;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Process tree management utilities for Bun subprocesses.
3
+ *
4
+ * - Track managed child processes for cleanup on shutdown (postmortem).
5
+ * - Drain stdout/stderr to avoid subprocess pipe deadlocks.
6
+ * - Cross-platform tree kill for process groups (Windows taskkill, Unix -pid).
7
+ * - Convenience helpers: captureText / execText, AbortSignal, timeouts.
8
+ */
9
+ import type { Spawn, Subprocess } from "bun";
10
+ type InMask = "pipe" | "ignore" | Buffer | Uint8Array | null;
11
+ /** A Bun subprocess with stdout/stderr always piped (stdin may vary). */
12
+ type PipedSubprocess<In extends InMask = InMask> = Subprocess<In, "pipe", "pipe">;
13
+ /**
14
+ * Base for all exceptions representing child process nonzero exit, killed, or
15
+ * cancellation.
16
+ */
17
+ export declare abstract class Exception extends Error {
18
+ readonly exitCode: number;
19
+ readonly stderr: string;
20
+ constructor(message: string, exitCode: number, stderr: string);
21
+ abstract readonly aborted: boolean;
22
+ }
23
+ /** Exception for nonzero exit codes (not cancellation). */
24
+ export declare class NonZeroExitError extends Exception {
25
+ static readonly MAX_TRACE: number;
26
+ constructor(exitCode: number, stderr: string);
27
+ get aborted(): boolean;
28
+ }
29
+ /** Exception for explicit process abortion (via signal). */
30
+ export declare class AbortError extends Exception {
31
+ readonly reason: unknown;
32
+ constructor(reason: unknown, stderr: string);
33
+ get aborted(): boolean;
34
+ }
35
+ /** Exception for process timeout. */
36
+ export declare class TimeoutError extends AbortError {
37
+ constructor(timeout: number, stderr: string);
38
+ }
39
+ /** Options for waiting for process exit and capturing output. */
40
+ export interface WaitOptions {
41
+ allowNonZero?: boolean;
42
+ allowAbort?: boolean;
43
+ stderr?: "full" | "buffer";
44
+ }
45
+ /** Result from wait and exec. */
46
+ export interface ExecResult {
47
+ stdout: string;
48
+ stderr: string;
49
+ exitCode: number | null;
50
+ ok: boolean;
51
+ exitError?: Exception;
52
+ }
53
+ /**
54
+ * ChildProcess wraps a managed subprocess, capturing stderr tail, providing
55
+ * cross-platform kill/detach logic plus AbortSignal integration.
56
+ *
57
+ * Stdout is exposed directly from the underlying Bun subprocess; consumers
58
+ * must read it (via text(), wait(), etc.) to prevent pipe deadlock.
59
+ * Stderr is eagerly drained into an internal buffer.
60
+ */
61
+ export declare class ChildProcess<In extends InMask = InMask> {
62
+ #private;
63
+ readonly proc: PipedSubprocess<In>;
64
+ readonly exposeStderr: boolean;
65
+ constructor(proc: PipedSubprocess<In>, exposeStderr: boolean);
66
+ get pid(): number;
67
+ get exited(): Promise<number>;
68
+ get exitCode(): number | null;
69
+ get exitReason(): Exception | undefined;
70
+ get killed(): boolean;
71
+ get stdin(): Bun.SpawnOptions.WritableToIO<In>;
72
+ /** Raw stdout stream. Must be consumed to prevent pipe deadlock. */
73
+ get stdout(): ReadableStream<Uint8Array<ArrayBuffer>>;
74
+ /** Optional stderr stream (only when requested in spawn options). */
75
+ get stderr(): ReadableStream<Uint8Array<ArrayBufferLike>> | undefined;
76
+ get exitedCleanly(): Promise<number>;
77
+ /** Returns the truncated stderr tail (last 32KB). */
78
+ peekStderr(): string;
79
+ nothrow(): this;
80
+ kill(reason?: Exception): void;
81
+ text(): Promise<string>;
82
+ blob(): Promise<Blob>;
83
+ json(): Promise<unknown>;
84
+ arrayBuffer(): Promise<ArrayBuffer>;
85
+ bytes(): Promise<Uint8Array>;
86
+ wait(opts?: WaitOptions): Promise<ExecResult>;
87
+ attachSignal(signal: AbortSignal): void;
88
+ attachTimeout(ms: number): void;
89
+ [Symbol.dispose](): void;
90
+ }
91
+ /** Options for child spawn. Always pipes stdout/stderr. */
92
+ type ChildSpawnOptions<In extends InMask = InMask> = Omit<Spawn.SpawnOptions<In, "pipe", "pipe">, "stdout" | "stderr" | "detached"> & {
93
+ signal?: AbortSignal;
94
+ detached?: boolean;
95
+ stderr?: "full" | null;
96
+ };
97
+ /** Spawn a child process with piped stdout/stderr. */
98
+ export declare function spawn<In extends InMask = InMask>(cmd: string[], opts?: ChildSpawnOptions<In>): ChildProcess<In>;
99
+ /** Options for exec. */
100
+ export interface ExecOptions extends Omit<ChildSpawnOptions, "stderr" | "stdin">, WaitOptions {
101
+ input?: string | Buffer | Uint8Array;
102
+ }
103
+ /** Spawn, wait, and return captured output. */
104
+ export declare function exec(cmd: string[], opts?: ExecOptions): Promise<ExecResult>;
105
+ type SignalValue = AbortSignal | number | null | undefined;
106
+ /** Combine AbortSignals and timeout values into a single signal. */
107
+ export declare function combineSignals(...signals: SignalValue[]): AbortSignal | undefined;
108
+ export {};
@@ -0,0 +1,93 @@
1
+ /**
2
+ * A fixed-capacity circular buffer that supports efficient push/pop/shift/unshift operations.
3
+ * When the buffer is full, adding new items overwrites the oldest items (FIFO behavior).
4
+ *
5
+ * @template T The type of elements stored in the buffer.
6
+ */
7
+ export declare class RingBuffer<T> {
8
+ #private;
9
+ readonly capacity: number;
10
+ /**
11
+ * Creates a new ring buffer with the specified capacity.
12
+ *
13
+ * @param capacity - The maximum number of elements the buffer can hold. Must be positive.
14
+ */
15
+ constructor(capacity: number);
16
+ /**
17
+ * The number of elements currently in the buffer.
18
+ */
19
+ get length(): number;
20
+ /**
21
+ * Whether the buffer is at full capacity.
22
+ */
23
+ get isFull(): boolean;
24
+ /**
25
+ * Whether the buffer is empty (contains no elements).
26
+ */
27
+ get isEmpty(): boolean;
28
+ /**
29
+ * Adds an item to the end of the buffer.
30
+ * If the buffer is full, the oldest item is overwritten and returned.
31
+ *
32
+ * @param item - The item to add.
33
+ * @returns The overwritten item if the buffer was full, otherwise `undefined`.
34
+ */
35
+ push(item: T): T | undefined;
36
+ /**
37
+ * Removes and returns the first (oldest) item from the buffer.
38
+ *
39
+ * @returns The removed item, or `undefined` if the buffer is empty.
40
+ */
41
+ shift(): T | undefined;
42
+ /**
43
+ * Removes and returns the last (newest) item from the buffer.
44
+ *
45
+ * @returns The removed item, or `undefined` if the buffer is empty.
46
+ */
47
+ pop(): T | undefined;
48
+ /**
49
+ * Adds an item to the beginning of the buffer.
50
+ * If the buffer is full, the newest item is overwritten and returned.
51
+ *
52
+ * @param item - The item to add.
53
+ * @returns The overwritten item if the buffer was full, otherwise `undefined`.
54
+ */
55
+ unshift(item: T): T | undefined;
56
+ /**
57
+ * Returns the element at the specified index without removing it.
58
+ * Supports negative indices (e.g., `-1` for the last element).
59
+ *
60
+ * @param index - The zero-based index, or negative index from the end.
61
+ * @returns The element at the index, or `undefined` if the index is out of bounds.
62
+ */
63
+ at(index: number): T | undefined;
64
+ /**
65
+ * Returns the first (oldest) element without removing it.
66
+ *
67
+ * @returns The first element, or `undefined` if the buffer is empty.
68
+ */
69
+ peek(): T | undefined;
70
+ /**
71
+ * Returns the last (newest) element without removing it.
72
+ *
73
+ * @returns The last element, or `undefined` if the buffer is empty.
74
+ */
75
+ peekBack(): T | undefined;
76
+ /**
77
+ * Removes all elements from the buffer, resetting it to an empty state.
78
+ */
79
+ clear(): void;
80
+ /**
81
+ * Returns an iterator that yields elements in logical order (oldest to newest).
82
+ * Allows the buffer to be used with `for...of` loops and spread syntax.
83
+ *
84
+ * @yields Elements in FIFO order.
85
+ */
86
+ [Symbol.iterator](): Iterator<T>;
87
+ /**
88
+ * Creates a new array containing all elements in logical order (oldest to newest).
89
+ *
90
+ * @returns A new array with all buffer elements.
91
+ */
92
+ toArray(): T[];
93
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Strip ANSI escape sequences, remove control characters / lone surrogates,
3
+ * and normalize line endings.
4
+ *
5
+ * Bun-native implementation of the former native `sanitizeText` (see
6
+ * `crates/pi-natives/src/text.rs::sanitize_text`). JavaScript strings are
7
+ * already UTF-16 code-unit arrays. `toWellFormed()` handles the uncommon
8
+ * malformed path; when it changes the input, replacement characters are
9
+ * dropped and the normalized result goes through the well-formed sanitizer.
10
+ *
11
+ * Fast path: well-formed input with no controls or ANSI returns the original
12
+ * string after the control probe.
13
+ */
14
+ export declare function sanitizeText(text: string): string;
@@ -0,0 +1,25 @@
1
+ type Snowflake = string & {
2
+ readonly __brand: unique symbol;
3
+ };
4
+ declare namespace Snowflake {
5
+ const PATTERN: RegExp;
6
+ const EPOCH_TIMESTAMP = 1420070400000;
7
+ const MAX_SEQUENCE = 4194303;
8
+ function formatParts(dt: number, seq: number): Snowflake;
9
+ class Source {
10
+ #private;
11
+ constructor(sequence?: number);
12
+ get sequence(): number;
13
+ set sequence(v: number);
14
+ reset(): void;
15
+ generate(timestamp: number): Snowflake;
16
+ }
17
+ function next(timestamp?: number): Snowflake;
18
+ function valid(value: string): value is Snowflake;
19
+ function lowerbound(timelike: Date | number | Snowflake): Snowflake;
20
+ function upperbound(timelike: Date | number | Snowflake): Snowflake;
21
+ function getSequence(value: Snowflake): number;
22
+ function getTimestamp(value: Snowflake): number;
23
+ function getDate(value: Snowflake): Date;
24
+ }
25
+ export { Snowflake };
@@ -0,0 +1,68 @@
1
+ export declare function readLines(stream: ReadableStream<Uint8Array>, signal?: AbortSignal): AsyncGenerator<Uint8Array>;
2
+ export declare function readJsonl<T>(stream: ReadableStream<Uint8Array>, signal?: AbortSignal): AsyncGenerator<T>;
3
+ /**
4
+ * Stream parsed JSON objects from SSE `data:` lines.
5
+ *
6
+ * Thin wrapper over {@link readSseEvents}: yields one parsed JSON value per
7
+ * dispatched SSE event, skipping events with empty `data` and stopping at the
8
+ * OpenAI-style `[DONE]` sentinel. If your consumer doesn't care about `event:`
9
+ * names or doesn't need a custom parse step, use this; otherwise call
10
+ * `readSseEvents` directly.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * for await (const obj of readSseJson(response.body!)) {
15
+ * console.log(obj);
16
+ * }
17
+ * ```
18
+ */
19
+ export type SseEventObserver = (event: ServerSentEvent) => void;
20
+ export declare function readSseJson<T>(stream: ReadableStream<Uint8Array>, signal?: AbortSignal, onEvent?: SseEventObserver): AsyncGenerator<T>;
21
+ /**
22
+ * A single Server-Sent Event dispatched on a blank-line boundary.
23
+ *
24
+ * - `event` is the value of the most recent `event:` field, or `null` if none.
25
+ * - `data` is the concatenation (joined by `\n`) of every `data:` field in the
26
+ * event, exactly as required by the SSE spec.
27
+ * - `raw` is the list of decoded non-empty lines that made up the event,
28
+ * preserved for diagnostic context (error reporting, debugging). The
29
+ * dispatching blank line is not included.
30
+ */
31
+ export interface ServerSentEvent {
32
+ event: string | null;
33
+ data: string;
34
+ raw: string[];
35
+ }
36
+ /**
37
+ * Stream raw Server-Sent Events from an HTTP response body.
38
+ *
39
+ * Yields one `ServerSentEvent` per blank-line dispatch. The consumer is
40
+ * responsible for parsing `data` (e.g. JSON, plain text, error envelope).
41
+ * Use `readSseJson` instead when every event is a single `data:` JSON object
42
+ * and you don't need access to the `event:` field.
43
+ *
44
+ * Internally backed by a Buffer-based line reader (`ConcatSink`) so chunk
45
+ * concatenation is O(n) and never triggers per-line string slicing of the
46
+ * accumulated buffer.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * for await (const sse of readSseEvents(response.body!)) {
51
+ * if (sse.event === "ping") continue;
52
+ * const obj = JSON.parse(sse.data);
53
+ * }
54
+ * ```
55
+ */
56
+ export declare function readSseEvents(stream: ReadableStream<Uint8Array>, signal?: AbortSignal): AsyncGenerator<ServerSentEvent>;
57
+ /**
58
+ * Parse a complete JSONL string, skipping malformed lines instead of throwing.
59
+ *
60
+ * Uses `Bun.JSONL.parseChunk` internally. On parse errors, the malformed
61
+ * region is skipped up to the next newline and parsing continues.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const entries = parseJsonlLenient<MyType>(fileContents);
66
+ * ```
67
+ */
68
+ export declare function parseJsonlLenient<T>(buffer: string): T[];
@@ -0,0 +1,9 @@
1
+ export declare const MIN_TAB_WIDTH = 1;
2
+ export declare const MAX_TAB_WIDTH = 16;
3
+ export declare const DEFAULT_TAB_WIDTH = 3;
4
+ export declare function getDefaultTabWidth(): number;
5
+ export declare function setDefaultTabWidth(width: number): void;
6
+ /**
7
+ * Visible tab width in columns for `file` (from `.editorconfig` + default), or the default when `file` is omitted.
8
+ */
9
+ export declare function getIndentation(file?: string | null, projectDir?: string | null): number;
@@ -0,0 +1,14 @@
1
+ export declare class TempDir {
2
+ #private;
3
+ private constructor();
4
+ static createSync(prefix?: string): TempDir;
5
+ static create(prefix?: string): Promise<TempDir>;
6
+ path(): string;
7
+ absolute(): string;
8
+ remove(): Promise<void>;
9
+ removeSync(): void;
10
+ toString(): string;
11
+ join(...paths: string[]): string;
12
+ [Symbol.asyncDispose](): Promise<void>;
13
+ [Symbol.dispose](): void;
14
+ }
@@ -0,0 +1,3 @@
1
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
2
+ export declare function asRecord(value: unknown): Record<string, unknown> | null;
3
+ export declare function toError(value: unknown): Error;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Cache policy for which lookups.
3
+ */
4
+ export declare const enum WhichCachePolicy {
5
+ /**
6
+ * Use cached result if available.
7
+ */
8
+ Cached = 0,
9
+ /**
10
+ * Bypass cache and perform a new lookup.
11
+ */
12
+ Bypass = 1,
13
+ /**
14
+ * Always update cache.
15
+ */
16
+ Fresh = 2,
17
+ /**
18
+ * Read-only, serves from cache if present, but doesn't write.
19
+ */
20
+ ReadOnly = 3
21
+ }
22
+ export interface WhichOptions extends Bun.WhichOptions {
23
+ /**
24
+ * Cache policy for the lookup.
25
+ * Defaults to `WhichCachePolicy.Fresh`.
26
+ */
27
+ cache?: WhichCachePolicy;
28
+ }
29
+ export declare const whichFresh: typeof Bun.which;
30
+ /**
31
+ * Locate binary on PATH (with flexible caching).
32
+ *
33
+ * @param command - Binary name to resolve
34
+ * @param options - Bun.WhichOptions plus `cache` control
35
+ * @returns Filesystem path if found, else null
36
+ */
37
+ export declare function $which(command: string, options?: WhichOptions): string | null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "15.1.1",
4
+ "version": "15.1.3",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
@@ -21,7 +21,7 @@
21
21
  "streams"
22
22
  ],
23
23
  "main": "./src/index.ts",
24
- "types": "./src/index.ts",
24
+ "types": "./dist/types/index.d.ts",
25
25
  "scripts": {
26
26
  "check": "biome check . && bun run check:types",
27
27
  "check:types": "tsgo -p tsconfig.json --noEmit",
@@ -31,28 +31,29 @@
31
31
  "fmt": "biome format --write ."
32
32
  },
33
33
  "dependencies": {
34
+ "@oh-my-pi/pi-natives": "15.1.3",
34
35
  "beautiful-mermaid": "^1.1.3",
35
36
  "handlebars": "^4.7.9",
36
37
  "winston": "^3.19.0",
37
38
  "winston-daily-rotate-file": "^5.0.0"
38
39
  },
39
40
  "devDependencies": {
40
- "@types/bun": "^1.3.14",
41
- "@oh-my-pi/pi-natives": "15.1.1"
41
+ "@types/bun": "^1.3.14"
42
42
  },
43
43
  "engines": {
44
44
  "bun": ">=1.3.14"
45
45
  },
46
46
  "files": [
47
- "src"
47
+ "src",
48
+ "dist/types"
48
49
  ],
49
50
  "exports": {
50
51
  ".": {
51
- "types": "./src/index.ts",
52
+ "types": "./dist/types/index.d.ts",
52
53
  "import": "./src/index.ts"
53
54
  },
54
55
  "./*": {
55
- "types": "./src/*.ts",
56
+ "types": "./dist/types/*.d.ts",
56
57
  "import": "./src/*.ts"
57
58
  },
58
59
  "./*.js": "./src/*.ts"