lean-agents 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +407 -0
- package/LICENSE +21 -0
- package/README.es.md +560 -0
- package/README.md +559 -2
- package/core/AGENTS.es.md +60 -0
- package/core/AGENTS.md +60 -0
- package/core/README.md +8 -0
- package/core/agents/debug.md +14 -0
- package/core/agents/explore.md +13 -0
- package/core/agents/planner.md +14 -0
- package/core/agents/research.md +13 -0
- package/core/agents/review.md +13 -0
- package/core/copilot-usage-tui.js +189 -0
- package/core/mcp.json +38 -0
- package/core/pins.json +39 -0
- package/core/tiers.json +4 -0
- package/node_modules/@clack/core/LICENSE +9 -0
- package/node_modules/@clack/core/README.md +22 -0
- package/node_modules/@clack/core/dist/index.d.mts +503 -0
- package/node_modules/@clack/core/dist/index.mjs +1003 -0
- package/node_modules/@clack/core/package.json +63 -0
- package/node_modules/@clack/prompts/LICENSE +9 -0
- package/node_modules/@clack/prompts/README.md +396 -0
- package/node_modules/@clack/prompts/dist/index.d.mts +949 -0
- package/node_modules/@clack/prompts/dist/index.mjs +1423 -0
- package/node_modules/@clack/prompts/package.json +67 -0
- package/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
- package/node_modules/fast-string-truncated-width/dist/index.js +111 -0
- package/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
- package/node_modules/fast-string-truncated-width/dist/types.js +2 -0
- package/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
- package/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
- package/node_modules/fast-string-truncated-width/license +21 -0
- package/node_modules/fast-string-truncated-width/package.json +35 -0
- package/node_modules/fast-string-truncated-width/readme.md +59 -0
- package/node_modules/fast-string-width/dist/index.d.ts +4 -0
- package/node_modules/fast-string-width/dist/index.js +14 -0
- package/node_modules/fast-string-width/license +21 -0
- package/node_modules/fast-string-width/package.json +34 -0
- package/node_modules/fast-string-width/readme.md +42 -0
- package/node_modules/fast-wrap-ansi/LICENSE +23 -0
- package/node_modules/fast-wrap-ansi/README.md +26 -0
- package/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
- package/node_modules/fast-wrap-ansi/lib/main.js +218 -0
- package/node_modules/fast-wrap-ansi/package.json +51 -0
- package/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/node_modules/jsonc-parser/LICENSE.md +21 -0
- package/node_modules/jsonc-parser/README.md +364 -0
- package/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
- package/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
- package/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
- package/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
- package/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
- package/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
- package/node_modules/jsonc-parser/lib/esm/main.js +178 -0
- package/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
- package/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
- package/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
- package/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
- package/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
- package/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
- package/node_modules/jsonc-parser/lib/umd/main.js +194 -0
- package/node_modules/jsonc-parser/package.json +37 -0
- package/node_modules/sisteransi/license +21 -0
- package/node_modules/sisteransi/package.json +34 -0
- package/node_modules/sisteransi/readme.md +113 -0
- package/node_modules/sisteransi/src/index.js +58 -0
- package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
- package/package.json +30 -4
- package/profiles/README.md +10 -0
- package/profiles/anthropic-api/gsd-defaults.json +26 -0
- package/profiles/anthropic-api.json +18 -0
- package/profiles/antigravity.json +12 -0
- package/profiles/claude-subscription/gsd-defaults.json +26 -0
- package/profiles/claude-subscription.json +17 -0
- package/profiles/github-copilot/gsd-defaults.json +26 -0
- package/profiles/github-copilot.json +17 -0
- package/profiles/openai-api/gsd-defaults.json +26 -0
- package/profiles/openai-api.json +17 -0
- package/profiles/opencode-go/gsd-defaults.json +26 -0
- package/profiles/opencode-go.json +17 -0
- package/profiles/vertex-gemini/gsd-defaults.json +26 -0
- package/profiles/vertex-gemini.json +18 -0
- package/scripts/adhd-skill.mjs +12 -0
- package/scripts/behavior-diff.sh +47 -0
- package/scripts/bump-pins.mjs +115 -0
- package/scripts/check-private.sh +52 -0
- package/scripts/check-readme.mjs +131 -0
- package/scripts/ci-download.sh +20 -0
- package/scripts/ci-install-opencode-v2.sh +6 -0
- package/scripts/ci-latest-report.mjs +38 -0
- package/scripts/ci-timing.mjs +61 -0
- package/scripts/copilot-context-mode.mjs +33 -0
- package/scripts/labels.sh +56 -0
- package/scripts/lean.mjs +1319 -0
- package/scripts/lib/adapters/antigravity.mjs +83 -0
- package/scripts/lib/adapters/claude.mjs +127 -0
- package/scripts/lib/adapters/copilot-cli.mjs +82 -0
- package/scripts/lib/adapters/cursor.mjs +60 -0
- package/scripts/lib/adapters/opencode-v1.mjs +79 -0
- package/scripts/lib/adapters/opencode-v2.mjs +216 -0
- package/scripts/lib/adapters/vscode-copilot.mjs +56 -0
- package/scripts/lib/adhd.mjs +28 -0
- package/scripts/lib/adopt.mjs +619 -0
- package/scripts/lib/agent-lifecycle.mjs +280 -0
- package/scripts/lib/backup-stamp.mjs +25 -0
- package/scripts/lib/copilot-usage.mjs +49 -0
- package/scripts/lib/doctor.mjs +279 -0
- package/scripts/lib/feedback.mjs +48 -0
- package/scripts/lib/fsops.mjs +319 -0
- package/scripts/lib/gsd.mjs +42 -0
- package/scripts/lib/inventory.mjs +196 -0
- package/scripts/lib/lean-update.mjs +30 -0
- package/scripts/lib/logins.mjs +28 -0
- package/scripts/lib/migrate.mjs +407 -0
- package/scripts/lib/network.mjs +119 -0
- package/scripts/lib/node-runtime.mjs +85 -0
- package/scripts/lib/opencode-backup.mjs +204 -0
- package/scripts/lib/opencode-upgrade.mjs +441 -0
- package/scripts/lib/opencode1.mjs +203 -0
- package/scripts/lib/parallel.mjs +270 -0
- package/scripts/lib/pins-diff.mjs +33 -0
- package/scripts/lib/pins.mjs +52 -0
- package/scripts/lib/plugin-health.mjs +191 -0
- package/scripts/lib/prereqs.mjs +203 -0
- package/scripts/lib/project.mjs +38 -0
- package/scripts/lib/redact.mjs +30 -0
- package/scripts/lib/render.mjs +101 -0
- package/scripts/lib/shell-path.mjs +22 -0
- package/scripts/lib/summary-data.mjs +30 -0
- package/scripts/lib/summary-html.mjs +159 -0
- package/scripts/lib/system.mjs +269 -0
- package/scripts/lib/terminals.mjs +316 -0
- package/scripts/lib/ui.mjs +34 -0
- package/scripts/lib/unverified.mjs +49 -0
- package/scripts/lib/update-plan.mjs +60 -0
- package/scripts/lib/upgrade.mjs +231 -0
- package/scripts/lib/verify-commit.mjs +16 -0
- package/scripts/lib/verify-prompt.mjs +46 -0
- package/scripts/lib/verify-sha256.mjs +20 -0
- package/scripts/lint-workflows.mjs +25 -0
- package/scripts/models-refresh.mjs +58 -0
- package/scripts/parallel.mjs +59 -0
- package/scripts/pins-latest.mjs +66 -0
- package/scripts/release.mjs +71 -0
- package/scripts/verify-pins.mjs +36 -0
- package/scripts/version-watch.mjs +124 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
import { Key } from 'node:readline';
|
|
2
|
+
import { Readable, Writable } from 'node:stream';
|
|
3
|
+
|
|
4
|
+
declare const actions: readonly ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
5
|
+
type Action = (typeof actions)[number];
|
|
6
|
+
/** Global settings for Clack programs, stored in memory */
|
|
7
|
+
interface InternalClackSettings {
|
|
8
|
+
actions: Set<Action>;
|
|
9
|
+
aliases: Map<string, Action>;
|
|
10
|
+
messages: {
|
|
11
|
+
cancel: string;
|
|
12
|
+
error: string;
|
|
13
|
+
};
|
|
14
|
+
withGuide: boolean;
|
|
15
|
+
accessible: boolean | undefined;
|
|
16
|
+
date: {
|
|
17
|
+
monthNames: string[];
|
|
18
|
+
messages: {
|
|
19
|
+
invalidMonth: string;
|
|
20
|
+
required: string;
|
|
21
|
+
invalidDay: (days: number, month: string) => string;
|
|
22
|
+
afterMin: (min: Date) => string;
|
|
23
|
+
beforeMax: (max: Date) => string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
declare const settings: InternalClackSettings;
|
|
28
|
+
interface ClackSettings {
|
|
29
|
+
/**
|
|
30
|
+
* Set custom global aliases for the default actions.
|
|
31
|
+
* This will not overwrite existing aliases, it will only add new ones!
|
|
32
|
+
*
|
|
33
|
+
* @param aliases - An object that maps aliases to actions
|
|
34
|
+
* @default { k: 'up', j: 'down', h: 'left', l: 'right', '\x03': 'cancel', 'escape': 'cancel' }
|
|
35
|
+
*/
|
|
36
|
+
aliases?: Record<string, Action>;
|
|
37
|
+
/**
|
|
38
|
+
* Custom messages for prompts
|
|
39
|
+
*/
|
|
40
|
+
messages?: {
|
|
41
|
+
/**
|
|
42
|
+
* Custom message to display when a spinner is cancelled
|
|
43
|
+
* @default "Canceled"
|
|
44
|
+
*/
|
|
45
|
+
cancel?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Custom message to display when a spinner encounters an error
|
|
48
|
+
* @default "Something went wrong"
|
|
49
|
+
*/
|
|
50
|
+
error?: string;
|
|
51
|
+
};
|
|
52
|
+
withGuide?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Force accessible (static, screen-reader friendly) output on or off.
|
|
55
|
+
* Overrides the `ACCESSIBLE` environment variable.
|
|
56
|
+
*/
|
|
57
|
+
accessible?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Date prompt localization
|
|
60
|
+
*/
|
|
61
|
+
date?: {
|
|
62
|
+
/** Month names for validation messages (January, February, ...) */
|
|
63
|
+
monthNames?: string[];
|
|
64
|
+
messages?: {
|
|
65
|
+
/** Shown when date is missing */
|
|
66
|
+
required?: string;
|
|
67
|
+
/** Shown when month > 12 */
|
|
68
|
+
invalidMonth?: string;
|
|
69
|
+
/** (days, monthName) => message for invalid day */
|
|
70
|
+
invalidDay?: (days: number, month: string) => string;
|
|
71
|
+
/** (min) => message when date is before minDate */
|
|
72
|
+
afterMin?: (min: Date) => string;
|
|
73
|
+
/** (max) => message when date is after maxDate */
|
|
74
|
+
beforeMax?: (max: Date) => string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
declare function updateSettings(updates: ClackSettings): void;
|
|
79
|
+
/**
|
|
80
|
+
* Resolves whether accessible (static, screen-reader friendly) output is enabled.
|
|
81
|
+
*
|
|
82
|
+
* Resolution order: per-call option > global `accessible` setting > `ACCESSIBLE`
|
|
83
|
+
* environment variable (any non-empty value enables it, except `0` and `false`).
|
|
84
|
+
*
|
|
85
|
+
* @param accessible - Per-call override; takes precedence when defined
|
|
86
|
+
*/
|
|
87
|
+
declare function isAccessible(accessible?: boolean): boolean;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The state of the prompt
|
|
91
|
+
*/
|
|
92
|
+
type ClackState = 'initial' | 'active' | 'cancel' | 'submit' | 'error' | 'validating';
|
|
93
|
+
/**
|
|
94
|
+
* Typed event emitter for clack
|
|
95
|
+
*/
|
|
96
|
+
interface ClackEvents<TValue> {
|
|
97
|
+
initial: (value?: any) => void;
|
|
98
|
+
active: (value?: any) => void;
|
|
99
|
+
cancel: (value?: any) => void;
|
|
100
|
+
submit: (value?: any) => void;
|
|
101
|
+
error: (value?: any) => void;
|
|
102
|
+
validating: (value?: any) => void;
|
|
103
|
+
cursor: (key?: Action) => void;
|
|
104
|
+
key: (key: string | undefined, info: Key) => void;
|
|
105
|
+
value: (value?: TValue) => void;
|
|
106
|
+
userInput: (value: string) => void;
|
|
107
|
+
confirm: (value?: boolean) => void;
|
|
108
|
+
finalize: () => void;
|
|
109
|
+
beforePrompt: () => void;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare const CANCEL_SYMBOL: unique symbol;
|
|
113
|
+
declare function isCancel(value: unknown): value is typeof CANCEL_SYMBOL;
|
|
114
|
+
interface BlockOptions {
|
|
115
|
+
input?: Readable;
|
|
116
|
+
output?: Writable;
|
|
117
|
+
overwrite?: boolean;
|
|
118
|
+
hideCursor?: boolean;
|
|
119
|
+
}
|
|
120
|
+
declare function block({ input, output, overwrite, hideCursor, }?: BlockOptions): () => void;
|
|
121
|
+
declare const getColumns: (output: Writable) => number;
|
|
122
|
+
declare const getRows: (output: Writable) => number;
|
|
123
|
+
declare function wrapTextWithPrefix(output: Writable | undefined, text: string, prefix: string, startPrefix?: string, endPrefix?: string, lineFormatter?: (line: string, index: number) => string): string;
|
|
124
|
+
|
|
125
|
+
/** The Standard Schema interface. */
|
|
126
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
127
|
+
/** The Standard Schema properties. */
|
|
128
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
129
|
+
}
|
|
130
|
+
declare namespace StandardSchemaV1 {
|
|
131
|
+
/** The Standard Schema properties interface. */
|
|
132
|
+
interface Props<Input = unknown, Output = Input> {
|
|
133
|
+
/** The version number of the standard. */
|
|
134
|
+
readonly version: 1;
|
|
135
|
+
/** The vendor name of the schema library. */
|
|
136
|
+
readonly vendor: string;
|
|
137
|
+
/** Validates unknown input values. */
|
|
138
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
139
|
+
/** Inferred types associated with the schema. */
|
|
140
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
141
|
+
}
|
|
142
|
+
/** The result interface of the validate function. */
|
|
143
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
144
|
+
/** The result interface if validation succeeds. */
|
|
145
|
+
interface SuccessResult<Output> {
|
|
146
|
+
/** The typed output value. */
|
|
147
|
+
readonly value: Output;
|
|
148
|
+
/** A falsy value for `issues` indicates success. */
|
|
149
|
+
readonly issues?: undefined;
|
|
150
|
+
}
|
|
151
|
+
interface Options {
|
|
152
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
153
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
154
|
+
}
|
|
155
|
+
/** The result interface if validation fails. */
|
|
156
|
+
interface FailureResult {
|
|
157
|
+
/** The issues of failed validation. */
|
|
158
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
159
|
+
}
|
|
160
|
+
/** The issue interface of the failure output. */
|
|
161
|
+
interface Issue {
|
|
162
|
+
/** The error message of the issue. */
|
|
163
|
+
readonly message: string;
|
|
164
|
+
/** The path of the issue, if any. */
|
|
165
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
166
|
+
}
|
|
167
|
+
/** The path segment interface of the issue. */
|
|
168
|
+
interface PathSegment {
|
|
169
|
+
/** The key representing a path segment. */
|
|
170
|
+
readonly key: PropertyKey;
|
|
171
|
+
}
|
|
172
|
+
/** The Standard Schema types interface. */
|
|
173
|
+
interface Types<Input = unknown, Output = Input> {
|
|
174
|
+
/** The input type of the schema. */
|
|
175
|
+
readonly input: Input;
|
|
176
|
+
/** The output type of the schema. */
|
|
177
|
+
readonly output: Output;
|
|
178
|
+
}
|
|
179
|
+
/** Infers the input type of a Standard Schema. */
|
|
180
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
181
|
+
/** Infers the output type of a Standard Schema. */
|
|
182
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
186
|
+
/**
|
|
187
|
+
* A function or [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
188
|
+
* that validates user input. If a custom function is given, you should return a
|
|
189
|
+
* `string` or `Error` to show as a validation error, or `undefined` to accept the result.
|
|
190
|
+
*
|
|
191
|
+
* @example Using arktype
|
|
192
|
+
* ```ts
|
|
193
|
+
* import { text } from '@clack/prompts';
|
|
194
|
+
* import { type } from 'arktype';
|
|
195
|
+
*
|
|
196
|
+
* const name = await text({
|
|
197
|
+
* message: 'Enter your name (letters only)',
|
|
198
|
+
* validate: type('string.alpha').describe('Name can only contain letters'),
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @example Custom validator
|
|
203
|
+
* ```ts
|
|
204
|
+
* import { text } from '@clack/prompts';
|
|
205
|
+
*
|
|
206
|
+
* const age = await text({
|
|
207
|
+
* message: 'Enter your age:',
|
|
208
|
+
* validate(value) {
|
|
209
|
+
* if (!value) return 'Please enter a value';
|
|
210
|
+
* const num = parseInt(value);
|
|
211
|
+
* if (isNaN(num)) return 'Please enter a valid number';
|
|
212
|
+
* if (num < 0 || num > 120) return 'Age must be between 0 and 120';
|
|
213
|
+
* return undefined;
|
|
214
|
+
* },
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
type Validate<TValue> = ((value: TValue | undefined) => MaybePromise<string | Error | undefined>) | StandardSchemaV1<TValue | undefined, unknown>;
|
|
219
|
+
/**
|
|
220
|
+
* Runs the `validate()` option and normalizes the result
|
|
221
|
+
* @param validate - The validate option
|
|
222
|
+
* @param value - The user input
|
|
223
|
+
* @returns the validation result
|
|
224
|
+
*/
|
|
225
|
+
declare function runValidation<TValue>(validate: Validate<TValue>, value: TValue | undefined): MaybePromise<string | Error | undefined>;
|
|
226
|
+
|
|
227
|
+
interface PromptOptions<TValue, Self extends Prompt<TValue>> {
|
|
228
|
+
render(this: Omit<Self, 'prompt'>): string | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Whether to render this prompt in accessible (static, screen-reader friendly) mode.
|
|
231
|
+
* Takes precedence over the global `accessible` setting and the `ACCESSIBLE` env var.
|
|
232
|
+
*/
|
|
233
|
+
accessible?: boolean;
|
|
234
|
+
initialValue?: any;
|
|
235
|
+
initialUserInput?: string;
|
|
236
|
+
/**
|
|
237
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
238
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
239
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
240
|
+
*/
|
|
241
|
+
validate?: Validate<TValue> | undefined;
|
|
242
|
+
input?: Readable;
|
|
243
|
+
output?: Writable;
|
|
244
|
+
signal?: AbortSignal;
|
|
245
|
+
}
|
|
246
|
+
declare class Prompt<TValue> {
|
|
247
|
+
protected input: Readable;
|
|
248
|
+
protected output: Writable;
|
|
249
|
+
private _abortSignal?;
|
|
250
|
+
private rl;
|
|
251
|
+
private opts;
|
|
252
|
+
private _render;
|
|
253
|
+
private _track;
|
|
254
|
+
private _prevFrame;
|
|
255
|
+
private _subscribers;
|
|
256
|
+
protected _cursor: number;
|
|
257
|
+
state: ClackState;
|
|
258
|
+
error: string;
|
|
259
|
+
value: TValue | undefined;
|
|
260
|
+
userInput: string;
|
|
261
|
+
/**
|
|
262
|
+
* Whether accessible (static, screen-reader friendly) output is enabled for
|
|
263
|
+
* this prompt, resolved from the `accessible` option, the global setting,
|
|
264
|
+
* and the `ACCESSIBLE` env var.
|
|
265
|
+
*/
|
|
266
|
+
get accessible(): boolean;
|
|
267
|
+
constructor(options: PromptOptions<TValue, Prompt<TValue>>, trackValue?: boolean);
|
|
268
|
+
/**
|
|
269
|
+
* Unsubscribe all listeners
|
|
270
|
+
*/
|
|
271
|
+
protected unsubscribe(): void;
|
|
272
|
+
/**
|
|
273
|
+
* Set a subscriber with opts
|
|
274
|
+
* @param event - The event name
|
|
275
|
+
*/
|
|
276
|
+
private setSubscriber;
|
|
277
|
+
/**
|
|
278
|
+
* Subscribe to an event
|
|
279
|
+
* @param event - The event name
|
|
280
|
+
* @param cb - The callback
|
|
281
|
+
*/
|
|
282
|
+
on<T extends keyof ClackEvents<TValue>>(event: T, cb: ClackEvents<TValue>[T]): void;
|
|
283
|
+
/**
|
|
284
|
+
* Subscribe to an event once
|
|
285
|
+
* @param event - The event name
|
|
286
|
+
* @param cb - The callback
|
|
287
|
+
*/
|
|
288
|
+
once<T extends keyof ClackEvents<TValue>>(event: T, cb: ClackEvents<TValue>[T]): void;
|
|
289
|
+
/**
|
|
290
|
+
* Emit an event with data
|
|
291
|
+
* @param event - The event name
|
|
292
|
+
* @param data - The data to pass to the callback
|
|
293
|
+
*/
|
|
294
|
+
emit<T extends keyof ClackEvents<TValue>>(event: T, ...data: Parameters<ClackEvents<TValue>[T]>): void;
|
|
295
|
+
prompt(): Promise<TValue | typeof CANCEL_SYMBOL | undefined>;
|
|
296
|
+
protected _isActionKey(char: string | undefined, _key: Key): boolean;
|
|
297
|
+
protected _shouldSubmit(_char: string | undefined, _key: Key): boolean;
|
|
298
|
+
protected _setValue(value: TValue | undefined): void;
|
|
299
|
+
protected _setUserInput(value: string | undefined, write?: boolean): void;
|
|
300
|
+
protected _clearUserInput(): void;
|
|
301
|
+
private onKeypress;
|
|
302
|
+
protected close(): void;
|
|
303
|
+
private restoreCursor;
|
|
304
|
+
private render;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
interface OptionLike$1 {
|
|
308
|
+
value: unknown;
|
|
309
|
+
label?: string;
|
|
310
|
+
disabled?: boolean;
|
|
311
|
+
}
|
|
312
|
+
type FilterFunction<T extends OptionLike$1> = (search: string, opt: T) => boolean;
|
|
313
|
+
interface AutocompleteOptions<T extends OptionLike$1> extends PromptOptions<T['value'] | T['value'][], AutocompletePrompt<T>> {
|
|
314
|
+
options: T[] | ((this: AutocompletePrompt<T>) => T[]);
|
|
315
|
+
filter?: FilterFunction<T>;
|
|
316
|
+
multiple?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* When set (non-empty), pressing Tab with no input fills the field with this value
|
|
319
|
+
* and runs the normal filter/selection logic so the user can confirm with Enter.
|
|
320
|
+
* Tab only fills the input when the placeholder matches at least one option under
|
|
321
|
+
* the prompt's filter (so the value remains selectable).
|
|
322
|
+
*/
|
|
323
|
+
placeholder?: string;
|
|
324
|
+
/**
|
|
325
|
+
* When `true` (single-select only), pressing Tab fills the input with the
|
|
326
|
+
* currently focused option's value, as if the user had typed it.
|
|
327
|
+
*/
|
|
328
|
+
completeOnTab?: boolean;
|
|
329
|
+
}
|
|
330
|
+
declare class AutocompletePrompt<T extends OptionLike$1> extends Prompt<T['value'] | T['value'][]> {
|
|
331
|
+
#private;
|
|
332
|
+
filteredOptions: T[];
|
|
333
|
+
multiple: boolean;
|
|
334
|
+
isNavigating: boolean;
|
|
335
|
+
selectedValues: Array<T['value']>;
|
|
336
|
+
focusedValue: T['value'] | undefined;
|
|
337
|
+
get cursor(): number;
|
|
338
|
+
get userInputWithCursor(): string;
|
|
339
|
+
get options(): T[];
|
|
340
|
+
constructor(opts: AutocompleteOptions<T>);
|
|
341
|
+
protected _isActionKey(char: string | undefined, key: Key): boolean;
|
|
342
|
+
deselectAll(): void;
|
|
343
|
+
toggleSelected(value: T['value']): void;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
interface ConfirmOptions extends PromptOptions<boolean, ConfirmPrompt> {
|
|
347
|
+
active: string;
|
|
348
|
+
inactive: string;
|
|
349
|
+
initialValue?: boolean;
|
|
350
|
+
}
|
|
351
|
+
declare class ConfirmPrompt extends Prompt<boolean> {
|
|
352
|
+
get cursor(): 0 | 1;
|
|
353
|
+
private get _value();
|
|
354
|
+
constructor(opts: ConfirmOptions);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
interface SegmentConfig {
|
|
358
|
+
type: 'year' | 'month' | 'day';
|
|
359
|
+
len: number;
|
|
360
|
+
}
|
|
361
|
+
interface DateParts {
|
|
362
|
+
year: string;
|
|
363
|
+
month: string;
|
|
364
|
+
day: string;
|
|
365
|
+
}
|
|
366
|
+
type DateFormat = 'YMD' | 'MDY' | 'DMY';
|
|
367
|
+
interface DateOptions extends PromptOptions<Date, DatePrompt> {
|
|
368
|
+
format?: DateFormat;
|
|
369
|
+
locale?: string;
|
|
370
|
+
separator?: string;
|
|
371
|
+
defaultValue?: Date;
|
|
372
|
+
initialValue?: Date;
|
|
373
|
+
minDate?: Date;
|
|
374
|
+
maxDate?: Date;
|
|
375
|
+
}
|
|
376
|
+
declare class DatePrompt extends Prompt<Date> {
|
|
377
|
+
#private;
|
|
378
|
+
inlineError: string;
|
|
379
|
+
get segmentCursor(): {
|
|
380
|
+
segmentIndex: number;
|
|
381
|
+
positionInSegment: number;
|
|
382
|
+
};
|
|
383
|
+
get segmentValues(): DateParts;
|
|
384
|
+
get segments(): readonly SegmentConfig[];
|
|
385
|
+
get separator(): string;
|
|
386
|
+
get formattedValue(): string;
|
|
387
|
+
constructor(opts: DateOptions);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
interface GroupMultiSelectOptions<T extends {
|
|
391
|
+
value: any;
|
|
392
|
+
}> extends PromptOptions<T['value'][], GroupMultiSelectPrompt<T>> {
|
|
393
|
+
options: Record<string, T[]>;
|
|
394
|
+
initialValues?: T['value'][];
|
|
395
|
+
required?: boolean;
|
|
396
|
+
cursorAt?: T['value'];
|
|
397
|
+
selectableGroups?: boolean;
|
|
398
|
+
}
|
|
399
|
+
declare class GroupMultiSelectPrompt<T extends {
|
|
400
|
+
value: any;
|
|
401
|
+
}> extends Prompt<T['value'][]> {
|
|
402
|
+
#private;
|
|
403
|
+
options: (T & {
|
|
404
|
+
group: string | boolean;
|
|
405
|
+
})[];
|
|
406
|
+
cursor: number;
|
|
407
|
+
getGroupItems(group: string): T[];
|
|
408
|
+
isGroupSelected(group: string): boolean;
|
|
409
|
+
private toggleValue;
|
|
410
|
+
constructor(opts: GroupMultiSelectOptions<T>);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
interface MultiLineOptions extends PromptOptions<string, MultiLinePrompt> {
|
|
414
|
+
placeholder?: string;
|
|
415
|
+
defaultValue?: string;
|
|
416
|
+
showSubmit?: boolean;
|
|
417
|
+
}
|
|
418
|
+
declare class MultiLinePrompt extends Prompt<string> {
|
|
419
|
+
#private;
|
|
420
|
+
focused: 'editor' | 'submit';
|
|
421
|
+
get userInputWithCursor(): string;
|
|
422
|
+
get cursor(): number;
|
|
423
|
+
protected _shouldSubmit(_char: string | undefined, _key: Key): boolean;
|
|
424
|
+
constructor(opts: MultiLineOptions);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
interface OptionLike {
|
|
428
|
+
value: any;
|
|
429
|
+
disabled?: boolean;
|
|
430
|
+
}
|
|
431
|
+
interface MultiSelectOptions<T extends OptionLike> extends PromptOptions<T['value'][], MultiSelectPrompt<T>> {
|
|
432
|
+
options: T[];
|
|
433
|
+
initialValues?: T['value'][];
|
|
434
|
+
required?: boolean;
|
|
435
|
+
cursorAt?: T['value'];
|
|
436
|
+
}
|
|
437
|
+
declare class MultiSelectPrompt<T extends OptionLike> extends Prompt<T['value'][]> {
|
|
438
|
+
options: T[];
|
|
439
|
+
cursor: number;
|
|
440
|
+
private get _value();
|
|
441
|
+
private get _enabledOptions();
|
|
442
|
+
private toggleAll;
|
|
443
|
+
private toggleInvert;
|
|
444
|
+
private toggleValue;
|
|
445
|
+
constructor(opts: MultiSelectOptions<T>);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
interface PasswordOptions extends PromptOptions<string, PasswordPrompt> {
|
|
449
|
+
mask?: string;
|
|
450
|
+
}
|
|
451
|
+
declare class PasswordPrompt extends Prompt<string> {
|
|
452
|
+
private _mask;
|
|
453
|
+
get cursor(): number;
|
|
454
|
+
get masked(): string;
|
|
455
|
+
get userInputWithCursor(): string;
|
|
456
|
+
clear(): void;
|
|
457
|
+
constructor({ mask, ...opts }: PasswordOptions);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
interface SelectOptions<T extends {
|
|
461
|
+
value: any;
|
|
462
|
+
disabled?: boolean;
|
|
463
|
+
}> extends PromptOptions<T['value'], SelectPrompt<T>> {
|
|
464
|
+
options: T[];
|
|
465
|
+
initialValue?: T['value'];
|
|
466
|
+
}
|
|
467
|
+
declare class SelectPrompt<T extends {
|
|
468
|
+
value: any;
|
|
469
|
+
disabled?: boolean;
|
|
470
|
+
}> extends Prompt<T['value']> {
|
|
471
|
+
options: T[];
|
|
472
|
+
cursor: number;
|
|
473
|
+
private get _selectedValue();
|
|
474
|
+
private changeValue;
|
|
475
|
+
constructor(opts: SelectOptions<T>);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
interface SelectKeyOptions<T extends {
|
|
479
|
+
value: string;
|
|
480
|
+
}> extends PromptOptions<T['value'], SelectKeyPrompt<T>> {
|
|
481
|
+
options: T[];
|
|
482
|
+
caseSensitive?: boolean;
|
|
483
|
+
}
|
|
484
|
+
declare class SelectKeyPrompt<T extends {
|
|
485
|
+
value: string;
|
|
486
|
+
}> extends Prompt<T['value']> {
|
|
487
|
+
options: T[];
|
|
488
|
+
cursor: number;
|
|
489
|
+
constructor(opts: SelectKeyOptions<T>);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
interface TextOptions extends PromptOptions<string, TextPrompt> {
|
|
493
|
+
placeholder?: string;
|
|
494
|
+
defaultValue?: string;
|
|
495
|
+
}
|
|
496
|
+
declare class TextPrompt extends Prompt<string> {
|
|
497
|
+
get userInputWithCursor(): string;
|
|
498
|
+
get cursor(): number;
|
|
499
|
+
constructor(opts: TextOptions);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export { AutocompletePrompt, CANCEL_SYMBOL, ConfirmPrompt, DatePrompt, GroupMultiSelectPrompt, MultiLinePrompt, MultiSelectPrompt, PasswordPrompt, Prompt, SelectKeyPrompt, SelectPrompt, TextPrompt, block, getColumns, getRows, isAccessible, isCancel, runValidation, settings, updateSettings, wrapTextWithPrefix };
|
|
503
|
+
export type { AutocompleteOptions, ClackSettings, ConfirmOptions, DateFormat, DateOptions, DateParts, GroupMultiSelectOptions, MultiLineOptions, MultiSelectOptions, PasswordOptions, PromptOptions, SelectKeyOptions, SelectOptions, ClackState as State, TextOptions, Validate };
|