swadhinbiswas feat: implement air-gapped mode, UI fixes, and project management integrations · 7/9/2026
e3bd4a1
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
/**
* Queue Commands
* Manage merge queue from the CLI
*/
import chalk from "chalk";
import { Command } from "commander";
import ora from "ora";
import { simpleGit } from "simple-git";
import { deleteWithAuth, getWithAuth, postWithAuth } from "../../lib/api.js";
import { getConfig } from "../../lib/config.js";
import { getRepoInfoFromGit } from "../../lib/git.js";
const git = simpleGit();
interface QueueItem {
id: string;
position: number;
status: string;
priority: number;
pullRequest: {
number: number;
title: string;
sourceBranch: string;
targetBranch: string;
author: { username: string };
};
addedAt: string;
estimatedMergeTime?: string;
}
export const queueCommands = new Command("queue").description(
"Manage merge queue",
);
// Get repo info from git remote
async function getRepoInfo() {
return getRepoInfoFromGit(git);
}
function getStatusIcon(status: string): string {
switch (status) {
case "pending":
return chalk.hex("#f1fa8c")("◷");
case "running_ci":
return chalk.blue("●");
case "ready":
return chalk.hex("#50fa7b")("✓");
case "merging":
return chalk.hex("#ff79c6")("↻");
case "failed":
return chalk.hex("#ff5555")("✗");
default:
return chalk.hex("#6272a4")("○");
}
}
// Queue Add
queueCommands
.command("add <pr-number>")
.description("Add a pull request to the merge queue")
.option("-p, --priority <n>", "Priority (higher = sooner)", "0")
.option(
"-m, --method <method>",
"Merge method (merge, squash, rebase)",
"merge",
)
.action(async (prNumber: string, options) => {
const config = getConfig();
if (!config.token) {
console.error(chalk.hex("#ff5555")("Not logged in. Run 'och auth login' first."));
process.exit(1);
}
const spinner = ora(`Adding PR #${prNumber} to merge queue...`).start();
try {
const repoInfo = await getRepoInfo();
if (!repoInfo) {
spinner.fail("Could not determine repository");
process.exit(1);
}
const result = await postWithAuth<{ data: QueueItem }>(
`/api/repos/${repoInfo.owner}/${repoInfo.repo}/queue`,
{
pullRequestNumber: parseInt(prNumber),
priority: parseInt(options.priority),
mergeMethod: options.method,
},
);
spinner.succeed(
`Added PR #${prNumber} to merge queue at position ${result.data.position}`,
);
if (result.data.estimatedMergeTime) {
const eta = new Date(result.data.estimatedMergeTime);
console.log(
chalk.hex("#6272a4")(` Estimated merge: ${eta.toLocaleTimeString()}`),
);
}
} catch (error) {
spinner.fail("Failed to add to merge queue");
console.error(
chalk.hex("#ff5555")(error instanceof Error ? error.message : "Unknown error"),
);
process.exit(1);
}
});
// Queue List
queueCommands
.command("list")
.alias("ls")
.description("List merge queue items")
.action(async () => {
const config = getConfig();
if (!config.token) {
console.error(chalk.hex("#ff5555")("Not logged in. Run 'och auth login' first."));
process.exit(1);
}
const spinner = ora("Fetching merge queue...").start();
try {
const repoInfo = await getRepoInfo();
if (!repoInfo) {
spinner.fail("Could not determine repository");
process.exit(1);
}
const result = await getWithAuth<{ data: QueueItem[] }>(
`/api/repos/${repoInfo.owner}/${repoInfo.repo}/queue`,
);
spinner.stop();
if (result.data.length === 0) {
console.log(chalk.hex("#6272a4")("Merge queue is empty."));
return;
}
console.log(
chalk.bold(`\n🔀 Merge Queue (${result.data.length} items)\n`),
);
console.log(
chalk.hex("#6272a4")(" Pos PR Title Status"),
);
console.log(
chalk.hex("#6272a4")(" ─── ── ───── ──────"),
);
for (const item of result.data) {
const icon = getStatusIcon(item.status);
const pr = item.pullRequest;
const title =
pr.title.length > 35
? pr.title.slice(0, 32) + "..."
: pr.title.padEnd(35);
console.log(
` ${String(item.position).padStart(3)} #${String(pr.number).padEnd(5)} ${title} ${icon} ${item.status}`,
);
}
console.log("");
} catch (error) {
spinner.fail("Failed to fetch merge queue");
console.error(
chalk.hex("#ff5555")(error instanceof Error ? error.message : "Unknown error"),
);
process.exit(1);
}
});
// Queue Remove
queueCommands
.command("remove <pr-number>")
.alias("rm")
.description("Remove a pull request from the merge queue")
.action(async (prNumber: string) => {
const config = getConfig();
if (!config.token) {
console.error(chalk.hex("#ff5555")("Not logged in. Run 'och auth login' first."));
process.exit(1);
}
const spinner = ora(`Removing PR #${prNumber} from merge queue...`).start();
try {
const repoInfo = await getRepoInfo();
if (!repoInfo) {
spinner.fail("Could not determine repository");
process.exit(1);
}
await deleteWithAuth(
`/api/repos/${repoInfo.owner}/${repoInfo.repo}/queue/${prNumber}`,
);
spinner.succeed(`Removed PR #${prNumber} from merge queue`);
} catch (error) {
spinner.fail("Failed to remove from merge queue");
console.error(
chalk.hex("#ff5555")(error instanceof Error ? error.message : "Unknown error"),
);
process.exit(1);
}
});
// Queue Status
queueCommands
.command("status")
.description("Show merge queue status for current PR")
.action(async () => {
const config = getConfig();
if (!config.token) {
console.error(chalk.hex("#ff5555")("Not logged in. Run 'och auth login' first."));
process.exit(1);
}
const spinner = ora("Checking queue status...").start();
try {
const repoInfo = await getRepoInfo();
if (!repoInfo) {
spinner.fail("Could not determine repository");
process.exit(1);
}
const currentBranch = (
await git.revparse(["--abbrev-ref", "HEAD"])
).trim();
// Find PR for current branch
const prs = await getWithAuth<{ data: { number: number }[] }>(
`/api/repos/${repoInfo.owner}/${repoInfo.repo}/pulls?sourceBranch=${currentBranch}&state=open&limit=1`,
);
if (prs.data.length === 0) {
spinner.info(`No open PR found for branch ${currentBranch}`);
return;
}
const prNumber = prs.data[0].number;
// Get queue status
const result = await getWithAuth<{ data: QueueItem[] }>(
`/api/repos/${repoInfo.owner}/${repoInfo.repo}/queue`,
);
spinner.stop();
const item = result.data.find((i) => i.pullRequest.number === prNumber);
if (!item) {
console.log(chalk.hex("#6272a4")(`PR #${prNumber} is not in the merge queue.`));
console.log(chalk.hex("#6272a4")(`Run 'och queue add ${prNumber}' to add it.`));
return;
}
const icon = getStatusIcon(item.status);
console.log(
`\n${icon} PR #${prNumber} is at position ${item.position} in the queue`,
);
console.log(`Status: ${item.status}`);
if (item.estimatedMergeTime) {
const eta = new Date(item.estimatedMergeTime);
console.log(`Estimated merge: ${eta.toLocaleString()}`);
}
console.log("");
} catch (error) {
spinner.fail("Failed to check queue status");
console.error(
chalk.hex("#ff5555")(error instanceof Error ? error.message : "Unknown error"),
);
process.exit(1);
}
});
export default queueCommands;