Files
zesdex/apps/packages/domain/src/cms/edit_log.ts
T
asepharyanaandClaude Opus 5 07e84e43b3 feat(rewrite): bootstrap monorepo Bun + port domain layer ke TypeScript
Mulai migrasi Zesdex dari Rust ke TypeScript/Bun.

- Root workspace package.json, tsconfig strict, bun.lock, gitignore fix
- Paket @zesdex/domain (apps/packages/domain):
  - core: ChatMessage/Conversation/ToolCall/SseParser/repairJson/
    sanitizeToolArguments/UsageStats/Store/DomainError
  - auth: Session/SessionId/SessionLock/OAuth + repository & service interfaces
  - cms: AppConfig/Settings/SettingsPatch/Memory/EditLog + repository &
    service interfaces
  - agent: TurnEvent/SessionRuntime/AgentTurnParams/AgentProgress/prompt
  - subagent & workflow models
- Wire-shape JSON disamakan dengan Rust (serde rename/flatten/skip_if)
- 27 unit test Bun port dari test Rust (SseParser, repair_json, resolve_effective_model, session id)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 22:50:38 +07:00

53 lines
1.4 KiB
TypeScript

/**
* Edit log — append-only log of file mutations. Mirrors `edit_log.rs`.
*/
/** A single recorded file edit event. */
export interface EditLogEntry {
/** Unix timestamp (ms) when the edit occurred. */
ts: number;
/** Name of the tool that performed the edit. */
tool: string;
/** Absolute file path that was modified. */
path: string;
/** Human-readable explanation of why the edit was made. */
reason: string;
/** SHA-256 hex digest of the content after the edit. */
content_sha256: string;
/** Signed byte count change (+added, -removed). */
bytes_delta: number;
/** Origin identifier (which agent / session context). */
origin: string;
/** Session in which this edit was performed. */
session_id: string;
}
/** Maximum number of edit entries held in memory at once. */
export const MAX_MEMORY_ENTRIES = 10_000;
/** In-memory view of a session's edit log. */
export class EditLog {
entries: EditLogEntry[];
constructor() {
this.entries = [];
}
/** Number of in-memory entries. */
get length(): number {
return this.entries.length;
}
/** Whether the log contains no entries. */
get isEmpty(): boolean {
return this.entries.length === 0;
}
/** Append an entry, evicting oldest beyond MAX_MEMORY_ENTRIES. */
push(entry: EditLogEntry): void {
this.entries.push(entry);
if (this.entries.length > MAX_MEMORY_ENTRIES) {
this.entries.shift();
}
}
}