codewhale_command_contract/facets/
debug_operations.rs1use super::{Receipt, SessionSyncPayload};
7use std::path::PathBuf;
8
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub enum DebugReceiptError {
11 ApprovalLog(String),
12 Build(String),
13}
14
15pub trait CommandDebugReceiptsContext {
16 fn receipt(&self, turn: Option<&str>) -> Result<Receipt, DebugReceiptError>;
17}
18
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub struct DebugChangeProjection {
21 pub changelog: &'static str,
22 pub is_english: bool,
23 pub translation_available: bool,
24 pub translation_target: &'static str,
25}
26
27pub trait CommandDebugChangeContext {
28 fn change_projection(&self) -> DebugChangeProjection;
29}
30
31pub trait CommandDebugHistoryContext {
32 fn last_user_input(&self) -> Option<String>;
33 fn load_composer(&mut self, input: String);
34 fn undo_conversation(&mut self) -> DebugConversationUndo;
38}
39
40#[derive(Debug, Clone, PartialEq)]
43pub struct DebugConversationUndo {
44 pub removed: usize,
45 pub sync: SessionSyncPayload,
46}
47
48#[derive(Debug, Clone, PartialEq, Eq)]
49pub enum DebugDiffObservation {
50 GitUnavailable,
51 NoBaseline,
54 Output {
55 names: String,
56 stat: String,
57 patch: String,
59 patch_truncated: bool,
61 },
62 Failed(String),
63}
64
65pub trait CommandDebugDiffContext {
66 fn diff(&self) -> DebugDiffObservation;
67}
68
69#[derive(Debug, Clone, Copy, PartialEq, Eq)]
70pub enum DebugRestoreAction {
71 Modified,
72 Recreated,
73 Removed,
74}
75
76#[derive(Debug, Clone, PartialEq, Eq)]
77pub struct DebugRestoredFile {
78 pub action: DebugRestoreAction,
79 pub path: PathBuf,
80}
81
82#[derive(Debug, Clone, PartialEq)]
83pub struct DebugUndoRestored {
84 pub request: Option<String>,
87 pub conversation_removed: bool,
90 pub forced: bool,
93 pub files: Vec<DebugRestoredFile>,
94 pub skipped: Vec<PathBuf>,
95 pub sync: SessionSyncPayload,
96}
97
98#[derive(Debug, Clone, PartialEq)]
99pub enum DebugUndoOutcome {
100 RepoUnavailable {
101 workspace: PathBuf,
102 error: String,
103 },
104 SnapshotPending,
105 NoSnapshots,
106 NoSession,
107 NoOwnedSteps,
108 NoDifference,
109 OpenEnded,
112 CompareFailed(String),
113 SnapshotFailed(String),
114 ChangedSince {
115 paths: Vec<String>,
116 },
117 ListFailed(String),
118 RestoreBlocked(String),
119 RestoreFailed(String),
120 Restored(DebugUndoRestored),
121}
122
123pub trait CommandDebugUndoContext {
124 fn undo_files(&mut self, force: bool) -> DebugUndoOutcome;
132}