summaryrefslogtreecommitdiff
path: root/makima/src/daemon/cli/contract.rs
blob: b5bd7ccfe08a550851ca5f9919f500f5fac8ff8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//! Contract subcommand - task-contract interaction commands.
//!
//! This module contains two types of commands:
//! 1. Task-contract interaction commands (used by agents via `makima contract`)
//! 2. Contract management helper commands (used by users via `makima contracts`)

use clap::Args;
use uuid::Uuid;

/// Common arguments for contract commands.
#[derive(Args, Debug, Clone)]
pub struct ContractArgs {
    /// API URL
    #[arg(long, env = "MAKIMA_API_URL", default_value = "https://api.makima.jp", global = true)]
    pub api_url: String,

    /// API key for authentication
    #[arg(long, env = "MAKIMA_API_KEY", global = true)]
    pub api_key: String,

    /// Current task ID (optional)
    #[arg(long, env = "MAKIMA_TASK_ID", global = true)]
    pub task_id: Option<Uuid>,

    /// Contract ID
    #[arg(long, env = "MAKIMA_CONTRACT_ID", global = true)]
    pub contract_id: Uuid,
}

/// Arguments for file command (get specific file).
#[derive(Args, Debug)]
pub struct FileArgs {
    #[command(flatten)]
    pub common: ContractArgs,

    /// File ID to retrieve
    pub file_id: Uuid,
}

/// Arguments for report command.
#[derive(Args, Debug)]
pub struct ReportArgs {
    #[command(flatten)]
    pub common: ContractArgs,

    /// Progress message
    pub message: String,
}

/// Arguments for completion-action command.
#[derive(Args, Debug)]
pub struct CompletionActionArgs {
    #[command(flatten)]
    pub common: ContractArgs,

    /// Comma-separated list of modified files
    #[arg(long)]
    pub files: Option<String>,

    /// Number of lines added
    #[arg(long, default_value = "0")]
    pub lines_added: i32,

    /// Number of lines removed
    #[arg(long, default_value = "0")]
    pub lines_removed: i32,

    /// Whether there are code changes
    #[arg(long)]
    pub code: bool,
}

/// Arguments for update-file command.
#[derive(Args, Debug)]
pub struct UpdateFileArgs {
    #[command(flatten)]
    pub common: ContractArgs,

    /// File ID to update
    pub file_id: Uuid,
}

/// Arguments for create-file command.
#[derive(Args, Debug)]
pub struct CreateFileArgs {
    #[command(flatten)]
    pub common: ContractArgs,

    /// Name of the new file
    pub name: String,
}

// =============================================================================
// Contract Management Helper Commands (makima contracts)
// =============================================================================

/// Common arguments for contracts management commands.
#[derive(Args, Debug, Clone)]
pub struct ContractsCommonArgs {
    /// API URL
    #[arg(long, env = "MAKIMA_API_URL", default_value = "https://api.makima.jp")]
    pub api_url: String,

    /// API key for authentication
    #[arg(long, env = "MAKIMA_API_KEY")]
    pub api_key: String,
}

/// Arguments for pause command.
#[derive(Args, Debug)]
pub struct PauseArgs {
    #[command(flatten)]
    pub common: ContractsCommonArgs,

    /// Contract ID to pause
    pub contract_id: Uuid,

    /// Reason for pausing the contract
    #[arg(long)]
    pub reason: Option<String>,
}

/// Arguments for resume command.
#[derive(Args, Debug)]
pub struct ResumeArgs {
    #[command(flatten)]
    pub common: ContractsCommonArgs,

    /// Contract ID to resume
    pub contract_id: Uuid,
}

/// Arguments for advance command.
#[derive(Args, Debug)]
pub struct AdvanceArgs {
    #[command(flatten)]
    pub common: ContractsCommonArgs,

    /// Contract ID to advance
    pub contract_id: Uuid,

    /// Target phase to advance to
    #[arg(long)]
    pub phase: String,

    /// Force the phase transition even if deliverables are incomplete
    #[arg(long)]
    pub force: bool,
}

/// Arguments for restart-supervisor command.
#[derive(Args, Debug)]
pub struct RestartSupervisorArgs {
    #[command(flatten)]
    pub common: ContractsCommonArgs,

    /// Contract ID to restart supervisor for
    pub contract_id: Uuid,
}

/// Arguments for show command.
#[derive(Args, Debug)]
pub struct ShowArgs {
    #[command(flatten)]
    pub common: ContractsCommonArgs,

    /// Contract ID to show
    pub contract_id: Uuid,

    /// Show verbose output with all details
    #[arg(long, short = 'v')]
    pub verbose: bool,
}

/// Arguments for health command.
#[derive(Args, Debug)]
pub struct HealthArgs {
    #[command(flatten)]
    pub common: ContractsCommonArgs,

    /// Contract ID to check health for
    pub contract_id: Uuid,
}