2.1 KiB
2.1 KiB
ClaudeDo.Data
Shared data layer: models, repositories, SQLite infrastructure, and git operations.
Models
- TaskEntity — Id, ListId, Title, Description, Status (Manual|Queued|Running|Done|Failed), ScheduledFor, Result, LogPath, timestamps, CommitType
- ListEntity — Id, Name, WorkingDir, DefaultCommitType, CreatedAt
- TagEntity — Id (autoincrement), Name (unique)
- WorktreeEntity — TaskId (PK, 1:1 with task), Path, BranchName, BaseCommit, HeadCommit, DiffStat, State (Active|Merged|Discarded|Kept)
Repositories
All repositories use raw parameterized SQL via Microsoft.Data.Sqlite. Each method opens its own connection — no Unit of Work.
- TaskRepository — CRUD, status transitions (
MarkRunningAsync,MarkDoneAsync,MarkFailedAsync),GetNextQueuedAgentTaskAsync(queue polling),GetEffectiveTagsAsync(union of task + list tags),FlipAllRunningToFailedAsync - ListRepository — CRUD, tag junction management
- TagRepository —
GetOrCreateAsync(idempotent) - WorktreeRepository — CRUD,
UpdateHeadAsync,SetStateAsync
Infrastructure
- SqliteConnectionFactory — creates connections, applies WAL mode once, enforces foreign keys via PRAGMA
- SchemaInitializer — applies embedded
schema/schema.sqlidempotently (IF NOT EXISTS, INSERT OR IGNORE) - Paths — expands
~and%USERPROFILE%, resolves relative paths. App root:~/.todo-app - AppSettings — loads
~/.todo-app/ui.config.json(DbPath, SignalRUrl)
Git
- GitService — async wrapper around git CLI (ProcessStartInfo, no shell). Operations: worktree add/remove, add all, commit (stdin for message), merge ff-only, rev-parse, diff-stat, has-changes, is-git-repo
Schema
6 tables: lists, tasks, tags, list_tags, task_tags, worktrees. See schema/schema.sql. Seed data: tags "agent" and "manual".
Conventions
- Enum <-> string mapping via explicit
ToDb()/FromDb()static methods on each enum - Primary keys are
init-only strings (GUIDs assigned at creation) - Nullable fields use
DBNull.Valuechecks - All methods are async with CancellationToken where applicable