Skip to main content

steer_workspace/
ops.rs

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}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct ListDirectoryRequest {
28    pub path: String,
29    pub ignore: Option<Vec<String>>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct GlobRequest {
34    pub pattern: String,
35    pub path: Option<String>,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct GrepRequest {
40    pub pattern: String,
41    pub include: Option<String>,
42    pub path: Option<String>,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct AstGrepRequest {
47    pub pattern: String,
48    pub lang: Option<String>,
49    pub include: Option<String>,
50    pub exclude: Option<String>,
51    pub path: Option<String>,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct EditOperation {
56    pub old_string: String,
57    pub new_string: String,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct ApplyEditsRequest {
62    pub file_path: String,
63    pub edits: Vec<EditOperation>,
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
67pub struct WriteFileRequest {
68    pub file_path: String,
69    pub content: String,
70}