diff options
| author | Kit Langton <[email protected]> | 2026-04-30 21:45:48 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-04-30 21:45:48 -0400 |
| commit | 5984d917dc87009c34fffebd6af09e2dd079f602 (patch) | |
| tree | d2334305f6b10cbad1e0e74f67995c172c88d856 | |
| parent | c2a97a7a6ce6733a2d4a3c6900e8d617d4dd7fe2 (diff) | |
| download | opencode-5984d917dc87009c34fffebd6af09e2dd079f602.tar.gz opencode-5984d917dc87009c34fffebd6af09e2dd079f602.zip | |
refactor(session): yield instance context in system prompt (#25207)
| -rw-r--r-- | packages/opencode/src/session/prompt.ts | 2 | ||||
| -rw-r--r-- | packages/opencode/src/session/system.ts | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts index 58edffe3f..fb822ff17 100644 --- a/packages/opencode/src/session/prompt.ts +++ b/packages/opencode/src/session/prompt.ts @@ -1443,7 +1443,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the const [skills, env, instructions, modelMsgs] = yield* Effect.all([ sys.skills(agent), - Effect.sync(() => sys.environment(model)), + sys.environment(model), instruction.system().pipe(Effect.orDie), MessageV2.toModelMessagesEffect(msgs, model), ]) diff --git a/packages/opencode/src/session/system.ts b/packages/opencode/src/session/system.ts index 9099f2d17..06c71fa7d 100644 --- a/packages/opencode/src/session/system.ts +++ b/packages/opencode/src/session/system.ts @@ -1,6 +1,6 @@ import { Context, Effect, Layer } from "effect" -import { Instance } from "../project/instance" +import { InstanceState } from "@/effect/instance-state" import PROMPT_ANTHROPIC from "./prompt/anthropic.txt" import PROMPT_DEFAULT from "./prompt/default.txt" @@ -33,7 +33,7 @@ export function provider(model: Provider.Model) { } export interface Interface { - readonly environment: (model: Provider.Model) => string[] + readonly environment: (model: Provider.Model) => Effect.Effect<string[]> readonly skills: (agent: Agent.Info) => Effect.Effect<string | undefined> } @@ -45,22 +45,22 @@ export const layer = Layer.effect( const skill = yield* Skill.Service return Service.of({ - environment(model) { - const project = Instance.project + environment: Effect.fn("SystemPrompt.environment")(function* (model: Provider.Model) { + const ctx = yield* InstanceState.context return [ [ `You are powered by the model named ${model.api.id}. The exact model ID is ${model.providerID}/${model.api.id}`, `Here is some useful information about the environment you are running in:`, `<env>`, - ` Working directory: ${Instance.directory}`, - ` Workspace root folder: ${Instance.worktree}`, - ` Is directory a git repo: ${project.vcs === "git" ? "yes" : "no"}`, + ` Working directory: ${ctx.directory}`, + ` Workspace root folder: ${ctx.worktree}`, + ` Is directory a git repo: ${ctx.project.vcs === "git" ? "yes" : "no"}`, ` Platform: ${process.platform}`, ` Today's date: ${new Date().toDateString()}`, `</env>`, ].join("\n"), ] - }, + }), skills: Effect.fn("SystemPrompt.skills")(function* (agent: Agent.Info) { if (Permission.disabled(["skill"], agent.permission).has("skill")) return |
