ai-wingman 0.0.2
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 +231 -0
- package/dist/wingman.js +7210 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# ai-wingman
|
|
2
|
+
|
|
3
|
+
Scaffold production-ready AI patterns into your existing Next.js app — one command per pattern.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx ai-wingman add chat
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
ai-wingman wires together the right SDK primitives, generates plain TypeScript files you own, and exits. There is no runtime dependency on ai-wingman after scaffolding.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Patterns
|
|
14
|
+
|
|
15
|
+
| Command | Core primitive | What you get |
|
|
16
|
+
|---------|---------------|-------------|
|
|
17
|
+
| `wingman add chat` | `streamText` | Streaming chat route, conversation storage, multi-turn page |
|
|
18
|
+
| `wingman add structured-output` | `generateText + Output.object` | Typed JSON route, Zod schema, React hook |
|
|
19
|
+
| `wingman add tools` | `streamText + tools` | Tool-calling route, typed tool stubs |
|
|
20
|
+
| `wingman add stream-object` | `streamObject + useObject` | Streaming structured JSON route and hook |
|
|
21
|
+
| `wingman add rag` | `embed + cosineSimilarity` | Embed route, query route, vector store, client hook |
|
|
22
|
+
| `wingman add interrupt` | `tool({ needsApproval: true }) + addToolApprovalResponse` | Human-in-the-loop approval route, widget, page |
|
|
23
|
+
| `wingman add agent` | `streamText + stopWhen: stepCountIs(N)` | Autonomous agent route, tool stubs, storage, page |
|
|
24
|
+
| `wingman add multimodal` | `convertToModelMessages` | Vision-aware chat route and page with image upload |
|
|
25
|
+
| `wingman add audio` | `experimental_transcribe` / `experimental_generateSpeech` | Transcription route, TTS route, recording page |
|
|
26
|
+
| `wingman add eval` | `generateText` (LLM judge) | Runnable eval script with string-match and judge scoring |
|
|
27
|
+
| `wingman add image-gen` | `generateImage` | Prompt-to-image route (DALL·E), display page with download |
|
|
28
|
+
| `wingman add generative-ui` | `streamUI` (ai/rsc) | Server action that streams React component trees to the client |
|
|
29
|
+
| `wingman add document-processing` | `generateText + Output.object` | File upload route, schema, and hook for PDF / document extraction |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
Run inside an existing Next.js + TypeScript project:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx ai-wingman add chat
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The CLI will:
|
|
42
|
+
|
|
43
|
+
1. Detect Next.js, TypeScript, and shadcn/ui prerequisites
|
|
44
|
+
2. Ask which provider (Anthropic / OpenAI / Google)
|
|
45
|
+
3. Ask pattern-specific questions (storage, auth, output paths)
|
|
46
|
+
4. Show the full plan and ask for confirmation
|
|
47
|
+
5. Install packages, run `npx ai-elements@latest` and `npx shadcn@latest add`
|
|
48
|
+
6. Write your files
|
|
49
|
+
7. Print the env vars you need to set
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## CLI commands
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
wingman add <pattern> # scaffold a pattern interactively
|
|
57
|
+
wingman list # list all available patterns
|
|
58
|
+
wingman add <pattern> --overwrite # re-scaffold, overwriting existing files
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Pass flags to skip prompts. `-y` / `--yes` accepts all defaults.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Fully non-interactive
|
|
65
|
+
npx ai-wingman add chat --provider anthropic --storage memory --yes
|
|
66
|
+
|
|
67
|
+
# Custom output paths
|
|
68
|
+
npx ai-wingman add chat --provider anthropic --api-route app/api/assistant/route.ts --yes
|
|
69
|
+
|
|
70
|
+
# Different storage backend
|
|
71
|
+
npx ai-wingman add rag --provider openai --storage pgvector --yes
|
|
72
|
+
|
|
73
|
+
# Re-scaffold after an update
|
|
74
|
+
npx ai-wingman add chat --provider anthropic --overwrite --yes
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Providers
|
|
80
|
+
|
|
81
|
+
| Flag | Package installed | Env var |
|
|
82
|
+
|------|------------------|---------|
|
|
83
|
+
| `anthropic` | `@ai-sdk/anthropic` | `ANTHROPIC_API_KEY` |
|
|
84
|
+
| `openai` | `@ai-sdk/openai` | `OPENAI_API_KEY` |
|
|
85
|
+
| `google` | `@ai-sdk/google` | `GOOGLE_GENERATIVE_AI_API_KEY` |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Common flags
|
|
90
|
+
|
|
91
|
+
| Flag | Applies to | Description |
|
|
92
|
+
|------|-----------|-------------|
|
|
93
|
+
| `--provider <id>` | all | `anthropic` / `openai` / `google` |
|
|
94
|
+
| `--auth` | all | Include NextAuth v5 session check (default: off) |
|
|
95
|
+
| `--no-page` | patterns with pages | Omit the generated page component |
|
|
96
|
+
| `--storage <id>` | `rag` | `memory` / `sqlite` / `pgvector` |
|
|
97
|
+
| `--storage memory` | `chat` | Include conversation storage (default: off) |
|
|
98
|
+
| `--interrupt` | `chat` | Embed a human-in-the-loop approval gate in the chat route |
|
|
99
|
+
| `--stream` | `rag` | Use `streamText` instead of `generateText` in query route |
|
|
100
|
+
| `--schema-name <name>` | `structured-output`, `stream-object` | Name for the schema, hook, and type |
|
|
101
|
+
| `--no-hook` | `structured-output`, `stream-object` | Omit the generated client hook |
|
|
102
|
+
| `--tool-name <name>` | `tools` | Name for the generated tool stub file |
|
|
103
|
+
| `--image-model <model>` | `image-gen` | `dall-e-3` (default) or `dall-e-2` |
|
|
104
|
+
| `--overwrite` | all | Overwrite existing files without prompting |
|
|
105
|
+
| `-y, --yes` | all | Accept all defaults |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## File conflict handling
|
|
110
|
+
|
|
111
|
+
Before writing each file, the CLI checks if it already exists:
|
|
112
|
+
|
|
113
|
+
- If taken, a warning appears inline
|
|
114
|
+
- You can overwrite, enter a different path, or skip the component
|
|
115
|
+
- `--overwrite` bypasses this prompt silently
|
|
116
|
+
- The CLI never silently overwrites without permission
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Prerequisites
|
|
121
|
+
|
|
122
|
+
| Requirement | Check | Auto-install |
|
|
123
|
+
|-------------|-------|-------------|
|
|
124
|
+
| React in `package.json` | Required — exits if missing | No |
|
|
125
|
+
| `tsconfig.json` | Required — exits if missing | No |
|
|
126
|
+
| shadcn/ui (`components.json`) | Required for page components | Prompted |
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
### Local dev loop
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# 1. Build and link the CLI globally (run once)
|
|
136
|
+
bash scripts/dev-link.sh
|
|
137
|
+
|
|
138
|
+
# 2. Start watch mode
|
|
139
|
+
pnpm --filter ai-wingman watch
|
|
140
|
+
|
|
141
|
+
# 3. Create a fresh test project
|
|
142
|
+
bash scripts/new-fixture.sh
|
|
143
|
+
cd /tmp/wingman-fixture
|
|
144
|
+
|
|
145
|
+
# 4. Run against it
|
|
146
|
+
ai-wingman add chat --provider anthropic --storage memory --yes
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Or point directly at the built binary from any project:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
node /path/to/wingman/packages/ai-wingman/dist/wingman.js add chat --yes
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Tests
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pnpm --filter ai-wingman test
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
330 tests across all 13 generators. Generators are pure `(config) => string` functions — fast, deterministic, snapshot-tested.
|
|
162
|
+
|
|
163
|
+
### Project structure
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
packages/ai-wingman/
|
|
167
|
+
├── bin/
|
|
168
|
+
│ └── wingman.ts # CLI entry point (commander)
|
|
169
|
+
├── src/
|
|
170
|
+
│ ├── types.ts # Config types for all patterns
|
|
171
|
+
│ ├── registry/
|
|
172
|
+
│ │ ├── providers.ts # Anthropic, OpenAI, Google
|
|
173
|
+
│ │ ├── storage-adapters.ts
|
|
174
|
+
│ │ ├── patterns.ts # Pattern registry + resolvers
|
|
175
|
+
│ │ └── index.ts
|
|
176
|
+
│ ├── generators/ # Pure (config) => string functions
|
|
177
|
+
│ ├── patterns/ # One dir per pattern
|
|
178
|
+
│ │ ├── chat/
|
|
179
|
+
│ │ ├── structured-output/
|
|
180
|
+
│ │ ├── tools/
|
|
181
|
+
│ │ ├── stream-object/
|
|
182
|
+
│ │ ├── rag/
|
|
183
|
+
│ │ ├── interrupt/
|
|
184
|
+
│ │ ├── agent/
|
|
185
|
+
│ │ ├── multimodal/
|
|
186
|
+
│ │ ├── audio/
|
|
187
|
+
│ │ ├── eval/
|
|
188
|
+
│ │ ├── image-gen/
|
|
189
|
+
│ │ ├── generative-ui/
|
|
190
|
+
│ │ └── document-processing/
|
|
191
|
+
│ ├── commands/
|
|
192
|
+
│ │ ├── add/ # Main orchestrator
|
|
193
|
+
│ │ └── list/
|
|
194
|
+
│ ├── planner/ # Builds ExecutionPlan before writing
|
|
195
|
+
│ ├── steps/ # Shared interactive steps
|
|
196
|
+
│ └── utils/
|
|
197
|
+
└── tests/
|
|
198
|
+
└── unit/generators/ # Snapshot tests per generator
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Adding a provider
|
|
202
|
+
|
|
203
|
+
Add an entry to `src/registry/providers.ts`:
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
{
|
|
207
|
+
id: 'mistral',
|
|
208
|
+
label: 'Mistral',
|
|
209
|
+
package: '@ai-sdk/mistral',
|
|
210
|
+
importName: 'mistral',
|
|
211
|
+
envVar: 'MISTRAL_API_KEY',
|
|
212
|
+
defaultModel: 'mistral-large-latest',
|
|
213
|
+
modelFactory: 'mistral("mistral-large-latest")',
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
No other changes needed — the prompt and all generators pick it up automatically.
|
|
218
|
+
|
|
219
|
+
### Adding a pattern
|
|
220
|
+
|
|
221
|
+
1. Create `src/patterns/<name>/index.ts` implementing the `Pattern` interface
|
|
222
|
+
2. Add `prompt-config.ts` and `execute.ts` alongside it
|
|
223
|
+
3. Add generators to `src/generators/` as needed
|
|
224
|
+
4. Register the pattern in `src/registry/patterns.ts`
|
|
225
|
+
5. Add snapshot tests in `tests/unit/generators/<name>.test.ts`
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT
|