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 rewind_conversation: bool,
89 pub forced: bool,
92 pub files: Vec<DebugRestoredFile>,
93 pub skipped: Vec<PathBuf>,
94 pub sync: SessionSyncPayload,
95}
96
97#[derive(Debug, Clone, PartialEq)]
98pub enum DebugUndoOutcome {
99 RepoUnavailable {
100 workspace: PathBuf,
101 error: String,
102 },
103 SnapshotPending,
104 NoSnapshots,
105 NoSession,
106 NoOwnedSteps,
107 NoDifference,
108 OpenEnded,
111 CompareFailed(String),
112 SnapshotFailed(String),
113 ChangedSince {
114 paths: Vec<String>,
115 },
116 ListFailed(String),
117 RestoreBlocked(String),
118 RestoreFailed(String),
119 Restored(DebugUndoRestored),
120}
121
122pub trait CommandDebugUndoContext {
123 fn undo_files(&mut self, force: bool) -> DebugUndoOutcome;
131}