pre-claude 0.0.1-beta.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/README.md +311 -0
- package/dist/cli.js +2643 -0
- package/dist/cli.js.map +7 -0
- package/dist/types.d.ts +842 -0
- package/dist/types.js +94 -0
- package/package.json +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# pre-claude
|
|
2
|
+
|
|
3
|
+
A TUI tool for building structured prompts for Claude. Define form structures in config files, fill them out interactively in the terminal, and generate documents using your local Claude Code settings.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Form structure defined in TypeScript config files
|
|
8
|
+
- Interactive TUI for filling out prompts
|
|
9
|
+
- Uses your local Claude Code configuration as-is
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Node.js 18+
|
|
14
|
+
- Claude Code installed
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install pre-claude
|
|
20
|
+
# or
|
|
21
|
+
pnpm add pre-claude
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Initialize Config
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx pre-claude init [-o filename] [-f]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Run TUI
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx pre-claude run --config ./pre-claude.config.ts
|
|
36
|
+
# or with scenario ID
|
|
37
|
+
npx pre-claude run --config ./pre-claude.config.ts --scenario design-doc
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Configuration
|
|
41
|
+
|
|
42
|
+
### Basic Structure
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// pre-claude.config.ts
|
|
46
|
+
import { defineConfig, defineScenario, type Step } from 'pre-claude';
|
|
47
|
+
|
|
48
|
+
const steps = [
|
|
49
|
+
{
|
|
50
|
+
slug: 'overview',
|
|
51
|
+
title: 'Overview',
|
|
52
|
+
description: 'Basic project information',
|
|
53
|
+
name: 'overview',
|
|
54
|
+
fields: [
|
|
55
|
+
{
|
|
56
|
+
id: 'projectName',
|
|
57
|
+
type: 'input',
|
|
58
|
+
label: 'Project Name',
|
|
59
|
+
description: 'Enter the name of your project',
|
|
60
|
+
required: true,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'description',
|
|
64
|
+
type: 'textarea',
|
|
65
|
+
label: 'Description',
|
|
66
|
+
description: 'Describe the project briefly',
|
|
67
|
+
rows: 5,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: 'priority',
|
|
71
|
+
type: 'select',
|
|
72
|
+
label: 'Priority',
|
|
73
|
+
description: 'Select the priority level',
|
|
74
|
+
options: [
|
|
75
|
+
{ value: 'low', label: 'Low' },
|
|
76
|
+
{ value: 'medium', label: 'Medium' },
|
|
77
|
+
{ value: 'high', label: 'High' },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
] as const satisfies Step[];
|
|
83
|
+
|
|
84
|
+
export default defineConfig({
|
|
85
|
+
scenarios: [
|
|
86
|
+
defineScenario({
|
|
87
|
+
id: 'design-doc',
|
|
88
|
+
name: 'Design Document',
|
|
89
|
+
steps,
|
|
90
|
+
prompt: ({ formData, aiContext }) =>
|
|
91
|
+
`Create a design document based on:\n${JSON.stringify({ formData, aiContext }, null, 2)}`,
|
|
92
|
+
outputDir: './docs',
|
|
93
|
+
}),
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Scenario Properties
|
|
99
|
+
|
|
100
|
+
| Property | Type | Required | Description |
|
|
101
|
+
|----------|------|----------|-------------|
|
|
102
|
+
| `id` | `string` | Yes | Unique identifier |
|
|
103
|
+
| `name` | `string` | Yes | Display name |
|
|
104
|
+
| `steps` | `Step[]` | Yes | Form wizard steps |
|
|
105
|
+
| `prompt` | `function` | Yes | Prompt generator function |
|
|
106
|
+
| `outputDir` | `string` | No | Directory for saved documents |
|
|
107
|
+
| `filename` | `string \| function` | No | Custom filename for saved documents |
|
|
108
|
+
|
|
109
|
+
## Field Types
|
|
110
|
+
|
|
111
|
+
### input
|
|
112
|
+
|
|
113
|
+
Text input field with optional type variants and autocomplete suggestions.
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
{
|
|
117
|
+
id: 'title',
|
|
118
|
+
type: 'input',
|
|
119
|
+
label: 'Title',
|
|
120
|
+
description: 'Enter the title',
|
|
121
|
+
placeholder: 'My Project',
|
|
122
|
+
required: true,
|
|
123
|
+
inputType: 'text', // 'text' | 'date' | 'url'
|
|
124
|
+
suggestions: ['Option A', 'Option B'], // autocomplete suggestions
|
|
125
|
+
default: 'Default Value',
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### textarea
|
|
130
|
+
|
|
131
|
+
Multi-line text input.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
{
|
|
135
|
+
id: 'description',
|
|
136
|
+
type: 'textarea',
|
|
137
|
+
label: 'Description',
|
|
138
|
+
description: 'Enter description',
|
|
139
|
+
rows: 5,
|
|
140
|
+
default: 'Default text',
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### select
|
|
145
|
+
|
|
146
|
+
Dropdown selection.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
{
|
|
150
|
+
id: 'priority',
|
|
151
|
+
type: 'select',
|
|
152
|
+
label: 'Priority',
|
|
153
|
+
description: 'Select priority',
|
|
154
|
+
options: [
|
|
155
|
+
{ value: 'low', label: 'Low' },
|
|
156
|
+
{ value: 'medium', label: 'Medium' },
|
|
157
|
+
{ value: 'high', label: 'High' },
|
|
158
|
+
],
|
|
159
|
+
default: 'medium',
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### checkbox
|
|
164
|
+
|
|
165
|
+
Boolean toggle.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
{
|
|
169
|
+
id: 'agree',
|
|
170
|
+
type: 'checkbox',
|
|
171
|
+
label: 'I agree to the terms',
|
|
172
|
+
description: 'You must agree to continue',
|
|
173
|
+
required: true,
|
|
174
|
+
default: false,
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Layouts
|
|
179
|
+
|
|
180
|
+
### repeatable
|
|
181
|
+
|
|
182
|
+
Dynamically add/remove field instances.
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
{
|
|
186
|
+
type: 'repeatable',
|
|
187
|
+
id: 'features',
|
|
188
|
+
label: 'Features',
|
|
189
|
+
minCount: 1,
|
|
190
|
+
defaultCount: 2,
|
|
191
|
+
field: {
|
|
192
|
+
type: 'group',
|
|
193
|
+
fields: [
|
|
194
|
+
{ id: 'name', type: 'input', label: 'Name', description: '' },
|
|
195
|
+
{ id: 'description', type: 'textarea', label: 'Description', description: '', rows: 2 },
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### group
|
|
202
|
+
|
|
203
|
+
Visual grouping of fields.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
{
|
|
207
|
+
type: 'group',
|
|
208
|
+
fields: [
|
|
209
|
+
{ id: 'street', type: 'input', label: 'Street', description: '' },
|
|
210
|
+
{ id: 'city', type: 'input', label: 'City', description: '' },
|
|
211
|
+
],
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Conditional Display
|
|
216
|
+
|
|
217
|
+
Fields support conditional visibility via the `when` property.
|
|
218
|
+
|
|
219
|
+
### Simple Condition
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
// Show when priority is 'high'
|
|
223
|
+
{ ..., when: { field: 'priority', is: 'high' } }
|
|
224
|
+
|
|
225
|
+
// Show when priority is 'high' or 'medium'
|
|
226
|
+
{ ..., when: { field: 'priority', is: ['high', 'medium'] } }
|
|
227
|
+
|
|
228
|
+
// Show when priority is NOT 'low'
|
|
229
|
+
{ ..., when: { field: 'priority', isNot: 'low' } }
|
|
230
|
+
|
|
231
|
+
// Show when checkbox is checked
|
|
232
|
+
{ ..., when: { field: 'hasDeadline', is: true } }
|
|
233
|
+
|
|
234
|
+
// Show when field is not empty
|
|
235
|
+
{ ..., when: { field: 'title', isNotEmpty: true } }
|
|
236
|
+
|
|
237
|
+
// Show when field is empty
|
|
238
|
+
{ ..., when: { field: 'notes', isEmpty: true } }
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### AND Condition
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
// Show when both conditions are true
|
|
245
|
+
{
|
|
246
|
+
...,
|
|
247
|
+
when: {
|
|
248
|
+
and: [
|
|
249
|
+
{ field: 'priority', is: 'high' },
|
|
250
|
+
{ field: 'type', is: 'feature' }
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### OR Condition
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
// Show when either condition is true
|
|
260
|
+
{
|
|
261
|
+
...,
|
|
262
|
+
when: {
|
|
263
|
+
or: [
|
|
264
|
+
{ field: 'priority', is: 'high' },
|
|
265
|
+
{ field: 'type', is: 'urgent' }
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Nested Conditions
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
// Complex nested condition
|
|
275
|
+
{
|
|
276
|
+
...,
|
|
277
|
+
when: {
|
|
278
|
+
or: [
|
|
279
|
+
{ field: 'priority', is: 'high' },
|
|
280
|
+
{
|
|
281
|
+
and: [
|
|
282
|
+
{ field: 'type', is: 'feature' },
|
|
283
|
+
{ field: 'status', is: 'approved' }
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Cross-Section References
|
|
292
|
+
|
|
293
|
+
Use dot notation to reference fields in other steps:
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
{ ..., when: { field: 'overview.priority', is: 'high' } }
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Development
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
pnpm install
|
|
303
|
+
pnpm build
|
|
304
|
+
pnpm dev
|
|
305
|
+
pnpm lint:fix
|
|
306
|
+
pnpm typecheck
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## License
|
|
310
|
+
|
|
311
|
+
MIT
|