branch-nexus 1.0.0
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 +21 -0
- package/README.md +190 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3651 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +326 -0
- package/dist/index.js +3661 -0
- package/dist/index.js.map +1 -0
- package/package.json +79 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const LayoutSchema: z.ZodEnum<["horizontal", "vertical", "grid"]>;
|
|
4
|
+
type Layout = z.infer<typeof LayoutSchema>;
|
|
5
|
+
declare const CleanupPolicySchema: z.ZodEnum<["session", "persistent"]>;
|
|
6
|
+
type CleanupPolicy = z.infer<typeof CleanupPolicySchema>;
|
|
7
|
+
declare const ColorThemeSchema: z.ZodEnum<["cyan", "green", "magenta", "blue", "yellow", "red"]>;
|
|
8
|
+
type ColorTheme = z.infer<typeof ColorThemeSchema>;
|
|
9
|
+
declare const TerminalRuntimeSchema: z.ZodEnum<["wsl", "powershell", "native"]>;
|
|
10
|
+
type TerminalRuntime = z.infer<typeof TerminalRuntimeSchema>;
|
|
11
|
+
declare const RepositoryCacheEntrySchema: z.ZodObject<{
|
|
12
|
+
full_name: z.ZodString;
|
|
13
|
+
clone_url: z.ZodString;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
full_name: string;
|
|
16
|
+
clone_url: string;
|
|
17
|
+
}, {
|
|
18
|
+
full_name: string;
|
|
19
|
+
clone_url: string;
|
|
20
|
+
}>;
|
|
21
|
+
type RepositoryCacheEntry = z.infer<typeof RepositoryCacheEntrySchema>;
|
|
22
|
+
declare const PresetConfigSchema: z.ZodObject<{
|
|
23
|
+
layout: z.ZodEnum<["horizontal", "vertical", "grid"]>;
|
|
24
|
+
panes: z.ZodNumber;
|
|
25
|
+
cleanup: z.ZodEnum<["session", "persistent"]>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
layout: "horizontal" | "vertical" | "grid";
|
|
28
|
+
panes: number;
|
|
29
|
+
cleanup: "session" | "persistent";
|
|
30
|
+
}, {
|
|
31
|
+
layout: "horizontal" | "vertical" | "grid";
|
|
32
|
+
panes: number;
|
|
33
|
+
cleanup: "session" | "persistent";
|
|
34
|
+
}>;
|
|
35
|
+
type PresetConfig = z.infer<typeof PresetConfigSchema>;
|
|
36
|
+
declare const AppConfigSchema: z.ZodObject<{
|
|
37
|
+
defaultRoot: z.ZodDefault<z.ZodString>;
|
|
38
|
+
remoteRepoUrl: z.ZodDefault<z.ZodString>;
|
|
39
|
+
githubToken: z.ZodDefault<z.ZodString>;
|
|
40
|
+
githubRepositoriesCache: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
41
|
+
full_name: z.ZodString;
|
|
42
|
+
clone_url: z.ZodString;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
full_name: string;
|
|
45
|
+
clone_url: string;
|
|
46
|
+
}, {
|
|
47
|
+
full_name: string;
|
|
48
|
+
clone_url: string;
|
|
49
|
+
}>, "many">>;
|
|
50
|
+
githubBranchesCache: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
51
|
+
defaultLayout: z.ZodDefault<z.ZodEnum<["horizontal", "vertical", "grid"]>>;
|
|
52
|
+
defaultPanes: z.ZodDefault<z.ZodNumber>;
|
|
53
|
+
cleanupPolicy: z.ZodDefault<z.ZodEnum<["session", "persistent"]>>;
|
|
54
|
+
tmuxAutoInstall: z.ZodDefault<z.ZodBoolean>;
|
|
55
|
+
wslDistribution: z.ZodDefault<z.ZodString>;
|
|
56
|
+
terminalDefaultRuntime: z.ZodDefault<z.ZodEnum<["wsl", "powershell", "native"]>>;
|
|
57
|
+
terminalMaxCount: z.ZodDefault<z.ZodNumber>;
|
|
58
|
+
sessionRestoreEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
59
|
+
lastSession: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
60
|
+
colorTheme: z.ZodDefault<z.ZodEnum<["cyan", "green", "magenta", "blue", "yellow", "red"]>>;
|
|
61
|
+
presets: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
62
|
+
layout: z.ZodEnum<["horizontal", "vertical", "grid"]>;
|
|
63
|
+
panes: z.ZodNumber;
|
|
64
|
+
cleanup: z.ZodEnum<["session", "persistent"]>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
layout: "horizontal" | "vertical" | "grid";
|
|
67
|
+
panes: number;
|
|
68
|
+
cleanup: "session" | "persistent";
|
|
69
|
+
}, {
|
|
70
|
+
layout: "horizontal" | "vertical" | "grid";
|
|
71
|
+
panes: number;
|
|
72
|
+
cleanup: "session" | "persistent";
|
|
73
|
+
}>>>;
|
|
74
|
+
commandHooks: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
defaultRoot: string;
|
|
77
|
+
remoteRepoUrl: string;
|
|
78
|
+
githubToken: string;
|
|
79
|
+
githubRepositoriesCache: {
|
|
80
|
+
full_name: string;
|
|
81
|
+
clone_url: string;
|
|
82
|
+
}[];
|
|
83
|
+
githubBranchesCache: Record<string, string[]>;
|
|
84
|
+
defaultLayout: "horizontal" | "vertical" | "grid";
|
|
85
|
+
defaultPanes: number;
|
|
86
|
+
cleanupPolicy: "session" | "persistent";
|
|
87
|
+
tmuxAutoInstall: boolean;
|
|
88
|
+
wslDistribution: string;
|
|
89
|
+
terminalDefaultRuntime: "wsl" | "powershell" | "native";
|
|
90
|
+
terminalMaxCount: number;
|
|
91
|
+
sessionRestoreEnabled: boolean;
|
|
92
|
+
lastSession: Record<string, unknown>;
|
|
93
|
+
colorTheme: "cyan" | "green" | "magenta" | "blue" | "yellow" | "red";
|
|
94
|
+
presets: Record<string, {
|
|
95
|
+
layout: "horizontal" | "vertical" | "grid";
|
|
96
|
+
panes: number;
|
|
97
|
+
cleanup: "session" | "persistent";
|
|
98
|
+
}>;
|
|
99
|
+
commandHooks: Record<string, string[]>;
|
|
100
|
+
}, {
|
|
101
|
+
defaultRoot?: string | undefined;
|
|
102
|
+
remoteRepoUrl?: string | undefined;
|
|
103
|
+
githubToken?: string | undefined;
|
|
104
|
+
githubRepositoriesCache?: {
|
|
105
|
+
full_name: string;
|
|
106
|
+
clone_url: string;
|
|
107
|
+
}[] | undefined;
|
|
108
|
+
githubBranchesCache?: Record<string, string[]> | undefined;
|
|
109
|
+
defaultLayout?: "horizontal" | "vertical" | "grid" | undefined;
|
|
110
|
+
defaultPanes?: number | undefined;
|
|
111
|
+
cleanupPolicy?: "session" | "persistent" | undefined;
|
|
112
|
+
tmuxAutoInstall?: boolean | undefined;
|
|
113
|
+
wslDistribution?: string | undefined;
|
|
114
|
+
terminalDefaultRuntime?: "wsl" | "powershell" | "native" | undefined;
|
|
115
|
+
terminalMaxCount?: number | undefined;
|
|
116
|
+
sessionRestoreEnabled?: boolean | undefined;
|
|
117
|
+
lastSession?: Record<string, unknown> | undefined;
|
|
118
|
+
colorTheme?: "cyan" | "green" | "magenta" | "blue" | "yellow" | "red" | undefined;
|
|
119
|
+
presets?: Record<string, {
|
|
120
|
+
layout: "horizontal" | "vertical" | "grid";
|
|
121
|
+
panes: number;
|
|
122
|
+
cleanup: "session" | "persistent";
|
|
123
|
+
}> | undefined;
|
|
124
|
+
commandHooks?: Record<string, string[]> | undefined;
|
|
125
|
+
}>;
|
|
126
|
+
type AppConfig = z.infer<typeof AppConfigSchema>;
|
|
127
|
+
declare const DEFAULT_CONFIG: AppConfig;
|
|
128
|
+
|
|
129
|
+
declare enum ExitCode {
|
|
130
|
+
SUCCESS = 0,
|
|
131
|
+
INVALID_ARGS = 2,
|
|
132
|
+
CONFIG_ERROR = 3,
|
|
133
|
+
RUNTIME_ERROR = 4,
|
|
134
|
+
GIT_ERROR = 5,
|
|
135
|
+
TMUX_ERROR = 6,
|
|
136
|
+
VALIDATION_ERROR = 7,
|
|
137
|
+
UNSUPPORTED_PLATFORM = 8
|
|
138
|
+
}
|
|
139
|
+
declare class BranchNexusError extends Error {
|
|
140
|
+
readonly code: ExitCode;
|
|
141
|
+
readonly hint: string;
|
|
142
|
+
constructor(message: string, code?: ExitCode, hint?: string);
|
|
143
|
+
toString(): string;
|
|
144
|
+
}
|
|
145
|
+
declare function userFacingError(message: string, hint?: string): string;
|
|
146
|
+
|
|
147
|
+
interface WorktreeAssignment {
|
|
148
|
+
pane: number;
|
|
149
|
+
repoPath: string;
|
|
150
|
+
branch: string;
|
|
151
|
+
}
|
|
152
|
+
interface ManagedWorktree {
|
|
153
|
+
pane: number;
|
|
154
|
+
repoPath: string;
|
|
155
|
+
branch: string;
|
|
156
|
+
path: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
declare function getConfigPath(): string;
|
|
160
|
+
declare function loadConfig(): AppConfig;
|
|
161
|
+
declare function saveConfig(config: AppConfig): void;
|
|
162
|
+
|
|
163
|
+
declare function savePreset(name: string, preset: PresetConfig): void;
|
|
164
|
+
declare function loadPresets(): Record<string, PresetConfig>;
|
|
165
|
+
declare function applyPreset(name: string): PresetConfig;
|
|
166
|
+
declare function deletePreset(name: string): void;
|
|
167
|
+
declare function renamePreset(oldName: string, newName: string): void;
|
|
168
|
+
|
|
169
|
+
interface OrchestrationRequest {
|
|
170
|
+
distribution: string;
|
|
171
|
+
availableDistributions: string[];
|
|
172
|
+
layout: Layout;
|
|
173
|
+
cleanupPolicy: CleanupPolicy;
|
|
174
|
+
assignments: WorktreeAssignment[];
|
|
175
|
+
worktreeBase: string;
|
|
176
|
+
sessionName?: string;
|
|
177
|
+
tmuxAutoInstall: boolean;
|
|
178
|
+
colorTheme?: ColorTheme;
|
|
179
|
+
paneNames?: string[];
|
|
180
|
+
displayBranches?: string[];
|
|
181
|
+
startupCommands?: string[];
|
|
182
|
+
}
|
|
183
|
+
interface OrchestrationResult {
|
|
184
|
+
worktrees: ManagedWorktree[];
|
|
185
|
+
executedCommands: string[][];
|
|
186
|
+
}
|
|
187
|
+
declare function orchestrate(request: OrchestrationRequest): Promise<OrchestrationResult>;
|
|
188
|
+
|
|
189
|
+
declare class WorktreeManager {
|
|
190
|
+
private baseDir;
|
|
191
|
+
private cleanupPolicy;
|
|
192
|
+
private posixMode;
|
|
193
|
+
private managed;
|
|
194
|
+
constructor(baseDir: string, cleanupPolicy?: CleanupPolicy);
|
|
195
|
+
setPosixMode(enabled: boolean): void;
|
|
196
|
+
private safe;
|
|
197
|
+
private asPosix;
|
|
198
|
+
private commandPath;
|
|
199
|
+
buildWorktreePath(assignment: WorktreeAssignment): string;
|
|
200
|
+
addWorktree(assignment: WorktreeAssignment, distribution?: string): Promise<ManagedWorktree>;
|
|
201
|
+
private getCurrentBranch;
|
|
202
|
+
materialize(assignments: WorktreeAssignment[], distribution?: string): Promise<ManagedWorktree[]>;
|
|
203
|
+
checkDirty(worktree: ManagedWorktree, distribution?: string): Promise<boolean>;
|
|
204
|
+
cleanup(options?: {
|
|
205
|
+
force?: boolean;
|
|
206
|
+
selected?: ManagedWorktree[];
|
|
207
|
+
ignorePolicy?: boolean;
|
|
208
|
+
distribution?: string;
|
|
209
|
+
}): Promise<string[]>;
|
|
210
|
+
getManaged(): ManagedWorktree[];
|
|
211
|
+
getCleanupPolicy(): CleanupPolicy;
|
|
212
|
+
private isUnderBaseDir;
|
|
213
|
+
private getWorktreesForBranch;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
interface BranchListResult {
|
|
217
|
+
branches: string[];
|
|
218
|
+
warning?: string;
|
|
219
|
+
}
|
|
220
|
+
declare function listLocalBranches(repoPath: string): Promise<BranchListResult>;
|
|
221
|
+
|
|
222
|
+
declare function validateLayout(layout: string, panes: number): void;
|
|
223
|
+
declare function buildLayoutCommands(sessionName: string, layout: Layout, panePaths: string[], colorTheme?: ColorTheme, paneBranches?: string[], paneNames?: string[], startupCommands?: string[]): string[][];
|
|
224
|
+
|
|
225
|
+
declare function startSession(sessionName: string, commands: string[][], distribution?: string): Promise<void>;
|
|
226
|
+
declare function killSession(sessionName: string, distribution?: string): Promise<void>;
|
|
227
|
+
declare function sessionExists(sessionName: string, distribution?: string): Promise<boolean>;
|
|
228
|
+
declare function attachSession(sessionName: string, distribution?: string): Promise<void>;
|
|
229
|
+
declare function listSessions(distribution?: string): Promise<string[]>;
|
|
230
|
+
|
|
231
|
+
declare enum Platform {
|
|
232
|
+
WINDOWS = "windows",
|
|
233
|
+
MACOS = "macos",
|
|
234
|
+
LINUX = "linux"
|
|
235
|
+
}
|
|
236
|
+
declare function detectPlatform(): Platform;
|
|
237
|
+
declare function hasTmux(): Promise<boolean>;
|
|
238
|
+
declare function expandHomeDir(filepath: string): string;
|
|
239
|
+
|
|
240
|
+
declare function listDistributions(): Promise<string[]>;
|
|
241
|
+
declare function buildWslCommand(distribution: string, command: string[]): string[];
|
|
242
|
+
declare function toWslPath(distribution: string, hostPath: string): Promise<string>;
|
|
243
|
+
|
|
244
|
+
interface ShellResult {
|
|
245
|
+
exitCode: number;
|
|
246
|
+
stdout: string;
|
|
247
|
+
stderr: string;
|
|
248
|
+
}
|
|
249
|
+
interface RunCommandOptions {
|
|
250
|
+
cwd?: string;
|
|
251
|
+
timeout?: number;
|
|
252
|
+
captureOutput?: boolean;
|
|
253
|
+
input?: string;
|
|
254
|
+
}
|
|
255
|
+
declare function runCommand$1(command: string[], options?: RunCommandOptions): Promise<ShellResult>;
|
|
256
|
+
declare function runCommandViaWSL(distribution: string, command: string[], options?: RunCommandOptions): Promise<ShellResult>;
|
|
257
|
+
|
|
258
|
+
interface RunOptions {
|
|
259
|
+
root?: string;
|
|
260
|
+
layout?: Layout;
|
|
261
|
+
panes?: number;
|
|
262
|
+
cleanup?: CleanupPolicy;
|
|
263
|
+
fresh?: boolean;
|
|
264
|
+
terminalTemplate?: string;
|
|
265
|
+
maxTerminals?: number;
|
|
266
|
+
logLevel?: string;
|
|
267
|
+
logFile?: string;
|
|
268
|
+
session?: string;
|
|
269
|
+
hooks?: boolean;
|
|
270
|
+
}
|
|
271
|
+
declare function runCommand(options: RunOptions): Promise<void>;
|
|
272
|
+
|
|
273
|
+
declare function configCommand(action?: string, key?: string, value?: string): void;
|
|
274
|
+
|
|
275
|
+
declare function killCommand(sessionName?: string): Promise<void>;
|
|
276
|
+
|
|
277
|
+
declare function presetCommand(action?: string, name?: string, extra?: string): void;
|
|
278
|
+
|
|
279
|
+
declare function statusCommand(): Promise<void>;
|
|
280
|
+
|
|
281
|
+
declare function attachCommand(sessionName?: string): Promise<void>;
|
|
282
|
+
|
|
283
|
+
declare function initCommand(): Promise<void>;
|
|
284
|
+
|
|
285
|
+
interface HookExecution {
|
|
286
|
+
command: string;
|
|
287
|
+
success: boolean;
|
|
288
|
+
returncode: number;
|
|
289
|
+
output: string;
|
|
290
|
+
}
|
|
291
|
+
interface HookRunResult {
|
|
292
|
+
pane: number;
|
|
293
|
+
executions: HookExecution[];
|
|
294
|
+
hasFailures: boolean;
|
|
295
|
+
}
|
|
296
|
+
declare class HookRunner {
|
|
297
|
+
private timeoutSeconds;
|
|
298
|
+
private trustedConfig;
|
|
299
|
+
private allowCommandPrefixes;
|
|
300
|
+
constructor(options?: {
|
|
301
|
+
timeoutSeconds?: number;
|
|
302
|
+
trustedConfig?: boolean;
|
|
303
|
+
allowCommandPrefixes?: string[];
|
|
304
|
+
});
|
|
305
|
+
private isCommandAllowed;
|
|
306
|
+
run(pane: number, commands: string[], distribution?: string): Promise<HookRunResult>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface GitHubRepo {
|
|
310
|
+
fullName: string;
|
|
311
|
+
cloneUrl: string;
|
|
312
|
+
}
|
|
313
|
+
interface GitHubBranch {
|
|
314
|
+
name: string;
|
|
315
|
+
isDefault: boolean;
|
|
316
|
+
}
|
|
317
|
+
declare class GitHubClient {
|
|
318
|
+
private token;
|
|
319
|
+
constructor(token?: string);
|
|
320
|
+
private fetch;
|
|
321
|
+
listRepositories(): Promise<GitHubRepo[]>;
|
|
322
|
+
listBranches(owner: string, repo: string): Promise<GitHubBranch[]>;
|
|
323
|
+
getDefaultBranch(owner: string, repo: string): Promise<string>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export { type AppConfig, type BranchListResult, BranchNexusError, type CleanupPolicy, DEFAULT_CONFIG, ExitCode, type GitHubBranch, GitHubClient, type GitHubRepo, type HookExecution, type HookRunResult, HookRunner, type Layout, type OrchestrationRequest, type OrchestrationResult, Platform, type PresetConfig, type RepositoryCacheEntry, type ShellResult, type TerminalRuntime, WorktreeManager, applyPreset, attachCommand, attachSession, buildLayoutCommands, buildWslCommand, configCommand, deletePreset, detectPlatform, expandHomeDir, getConfigPath, hasTmux, initCommand, killCommand, killSession, listDistributions, listLocalBranches, listSessions, loadConfig, loadPresets, orchestrate, presetCommand, renamePreset, runCommand as run, runCommand$1 as runCommand, runCommandViaWSL, saveConfig, savePreset, sessionExists, startSession, statusCommand, toWslPath, userFacingError, validateLayout };
|