feat(agents): inject environment context into OmO system prompt

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)
This commit is contained in:
YeonGyu-Kim
2025-12-15 19:02:31 +09:00
parent a0ffe43771
commit e93c9d6be6
2 changed files with 48 additions and 3 deletions
+47 -3
View File
@@ -19,6 +19,39 @@ const allBuiltinAgents: Record<BuiltinAgentName, AgentConfig> = {
"multimodal-looker": multimodalLookerAgent, "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:
<env>
Working directory: ${directory}
Platform: ${platform}
Today's date: ${dateStr}
Current time: ${timeStr}
Timezone: ${timezone}
Locale: ${locale}
</env>`
}
function mergeAgentConfig( function mergeAgentConfig(
base: AgentConfig, base: AgentConfig,
override: AgentOverrideConfig override: AgentOverrideConfig
@@ -28,7 +61,8 @@ function mergeAgentConfig(
export function createBuiltinAgents( export function createBuiltinAgents(
disabledAgents: BuiltinAgentName[] = [], disabledAgents: BuiltinAgentName[] = [],
agentOverrides: AgentOverrides = {} agentOverrides: AgentOverrides = {},
directory?: string
): Record<string, AgentConfig> { ): Record<string, AgentConfig> {
const result: Record<string, AgentConfig> = {} const result: Record<string, AgentConfig> = {}
@@ -39,11 +73,21 @@ export function createBuiltinAgents(
continue continue
} }
let finalConfig = config
if (agentName === "OmO" && directory && config.prompt) {
const envContext = createEnvContext(directory)
finalConfig = {
...config,
prompt: config.prompt + envContext,
}
}
const override = agentOverrides[agentName] const override = agentOverrides[agentName]
if (override) { if (override) {
result[name] = mergeAgentConfig(config, override) result[name] = mergeAgentConfig(finalConfig, override)
} else { } else {
result[name] = config result[name] = finalConfig
} }
} }
+1
View File
@@ -278,6 +278,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
const builtinAgents = createBuiltinAgents( const builtinAgents = createBuiltinAgents(
pluginConfig.disabled_agents, pluginConfig.disabled_agents,
pluginConfig.agents, pluginConfig.agents,
ctx.directory,
); );
const userAgents = (pluginConfig.claude_code?.agents ?? true) ? loadUserAgents() : {}; const userAgents = (pluginConfig.claude_code?.agents ?? true) ? loadUserAgents() : {};