@sideboard-ai/cli 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +13 -0
- package/dist/index.js +636 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Sideboard contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# `@sideboard-ai/cli`
|
|
2
|
+
|
|
3
|
+
Agent-agnostic worktree orchestration from the terminal.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -g @sideboard-ai/cli
|
|
7
|
+
|
|
8
|
+
sideboard ls
|
|
9
|
+
sideboard send <thread> "…"
|
|
10
|
+
sideboard mcp # MCP stdio server
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Also installs `side` as a short alias. The MCP server is available as `sideboard mcp`, or via `@sideboard-ai/core`'s `sideboard-mcp` bin.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { createInterface } from "readline";
|
|
5
|
+
import { spawn } from "child_process";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { Command } from "commander";
|
|
8
|
+
import {
|
|
9
|
+
detectAgents,
|
|
10
|
+
getOrchestrator,
|
|
11
|
+
listBranches,
|
|
12
|
+
listPrs,
|
|
13
|
+
listIssues,
|
|
14
|
+
listLinearIssues,
|
|
15
|
+
resolveRepoRoot,
|
|
16
|
+
startMcpServer,
|
|
17
|
+
startOrchestration,
|
|
18
|
+
hasRepoHook,
|
|
19
|
+
settingsSourceLabel,
|
|
20
|
+
runCloudConnect,
|
|
21
|
+
getBrightsySession,
|
|
22
|
+
switchBrightsyAccount,
|
|
23
|
+
connectBrightsyTeam,
|
|
24
|
+
disconnectBrightsyTeam
|
|
25
|
+
} from "@sideboard-ai/core";
|
|
26
|
+
var VERSION = "0.1.0";
|
|
27
|
+
async function printUpgradeHint() {
|
|
28
|
+
try {
|
|
29
|
+
const { execFile } = await import("child_process");
|
|
30
|
+
const latest = await new Promise((resolve, reject) => {
|
|
31
|
+
execFile(
|
|
32
|
+
"npm",
|
|
33
|
+
["view", "@sideboard-ai/cli", "version"],
|
|
34
|
+
{ timeout: 2500 },
|
|
35
|
+
(err, stdout) => {
|
|
36
|
+
if (err) reject(err);
|
|
37
|
+
else resolve(String(stdout).trim());
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
if (latest && latest !== VERSION) {
|
|
42
|
+
console.error(
|
|
43
|
+
chalk.dim(
|
|
44
|
+
`Upgrade available: ${latest} (you have ${VERSION}). npm i -g @sideboard-ai/cli`
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function confirm(question) {
|
|
52
|
+
if (!process.stdin.isTTY) {
|
|
53
|
+
throw new Error("Interactive confirmation required (no TTY) \u2014 land has no --yes in v1");
|
|
54
|
+
}
|
|
55
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
rl.question(`${question} [y/N] `, (answer) => {
|
|
58
|
+
rl.close();
|
|
59
|
+
resolve(/^y(es)?$/i.test(answer.trim()));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function parseAgent(raw) {
|
|
64
|
+
if (raw === "claude" || raw === "codex" || raw === "opencode" || raw === "brightsy" || raw === "cursor") {
|
|
65
|
+
return raw;
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`Unknown agent: ${raw}`);
|
|
68
|
+
}
|
|
69
|
+
function parseFrom(raw) {
|
|
70
|
+
const idx = raw.indexOf(":");
|
|
71
|
+
if (idx === -1) throw new Error(`--from must be branch:<name>|pr:<n>|ticket:<key>, got ${raw}`);
|
|
72
|
+
const kind = raw.slice(0, idx);
|
|
73
|
+
const ref = raw.slice(idx + 1);
|
|
74
|
+
if (kind !== "branch" && kind !== "pr" && kind !== "ticket") {
|
|
75
|
+
throw new Error(`Unknown source kind: ${kind}`);
|
|
76
|
+
}
|
|
77
|
+
if (!ref) throw new Error(`Missing source ref in ${raw}`);
|
|
78
|
+
return { sourceType: kind, sourceRef: ref };
|
|
79
|
+
}
|
|
80
|
+
async function main() {
|
|
81
|
+
if (process.argv.includes("-V") || process.argv.includes("--version")) {
|
|
82
|
+
console.log(VERSION);
|
|
83
|
+
await printUpgradeHint();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const program = new Command();
|
|
87
|
+
program.name("sideboard").description("Your agent threads aren't trapped anywhere.").version(VERSION);
|
|
88
|
+
const orch = getOrchestrator();
|
|
89
|
+
program.command("detect").description("Show agent availability, auth, MCP, and warnings").action(async () => {
|
|
90
|
+
const statuses = await detectAgents();
|
|
91
|
+
for (const s of statuses) {
|
|
92
|
+
const ok = s.installed && s.authenticated;
|
|
93
|
+
const mark = ok ? chalk.green("\u2713") : chalk.red("\u2717");
|
|
94
|
+
console.log(
|
|
95
|
+
`${mark} ${chalk.bold(s.agent)} installed=${s.installed} auth=${s.authenticated} linearMcp=${s.linearMcp}`
|
|
96
|
+
);
|
|
97
|
+
if (s.reason) console.log(chalk.yellow(` ${s.reason}`));
|
|
98
|
+
for (const w of s.warnings) console.log(chalk.yellow(` warning: ${w}`));
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
program.command("new").description("Create a thread from branch, PR, or Linear ticket").requiredOption("--from <spec>", "branch:<name>|pr:<n>|ticket:<key>").requiredOption("--agent <agent>", "claude|codex|opencode|brightsy|cursor").option("--repo <path>", "repo path", process.cwd()).option("--title <title>", "thread title").action(async (opts) => {
|
|
102
|
+
await orch.reconcile(opts.repo);
|
|
103
|
+
const { sourceType, sourceRef } = parseFrom(opts.from);
|
|
104
|
+
const agent = parseAgent(opts.agent);
|
|
105
|
+
const repoPath = await resolveRepoRoot(opts.repo);
|
|
106
|
+
console.log(chalk.dim(`Creating ${sourceType} thread in ${repoPath}\u2026`));
|
|
107
|
+
const hook = settingsSourceLabel(repoPath);
|
|
108
|
+
if (hook) {
|
|
109
|
+
console.log(chalk.dim(`Found ${hook} \u2014 will run setup / enable dev`));
|
|
110
|
+
} else if (hasRepoHook(repoPath)) {
|
|
111
|
+
console.log(chalk.dim("Repo hook present"));
|
|
112
|
+
}
|
|
113
|
+
const thread = await orch.createThread({
|
|
114
|
+
sourceType,
|
|
115
|
+
sourceRef,
|
|
116
|
+
agent,
|
|
117
|
+
repoPath,
|
|
118
|
+
title: opts.title
|
|
119
|
+
});
|
|
120
|
+
console.log(chalk.green(`Created ${thread.id.slice(0, 8)} ${thread.branchName}`));
|
|
121
|
+
console.log(` worktree: ${thread.worktreePath}`);
|
|
122
|
+
console.log(` agent: ${thread.agent}`);
|
|
123
|
+
});
|
|
124
|
+
program.command("adopt").description("Adopt an existing worktree or import from Conductor").argument("[path]", "worktree path").option("--agent <agent>", "claude|codex|opencode|brightsy|cursor", "claude").option("--from-conductor", "import from Conductor DB").option("--all", "import all Conductor workspaces").option("--id <id>", "Conductor workspace id").action(async (path, opts) => {
|
|
125
|
+
if (opts.fromConductor) {
|
|
126
|
+
const workspaces = orch.listConductor();
|
|
127
|
+
if (opts.all) {
|
|
128
|
+
for (const w of workspaces) {
|
|
129
|
+
if (!w.workspacePath) continue;
|
|
130
|
+
try {
|
|
131
|
+
const t3 = await orch.adoptFromConductor(w.id);
|
|
132
|
+
console.log(chalk.green(`Imported ${t3.id.slice(0, 8)} ${t3.title} (${t3.messages.length} msgs)`));
|
|
133
|
+
} catch (err) {
|
|
134
|
+
console.error(chalk.red(`Skip ${w.workspaceName}: ${err instanceof Error ? err.message : err}`));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (opts.id) {
|
|
140
|
+
const t3 = await orch.adoptFromConductor(opts.id);
|
|
141
|
+
console.log(chalk.green(`Imported ${t3.id.slice(0, 8)} ${t3.title}`));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
console.log(chalk.bold("Conductor workspaces:"));
|
|
145
|
+
workspaces.forEach((w, i) => {
|
|
146
|
+
console.log(
|
|
147
|
+
` ${String(i + 1).padStart(2)}. ${w.workspaceName} ${w.branch} msgs=${w.messageCount} ${w.id.slice(0, 8)}`
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
if (!process.stdin.isTTY) {
|
|
151
|
+
console.log(chalk.dim("Pass --id <id> or --all to import non-interactively"));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
155
|
+
const answer = await new Promise((resolve) => {
|
|
156
|
+
rl.question("Import number (or q): ", resolve);
|
|
157
|
+
});
|
|
158
|
+
rl.close();
|
|
159
|
+
if (answer === "q") return;
|
|
160
|
+
const idx = Number(answer) - 1;
|
|
161
|
+
const chosen = workspaces[idx];
|
|
162
|
+
if (!chosen) throw new Error("Invalid selection");
|
|
163
|
+
const t2 = await orch.adoptFromConductor(chosen.id);
|
|
164
|
+
console.log(chalk.green(`Imported ${t2.id.slice(0, 8)} ${t2.title} (${t2.messages.length} msgs)`));
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (!path) throw new Error("Provide a worktree path or --from-conductor");
|
|
168
|
+
const t = await orch.adopt({
|
|
169
|
+
worktreePath: path,
|
|
170
|
+
agent: parseAgent(opts.agent)
|
|
171
|
+
});
|
|
172
|
+
console.log(chalk.green(`Adopted ${t.id.slice(0, 8)} ${t.branchName}`));
|
|
173
|
+
});
|
|
174
|
+
program.command("ls").description("List threads").option("--archived", "include archived").action(async (opts) => {
|
|
175
|
+
const threads = orch.getThreads(Boolean(opts.archived));
|
|
176
|
+
if (!threads.length) {
|
|
177
|
+
console.log("(no threads)");
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
for (const t of threads) {
|
|
181
|
+
const port = t.devPort ? chalk.cyan(` http://localhost:${t.devPort}`) : "";
|
|
182
|
+
console.log(
|
|
183
|
+
`${t.id.slice(0, 8)} ${statusColor(t.status)} ${t.agent.padEnd(8)} ${t.sourceType}:${t.sourceRef} ${t.title}${port}`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
program.command("watch").description("Live TTY dashboard of all threads").action(async () => {
|
|
188
|
+
await orch.reconcile();
|
|
189
|
+
const render = () => {
|
|
190
|
+
console.clear();
|
|
191
|
+
console.log(chalk.bold("sideboard watch") + chalk.dim(` ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`));
|
|
192
|
+
console.log(chalk.dim("\u2500".repeat(72)));
|
|
193
|
+
for (const t of orch.getThreads()) {
|
|
194
|
+
const q = t.queue.length ? chalk.yellow(` q=${t.queue.length}`) : "";
|
|
195
|
+
const port = t.devPort ? chalk.cyan(` :${t.devPort}`) : "";
|
|
196
|
+
console.log(
|
|
197
|
+
`${t.id.slice(0, 8)} ${statusColor(t.status)}${q}${port} ${t.agent} ${t.title}`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
render();
|
|
202
|
+
orch.on(() => render());
|
|
203
|
+
await new Promise(() => {
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
program.command("send").description("Send a prompt to a thread (queues if running)").argument("[thread]", "thread id/ref").argument("[prompt]", "prompt text").option("--to <refs>", "comma-separated thread refs for fan-out").action(async (thread, prompt, opts) => {
|
|
207
|
+
await orch.reconcile();
|
|
208
|
+
if (opts.to) {
|
|
209
|
+
if (!prompt && thread) prompt = thread;
|
|
210
|
+
if (!prompt) throw new Error("Prompt required");
|
|
211
|
+
const refs = String(opts.to).split(",").map((s) => s.trim());
|
|
212
|
+
const off2 = orch.on((event) => {
|
|
213
|
+
if (event.type === "turn_output" && event.event.type === "stdout") {
|
|
214
|
+
process.stdout.write(event.event.data);
|
|
215
|
+
}
|
|
216
|
+
if (event.type === "turn_output" && event.event.type === "stderr") {
|
|
217
|
+
process.stderr.write(event.event.data + "\n");
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
await orch.fanOut(refs, prompt);
|
|
221
|
+
for (const ref of refs) {
|
|
222
|
+
await orch.waitForTurn(ref);
|
|
223
|
+
}
|
|
224
|
+
off2();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (!thread || !prompt) throw new Error('Usage: sideboard send <thread> "<prompt>"');
|
|
228
|
+
const off = orch.on((event) => {
|
|
229
|
+
if (event.type === "turn_output" && event.threadId.startsWith(thread.slice(0, 8))) {
|
|
230
|
+
if (event.event.type === "stdout") process.stdout.write(event.event.data);
|
|
231
|
+
if (event.event.type === "stderr") process.stderr.write(event.event.data + "\n");
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
await orch.send(thread, prompt);
|
|
235
|
+
const done = await orch.waitForTurn(thread);
|
|
236
|
+
off();
|
|
237
|
+
console.log(chalk.dim(`
|
|
238
|
+
[${done.status}]`));
|
|
239
|
+
});
|
|
240
|
+
program.command("stop").argument("<thread>", "thread id/ref").action(async (thread) => {
|
|
241
|
+
const t = orch.stop(thread);
|
|
242
|
+
console.log(chalk.yellow(`Stopped ${t.id.slice(0, 8)}`));
|
|
243
|
+
});
|
|
244
|
+
program.command("attach").description("Exec the native CLI interactively in the thread worktree").argument("<thread>", "thread id/ref").action(async (thread) => {
|
|
245
|
+
const cmd = await orch.attachCommand(thread);
|
|
246
|
+
console.log(chalk.dim(`Attaching: ${cmd.file} ${cmd.args.join(" ")}`));
|
|
247
|
+
const child = spawn(cmd.file, cmd.args, {
|
|
248
|
+
cwd: cmd.cwd,
|
|
249
|
+
env: { ...process.env, ...cmd.env },
|
|
250
|
+
stdio: "inherit"
|
|
251
|
+
});
|
|
252
|
+
await new Promise((resolve, reject) => {
|
|
253
|
+
child.on("exit", () => resolve());
|
|
254
|
+
child.on("error", reject);
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
program.command("dev").description("Start/stop per-worktree run script").argument("<thread>", "thread id/ref").argument("[script]", "named run script (default script if omitted)").option("--stop", "stop the run script").action(async (thread, script, opts) => {
|
|
258
|
+
if (opts.stop) {
|
|
259
|
+
orch.stopDev(thread, script);
|
|
260
|
+
console.log(chalk.yellow(script ? `Stopped ${script}` : "Run scripts stopped"));
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const { port, scriptName } = await orch.startDev(thread, script);
|
|
264
|
+
console.log(chalk.green(`${scriptName} on http://localhost:${port}`));
|
|
265
|
+
});
|
|
266
|
+
program.command("setup").description("Re-run workspace setup for a thread").argument("<thread>", "thread id/ref").action(async (thread) => {
|
|
267
|
+
const off = orch.on((event) => {
|
|
268
|
+
if (event.type === "setup_output" && event.threadId.startsWith(thread.slice(0, 8))) {
|
|
269
|
+
console.log(event.line);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
const result = await orch.runSetup(thread);
|
|
273
|
+
off();
|
|
274
|
+
console.log(
|
|
275
|
+
chalk.green(`Setup finished exit=${result.exitCode}${result.source ? ` (${result.source})` : ""}`)
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
const workspaceCmd = program.command("workspace").description("Manage registered Sideboard workspaces (repos)");
|
|
279
|
+
workspaceCmd.command("ls").description("List workspaces").action(() => {
|
|
280
|
+
const list = orch.listWorkspaces();
|
|
281
|
+
if (!list.length) {
|
|
282
|
+
console.log("(no workspaces)");
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
for (const w of list) {
|
|
286
|
+
console.log(`${w.name} ${w.path}`);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
workspaceCmd.command("add").argument("<path>", "git repo path").action(async (path) => {
|
|
290
|
+
const repoPath = await resolveRepoRoot(path);
|
|
291
|
+
const w = await orch.addWorkspace(repoPath);
|
|
292
|
+
console.log(chalk.green(`Added ${w.name} ${w.path}`));
|
|
293
|
+
});
|
|
294
|
+
workspaceCmd.command("rm").argument("<path>", "git repo path").action(async (path) => {
|
|
295
|
+
const repoPath = await resolveRepoRoot(path);
|
|
296
|
+
orch.removeWorkspace(repoPath);
|
|
297
|
+
console.log(chalk.yellow(`Removed ${repoPath}`));
|
|
298
|
+
});
|
|
299
|
+
program.command("clone").description("Clone a repo into ~/sideboard/repos and register it").argument("<url>", "git clone URL").option("--name <name>", "directory name under ~/sideboard/repos").action(async (url, opts) => {
|
|
300
|
+
const { repoPath, workspace } = await orch.cloneRepo(url, opts.name);
|
|
301
|
+
console.log(chalk.green(`Cloned ${workspace.name}`));
|
|
302
|
+
console.log(` path: ${repoPath}`);
|
|
303
|
+
});
|
|
304
|
+
program.command("apply").description("Merge/cherry-pick thread branch into the main checkout (no PR)").argument("<thread>", "thread id/ref").option("--method <method>", "merge|cherry-pick", "merge").option("--target <branch>", "target branch (default: repo default)").action(async (thread, opts) => {
|
|
305
|
+
const method = opts.method === "cherry-pick" ? "cherry-pick" : "merge";
|
|
306
|
+
const ok = await confirm(
|
|
307
|
+
`Apply thread into main checkout via ${method}? This modifies the main working tree.`
|
|
308
|
+
);
|
|
309
|
+
if (!ok) {
|
|
310
|
+
console.log("Aborted");
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const result = await orch.applyIntoMain(thread, {
|
|
314
|
+
method,
|
|
315
|
+
targetBranch: opts.target
|
|
316
|
+
});
|
|
317
|
+
console.log(chalk.green(result.message));
|
|
318
|
+
});
|
|
319
|
+
program.command("orphans").description("List or clean orphan Sideboard worktrees").option("--clean", "remove orphans beyond worktreeMaxCount").option("--dry-run", "show what would be removed").option("--repo <path>", "limit to one repo").action(async (opts) => {
|
|
320
|
+
if (opts.clean) {
|
|
321
|
+
const result = await orch.cleanupOrphans({
|
|
322
|
+
dryRun: Boolean(opts.dryRun),
|
|
323
|
+
repoPath: opts.repo
|
|
324
|
+
});
|
|
325
|
+
console.log(
|
|
326
|
+
chalk.bold(
|
|
327
|
+
opts.dryRun ? `Would remove ${result.removed.length}, keep ${result.kept.length}` : `Removed ${result.removed.length}, kept ${result.kept.length}`
|
|
328
|
+
)
|
|
329
|
+
);
|
|
330
|
+
for (const p of result.removed) console.log(chalk.red(` - ${p}`));
|
|
331
|
+
for (const p of result.kept) console.log(chalk.dim(` keep ${p}`));
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const orphans = await orch.listOrphanWorktrees(opts.repo);
|
|
335
|
+
if (!orphans.length) {
|
|
336
|
+
console.log("(no orphans)");
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
for (const o of orphans) {
|
|
340
|
+
console.log(`${o.path} (${o.repoPath})`);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
program.command("best-of-n").description("Create one thread per agent with the same prompt (Cursor-style fanout)").argument("<prompt>", "prompt text").requiredOption(
|
|
344
|
+
"--agents <list>",
|
|
345
|
+
"comma-separated agents (claude,codex,opencode,cursor,brightsy)"
|
|
346
|
+
).option("--repo <path>", "repo path", process.cwd()).option("--from <spec>", "branch:<name>|pr:<n>|ticket:<key>", "branch:default").action(async (prompt, opts) => {
|
|
347
|
+
const agents = String(opts.agents).split(",").map((s) => parseAgent(s.trim()));
|
|
348
|
+
const repoPath = await resolveRepoRoot(opts.repo);
|
|
349
|
+
const { sourceType, sourceRef } = parseFrom(opts.from);
|
|
350
|
+
const threads = await orch.bestOfN({
|
|
351
|
+
prompt,
|
|
352
|
+
agents,
|
|
353
|
+
repoPath,
|
|
354
|
+
sourceType,
|
|
355
|
+
sourceRef
|
|
356
|
+
});
|
|
357
|
+
for (const t of threads) {
|
|
358
|
+
console.log(
|
|
359
|
+
chalk.green(`${t.id.slice(0, 8)} ${t.agent.padEnd(8)} ${t.branchName}`)
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
program.command("diff").argument("<thread>", "thread id/ref").action(async (thread) => {
|
|
364
|
+
const diff = await orch.diff(thread);
|
|
365
|
+
console.log(chalk.bold(`base: ${diff.base}`) + (diff.dirty ? chalk.yellow(" (dirty)") : ""));
|
|
366
|
+
console.log(diff.stat);
|
|
367
|
+
console.log("");
|
|
368
|
+
for (const f of diff.files) {
|
|
369
|
+
console.log(chalk.cyan(`--- ${f.path} (${f.status})`));
|
|
370
|
+
console.log(f.patch);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
program.command("open").argument("<thread>", "thread id/ref").option("--editor <cmd>", "editor command", process.env.SIDEBOARD_EDITOR ?? "cursor").action(async (thread, opts) => {
|
|
374
|
+
const t = orch.getThread(thread);
|
|
375
|
+
if (!t) throw new Error(`Thread not found: ${thread}`);
|
|
376
|
+
spawn(opts.editor, [t.worktreePath], { stdio: "inherit", detached: true }).unref();
|
|
377
|
+
console.log(chalk.green(`Opened ${t.worktreePath} in ${opts.editor}`));
|
|
378
|
+
});
|
|
379
|
+
program.command("land").argument("<thread>", "thread id/ref").option("--draft", "create/update as a draft PR").action(async (thread, opts) => {
|
|
380
|
+
const preview = await orch.previewLand(thread);
|
|
381
|
+
console.log(chalk.bold("Land preview"));
|
|
382
|
+
console.log(` branch: ${preview.branch}`);
|
|
383
|
+
console.log(` target: ${preview.target}`);
|
|
384
|
+
console.log(` dirty: ${preview.dirty}${preview.dirty ? " (will auto-commit on confirm)" : ""}`);
|
|
385
|
+
console.log(` draft: ${Boolean(opts.draft)}`);
|
|
386
|
+
console.log(` stat:
|
|
387
|
+
${preview.diffStat}`);
|
|
388
|
+
if (preview.blocked) {
|
|
389
|
+
console.error(chalk.red(preview.blockReason));
|
|
390
|
+
process.exitCode = 1;
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const ok = await confirm(
|
|
394
|
+
opts.draft ? "Push and create/update DRAFT PR?" : "Push and create/update PR?"
|
|
395
|
+
);
|
|
396
|
+
if (!ok) {
|
|
397
|
+
console.log("Aborted");
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const result = await orch.confirmLand(thread, { draft: Boolean(opts.draft) });
|
|
401
|
+
console.log(chalk.green(`PR: ${result.prUrl}`));
|
|
402
|
+
});
|
|
403
|
+
program.command("rm").argument("<thread>", "thread id/ref").option("--purge", "delete record too").option("--delete-branch", "also delete the git branch (with --purge)").action(async (thread, opts) => {
|
|
404
|
+
if (opts.purge) {
|
|
405
|
+
const ok = await confirm(`Purge thread ${thread}? This deletes the record.`);
|
|
406
|
+
if (!ok) return;
|
|
407
|
+
await orch.purge(thread, { deleteBranch: Boolean(opts.deleteBranch) });
|
|
408
|
+
console.log(chalk.red("Purged"));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
const t = await orch.archive(thread);
|
|
412
|
+
console.log(chalk.yellow(`Archived ${t.id.slice(0, 8)}`));
|
|
413
|
+
});
|
|
414
|
+
program.command("restore").argument("<thread>", "thread id/ref").action(async (thread) => {
|
|
415
|
+
const t = await orch.restore(thread);
|
|
416
|
+
console.log(chalk.green(`Restored ${t.id.slice(0, 8)}`));
|
|
417
|
+
});
|
|
418
|
+
program.command("orchestrate").argument("<goal>", "orchestration goal").option("--agent <agent>", "claude|codex|opencode|cursor", "claude").option(
|
|
419
|
+
"--repo <path>",
|
|
420
|
+
"optional legacy pinned-repo home (omit for Global workspace)"
|
|
421
|
+
).action(async (goal, opts) => {
|
|
422
|
+
const agent = parseAgent(opts.agent);
|
|
423
|
+
if (agent === "brightsy") {
|
|
424
|
+
throw new Error(
|
|
425
|
+
"orchestrate is not supported with brightsy \u2014 use claude, codex, opencode, or cursor"
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
const repoPath = opts.repo ? await resolveRepoRoot(opts.repo) : void 0;
|
|
429
|
+
const thread = await startOrchestration({ goal, agent, repoPath });
|
|
430
|
+
const agentCwd = thread.worktreePath || process.cwd();
|
|
431
|
+
console.log(chalk.bold("Orchestration thread"), thread.id.slice(0, 8));
|
|
432
|
+
console.log(chalk.dim("Registering sideboard MCP with agent and starting coordinator\u2026"));
|
|
433
|
+
console.log(
|
|
434
|
+
chalk.dim(
|
|
435
|
+
"Tip: MCP is for judgment. Use `sideboard ls/send/diff/land` for mechanical control (zero tokens)."
|
|
436
|
+
)
|
|
437
|
+
);
|
|
438
|
+
const systemHint = [
|
|
439
|
+
"You are a Sideboard coordinator.",
|
|
440
|
+
"You operate from the Global workspace (no git home). Use Sideboard MCP tools only.",
|
|
441
|
+
"Use Sideboard MCP tools for persistent cross-agent threads, land/dev lifecycle, and work that outlives this session.",
|
|
442
|
+
'For same-session Claude subtasks, prefer Claude Code native Agent(isolation: "worktree") instead.',
|
|
443
|
+
"You cannot confirm_land or purge_thread \u2014 those stay human-only.",
|
|
444
|
+
`Goal: ${goal}`,
|
|
445
|
+
repoPath ? `Pinned repo (legacy): ${repoPath}` : "Workspace: Global",
|
|
446
|
+
`Parent thread id (pass as parentThreadId when creating children): ${thread.id}`
|
|
447
|
+
].join("\n");
|
|
448
|
+
const mcpConfig = {
|
|
449
|
+
mcpServers: {
|
|
450
|
+
sideboard: {
|
|
451
|
+
command: "sideboard",
|
|
452
|
+
args: ["mcp"]
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
const { writeFileSync, mkdtempSync } = await import("fs");
|
|
457
|
+
const { join } = await import("path");
|
|
458
|
+
const { tmpdir } = await import("os");
|
|
459
|
+
const dir = mkdtempSync(join(tmpdir(), "sideboard-orch-"));
|
|
460
|
+
const cfgPath = join(dir, "mcp.json");
|
|
461
|
+
writeFileSync(cfgPath, JSON.stringify(mcpConfig, null, 2));
|
|
462
|
+
let child;
|
|
463
|
+
if (agent === "claude") {
|
|
464
|
+
child = spawn(
|
|
465
|
+
"claude",
|
|
466
|
+
["-p", systemHint, "--mcp-config", cfgPath, "--permission-mode", "plan"],
|
|
467
|
+
{ cwd: agentCwd, stdio: "inherit" }
|
|
468
|
+
);
|
|
469
|
+
} else if (agent === "codex") {
|
|
470
|
+
child = spawn("codex", ["exec", systemHint, "--cd", agentCwd], {
|
|
471
|
+
cwd: agentCwd,
|
|
472
|
+
stdio: "inherit"
|
|
473
|
+
});
|
|
474
|
+
} else if (agent === "cursor") {
|
|
475
|
+
child = spawn(
|
|
476
|
+
"cursor-agent",
|
|
477
|
+
["--workspace", agentCwd, systemHint],
|
|
478
|
+
{ cwd: agentCwd, stdio: "inherit", env: process.env }
|
|
479
|
+
);
|
|
480
|
+
child.on("error", () => {
|
|
481
|
+
console.error(
|
|
482
|
+
chalk.yellow(
|
|
483
|
+
"cursor-agent CLI not found \u2014 orchestration thread was created; use MCP from Claude/Codex or the desktop app."
|
|
484
|
+
)
|
|
485
|
+
);
|
|
486
|
+
});
|
|
487
|
+
} else {
|
|
488
|
+
child = spawn("opencode", ["run", systemHint, "--dir", agentCwd], {
|
|
489
|
+
cwd: agentCwd,
|
|
490
|
+
stdio: "inherit"
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
await new Promise((resolve) => child.on("exit", () => resolve()));
|
|
494
|
+
});
|
|
495
|
+
program.command("mcp").description("Run the Sideboard MCP stdio server").action(async () => {
|
|
496
|
+
await startMcpServer();
|
|
497
|
+
});
|
|
498
|
+
const brightsyCmd = program.command("brightsy").description(
|
|
499
|
+
"Brightsy team helpers (wraps `brightsy teams` + Sideboard multi-team MCP state)"
|
|
500
|
+
);
|
|
501
|
+
brightsyCmd.command("teams").alias("accounts").description("List Brightsy teams (via `brightsy teams --json`)").action(async () => {
|
|
502
|
+
const session = await getBrightsySession();
|
|
503
|
+
if (!session.connected) {
|
|
504
|
+
console.error(chalk.red(session.reason || "Not logged in \u2014 brightsy login"));
|
|
505
|
+
process.exitCode = 1;
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const connectedIds = new Set(
|
|
509
|
+
(session.connectedTeams ?? []).map((t) => t.id)
|
|
510
|
+
);
|
|
511
|
+
console.log(
|
|
512
|
+
chalk.dim(
|
|
513
|
+
`Active: ${session.accountSlug || session.accountId} @ ${session.endpoint}`
|
|
514
|
+
)
|
|
515
|
+
);
|
|
516
|
+
console.log(
|
|
517
|
+
chalk.dim(
|
|
518
|
+
`Connected (CLI + MCP): ${(session.connectedTeams ?? []).map((t) => t.slug).join(", ") || "(none)"}`
|
|
519
|
+
)
|
|
520
|
+
);
|
|
521
|
+
for (const a of session.accounts) {
|
|
522
|
+
const mark = a.id === session.accountId ? chalk.green("*") : connectedIds.has(a.id) ? chalk.cyan("+") : " ";
|
|
523
|
+
console.log(
|
|
524
|
+
`${mark} ${a.slug.padEnd(24)} ${a.name}${a.is_personal_account ? chalk.dim(" (personal)") : ""}`
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
console.log(chalk.dim(" * = active (CLI) \xB7 + = connected"));
|
|
528
|
+
});
|
|
529
|
+
brightsyCmd.command("switch").argument("<team>", "team id or slug").description("Connect/activate a team for CLI + MCP (alias of connect-team)").action(async (team) => {
|
|
530
|
+
const session = await switchBrightsyAccount(team);
|
|
531
|
+
const names = (session.connectedTeams ?? []).map((t) => t.slug).join(", ");
|
|
532
|
+
console.log(
|
|
533
|
+
chalk.green(
|
|
534
|
+
`Active: ${session.accountSlug || session.accountId} \xB7 connected: ${names}`
|
|
535
|
+
)
|
|
536
|
+
);
|
|
537
|
+
});
|
|
538
|
+
brightsyCmd.command("connect-team").argument("<team>", "team id or slug").description("Connect a team for Brightsy CLI + MCP (activates it for CLI)").action(async (team) => {
|
|
539
|
+
await connectBrightsyTeam(team);
|
|
540
|
+
const session = await getBrightsySession();
|
|
541
|
+
const names = (session.connectedTeams ?? []).map((t) => t.slug).join(", ");
|
|
542
|
+
console.log(
|
|
543
|
+
chalk.green(
|
|
544
|
+
`Active: ${session.accountSlug || session.accountId} \xB7 connected: ${names}`
|
|
545
|
+
)
|
|
546
|
+
);
|
|
547
|
+
});
|
|
548
|
+
brightsyCmd.command("disconnect-team").argument("<team>", "team id or slug").description("Disconnect a team from Brightsy CLI + MCP selection").action(async (team) => {
|
|
549
|
+
await disconnectBrightsyTeam(team);
|
|
550
|
+
const session = await getBrightsySession();
|
|
551
|
+
const names = (session.connectedTeams ?? []).map((t) => t.slug).join(", ");
|
|
552
|
+
console.log(
|
|
553
|
+
chalk.green(
|
|
554
|
+
names ? `Active: ${session.accountSlug || session.accountId} \xB7 connected: ${names}` : "No teams connected"
|
|
555
|
+
)
|
|
556
|
+
);
|
|
557
|
+
});
|
|
558
|
+
program.command("connect").description(
|
|
559
|
+
"Connect Sideboard to Brightsy cloud (Slack/Discord/Teams \u2014 poll inbound orchestrator tasks across all workspaces)"
|
|
560
|
+
).option(
|
|
561
|
+
"--repo <path>",
|
|
562
|
+
"deprecated \u2014 ignored; cloud connect uses the Global workspace coordinator"
|
|
563
|
+
).option("--agent <agent>", "claude|codex|opencode|cursor", "claude").option("--no-enable-access", "do not auto-enable Brightsy desktop access").option("--no-allow-always", "do not set allow_always when enabling access").option("--poll-ms <ms>", "poll interval", "5000").action(async (opts) => {
|
|
564
|
+
const agent = parseAgent(opts.agent);
|
|
565
|
+
if (agent === "brightsy") {
|
|
566
|
+
throw new Error(
|
|
567
|
+
"connect coordinator cannot use brightsy \u2014 use claude, codex, opencode, or cursor"
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
const ac = new AbortController();
|
|
571
|
+
const stop = () => ac.abort();
|
|
572
|
+
process.on("SIGINT", stop);
|
|
573
|
+
process.on("SIGTERM", stop);
|
|
574
|
+
console.log(
|
|
575
|
+
chalk.bold("Sideboard \u2194 Brightsy"),
|
|
576
|
+
chalk.dim("(Ctrl+C to stop)")
|
|
577
|
+
);
|
|
578
|
+
await runCloudConnect({
|
|
579
|
+
agent,
|
|
580
|
+
enableAccess: opts.enableAccess !== false,
|
|
581
|
+
allowAlways: opts.allowAlways !== false,
|
|
582
|
+
pollIntervalMs: Number(opts.pollMs) || 5e3,
|
|
583
|
+
signal: ac.signal,
|
|
584
|
+
onLog: (line) => console.log(chalk.dim(line))
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
program.command("branches").description("List branches in a repo").option("--repo <path>", "repo path", process.cwd()).option("--all", "include branches already merged into the default branch").action(async (opts) => {
|
|
588
|
+
const repo = await resolveRepoRoot(opts.repo);
|
|
589
|
+
const branches = await listBranches(repo, { unmergedOnly: !opts.all });
|
|
590
|
+
for (const b of branches) {
|
|
591
|
+
console.log(`${b.current ? "*" : " "} ${b.name}${b.remote ? " (remote)" : ""}`);
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
program.command("prs").option("--repo <path>", "repo path", process.cwd()).action(async (opts) => {
|
|
595
|
+
const repo = await resolveRepoRoot(opts.repo);
|
|
596
|
+
const prs = await listPrs(repo);
|
|
597
|
+
for (const p of prs) {
|
|
598
|
+
console.log(
|
|
599
|
+
`#${p.number} ${p.title} ${p.headRefName}${p.isCrossRepository ? " [fork]" : ""}`
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
program.command("issues").option("--repo <path>", "repo path", process.cwd()).option(
|
|
604
|
+
"--agent <agent>",
|
|
605
|
+
"legacy: list via agent Linear MCP (claude|codex|opencode). Omit to use Account connections."
|
|
606
|
+
).action(async (opts) => {
|
|
607
|
+
const repo = await resolveRepoRoot(opts.repo);
|
|
608
|
+
if (opts.agent) {
|
|
609
|
+
const issues = await listLinearIssues(parseAgent(opts.agent), repo);
|
|
610
|
+
console.log(JSON.stringify(issues, null, 2));
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
const result = await listIssues(repo);
|
|
614
|
+
console.log(JSON.stringify(result, null, 2));
|
|
615
|
+
});
|
|
616
|
+
await program.parseAsync(process.argv);
|
|
617
|
+
}
|
|
618
|
+
function statusColor(status) {
|
|
619
|
+
switch (status) {
|
|
620
|
+
case "running":
|
|
621
|
+
return chalk.green(status.padEnd(9));
|
|
622
|
+
case "queued":
|
|
623
|
+
return chalk.yellow(status.padEnd(9));
|
|
624
|
+
case "error":
|
|
625
|
+
case "broken":
|
|
626
|
+
return chalk.red(status.padEnd(9));
|
|
627
|
+
case "archived":
|
|
628
|
+
return chalk.dim(status.padEnd(9));
|
|
629
|
+
default:
|
|
630
|
+
return status.padEnd(9);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
main().catch((err) => {
|
|
634
|
+
console.error(chalk.red(err instanceof Error ? err.message : String(err)));
|
|
635
|
+
process.exit(1);
|
|
636
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sideboard-ai/cli",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "Sideboard CLI — agent-agnostic worktree orchestration (includes `sideboard mcp`)",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"sideboard": "./dist/index.js",
|
|
9
|
+
"side": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"chalk": "^5.4.1",
|
|
17
|
+
"commander": "^13.1.0",
|
|
18
|
+
"ora": "^8.2.0",
|
|
19
|
+
"@sideboard-ai/core": "0.1.9"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^22.13.10",
|
|
23
|
+
"tsup": "^8.4.0",
|
|
24
|
+
"tsx": "^4.19.3",
|
|
25
|
+
"typescript": "^5.8.2",
|
|
26
|
+
"vitest": "^3.0.9"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/mattlevine/sideboard.git",
|
|
34
|
+
"directory": "packages/cli"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"sideboard",
|
|
38
|
+
"cli",
|
|
39
|
+
"mcp",
|
|
40
|
+
"agents",
|
|
41
|
+
"worktree"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup",
|
|
45
|
+
"start": "tsx src/index.ts",
|
|
46
|
+
"dev": "tsx watch src/index.ts",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"test": "vitest run --passWithNoTests"
|
|
49
|
+
}
|
|
50
|
+
}
|