└── main.py /main.py: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | func askQuestion(_ prompt: String) -> String { 4 | print(prompt, terminator: " ") 5 | return readLine() ?? "" 6 | } 7 | 8 | let initialQuery = askQuestion("What would you like to research?") 9 | 10 | let breadth = Int(askQuestion("Enter research breadth (2-10, default 4):")) ?? 4 11 | let depth = Int(askQuestion("Enter research depth (1-5, default 2):")) ?? 2 12 | 13 | print("Creating research plan...") 14 | let followUpQuestions = ["Why is this topic important?", "What are the key challenges?"] 15 | var answers: [String] = [] 16 | 17 | for question in followUpQuestions { 18 | answers.append(askQuestion(question)) 19 | } 20 | 21 | var combinedQuery = "Initial Query: \(initialQuery)\n" 22 | for (index, question) in followUpQuestions.enumerated() { 23 | combinedQuery += "Q: \(question)\nA: \(answers[index])\n" 24 | } 25 | 26 | print("Researching your topic...") 27 | let learnings = ["Fact 1", "Fact 2"] 28 | let visitedUrls = ["https://example.com"] 29 | 30 | let report = "\nLearnings:\n\(learnings.joined(separator: "\n"))\n\nVisited URLs:\n\(visitedUrls.joined(separator: "\n"))\n" 31 | let filePath = FileManager.default.currentDirectoryPath + "/output.md" 32 | 33 | do { 34 | try report.write(toFile: filePath, atomically: true, encoding: .utf8) 35 | print("Report has been saved to output.md") 36 | } catch { 37 | print("Failed to save report.") 38 | } 39 | --------------------------------------------------------------------------------