Skip to content

Commit 9cdfc75

Browse files
authored
Merge pull request #279 from syncable-dev/develop
Develop
2 parents f81fe57 + 7d6c701 commit 9cdfc75

63 files changed

Lines changed: 15492 additions & 21 deletions

Some content is hidden

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

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ colored = "3"
5151
crossterm = "0.29" # Terminal raw mode for interactive input
5252
inquire = "0.9" # Interactive terminal prompts with autocomplete
5353
rustyline = "17" # Readline-style input with completions
54+
webbrowser = "1" # Open URLs in default browser
5455
prettytable = "0.10"
5556
term_size = "0.3"
5657

src/agent/mod.rs

Lines changed: 110 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ pub async fn run_interactive(
184184

185185
session.print_banner();
186186

187+
// Display platform context if a project is selected
188+
if session.platform_session.is_project_selected() {
189+
println!(
190+
"{}",
191+
format!("Platform context: {}", session.platform_session.display_context()).dimmed()
192+
);
193+
}
194+
187195
// NOTE: Terminal layout with ANSI scroll regions is disabled for now.
188196
// The scroll region approach conflicts with the existing input/output flow.
189197
// TODO: Implement proper scroll region support that integrates with the input handler.
@@ -577,7 +585,23 @@ pub async fn run_interactive(
577585
.tool(PrometheusConnectTool::new(bg_manager.clone()))
578586
// RAG retrieval tools for compressed tool outputs
579587
.tool(RetrieveOutputTool::new())
580-
.tool(ListOutputsTool::new());
588+
.tool(ListOutputsTool::new())
589+
// Platform tools for project management
590+
.tool(ListOrganizationsTool::new())
591+
.tool(ListProjectsTool::new())
592+
.tool(SelectProjectTool::new())
593+
.tool(CurrentContextTool::new())
594+
.tool(OpenProviderSettingsTool::new())
595+
.tool(CheckProviderConnectionTool::new())
596+
.tool(ListDeploymentCapabilitiesTool::new())
597+
// Deployment tools for service management
598+
.tool(CreateDeploymentConfigTool::new())
599+
.tool(DeployServiceTool::new(project_path_buf.clone()))
600+
.tool(ListDeploymentConfigsTool::new())
601+
.tool(TriggerDeploymentTool::new())
602+
.tool(GetDeploymentStatusTool::new())
603+
.tool(ListDeploymentsTool::new())
604+
.tool(GetServiceLogsTool::new());
581605

582606
// Add tools based on mode
583607
if is_planning {
@@ -678,7 +702,23 @@ pub async fn run_interactive(
678702
.tool(PrometheusConnectTool::new(bg_manager.clone()))
679703
// RAG retrieval tools for compressed tool outputs
680704
.tool(RetrieveOutputTool::new())
681-
.tool(ListOutputsTool::new());
705+
.tool(ListOutputsTool::new())
706+
// Platform tools for project management
707+
.tool(ListOrganizationsTool::new())
708+
.tool(ListProjectsTool::new())
709+
.tool(SelectProjectTool::new())
710+
.tool(CurrentContextTool::new())
711+
.tool(OpenProviderSettingsTool::new())
712+
.tool(CheckProviderConnectionTool::new())
713+
.tool(ListDeploymentCapabilitiesTool::new())
714+
// Deployment tools for service management
715+
.tool(CreateDeploymentConfigTool::new())
716+
.tool(DeployServiceTool::new(project_path_buf.clone()))
717+
.tool(ListDeploymentConfigsTool::new())
718+
.tool(TriggerDeploymentTool::new())
719+
.tool(GetDeploymentStatusTool::new())
720+
.tool(ListDeploymentsTool::new())
721+
.tool(GetServiceLogsTool::new());
682722

683723
// Add tools based on mode
684724
if is_planning {
@@ -770,7 +810,23 @@ pub async fn run_interactive(
770810
.tool(PrometheusConnectTool::new(bg_manager.clone()))
771811
// RAG retrieval tools for compressed tool outputs
772812
.tool(RetrieveOutputTool::new())
773-
.tool(ListOutputsTool::new());
813+
.tool(ListOutputsTool::new())
814+
// Platform tools for project management
815+
.tool(ListOrganizationsTool::new())
816+
.tool(ListProjectsTool::new())
817+
.tool(SelectProjectTool::new())
818+
.tool(CurrentContextTool::new())
819+
.tool(OpenProviderSettingsTool::new())
820+
.tool(CheckProviderConnectionTool::new())
821+
.tool(ListDeploymentCapabilitiesTool::new())
822+
// Deployment tools for service management
823+
.tool(CreateDeploymentConfigTool::new())
824+
.tool(DeployServiceTool::new(project_path_buf.clone()))
825+
.tool(ListDeploymentConfigsTool::new())
826+
.tool(TriggerDeploymentTool::new())
827+
.tool(GetDeploymentStatusTool::new())
828+
.tool(ListDeploymentsTool::new())
829+
.tool(GetServiceLogsTool::new());
774830

775831
// Add tools based on mode
776832
if is_planning {
@@ -2210,7 +2266,23 @@ pub async fn run_query(
22102266
.tool(PrometheusConnectTool::new(bg_manager.clone()))
22112267
// RAG retrieval tools for compressed tool outputs
22122268
.tool(RetrieveOutputTool::new())
2213-
.tool(ListOutputsTool::new());
2269+
.tool(ListOutputsTool::new())
2270+
// Platform tools for project management
2271+
.tool(ListOrganizationsTool::new())
2272+
.tool(ListProjectsTool::new())
2273+
.tool(SelectProjectTool::new())
2274+
.tool(CurrentContextTool::new())
2275+
.tool(OpenProviderSettingsTool::new())
2276+
.tool(CheckProviderConnectionTool::new())
2277+
.tool(ListDeploymentCapabilitiesTool::new())
2278+
// Deployment tools for service management
2279+
.tool(CreateDeploymentConfigTool::new())
2280+
.tool(DeployServiceTool::new(project_path_buf.clone()))
2281+
.tool(ListDeploymentConfigsTool::new())
2282+
.tool(TriggerDeploymentTool::new())
2283+
.tool(GetDeploymentStatusTool::new())
2284+
.tool(ListDeploymentsTool::new())
2285+
.tool(GetServiceLogsTool::new());
22142286

22152287
// Add generation tools if this is a generation query
22162288
if is_generation {
@@ -2279,7 +2351,23 @@ pub async fn run_query(
22792351
.tool(PrometheusConnectTool::new(bg_manager.clone()))
22802352
// RAG retrieval tools for compressed tool outputs
22812353
.tool(RetrieveOutputTool::new())
2282-
.tool(ListOutputsTool::new());
2354+
.tool(ListOutputsTool::new())
2355+
// Platform tools for project management
2356+
.tool(ListOrganizationsTool::new())
2357+
.tool(ListProjectsTool::new())
2358+
.tool(SelectProjectTool::new())
2359+
.tool(CurrentContextTool::new())
2360+
.tool(OpenProviderSettingsTool::new())
2361+
.tool(CheckProviderConnectionTool::new())
2362+
.tool(ListDeploymentCapabilitiesTool::new())
2363+
// Deployment tools for service management
2364+
.tool(CreateDeploymentConfigTool::new())
2365+
.tool(DeployServiceTool::new(project_path_buf.clone()))
2366+
.tool(ListDeploymentConfigsTool::new())
2367+
.tool(TriggerDeploymentTool::new())
2368+
.tool(GetDeploymentStatusTool::new())
2369+
.tool(ListDeploymentsTool::new())
2370+
.tool(GetServiceLogsTool::new());
22832371

22842372
// Add generation tools if this is a generation query
22852373
if is_generation {
@@ -2337,7 +2425,23 @@ pub async fn run_query(
23372425
.tool(PrometheusConnectTool::new(bg_manager.clone()))
23382426
// RAG retrieval tools for compressed tool outputs
23392427
.tool(RetrieveOutputTool::new())
2340-
.tool(ListOutputsTool::new());
2428+
.tool(ListOutputsTool::new())
2429+
// Platform tools for project management
2430+
.tool(ListOrganizationsTool::new())
2431+
.tool(ListProjectsTool::new())
2432+
.tool(SelectProjectTool::new())
2433+
.tool(CurrentContextTool::new())
2434+
.tool(OpenProviderSettingsTool::new())
2435+
.tool(CheckProviderConnectionTool::new())
2436+
.tool(ListDeploymentCapabilitiesTool::new())
2437+
// Deployment tools for service management
2438+
.tool(CreateDeploymentConfigTool::new())
2439+
.tool(DeployServiceTool::new(project_path_buf.clone()))
2440+
.tool(ListDeploymentConfigsTool::new())
2441+
.tool(TriggerDeploymentTool::new())
2442+
.tool(GetDeploymentStatusTool::new())
2443+
.tool(ListDeploymentsTool::new())
2444+
.tool(GetServiceLogsTool::new());
23412445

23422446
// Add generation tools if this is a generation query
23432447
if is_generation {

src/agent/prompts/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ Just identify → explain → fix → proceed.
169169
/// Thinking guidelines - prevent "oops" and self-doubt patterns
170170
const THINKING_GUIDELINES: &str = r#"
171171
<thinking_guidelines>
172-
- Plan briefly (2-3 sentences), then execute
172+
- Do NOT narrate what you're about to do (e.g., "I'll call X tool" or "The user wants Y so I'll Z")
173+
- Just take action directly without announcing it
174+
- Plan internally, execute externally - users see results, not reasoning
173175
- Do NOT second-guess yourself with phrases like "oops", "I should have", or "I made a mistake"
174176
- If you made an error, fix it without self-deprecation - just fix it
175177
- Show confidence in your actions

src/agent/session/mod.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub use providers::{get_available_models, get_configured_providers, prompt_api_k
2020

2121
use crate::agent::commands::TokenUsage;
2222
use crate::agent::{AgentResult, ProviderType};
23+
use crate::platform::PlatformSession;
2324
use colored::Colorize;
2425
use std::io;
2526
use std::path::Path;
@@ -35,6 +36,8 @@ pub struct ChatSession {
3536
pub plan_mode: PlanMode,
3637
/// Session loaded via /resume command, to be processed by main loop
3738
pub pending_resume: Option<crate::agent::persistence::ConversationRecord>,
39+
/// Platform session state (selected project/org context)
40+
pub platform_session: PlatformSession,
3841
}
3942

4043
impl ChatSession {
@@ -45,6 +48,9 @@ impl ChatSession {
4548
ProviderType::Bedrock => "global.anthropic.claude-sonnet-4-20250514-v1:0".to_string(),
4649
};
4750

51+
// Load platform session from disk (returns default if not exists)
52+
let platform_session = PlatformSession::load().unwrap_or_default();
53+
4854
Self {
4955
provider,
5056
model: model.unwrap_or(default_model),
@@ -53,6 +59,18 @@ impl ChatSession {
5359
token_usage: TokenUsage::new(),
5460
plan_mode: PlanMode::default(),
5561
pending_resume: None,
62+
platform_session,
63+
}
64+
}
65+
66+
/// Update the platform session and save to disk
67+
pub fn update_platform_session(&mut self, session: PlatformSession) {
68+
self.platform_session = session;
69+
if let Err(e) = self.platform_session.save() {
70+
eprintln!(
71+
"{}",
72+
format!("Warning: Failed to save platform session: {}", e).yellow()
73+
);
5674
}
5775
}
5876

@@ -242,8 +260,18 @@ impl ChatSession {
242260
pub fn read_input(&self) -> io::Result<crate::agent::ui::input::InputResult> {
243261
use crate::agent::ui::input::read_input_with_file_picker;
244262

263+
// Build prompt with platform context if project is selected
264+
let prompt = if self.platform_session.is_project_selected() {
265+
format!(
266+
"{} >",
267+
self.platform_session.display_context()
268+
)
269+
} else {
270+
">".to_string()
271+
};
272+
245273
Ok(read_input_with_file_picker(
246-
">",
274+
&prompt,
247275
&self.project_path,
248276
self.plan_mode.is_planning(),
249277
))

src/agent/session/ui.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,39 @@ pub fn print_banner(session: &ChatSession) {
203203
);
204204
println!(" {}", "Your AI-powered code analysis assistant".dimmed());
205205

206+
// Show platform context (selected project/organization)
207+
if session.platform_session.is_project_selected() {
208+
println!(
209+
" {} {}: {}/{}",
210+
"📦",
211+
"Project".white(),
212+
session
213+
.platform_session
214+
.org_name
215+
.as_deref()
216+
.unwrap_or("?")
217+
.cyan(),
218+
session
219+
.platform_session
220+
.project_name
221+
.as_deref()
222+
.unwrap_or("?")
223+
.cyan()
224+
);
225+
} else {
226+
println!(
227+
" {} {} {}",
228+
"📦",
229+
"Project:".white(),
230+
"(none selected)".dimmed()
231+
);
232+
println!(
233+
" {} {}",
234+
"→".cyan(),
235+
"sync-ctl org list".dimmed()
236+
);
237+
}
238+
206239
// Check for incomplete plans and show a hint
207240
let incomplete_plans = find_incomplete_plans(&session.project_path);
208241
if !incomplete_plans.is_empty() {

0 commit comments

Comments
 (0)