-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.swift
More file actions
460 lines (449 loc) · 17.7 KB
/
Copy pathPackage.swift
File metadata and controls
460 lines (449 loc) · 17.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
// swift-tools-version: 6.3
import PackageDescription
// Platform-specific dependencies
// On Windows: use FlyingFox for HTTP server (polling-based, no NIO dependency)
// On macOS/Linux: use official SwiftNIO releases
var platformDependencies: [Package.Dependency] = []
var runtimePlatformDependencies: [Target.Dependency] = []
var lspDependencies: [Package.Dependency] = []
var lspTargetDependencies: [Target.Dependency] = []
var cliLspDependency: [Target.Dependency] = []
var compilerLLVMDependency: [Target.Dependency] = []
var mlxDependencies: [Package.Dependency] = []
var askMLXTargetDependencies: [Target.Dependency] = []
#if os(Windows)
// Windows-specific dependencies
// FlyingFox provides HTTP server and sockets without NIO (uses polling on Windows)
platformDependencies = [
// FlyingFox for HTTP server (includes FlyingSocks for socket support)
.package(url: "https://github.com/swhitty/FlyingFox.git", from: "0.21.0"),
// SwiftSoup for HTML/XML parsing (pure Swift, works on all platforms)
.package(url: "https://github.com/scinfu/SwiftSoup.git", from: "2.7.0"),
]
runtimePlatformDependencies = [
.product(name: "FlyingFox", package: "FlyingFox"),
.product(name: "FlyingSocks", package: "FlyingFox"),
.product(name: "SwiftSoup", package: "SwiftSoup"),
]
// LLVM/native compilation not available on Windows yet (requires LLVM installation)
// LSP not available on Windows yet - JSONRPC has issues
#else
// macOS and Linux dependencies
platformDependencies = [
// SwiftNIO for HTTP server and sockets (2.75.0+ for Swift 6 support)
.package(url: "https://github.com/apple/swift-nio.git", from: "2.75.0"),
// AsyncHTTPClient for outgoing HTTP requests
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.21.0"),
// FileMonitor for file system watching
.package(url: "https://github.com/KrisSimon/FileMonitor.git", from: "2.1.0"),
// LLVM C API bindings for type-safe IR generation (Issue #53)
// Swifty-LLVM requires Swift 6.2 and LLVM 20
.package(url: "https://github.com/hylo-lang/Swifty-LLVM.git", branch: "main"),
// SwiftSoup for HTML/XML parsing (pure Swift, works on all platforms)
.package(url: "https://github.com/scinfu/SwiftSoup.git", from: "2.7.0"),
]
runtimePlatformDependencies = [
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "NIOWebSocket", package: "swift-nio"),
.product(name: "NIOFoundationCompat", package: "swift-nio"),
.product(name: "AsyncHTTPClient", package: "async-http-client"),
.product(name: "FileMonitor", package: "FileMonitor"),
.product(name: "SwiftSoup", package: "SwiftSoup"),
]
// LSP dependencies (JSONRPC doesn't support Windows)
lspDependencies = [
.package(url: "https://github.com/ChimeHQ/LanguageServerProtocol", from: "0.14.0"),
]
lspTargetDependencies = [
.product(name: "LanguageServerProtocol", package: "LanguageServerProtocol"),
]
cliLspDependency = [
"AROLSP",
]
// LLVM C API for type-safe IR generation
compilerLLVMDependency = [
.product(name: "SwiftyLLVM", package: "Swifty-LLVM"),
]
#endif
// Issue #228 — SOLARO desktop app (macOS only). The product + target
// + test wiring is gated here so Linux/Windows builds don't trip on
// the AppKit/SwiftUI imports. See ADR-001 follow-up note about the
// SwiftCrossUI -> native-SwiftUI pivot.
var solaroProducts: [Product] = []
var solaroTargets: [Target] = []
#if os(macOS)
solaroProducts = [
.executable(
name: "SolaroApp",
targets: ["SOLARO"]
),
.executable(
name: "solaro",
targets: ["SOLAROLauncher"]
),
.executable(
name: "AROXPCService",
targets: ["AROXPCService"]
),
.library(
name: "AROXPCProtocol",
targets: ["AROXPCProtocol"]
),
]
solaroTargets = [
.executableTarget(
name: "SOLARO",
dependencies: [
"AROVersion",
"AROParser",
"ARORuntime",
// In-process `aro ask` for the editor's inline suggestion
// surfaces (ActionSuggester, AICompletionFallback). Links the
// LLM stack (MLX/llama) into the app so one shared, warm
// AskSession answers hover/autocomplete prompts instead of
// cold-starting an `aro ask` subprocess per call.
"AROAsk",
"AROXPCProtocol",
.product(name: "Logging", package: "swift-log"),
.product(name: "Yams", package: "Yams"),
// STTextView (TextKit 2 editor) for the code-editing pane —
// gives us a gutter, proper attributed-text editing, and
// a plugin surface for syntax highlighting + breakpoints.
.product(name: "STTextView", package: "STTextView"),
// SwiftTerm — ANSI terminal emulator for the bottom panel.
.product(name: "SwiftTerm", package: "SwiftTerm"),
],
path: "Sources/SOLARO",
// Docs aimed at engineers reading the source tree — neither
// is a runtime resource. Without the exclude SwiftPM warns
// on every clean build (#291).
exclude: [
"LICENSE-NOTICE.md",
"ARCHITECTURE.md",
"TROUBLESHOOTING.md",
]
),
.executableTarget(
name: "SOLAROLauncher",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
path: "Sources/SOLAROLauncher"
),
// Shared types used by both SOLARO and the XPC service to
// describe runtime events crossing the process boundary
// (#282 phase 3). Codable structs — kept tiny so the wire
// format stays stable.
.target(
name: "AROXPCProtocol",
dependencies: [],
path: "Sources/AROXPCProtocol"
),
// Out-of-process host for the ARO runtime. SOLARO launches
// it via NSXPCConnection, hands it a project root, and gets
// pause records / end notifications back across the
// boundary. Crashes don't take SOLARO down with them.
.executableTarget(
name: "AROXPCService",
dependencies: [
"AROVersion",
"AROParser",
"ARORuntime",
"AROXPCProtocol",
],
path: "Sources/AROXPCService"
),
.testTarget(
name: "SOLAROTests",
dependencies: ["SOLARO"],
path: "Tests/SOLAROTests"
),
]
#endif
// MLX dependencies — macOS Apple Silicon only (Linux uses llama.cpp/CUDA)
#if os(macOS)
mlxDependencies = [
.package(url: "https://github.com/ml-explore/mlx-swift-lm.git", branch: "main"),
// 1.3.0+ avoids a Swift 6.2.1 SIL OwnershipModelEliminator crash that
// 0.1.8 triggered while compiling Tokenizers' LeavesWithCommonPrefixIterator.
.package(url: "https://github.com/huggingface/swift-transformers.git", from: "1.3.0"),
]
askMLXTargetDependencies = [
.product(name: "MLXLLM", package: "mlx-swift-lm"),
.product(name: "MLXLMCommon", package: "mlx-swift-lm"),
.product(name: "Transformers", package: "swift-transformers"),
]
#endif
// LLVM linker settings - pkg-config needs help finding LLVM
#if os(macOS)
import Foundation
let llvmPath = ProcessInfo.processInfo.environment["LLVM_PATH"] ?? "/opt/homebrew/opt/llvm@20"
let llvmLibPath = "\(llvmPath)/lib"
let llvmIncludePath = "\(llvmPath)/include"
let llvmLinkerSettings: [LinkerSetting] = [
.unsafeFlags(["-L\(llvmLibPath)", "-lLLVM-20"]),
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", llvmLibPath]),
]
#elseif os(Linux)
import Foundation
let llvmPath = ProcessInfo.processInfo.environment["LLVM_PATH"] ?? "/usr/lib/llvm-20"
let llvmLibPath = "\(llvmPath)/lib"
let llvmIncludePath = "\(llvmPath)/include"
let llvmLinkerSettings: [LinkerSetting] = [
.unsafeFlags(["-L\(llvmLibPath)", "-lLLVM-20"]),
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", llvmLibPath]),
]
#else
// Windows and other platforms: LLVM not available
let llvmPath = ""
let llvmLibPath = ""
let llvmIncludePath = ""
let llvmLinkerSettings: [LinkerSetting] = []
#endif
// Issue #231 — C bridge target exposing llvm-c/DebugInfo.h to Swift so
// AROCompiler can emit DWARF metadata. Swifty-LLVM's bundled `llvmc`
// module only covers Core.h.
let arocDebugInfoCSettings: [CSetting] = [
.headerSearchPath("include"),
.unsafeFlags(["-I\(llvmIncludePath)"], .when(platforms: [.macOS, .linux])),
]
let package = Package(
name: "AROParser",
platforms: [
.macOS(.v15),
.iOS(.v18)
],
products: [
.library(
name: "AROParser",
targets: ["AROParser"]
),
// ARORuntime is now a static library that exports C symbols via @_cdecl
// for use by compiled ARO binaries (previously this was in AROCRuntime)
.library(
name: "ARORuntime",
type: .static,
targets: ["ARORuntime"]
),
.library(
name: "AROCompiler",
targets: ["AROCompiler"]
),
.library(
name: "AROPackageManager",
targets: ["AROPackageManager"]
),
.executable(
name: "aro",
targets: ["AROCLI"]
),
// SOLARO products (macOS only) are appended via `solaroProducts`
// below — see the top of this file for the gated definition.
] + solaroProducts,
dependencies: platformDependencies + lspDependencies + mlxDependencies + [
// Swift Argument Parser for CLI
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0"),
// Yams for YAML parsing (OpenAPI contracts)
.package(url: "https://github.com/jpsim/Yams.git", from: "6.2.0"),
// Swift Crypto for cryptographic operations (SHA256, etc.)
.package(url: "https://github.com/apple/swift-crypto.git", from: "4.0.0"),
// swift-collections — Deque (#318) for O(1) FIFO eviction
// in BoundedSet. Already present transitively via swift-nio;
// declared here so ARORuntime can take an explicit `.product`
// dependency.
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"),
// LineNoise (REPL line editing: arrow keys, history) is vendored as a
// local `LineNoise` target under Sources/LineNoise — a fork of
// andybest/linenoise-swift patched with multi-line refresh so long
// wrapped input renders correctly (the upstream port is single-line
// only and duplicates rows once a line wraps).
// Swift Log for structured logging
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.0"),
// STTextView — TextKit 2 editor used by SOLARO's center pane.
// Pinned to the minor while the API is still settling.
.package(url: "https://github.com/krzyzanowskim/STTextView.git", from: "2.3.10"),
// SwiftTerm — real ANSI terminal emulator for the bottom
// panel's Terminal tab (#244).
.package(url: "https://github.com/migueldeicaza/SwiftTerm.git", from: "1.2.0"),
],
targets: {
// AROAsk dependencies (non-Windows)
#if !os(Windows)
let askDependency: [Target.Dependency] = ["AROAsk"]
#else
let askDependency: [Target.Dependency] = []
#endif
// Core targets available on all platforms
var targets: [Target] = [
// Version information library
.target(
name: "AROVersion",
path: "Sources/AROVersion"
),
// Core parser library
.target(
name: "AROParser",
path: "Sources/AROParser"
),
// Runtime library
.target(
name: "ARORuntime",
dependencies: [
"AROParser",
"Clibgit2",
.product(name: "Yams", package: "Yams"),
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "Logging", package: "swift-log"),
// #318: Deque for O(1) BoundedSet eviction.
.product(name: "DequeModule", package: "swift-collections"),
] + runtimePlatformDependencies,
path: "Sources/ARORuntime"
),
// Issue #231 — C bridge target exposing llvm-c/DebugInfo.h
// to Swift for DWARF source-mapping emission.
.target(
name: "AROCDebugInfo",
path: "Sources/AROCDebugInfo",
publicHeadersPath: "include",
cSettings: arocDebugInfoCSettings
),
// Native compiler (LLVM IR generation)
.target(
name: "AROCompiler",
dependencies: [
"AROParser",
"AROCDebugInfo",
.product(name: "Logging", package: "swift-log"),
] + compilerLLVMDependency,
path: "Sources/AROCompiler",
linkerSettings: llvmLinkerSettings
),
// System library for libgit2
.systemLibrary(
name: "Clibgit2",
path: "Sources/Clibgit2",
pkgConfig: "libgit2",
providers: [
.brew(["libgit2"]),
.apt(["libgit2-dev"]),
]
),
// Package manager for plugins
.target(
name: "AROPackageManager",
dependencies: [
"Clibgit2",
.product(name: "Yams", package: "Yams"),
],
path: "Sources/AROPackageManager"
),
// Vendored line editor (fork of andybest/linenoise-swift) with a
// multi-line refresh patch. Keeps the `LineNoise` module name so
// `import LineNoise` call sites are unchanged.
.target(
name: "LineNoise",
path: "Sources/LineNoise",
exclude: ["LICENSE"]
),
// CLI tool
.executableTarget(
name: "AROCLI",
dependencies: [
"AROVersion",
"AROParser",
"ARORuntime",
"AROCompiler",
"AROPackageManager",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"LineNoise",
.product(name: "Logging", package: "swift-log"),
] + cliLspDependency + askDependency,
path: "Sources/AROCLI",
linkerSettings: llvmLinkerSettings
),
// SOLARO targets (macOS only) are appended below via
// `solaroTargets` — see the top of this file.
// Parser tests
.testTarget(
name: "AROParserTests",
dependencies: ["AROParser"],
path: "Tests/AROParserTests"
),
// Runtime tests
.testTarget(
name: "AROuntimeTests",
dependencies: ["ARORuntime"],
path: "Tests/AROuntimeTests"
),
// Compiler tests
.testTarget(
name: "AROCompilerTests",
dependencies: ["AROCompiler", "AROParser"],
path: "Tests/AROCompilerTests"
),
// Package manager tests
.testTarget(
name: "AROPackageManagerTests",
dependencies: ["AROPackageManager"],
path: "Tests/AROPackageManagerTests"
),
// CLI tests — covers the small pieces of pure logic that
// live inside CLI command structs (e.g. UILauncher path
// resolution). Uses @testable import AROCLI.
.testTarget(
name: "AROCLITests",
dependencies: ["AROCLI"],
path: "Tests/AROCLITests"
),
]
// SOLARO targets (macOS only) — appended unconditionally; the
// array is empty on non-macOS hosts.
targets.append(contentsOf: solaroTargets)
// LSP targets - not available on Windows (no compatible library)
#if !os(Windows)
targets.append(contentsOf: [
// Language Server Protocol implementation
.target(
name: "AROLSP",
dependencies: [
"AROParser",
"ARORuntime",
] + lspTargetDependencies,
path: "Sources/AROLSP"
),
// LSP tests
.testTarget(
name: "AROLSPTests",
dependencies: ["AROLSP", "AROParser"] + lspTargetDependencies,
path: "Tests/AROLSPTests"
),
// AROAsk - local LLM coding assistant (`aro ask`)
// On macOS: native MLX inference (MLXLLM + Transformers)
// On Linux: llama-server (CUDA) or remote endpoint
.target(
name: "AROAsk",
dependencies: [
"AROParser",
"ARORuntime",
"AROVersion",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Yams", package: "Yams"),
.product(name: "Crypto", package: "swift-crypto"),
"LineNoise",
] + askMLXTargetDependencies,
path: "Sources/AROAsk"
),
// AROAsk tests — tool schema generation and argument
// decoding (#357).
.testTarget(
name: "AROAskTests",
dependencies: ["AROAsk"],
path: "Tests/AROAskTests"
),
])
#endif
return targets
}(),
swiftLanguageModes: [.v6]
)