Skip to content
Draft
8 changes: 6 additions & 2 deletions Packages/OsaurusCore/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelega
// the specific crash class this prevents.
MLXErrorRecovery.installGlobalHandler()

// Register in-tree document format adapters before any file-ingress
// path can run. Idempotent; safe if a future migration moves this.
DocumentAdaptersBootstrap.registerBuiltIns()

// Detect repeated startup crashes and enter safe mode if needed
LaunchGuard.checkOnLaunch()

Expand Down Expand Up @@ -175,7 +179,7 @@ public final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelega
#endif

// Initialize directory access early so security-scoped bookmark is active
let _ = DirectoryPickerService.shared
_ = DirectoryPickerService.shared

if LaunchGuard.isSafeMode {
NotificationService.shared.postSafeModeActive()
Expand Down Expand Up @@ -876,7 +880,7 @@ extension AppDelegate {
}

@objc private func handleServeCommand(_ note: Notification) {
var desiredPort: Int? = nil
var desiredPort: Int?
var exposeFlag: Bool = false
if let ui = note.userInfo {
if let p = ui["port"] as? Int {
Expand Down
19 changes: 12 additions & 7 deletions Packages/OsaurusCore/Folder/FolderTools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ enum FolderToolHelpers {
static func detectProjectType(_ url: URL) -> ProjectType {
let fm = FileManager.default
for projectType in ProjectType.allCases where projectType != .unknown {
for manifestFile in projectType.manifestFiles {
if fm.fileExists(atPath: url.appendingPathComponent(manifestFile).path) {
return projectType
}
let hasManifest = projectType.manifestFiles.contains { manifestFile in
fm.fileExists(atPath: url.appendingPathComponent(manifestFile).path)
}
if hasManifest {
return projectType
}
}
return .unknown
Expand Down Expand Up @@ -638,9 +639,10 @@ struct FileSearchTool: OsaurusTool {
if let pattern = filePattern {
let regex = pattern.replacingOccurrences(of: ".", with: "\\.")
.replacingOccurrences(of: "*", with: ".*")
if fileURL.lastPathComponent.range(of: "^\(regex)$", options: .regularExpression)
== nil
{
if fileURL.lastPathComponent.range(
of: "^\(regex)$",
options: .regularExpression
) == nil {
continue
}
}
Expand Down Expand Up @@ -1016,6 +1018,9 @@ enum FolderToolFactory {
FileWriteTool(rootPath: rootPath),
FileEditTool(rootPath: rootPath),
FileSearchTool(rootPath: rootPath),
ReadWorkbookTool(rootPath: rootPath),
ReadWorkbookCellTool(rootPath: rootPath),
WriteWorkbookTool(rootPath: rootPath),
]
}

Expand Down
Loading
Loading