Skip to content

Commit 8315508

Browse files
committed
version 0.1.2; cargo fmt
1 parent b4acc7c commit 8315508

9 files changed

Lines changed: 47 additions & 31 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
22
name = "sofos"
3-
version = "0.1.0"
3+
version = "0.1.2"
44
edition = "2021"
55
authors = ["Alexander Alexandrov"]
6-
description = "An interactive AI coding assistant powered by Claude"
6+
description = "An interactive AI coding assistant powered by Claude/GPT"
77
license = "MIT"
88
repository = "https://github.com/alexylon/sofos-code"
99
keywords = ["cli", "ai", "coding-assistant", "repl"]

src/api/openai.rs

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl OpenAIClient {
146146
"parameters": input_schema
147147
}
148148
})),
149-
_ => None, // Web search isn't supported via OpenAI tools
149+
_ => None, // TODO: Add OpenAI web search
150150
})
151151
.collect();
152152

@@ -243,7 +243,7 @@ impl OpenAIClient {
243243
if !tools.is_empty() {
244244
body["tools"] = json!(tools);
245245
body["tool_choice"] = json!("auto");
246-
246+
247247
if std::env::var("SOFOS_DEBUG").is_ok() {
248248
eprintln!("\n=== OpenAI /responses Request ===");
249249
eprintln!("Sending {} tools to OpenAI", tools.len());
@@ -260,23 +260,27 @@ impl OpenAIClient {
260260
}
261261

262262
let url = format!("{}/responses", OPENAI_API_BASE);
263-
263+
264264
if std::env::var("SOFOS_DEBUG").is_ok() {
265265
eprintln!("\n=== OpenAI /responses Request Body ===");
266-
eprintln!("{}", serde_json::to_string_pretty(&body).unwrap_or_else(|_| "Failed to serialize".to_string()));
266+
eprintln!(
267+
"{}",
268+
serde_json::to_string_pretty(&body)
269+
.unwrap_or_else(|_| "Failed to serialize".to_string())
270+
);
267271
eprintln!("======================================\n");
268272
}
269-
273+
270274
let response = self.client.post(&url).json(&body).send().await?;
271275
let response = super::utils::check_response_status(response).await?;
272-
276+
273277
let response_text = response.text().await?;
274278
if std::env::var("SOFOS_DEBUG").is_ok() {
275279
eprintln!("\n=== OpenAI Raw Response ===");
276280
eprintln!("{}", response_text);
277281
eprintln!("===========================\n");
278282
}
279-
283+
280284
let parsed: OpenAIResponse = serde_json::from_str(&response_text)
281285
.map_err(|e| SofosError::Api(format!("Failed to parse OpenAI response: {}", e)))?;
282286

@@ -285,24 +289,27 @@ impl OpenAIClient {
285289
eprintln!("Model: {}", parsed.model);
286290
eprintln!("Output items count: {}", parsed.output.len());
287291
for (i, item) in parsed.output.iter().enumerate() {
288-
eprintln!(" Item {}: type={}, content_count={}, tool_calls={:?}",
289-
i,
290-
item.item_type,
292+
eprintln!(
293+
" Item {}: type={}, content_count={}, tool_calls={:?}",
294+
i,
295+
item.item_type,
291296
item.content.len(),
292297
item.tool_calls.as_ref().map(|tc| tc.len())
293298
);
294299
for (j, content) in item.content.iter().enumerate() {
295-
eprintln!(" Content {}: type={}, text_len={}",
296-
j,
297-
content.content_type,
300+
eprintln!(
301+
" Content {}: type={}, text_len={}",
302+
j,
303+
content.content_type,
298304
content.text.len()
299305
);
300306
}
301307
if let Some(ref tool_calls) = item.tool_calls {
302308
for (j, call) in tool_calls.iter().enumerate() {
303-
eprintln!(" Tool call {}: name={}, args_len={}",
304-
j,
305-
call.name,
309+
eprintln!(
310+
" Tool call {}: name={}, args_len={}",
311+
j,
312+
call.name,
306313
call.arguments.len()
307314
);
308315
}
@@ -316,7 +323,8 @@ impl OpenAIClient {
316323
match item.item_type.as_str() {
317324
"message" => {
318325
for content in item.content {
319-
if content.content_type == "output_text" && !content.text.trim().is_empty() {
326+
if content.content_type == "output_text" && !content.text.trim().is_empty()
327+
{
320328
content_blocks.push(ContentBlock::Text { text: content.text });
321329
}
322330
}
@@ -334,8 +342,9 @@ impl OpenAIClient {
334342
}
335343
}
336344
"function_call" => {
337-
if let (Some(name), Some(arguments), Some(call_id)) =
338-
(item.name, item.arguments, item.call_id) {
345+
if let (Some(name), Some(arguments), Some(call_id)) =
346+
(item.name, item.arguments, item.call_id)
347+
{
339348
let input = serde_json::from_str::<serde_json::Value>(&arguments)
340349
.unwrap_or_else(|_| json!({"raw_arguments": arguments}));
341350
content_blocks.push(ContentBlock::ToolUse {
@@ -359,7 +368,10 @@ impl OpenAIClient {
359368
}
360369

361370
if std::env::var("SOFOS_DEBUG").is_ok() {
362-
eprintln!("=== Converted to {} content blocks ===\n", content_blocks.len());
371+
eprintln!(
372+
"=== Converted to {} content blocks ===\n",
373+
content_blocks.len()
374+
);
363375
}
364376

365377
let usage = parsed.usage.unwrap_or_default();
@@ -400,7 +412,11 @@ fn build_response_input(request: &CreateMessageRequest) -> Vec<serde_json::Value
400412
MessageContentBlock::Text { text } => {
401413
input.push(json!({"role": msg.role, "content": text}));
402414
}
403-
MessageContentBlock::ToolUse { id, name, input: tool_input } => {
415+
MessageContentBlock::ToolUse {
416+
id,
417+
name,
418+
input: tool_input,
419+
} => {
404420
// Responses API requires function_call items to match with function_call_output
405421
input.push(json!({
406422
"type": "function_call",

src/history.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct SessionMetadata {
3939
#[derive(Debug, Serialize, Deserialize)]
4040
pub struct Session {
4141
pub id: String,
42-
/// Messages in API format (for continuing the conversation with Claude)
42+
/// Messages in API format (for continuing the conversation with AI)
4343
pub api_messages: Vec<Message>,
4444
/// Messages in display format (for reconstructing the original UI)
4545
#[serde(default, skip_serializing_if = "Vec::is_empty")]

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod syntax;
1212
mod tools;
1313
mod ui;
1414

15-
use api::{LlmClient, MorphClient, AnthropicClient, OpenAIClient};
15+
use api::{AnthropicClient, LlmClient, MorphClient, OpenAIClient};
1616
use clap::Parser;
1717
use cli::Cli;
1818
use colored::Colorize;

src/response_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use colored::Colorize;
99
use std::sync::atomic::{AtomicBool, Ordering};
1010
use std::sync::Arc;
1111

12-
/// Handles Claude's responses and manages tool execution iteration
12+
/// Handles AI's responses and manages tool execution iteration
1313
pub struct ResponseHandler {
1414
client: LlmClient,
1515
tool_executor: ToolExecutor,
@@ -400,7 +400,7 @@ impl ResponseHandler {
400400
content: "[System: Maximum tool iterations reached]".to_string(),
401401
});
402402

403-
// Let Claude respond to the interruption
403+
// Let AI respond to the interruption
404404
let request = self.build_request();
405405

406406
match self.client.create_message(request).await {

src/tools/filesystem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl FileSystemTool {
2323
/// Returns an error if the path attempts to escape the workspace
2424
fn validate_path(&self, path: &str) -> Result<PathBuf> {
2525
let path = path.trim();
26-
26+
2727
if Path::new(path).is_absolute() {
2828
return Err(SofosError::PathViolation(
2929
"Absolute paths are not allowed".to_string(),

src/tools/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn confirm_action(prompt: &str) -> Result<bool> {
2525
Ok(answer == "y" || answer == "yes")
2626
}
2727

28-
/// ToolExecutor handles execution of tool calls from Claude
28+
/// ToolExecutor handles execution of tool calls from AI
2929
#[derive(Clone)]
3030
pub struct ToolExecutor {
3131
fs_tool: FileSystemTool,

src/tools/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn morph_edit_file_tool() -> Tool {
207207
}
208208
}
209209

210-
/// Get all available tools for Claude API
210+
/// Get all available tools for Claude/GPT API
211211
pub fn get_tools() -> Vec<Tool> {
212212
vec![
213213
read_file_tool(),

0 commit comments

Comments
 (0)