Skip to content
Merged
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
17 changes: 16 additions & 1 deletion src/basic_memory/cli/commands/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def display_changes(
"""Display changes using Rich for better visualization."""
tree = Tree(f"{project_name}: {title}")

if changes.total == 0:
if changes.total == 0 and not changes.skipped_files:
tree.add("No changes")
console.print(Panel(tree, expand=False))
return
Expand All @@ -114,6 +114,13 @@ def display_changes(
if changes.deleted:
del_branch = tree.add("[red]Deleted[/red]")
add_files_to_tree(del_branch, changes.deleted, "red")
if changes.skipped_files:
skip_branch = tree.add("[red]⚠️ Skipped (Circuit Breaker)[/red]")
for skipped in sorted(changes.skipped_files, key=lambda x: x.path):
skip_branch.add(
f"[red]{skipped.path}[/red] "
f"(failures: {skipped.failure_count}, reason: {skipped.reason})"
)
else:
# Show directory summaries
by_dir = group_changes_by_directory(changes)
Expand All @@ -122,6 +129,14 @@ def display_changes(
if summary: # Only show directories with changes
tree.add(f"[bold]{dir_name}/[/bold] {summary}")

# Show skipped files summary in non-verbose mode
if changes.skipped_files:
skip_count = len(changes.skipped_files)
tree.add(
f"[red]⚠️ {skip_count} file{'s' if skip_count != 1 else ''} "
f"skipped due to repeated failures[/red]"
)

console.print(Panel(tree, expand=False))


Expand Down
3 changes: 2 additions & 1 deletion src/basic_memory/importers/claude_conversations_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def _format_chat_markdown(
if msg.get("content"):
# Filter out None values before joining
content = " ".join(
str(c.get("text", "")) for c in msg["content"]
str(c.get("text", ""))
for c in msg["content"]
if c and c.get("text") is not None
)
lines.append(content)
Expand Down
26 changes: 25 additions & 1 deletion src/basic_memory/schemas/sync_report.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Pydantic schemas for sync report responses."""

from typing import TYPE_CHECKING, Dict, Set
from datetime import datetime
from typing import TYPE_CHECKING, Dict, List, Set

from pydantic import BaseModel, Field

Expand All @@ -9,6 +10,17 @@
from basic_memory.sync.sync_service import SyncReport


class SkippedFileResponse(BaseModel):
"""Information about a file that was skipped due to repeated failures."""

path: str = Field(description="File path relative to project root")
reason: str = Field(description="Error message from last failure")
failure_count: int = Field(description="Number of consecutive failures")
first_failed: datetime = Field(description="Timestamp of first failure")

model_config = {"from_attributes": True}


class SyncReportResponse(BaseModel):
"""Report of file changes found compared to database state.

Expand All @@ -24,6 +36,9 @@ class SyncReportResponse(BaseModel):
checksums: Dict[str, str] = Field(
default_factory=dict, description="Current file checksums (path -> checksum)"
)
skipped_files: List[SkippedFileResponse] = Field(
default_factory=list, description="Files skipped due to repeated failures"
)
total: int = Field(description="Total number of changes")

@classmethod
Expand All @@ -42,6 +57,15 @@ def from_sync_report(cls, report: "SyncReport") -> "SyncReportResponse":
deleted=report.deleted,
moves=report.moves,
checksums=report.checksums,
skipped_files=[
SkippedFileResponse(
path=skipped.path,
reason=skipped.reason,
failure_count=skipped.failure_count,
first_failed=skipped.first_failed,
)
for skipped in report.skipped_files
],
total=report.total,
)

Expand Down
Loading
Loading