Skip to content

Commit 36cb86d

Browse files
committed
Create MVP project
1 parent 17559d0 commit 36cb86d

File tree

12 files changed

+217
-177
lines changed

12 files changed

+217
-177
lines changed

Agni/Agni.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

Agni/Agni/Components/ResultView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ struct ResultView: View {
1515

1616
ScrollView {
1717
if selectedFormat == "markdown" {
18-
MarkdownView(content)
18+
// MarkdownView(content)
1919
} else {
2020
TextEditor(text: .constant(content))
2121
.font(.system(.body, design: .monospaced))
2222
}
2323
}
2424
}
2525
}
26-
}
26+
}

Agni/Agni/Models/CrawlMap.swift

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,48 @@ import AgniKit
33

44
/// A structure representing the results of a web crawl operation.
55
///
6-
/// `CrawlMap` contains information about the pages visited during crawling
7-
/// and their relationships to each other.
6+
/// The `CrawlMap` structure provides a structured representation of crawled web pages
7+
/// and their relationships. It contains information about pages visited during crawling
8+
/// and the links between them.
9+
///
10+
/// - Important: This structure is immutable and thread-safe.
11+
///
12+
/// - Note: The map is constructed from a `CrawlResponse` which contains the raw data
13+
/// from the crawling operation.
814
public struct CrawlMap {
9-
/// Unique identifier for the crawl job
15+
/// Unique identifier for the crawl job.
16+
///
17+
/// This identifier can be used to track or reference specific crawl operations.
1018
public let jobId: String
1119

12-
/// The root URL where crawling started
20+
/// The root URL where crawling started.
21+
///
22+
/// This URL serves as the entry point for the crawl operation and
23+
/// all other pages are discovered relative to this starting point.
1324
public let rootURL: URL
1425

15-
/// Collection of pages discovered during crawling
26+
/// Collection of pages discovered during crawling.
27+
///
28+
/// An array of `CrawlPage` objects representing each unique page
29+
/// that was successfully crawled.
1630
public let pages: [CrawlPage]
1731

18-
/// Collection of links between pages
32+
/// Collection of links between pages.
33+
///
34+
/// An array of `CrawlLink` objects representing the relationships
35+
/// between crawled pages.
1936
public let links: [CrawlLink]
2037

21-
/// Creates a new instance from an API response
38+
/// Creates a new instance from an API response.
39+
///
40+
/// - Parameter response: A `CrawlResponse` containing the raw crawl data.
41+
///
42+
/// - Note: This initializer transforms the raw response data into a more
43+
/// structured representation.
2244
public init(from response: CrawlResponse) {
2345
self.jobId = response.jobId
2446
self.rootURL = response.startUrl
25-
self.pages = response.pages.map { CrawlPage(from: $0) }
26-
self.links = response.links.map { CrawlLink(from: $0) }
47+
self.pages = response.pages
48+
self.links = response.links
2749
}
2850
}
Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
1-
/// A wrapper for UIDocumentPickerViewController to use with SwiftUI
2-
class DocumentPickerViewController: UIDocumentPickerViewController {
1+
import AppKit
2+
3+
/// A wrapper for NSOpenPanel to use with SwiftUI
4+
class DocumentPickerViewController: NSOpenPanel {
35
private let onPick: (URL) -> Void
46

57
init(supportedTypes: [String], onPick: @escaping (URL) -> Void) {
68
self.onPick = onPick
7-
super.init(forOpeningContentTypes: supportedTypes.map { UTType(tag: $0, tagClass: .filenameExtension, conformingTo: nil)! })
9+
super.init()
10+
self.allowedFileTypes = supportedTypes
811
self.delegate = self
912
}
1013

1114
required init?(coder: NSCoder) {
1215
fatalError("init(coder:) has not been implemented")
1316
}
17+
18+
/// Presents the document picker to the user
19+
///
20+
/// This method displays the document picker interface to allow the user to select a file.
21+
///
22+
/// - Parameter parent: The parent view controller from which to present the document picker.
23+
func present(from parent: NSViewController) {
24+
self.beginSheetModal(for: parent.view.window!) { response in
25+
if response == .OK, let url = self.url {
26+
self.onPick(url)
27+
}
28+
}
29+
}
1430
}
1531

16-
extension DocumentPickerViewController: UIDocumentPickerDelegate {
17-
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
18-
guard let url = urls.first else { return }
19-
onPick(url)
32+
extension DocumentPickerViewController: NSOpenSavePanelDelegate {
33+
func panel(_ sender: NSOpenPanel, didChangeToDirectoryURL url: URL?) {
34+
// Handle directory change if needed
2035
}
21-
}
36+
}
Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
/// A view that displays the results of a batch scrape operation
2-
struct BatchResultsView: View {
3-
let results: [BatchScrapeResult]
4-
5-
var body: some View {
6-
List(results, id: \.metadata.sourceURL) { result in
7-
VStack(alignment: .leading) {
8-
Text(result.metadata.title)
9-
.font(.headline)
10-
11-
Text(result.metadata.sourceURL)
12-
.font(.caption)
13-
.foregroundColor(.secondary)
14-
15-
if let markdown = result.markdown {
16-
Text(markdown)
17-
.lineLimit(3)
18-
.padding(.top, 4)
19-
}
20-
}
21-
.padding(.vertical, 4)
22-
}
23-
}
24-
}
1+
import SwiftUI
2+
//
3+
///// A view that displays the results of a batch scrape operation
4+
//struct BatchResultsView: View {
5+
// let results: [BatchScrapeResult]
6+
//
7+
// var body: some View {
8+
// List(results, id: \.metadata.sourceURL) { result in
9+
// VStack(alignment: .leading) {
10+
// Text(result.metadata.title)
11+
// .font(.headline)
12+
//
13+
// Text(result.metadata.sourceURL)
14+
// .font(.caption)
15+
// .foregroundColor(.secondary)
16+
//
17+
// if let markdown = result.markdown {
18+
// Text(markdown)
19+
// .lineLimit(3)
20+
// .padding(.top, 4)
21+
// }
22+
// }
23+
// .padding(.vertical, 4)
24+
// }
25+
// }
26+
//}

0 commit comments

Comments
 (0)