commit a1d2586b71284760f29117453e5302f7b56551e9
parent 9e3c8b9f24122981bf49cdb7439471081fec3bc6
Author: Michael Percival <m@michaelpercival.xyz>
Date: Tue, 14 Apr 2026 13:14:19 +0100
writing messages to stdout, changed history limit
Diffstat:
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/bot.js b/src/bot.js
@@ -32,10 +32,13 @@ function createBot(token) {
// Show typing indicator while Claude thinks
await bot.sendChatAction(chatId, 'typing');
+ console.log(`[user:${userId}] ${text}`);
+
const history = state.load(userId);
const currentTodo = todo.read();
const result = await claude.chat(history, text, currentTodo);
+ console.log(`[claude] ${result.reply}`);
// Write and commit if the todo changed
if (result.updatedTodo !== currentTodo) {
diff --git a/src/state.js b/src/state.js
@@ -2,7 +2,6 @@ const fs = require('fs');
const path = require('path');
const STATE_DIR = path.join(__dirname, '..', 'data', 'conversations');
-const MAX_MESSAGES = 20; // number of messages (user + assistant) to retain
function filePath(userId) {
return path.join(STATE_DIR, `${userId}.json`);
@@ -20,8 +19,7 @@ function load(userId) {
function save(userId, history) {
fs.mkdirSync(STATE_DIR, { recursive: true });
- const trimmed = history.slice(-MAX_MESSAGES);
- fs.writeFileSync(filePath(userId), JSON.stringify(trimmed, null, 2), 'utf8');
+ fs.writeFileSync(filePath(userId), JSON.stringify(history, null, 2), 'utf8');
}
// Appends a message and persists. Returns the full updated history.