Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ disabled_rules:
- identifier_name
- type_name
- trailing_comma
- multiple_closures_with_trailing_closure
- inclusive_language
- discouraged_optional_boolean

opt_in_rules:
- empty_count
Expand Down
2 changes: 1 addition & 1 deletion App/osaurusUITests/osaurusUITestsLaunchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import XCTest

final class osaurusUITestsLaunchTests: XCTestCase {

override class var runsForEachTargetApplicationUIConfiguration: Bool {
override static var runsForEachTargetApplicationUIConfiguration: Bool {
true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public struct MCPCommand: Command {
fputs("[MCP] Tools fetched successfully\n", stderr)
let tools: [MCP.Tool]
if let obj = try JSONSerialization.jsonObject(with: data) as? [String: Any],
let arr = obj["tools"] as? [[String: Any]]
{
let arr = obj["tools"] as? [[String: Any]] {
tools = arr.map { item in
let name = (item["name"] as? String) ?? ""
let description = (item["description"] as? String) ?? ""
Expand Down Expand Up @@ -103,7 +102,7 @@ public struct MCPCommand: Command {

let (data, response) = try await URLSession.shared.data(for: request)
guard let http = response as? HTTPURLResponse, http.statusCode == 200 else {
let message = String(decoding: data, as: UTF8.self)
let message = String(bytes: data, encoding: .utf8) ?? ""
return .init(
content: [
.text("HTTP \(String(describing: (response as? HTTPURLResponse)?.statusCode)): \(message)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ public struct PullCommand: Command {
let baseDir: URL
if let shared = UserDefaults(suiteName: "group.com.osaurus.shared"),
let storedPath = shared.string(forKey: "modelsDirectoryPath"),
!storedPath.isEmpty
{
!storedPath.isEmpty {
baseDir = URL(fileURLWithPath: storedPath, isDirectory: true)
} else {
baseDir = FileManager.default.homeDirectoryForCurrentUser
Expand Down Expand Up @@ -379,8 +378,7 @@ private final class CLIFileDownloader: NSObject, URLSessionDownloadDelegate, @un
guard let cont, let dest else { return }

if let http = downloadTask.response as? HTTPURLResponse,
!(200 ..< 300).contains(http.statusCode)
{
!(200 ..< 300).contains(http.statusCode) {
cont.resume(
throwing: URLError(
.badServerResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public struct RunCommand: Command {
if line.isEmpty { continue }
// Decode NDJSON event and print incremental content
if let data = line.data(using: .utf8),
let event = try? decoder.decode(NDJSONEvent.self, from: data)
{
let event = try? decoder.decode(NDJSONEvent.self, from: data) {
if let content = event.message?.content, !content.isEmpty {
assistantAggregate += content
print(content, terminator: "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct ServeCommand: Command {

public static func execute(args: [String]) async {
// Parse optional --port argument
var desiredPort: Int? = nil
var desiredPort: Int?
var expose: Bool = false
var assumeYes: Bool = false
var i = 0
Expand All @@ -39,7 +39,7 @@ public struct ServeCommand: Command {
let warning = """
WARNING: Exposing Osaurus to the local network will allow other devices on your LAN
to connect to your server. Make sure you trust your network and understand the risks.
Proceed with exposure? [y/N]:
Proceed with exposure? [y/N]:
"""
fputs(warning, stderr)
fflush(stderr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ public struct ShowCommand: Command {
if http.statusCode != 200 {
// Try to parse error message
if let errorResp = try? JSONDecoder().decode(ErrorResponse.self, from: data),
let message = errorResp.error?.message
{
let message = errorResp.error?.message {
fputs("Error: \(message)\n", stderr)
} else {
fputs("Failed to get model info (status \(http.statusCode))\n", stderr)
Expand Down
Loading
Loading