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
1 change: 1 addition & 0 deletions packages/opencode/src/effect/runtime-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class Service extends ConfigService.Service<Service>()("@opencode/Runtime
bashDefaultTimeoutMs: positiveInteger("OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS"),
experimentalNativeLlm: enabledByExperimental("OPENCODE_EXPERIMENTAL_NATIVE_LLM"),
client: Config.string("OPENCODE_CLIENT").pipe(Config.withDefault("cli")),
dateOverride: Config.string("OPENCODE_DATE").pipe(Config.option),
}) {}

export type Info = Context.Service.Shape<typeof Service>
Expand Down
12 changes: 9 additions & 3 deletions packages/opencode/src/session/system.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Context, Effect, Layer } from "effect"
import { Context, Effect, Layer, Option } from "effect"

import { InstanceState } from "@/effect/instance-state"
import { RuntimeFlags } from "@/effect/runtime-flags"

import PROMPT_ANTHROPIC from "./prompt/anthropic.txt"
import PROMPT_DEFAULT from "./prompt/default.txt"
Expand Down Expand Up @@ -43,10 +44,12 @@ export const layer = Layer.effect(
Service,
Effect.gen(function* () {
const skill = yield* Skill.Service
const flags = yield* RuntimeFlags.Service

return Service.of({
environment: Effect.fn("SystemPrompt.environment")(function* (model: Provider.Model) {
const ctx = yield* InstanceState.context
const dateStr = Option.getOrElse(flags.dateOverride, () => new Date().toDateString())
return [
[
`You are powered by the model named ${model.api.id}. The exact model ID is ${model.providerID}/${model.api.id}`,
Expand All @@ -56,7 +59,7 @@ export const layer = Layer.effect(
` 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()}`,
` Today's date: ${dateStr}`,
`</env>`,
].join("\n"),
]
Expand All @@ -79,6 +82,9 @@ export const layer = Layer.effect(
}),
)

export const defaultLayer = layer.pipe(Layer.provide(Skill.defaultLayer))
export const defaultLayer = layer.pipe(
Layer.provide(Skill.defaultLayer),
Layer.provide(RuntimeFlags.defaultLayer),
)

export * as SystemPrompt from "./system"
2 changes: 2 additions & 0 deletions packages/opencode/test/session/system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect } from "bun:test"
import { Effect, Layer } from "effect"
import type { Agent } from "../../src/agent/agent"
import { NamedError } from "@opencode-ai/core/util/error"
import { RuntimeFlags } from "../../src/effect/runtime-flags"
import { Skill } from "../../src/skill"
import { Permission } from "../../src/permission"
import { SystemPrompt } from "../../src/session/system"
Expand Down Expand Up @@ -53,6 +54,7 @@ const it = testEffect(
}),
),
),
Layer.provide(RuntimeFlags.defaultLayer),
),
)

Expand Down
Loading