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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

### Fixed

- Format the current time in Claude response prompts in UTC regardless of the host timezone.
- Bound recent live Discord context passed to Claude so deep-context requests cannot contribute unbounded live-message input.
- Support announcement and other guild text-based channels in MCP channel tools.
- Reject symbolic-link attachment destinations instead of following them when saving downloads.
Expand Down
1 change: 1 addition & 0 deletions src/askClaude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function askClaude(
const now = new Date();
promptParts.push(
`=== Current time: ${now.toLocaleString("en-US", {
timeZone: "UTC",
weekday: "long",
year: "numeric",
month: "long",
Expand Down
48 changes: 48 additions & 0 deletions tests/promptTime.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { spawnSync } from "node:child_process";
import test from "node:test";
import { fileURLToPath } from "node:url";

const repoDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");

test("formats Claude response prompt times in UTC", () => {
const messagesDir = fs.mkdtempSync(
path.join(os.tmpdir(), "claudify-prompt-time-"),
);
try {
const script = `
import { askClaude } from "./build/askClaude.js";
let prompt = "";
await askClaude(
"Question", "User", "user-1", "general", "channel-1",
"Guild", "guild-1", [], "",
async (_args, input) => {
prompt = input;
return { stdout: "Answer", stderr: "" };
},
);
process.stdout.write(prompt.split("\\n", 1)[0]);
`;
const result = spawnSync(
process.execPath,
["--input-type=module", "--eval", script],
{
cwd: repoDir,
encoding: "utf8",
env: {
...process.env,
MESSAGES_DIR: messagesDir,
TZ: "America/Los_Angeles",
},
},
);

assert.equal(result.status, 0, result.stderr);
assert.match(result.stdout, /^=== Current time: .* UTC ===$/);
} finally {
fs.rmSync(messagesDir, { recursive: true, force: true });
}
});