Skip to content
Open
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
4 changes: 2 additions & 2 deletions freewrite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"freewrite/Preview Content\"";
DEVELOPMENT_TEAM = 2UDAY4J48G;
DEVELOPMENT_TEAM = 8Y3ZVN9AH6;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -444,7 +444,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"freewrite/Preview Content\"";
DEVELOPMENT_TEAM = 2UDAY4J48G;
DEVELOPMENT_TEAM = 8Y3ZVN9AH6;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
1,308 changes: 0 additions & 1,308 deletions freewrite/ContentView.swift

This file was deleted.

14 changes: 14 additions & 0 deletions freewrite/Helpers/GetLineHeight.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// GetLineHeight.swift
// freewrite
//
// Created by Gaspar Dolcemascolo on 18-04-25.
//

import Foundation
import AppKit

// Helper function to calculate line height
func getLineHeight(font: NSFont) -> CGFloat {
return font.ascender - font.descender + font.leading
}
39 changes: 39 additions & 0 deletions freewrite/Helpers/NSView+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// NSView+Extension.swift
// freewrite
//
// Created by Gaspar Dolcemascolo on 18-04-25.
//

import Foundation
import AppKit

// Add helper extension to find NSTextView
extension NSView {
func findTextView() -> NSView? {
if self is NSTextView {
return self
}
for subview in subviews {
if let textView = subview.findTextView() {
return textView
}
}
return nil
}
}

// Add helper extension for finding subviews of a specific type
extension NSView {
func findSubview<T: NSView>(ofType type: T.Type) -> T? {
if let typedSelf = self as? T {
return typedSelf
}
for subview in subviews {
if let found = subview.findSubview(ofType: type) {
return found
}
}
return nil
}
}
60 changes: 60 additions & 0 deletions freewrite/Managers/AIChatManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// AIChatManager.swift
// freewrite
//
// Created by Gaspar Dolcemascolo on 18-04-25.
//

import Foundation
import AppKit

final class AIChatManager {
static let shared: AIChatManager = AIChatManager()

// Add shared prompt constant
private let aiChatPrompt = """
below is my journal entry. wyt? talk through it with me like a friend. don't therpaize me and give me a whole breakdown, don't repeat my thoughts with headings. really take all of this, and tell me back stuff truly as if you're an old homie.

Keep it casual, dont say yo, help me make new connections i don't see, comfort, validate, challenge, all of it. dont be afraid to say a lot. format with markdown headings if needed.

do not just go through every single thing i say, and say it back to me. you need to proccess everythikng is say, make connections i don't see it, and deliver it all back to me as a story that makes me feel what you think i wanna feel. thats what the best therapists do.

ideally, you're style/tone should sound like the user themselves. it's as if the user is hearing their own tone but it should still feel different, because you have different things to say and don't just repeat back they say.

else, start by saying, "hey, thanks for showing me this. my thoughts:"

my entry:
"""

private let claudePrompt = """
Take a look at my journal entry below. I'd like you to analyze it and respond with deep insight that feels personal, not clinical.
Imagine you're not just a friend, but a mentor who truly gets both my tech background and my psychological patterns. I want you to uncover the deeper meaning and emotional undercurrents behind my scattered thoughts.
Keep it casual, dont say yo, help me make new connections i don't see, comfort, validate, challenge, all of it. dont be afraid to say a lot. format with markdown headings if needed.
Use vivid metaphors and powerful imagery to help me see what I'm really building. Organize your thoughts with meaningful headings that create a narrative journey through my ideas.
Don't just validate my thoughts - reframe them in a way that shows me what I'm really seeking beneath the surface. Go beyond the product concepts to the emotional core of what I'm trying to solve.
Be willing to be profound and philosophical without sounding like you're giving therapy. I want someone who can see the patterns I can't see myself and articulate them in a way that feels like an epiphany.
Start with 'hey, thanks for showing me this. my thoughts:' and then use markdown headings to structure your response.

Here's my journal entry:
"""

func openChatGPT(text: String) {
let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines)
let fullText = aiChatPrompt + "\n\n" + trimmedText

if let encodedText = fullText.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
let url = URL(string: "https://chat.openai.com/?m=" + encodedText) {
NSWorkspace.shared.open(url)
}
}

func openClaude(text: String) {
let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines)
let fullText = claudePrompt + "\n\n" + trimmedText

if let encodedText = fullText.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
let url = URL(string: "https://claude.ai/new?q=" + encodedText) {
NSWorkspace.shared.open(url)
}
}
}
Loading