spec-snake 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.ja.md +333 -0
- package/README.md +335 -0
- package/dist/cli.js +783 -0
- package/dist/cli.js.map +7 -0
- package/dist/client/assets/ChevronRightIcon-BcBiiChF.js +1 -0
- package/dist/client/assets/DocumentIcon-jB6zASay.js +1 -0
- package/dist/client/assets/Header-DN39nNWE.js +1 -0
- package/dist/client/assets/PlusIcon-DqYOBije.js +1 -0
- package/dist/client/assets/index-CSjjObwb.css +1 -0
- package/dist/client/assets/index-CT_VQ59w.js +1 -0
- package/dist/client/assets/index-D6usLrOW.js +26 -0
- package/dist/client/assets/index-DQxQHK-0.js +1 -0
- package/dist/client/assets/index-DYnzYTb1.js +1 -0
- package/dist/client/assets/index-Q_AobJB0.js +1 -0
- package/dist/client/assets/index-pyqED_5G.js +1 -0
- package/dist/client/assets/useStepFormStore-CBcs2c-9.js +41 -0
- package/dist/client/index.html +13 -0
- package/dist/types.d.ts +848 -0
- package/dist/types.js +99 -0
- package/package.json +85 -0
package/README.ja.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
# Spec Snake Beta
|
|
2
|
+
|
|
3
|
+
AI を活用した設計ドキュメントジェネレーター
|
|
4
|
+
|
|
5
|
+
- Config Base
|
|
6
|
+
- TypeScript の設定ファイルでシナリオ、フォーム、プロンプトを定義
|
|
7
|
+
- Multi Step Form
|
|
8
|
+
- ステップ形式のフォームで必要な情報を段階的に収集
|
|
9
|
+
- AI Generation
|
|
10
|
+
- Claude Agent SDK を使用し、収集した情報から高品質なドキュメントを生成
|
|
11
|
+
- MCP Integration
|
|
12
|
+
- Figma などの外部ツールと連携して、より詳細なドキュメントを生成可能
|
|
13
|
+
|
|
14
|
+
## コンセプト
|
|
15
|
+
|
|
16
|
+
下記の 3 つの概念を基本としてドキュメントを管理します。
|
|
17
|
+
|
|
18
|
+
- Scenario
|
|
19
|
+
- ドキュメントの種類を表す単位。技術設計書、実装方針など、目的ごとにシナリオを定義する
|
|
20
|
+
- Step
|
|
21
|
+
- シナリオ内のフォーム入力ステップ。複数のステップで情報を段階的に収集する
|
|
22
|
+
- Document
|
|
23
|
+
- 生成されるマークダウン形式のドキュメント。フォーム入力と AI によって生成される
|
|
24
|
+
|
|
25
|
+
## インストール
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm add @cut0/spec-snake
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Note**: GitHub Packages で公開されている
|
|
32
|
+
|
|
33
|
+
## 環境
|
|
34
|
+
|
|
35
|
+
- **Node.js**: 18 以上
|
|
36
|
+
- **Claude Code**: [Claude Code](https://claude.ai/code) がインストールされている必要があります。
|
|
37
|
+
|
|
38
|
+
## CLI コマンド
|
|
39
|
+
|
|
40
|
+
### `init` - 設定ファイルの初期化
|
|
41
|
+
|
|
42
|
+
新しい設定ファイルを作成します。
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx spec-snake-beta init
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
オプション:
|
|
49
|
+
|
|
50
|
+
| オプション | エイリアス | デフォルト | 説明 |
|
|
51
|
+
| ---------- | ---------- | ---------------------- | -------------------- |
|
|
52
|
+
| `--output` | `-o` | `spec-snake.config.ts` | 出力ファイルパス |
|
|
53
|
+
| `--force` | `-f` | `false` | 既存ファイルを上書き |
|
|
54
|
+
|
|
55
|
+
例:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# デフォルトのファイル名で作成
|
|
59
|
+
npx spec-snake-beta init
|
|
60
|
+
|
|
61
|
+
# カスタムファイル名で作成
|
|
62
|
+
npx spec-snake-beta init -o my-config.ts
|
|
63
|
+
|
|
64
|
+
# 既存ファイルを上書き
|
|
65
|
+
npx spec-snake-beta init -f
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### `start` - サーバーの起動
|
|
69
|
+
|
|
70
|
+
設定ファイルを読み込み、Web UI サーバーを起動します。
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npx spec-snake-beta start
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
オプション:
|
|
77
|
+
|
|
78
|
+
| オプション | エイリアス | デフォルト | 説明 |
|
|
79
|
+
| ---------- | ---------- | ---------------------- | -------------------- |
|
|
80
|
+
| `--config` | `-c` | `spec-snake.config.ts` | 設定ファイルのパス |
|
|
81
|
+
| `--port` | `-p` | `3000` | サーバーのポート番号 |
|
|
82
|
+
| `--host` | - | `localhost` | バインドするホスト |
|
|
83
|
+
|
|
84
|
+
例:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# デフォルト設定で起動
|
|
88
|
+
npx spec-snake-beta start
|
|
89
|
+
|
|
90
|
+
# カスタム設定ファイルとポートで起動
|
|
91
|
+
npx spec-snake-beta start -c my-config.ts -p 8080
|
|
92
|
+
|
|
93
|
+
# すべてのインターフェースでリッスン
|
|
94
|
+
npx spec-snake-beta start --host 0.0.0.0
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 設定ファイル
|
|
98
|
+
|
|
99
|
+
### 設定ファイルの例
|
|
100
|
+
|
|
101
|
+
設定ファイル例は [`examples/`](./examples/) ディレクトリを参照してください。
|
|
102
|
+
|
|
103
|
+
- [`examples/spec-snake.ts`](./examples/spec-snake-ja.ts) - 基本的な設定例
|
|
104
|
+
|
|
105
|
+
また、設定可能な項目は [src/types.ts](./src/types.ts) を参照してください。
|
|
106
|
+
|
|
107
|
+
### 設定構造
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { defineConfig, defineScenario } from '@cut0/spec-snake';
|
|
111
|
+
|
|
112
|
+
export default defineConfig({
|
|
113
|
+
scenarios: [
|
|
114
|
+
defineScenario({
|
|
115
|
+
id: 'design-doc',
|
|
116
|
+
name: '設計ドキュメント',
|
|
117
|
+
steps: [
|
|
118
|
+
{
|
|
119
|
+
slug: 'overview',
|
|
120
|
+
title: '概要',
|
|
121
|
+
description: 'プロジェクトの概要',
|
|
122
|
+
section: {
|
|
123
|
+
type: 'single',
|
|
124
|
+
name: 'overview',
|
|
125
|
+
fields: [
|
|
126
|
+
{ id: 'title', type: 'input', label: 'タイトル', description: '' },
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
prompt: '...',
|
|
132
|
+
outputDir: 'docs',
|
|
133
|
+
overrides: {
|
|
134
|
+
filename: ({ formData, timestamp }) =>
|
|
135
|
+
`${formData.overview?.title ?? 'untitled'}-${timestamp}.md`,
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
],
|
|
139
|
+
permissions: {
|
|
140
|
+
allowSave: true,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 型定義
|
|
146
|
+
|
|
147
|
+
**`Config`** - ルート設定オブジェクト
|
|
148
|
+
|
|
149
|
+
| プロパティ | 型 | 必須 | 説明 |
|
|
150
|
+
| ------------- | ------------- | ---- | ------------------------ |
|
|
151
|
+
| `scenarios` | `Scenario[]` | Yes | 利用可能なシナリオの配列 |
|
|
152
|
+
| `permissions` | `Permissions` | Yes | グローバル権限設定 |
|
|
153
|
+
|
|
154
|
+
**`Permissions`** - 権限設定
|
|
155
|
+
|
|
156
|
+
| プロパティ | 型 | 説明 |
|
|
157
|
+
| ----------- | --------- | ------------------------------ |
|
|
158
|
+
| `allowSave` | `boolean` | ドキュメントの保存を許可するか |
|
|
159
|
+
|
|
160
|
+
**`Scenario`** - シナリオ定義。各シナリオは 1 つのドキュメントタイプを表す
|
|
161
|
+
|
|
162
|
+
| プロパティ | 型 | 必須 | 説明 |
|
|
163
|
+
| ------------ | -------------------- | ---- | --------------------------------------- |
|
|
164
|
+
| `id` | `string` | Yes | URL で使用される一意の識別子 |
|
|
165
|
+
| `name` | `string` | Yes | 表示名 |
|
|
166
|
+
| `steps` | `Step[]` | Yes | フォームウィザードのステップ |
|
|
167
|
+
| `prompt` | `string \| Function` | Yes | Claude に送信するプロンプトテンプレート |
|
|
168
|
+
| `outputDir` | `string` | No | ドキュメントの保存先ディレクトリ |
|
|
169
|
+
| `aiSettings` | `AiSettings` | No | Claude Agent SDK の設定 |
|
|
170
|
+
| `hooks` | `ScenarioHooks` | No | ライフサイクルフック |
|
|
171
|
+
| `overrides` | `ScenarioOverrides` | No | デフォルト動作のオーバーライド |
|
|
172
|
+
|
|
173
|
+
**`Step`** - マルチステップフォームの各ステップ
|
|
174
|
+
|
|
175
|
+
| プロパティ | 型 | 必須 | 説明 |
|
|
176
|
+
| ------------- | --------- | ---- | ------------------------------------ |
|
|
177
|
+
| `slug` | `string` | Yes | URL フレンドリーな識別子 |
|
|
178
|
+
| `title` | `string` | Yes | ステップヘッダーに表示されるタイトル |
|
|
179
|
+
| `description` | `string` | Yes | タイトル下に表示される説明文 |
|
|
180
|
+
| `section` | `Section` | Yes | ステップのフィールドを含むセクション |
|
|
181
|
+
|
|
182
|
+
### `Section` - セクションは 2 種類
|
|
183
|
+
|
|
184
|
+
SingleSection - 1 回だけ入力するフィールドのグループ
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
{
|
|
188
|
+
type: 'single',
|
|
189
|
+
name: 'overview',
|
|
190
|
+
fields: [...]
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
ArraySection - 複数のエントリを追加できるフィールドのグループ
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
{
|
|
198
|
+
type: 'array',
|
|
199
|
+
name: 'requirements',
|
|
200
|
+
fields: [...],
|
|
201
|
+
minFieldCount: 1 // 最小エントリ数(オプション)
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### フィールドタイプ
|
|
206
|
+
|
|
207
|
+
#### InputField - テキスト入力
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
{
|
|
211
|
+
type: 'input',
|
|
212
|
+
id: 'title',
|
|
213
|
+
label: 'タイトル',
|
|
214
|
+
description: 'フィールドの説明',
|
|
215
|
+
placeholder: 'プレースホルダー',
|
|
216
|
+
required: true,
|
|
217
|
+
inputType: 'text' | 'date' | 'url',
|
|
218
|
+
suggestions: ['候補1', '候補2']
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### TextareaField - 複数行テキスト
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
{
|
|
226
|
+
type: 'textarea',
|
|
227
|
+
id: 'description',
|
|
228
|
+
label: '説明',
|
|
229
|
+
description: 'フィールドの説明',
|
|
230
|
+
rows: 4
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### SelectField - ドロップダウン選択
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
{
|
|
238
|
+
type: 'select',
|
|
239
|
+
id: 'priority',
|
|
240
|
+
label: '優先度',
|
|
241
|
+
description: 'フィールドの説明',
|
|
242
|
+
options: [
|
|
243
|
+
{ value: 'high', label: '高' },
|
|
244
|
+
{ value: 'medium', label: '中' },
|
|
245
|
+
{ value: 'low', label: '低' }
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### CheckboxField - チェックボックス
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
{
|
|
254
|
+
type: 'checkbox',
|
|
255
|
+
id: 'agree',
|
|
256
|
+
label: '同意する',
|
|
257
|
+
description: 'フィールドの説明'
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### `AiSettings` - Claude Agent SDK の設定オプション
|
|
262
|
+
|
|
263
|
+
| プロパティ | 型 | 説明 |
|
|
264
|
+
| --------------------------------- | --------------------------------- | --------------------------------------------------------- |
|
|
265
|
+
| `model` | `string` | 使用するモデル(例: `claude-sonnet-4-5-20250929`) |
|
|
266
|
+
| `fallbackModel` | `string` | フォールバックモデル |
|
|
267
|
+
| `maxTurns` | `number` | 最大ターン数 |
|
|
268
|
+
| `maxBudgetUsd` | `number` | USD での予算上限 |
|
|
269
|
+
| `tools` | `object` | ツール設定(`{ type: 'preset', preset: 'claude_code' }`) |
|
|
270
|
+
| `allowedTools` | `string[]` | 許可するツール |
|
|
271
|
+
| `disallowedTools` | `string[]` | 禁止するツール |
|
|
272
|
+
| `permissionMode` | `PermissionMode` | 権限モード |
|
|
273
|
+
| `allowDangerouslySkipPermissions` | `boolean` | 権限チェックをスキップ |
|
|
274
|
+
| `mcpServers` | `Record<string, McpServerConfig>` | MCP サーバー設定 |
|
|
275
|
+
|
|
276
|
+
#### 利用可能なツール
|
|
277
|
+
|
|
278
|
+
- ファイル操作: `Read`, `Write`, `Edit`, `Glob`, `Grep`, `NotebookEdit`
|
|
279
|
+
- コマンド実行: `Bash`
|
|
280
|
+
- Web: `WebSearch`, `WebFetch`
|
|
281
|
+
- エージェント: `Task`, `TodoWrite`
|
|
282
|
+
- コード補完: `LSP`
|
|
283
|
+
- MCP ツール: `mcp__<server>__<tool>` 形式
|
|
284
|
+
|
|
285
|
+
### `scenario.hooks` - ライフサイクルフック
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
{
|
|
289
|
+
// プレビュー生成後に呼ばれる
|
|
290
|
+
onPreview: async ({ formData, content }) => {
|
|
291
|
+
console.log('Preview generated');
|
|
292
|
+
},
|
|
293
|
+
// ドキュメント保存後に呼ばれる
|
|
294
|
+
onSave: async ({ content, filename, outputPath, formData }) => {
|
|
295
|
+
console.log(`Saved to ${outputPath}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### `scenario.overrides` - デフォルト動作のオーバーライド
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
{
|
|
304
|
+
// 静的ファイル名
|
|
305
|
+
filename: 'design-doc.md',
|
|
306
|
+
// または動的ファイル名
|
|
307
|
+
filename: ({ formData, timestamp }) =>
|
|
308
|
+
`${formData.project_name}-${timestamp}.md`
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### プロンプトテンプレート
|
|
313
|
+
|
|
314
|
+
プロンプト内で `{{INPUT_JSON}}` を使用すると、フォームデータが JSON 形式で挿入されます。
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
const prompt = `以下の入力に基づいて設計ドキュメントを生成してください。
|
|
318
|
+
|
|
319
|
+
{{INPUT_JSON}}
|
|
320
|
+
|
|
321
|
+
マークダウン形式で出力してください。`;
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
プロンプトは関数としても定義可能です。
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
const prompt = ({ formData }) =>
|
|
328
|
+
`${formData.doc_type} ドキュメントを生成: {{INPUT_JSON}}`;
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## ライセンス
|
|
332
|
+
|
|
333
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# Spec Snake Beta
|
|
2
|
+
|
|
3
|
+
AI-powered design document generator
|
|
4
|
+
|
|
5
|
+
[日本語版](./README.ja.md)
|
|
6
|
+
|
|
7
|
+
- Config Base
|
|
8
|
+
- Define scenarios, forms, and prompts in TypeScript config files
|
|
9
|
+
- Multi Step Form
|
|
10
|
+
- Collect required information step by step through wizard-style forms
|
|
11
|
+
- AI Generation
|
|
12
|
+
- Generate high-quality documents from collected information using Claude Agent SDK
|
|
13
|
+
- MCP Integration
|
|
14
|
+
- Connect with external tools like Figma to generate more detailed documents
|
|
15
|
+
|
|
16
|
+
## Concept
|
|
17
|
+
|
|
18
|
+
Documents are managed based on three core concepts:
|
|
19
|
+
|
|
20
|
+
- Scenario
|
|
21
|
+
- A unit representing the type of document. Define scenarios for each purpose such as technical design docs, implementation plans, etc.
|
|
22
|
+
- Step
|
|
23
|
+
- Form input steps within a scenario. Collect information progressively through multiple steps
|
|
24
|
+
- Document
|
|
25
|
+
- The generated markdown document. Created from form input and AI
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @cut0/spec-snake
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Note**: Published on GitHub Packages
|
|
34
|
+
|
|
35
|
+
## Requirements
|
|
36
|
+
|
|
37
|
+
- **Node.js**: 18 or higher
|
|
38
|
+
- **Claude Code**: [Claude Code](https://claude.ai/code) must be installed
|
|
39
|
+
|
|
40
|
+
## CLI Commands
|
|
41
|
+
|
|
42
|
+
### `init` - Initialize config file
|
|
43
|
+
|
|
44
|
+
Creates a new config file.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx spec-snake-beta init
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Options:
|
|
51
|
+
|
|
52
|
+
| Option | Alias | Default | Description |
|
|
53
|
+
| ---------- | ----- | ---------------------- | ------------------------ |
|
|
54
|
+
| `--output` | `-o` | `spec-snake.config.ts` | Output file path |
|
|
55
|
+
| `--force` | `-f` | `false` | Overwrite existing files |
|
|
56
|
+
|
|
57
|
+
Examples:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Create with default filename
|
|
61
|
+
npx spec-snake-beta init
|
|
62
|
+
|
|
63
|
+
# Create with custom filename
|
|
64
|
+
npx spec-snake-beta init -o my-config.ts
|
|
65
|
+
|
|
66
|
+
# Overwrite existing file
|
|
67
|
+
npx spec-snake-beta init -f
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### `start` - Start the server
|
|
71
|
+
|
|
72
|
+
Loads the config file and starts the Web UI server.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npx spec-snake-beta start
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Options:
|
|
79
|
+
|
|
80
|
+
| Option | Alias | Default | Description |
|
|
81
|
+
| ---------- | ----- | ---------------------- | ---------------- |
|
|
82
|
+
| `--config` | `-c` | `spec-snake.config.ts` | Config file path |
|
|
83
|
+
| `--port` | `-p` | `3000` | Server port |
|
|
84
|
+
| `--host` | - | `localhost` | Host to bind |
|
|
85
|
+
|
|
86
|
+
Examples:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Start with default settings
|
|
90
|
+
npx spec-snake-beta start
|
|
91
|
+
|
|
92
|
+
# Start with custom config and port
|
|
93
|
+
npx spec-snake-beta start -c my-config.ts -p 8080
|
|
94
|
+
|
|
95
|
+
# Listen on all interfaces
|
|
96
|
+
npx spec-snake-beta start --host 0.0.0.0
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Config File
|
|
100
|
+
|
|
101
|
+
### Config Examples
|
|
102
|
+
|
|
103
|
+
See the [`examples/`](./examples/) directory for config file examples.
|
|
104
|
+
|
|
105
|
+
- [`examples/spec-snake.ts`](./examples/spec-snake-ja.ts) - Basic config example
|
|
106
|
+
|
|
107
|
+
Also refer to [src/types.ts](./src/types.ts) for configurable options.
|
|
108
|
+
|
|
109
|
+
### Config Structure
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { defineConfig, defineScenario } from '@cut0/spec-snake';
|
|
113
|
+
|
|
114
|
+
export default defineConfig({
|
|
115
|
+
scenarios: [
|
|
116
|
+
defineScenario({
|
|
117
|
+
id: 'design-doc',
|
|
118
|
+
name: 'Design Document',
|
|
119
|
+
steps: [
|
|
120
|
+
{
|
|
121
|
+
slug: 'overview',
|
|
122
|
+
title: 'Overview',
|
|
123
|
+
description: 'Project overview',
|
|
124
|
+
section: {
|
|
125
|
+
type: 'single',
|
|
126
|
+
name: 'overview',
|
|
127
|
+
fields: [
|
|
128
|
+
{ id: 'title', type: 'input', label: 'Title', description: '' },
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
prompt: '...',
|
|
134
|
+
outputDir: 'docs',
|
|
135
|
+
overrides: {
|
|
136
|
+
filename: ({ formData, timestamp }) =>
|
|
137
|
+
`${formData.overview?.title ?? 'untitled'}-${timestamp}.md`,
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
140
|
+
],
|
|
141
|
+
permissions: {
|
|
142
|
+
allowSave: true,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Type Definitions
|
|
148
|
+
|
|
149
|
+
**`Config`** - Root config object
|
|
150
|
+
|
|
151
|
+
| Property | Type | Required | Description |
|
|
152
|
+
| ------------- | ------------- | -------- | ------------------------ |
|
|
153
|
+
| `scenarios` | `Scenario[]` | Yes | Array of scenarios |
|
|
154
|
+
| `permissions` | `Permissions` | Yes | Global permission config |
|
|
155
|
+
|
|
156
|
+
**`Permissions`** - Permission settings
|
|
157
|
+
|
|
158
|
+
| Property | Type | Description |
|
|
159
|
+
| ----------- | --------- | ------------------------------ |
|
|
160
|
+
| `allowSave` | `boolean` | Whether to allow saving docs |
|
|
161
|
+
|
|
162
|
+
**`Scenario`** - Scenario definition. Each scenario represents one document type
|
|
163
|
+
|
|
164
|
+
| Property | Type | Required | Description |
|
|
165
|
+
| ------------ | -------------------- | -------- | ------------------------------------ |
|
|
166
|
+
| `id` | `string` | Yes | Unique identifier used in URL |
|
|
167
|
+
| `name` | `string` | Yes | Display name |
|
|
168
|
+
| `steps` | `Step[]` | Yes | Form wizard steps |
|
|
169
|
+
| `prompt` | `string \| Function` | Yes | Prompt template sent to Claude |
|
|
170
|
+
| `outputDir` | `string` | No | Directory for saving documents |
|
|
171
|
+
| `aiSettings` | `AiSettings` | No | Claude Agent SDK settings |
|
|
172
|
+
| `hooks` | `ScenarioHooks` | No | Lifecycle hooks |
|
|
173
|
+
| `overrides` | `ScenarioOverrides` | No | Override default behaviors |
|
|
174
|
+
|
|
175
|
+
**`Step`** - Each step in the multi-step form
|
|
176
|
+
|
|
177
|
+
| Property | Type | Required | Description |
|
|
178
|
+
| ------------- | --------- | -------- | ---------------------------------- |
|
|
179
|
+
| `slug` | `string` | Yes | URL-friendly identifier |
|
|
180
|
+
| `title` | `string` | Yes | Title displayed in step header |
|
|
181
|
+
| `description` | `string` | Yes | Description shown below title |
|
|
182
|
+
| `section` | `Section` | Yes | Section containing step fields |
|
|
183
|
+
|
|
184
|
+
### `Section` - Two types available
|
|
185
|
+
|
|
186
|
+
SingleSection - A group of fields entered once
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
{
|
|
190
|
+
type: 'single',
|
|
191
|
+
name: 'overview',
|
|
192
|
+
fields: [...]
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
ArraySection - A group of fields that can have multiple entries
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
{
|
|
200
|
+
type: 'array',
|
|
201
|
+
name: 'requirements',
|
|
202
|
+
fields: [...],
|
|
203
|
+
minFieldCount: 1 // Minimum entries (optional)
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Field Types
|
|
208
|
+
|
|
209
|
+
#### InputField - Text input
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
{
|
|
213
|
+
type: 'input',
|
|
214
|
+
id: 'title',
|
|
215
|
+
label: 'Title',
|
|
216
|
+
description: 'Field description',
|
|
217
|
+
placeholder: 'Placeholder',
|
|
218
|
+
required: true,
|
|
219
|
+
inputType: 'text' | 'date' | 'url',
|
|
220
|
+
suggestions: ['Option 1', 'Option 2']
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### TextareaField - Multi-line text
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
{
|
|
228
|
+
type: 'textarea',
|
|
229
|
+
id: 'description',
|
|
230
|
+
label: 'Description',
|
|
231
|
+
description: 'Field description',
|
|
232
|
+
rows: 4
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### SelectField - Dropdown select
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
{
|
|
240
|
+
type: 'select',
|
|
241
|
+
id: 'priority',
|
|
242
|
+
label: 'Priority',
|
|
243
|
+
description: 'Field description',
|
|
244
|
+
options: [
|
|
245
|
+
{ value: 'high', label: 'High' },
|
|
246
|
+
{ value: 'medium', label: 'Medium' },
|
|
247
|
+
{ value: 'low', label: 'Low' }
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### CheckboxField - Checkbox
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
{
|
|
256
|
+
type: 'checkbox',
|
|
257
|
+
id: 'agree',
|
|
258
|
+
label: 'I agree',
|
|
259
|
+
description: 'Field description'
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### `AiSettings` - Claude Agent SDK settings
|
|
264
|
+
|
|
265
|
+
| Property | Type | Description |
|
|
266
|
+
| --------------------------------- | --------------------------------- | --------------------------------------------------------- |
|
|
267
|
+
| `model` | `string` | Model to use (e.g., `claude-sonnet-4-5-20250929`) |
|
|
268
|
+
| `fallbackModel` | `string` | Fallback model |
|
|
269
|
+
| `maxTurns` | `number` | Maximum turns |
|
|
270
|
+
| `maxBudgetUsd` | `number` | Budget limit in USD |
|
|
271
|
+
| `tools` | `object` | Tool settings (`{ type: 'preset', preset: 'claude_code' }`) |
|
|
272
|
+
| `allowedTools` | `string[]` | Allowed tools |
|
|
273
|
+
| `disallowedTools` | `string[]` | Disallowed tools |
|
|
274
|
+
| `permissionMode` | `PermissionMode` | Permission mode |
|
|
275
|
+
| `allowDangerouslySkipPermissions` | `boolean` | Skip permission checks |
|
|
276
|
+
| `mcpServers` | `Record<string, McpServerConfig>` | MCP server config |
|
|
277
|
+
|
|
278
|
+
#### Available Tools
|
|
279
|
+
|
|
280
|
+
- File operations: `Read`, `Write`, `Edit`, `Glob`, `Grep`, `NotebookEdit`
|
|
281
|
+
- Command execution: `Bash`
|
|
282
|
+
- Web: `WebSearch`, `WebFetch`
|
|
283
|
+
- Agents: `Task`, `TodoWrite`
|
|
284
|
+
- Code completion: `LSP`
|
|
285
|
+
- MCP tools: `mcp__<server>__<tool>` format
|
|
286
|
+
|
|
287
|
+
### `scenario.hooks` - Lifecycle hooks
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
{
|
|
291
|
+
// Called after preview generation
|
|
292
|
+
onPreview: async ({ formData, content }) => {
|
|
293
|
+
console.log('Preview generated');
|
|
294
|
+
},
|
|
295
|
+
// Called after document save
|
|
296
|
+
onSave: async ({ content, filename, outputPath, formData }) => {
|
|
297
|
+
console.log(`Saved to ${outputPath}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### `scenario.overrides` - Override default behaviors
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
{
|
|
306
|
+
// Static filename
|
|
307
|
+
filename: 'design-doc.md',
|
|
308
|
+
// Or dynamic filename
|
|
309
|
+
filename: ({ formData, timestamp }) =>
|
|
310
|
+
`${formData.project_name}-${timestamp}.md`
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Prompt Template
|
|
315
|
+
|
|
316
|
+
Use `{{INPUT_JSON}}` in prompts to insert form data as JSON.
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
const prompt = `Generate a design document based on the following input.
|
|
320
|
+
|
|
321
|
+
{{INPUT_JSON}}
|
|
322
|
+
|
|
323
|
+
Output in markdown format.`;
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Prompts can also be defined as functions.
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
const prompt = ({ formData }) =>
|
|
330
|
+
`Generate ${formData.doc_type} document: {{INPUT_JSON}}`;
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## License
|
|
334
|
+
|
|
335
|
+
MIT
|