Skip to content

Commit 31876e8

Browse files
committed
File watcher
1 parent 302f0f9 commit 31876e8

File tree

10 files changed

+649
-109
lines changed

10 files changed

+649
-109
lines changed

Cargo.lock

Lines changed: 22 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ http = "1.2.0"
5959
http-body-util = "0.1.3"
6060
hyper = { version = "1.6.0", features = ["server"] }
6161
hyper-util = { version = "0.1.11", features = ["tokio"] }
62+
ignore = "0.4.24"
6263
indicatif = "0.17.11"
6364
indoc = "2.0.6"
6465
insta = "1.43.1"
6566
libc = "0.2.172"
6667
mimalloc = "0.1.46"
6768
mockito = "1.7.0"
6869
nix = { version = "0.29.0", features = ["feature", "fs", "ioctl", "process", "signal", "term", "user"] }
70+
notify = "8.2.0"
6971
objc2 = "0.5.2"
7072
objc2-app-kit = { version = "0.2.2", features = ["NSWorkspace"] }
7173
objc2-foundation = { version = "0.2.2", features = ["NSString", "NSURL"] }

crates/code-agent-sdk/src/config/json_config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub struct LanguageConfig {
1111
pub args: Vec<String>,
1212
pub file_extensions: Vec<String>,
1313
pub project_patterns: Vec<String>,
14+
pub exclude_patterns: Vec<String>,
1415
pub initialization_options: Option<Value>,
1516
}
1617

@@ -66,6 +67,7 @@ impl LanguagesConfig {
6667
command: config.command.clone(),
6768
args: config.args.clone(),
6869
file_extensions: config.file_extensions.clone(),
70+
exclude_patterns: config.exclude_patterns.clone(),
6971
initialization_options: config.initialization_options.clone(),
7072
})
7173
}
@@ -79,6 +81,7 @@ impl LanguagesConfig {
7981
command: config.command.clone(),
8082
args: config.args.clone(),
8183
file_extensions: config.file_extensions.clone(),
84+
exclude_patterns: config.exclude_patterns.clone(),
8285
initialization_options: config.initialization_options.clone(),
8386
})
8487
.collect()
@@ -108,6 +111,7 @@ impl LanguagesConfig {
108111
"args": ["--stdio"],
109112
"file_extensions": ["ts", "js", "tsx", "jsx"],
110113
"project_patterns": ["package.json", "tsconfig.json"],
114+
"exclude_patterns": ["**/node_modules/**", "**/dist/**"],
111115
"initialization_options": {
112116
"preferences": {
113117
"disableSuggestions": false
@@ -120,6 +124,7 @@ impl LanguagesConfig {
120124
"args": [],
121125
"file_extensions": ["rs"],
122126
"project_patterns": ["Cargo.toml"],
127+
"exclude_patterns": ["**/target/**"],
123128
"initialization_options": {
124129
"cargo": {
125130
"buildScripts": {
@@ -134,6 +139,7 @@ impl LanguagesConfig {
134139
"args": [],
135140
"file_extensions": ["py"],
136141
"project_patterns": ["pyproject.toml", "setup.py"],
142+
"exclude_patterns": ["**/__pycache__/**", "**/venv/**"],
137143
"initialization_options": {}
138144
}
139145
}

crates/code-agent-sdk/src/lsp/lsp_registry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ mod tests {
8989
command: format!("{}-lsp", name),
9090
args: vec!["--stdio".to_string()],
9191
file_extensions: extensions.iter().map(|s| s.to_string()).collect(),
92+
exclude_patterns: vec!["**/test/**".to_string()],
9293
initialization_options: None,
9394
}
9495
}

crates/code-agent-sdk/src/model/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ pub use types::{
1313
FormatCodeRequest, GetDocumentSymbolsRequest, GetSymbolsRequest, GotoDefinitionRequest,
1414
LanguageServerConfig, LspInfo, OpenFileRequest, RenameSymbolRequest, WorkspaceInfo,
1515
};
16+
17+
// Re-export crate-internal types
18+
pub(crate) use types::{FsEvent, FsEventKind};

crates/code-agent-sdk/src/model/types.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ pub struct LanguageServerConfig {
196196
pub args: Vec<String>,
197197
/// File extensions this language server handles (e.g., ["rs", "toml"])
198198
pub file_extensions: Vec<String>,
199+
/// Patterns to exclude from file watching (e.g., ["**/target/**", "**/node_modules/**"])
200+
pub exclude_patterns: Vec<String>,
199201
/// Optional initialization options sent to the language server
200202
pub initialization_options: Option<serde_json::Value>,
201203
}
@@ -232,3 +234,24 @@ pub struct LspInfo {
232234
pub version: Option<String>,
233235
}
234236

237+
// ============================================================================
238+
// File Watching Types (Crate Internal)
239+
// ============================================================================
240+
241+
/// File system event for internal file watching system
242+
#[derive(Debug, Clone)]
243+
pub(crate) struct FsEvent {
244+
pub(crate) uri: url::Url,
245+
pub(crate) kind: FsEventKind,
246+
pub(crate) timestamp: std::time::Instant,
247+
}
248+
249+
/// Types of file system events
250+
#[derive(Debug, Clone, PartialEq)]
251+
pub(crate) enum FsEventKind {
252+
Created,
253+
Modified,
254+
Deleted,
255+
Renamed { from: url::Url },
256+
}
257+

0 commit comments

Comments
 (0)