|
1 | 1 | /** |
2 | 2 | * Install and rules commands for AI tool integration |
3 | | - * |
| 3 | + * |
4 | 4 | * Commands for installing Effect patterns into AI tools and generating skills |
5 | 5 | */ |
6 | 6 |
|
7 | 7 | import { |
8 | | - createApplicationPatternRepository, |
9 | | - createDatabase, |
10 | | - createEffectPatternRepository, |
| 8 | + ApplicationPatternRepositoryService, |
| 9 | + DatabaseLayer, |
| 10 | + EffectPatternRepositoryLive, |
| 11 | + EffectPatternRepositoryService, |
11 | 12 | type SkillLevel, |
12 | 13 | } from "@effect-patterns/toolkit"; |
13 | 14 | import { Command, Options } from "@effect/cli"; |
@@ -162,18 +163,7 @@ export const installAddCommand = Command.make("add", { |
162 | 163 | return yield* Effect.fail(new Error(`Unsupported tool: ${tool}`)); |
163 | 164 | } |
164 | 165 |
|
165 | | - const conn = yield* Effect.try({ |
166 | | - try: () => createDatabase(), |
167 | | - catch: (error) => |
168 | | - new Error( |
169 | | - `Failed to create database connection: ${error instanceof Error ? error.message : String(error)}` |
170 | | - ), |
171 | | - }); |
172 | | - yield* Effect.addFinalizer(() => |
173 | | - Effect.promise(() => conn.close()) |
174 | | - ); |
175 | | - |
176 | | - const repo = createEffectPatternRepository(conn.db); |
| 166 | + const repo = yield* EffectPatternRepositoryService; |
177 | 167 | const searchParams: { |
178 | 168 | query?: string; |
179 | 169 | skillLevel?: SkillLevel; |
@@ -287,6 +277,8 @@ Your AI tool configuration has been updated with Effect patterns!`, |
287 | 277 | { type: "success" } |
288 | 278 | ); |
289 | 279 | }) |
| 280 | + ).pipe( |
| 281 | + Effect.provide(EffectPatternRepositoryLive), |
290 | 282 | ) as any |
291 | 283 | ) |
292 | 284 | ); |
@@ -415,10 +407,8 @@ export const installSkillsCommand = Command.make("skills", { |
415 | 407 | colorize("\n🎓 Generating Skills from Effect Patterns\n", "BRIGHT") |
416 | 408 | ); |
417 | 409 |
|
418 | | - const conn = createDatabase(); |
419 | | - yield* Effect.addFinalizer(() => Effect.promise(() => conn.close())); |
420 | | - const apRepo = createApplicationPatternRepository(conn.db); |
421 | | - const epRepo = createEffectPatternRepository(conn.db); |
| 410 | + const epRepo = yield* EffectPatternRepositoryService; |
| 411 | + const apRepo = yield* ApplicationPatternRepositoryService; |
422 | 412 |
|
423 | 413 | yield* Console.log( |
424 | 414 | colorize("📖 Loading patterns from database...", "CYAN") |
@@ -681,7 +671,9 @@ export const installSkillsCommand = Command.make("skills", { |
681 | 671 | "✨ Skills Generation Complete!", |
682 | 672 | { type: "success" } |
683 | 673 | ); |
684 | | - })) as any; |
| 674 | + })).pipe( |
| 675 | + Effect.provide(DatabaseLayer), |
| 676 | + ) as any; |
685 | 677 | }) |
686 | 678 | ); |
687 | 679 |
|
|
0 commit comments