Skip to content

Commit f9916b6

Browse files
committed
fix: format code and update CI to use npm for GUI
- Run cargo fmt --all to fix formatting issues - Update gui-check CI job to use npm instead of pnpm (orion desktop uses npm)
1 parent 7621ea9 commit f9916b6

47 files changed

Lines changed: 863 additions & 767 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,22 @@ jobs:
105105
runner: windows-64-cli
106106
steps:
107107
- uses: actions/checkout@v4
108-
- uses: pnpm/action-setup@v4
109-
with:
110-
version: 9
111108
- uses: actions/setup-node@v4
112109
with:
113110
node-version: "20"
114-
cache: "pnpm"
115-
cache-dependency-path: cortex-gui/pnpm-lock.yaml
111+
cache: "npm"
112+
cache-dependency-path: cortex-gui/package-lock.json
116113
- name: Install Linux dependencies
117114
if: matrix.name == 'ubuntu'
118115
run: |
119116
sudo apt-get update
120117
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libglib2.0-dev
121118
- name: Install frontend dependencies
122119
working-directory: cortex-gui
123-
run: pnpm install --frozen-lockfile
120+
run: npm ci
124121
- name: Build frontend
125122
working-directory: cortex-gui
126-
run: pnpm build
123+
run: npm run build
127124
- uses: dtolnay/rust-toolchain@stable
128125
- uses: Swatinem/rust-cache@v2
129126
with:

cortex-engine/src/agent/generator.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,10 @@ fn validate_agent(mut agent: GeneratedAgent) -> Result<GeneratedAgent> {
372372

373373
// Validate temperature
374374
if let Some(temp) = agent.temperature
375-
&& !(0.0..=2.0).contains(&temp) {
376-
agent.temperature = Some(temp.clamp(0.0, 2.0));
377-
}
375+
&& !(0.0..=2.0).contains(&temp)
376+
{
377+
agent.temperature = Some(temp.clamp(0.0, 2.0));
378+
}
378379

379380
// Validate tools - filter to known tools
380381
let known_tools = [

cortex-engine/src/agent/tools/multiedit.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,14 @@ impl ToolHandler for MultiEditTool {
127127
for (path, content) in &working_contents {
128128
// Only write if content actually changed
129129
if content != file_contents.get(path).unwrap()
130-
&& let Err(e) = fs::write(path, content).await {
131-
return Ok(ToolResult::error(format!(
132-
"Failed to write to {}: {}",
133-
path.display(),
134-
e
135-
)));
136-
}
130+
&& let Err(e) = fs::write(path, content).await
131+
{
132+
return Ok(ToolResult::error(format!(
133+
"Failed to write to {}: {}",
134+
path.display(),
135+
e
136+
)));
137+
}
137138
}
138139

139140
let metadata = ToolMetadata {

cortex-engine/src/agent/tools/patch.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,11 @@ impl PatchTool {
125125
&& let Some(ref old_path) = change.old_path
126126
{
127127
let full_path = cwd.join(old_path);
128-
if !dry_run
129-
&& full_path.exists() {
130-
fs::remove_file(&full_path)
131-
.await
132-
.map_err(|e| format!("Failed to delete {}: {}", old_path.display(), e))?;
133-
}
128+
if !dry_run && full_path.exists() {
129+
fs::remove_file(&full_path)
130+
.await
131+
.map_err(|e| format!("Failed to delete {}: {}", old_path.display(), e))?;
132+
}
134133
return Ok(format!(" D {}", old_path.display()));
135134
}
136135

@@ -454,10 +453,9 @@ fn find_hunk_position(
454453
}
455454
}
456455
let pos = suggested_start + offset;
457-
if pos < lines.len()
458-
&& matches_at_position(lines, &match_lines, pos) {
459-
return Ok(pos);
460-
}
456+
if pos < lines.len() && matches_at_position(lines, &match_lines, pos) {
457+
return Ok(pos);
458+
}
461459
}
462460

463461
Err(())

cortex-engine/src/agent/tools/search.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,20 @@ impl ToolHandler for WebSearchTool {
189189
for line in response_text.lines() {
190190
if let Some(data) = line.strip_prefix("data: ")
191191
&& let Ok(mcp_resp) = serde_json::from_str::<McpSearchResponse>(data)
192-
&& let Some(content) = mcp_resp.result.content.first() {
193-
output = content.text.clone();
194-
break;
195-
}
192+
&& let Some(content) = mcp_resp.result.content.first()
193+
{
194+
output = content.text.clone();
195+
break;
196+
}
196197
}
197198

198199
if output.is_empty() {
199200
// Try parsing as direct JSON if not SSE
200201
if let Ok(mcp_resp) = serde_json::from_str::<McpSearchResponse>(&response_text)
201-
&& let Some(content) = mcp_resp.result.content.first() {
202-
output = content.text.clone();
203-
}
202+
&& let Some(content) = mcp_resp.result.content.first()
203+
{
204+
output = content.text.clone();
205+
}
204206
}
205207

206208
if output.is_empty() {

cortex-engine/src/agents.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -276,28 +276,29 @@ impl AgentRegistry {
276276
// Scan OS-specific agents directory (custom agents from IDE/desktop)
277277
// This takes priority over other sources for custom agents
278278
if let Some(os_agents_dir) = get_os_agents_dir()
279-
&& os_agents_dir.exists() {
280-
tracing::debug!(path = %os_agents_dir.display(), "Scanning OS agents directory");
281-
match self.scan_directory(&os_agents_dir, AgentSource::Personal) {
282-
Ok(agents) => {
283-
// Only include enabled agents
284-
let enabled_agents: Vec<_> =
285-
agents.into_iter().filter(|a| a.metadata.enabled).collect();
286-
tracing::info!(
287-
count = enabled_agents.len(),
288-
"Loaded custom agents from OS directory"
289-
);
290-
all_agents.extend(enabled_agents);
291-
}
292-
Err(e) => {
293-
tracing::warn!(
294-
path = %os_agents_dir.display(),
295-
error = %e,
296-
"Failed to scan OS agents directory"
297-
);
298-
}
279+
&& os_agents_dir.exists()
280+
{
281+
tracing::debug!(path = %os_agents_dir.display(), "Scanning OS agents directory");
282+
match self.scan_directory(&os_agents_dir, AgentSource::Personal) {
283+
Ok(agents) => {
284+
// Only include enabled agents
285+
let enabled_agents: Vec<_> =
286+
agents.into_iter().filter(|a| a.metadata.enabled).collect();
287+
tracing::info!(
288+
count = enabled_agents.len(),
289+
"Loaded custom agents from OS directory"
290+
);
291+
all_agents.extend(enabled_agents);
292+
}
293+
Err(e) => {
294+
tracing::warn!(
295+
path = %os_agents_dir.display(),
296+
error = %e,
297+
"Failed to scan OS agents directory"
298+
);
299299
}
300300
}
301+
}
301302

302303
// Scan personal agents (~/.fabric/agents)
303304
if self.personal_dir.exists() {

cortex-engine/src/client/cortex.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,10 @@ impl ModelClient for CortexClient {
405405
};
406406

407407
if let Some(event) = response_event
408-
&& tx.send(Ok(event)).await.is_err() {
409-
break;
410-
}
408+
&& tx.send(Ok(event)).await.is_err()
409+
{
410+
break;
411+
}
411412
}
412413
Err(e) => {
413414
tracing::debug!(

cortex-engine/src/config/config_discovery.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ pub fn find_up(start_dir: &Path, filename: &str) -> Option<PathBuf> {
4949

5050
// Check cache first
5151
if let Ok(cache) = CONFIG_CACHE.read()
52-
&& let Some(cached) = cache.get(&cache_key) {
53-
trace!(key = %cache_key.display(), "Using cached config lookup");
54-
return cached.clone();
55-
}
52+
&& let Some(cached) = cache.get(&cache_key)
53+
{
54+
trace!(key = %cache_key.display(), "Using cached config lookup");
55+
return cached.clone();
56+
}
5657

5758
let result = find_up_uncached(start_dir, filename);
5859

@@ -130,10 +131,11 @@ fn is_root_directory(dir: &Path) -> bool {
130131
pub fn find_project_root(start_dir: &Path) -> Option<PathBuf> {
131132
// Check cache first
132133
if let Ok(cache) = PROJECT_ROOT_CACHE.read()
133-
&& let Some(cached) = cache.get(start_dir) {
134-
trace!(start = %start_dir.display(), "Using cached project root");
135-
return cached.clone();
136-
}
134+
&& let Some(cached) = cache.get(start_dir)
135+
{
136+
trace!(start = %start_dir.display(), "Using cached project root");
137+
return cached.clone();
138+
}
137139

138140
let result = find_project_root_uncached(start_dir);
139141

cortex-engine/src/config/loader.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,21 @@ pub const FABRIC_CONFIG_DIR_ENV: &str = "FABRIC_CONFIG_DIR";
3737
pub fn find_fabric_home() -> std::io::Result<PathBuf> {
3838
// Check FABRIC_CONFIG_DIR environment variable first (new)
3939
if let Ok(val) = std::env::var(FABRIC_CONFIG_DIR_ENV)
40-
&& !val.is_empty() {
41-
let path = PathBuf::from(&val);
42-
debug!(path = %path.display(), "Using FABRIC_CONFIG_DIR");
43-
return Ok(path);
44-
}
40+
&& !val.is_empty()
41+
{
42+
let path = PathBuf::from(&val);
43+
debug!(path = %path.display(), "Using FABRIC_CONFIG_DIR");
44+
return Ok(path);
45+
}
4546

4647
// Check FABRIC_HOME environment variable
4748
if let Ok(val) = std::env::var("FABRIC_HOME")
48-
&& !val.is_empty() {
49-
let path = PathBuf::from(&val);
50-
debug!(path = %path.display(), "Using FABRIC_HOME");
51-
return Ok(path);
52-
}
49+
&& !val.is_empty()
50+
{
51+
let path = PathBuf::from(&val);
52+
debug!(path = %path.display(), "Using FABRIC_HOME");
53+
return Ok(path);
54+
}
5355

5456
// Default to ~/.fabric
5557
let mut home = dirs::home_dir().ok_or_else(|| {
@@ -66,11 +68,12 @@ pub fn find_fabric_home() -> std::io::Result<PathBuf> {
6668
pub fn get_config_path(fabric_home: &Path) -> PathBuf {
6769
// Check FABRIC_CONFIG environment variable
6870
if let Ok(val) = std::env::var(FABRIC_CONFIG_ENV)
69-
&& !val.is_empty() {
70-
let path = PathBuf::from(&val);
71-
debug!(path = %path.display(), "Using FABRIC_CONFIG");
72-
return path;
73-
}
71+
&& !val.is_empty()
72+
{
73+
let path = PathBuf::from(&val);
74+
debug!(path = %path.display(), "Using FABRIC_CONFIG");
75+
return path;
76+
}
7477

7578
fabric_home.join(CONFIG_FILE)
7679
}

cortex-engine/src/custom_command/loader.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ pub fn load_command_file(path: &Path, source: CommandSource) -> Result<CustomCom
4242
source_path: Some(path.to_path_buf()),
4343
};
4444

45-
command
46-
.validate()
47-
.map_err(CortexError::InvalidInput)?;
45+
command.validate().map_err(CortexError::InvalidInput)?;
4846

4947
Ok(command)
5048
}

0 commit comments

Comments
 (0)