mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-06 03:03:36 +00:00
fix(memory): repair Dream follow-up paths and move GitStore to utils
Made-with: Cursor
This commit is contained in:
parent
30ea048f19
commit
7e0c196797
@ -15,7 +15,7 @@ from nanobot.utils.helpers import ensure_dir, estimate_message_tokens, estimate_
|
||||
|
||||
from nanobot.agent.runner import AgentRunSpec, AgentRunner
|
||||
from nanobot.agent.tools.registry import ToolRegistry
|
||||
from nanobot.agent.git_store import GitStore
|
||||
from nanobot.utils.git_store import GitStore
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from nanobot.providers.base import LLMProvider
|
||||
@ -569,6 +569,7 @@ class Dream:
|
||||
|
||||
# Git auto-commit (only when there are actual changes)
|
||||
if changelog and self.store.git.is_initialized():
|
||||
ts = batch[-1]["timestamp"]
|
||||
sha = self.store.git.auto_commit(f"dream: {ts}, {len(changelog)} change(s)")
|
||||
if sha:
|
||||
logger.info("Dream commit: {}", sha)
|
||||
|
||||
@ -136,7 +136,8 @@ async def cmd_dream_log(ctx: CommandContext) -> OutboundMessage:
|
||||
content = commit.format(diff)
|
||||
else:
|
||||
# Default: show the latest commit's diff
|
||||
result = git.show_commit_diff(git.log(max_entries=1)[0].sha) if git.log(max_entries=1) else None
|
||||
commits = git.log(max_entries=1)
|
||||
result = git.show_commit_diff(commits[0].sha) if commits else None
|
||||
if result:
|
||||
commit, diff = result
|
||||
content = commit.format(diff)
|
||||
|
||||
@ -457,7 +457,7 @@ def sync_workspace_templates(workspace: Path, silent: bool = False) -> list[str]
|
||||
|
||||
# Initialize git for memory version control
|
||||
try:
|
||||
from nanobot.agent.git_store import GitStore
|
||||
from nanobot.utils.git_store import GitStore
|
||||
gs = GitStore(workspace, tracked_files=[
|
||||
"SOUL.md", "USER.md", "memory/MEMORY.md",
|
||||
])
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
|
||||
from nanobot.agent.git_store import GitStore, CommitInfo
|
||||
from nanobot.utils.git_store import GitStore, CommitInfo
|
||||
|
||||
|
||||
TRACKED = ["SOUL.md", "USER.md", "memory/MEMORY.md"]
|
||||
@ -181,7 +181,7 @@ class TestShowCommitDiff:
|
||||
|
||||
class TestCommitInfoFormat:
|
||||
def test_format_with_diff(self):
|
||||
from nanobot.agent.git_store import CommitInfo
|
||||
from nanobot.utils.git_store import CommitInfo
|
||||
c = CommitInfo(sha="abcd1234", message="test commit\nsecond line", timestamp="2026-04-02 12:00")
|
||||
result = c.format(diff="some diff")
|
||||
assert "test commit" in result
|
||||
@ -189,7 +189,7 @@ class TestCommitInfoFormat:
|
||||
assert "some diff" in result
|
||||
|
||||
def test_format_without_diff(self):
|
||||
from nanobot.agent.git_store import CommitInfo
|
||||
from nanobot.utils.git_store import CommitInfo
|
||||
c = CommitInfo(sha="abcd1234", message="test", timestamp="2026-04-02 12:00")
|
||||
result = c.format()
|
||||
assert "(no file changes)" in result
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user