1use serde::{Deserialize, Serialize};
2use tokio_util::sync::CancellationToken;
3
4#[derive(Debug, Clone)]
5pub struct WorkspaceOpContext {
6 pub op_id: String,
7 pub cancellation_token: CancellationToken,
8}
9
10impl WorkspaceOpContext {
11 pub fn new(op_id: impl Into<String>, cancellation_token: CancellationToken) -> Self {
12 Self {
13 op_id: op_id.into(),
14 cancellation_token,
15 }
16 }
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct ReadFileRequest {
21 pub file_path: String,
22 pub offset: Option<u64>,
23 pub limit: Option<u64>,
24 pub raw: Option<bool>,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct ListDirectoryRequest {
29 pub path: String,
30 pub ignore: Option<Vec<String>>,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct GlobRequest {
35 pub pattern: String,
36 pub path: Option<String>,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct GrepRequest {
41 pub pattern: String,
42 pub include: Option<String>,
43 pub path: Option<String>,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct AstGrepRequest {
48 pub pattern: String,
49 pub lang: Option<String>,
50 pub include: Option<String>,
51 pub exclude: Option<String>,
52 pub path: Option<String>,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct EditOperation {
57 pub old_string: String,
58 pub new_string: String,
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
62pub struct ApplyEditsRequest {
63 pub file_path: String,
64 pub edits: Vec<EditOperation>,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
68pub struct WriteFileRequest {
69 pub file_path: String,
70 pub content: String,
71}