mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 22:21:52 +08:00
Rewriting Project Claw Code - Python port with Rust on the way
This commit is contained in:
23
src/transcript.py
Normal file
23
src/transcript.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
|
||||
@dataclass
|
||||
class TranscriptStore:
|
||||
entries: list[str] = field(default_factory=list)
|
||||
flushed: bool = False
|
||||
|
||||
def append(self, entry: str) -> None:
|
||||
self.entries.append(entry)
|
||||
self.flushed = False
|
||||
|
||||
def compact(self, keep_last: int = 10) -> None:
|
||||
if len(self.entries) > keep_last:
|
||||
self.entries[:] = self.entries[-keep_last:]
|
||||
|
||||
def replay(self) -> tuple[str, ...]:
|
||||
return tuple(self.entries)
|
||||
|
||||
def flush(self) -> None:
|
||||
self.flushed = True
|
||||
Reference in New Issue
Block a user