Merge pull request #378 from timkrase/system-prompt-weekday

Agents: add weekday to user time (codex assisted)
This commit is contained in:
Josh Palmer
2026-01-07 11:27:07 +01:00
committed by GitHub
2 changed files with 12 additions and 4 deletions

View File

@@ -213,6 +213,7 @@ function formatUserTime(date: Date, timeZone: string): string | undefined {
try {
const parts = new Intl.DateTimeFormat("en-CA", {
timeZone,
weekday: "long",
year: "numeric",
month: "2-digit",
day: "2-digit",
@@ -224,10 +225,17 @@ function formatUserTime(date: Date, timeZone: string): string | undefined {
for (const part of parts) {
if (part.type !== "literal") map[part.type] = part.value;
}
if (!map.year || !map.month || !map.day || !map.hour || !map.minute) {
if (
!map.weekday ||
!map.year ||
!map.month ||
!map.day ||
!map.hour ||
!map.minute
) {
return undefined;
}
return `${map.year}-${map.month}-${map.day} ${map.hour}:${map.minute}`;
return `${map.weekday} ${map.year}-${map.month}-${map.day} ${map.hour}:${map.minute}`;
} catch {
return undefined;
}

View File

@@ -50,12 +50,12 @@ describe("buildAgentSystemPromptAppend", () => {
const prompt = buildAgentSystemPromptAppend({
workspaceDir: "/tmp/clawd",
userTimezone: "America/Chicago",
userTime: "2026-01-05 15:26",
userTime: "Monday 2026-01-05 15:26",
});
expect(prompt).toContain("## Time");
expect(prompt).toContain("User timezone: America/Chicago");
expect(prompt).toContain("Current user time: 2026-01-05 15:26");
expect(prompt).toContain("Current user time: Monday 2026-01-05 15:26");
});
it("includes model alias guidance when aliases are provided", () => {