Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ cli-framework = { git = "https://github.com/aroff/cli-framework", rev = "76a83e0
validator = { version = "0.20", features = ["derive"] }

# SQLite for vector index
rusqlite = { version = "0.40", features = ["bundled"] }
rusqlite = { version = "0.39", features = ["bundled"] }

# SHA256 hashing for file integrity
sha2 = "0.10"
Expand Down
1 change: 0 additions & 1 deletion crates/fastskill-cli/src/commands/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub async fn execute_serve(
);

println!("FastSkill HTTP server starting...");
println!(" Listening on: http://{}:{}", args.host, args.port);

let server =
fastskill_core::http::server::FastSkillServer::from_ref(&service, &args.host, args.port);
Expand Down
25 changes: 18 additions & 7 deletions crates/fastskill-core/src/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,24 @@ impl FastSkillServer {
pub async fn serve(self) -> Result<(), Box<dyn std::error::Error>> {
// Load project configuration (same as previous create_router logic)
let current_dir = env::current_dir()?;
let project_config = crate::core::load_project_config(&current_dir)
.map_err(|e| format!("Failed to load project config: {}", e))?;
let project_config = crate::core::load_project_config(&current_dir).ok();
if project_config.is_none() {
tracing::warn!(
"No skill-project.toml found in {} or any parent. \
Project-level features (manifest, skills install) will be unavailable. \
Run `fastskill init` in your project root to create one.",
current_dir.display()
);
}

let state = AppState::new(self.service.clone())?.with_project_config(
project_config.project_root,
project_config.project_file_path,
project_config.skills_directory,
);
let mut state = AppState::new(self.service.clone())?;
if let Some(cfg) = project_config {
state = state.with_project_config(
cfg.project_root,
cfg.project_file_path,
cfg.skills_directory,
);
}

// Build versioned v1 router with compression (applied to fastskill routes only)
let v1_router = Router::new()
Expand Down Expand Up @@ -484,6 +494,7 @@ impl FastSkillServer {
info!("Starting FastSkill HTTP server on {}", self.addr);

let addr_str = self.addr.to_string();
println!(" Listening on: http://{}", self.addr);
server.serve(&addr_str).await?;

Ok(())
Expand Down
46 changes: 46 additions & 0 deletions tests/cli/serve_e2e_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,52 @@ fn test_serve_health_endpoints() {
);
}

#[test]
fn test_serve_starts_without_skill_project_toml() {
if !can_bind_localhost_or_skip() {
return;
}

// Create a temp dir with NO skill-project.toml
let temp_dir = TempDir::new().unwrap();

let mut child = Command::new(env!("CARGO_BIN_EXE_fastskill"))
.args(&["serve", "--port", "18086"])
.current_dir(temp_dir.path())
.spawn()
.expect("Failed to start server");

assert!(
wait_for_port(18086, 5),
"Server failed to start on port 18086 without skill-project.toml"
);

let rt = tokio::runtime::Runtime::new().unwrap();
let client = reqwest::Client::new();

let health_status = rt.block_on(async {
client
.get("http://127.0.0.1:18086/healthz")
.send()
.await
.expect("GET /healthz")
.status()
});
assert_eq!(health_status, reqwest::StatusCode::OK, "/healthz should return 200 without skill-project.toml");

let ready_status = rt.block_on(async {
client
.get("http://127.0.0.1:18086/readyz")
.send()
.await
.expect("GET /readyz")
.status()
});
assert_eq!(ready_status, reqwest::StatusCode::OK, "/readyz should return 200 without skill-project.toml");

child.kill().expect("Failed to kill server");
}

#[test]
fn test_serve_port_already_in_use_error() {
if !can_bind_localhost_or_skip() {
Expand Down
Loading