From 50112b97eacea074376978748d1f5b853feb83cf Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 15 Dec 2025 19:02:31 +0900 Subject: [PATCH] feat(agents): inject environment context into OmO system prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add user time and system context to OmO agent prompt to help the model understand the temporal context of the conversation. Injected context includes: - Working directory - Platform (darwin/linux/win32) - Current date and time - Timezone - Locale Closes #51 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) --- src/agents/utils.ts | 50 ++++++++++++++++++++++++++++++++++++++++++--- src/index.ts | 1 + 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/agents/utils.ts b/src/agents/utils.ts index 394ec60..a2223d0 100644 --- a/src/agents/utils.ts +++ b/src/agents/utils.ts @@ -19,6 +19,39 @@ const allBuiltinAgents: Record = { "multimodal-looker": multimodalLookerAgent, } +export function createEnvContext(directory: string): string { + const now = new Date() + const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone + const locale = Intl.DateTimeFormat().resolvedOptions().locale + + const dateStr = now.toLocaleDateString("en-US", { + weekday: "short", + year: "numeric", + month: "short", + day: "numeric", + }) + + const timeStr = now.toLocaleTimeString("en-US", { + hour: "2-digit", + minute: "2-digit", + second: "2-digit", + hour12: true, + }) + + const platform = process.platform as "darwin" | "linux" | "win32" | string + + return ` +Here is some useful information about the environment you are running in: + + Working directory: ${directory} + Platform: ${platform} + Today's date: ${dateStr} + Current time: ${timeStr} + Timezone: ${timezone} + Locale: ${locale} +` +} + function mergeAgentConfig( base: AgentConfig, override: AgentOverrideConfig @@ -28,7 +61,8 @@ function mergeAgentConfig( export function createBuiltinAgents( disabledAgents: BuiltinAgentName[] = [], - agentOverrides: AgentOverrides = {} + agentOverrides: AgentOverrides = {}, + directory?: string ): Record { const result: Record = {} @@ -39,11 +73,21 @@ export function createBuiltinAgents( continue } + let finalConfig = config + + if (agentName === "OmO" && directory && config.prompt) { + const envContext = createEnvContext(directory) + finalConfig = { + ...config, + prompt: config.prompt + envContext, + } + } + const override = agentOverrides[agentName] if (override) { - result[name] = mergeAgentConfig(config, override) + result[name] = mergeAgentConfig(finalConfig, override) } else { - result[name] = config + result[name] = finalConfig } } diff --git a/src/index.ts b/src/index.ts index efcfee4..d9e3a25 100644 --- a/src/index.ts +++ b/src/index.ts @@ -278,6 +278,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { const builtinAgents = createBuiltinAgents( pluginConfig.disabled_agents, pluginConfig.agents, + ctx.directory, ); const userAgents = (pluginConfig.claude_code?.agents ?? true) ? loadUserAgents() : {};