lean-agents 0.0.0-stage → 0.8.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/LICENSE +21 -0
- package/README.es.md +454 -0
- package/README.md +453 -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 +186 -0
- package/core/mcp.json +38 -0
- package/core/pins.json +30 -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 +29 -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/bump-pins.mjs +104 -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/copilot-context-mode.mjs +33 -0
- package/scripts/labels.sh +55 -0
- package/scripts/lean.mjs +700 -0
- package/scripts/lib/adapters/antigravity.mjs +72 -0
- package/scripts/lib/adapters/claude.mjs +122 -0
- package/scripts/lib/adapters/copilot-cli.mjs +81 -0
- package/scripts/lib/adapters/cursor.mjs +60 -0
- package/scripts/lib/adapters/opencode-v1.mjs +86 -0
- package/scripts/lib/adapters/opencode-v2.mjs +168 -0
- package/scripts/lib/adapters/vscode-copilot.mjs +56 -0
- package/scripts/lib/adhd.mjs +28 -0
- package/scripts/lib/adopt.mjs +474 -0
- package/scripts/lib/agent-lifecycle.mjs +163 -0
- package/scripts/lib/copilot-usage.mjs +49 -0
- package/scripts/lib/doctor.mjs +207 -0
- package/scripts/lib/feedback.mjs +30 -0
- package/scripts/lib/fsops.mjs +291 -0
- package/scripts/lib/gsd.mjs +42 -0
- package/scripts/lib/inventory.mjs +195 -0
- package/scripts/lib/lean-update.mjs +30 -0
- package/scripts/lib/migrate.mjs +407 -0
- package/scripts/lib/network.mjs +79 -0
- package/scripts/lib/node-runtime.mjs +85 -0
- package/scripts/lib/parallel.mjs +265 -0
- package/scripts/lib/pins.mjs +47 -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/system.mjs +178 -0
- package/scripts/lib/terminals.mjs +218 -0
- package/scripts/lib/ui.mjs +34 -0
- package/scripts/lib/unverified.mjs +49 -0
- package/scripts/lib/upgrade.mjs +130 -0
- package/scripts/lib/verify-commit.mjs +16 -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 +43 -0
- package/scripts/release.mjs +46 -0
- package/scripts/verify-pins.mjs +36 -0
- package/scripts/version-watch.mjs +118 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clack/core",
|
|
3
|
+
"version": "1.5.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.mts",
|
|
10
|
+
"default": "./dist/index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"types": "./dist/index.d.mts",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/bombshell-dev/clack.git",
|
|
18
|
+
"directory": "packages/core"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/bombshell-dev/clack/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/bombshell-dev/clack/tree/main/packages/core#readme",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"ask",
|
|
29
|
+
"clack",
|
|
30
|
+
"cli",
|
|
31
|
+
"command-line",
|
|
32
|
+
"command",
|
|
33
|
+
"input",
|
|
34
|
+
"interact",
|
|
35
|
+
"interface",
|
|
36
|
+
"menu",
|
|
37
|
+
"prompt",
|
|
38
|
+
"prompts",
|
|
39
|
+
"stdin",
|
|
40
|
+
"ui"
|
|
41
|
+
],
|
|
42
|
+
"author": {
|
|
43
|
+
"name": "Nate Moore",
|
|
44
|
+
"email": "nate@natemoo.re",
|
|
45
|
+
"url": "https://twitter.com/n_moore"
|
|
46
|
+
},
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">= 20.12.0"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"fast-wrap-ansi": "^0.2.0",
|
|
53
|
+
"sisteransi": "^1.0.5"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"arktype": "^2.2.0",
|
|
57
|
+
"vitest": "^3.2.4"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "unbuild",
|
|
61
|
+
"test": "vitest run"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
MIT License Copyright (c) 2025-Present [Bombshell contributors](https://bomb.sh/team)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
# `@clack/prompts`
|
|
2
|
+
|
|
3
|
+
Effortlessly build beautiful command-line apps 🪄 [Try the demo](https://stackblitz.com/edit/clack-prompts?file=index.js)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
`@clack/prompts` is an opinionated, pre-styled wrapper around [`@clack/core`](https://www.npmjs.com/package/@clack/core).
|
|
10
|
+
|
|
11
|
+
- 🤏 80% smaller than other options
|
|
12
|
+
- 💎 Beautiful, minimal UI
|
|
13
|
+
- ✅ Simple API
|
|
14
|
+
- 🧱 Comes with `text`, `password`, `confirm`, `date`, `select`, `autocomplete`, `selectKey`, `multiselect`, `path`, and `spinner` components
|
|
15
|
+
|
|
16
|
+
## Basics
|
|
17
|
+
|
|
18
|
+
### Setup
|
|
19
|
+
|
|
20
|
+
The `intro` and `outro` functions will print a message to begin or end a prompt session, respectively.
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { intro, outro } from '@clack/prompts';
|
|
24
|
+
|
|
25
|
+
intro(`create-my-app`);
|
|
26
|
+
// Do stuff
|
|
27
|
+
outro(`You're all set!`);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Cancellation
|
|
31
|
+
|
|
32
|
+
The `isCancel` function is a guard that detects when a user cancels a question with `CTRL + C`. You should handle this situation for each prompt, optionally providing a nice cancellation message with the `cancel` utility.
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import { isCancel, cancel, text } from '@clack/prompts';
|
|
36
|
+
|
|
37
|
+
const value = await text({
|
|
38
|
+
message: 'What is the meaning of life?',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (isCancel(value)) {
|
|
42
|
+
cancel('Operation cancelled.');
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Components
|
|
48
|
+
|
|
49
|
+
### Text
|
|
50
|
+
|
|
51
|
+
The text component accepts a single line of text.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { text } from '@clack/prompts';
|
|
55
|
+
|
|
56
|
+
const meaning = await text({
|
|
57
|
+
message: 'What is the meaning of life?',
|
|
58
|
+
placeholder: 'Not sure',
|
|
59
|
+
initialValue: '42',
|
|
60
|
+
validate(value) {
|
|
61
|
+
if (value.length === 0) return `Value is required!`;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Password
|
|
67
|
+
|
|
68
|
+
The password prompt behaves like the [`text`](#text) prompt, but masks the input as the user types.
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
import { password } from '@clack/prompts';
|
|
72
|
+
|
|
73
|
+
const secret = await password({
|
|
74
|
+
message: 'Set a password.',
|
|
75
|
+
mask: '*',
|
|
76
|
+
validate(value) {
|
|
77
|
+
if (!value || value.length < 8) return 'Password must be at least 8 characters.';
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Confirm
|
|
83
|
+
|
|
84
|
+
The `confirm` prompt accepts a yes or no choice, returning a boolean value corresponding to the user's selection.
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
import { confirm } from '@clack/prompts';
|
|
88
|
+
|
|
89
|
+
const shouldContinue = await confirm({
|
|
90
|
+
message: 'Do you want to continue?',
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Date
|
|
95
|
+
|
|
96
|
+
The `date` prompt provides an interactive date picker, allowing users to navigate between year, month, and day segments and increment/decrement values using keyboard controls.
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
import { date } from '@clack/prompts';
|
|
100
|
+
|
|
101
|
+
const birthday = await date({
|
|
102
|
+
message: 'Pick your birthday',
|
|
103
|
+
minDate: new Date('1900-01-01'),
|
|
104
|
+
initialValue: new Date(),
|
|
105
|
+
maxDate: new Date(),
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Select
|
|
110
|
+
|
|
111
|
+
The select component allows a user to choose one value from a list of options. The result is the `value` prop of a given option.
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
import { select } from '@clack/prompts';
|
|
115
|
+
|
|
116
|
+
const projectType = await select({
|
|
117
|
+
message: 'Pick a project type.',
|
|
118
|
+
options: [
|
|
119
|
+
{ value: 'ts', label: 'TypeScript' },
|
|
120
|
+
{ value: 'js', label: 'JavaScript', disabled: true },
|
|
121
|
+
{ value: 'coffee', label: 'CoffeeScript', hint: 'oh no' },
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Autocomplete
|
|
127
|
+
|
|
128
|
+
The `autocomplete` prompt combines text input with a searchable list of options. It's perfect for when you have a large list of options and want to help users find what they're looking for quickly.
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
import { autocomplete } from '@clack/prompts';
|
|
132
|
+
|
|
133
|
+
const framework = await autocomplete({
|
|
134
|
+
message: 'Pick a framework.',
|
|
135
|
+
placeholder: 'Type to search...',
|
|
136
|
+
options: [
|
|
137
|
+
{ value: 'next', label: 'Next.js' },
|
|
138
|
+
{ value: 'nuxt', label: 'Nuxt' },
|
|
139
|
+
{ value: 'sveltekit', label: 'SvelteKit' },
|
|
140
|
+
{ value: 'remix', label: 'Remix' },
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Autocomplete Multi-Select
|
|
146
|
+
|
|
147
|
+
The `autocompleteMultiselect` prompt combines the search functionality of [autocomplete](#autocomplete) with the ability to select multiple options.
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
import { autocomplete } from '@clack/prompts';
|
|
151
|
+
|
|
152
|
+
const framework = await autocomplete({
|
|
153
|
+
message: 'Search for a framework',
|
|
154
|
+
options: [
|
|
155
|
+
{ value: 'next', label: 'Next.js', hint: 'React framework' },
|
|
156
|
+
{ value: 'astro', label: 'Astro', hint: 'Content-focused' },
|
|
157
|
+
{ value: 'svelte', label: 'SvelteKit', hint: 'Compile-time framework' },
|
|
158
|
+
{ value: 'remix', label: 'Remix', hint: 'Full stack framework' },
|
|
159
|
+
{ value: 'nuxt', label: 'Nuxt', hint: 'Vue framework' },
|
|
160
|
+
],
|
|
161
|
+
placeholder: 'Type to search...',
|
|
162
|
+
maxItems: 5,
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Select Key
|
|
167
|
+
|
|
168
|
+
The `selectKey` component lets a user choose an option by pressing its single-character string `value` key directly.
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
import { selectKey } from '@clack/prompts';
|
|
172
|
+
|
|
173
|
+
const action = await selectKey({
|
|
174
|
+
message: 'Pick an action.',
|
|
175
|
+
options: [
|
|
176
|
+
{ value: 'd', label: 'Deploy' },
|
|
177
|
+
{ value: 't', label: 'Run tests' },
|
|
178
|
+
{ value: 'q', label: 'Quit' },
|
|
179
|
+
],
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Multi-Select
|
|
184
|
+
|
|
185
|
+
The `multiselect` component allows a user to choose many values from a list of options. The result is an array with all selected `value` props.
|
|
186
|
+
|
|
187
|
+
```js
|
|
188
|
+
import { multiselect } from '@clack/prompts';
|
|
189
|
+
|
|
190
|
+
const additionalTools = await multiselect({
|
|
191
|
+
message: 'Select additional tools.',
|
|
192
|
+
options: [
|
|
193
|
+
{ value: 'eslint', label: 'ESLint', hint: 'recommended' },
|
|
194
|
+
{ value: 'prettier', label: 'Prettier', disabled: true },
|
|
195
|
+
{ value: 'gh-action', label: 'GitHub Action' },
|
|
196
|
+
],
|
|
197
|
+
required: false,
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
It is also possible to select multiple items arranged into hierarchy by using `groupMultiselect`:
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
import { groupMultiselect } from '@clack/prompts';
|
|
205
|
+
|
|
206
|
+
const basket = await groupMultiselect({
|
|
207
|
+
message: 'Select your favorite fruits and vegetables:',
|
|
208
|
+
options: {
|
|
209
|
+
fruits: [
|
|
210
|
+
{ value: 'apple', label: 'apple' },
|
|
211
|
+
{ value: 'banana', label: 'banana' },
|
|
212
|
+
{ value: 'cherry', label: 'cherry' },
|
|
213
|
+
],
|
|
214
|
+
vegetables: [
|
|
215
|
+
{ value: 'carrot', label: 'carrot' },
|
|
216
|
+
{ value: 'spinach', label: 'spinach' },
|
|
217
|
+
{ value: 'potato', label: 'potato' },
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Multi-Line Text
|
|
224
|
+
|
|
225
|
+
The multi-line prompt accepts multiple lines of text input. By default, pressing `Enter` twice submits the input.
|
|
226
|
+
|
|
227
|
+
```js
|
|
228
|
+
import { multiline } from '@clack/prompts';
|
|
229
|
+
|
|
230
|
+
const bio = await multiline({
|
|
231
|
+
message: 'Tell us about yourself.',
|
|
232
|
+
placeholder: 'Start typing...',
|
|
233
|
+
validate(value) {
|
|
234
|
+
if (value.length === 0) return `value is required`;
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Set `showSubmit` to display an explicit submit button instead of double `Enter` submission:
|
|
240
|
+
|
|
241
|
+
```js
|
|
242
|
+
const bio = await multiline({
|
|
243
|
+
message: 'Tell us about yourself.',
|
|
244
|
+
showSubmit: true,
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Path
|
|
249
|
+
|
|
250
|
+
The `path` prompt extends [`autocomplete`](#autocomplete) to provide file and directory suggestions.
|
|
251
|
+
|
|
252
|
+
```js
|
|
253
|
+
import { path } from '@clack/prompts';
|
|
254
|
+
|
|
255
|
+
const targetDir = await path({
|
|
256
|
+
message: 'Select an existing directory.',
|
|
257
|
+
directory: true,
|
|
258
|
+
});
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Spinner
|
|
262
|
+
|
|
263
|
+
The spinner component surfaces a pending action, such as a long-running download or dependency installation.
|
|
264
|
+
|
|
265
|
+
```js
|
|
266
|
+
import { spinner } from '@clack/prompts';
|
|
267
|
+
|
|
268
|
+
const s = spinner();
|
|
269
|
+
s.start('Installing via npm');
|
|
270
|
+
// Do installation here
|
|
271
|
+
s.stop('Installed via npm');
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Progress
|
|
275
|
+
|
|
276
|
+
The progress component extends the spinner component to add a progress bar to visualize the progression of an action.
|
|
277
|
+
|
|
278
|
+
```js
|
|
279
|
+
import { progress } from '@clack/prompts';
|
|
280
|
+
|
|
281
|
+
const p = progress({ max: 10 });
|
|
282
|
+
p.start('Downloading archive');
|
|
283
|
+
// Do download here
|
|
284
|
+
p.advance(3, 'Downloading (30%)');
|
|
285
|
+
// ...
|
|
286
|
+
p.advance(5, 'Downloading (80%)');
|
|
287
|
+
// ...
|
|
288
|
+
p.stop('Archive downloaded');
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Utilities
|
|
292
|
+
|
|
293
|
+
### Grouping
|
|
294
|
+
|
|
295
|
+
Grouping prompts together is a great way to keep your code organized. This accepts a JSON object with a name that can be used to reference the group later. The second argument is an optional but has a `onCancel` callback that will be called if the user cancels one of the prompts in the group.
|
|
296
|
+
|
|
297
|
+
```js
|
|
298
|
+
import * as p from '@clack/prompts';
|
|
299
|
+
|
|
300
|
+
const group = await p.group(
|
|
301
|
+
{
|
|
302
|
+
name: () => p.text({ message: 'What is your name?' }),
|
|
303
|
+
age: () => p.text({ message: 'What is your age?' }),
|
|
304
|
+
color: ({ results }) =>
|
|
305
|
+
p.multiselect({
|
|
306
|
+
message: `What is your favorite color ${results.name}?`,
|
|
307
|
+
options: [
|
|
308
|
+
{ value: 'red', label: 'Red' },
|
|
309
|
+
{ value: 'green', label: 'Green' },
|
|
310
|
+
{ value: 'blue', label: 'Blue' },
|
|
311
|
+
],
|
|
312
|
+
}),
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
// On Cancel callback that wraps the group
|
|
316
|
+
// So if the user cancels one of the prompts in the group this function will be called
|
|
317
|
+
onCancel: ({ results }) => {
|
|
318
|
+
p.cancel('Operation cancelled.');
|
|
319
|
+
process.exit(0);
|
|
320
|
+
},
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
console.log(group.name, group.age, group.color);
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Tasks
|
|
328
|
+
|
|
329
|
+
Execute multiple tasks in spinners.
|
|
330
|
+
|
|
331
|
+
```js
|
|
332
|
+
import { tasks } from '@clack/prompts';
|
|
333
|
+
|
|
334
|
+
await tasks([
|
|
335
|
+
{
|
|
336
|
+
title: 'Installing via npm',
|
|
337
|
+
task: async (message) => {
|
|
338
|
+
// Do installation here
|
|
339
|
+
return 'Installed via npm';
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
]);
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Logs
|
|
346
|
+
|
|
347
|
+
```js
|
|
348
|
+
import { log } from '@clack/prompts';
|
|
349
|
+
|
|
350
|
+
log.info('Info!');
|
|
351
|
+
log.success('Success!');
|
|
352
|
+
log.step('Step!');
|
|
353
|
+
log.warn('Warn!');
|
|
354
|
+
log.error('Error!');
|
|
355
|
+
log.message('Hello, World', { symbol: color.cyan('~') });
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
### Stream
|
|
360
|
+
|
|
361
|
+
When interacting with dynamic LLMs or other streaming message providers, use the `stream` APIs to log messages from an iterable, even an async one.
|
|
362
|
+
|
|
363
|
+
```js
|
|
364
|
+
import { stream } from '@clack/prompts';
|
|
365
|
+
|
|
366
|
+
stream.info((function *() { yield 'Info!'; })());
|
|
367
|
+
stream.success((function *() { yield 'Success!'; })());
|
|
368
|
+
stream.step((function *() { yield 'Step!'; })());
|
|
369
|
+
stream.warn((function *() { yield 'Warn!'; })());
|
|
370
|
+
stream.error((function *() { yield 'Error!'; })());
|
|
371
|
+
stream.message((function *() { yield 'Hello'; yield ", World" })(), { symbol: color.cyan('~') });
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+

|
|
375
|
+
|
|
376
|
+
### Task Log
|
|
377
|
+
|
|
378
|
+
When executing a sub-process or a similar sub-task, `taskLog` can be used to render the output continuously and clear it at the end if it was successful.
|
|
379
|
+
|
|
380
|
+
```js
|
|
381
|
+
import { taskLog } from '@clack/prompts';
|
|
382
|
+
|
|
383
|
+
const log = taskLog({
|
|
384
|
+
title: 'Running npm install'
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
for await (const line of npmInstall()) {
|
|
388
|
+
log.message(line);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (success) {
|
|
392
|
+
log.success('Done!');
|
|
393
|
+
} else {
|
|
394
|
+
log.error('Failed!');
|
|
395
|
+
}
|
|
396
|
+
```
|