From d722820fc8fc264bc0c0d20fbe99b9edbaa9b339 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 16 Oct 2026 14:49:26 +0200 Subject: [PATCH] chore: swiftformat drift + xcode 27 settings leftovers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Format-only pass over spikes, the gate prototype, and three app files (brace style, wrapping — no semantic change), plus the 4-line pbxproj alignment finishing the Xcode 27 settings pass (test-target deployment target parity with 8e70f69). [Generated by AI] --- Museion.xcodeproj/project.pbxproj | 8 +- Museion/ProfileBackup.swift | 3 +- Museion/ReadingPresenter.swift | 12 +- Museion/ReadingSurface.swift | 1 - MuseionTests/ProfileBackupTests.swift | 4 +- prototypes/GateUIPrototype.swift | 872 +++++++++--------- spike/apexhtml/Package.swift | 6 +- .../Sources/ApexHTMLSpike/ApexHTMLSpike.swift | 735 ++++++++------- spike/blocks/Package.swift | 6 +- .../Sources/BlocksSpike/BlockModel.swift | 142 +-- .../blocks/Sources/BlocksSpike/SpikeApp.swift | 614 ++++++------ spike/codeedit/Package.swift | 14 +- .../Sources/CodeEditSpike/SpikeApp.swift | 655 ++++++------- spike/textkit2/Package.swift | 6 +- .../Sources/TextKit2Spike/EditorPane.swift | 140 +-- .../TextKit2Spike/ProsePresenter.swift | 224 ++--- .../Sources/TextKit2Spike/SpikeApp.swift | 259 +++--- 17 files changed, 1910 insertions(+), 1791 deletions(-) diff --git a/Museion.xcodeproj/project.pbxproj b/Museion.xcodeproj/project.pbxproj index eaf92a6..0963ca4 100644 --- a/Museion.xcodeproj/project.pbxproj +++ b/Museion.xcodeproj/project.pbxproj @@ -331,7 +331,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 26.5; + MACOSX_DEPLOYMENT_TARGET = 27.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -391,7 +391,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 26.5; + MACOSX_DEPLOYMENT_TARGET = 27.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; @@ -481,7 +481,7 @@ DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = 3M7APDAAC5; GENERATE_INFOPLIST_FILE = YES; - MACOSX_DEPLOYMENT_TARGET = 26.5; + MACOSX_DEPLOYMENT_TARGET = 27.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.babylondreams.MuseionTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -503,7 +503,7 @@ DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = 3M7APDAAC5; GENERATE_INFOPLIST_FILE = YES; - MACOSX_DEPLOYMENT_TARGET = 26.5; + MACOSX_DEPLOYMENT_TARGET = 27.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.babylondreams.MuseionTests; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Museion/ProfileBackup.swift b/Museion/ProfileBackup.swift index 1d9f82c..ef349fd 100644 --- a/Museion/ProfileBackup.swift +++ b/Museion/ProfileBackup.swift @@ -70,7 +70,8 @@ nonisolated enum ProfileBackup { // Age check against the newest existing snapshot (#15: skips record no // state; the normal age check governs retry). if let newest = sortedSnapshots(in: backupsRoot).first, - now.timeIntervalSince(newest.timestamp) < snapshotInterval { + now.timeIntervalSince(newest.timestamp) < snapshotInterval + { return .skippedFresh } diff --git a/Museion/ReadingPresenter.swift b/Museion/ReadingPresenter.swift index 4c7bb7c..d202cc8 100644 --- a/Museion/ReadingPresenter.swift +++ b/Museion/ReadingPresenter.swift @@ -176,12 +176,12 @@ nonisolated enum ReadingPresenter { /// the bundle without any config). static func styleSheet() -> String { #if DEBUG - let repoCSS = URL(fileURLWithPath: #filePath) // …/Museion/ReadingPresenter.swift - .deletingLastPathComponent() - .appendingPathComponent("Resources/reading.css") - if let live = try? String(contentsOf: repoCSS, encoding: .utf8), !live.isEmpty { - return live - } + let repoCSS = URL(fileURLWithPath: #filePath) // …/Museion/ReadingPresenter.swift + .deletingLastPathComponent() + .appendingPathComponent("Resources/reading.css") + if let live = try? String(contentsOf: repoCSS, encoding: .utf8), !live.isEmpty { + return live + } #endif return Bundle.main.path(forResource: "reading", ofType: "css").flatMap { try? String(contentsOf: URL(fileURLWithPath: $0), encoding: .utf8) diff --git a/Museion/ReadingSurface.swift b/Museion/ReadingSurface.swift index 19b79a9..4c00754 100644 --- a/Museion/ReadingSurface.swift +++ b/Museion/ReadingSurface.swift @@ -162,7 +162,6 @@ struct ReadingSurface: NSViewRepresentable { return blocks.first { $0.sourceRange.location >= caret }?.sourceLine } - // MARK: WKNavigationDelegate func webView(_ wv: WKWebView, didFinish _: WKNavigation!) { diff --git a/MuseionTests/ProfileBackupTests.swift b/MuseionTests/ProfileBackupTests.swift index 04464c7..357c4af 100644 --- a/MuseionTests/ProfileBackupTests.swift +++ b/MuseionTests/ProfileBackupTests.swift @@ -29,13 +29,13 @@ func makeProfileFixture(at root: String) -> String { for dir in ["skills/serif-writing", "logs", "cache", "sessions/xyz/cache"] { try? fileManager.createDirectory( atPath: (profile as NSString).appendingPathComponent(dir), - withIntermediateDirectories: true + withIntermediateDirectories: true, ) } func write(_ text: String, _ rel: String) { try? text.write( toFile: (profile as NSString).appendingPathComponent(rel), - atomically: true, encoding: .utf8 + atomically: true, encoding: .utf8, ) } write("{\"token\": \"secret\"}", "auth.json") diff --git a/prototypes/GateUIPrototype.swift b/prototypes/GateUIPrototype.swift index ece5540..3853964 100644 --- a/prototypes/GateUIPrototype.swift +++ b/prototypes/GateUIPrototype.swift @@ -11,522 +11,534 @@ import SwiftUI // MARK: - Tokens (from ref/Web-Prototype/museion-workspace.html) -enum Tok { - static let bg = Color(hex: 0xFAFAF7) - static let surface = Color(hex: 0xFFFFFF) - static let fg = Color(hex: 0x1A1916) - static let muted = Color(hex: 0x6B6964) - static let border = Color(hex: 0xE8E5DF) - static let accent = Color(hex: 0xC96442) - static let fgSoft = Color(hex: 0x1A1916).opacity(0.06) - static let accentSoft = Color(hex: 0xC96442).opacity(0.14) - static func display(_ size: CGFloat, _ weight: Font.Weight = .regular) -> Font { - .custom("Iowan Old Style", size: size).weight(weight) - } - static func mono(_ size: CGFloat) -> Font { - .system(size: size, design: .monospaced) - } +enum Tok { + static let bg = Color(hex: 0xFAFAF7) + static let surface = Color(hex: 0xFFFFFF) + static let fg = Color(hex: 0x1A1916) + static let muted = Color(hex: 0x6B6964) + static let border = Color(hex: 0xE8E5DF) + static let accent = Color(hex: 0xC96442) + static let fgSoft = Color(hex: 0x1A1916).opacity(0.06) + static let accentSoft = Color(hex: 0xC96442).opacity(0.14) + + static func display(_ size: CGFloat, _ weight: Font.Weight = .regular) -> Font { + .custom("Iowan Old Style", size: size).weight(weight) + } + + static func mono(_ size: CGFloat) -> Font { + .system(size: size, design: .monospaced) + } } extension Color { - init(hex: UInt32) { - self.init(.sRGB, - red: Double((hex >> 16) & 0xFF) / 255, - green: Double((hex >> 8) & 0xFF) / 255, - blue: Double(hex & 0xFF) / 255) - } + init(hex: UInt32) { + self.init(.sRGB, + red: Double((hex >> 16) & 0xFF) / 255, + green: Double((hex >> 8) & 0xFF) / 255, + blue: Double(hex & 0xFF) / 255) + } } // MARK: - Mock state -final class GateModel: ObservableObject { - enum Phase: Equatable { case checking, passed, failed } - @Published var phase: Phase = .checking - @Published var firstRun = true - @Published var nextPass = false // outcome of the NEXT check (scenario control) - let version = "0.42.1" - private var token = 0 - func check() { - token += 1 - let myToken = token - phase = .checking - DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) { [weak self] in - guard let self, self.token == myToken else { return } - self.phase = self.nextPass ? .passed : .failed - } - } +final class GateModel: ObservableObject { + enum Phase: Equatable { case checking, passed, failed } + @Published var phase: Phase = .checking + @Published var firstRun = true + @Published var nextPass = false // outcome of the NEXT check (scenario control) + let version = "0.42.1" + private var token = 0 + + func check() { + token += 1 + let myToken = token + phase = .checking + DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) { [weak self] in + guard let self, token == myToken else { return } + phase = nextPass ? .passed : .failed + } + } } // MARK: - Shared pieces + struct EnginePill: View { - @EnvironmentObject var model: GateModel + @EnvironmentObject var model: GateModel - var body: some View { - HStack(spacing: 7) { - Circle() - .fill(dotColor) - .frame(width: 7, height: 7) - .modifier(Pulse(active: model.phase == .checking)) - Text("Hermes") - .font(Tok.mono(11)) - .foregroundStyle(Tok.fg) - if model.phase == .passed { - Text(model.version) - .font(Tok.mono(11)) - .foregroundStyle(Tok.muted) - } - } - .padding(.horizontal, 10) - .frame(minHeight: 30) - .background(Tok.surface, in: RoundedRectangle(cornerRadius: 10)) - .overlay( - RoundedRectangle(cornerRadius: 10) - .strokeBorder(model.phase == .failed ? Tok.accent : Tok.border, lineWidth: 1) - ) - } + var body: some View { + HStack(spacing: 7) { + Circle() + .fill(dotColor) + .frame(width: 7, height: 7) + .modifier(Pulse(active: model.phase == .checking)) + Text("Hermes") + .font(Tok.mono(11)) + .foregroundStyle(Tok.fg) + if model.phase == .passed { + Text(model.version) + .font(Tok.mono(11)) + .foregroundStyle(Tok.muted) + } + } + .padding(.horizontal, 10) + .frame(minHeight: 30) + .background(Tok.surface, in: RoundedRectangle(cornerRadius: 10)) + .overlay( + RoundedRectangle(cornerRadius: 10) + .strokeBorder(model.phase == .failed ? Tok.accent : Tok.border, lineWidth: 1), + ) + } - private var dotColor: Color { - switch model.phase { - case .checking: Tok.accent - case .passed: Tok.fg - case .failed: Tok.accent - } - } + private var dotColor: Color { + switch model.phase { + case .checking: Tok.accent + case .passed: Tok.fg + case .failed: Tok.accent + } + } } struct Pulse: ViewModifier { - let active: Bool - func body(content: Content) -> some View { - if active { - content.opacity(0.35).animation( - Animation.easeInOut(duration: 0.55).repeatForever(autoreverses: true), - value: active) - } else { - content - } - } + let active: Bool + func body(content: Content) -> some View { + if active { + content.opacity(0.35).animation( + Animation.easeInOut(duration: 0.55).repeatForever(autoreverses: true), + value: active, + ) + } else { + content + } + } } /// Placeholder install steps — the real copy is a graduated ticket, not this one. struct InstallSteps: View { - var numbered = true + var numbered = true - var body: some View { - VStack(alignment: .leading, spacing: 7) { - ForEach(Array(steps.enumerated()), id: \.offset) { idx, step in - HStack(alignment: .top, spacing: 8) { - if numbered { - Text("\(idx + 1).").font(Tok.mono(11)).foregroundStyle(Tok.muted) - } - Text(step) - .font(.system(size: 12)) - .foregroundStyle(Tok.fg) - } - } - } - .frame(maxWidth: .infinity, alignment: .leading) - .padding(12) - .background(Tok.bg, in: RoundedRectangle(cornerRadius: 10)) - .overlay(RoundedRectangle(cornerRadius: 10).strokeBorder(Tok.border)) - } + var body: some View { + VStack(alignment: .leading, spacing: 7) { + ForEach(Array(steps.enumerated()), id: \.offset) { idx, step in + HStack(alignment: .top, spacing: 8) { + if numbered { + Text("\(idx + 1).").font(Tok.mono(11)).foregroundStyle(Tok.muted) + } + Text(step) + .font(.system(size: 12)) + .foregroundStyle(Tok.fg) + } + } + } + .frame(maxWidth: .infinity, alignment: .leading) + .padding(12) + .background(Tok.bg, in: RoundedRectangle(cornerRadius: 10)) + .overlay(RoundedRectangle(cornerRadius: 10).strokeBorder(Tok.border)) + } - private var steps: [String] { - [ - "Install Hermes: brew install hermes", - "Check the install: hermes acp --check", - "Then click Re-check below.", - ] - } + private var steps: [String] { + [ + "Install Hermes: brew install hermes", + "Check the install: hermes acp --check", + "Then click Re-check below.", + ] + } } struct RecheckButton: View { - @EnvironmentObject var model: GateModel - var label = "Re-check" + @EnvironmentObject var model: GateModel + var label = "Re-check" - var body: some View { - Button { - model.check() - } label: { - HStack(spacing: 6) { - if model.phase == .checking { - ProgressView().controlSize(.small) - } - Text(model.phase == .checking ? "Checking…" : label) - } - .frame(maxWidth: 180) - } - .buttonStyle(.borderedProminent) - .tint(Tok.accent) - .disabled(model.phase == .checking) - } + var body: some View { + Button { + model.check() + } label: { + HStack(spacing: 6) { + if model.phase == .checking { + ProgressView().controlSize(.small) + } + Text(model.phase == .checking ? "Checking…" : label) + } + .frame(maxWidth: 180) + } + .buttonStyle(.borderedProminent) + .tint(Tok.accent) + .disabled(model.phase == .checking) + } } // MARK: - Mock workspace (context for the gate to sit over) + struct MockWorkspace: View { - @EnvironmentObject var model: GateModel - var banner: AnyView? = nil + @EnvironmentObject var model: GateModel + var banner: AnyView? - var body: some View { - VStack(spacing: 0) { - toolbar - if let banner { banner } - HStack(spacing: 0) { - rail - editor - } - } - .background(Tok.bg) - } + var body: some View { + VStack(spacing: 0) { + toolbar + if let banner { + banner + } + HStack(spacing: 0) { + rail + editor + } + } + .background(Tok.bg) + } - private var toolbar: some View { - HStack(spacing: 12) { - Text("M") - .font(Tok.display(17, .semibold)) - .foregroundStyle(Tok.accent) - .frame(width: 26, height: 26) - .background(Tok.accentSoft, in: RoundedRectangle(cornerRadius: 7)) - Text("On rereading Orwell") - .font(.system(size: 13)) - .foregroundStyle(Tok.muted) - .lineLimit(1) - Spacer() - EnginePill() - } - .padding(.horizontal, 14) - .frame(height: 48) - .background(Tok.surface) - .overlay(alignment: .bottom) { Divider().overlay(Tok.border) } - } + private var toolbar: some View { + HStack(spacing: 12) { + Text("M") + .font(Tok.display(17, .semibold)) + .foregroundStyle(Tok.accent) + .frame(width: 26, height: 26) + .background(Tok.accentSoft, in: RoundedRectangle(cornerRadius: 7)) + Text("On rereading Orwell") + .font(.system(size: 13)) + .foregroundStyle(Tok.muted) + .lineLimit(1) + Spacer() + EnginePill() + } + .padding(.horizontal, 14) + .frame(height: 48) + .background(Tok.surface) + .overlay(alignment: .bottom) { Divider().overlay(Tok.border) } + } - private var rail: some View { - VStack(spacing: 6) { - ForEach(["square.stack.3d.up", "bubble.left.and.bubble.right", "sparkles", "gearshape"], id: \.self) { icon in - Image(systemName: icon) - .font(.system(size: 15)) - .foregroundStyle(Tok.muted) - .frame(width: 40, height: 40) - } - Spacer() - } - .padding(.top, 10) - .frame(width: 56) - .background(Tok.bg) - .overlay(alignment: .trailing) { Divider().overlay(Tok.border) } - } + private var rail: some View { + VStack(spacing: 6) { + ForEach(["square.stack.3d.up", "bubble.left.and.bubble.right", "sparkles", "gearshape"], id: \.self) { icon in + Image(systemName: icon) + .font(.system(size: 15)) + .foregroundStyle(Tok.muted) + .frame(width: 40, height: 40) + } + Spacer() + } + .padding(.top, 10) + .frame(width: 56) + .background(Tok.bg) + .overlay(alignment: .trailing) { Divider().overlay(Tok.border) } + } - private var editor: some View { - ScrollView { - VStack(alignment: .leading, spacing: 18) { - Text("On rereading Orwell") - .font(Tok.display(26, .semibold)) - Text(previewText) - .font(.system(size: 14)) - .foregroundStyle(Tok.fg) - .lineSpacing(5) - } - .padding(36) - .frame(maxWidth: 720, alignment: .leading) - .frame(maxWidth: .infinity, alignment: .center) - } - } + private var editor: some View { + ScrollView { + VStack(alignment: .leading, spacing: 18) { + Text("On rereading Orwell") + .font(Tok.display(26, .semibold)) + Text(previewText) + .font(.system(size: 14)) + .foregroundStyle(Tok.fg) + .lineSpacing(5) + } + .padding(36) + .frame(maxWidth: 720, alignment: .leading) + .frame(maxWidth: .infinity, alignment: .center) + } + } - private var previewText: String { - String(repeating: "The essay argues itself into a corner by the third paragraph, and the prose knows it. Sentences shorten. Claims retreat. ", count: 6) - } + private var previewText: String { + String(repeating: "The essay argues itself into a corner by the third paragraph, and the prose knows it. Sentences shorten. Claims retreat. ", count: 6) + } } // MARK: - Variant A — blocking sheet, every launch + struct VariantA: View { - @EnvironmentObject var model: GateModel - @State private var showSteps = false + @EnvironmentObject var model: GateModel + @State private var showSteps = false - var body: some View { - ZStack { - MockWorkspace().disabled(true) - Rectangle().fill(Tok.fg.opacity(0.28)).ignoresSafeArea() - card - .padding(30) - .frame(maxWidth: 430) - .background(Tok.surface, in: RoundedRectangle(cornerRadius: 14)) - .overlay( - RoundedRectangle(cornerRadius: 14) - .strokeBorder(model.phase == .failed ? Tok.accent : Tok.border, lineWidth: 1) - ) - .shadow(radius: 24, y: 8) - } - } + var body: some View { + ZStack { + MockWorkspace().disabled(true) + Rectangle().fill(Tok.fg.opacity(0.28)).ignoresSafeArea() + card + .padding(30) + .frame(maxWidth: 430) + .background(Tok.surface, in: RoundedRectangle(cornerRadius: 14)) + .overlay( + RoundedRectangle(cornerRadius: 14) + .strokeBorder(model.phase == .failed ? Tok.accent : Tok.border, lineWidth: 1), + ) + .shadow(radius: 24, y: 8) + } + } - private var card: some View { - VStack(spacing: 14) { - Image(systemName: model.phase == .failed ? "exclamationmark.triangle.fill" : "checkmark.circle.fill") - .font(.system(size: 30)) - .foregroundStyle(model.phase == .failed ? Tok.accent : Tok.fg) - .opacity(model.phase == .checking ? 0 : 1) + private var card: some View { + VStack(spacing: 14) { + Image(systemName: model.phase == .failed ? "exclamationmark.triangle.fill" : "checkmark.circle.fill") + .font(.system(size: 30)) + .foregroundStyle(model.phase == .failed ? Tok.accent : Tok.fg) + .opacity(model.phase == .checking ? 0 : 1) - Text(title) - .font(Tok.display(19, .semibold)) - .multilineTextAlignment(.center) + Text(title) + .font(Tok.display(19, .semibold)) + .multilineTextAlignment(.center) - Text(subtitle) - .font(.system(size: 12.5)) - .foregroundStyle(Tok.muted) - .multilineTextAlignment(.center) - .fixedSize(horizontal: false, vertical: true) + Text(subtitle) + .font(.system(size: 12.5)) + .foregroundStyle(Tok.muted) + .multilineTextAlignment(.center) + .fixedSize(horizontal: false, vertical: true) - if model.phase == .failed { - if showSteps { - InstallSteps() - } else { - Button("How do I install Hermes?") { showSteps = true } - .buttonStyle(.link) - .font(.system(size: 12)) - } - } + if model.phase == .failed { + if showSteps { + InstallSteps() + } else { + Button("How do I install Hermes?") { showSteps = true } + .buttonStyle(.link) + .font(.system(size: 12)) + } + } - RecheckButton(label: model.phase == .passed ? "Re-check anyway" : "Re-check") + RecheckButton(label: model.phase == .passed ? "Re-check anyway" : "Re-check") - if model.phase == .passed { - Text("Checked on launch · Hermes \(model.version)") - .font(Tok.mono(10)) - .foregroundStyle(Tok.muted) - } - } - .padding(24) - } + if model.phase == .passed { + Text("Checked on launch · Hermes \(model.version)") + .font(Tok.mono(10)) + .foregroundStyle(Tok.muted) + } + } + .padding(24) + } - private var title: String { - switch model.phase { - case .checking: "Checking the engine…" - case .passed: "Engine ready" - case .failed: "Museion needs its engine" - } - } + private var title: String { + switch model.phase { + case .checking: "Checking the engine…" + case .passed: "Engine ready" + case .failed: "Museion needs its engine" + } + } - private var subtitle: String { - switch model.phase { - case .checking: "Running hermes acp --check." - case .passed: "Hermes \(model.version) answered the health check. The mentor is available." - case .failed: "The Hermes engine wasn't found or didn't answer. Museion can't run Passes or Sessions without it — the editor below stays available." - } - } + private var subtitle: String { + switch model.phase { + case .checking: "Running hermes acp --check." + case .passed: "Hermes \(model.version) answered the health check. The mentor is available." + case .failed: "The Hermes engine wasn't found or didn't answer. Museion can't run Passes or Sessions without it — the editor below stays available." + } + } } // MARK: - Variant B — gate window (first run), pill (repeat runs) -struct VariantB: View { - @EnvironmentObject var model: GateModel - var body: some View { - if model.firstRun { - GateWindow() - } else { - MockWorkspace() - } - } +struct VariantB: View { + @EnvironmentObject var model: GateModel + + var body: some View { + if model.firstRun { + GateWindow() + } else { + MockWorkspace() + } + } } private struct GateWindow: View { - @EnvironmentObject var model: GateModel + @EnvironmentObject var model: GateModel - var body: some View { - VStack(spacing: 0) { - Spacer(minLength: 40) - VStack(spacing: 16) { - Text("Museion") - .font(Tok.display(34, .semibold)) - Text("The Agentic Writing Environment") - .font(Tok.mono(11)) - .foregroundStyle(Tok.muted) - .textCase(.uppercase) + var body: some View { + VStack(spacing: 0) { + Spacer(minLength: 40) + VStack(spacing: 16) { + Text("Museion") + .font(Tok.display(34, .semibold)) + Text("The Agentic Writing Environment") + .font(Tok.mono(11)) + .foregroundStyle(Tok.muted) + .textCase(.uppercase) - Divider().frame(width: 60).overlay(Tok.border) + Divider().frame(width: 60).overlay(Tok.border) - status + status - if model.phase == .failed { - InstallSteps() - } - if model.phase == .passed { - Text("First run complete — the workspace opens next.") - .font(.system(size: 12)) - .foregroundStyle(Tok.muted) - } - } - .padding(34) - .frame(maxWidth: 470) - .background(Tok.surface, in: RoundedRectangle(cornerRadius: 14)) - .overlay(RoundedRectangle(cornerRadius: 14).strokeBorder(Tok.border)) - .shadow(radius: 18, y: 6) - Spacer(minLength: 40) - } - .frame(maxWidth: .infinity, maxHeight: .infinity) - .background(Tok.bg) - } + if model.phase == .failed { + InstallSteps() + } + if model.phase == .passed { + Text("First run complete — the workspace opens next.") + .font(.system(size: 12)) + .foregroundStyle(Tok.muted) + } + } + .padding(34) + .frame(maxWidth: 470) + .background(Tok.surface, in: RoundedRectangle(cornerRadius: 14)) + .overlay(RoundedRectangle(cornerRadius: 14).strokeBorder(Tok.border)) + .shadow(radius: 18, y: 6) + Spacer(minLength: 40) + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background(Tok.bg) + } - @ViewBuilder private var status: some View { - switch model.phase { - case .checking: - VStack(spacing: 10) { - ProgressView().controlSize(.regular) - Text("Looking for the Hermes engine…") - .font(.system(size: 13)) - .foregroundStyle(Tok.muted) - } - case .passed: - VStack(spacing: 10) { - Image(systemName: "checkmark.circle.fill") - .font(.system(size: 26)) - .foregroundStyle(Tok.fg) - Text("Engine ready — Hermes \(model.version)") - .font(Tok.display(15, .semibold)) - } - case .failed: - VStack(spacing: 10) { - Image(systemName: "exclamationmark.triangle.fill") - .font(.system(size: 26)) - .foregroundStyle(Tok.accent) - Text("Engine missing") - .font(Tok.display(15, .semibold)) - } - } - } + @ViewBuilder private var status: some View { + switch model.phase { + case .checking: + VStack(spacing: 10) { + ProgressView().controlSize(.regular) + Text("Looking for the Hermes engine…") + .font(.system(size: 13)) + .foregroundStyle(Tok.muted) + } + case .passed: + VStack(spacing: 10) { + Image(systemName: "checkmark.circle.fill") + .font(.system(size: 26)) + .foregroundStyle(Tok.fg) + Text("Engine ready — Hermes \(model.version)") + .font(Tok.display(15, .semibold)) + } + case .failed: + VStack(spacing: 10) { + Image(systemName: "exclamationmark.triangle.fill") + .font(.system(size: 26)) + .foregroundStyle(Tok.accent) + Text("Engine missing") + .font(Tok.display(15, .semibold)) + } + } + } } // MARK: - Variant C — inline banner, never blocks + struct VariantC: View { - @EnvironmentObject var model: GateModel + @EnvironmentObject var model: GateModel - var body: some View { - MockWorkspace(banner: AnyView(banner)) - } + var body: some View { + MockWorkspace(banner: AnyView(banner)) + } - @ViewBuilder private var banner: some View { - if model.phase == .failed { - failBanner - } else if model.firstRun, model.phase == .passed { - passBanner - } - } + @ViewBuilder private var banner: some View { + if model.phase == .failed { + failBanner + } else if model.firstRun, model.phase == .passed { + passBanner + } + } - private var failBanner: some View { - HStack(alignment: .top, spacing: 12) { - Image(systemName: "exclamationmark.triangle.fill") - .foregroundStyle(Tok.accent) - VStack(alignment: .leading, spacing: 8) { - (Text("Engine unavailable. ").font(.system(size: 12.5, weight: .semibold)) - + Text("Passes and Sessions need Hermes; the editor keeps working.") - .font(.system(size: 12.5)) - .foregroundStyle(Tok.muted)) - InstallSteps() - } - Spacer(minLength: 12) - RecheckButton() - } - .padding(14) - .background(Tok.accent.opacity(0.08)) - .overlay(alignment: .bottom) { Rectangle().fill(Tok.accent).frame(height: 1) } - } + private var failBanner: some View { + HStack(alignment: .top, spacing: 12) { + Image(systemName: "exclamationmark.triangle.fill") + .foregroundStyle(Tok.accent) + VStack(alignment: .leading, spacing: 8) { + Text("Engine unavailable. ").font(.system(size: 12.5, weight: .semibold)) + + Text("Passes and Sessions need Hermes; the editor keeps working.") + .font(.system(size: 12.5)) + .foregroundStyle(Tok.muted) + InstallSteps() + } + Spacer(minLength: 12) + RecheckButton() + } + .padding(14) + .background(Tok.accent.opacity(0.08)) + .overlay(alignment: .bottom) { Rectangle().fill(Tok.accent).frame(height: 1) } + } - private var passBanner: some View { - HStack(spacing: 8) { - Image(systemName: "checkmark.circle.fill").foregroundStyle(Tok.fg) - Text("Engine ready — Hermes \(model.version)") - .font(.system(size: 12.5)) - Spacer() - } - .padding(.horizontal, 14).padding(.vertical, 8) - .background(Tok.surface) - .overlay(alignment: .bottom) { Divider().overlay(Tok.border) } - } + private var passBanner: some View { + HStack(spacing: 8) { + Image(systemName: "checkmark.circle.fill").foregroundStyle(Tok.fg) + Text("Engine ready — Hermes \(model.version)") + .font(.system(size: 12.5)) + Spacer() + } + .padding(.horizontal, 14).padding(.vertical, 8) + .background(Tok.surface) + .overlay(alignment: .bottom) { Divider().overlay(Tok.border) } + } } // MARK: - Root + switcher + struct GatePrototypeRoot: View { - @StateObject private var model = GateModel() - @State private var variant = "A" - let variants: [(String, String)] = [ - ("A", "Blocking sheet"), - ("B", "Gate window"), - ("C", "Inline banner"), - ] + @StateObject private var model = GateModel() + @State private var variant = "A" + let variants: [(String, String)] = [ + ("A", "Blocking sheet"), + ("B", "Gate window"), + ("C", "Inline banner"), + ] - var body: some View { - ZStack(alignment: .bottom) { - currentView.environmentObject(model) - SwitcherBar(variant: $variant, model: model) - } - .frame(minWidth: 1100, minHeight: 680) - .background(Tok.bg) - .onAppear { model.check() } - } + var body: some View { + ZStack(alignment: .bottom) { + currentView.environmentObject(model) + SwitcherBar(variant: $variant, model: model) + } + .frame(minWidth: 1100, minHeight: 680) + .background(Tok.bg) + .onAppear { model.check() } + } - private var currentView: some View { - switch variant { - case "A": AnyView(VariantA()) - case "B": AnyView(VariantB()) - default: AnyView(VariantC()) - } - } + private var currentView: some View { + switch variant { + case "A": AnyView(VariantA()) + case "B": AnyView(VariantB()) + default: AnyView(VariantC()) + } + } } struct SwitcherBar: View { - @Binding var variant: String - @ObservedObject var model: GateModel + @Binding var variant: String + @ObservedObject var model: GateModel - var body: some View { - HStack(spacing: 14) { - arrow("chevron.left") { cycle(-1) } - .keyboardShortcut(.leftArrow, modifiers: []) - Text("\(variant) — \(variants.first { $0.0 == variant }?.1 ?? "")") - .font(Tok.mono(12)) - arrow("chevron.right") { cycle(1) } - .keyboardShortcut(.rightArrow, modifiers: []) + var body: some View { + HStack(spacing: 14) { + arrow("chevron.left") { cycle(-1) } + .keyboardShortcut(.leftArrow, modifiers: []) + Text("\(variant) — \(variants.first { $0.0 == variant }?.1 ?? "")") + .font(Tok.mono(12)) + arrow("chevron.right") { cycle(1) } + .keyboardShortcut(.rightArrow, modifiers: []) - Divider().frame(height: 16).overlay(Tok.border) - Toggle("First run", isOn: $model.firstRun) - .toggleStyle(.checkbox).font(Tok.mono(11)) - Toggle("Next check passes", isOn: $model.nextPass) - .toggleStyle(.checkbox).font(Tok.mono(11)) - Divider().frame(height: 16).overlay(Tok.border) - Text(phaseLabel) - .font(Tok.mono(11)).foregroundStyle(.tertiary) - } - .padding(.horizontal, 14).padding(.vertical, 9) - .background(Tok.fg, in: RoundedRectangle(cornerRadius: 10)) - .foregroundStyle(Tok.bg) - .padding(.bottom, 14) - .shadow(radius: 12, y: 4) - .onAppear { NSApp.appearance = NSAppearance(named: .aqua) } // prototype: force light so tokens read as designed - } + Divider().frame(height: 16).overlay(Tok.border) + Toggle("First run", isOn: $model.firstRun) + .toggleStyle(.checkbox).font(Tok.mono(11)) + Toggle("Next check passes", isOn: $model.nextPass) + .toggleStyle(.checkbox).font(Tok.mono(11)) + Divider().frame(height: 16).overlay(Tok.border) + Text(phaseLabel) + .font(Tok.mono(11)).foregroundStyle(.tertiary) + } + .padding(.horizontal, 14).padding(.vertical, 9) + .background(Tok.fg, in: RoundedRectangle(cornerRadius: 10)) + .foregroundStyle(Tok.bg) + .padding(.bottom, 14) + .shadow(radius: 12, y: 4) + .onAppear { NSApp.appearance = NSAppearance(named: .aqua) } // prototype: force light so tokens read as designed + } - private var variants: [(String, String)] { - [("A", "Blocking sheet"), ("B", "Gate window"), ("C", "Inline banner")] - } + private var variants: [(String, String)] { + [("A", "Blocking sheet"), ("B", "Gate window"), ("C", "Inline banner")] + } - private var phaseLabel: String { - switch model.phase { - case .checking: "checking" - case .passed: "passed · hermes \(model.version)" - case .failed: "failed" - } - } + private var phaseLabel: String { + switch model.phase { + case .checking: "checking" + case .passed: "passed · hermes \(model.version)" + case .failed: "failed" + } + } - private func cycle(_ dir: Int) { - let idx = variants.firstIndex { $0.0 == variant } ?? 0 - variant = variants[(idx + dir + variants.count) % variants.count].0 - } + private func cycle(_ dir: Int) { + let idx = variants.firstIndex { $0.0 == variant } ?? 0 + variant = variants[(idx + dir + variants.count) % variants.count].0 + } - private func arrow(_ system: String, action: @escaping () -> Void) -> some View { - Button(action: action) { - Image(systemName: system).font(.system(size: 11, weight: .semibold)) - } - .buttonStyle(.plain) - } + private func arrow(_ system: String, action: @escaping () -> Void) -> some View { + Button(action: action) { + Image(systemName: system).font(.system(size: 11, weight: .semibold)) + } + .buttonStyle(.plain) + } } @main struct GateUIPrototypeApp: App { - var body: some Scene { - WindowGroup { GatePrototypeRoot() } - } + var body: some Scene { + WindowGroup { GatePrototypeRoot() } + } } diff --git a/spike/apexhtml/Package.swift b/spike/apexhtml/Package.swift index eb53cd9..b256b45 100644 --- a/spike/apexhtml/Package.swift +++ b/spike/apexhtml/Package.swift @@ -2,7 +2,7 @@ import PackageDescription let package = Package( - name: "ApexHTMLSpike", - platforms: [.macOS(.v26)], - targets: [.executableTarget(name: "ApexHTMLSpike")] + name: "ApexHTMLSpike", + platforms: [.macOS(.v26)], + targets: [.executableTarget(name: "ApexHTMLSpike")], ) diff --git a/spike/apexhtml/Sources/ApexHTMLSpike/ApexHTMLSpike.swift b/spike/apexhtml/Sources/ApexHTMLSpike/ApexHTMLSpike.swift index 471f318..7b4c02f 100644 --- a/spike/apexhtml/Sources/ApexHTMLSpike/ApexHTMLSpike.swift +++ b/spike/apexhtml/Sources/ApexHTMLSpike/ApexHTMLSpike.swift @@ -8,399 +8,444 @@ import WebKit /// ponytail: sentinel pre-pass — apex passes HTML comments through verbatim, we stamp after. enum MarkdownChunker { - /// Prepend `` (N = 1-based source line) before every blank-line chunk. - nonisolated static func stamp(_ source: String) -> String { - let isBlank = { (l: Substring) in l.allSatisfy { $0 == " " || $0 == "\t" || $0 == "\r" } } - let lines = source.split(separator: "\n", omittingEmptySubsequences: false) - var out: [String] = [] - var i = 0 - while i < lines.count { - if isBlank(lines[i]) { i += 1; continue } - if !out.isEmpty { out.append("") } - out.append("") - while i < lines.count && !isBlank(lines[i]) { out.append(String(lines[i])); i += 1 } - } - return out.joined(separator: "\n") - } + /// Prepend `` (N = 1-based source line) before every blank-line chunk. + nonisolated static func stamp(_ source: String) -> String { + let isBlank = { (l: Substring) in l.allSatisfy { $0 == " " || $0 == "\t" || $0 == "\r" } } + let lines = source.split(separator: "\n", omittingEmptySubsequences: false) + var out: [String] = [] + var i = 0 + while i < lines.count { + if isBlank(lines[i]) { + i += 1; continue + } + if !out.isEmpty { + out.append("") + } + out.append("") + while i < lines.count, !isBlank(lines[i]) { + out.append(String(lines[i])); i += 1 + } + } + return out.joined(separator: "\n") + } } /// Rewrites `` into `data-source-line="N"` on the element that follows. enum HTMLStamper { - nonisolated static func stamp(_ html: String) -> String { - let re = try! NSRegularExpression(pattern: #"\s*\n<([a-zA-Z][a-zA-Z0-9]*)"#) - let ms = NSMutableString(string: html) - re.replaceMatches(in: ms, range: NSMakeRange(0, ms.length), withTemplate: "<$2 data-source-line=\"$1\"") - return ms as String - } + nonisolated static func stamp(_ html: String) -> String { + let re = try! NSRegularExpression(pattern: #"\s*\n<([a-zA-Z][a-zA-Z0-9]*)"#) + let ms = NSMutableString(string: html) + re.replaceMatches(in: ms, range: NSMakeRange(0, ms.length), withTemplate: "<$2 data-source-line=\"$1\"") + return ms as String + } } // MARK: - Apex runner enum Apex { - nonisolated static func binaryPath() -> String? { - if let env = ProcessInfo.processInfo.environment["APEX_PATH"] { return env } - for p in ["/opt/homebrew/bin/apex", "/usr/local/bin/apex"] where FileManager.default.isExecutableFile(atPath: p) { return p } - return nil - } + nonisolated static func binaryPath() -> String? { + if let env = ProcessInfo.processInfo.environment["APEX_PATH"] { + return env + } + for p in ["/opt/homebrew/bin/apex", "/usr/local/bin/apex"] where FileManager.default.isExecutableFile(atPath: p) { + return p + } + return nil + } - /// markdown → HTML fragment with images embedded (base64). Returns (html, milliseconds). - nonisolated static func render(_ markdown: String, baseDir: URL) throws -> (String, Double) { - guard let bin = binaryPath() else { throw CocoaError(.fileNoSuchFile) } - let t0 = DispatchTime.now() - let p = Process() - p.executableURL = URL(fileURLWithPath: bin) - // --no-mixed-lists: apex default merges an ordered list after a bullet list into one