life-todo

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 2bbe9402334affa62178aa94c47f1fa550d31484
parent 00d1ff9dd0d9bc89ecb905efc0f853a3170520a5
Author: Michael Percival <m@michaelpercival.xyz>
Date:   Tue, 14 Apr 2026 15:19:13 +0100

Commit conversation history alongside todo on every exchange

git.js now stages conversations/ as well as todo.md. bot.js always
commits after each message, using the todo commit message when the
todo changed, or 'Update conversation history' otherwise.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Diffstat:
Msrc/bot.js | 19++++++++++---------
Msrc/git.js | 2+-
2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/bot.js b/src/bot.js @@ -45,23 +45,24 @@ function createBot(token) { const result = await claude.chat(history, text, currentTodo); console.log(`[claude] ${result.reply}`); - // Write and commit if the todo changed if (result.updatedTodo !== currentTodo) { todo.write(result.updatedTodo); - if (result.commitMessage) { - try { - await git.commitAndPush(result.commitMessage); - } catch (gitErr) { - console.error('Git push failed:', gitErr.message); - // Non-fatal — the file is updated locally even if push fails - } - } } // Persist both sides of the exchange state.append(userId, 'user', text); state.append(userId, 'assistant', result.reply); + // Always commit — todo + conversation history together + const commitMessage = result.updatedTodo !== currentTodo && result.commitMessage + ? result.commitMessage + : 'Update conversation history'; + try { + await git.commitAndPush(commitMessage); + } catch (gitErr) { + console.error('Git push failed:', gitErr.message); + } + await bot.sendMessage(chatId, result.reply, { parse_mode: 'Markdown' }); } catch (err) { diff --git a/src/git.js b/src/git.js @@ -5,7 +5,7 @@ const DATA_REPO = path.join(__dirname, '..', 'data', 'repo'); const git = simpleGit(DATA_REPO); async function commitAndPush(message) { - await git.add('todo.md'); + await git.add(['todo.md', 'conversations']); const status = await git.status(); if (status.staged.length === 0) {