@sayknow-cli/utils 0.3.16 → 0.4.1
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/package.json +6 -7
- package/src/dirs.ts +10 -4
- package/src/postmortem.ts +69 -9
- package/src/procmgr.ts +4 -1
- package/dist/types/abortable.d.ts +0 -27
- package/dist/types/async.d.ts +0 -6
- package/dist/types/broken-pipe.d.ts +0 -27
- package/dist/types/cli.d.ts +0 -126
- package/dist/types/color.d.ts +0 -82
- package/dist/types/dirs.d.ts +0 -163
- package/dist/types/env.d.ts +0 -68
- package/dist/types/fetch-retry.d.ts +0 -80
- package/dist/types/format.d.ts +0 -37
- package/dist/types/frontmatter.d.ts +0 -25
- package/dist/types/fs-error.d.ts +0 -31
- package/dist/types/glob.d.ts +0 -28
- package/dist/types/hook-fetch.d.ts +0 -16
- package/dist/types/index.d.ts +0 -31
- package/dist/types/json.d.ts +0 -4
- package/dist/types/logger.d.ts +0 -66
- package/dist/types/mermaid-ascii.d.ts +0 -11
- package/dist/types/mime.d.ts +0 -29
- package/dist/types/peek-file.d.ts +0 -9
- package/dist/types/postmortem.d.ts +0 -29
- package/dist/types/procmgr.d.ts +0 -35
- package/dist/types/prompt.d.ts +0 -18
- package/dist/types/ptree.d.ts +0 -108
- package/dist/types/ring.d.ts +0 -93
- package/dist/types/safe-stderr.d.ts +0 -1
- package/dist/types/sanitize-text.d.ts +0 -14
- package/dist/types/snowflake.d.ts +0 -25
- package/dist/types/spawn-env.d.ts +0 -4
- package/dist/types/stream.d.ts +0 -68
- package/dist/types/tab-spacing.d.ts +0 -12
- package/dist/types/temp.d.ts +0 -14
- package/dist/types/type-guards.d.ts +0 -3
- package/dist/types/which.d.ts +0 -39
package/dist/types/env.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export { filterProcessEnv, isSafeEnvName, isSafeEnvValue } from "./spawn-env";
|
|
2
|
-
/**
|
|
3
|
-
* Strict shell-identifier shape. Used for dotenv keys we accept into
|
|
4
|
-
* `Bun.env` — those should be referenceable as `$NAME` from POSIX shells,
|
|
5
|
-
* so we reject anything outside `[A-Za-z_][A-Za-z0-9_]*`.
|
|
6
|
-
*/
|
|
7
|
-
export declare function isValidEnvName(name: string): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Parses simple POSIX shell environment assignments from files such as
|
|
10
|
-
* ~/.zshrc without executing user shell code. Supports `export KEY=value` and
|
|
11
|
-
* `KEY=value`, including single/double quoted literal values. Dynamic shell
|
|
12
|
-
* expressions are intentionally ignored because evaluating startup files would
|
|
13
|
-
* run arbitrary code during CLI startup.
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseShellEnvFile(filePath: string): Record<string, string>;
|
|
16
|
-
/**
|
|
17
|
-
* Parses a .env file synchronously and extracts key-value string pairs.
|
|
18
|
-
* Ignores lines that are empty or start with '#'. Trims whitespace.
|
|
19
|
-
* Allows values to be quoted with single or double quotes.
|
|
20
|
-
* Returns an object of key-value pairs.
|
|
21
|
-
*/
|
|
22
|
-
export declare function parseEnvFile(filePath: string): Record<string, string>;
|
|
23
|
-
export declare function $inheritedEnv(name: string): string | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Intentional re-export of Bun.env.
|
|
26
|
-
*
|
|
27
|
-
* All users should import this env module (import { $env } from "@sayknow-cli/utils")
|
|
28
|
-
* before using environment variables. This ensures that .env files have been loaded and
|
|
29
|
-
* overrides (project, home) have been applied, so $env always reflects the correct values.
|
|
30
|
-
*
|
|
31
|
-
* Provider credential resolution must not use this merged view because it includes the
|
|
32
|
-
* caller's cwd/.env. Use $credentialEnv/$pickCredentialEnv for model authentication.
|
|
33
|
-
*/
|
|
34
|
-
export declare const $env: Record<string, string>;
|
|
35
|
-
/**
|
|
36
|
-
* Resolve the first environment variable value from the given keys.
|
|
37
|
-
* @param keys - The keys to resolve.
|
|
38
|
-
* @returns The first environment variable value, or undefined if no value is found.
|
|
39
|
-
*/
|
|
40
|
-
export declare function $pickenv(...keys: string[]): string | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Resolve credential-bearing environment variables without consulting the caller's project .env.
|
|
43
|
-
*
|
|
44
|
-
* SKC loads cwd/.env into $env for project-aware tools, but model-provider authentication should
|
|
45
|
-
* only use values explicitly inherited from the launching shell or SKC/user-owned config files.
|
|
46
|
-
*/
|
|
47
|
-
export declare function $credentialEnv(name: string): string | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Resolve the first credential env value from the given keys, excluding cwd/.env overlays.
|
|
50
|
-
*/
|
|
51
|
-
export declare function $pickCredentialEnv(...keys: string[]): string | undefined;
|
|
52
|
-
/**
|
|
53
|
-
* Parses a positive decimal integer from `$env[name]`.
|
|
54
|
-
* Empty, invalid, NaN, zero, or negative values return `defaultValue`.
|
|
55
|
-
*/
|
|
56
|
-
export declare function $envpos(name: string, defaultValue: number): number;
|
|
57
|
-
/** True when `BUN_ENV` or `NODE_ENV` is the string `test`. */
|
|
58
|
-
export declare function isBunTestRuntime(): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* True when this code is running inside a `bun build --compile` standalone
|
|
61
|
-
* binary. Detects via the embedded virtual-filesystem path markers
|
|
62
|
-
* (`$bunfs`, `~BUN`, or its URL-encoded form `%7EBUN`) in `import.meta.url`,
|
|
63
|
-
* which Bun rewrites for every module bundled into the executable. The
|
|
64
|
-
* `PI_COMPILED` env var (set by the build script's `--define`) is checked
|
|
65
|
-
* first for cheap fast-path detection.
|
|
66
|
-
*/
|
|
67
|
-
export declare function isCompiledBinary(): boolean;
|
|
68
|
-
export declare function $flag(name: string, def?: boolean): boolean;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-suggested retry delay extraction. Merges the patterns historically used
|
|
3
|
-
* by the OpenAI code provider and Google Gemini retry helpers.
|
|
4
|
-
*
|
|
5
|
-
* Header sources (checked in order):
|
|
6
|
-
* - `Retry-After` (numeric seconds, or HTTP date)
|
|
7
|
-
* - `x-ratelimit-reset` (Unix epoch seconds)
|
|
8
|
-
* - `x-ratelimit-reset-after` (seconds)
|
|
9
|
-
*
|
|
10
|
-
* Body patterns:
|
|
11
|
-
* - `Your quota will reset after 18h31m10s` / `10m15s` / `39s`
|
|
12
|
-
* - `Please retry in 250ms` / `Please retry in 12s`
|
|
13
|
-
* - `"retryDelay": "34.074824224s"` (JSON error detail field)
|
|
14
|
-
* - `try again in 250ms` / `try again in 12s` / `try again in 12sec`
|
|
15
|
-
*
|
|
16
|
-
* Returns `undefined` if no signal is found.
|
|
17
|
-
*/
|
|
18
|
-
export declare function extractRetryHint(source: Response | Headers | null | undefined, body?: string): number | undefined;
|
|
19
|
-
export interface FetchWithRetryOptions extends RequestInit {
|
|
20
|
-
/** Total fetch attempts (initial + retries). Default `5`. */
|
|
21
|
-
maxAttempts?: number;
|
|
22
|
-
/**
|
|
23
|
-
* Per-delay cap. Server-provided `Retry-After` hints exceeding this return
|
|
24
|
-
* the current response immediately — caller deals with the `!response.ok`.
|
|
25
|
-
* Default `60_000`.
|
|
26
|
-
*/
|
|
27
|
-
maxDelayMs?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Fallback delay schedule when no server hint is present. Number, array
|
|
30
|
-
* (indexed by attempt, clamped to last), or function. Default exponential
|
|
31
|
-
* `500ms * 2 ** attempt` capped at `maxDelayMs`.
|
|
32
|
-
*/
|
|
33
|
-
defaultDelayMs?: number | readonly number[] | ((attempt: number) => number);
|
|
34
|
-
/**
|
|
35
|
-
* Optional per-attempt overlay merged into the base `RequestInit` each try.
|
|
36
|
-
* Headers from the overlay shallow-merge over the base. Useful for auth
|
|
37
|
-
* token refresh or user-agent rotation.
|
|
38
|
-
*/
|
|
39
|
-
prepareInit?: (attempt: number) => RequestInit | Promise<RequestInit>;
|
|
40
|
-
/**
|
|
41
|
-
* Optional `fetch` implementation override. Defaults to `globalThis.fetch`.
|
|
42
|
-
* Useful for routing requests through a proxy, instrumented transport, or
|
|
43
|
-
* mock during tests.
|
|
44
|
-
*/
|
|
45
|
-
fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Fetch with bounded retries and sensible defaults. Retries on any
|
|
49
|
-
* `isRetryableStatus` (5xx, 408, 429) and on transient network errors. Server
|
|
50
|
-
* `Retry-After`/quota hints are honoured up to `maxDelayMs`; a hint that exceeds
|
|
51
|
-
* the cap returns the current response so the caller can fail fast. Aborts on
|
|
52
|
-
* `init.signal` propagate as `"Request was aborted"`.
|
|
53
|
-
*
|
|
54
|
-
* The caller is responsible for inspecting `!response.ok` once the call returns.
|
|
55
|
-
*/
|
|
56
|
-
export declare function fetchWithRetry(url: string | URL | ((attempt: number) => string | URL), options?: FetchWithRetryOptions): Promise<Response>;
|
|
57
|
-
/**
|
|
58
|
-
* Inspect an arbitrary error value (or its `cause` chain, up to depth 2) for an
|
|
59
|
-
* HTTP status code. Reads `status`, `statusCode`, and `response.status` fields,
|
|
60
|
-
* coerces string values, and falls back to scanning the error message for
|
|
61
|
-
* common patterns like `Error: 401`, `error (429)`, or `HTTP 503`.
|
|
62
|
-
*/
|
|
63
|
-
export declare function extractHttpStatusFromError(error: unknown): number | undefined;
|
|
64
|
-
/**
|
|
65
|
-
* `true` if the given HTTP status code is one we treat as transient: 408
|
|
66
|
-
* (Request Timeout), 429 (Too Many Requests), or any 5xx (server error).
|
|
67
|
-
*/
|
|
68
|
-
export declare function isRetryableStatus(status: number): boolean;
|
|
69
|
-
/**
|
|
70
|
-
* `true` if the message describes an unexpected socket closure — Bun and some
|
|
71
|
-
* proxies surface these for any HTTP/2 stream reset.
|
|
72
|
-
*/
|
|
73
|
-
export declare function isUnexpectedSocketCloseMessage(message: string): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Identify errors that should be retried: aborts/timeouts in the error name or
|
|
76
|
-
* message, retryable HTTP statuses (see `isRetryableStatus`), unexpected socket
|
|
77
|
-
* closes, and the standard transient phrases. 4xx statuses other than 408/429
|
|
78
|
-
* and validation-shaped messages short-circuit to `false`.
|
|
79
|
-
*/
|
|
80
|
-
export declare function isRetryableError(error: unknown): boolean;
|
package/dist/types/format.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format a duration in milliseconds to a short human-readable string.
|
|
3
|
-
* Examples: "123ms", "1.5s", "30m15s", "2h30m", "3d2h"
|
|
4
|
-
*/
|
|
5
|
-
export declare function formatDuration(ms: number): string;
|
|
6
|
-
/**
|
|
7
|
-
* Format a number with K/M/B suffix for compact display.
|
|
8
|
-
* Uses 1 decimal for small leading digits when non-zero, rounded otherwise.
|
|
9
|
-
* Examples: "999", "1K", "1.5K", "25K", "1M", "1.5M", "25M", "1.5B"
|
|
10
|
-
*/
|
|
11
|
-
export declare function formatNumber(n: number): string;
|
|
12
|
-
/**
|
|
13
|
-
* Format a byte count to a human-readable string.
|
|
14
|
-
* Examples: "512B", "1.5KB", "2.3MB", "1.2GB"
|
|
15
|
-
*/
|
|
16
|
-
export declare function formatBytes(bytes: number): string;
|
|
17
|
-
/**
|
|
18
|
-
* Truncate a string to maxLen characters, appending an ellipsis if truncated.
|
|
19
|
-
* For display-width-aware truncation (terminals), use truncateToWidth from @sayknow-cli/tui.
|
|
20
|
-
*/
|
|
21
|
-
export declare function truncate(str: string, maxLen: number, ellipsis?: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Format count with pluralized label (e.g., "3 files", "1 error").
|
|
24
|
-
*/
|
|
25
|
-
export declare function formatCount(label: string, count: number): string;
|
|
26
|
-
/**
|
|
27
|
-
* Format age from seconds to human-readable string.
|
|
28
|
-
*/
|
|
29
|
-
export declare function formatAge(ageSeconds: number | null | undefined): string;
|
|
30
|
-
/**
|
|
31
|
-
* Pluralize a label based on the count.
|
|
32
|
-
*/
|
|
33
|
-
export declare function pluralize(label: string, count: number): string;
|
|
34
|
-
/**
|
|
35
|
-
* Format a ratio as a percentage.
|
|
36
|
-
*/
|
|
37
|
-
export declare function formatPercent(ratio: number): string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export declare class FrontmatterError extends Error {
|
|
2
|
-
readonly source?: unknown | undefined;
|
|
3
|
-
constructor(error: Error, source?: unknown | undefined);
|
|
4
|
-
toString(): string;
|
|
5
|
-
}
|
|
6
|
-
export interface FrontmatterOptions {
|
|
7
|
-
/** Source of the content (alias: source) */
|
|
8
|
-
location?: unknown;
|
|
9
|
-
/** Source of the content (alias for location) */
|
|
10
|
-
source?: unknown;
|
|
11
|
-
/** Fallback frontmatter values */
|
|
12
|
-
fallback?: Record<string, unknown>;
|
|
13
|
-
/** Normalize the content */
|
|
14
|
-
normalize?: boolean;
|
|
15
|
-
/** Level of error handling */
|
|
16
|
-
level?: "off" | "warn" | "fatal";
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Parse YAML frontmatter from markdown content
|
|
20
|
-
* Returns { frontmatter, body } where body has frontmatter stripped
|
|
21
|
-
*/
|
|
22
|
-
export declare function parseFrontmatter(content: string, options?: FrontmatterOptions): {
|
|
23
|
-
frontmatter: Record<string, unknown>;
|
|
24
|
-
body: string;
|
|
25
|
-
};
|
package/dist/types/fs-error.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type-safe filesystem error handling utilities.
|
|
3
|
-
*
|
|
4
|
-
* Use these to check error codes without string matching on messages:
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* import { isEnoent, isFsError } from "@sayknow-cli/utils";
|
|
9
|
-
*
|
|
10
|
-
* try {
|
|
11
|
-
* return await Bun.file(path).text();
|
|
12
|
-
* } catch (err) {
|
|
13
|
-
* if (isEnoent(err)) return null;
|
|
14
|
-
* throw err;
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export interface FsError extends Error {
|
|
19
|
-
code: string;
|
|
20
|
-
errno?: number;
|
|
21
|
-
syscall?: string;
|
|
22
|
-
path?: string;
|
|
23
|
-
}
|
|
24
|
-
export declare function isFsError(err: unknown): err is FsError;
|
|
25
|
-
export declare function isEnoent(err: unknown): err is FsError;
|
|
26
|
-
export declare function isEacces(err: unknown): err is FsError;
|
|
27
|
-
export declare function isEisdir(err: unknown): err is FsError;
|
|
28
|
-
export declare function isEnotdir(err: unknown): err is FsError;
|
|
29
|
-
export declare function isEexist(err: unknown): err is FsError;
|
|
30
|
-
export declare function isEnotempty(err: unknown): err is FsError;
|
|
31
|
-
export declare function hasFsCode(err: unknown, code: string): err is FsError;
|
package/dist/types/glob.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export interface GlobPathsOptions {
|
|
2
|
-
/** Base directory for glob patterns. Defaults to getProjectDir(). */
|
|
3
|
-
cwd?: string;
|
|
4
|
-
/** Glob exclusion patterns. */
|
|
5
|
-
exclude?: string[];
|
|
6
|
-
/** Abort signal to cancel the glob. */
|
|
7
|
-
signal?: AbortSignal;
|
|
8
|
-
/** Timeout in milliseconds for the glob operation. */
|
|
9
|
-
timeoutMs?: number;
|
|
10
|
-
/** Include dotfiles when true. */
|
|
11
|
-
dot?: boolean;
|
|
12
|
-
/** Only return files (skip directories). Default: true. */
|
|
13
|
-
onlyFiles?: boolean;
|
|
14
|
-
/** Respect .gitignore files when true. Walks up directory tree to find all applicable .gitignore files. */
|
|
15
|
-
gitignore?: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Load .gitignore patterns from a directory and its parents.
|
|
19
|
-
* Walks up the directory tree to find all applicable .gitignore files.
|
|
20
|
-
* Returns glob-compatible exclude patterns.
|
|
21
|
-
*/
|
|
22
|
-
export declare function loadGitignorePatterns(baseDir: string): Promise<string[]>;
|
|
23
|
-
/**
|
|
24
|
-
* Resolve filesystem paths matching glob patterns with optional exclude filters.
|
|
25
|
-
* Returns paths relative to the provided cwd (or getProjectDir()).
|
|
26
|
-
* Errors and abort/timeouts are surfaced to the caller.
|
|
27
|
-
*/
|
|
28
|
-
export declare function globPaths(patterns: string | string[], options?: GlobPathsOptions): Promise<string[]>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Intercept `globalThis.fetch` with a middleware-style handler.
|
|
3
|
-
*
|
|
4
|
-
* Returns a `Disposable` so callers can use `using` for automatic cleanup:
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* using _hook = hookFetch((input, init, next) => {
|
|
8
|
-
* if (shouldIntercept(input)) {
|
|
9
|
-
* return new Response("mocked");
|
|
10
|
-
* }
|
|
11
|
-
* return next(input, init);
|
|
12
|
-
* });
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export type FetchHandler = (input: string | URL | Request, init: RequestInit | undefined, next: typeof fetch) => Response | Promise<Response>;
|
|
16
|
-
export declare function hookFetch(handler: FetchHandler): Disposable;
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export { createAbortableStream, once, untilAborted } from "./abortable";
|
|
2
|
-
export * from "./async";
|
|
3
|
-
export * from "./broken-pipe";
|
|
4
|
-
export * from "./color";
|
|
5
|
-
export * from "./dirs";
|
|
6
|
-
export * from "./env";
|
|
7
|
-
export * from "./fetch-retry";
|
|
8
|
-
export * from "./format";
|
|
9
|
-
export * from "./frontmatter";
|
|
10
|
-
export * from "./fs-error";
|
|
11
|
-
export * from "./glob";
|
|
12
|
-
export * from "./hook-fetch";
|
|
13
|
-
export * from "./json";
|
|
14
|
-
export * as logger from "./logger";
|
|
15
|
-
export * from "./mermaid-ascii";
|
|
16
|
-
export * from "./mime";
|
|
17
|
-
export * from "./peek-file";
|
|
18
|
-
export * as postmortem from "./postmortem";
|
|
19
|
-
export * as procmgr from "./procmgr";
|
|
20
|
-
export * as prompt from "./prompt";
|
|
21
|
-
export * as ptree from "./ptree";
|
|
22
|
-
export { AbortError, ChildProcess, Exception, NonZeroExitError } from "./ptree";
|
|
23
|
-
export * from "./safe-stderr";
|
|
24
|
-
export * from "./sanitize-text";
|
|
25
|
-
export * from "./snowflake";
|
|
26
|
-
export * from "./stream";
|
|
27
|
-
export * from "./tab-spacing";
|
|
28
|
-
export * from "./temp";
|
|
29
|
-
export * from "./type-guards";
|
|
30
|
-
export * from "./which";
|
|
31
|
-
export declare function structuredCloneJSON<T>(value: T): T;
|
package/dist/types/json.d.ts
DELETED
package/dist/types/logger.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
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;
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}[];
|
package/dist/types/mime.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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>;
|
|
@@ -1,9 +0,0 @@
|
|
|
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>;
|
|
@@ -1,29 +0,0 @@
|
|
|
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>;
|
package/dist/types/procmgr.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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>;
|
package/dist/types/prompt.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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;
|
package/dist/types/ptree.d.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
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 {};
|