Files
Sprachmittler/Packages/SprachmittlerKit/Package.swift
T
schihei a3e544fbe4 feat(panel): close with Esc without a click and render Markdown
Esc: make the panel key when shown (closeWithEscape, default on) without activating the app; the source app stays frontmost and Replace still targets it. Handle Esc with SwiftUI's exit command, which also works from the popover and after clicking controls. Add TranslationPanel.canBecomeKey and amend ADR-009.\n\nMarkdown: add MarkdownPresentation in SprachmittlerText (Foundation inline parser plus a conservative block parser for headings, lists, quotes, fenced code and rules), a SwiftUI MarkdownTranslationView, and a renderMarkdown setting (default on). JSON, HTML and code sources are never rendered; only http/https links open; images become alt text; Copy and Replace keep the raw Markdown (ADR-021).\n\nVerified: make verify green; synthetic Esc closes the panel and closes an open language popover first; a live Markdown translation rendered heading, bold/italic, inline code, list, quote, code block and link; Copy returned the raw Markdown; Replace still changed the TextEdit selection with the panel key.
2026-11-26 15:26:30 +01:00

122 lines
4.9 KiB
Swift

// swift-tools-version: 6.0
// SprachmittlerKit — all testable logic for Sprachmittler. The macOS app target (App/) is generated by
// XcodeGen from project.yml and links the library products below. See docs/ARCHITECTURE.md §3–§4.
import PackageDescription
let strictSettings: [SwiftSetting] = [
.enableUpcomingFeature("ExistentialAny"),
]
let package = Package(
name: "SprachmittlerKit",
platforms: [.macOS(.v14)],
products: [
.library(name: "SprachmittlerCore", targets: ["SprachmittlerCore"]),
.library(name: "SprachmittlerCapture", targets: ["SprachmittlerCapture"]),
.library(name: "SprachmittlerText", targets: ["SprachmittlerText"]),
.executable(name: "sprachmittler-cli", targets: ["sprachmittler-cli"]),
],
dependencies: [
// CLI harness only (ARCHITECTURE §4). The app target must not depend on it.
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
],
targets: [
// Leaf modules — must not depend on each other or on any other package module.
// SprachmittlerText: pure Foundation + NaturalLanguage.
.target(name: "SprachmittlerText", swiftSettings: strictSettings),
// SprachmittlerOllama: the only URLSession user.
.target(name: "SprachmittlerOllama", swiftSettings: strictSettings),
// The only module that knows model names, prompts, language names and dialects (ADR-002, ADR-012).
.target(
name: "SprachmittlerEngines",
dependencies: ["SprachmittlerText", "SprachmittlerOllama"],
swiftSettings: strictSettings
),
// Composition through protocols; no model-specific branches.
.target(
name: "SprachmittlerCore",
dependencies: ["SprachmittlerText", "SprachmittlerOllama", "SprachmittlerEngines"],
swiftSettings: strictSettings
),
// The only module that imports Accessibility and touches NSPasteboard (ADR-004, ADR-005).
.target(name: "SprachmittlerCapture", dependencies: ["SprachmittlerCore"], swiftSettings: strictSettings),
// Evaluation harness — linked into the CLI only, never into the app.
.target(
name: "SprachmittlerEval",
dependencies: ["SprachmittlerCore", "SprachmittlerEngines", "SprachmittlerText", "SprachmittlerOllama"],
swiftSettings: strictSettings
),
// Fakes shared by tests (FakePasteboard, FakeClock, FakeOllamaTransport, FakeTextInserter, …).
.target(
name: "SprachmittlerTestSupport",
dependencies: ["SprachmittlerCore", "SprachmittlerCapture", "SprachmittlerOllama"],
swiftSettings: strictSettings
),
.executableTarget(
name: "sprachmittler-cli",
dependencies: [
"SprachmittlerCore",
"SprachmittlerEngines",
"SprachmittlerEval",
"SprachmittlerOllama",
"SprachmittlerText",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
swiftSettings: strictSettings
),
.testTarget(
name: "SprachmittlerTextTests",
dependencies: ["SprachmittlerText"],
resources: [.copy("Fixtures")]
),
.testTarget(
name: "SprachmittlerOllamaTests",
dependencies: ["SprachmittlerOllama", "SprachmittlerTestSupport"],
resources: [.copy("Fixtures")]
),
.testTarget(
name: "SprachmittlerEnginesTests",
dependencies: ["SprachmittlerEngines", "SprachmittlerOllama", "SprachmittlerText"],
resources: [.copy("Fixtures")]
),
.testTarget(
name: "SprachmittlerCoreTests",
dependencies: [
"SprachmittlerCore", "SprachmittlerEngines", "SprachmittlerOllama", "SprachmittlerText",
"SprachmittlerTestSupport",
]
),
.testTarget(
name: "SprachmittlerCaptureTests",
dependencies: ["SprachmittlerCapture", "SprachmittlerTestSupport"]
),
.testTarget(
name: "SprachmittlerEvalTests",
dependencies: [
"SprachmittlerEval", "SprachmittlerCore", "SprachmittlerEngines", "SprachmittlerText",
"SprachmittlerOllama", "SprachmittlerTestSupport",
]
),
.testTarget(
name: "SprachmittlerCLITests",
dependencies: [
"sprachmittler-cli",
"SprachmittlerCore",
"SprachmittlerEngines",
"SprachmittlerOllama",
"SprachmittlerTestSupport",
]
),
// Opt-in tests against a real local Ollama: SPRACHMITTLER_LIVE=1 swift test --filter SprachmittlerLiveTests
.testTarget(name: "SprachmittlerLiveTests", dependencies: ["SprachmittlerCore"]),
]
)