|
1 | 1 | import { Context, Effect, Layer } from "effect" |
2 | 2 |
|
3 | | -import { Instance } from "../project/instance" |
| 3 | +import { InstanceState } from "@/effect/instance-state" |
4 | 4 |
|
5 | 5 | import PROMPT_ANTHROPIC from "./prompt/anthropic.txt" |
6 | 6 | import PROMPT_DEFAULT from "./prompt/default.txt" |
@@ -33,7 +33,7 @@ export function provider(model: Provider.Model) { |
33 | 33 | } |
34 | 34 |
|
35 | 35 | export interface Interface { |
36 | | - readonly environment: (model: Provider.Model) => string[] |
| 36 | + readonly environment: (model: Provider.Model) => Effect.Effect<string[]> |
37 | 37 | readonly skills: (agent: Agent.Info) => Effect.Effect<string | undefined> |
38 | 38 | } |
39 | 39 |
|
@@ -45,22 +45,22 @@ export const layer = Layer.effect( |
45 | 45 | const skill = yield* Skill.Service |
46 | 46 |
|
47 | 47 | return Service.of({ |
48 | | - environment(model) { |
49 | | - const project = Instance.project |
| 48 | + environment: Effect.fn("SystemPrompt.environment")(function* (model: Provider.Model) { |
| 49 | + const ctx = yield* InstanceState.context |
50 | 50 | return [ |
51 | 51 | [ |
52 | 52 | `You are powered by the model named ${model.api.id}. The exact model ID is ${model.providerID}/${model.api.id}`, |
53 | 53 | `Here is some useful information about the environment you are running in:`, |
54 | 54 | `<env>`, |
55 | | - ` Working directory: ${Instance.directory}`, |
56 | | - ` Workspace root folder: ${Instance.worktree}`, |
57 | | - ` Is directory a git repo: ${project.vcs === "git" ? "yes" : "no"}`, |
| 55 | + ` Working directory: ${ctx.directory}`, |
| 56 | + ` Workspace root folder: ${ctx.worktree}`, |
| 57 | + ` Is directory a git repo: ${ctx.project.vcs === "git" ? "yes" : "no"}`, |
58 | 58 | ` Platform: ${process.platform}`, |
59 | 59 | ` Today's date: ${new Date().toDateString()}`, |
60 | 60 | `</env>`, |
61 | 61 | ].join("\n"), |
62 | 62 | ] |
63 | | - }, |
| 63 | + }), |
64 | 64 |
|
65 | 65 | skills: Effect.fn("SystemPrompt.skills")(function* (agent: Agent.Info) { |
66 | 66 | if (Permission.disabled(["skill"], agent.permission).has("skill")) return |
|