Skip to content

Commit 6f99f63

Browse files
authored
feat: migrate to autopilot for repository fetching (#62)
1 parent c027f8b commit 6f99f63

30 files changed

Lines changed: 1784 additions & 1336 deletions

Packages/Sources/RxCodeCore/CLISession/CLILineToBlocksMapper.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ public enum CLILineToBlocksMapper {
129129
switch part {
130130
case .text(let t):
131131
guard !t.isEmpty else { continue }
132+
let trimmed = t.trimmingCharacters(in: .whitespacesAndNewlines)
133+
if CLIMetaEnvelope.isNoResponseRequested(trimmed) { continue }
132134
blocks.append(.text(t))
133135
case .toolUse(let id, let name, let input):
134136
blocks.append(.toolCall(ToolCall(id: id, name: name, input: input)))
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import Foundation
2+
3+
// MARK: - autopilot Repo DTO
4+
5+
/// Repository payload returned by `GET /api/v1/repos` on autopilot
6+
/// (deployed at https://autopilot.rxlab.app). The macOS app no longer talks
7+
/// to api.github.com directly — autopilot fans out across the signed-in
8+
/// user's GitHub App installations and hands back a deduped list.
9+
public struct AutopilotRepo: Identifiable, Codable, Sendable, Hashable {
10+
public let id: Int
11+
public let fullName: String
12+
public let name: String
13+
public let owner: String
14+
public let isPrivate: Bool
15+
public let defaultBranch: String?
16+
public let htmlUrl: String
17+
public let cloneUrl: String
18+
public let sshUrl: String
19+
public let updatedAt: String?
20+
public let description: String?
21+
22+
public init(
23+
id: Int,
24+
fullName: String,
25+
name: String,
26+
owner: String,
27+
isPrivate: Bool,
28+
defaultBranch: String?,
29+
htmlUrl: String,
30+
cloneUrl: String,
31+
sshUrl: String,
32+
updatedAt: String?,
33+
description: String?
34+
) {
35+
self.id = id
36+
self.fullName = fullName
37+
self.name = name
38+
self.owner = owner
39+
self.isPrivate = isPrivate
40+
self.defaultBranch = defaultBranch
41+
self.htmlUrl = htmlUrl
42+
self.cloneUrl = cloneUrl
43+
self.sshUrl = sshUrl
44+
self.updatedAt = updatedAt
45+
self.description = description
46+
}
47+
48+
private enum CodingKeys: String, CodingKey {
49+
case id
50+
case fullName
51+
case name
52+
case owner
53+
case isPrivate = "private"
54+
case defaultBranch
55+
case htmlUrl
56+
case cloneUrl
57+
case sshUrl
58+
case updatedAt
59+
case description
60+
}
61+
}
62+
63+
public struct AutopilotRepoListResponse: Codable, Sendable {
64+
public let items: [AutopilotRepo]
65+
public let pagination: Pagination?
66+
67+
public struct Pagination: Codable, Sendable {
68+
public let nextCursor: String?
69+
public let hasMore: Bool
70+
71+
public init(nextCursor: String?, hasMore: Bool) {
72+
self.nextCursor = nextCursor
73+
self.hasMore = hasMore
74+
}
75+
}
76+
77+
public init(items: [AutopilotRepo], pagination: Pagination?) {
78+
self.items = items
79+
self.pagination = pagination
80+
}
81+
}
82+
83+
// MARK: - GitHub App Installation DTOs
84+
85+
/// A GitHub App installation owned by the signed-in user, as recorded by
86+
/// autopilot. The macOS app uses this to decide whether to surface the
87+
/// "Install GitHub App" CTA in the import-repo sheet.
88+
public struct AutopilotInstallation: Identifiable, Codable, Sendable, Hashable {
89+
public let id: String
90+
public let installationId: Int
91+
public let accountLogin: String
92+
public let accountType: String
93+
public let accountAvatarUrl: String?
94+
public let repositorySelection: String
95+
96+
public init(
97+
id: String,
98+
installationId: Int,
99+
accountLogin: String,
100+
accountType: String,
101+
accountAvatarUrl: String?,
102+
repositorySelection: String
103+
) {
104+
self.id = id
105+
self.installationId = installationId
106+
self.accountLogin = accountLogin
107+
self.accountType = accountType
108+
self.accountAvatarUrl = accountAvatarUrl
109+
self.repositorySelection = repositorySelection
110+
}
111+
}
112+
113+
/// Cheap "do you have any installations?" probe returned by
114+
/// `GET /api/v1/installations/precheck`.
115+
public struct AutopilotPrecheckResponse: Codable, Sendable {
116+
public let hasInstallation: Bool
117+
public let count: Int
118+
119+
public init(hasInstallation: Bool, count: Int) {
120+
self.hasInstallation = hasInstallation
121+
self.count = count
122+
}
123+
}
124+
125+
/// Reply from `GET /api/v1/installations/install-url`. The URL embeds a
126+
/// signed `state` JWT tying the GitHub callback back to the requesting
127+
/// rxauth user, so the install completes correctly even if the browser
128+
/// is not signed in to autopilot.rxlab.app.
129+
public struct AutopilotInstallUrlResponse: Codable, Sendable {
130+
public let url: String
131+
public let state: String
132+
public let expiresAt: String
133+
134+
public init(url: String, state: String, expiresAt: String) {
135+
self.url = url
136+
self.state = state
137+
self.expiresAt = expiresAt
138+
}
139+
}
140+

Packages/Sources/RxCodeCore/Models/GitHubModels.swift

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)