Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/opencode/src/session/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { LocationServiceMap, locationServiceMapLayer } from "@opencode-ai/core/l
import { Reference } from "@opencode-ai/core/reference"
import { MCP } from "@/mcp"
import { PermissionV1 } from "@opencode-ai/core/v1/permission"
import { InstallationVersion } from "@opencode-ai/core/installation/version"

export function provider(model: Provider.Model) {
if (model.api.id.includes("muse")) {
Expand Down Expand Up @@ -73,14 +74,17 @@ const layer = Layer.effect(
}).pipe(Effect.provide(locations.get(Location.Ref.make({ directory: AbsolutePath.make(ctx.directory) }))))
return [
[
`You are powered by the model named ${model.api.id}. The exact model ID is ${model.providerID}/${model.api.id}`,
`You are powered by the model named ${model.name}. 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: ${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()}`,
` OpenCode version: ${InstallationVersion}`,
` Provider: ${model.providerID}`,
` Model: ${model.name} (${model.api.id})`,
`</env>`,
].join("\n"),
references.length === 0
Expand Down
20 changes: 20 additions & 0 deletions packages/opencode/test/session/system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Skill } from "../../src/skill"
import { Permission } from "../../src/permission"
import type { Provider } from "../../src/provider/provider"
import { SystemPrompt } from "../../src/session/system"
import { InstallationVersion } from "@opencode-ai/core/installation/version"
import { MCP } from "../../src/mcp"
import { testEffect } from "../lib/effect"

Expand Down Expand Up @@ -109,6 +110,25 @@ describe("session.system", () => {
}
})

it.instance("environment exposes version, provider and model", () =>
Effect.gen(function* () {
const prompt = yield* SystemPrompt.Service
const model = {
name: "Test Model",
providerID: "test-provider",
api: { id: "test-model-id" },
} as unknown as Provider.Model
const parts = yield* prompt.environment(model)
const block = parts.join("\n")

expect(block).toContain(`OpenCode version: ${InstallationVersion}`)
expect(block).toContain("Provider: test-provider")
expect(block).toContain("Model: Test Model (test-model-id)")
expect(block).toContain("You are powered by the model named Test Model.")
expect(block).toContain("The exact model ID is test-provider/test-model-id")
}),
)

it.effect("skills output is sorted by name and stable across calls", () =>
Effect.gen(function* () {
const prompt = yield* SystemPrompt.Service
Expand Down
Loading