One module per API area (base, files, activity, skills, conversations, notifications, forms, search, plans, projects, services, misc, diff, cron, agents) on a shared base.Schema; __init__.py re-exports every model so handlers keep writing schemas.<Name>. OpenAPI output is byte-identical. PlanSummary lives in conversations.py to keep the module graph a DAG. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
90 lines
2.0 KiB
Python
90 lines
2.0 KiB
Python
"""The diff view (commit + conversation diffs)."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Literal, Optional
|
|
|
|
from .base import Schema
|
|
|
|
__all__ = [
|
|
"CommitRef",
|
|
"ConversationCommits",
|
|
"DiffLine",
|
|
"DiffHunk",
|
|
"FileDiff",
|
|
"WorktreeRef",
|
|
"DiffResult",
|
|
]
|
|
|
|
|
|
class CommitRef(Schema):
|
|
sha: str
|
|
short: str
|
|
date: str
|
|
author: str
|
|
subject: str
|
|
additions: int
|
|
deletions: int
|
|
files: int
|
|
repo: str # repo token: project:<slug> | service:<slug> | super:_
|
|
|
|
|
|
class ConversationCommits(Schema):
|
|
id: str
|
|
commits: list[CommitRef]
|
|
repos: list[str]
|
|
filesChanged: int
|
|
additions: int
|
|
deletions: int
|
|
|
|
|
|
class DiffLine(Schema):
|
|
type: Literal["add", "del", "ctx"]
|
|
oldNo: Optional[int] = None
|
|
newNo: Optional[int] = None
|
|
text: str
|
|
|
|
|
|
class DiffHunk(Schema):
|
|
header: str
|
|
oldStart: int
|
|
oldLines: int
|
|
newStart: int
|
|
newLines: int
|
|
lines: list[DiffLine]
|
|
|
|
|
|
class FileDiff(Schema):
|
|
path: str
|
|
oldPath: Optional[str] = None
|
|
status: Literal["added", "deleted", "modified", "renamed"]
|
|
additions: int
|
|
deletions: int
|
|
binary: bool
|
|
truncated: bool
|
|
hunks: list[DiffHunk]
|
|
repo: Optional[str] = None
|
|
# Worktree directory this file was read from (worktree diffs only) — the
|
|
# blob route needs it to serve the right copy of an image.
|
|
wt: Optional[str] = None
|
|
|
|
|
|
class WorktreeRef(Schema):
|
|
"""A live git worktree a conversation's diff was read from."""
|
|
dir: str
|
|
branch: Optional[str] = None
|
|
repo: str
|
|
|
|
|
|
class DiffResult(Schema):
|
|
title: str
|
|
subtitle: Optional[str] = None
|
|
files: list[FileDiff]
|
|
additions: int
|
|
deletions: int
|
|
commits: Optional[list[CommitRef]] = None
|
|
approx: Optional[bool] = None
|
|
# "worktree" when the changes were read with a real `git diff` from a live
|
|
# worktree; absent/"transcript" when replayed from the transcript's edits.
|
|
source: Optional[Literal["worktree", "transcript"]] = None
|
|
worktrees: Optional[list[WorktreeRef]] = None
|