@kood/claude-code 0.1.7 → 0.1.9

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.
Files changed (49) hide show
  1. package/dist/index.js +118 -3
  2. package/package.json +8 -2
  3. package/templates/hono/CLAUDE.md +53 -326
  4. package/templates/hono/docs/architecture/architecture.md +93 -747
  5. package/templates/hono/docs/deployment/cloudflare.md +59 -513
  6. package/templates/hono/docs/deployment/docker.md +41 -356
  7. package/templates/hono/docs/deployment/index.md +49 -190
  8. package/templates/hono/docs/deployment/railway.md +36 -306
  9. package/templates/hono/docs/deployment/vercel.md +49 -434
  10. package/templates/hono/docs/library/ai-sdk/index.md +53 -290
  11. package/templates/hono/docs/library/ai-sdk/openrouter.md +19 -387
  12. package/templates/hono/docs/library/ai-sdk/providers.md +28 -394
  13. package/templates/hono/docs/library/ai-sdk/streaming.md +52 -353
  14. package/templates/hono/docs/library/ai-sdk/structured-output.md +63 -395
  15. package/templates/hono/docs/library/ai-sdk/tools.md +62 -431
  16. package/templates/hono/docs/library/hono/env-setup.md +24 -313
  17. package/templates/hono/docs/library/hono/error-handling.md +34 -295
  18. package/templates/hono/docs/library/hono/index.md +24 -122
  19. package/templates/hono/docs/library/hono/middleware.md +21 -188
  20. package/templates/hono/docs/library/hono/rpc.md +40 -341
  21. package/templates/hono/docs/library/hono/validation.md +35 -195
  22. package/templates/hono/docs/library/pino/index.md +42 -333
  23. package/templates/hono/docs/library/prisma/cloudflare-d1.md +64 -367
  24. package/templates/hono/docs/library/prisma/config.md +19 -260
  25. package/templates/hono/docs/library/prisma/index.md +64 -320
  26. package/templates/hono/docs/library/zod/index.md +53 -257
  27. package/templates/npx/CLAUDE.md +58 -276
  28. package/templates/npx/docs/references/patterns.md +160 -0
  29. package/templates/tanstack-start/CLAUDE.md +0 -4
  30. package/templates/tanstack-start/docs/architecture/architecture.md +44 -589
  31. package/templates/tanstack-start/docs/design/index.md +119 -12
  32. package/templates/tanstack-start/docs/guides/conventions.md +103 -0
  33. package/templates/tanstack-start/docs/guides/env-setup.md +34 -340
  34. package/templates/tanstack-start/docs/guides/getting-started.md +22 -209
  35. package/templates/tanstack-start/docs/guides/hooks.md +166 -0
  36. package/templates/tanstack-start/docs/guides/routes.md +166 -0
  37. package/templates/tanstack-start/docs/guides/services.md +143 -0
  38. package/templates/tanstack-start/docs/library/tanstack-query/index.md +18 -2
  39. package/templates/tanstack-start/docs/library/zod/index.md +16 -1
  40. package/templates/tanstack-start/docs/design/accessibility.md +0 -163
  41. package/templates/tanstack-start/docs/design/color.md +0 -93
  42. package/templates/tanstack-start/docs/design/spacing.md +0 -122
  43. package/templates/tanstack-start/docs/design/typography.md +0 -80
  44. package/templates/tanstack-start/docs/guides/best-practices.md +0 -950
  45. package/templates/tanstack-start/docs/guides/husky-lint-staged.md +0 -303
  46. package/templates/tanstack-start/docs/guides/prettier.md +0 -189
  47. package/templates/tanstack-start/docs/guides/project-templates.md +0 -710
  48. package/templates/tanstack-start/docs/library/tanstack-query/setup.md +0 -48
  49. package/templates/tanstack-start/docs/library/zod/basic-types.md +0 -74
@@ -1,12 +1,6 @@
1
- # AI SDK - 프로바이더 (Hono)
1
+ # AI SDK - 프로바이더
2
2
 
3
- > **상위 문서**: [AI SDK](./index.md)
4
-
5
- ---
6
-
7
- ## 개요
8
-
9
- AI SDK 프로바이더를 Hono와 함께 사용하는 방법입니다. Cloudflare Workers 환경에서의 설정을 포함합니다.
3
+ > 다양한 AI 프로바이더 설정
10
4
 
11
5
  ---
12
6
 
@@ -14,8 +8,8 @@ AI SDK 프로바이더를 Hono와 함께 사용하는 방법입니다. Cloudflar
14
8
 
15
9
  ```bash
16
10
  npm install @ai-sdk/openai # OpenAI
17
- npm install @ai-sdk/anthropic # Anthropic (Claude)
18
- npm install @ai-sdk/google # Google (Gemini)
11
+ npm install @ai-sdk/anthropic # Claude
12
+ npm install @ai-sdk/google # Gemini
19
13
  npm install @ai-sdk/mistral # Mistral
20
14
  npm install @ai-sdk/groq # Groq
21
15
  ```
@@ -24,445 +18,85 @@ npm install @ai-sdk/groq # Groq
24
18
 
25
19
  ## OpenAI
26
20
 
27
- ### 기본 사용
28
-
29
21
  ```typescript
30
- import { Hono } from 'hono'
31
- import { streamText } from 'ai'
32
22
  import { openai } from '@ai-sdk/openai'
33
23
 
34
- const app = new Hono()
35
-
36
- app.post('/api/chat', async (c) => {
37
- const { messages } = await c.req.json()
38
-
39
- const result = streamText({
40
- model: openai('gpt-4o'),
41
- messages,
42
- })
43
-
44
- return result.toUIMessageStreamResponse()
24
+ const result = streamText({
25
+ model: openai('gpt-4o'),
26
+ messages,
45
27
  })
46
28
  ```
47
29
 
48
- ### Cloudflare Workers 설정
30
+ ### Cloudflare Workers
49
31
 
50
32
  ```typescript
51
- import { Hono } from 'hono'
52
- import { streamText } from 'ai'
53
33
  import { createOpenAI } from '@ai-sdk/openai'
54
34
 
55
- type Bindings = {
56
- OPENAI_API_KEY: string
57
- }
58
-
35
+ type Bindings = { OPENAI_API_KEY: string }
59
36
  const app = new Hono<{ Bindings: Bindings }>()
60
37
 
61
38
  app.post('/api/chat', async (c) => {
62
- const openai = createOpenAI({
63
- apiKey: c.env.OPENAI_API_KEY,
64
- })
65
-
66
- const { messages } = await c.req.json()
67
-
68
- const result = streamText({
69
- model: openai('gpt-4o'),
70
- messages,
71
- })
72
-
39
+ const openai = createOpenAI({ apiKey: c.env.OPENAI_API_KEY })
40
+ const result = streamText({ model: openai('gpt-4o'), messages })
73
41
  return result.toUIMessageStreamResponse()
74
42
  })
75
43
  ```
76
44
 
77
- ### 사용 가능한 모델
45
+ ### 모델
78
46
 
79
47
  | 모델 | 설명 |
80
48
  |------|------|
81
- | `gpt-4o` | 최신 GPT-4 Omni |
82
- | `gpt-4o-mini` | 경량화된 GPT-4o |
83
- | `gpt-4-turbo` | GPT-4 Turbo |
84
- | `o1` | 추론 최적화 모델 |
85
- | `o1-mini` | 경량 추론 모델 |
49
+ | `gpt-4o` | GPT-4 Omni |
50
+ | `gpt-4o-mini` | 경량 GPT-4o |
51
+ | `o1` | 추론 최적화 |
86
52
 
87
53
  ---
88
54
 
89
55
  ## Anthropic (Claude)
90
56
 
91
- ### 기본 사용
92
-
93
57
  ```typescript
94
- import { Hono } from 'hono'
95
- import { streamText } from 'ai'
96
58
  import { anthropic } from '@ai-sdk/anthropic'
97
59
 
98
- const app = new Hono()
99
-
100
- app.post('/api/chat', async (c) => {
101
- const { messages } = await c.req.json()
102
-
103
- const result = streamText({
104
- model: anthropic('claude-3-5-sonnet-20241022'),
105
- messages,
106
- })
107
-
108
- return result.toUIMessageStreamResponse()
109
- })
110
- ```
111
-
112
- ### Cloudflare Workers 설정
113
-
114
- ```typescript
115
- import { Hono } from 'hono'
116
- import { streamText } from 'ai'
117
- import { createAnthropic } from '@ai-sdk/anthropic'
118
-
119
- type Bindings = {
120
- ANTHROPIC_API_KEY: string
121
- }
122
-
123
- const app = new Hono<{ Bindings: Bindings }>()
124
-
125
- app.post('/api/chat', async (c) => {
126
- const anthropic = createAnthropic({
127
- apiKey: c.env.ANTHROPIC_API_KEY,
128
- })
129
-
130
- const { messages } = await c.req.json()
131
-
132
- const result = streamText({
133
- model: anthropic('claude-3-5-sonnet-20241022'),
134
- messages,
135
- })
136
-
137
- return result.toUIMessageStreamResponse()
60
+ const result = streamText({
61
+ model: anthropic('claude-3-5-sonnet-latest'),
62
+ messages,
138
63
  })
139
64
  ```
140
65
 
141
- ### 사용 가능한 모델
66
+ ### 모델
142
67
 
143
68
  | 모델 | 설명 |
144
69
  |------|------|
145
- | `claude-3-5-sonnet-20241022` | Claude 3.5 Sonnet (최신) |
146
- | `claude-3-5-haiku-20241022` | Claude 3.5 Haiku (빠름) |
147
- | `claude-3-opus-20240229` | Claude 3 Opus (강력) |
70
+ | `claude-3-5-sonnet-latest` | Claude 3.5 Sonnet |
71
+ | `claude-3-opus-latest` | Claude 3 Opus |
72
+ | `claude-3-haiku-latest` | 경량 모델 |
148
73
 
149
74
  ---
150
75
 
151
76
  ## Google (Gemini)
152
77
 
153
- ### 기본 사용
154
-
155
78
  ```typescript
156
- import { Hono } from 'hono'
157
- import { streamText } from 'ai'
158
79
  import { google } from '@ai-sdk/google'
159
80
 
160
- const app = new Hono()
161
-
162
- app.post('/api/chat', async (c) => {
163
- const { messages } = await c.req.json()
164
-
165
- const result = streamText({
166
- model: google('gemini-1.5-pro'),
167
- messages,
168
- })
169
-
170
- return result.toUIMessageStreamResponse()
171
- })
172
- ```
173
-
174
- ### Cloudflare Workers 설정
175
-
176
- ```typescript
177
- import { Hono } from 'hono'
178
- import { streamText } from 'ai'
179
- import { createGoogleGenerativeAI } from '@ai-sdk/google'
180
-
181
- type Bindings = {
182
- GOOGLE_GENERATIVE_AI_API_KEY: string
183
- }
184
-
185
- const app = new Hono<{ Bindings: Bindings }>()
186
-
187
- app.post('/api/chat', async (c) => {
188
- const google = createGoogleGenerativeAI({
189
- apiKey: c.env.GOOGLE_GENERATIVE_AI_API_KEY,
190
- })
191
-
192
- const { messages } = await c.req.json()
193
-
194
- const result = streamText({
195
- model: google('gemini-1.5-pro'),
196
- messages,
197
- })
198
-
199
- return result.toUIMessageStreamResponse()
200
- })
201
- ```
202
-
203
- ### 사용 가능한 모델
204
-
205
- | 모델 | 설명 |
206
- |------|------|
207
- | `gemini-1.5-pro` | Gemini 1.5 Pro |
208
- | `gemini-1.5-flash` | Gemini 1.5 Flash (빠름) |
209
- | `gemini-2.0-flash-exp` | Gemini 2.0 Flash (실험) |
210
-
211
- ---
212
-
213
- ## Groq
214
-
215
- ### 기본 사용
216
-
217
- ```typescript
218
- import { Hono } from 'hono'
219
- import { streamText } from 'ai'
220
- import { groq } from '@ai-sdk/groq'
221
-
222
- const app = new Hono()
223
-
224
- app.post('/api/chat', async (c) => {
225
- const { messages } = await c.req.json()
226
-
227
- const result = streamText({
228
- model: groq('llama-3.1-70b-versatile'),
229
- messages,
230
- })
231
-
232
- return result.toUIMessageStreamResponse()
233
- })
234
- ```
235
-
236
- ### Cloudflare Workers 설정
237
-
238
- ```typescript
239
- import { Hono } from 'hono'
240
- import { streamText } from 'ai'
241
- import { createGroq } from '@ai-sdk/groq'
242
-
243
- type Bindings = {
244
- GROQ_API_KEY: string
245
- }
246
-
247
- const app = new Hono<{ Bindings: Bindings }>()
248
-
249
- app.post('/api/chat', async (c) => {
250
- const groq = createGroq({
251
- apiKey: c.env.GROQ_API_KEY,
252
- })
253
-
254
- const { messages } = await c.req.json()
255
-
256
- const result = streamText({
257
- model: groq('llama-3.1-70b-versatile'),
258
- messages,
259
- })
260
-
261
- return result.toUIMessageStreamResponse()
262
- })
263
- ```
264
-
265
- ---
266
-
267
- ## 다중 프로바이더 설정
268
-
269
- ```typescript
270
- import { Hono } from 'hono'
271
- import { streamText } from 'ai'
272
- import { createOpenAI } from '@ai-sdk/openai'
273
- import { createAnthropic } from '@ai-sdk/anthropic'
274
- import { createGoogleGenerativeAI } from '@ai-sdk/google'
275
-
276
- type Bindings = {
277
- OPENAI_API_KEY: string
278
- ANTHROPIC_API_KEY: string
279
- GOOGLE_GENERATIVE_AI_API_KEY: string
280
- }
281
-
282
- const app = new Hono<{ Bindings: Bindings }>()
283
-
284
- app.post('/api/chat/:provider', async (c) => {
285
- const provider = c.req.param('provider')
286
- const { messages } = await c.req.json()
287
-
288
- let model
289
-
290
- switch (provider) {
291
- case 'openai':
292
- const openai = createOpenAI({ apiKey: c.env.OPENAI_API_KEY })
293
- model = openai('gpt-4o')
294
- break
295
- case 'anthropic':
296
- const anthropic = createAnthropic({ apiKey: c.env.ANTHROPIC_API_KEY })
297
- model = anthropic('claude-3-5-sonnet-20241022')
298
- break
299
- case 'google':
300
- const google = createGoogleGenerativeAI({
301
- apiKey: c.env.GOOGLE_GENERATIVE_AI_API_KEY,
302
- })
303
- model = google('gemini-1.5-pro')
304
- break
305
- default:
306
- return c.json({ error: 'Unknown provider' }, 400)
307
- }
308
-
309
- const result = streamText({ model, messages })
310
-
311
- return result.toUIMessageStreamResponse()
312
- })
313
- ```
314
-
315
- ---
316
-
317
- ## 프로바이더 미들웨어
318
-
319
- ```typescript
320
- import { Hono } from 'hono'
321
- import { createMiddleware } from 'hono/factory'
322
- import { streamText } from 'ai'
323
- import { createOpenAI } from '@ai-sdk/openai'
324
- import { createAnthropic } from '@ai-sdk/anthropic'
325
-
326
- type Bindings = {
327
- OPENAI_API_KEY: string
328
- ANTHROPIC_API_KEY: string
329
- }
330
-
331
- type Variables = {
332
- providers: {
333
- openai: ReturnType<typeof createOpenAI>
334
- anthropic: ReturnType<typeof createAnthropic>
335
- }
336
- }
337
-
338
- const providersMiddleware = createMiddleware<{
339
- Bindings: Bindings
340
- Variables: Variables
341
- }>(async (c, next) => {
342
- c.set('providers', {
343
- openai: createOpenAI({ apiKey: c.env.OPENAI_API_KEY }),
344
- anthropic: createAnthropic({ apiKey: c.env.ANTHROPIC_API_KEY }),
345
- })
346
- await next()
347
- })
348
-
349
- const app = new Hono<{ Bindings: Bindings; Variables: Variables }>()
350
-
351
- app.use('/api/*', providersMiddleware)
352
-
353
- app.post('/api/chat', async (c) => {
354
- const { messages, provider = 'openai' } = await c.req.json()
355
- const providers = c.get('providers')
356
-
357
- const model =
358
- provider === 'anthropic'
359
- ? providers.anthropic('claude-3-5-sonnet-20241022')
360
- : providers.openai('gpt-4o')
361
-
362
- const result = streamText({ model, messages })
363
-
364
- return result.toUIMessageStreamResponse()
365
- })
366
- ```
367
-
368
- ---
369
-
370
- ## 모델 파라미터
371
-
372
- ```typescript
373
81
  const result = streamText({
374
- model: openai('gpt-4o'),
82
+ model: google('gemini-1.5-pro'),
375
83
  messages,
376
-
377
- // 공통 파라미터
378
- temperature: 0.7, // 창의성 (0-2)
379
- maxTokens: 1000, // 최대 토큰 수
380
- topP: 0.9, // 핵 샘플링
381
- frequencyPenalty: 0.5, // 반복 억제
382
- presencePenalty: 0.5, // 새로운 주제 유도
383
- stopSequences: ['\n\n'], // 생성 중단 시퀀스
384
84
  })
385
85
  ```
386
86
 
387
87
  ---
388
88
 
389
- ## OpenRouter (통합 게이트웨이)
390
-
391
- 하나의 API 키로 수백 개 모델에 접근할 수 있는 통합 게이트웨이입니다.
392
-
393
- ### 설치
394
-
395
- ```bash
396
- npm install @openrouter/ai-sdk-provider
397
- ```
398
-
399
- ### Hono 사용
400
-
401
- ```typescript
402
- import { Hono } from 'hono'
403
- import { streamText, convertToModelMessages } from 'ai'
404
- import { createOpenRouter } from '@openrouter/ai-sdk-provider'
405
-
406
- type Bindings = {
407
- OPENROUTER_API_KEY: string
408
- }
409
-
410
- const app = new Hono<{ Bindings: Bindings }>()
411
-
412
- app.post('/api/chat', async (c) => {
413
- const openrouter = createOpenRouter({
414
- apiKey: c.env.OPENROUTER_API_KEY,
415
- })
416
-
417
- const { messages, model } = await c.req.json()
418
-
419
- const result = streamText({
420
- model: openrouter.chat(model ?? 'anthropic/claude-3.5-sonnet'),
421
- messages: convertToModelMessages(messages),
422
- })
423
-
424
- return result.toUIMessageStreamResponse()
425
- })
426
- ```
427
-
428
- ### 인기 모델
429
-
430
- | 모델 ID | 설명 |
431
- |---------|------|
432
- | `anthropic/claude-3.5-sonnet` | Claude 3.5 Sonnet |
433
- | `openai/gpt-4o` | GPT-4o |
434
- | `google/gemini-pro-1.5` | Gemini Pro 1.5 |
435
- | `meta-llama/llama-3.1-70b-instruct` | Llama 3.1 70B |
436
-
437
- 자세한 내용: [OpenRouter 가이드](./openrouter.md)
438
-
439
- ---
440
-
441
- ## 환경 변수 설정
442
-
443
- ### .env (로컬 개발)
89
+ ## 환경 변수
444
90
 
445
91
  ```bash
446
92
  OPENAI_API_KEY=sk-...
447
93
  ANTHROPIC_API_KEY=sk-ant-...
448
94
  GOOGLE_GENERATIVE_AI_API_KEY=...
449
- GROQ_API_KEY=gsk_...
450
- MISTRAL_API_KEY=...
451
- OPENROUTER_API_KEY=sk-or-v1-...
452
95
  ```
453
96
 
454
- ### wrangler.toml (Cloudflare Workers)
455
-
456
- ```toml
457
- [vars]
458
- # 민감하지 않은 변수만 여기에
459
-
460
- # 민감한 키는 Cloudflare 대시보드에서 설정:
461
- # Settings > Variables > Environment Variables
462
- ```
97
+ ---
463
98
 
464
- ### Cloudflare 대시보드 설정
99
+ ## 관련 문서
465
100
 
466
- 1. Workers & Pages > 프로젝트 선택
467
- 2. Settings > Variables
468
- 3. Environment Variables에서 API 키 추가
101
+ - [AI SDK 개요](./index.md)
102
+ - [OpenRouter](./openrouter.md)