@camerontaylor/paseo-cli 0.8.0-fork.1
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/bin/paseo +3 -0
- package/dist/classify.d.ts +19 -0
- package/dist/classify.js +49 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +135 -0
- package/dist/commands/agent/archive.d.ts +18 -0
- package/dist/commands/agent/archive.js +102 -0
- package/dist/commands/agent/attach.d.ts +11 -0
- package/dist/commands/agent/attach.js +161 -0
- package/dist/commands/agent/delete.d.ts +15 -0
- package/dist/commands/agent/delete.js +107 -0
- package/dist/commands/agent/detach.d.ts +9 -0
- package/dist/commands/agent/detach.js +38 -0
- package/dist/commands/agent/import.d.ts +14 -0
- package/dist/commands/agent/import.js +122 -0
- package/dist/commands/agent/index.d.ts +3 -0
- package/dist/commands/agent/index.js +56 -0
- package/dist/commands/agent/inspect.d.ts +15 -0
- package/dist/commands/agent/inspect.js +209 -0
- package/dist/commands/agent/logs.d.ts +19 -0
- package/dist/commands/agent/logs.js +180 -0
- package/dist/commands/agent/ls.d.ts +44 -0
- package/dist/commands/agent/ls.js +212 -0
- package/dist/commands/agent/mode.d.ts +18 -0
- package/dist/commands/agent/mode.js +100 -0
- package/dist/commands/agent/open.d.ts +11 -0
- package/dist/commands/agent/open.js +61 -0
- package/dist/commands/agent/reload.d.ts +15 -0
- package/dist/commands/agent/reload.js +75 -0
- package/dist/commands/agent/run.d.ts +78 -0
- package/dist/commands/agent/run.js +554 -0
- package/dist/commands/agent/send.d.ts +19 -0
- package/dist/commands/agent/send.js +187 -0
- package/dist/commands/agent/stop.d.ts +17 -0
- package/dist/commands/agent/stop.js +115 -0
- package/dist/commands/agent/update.d.ts +51 -0
- package/dist/commands/agent/update.js +186 -0
- package/dist/commands/agent/wait.d.ts +17 -0
- package/dist/commands/agent/wait.js +158 -0
- package/dist/commands/clone.d.ts +17 -0
- package/dist/commands/clone.js +65 -0
- package/dist/commands/daemon/index.d.ts +3 -0
- package/dist/commands/daemon/index.js +60 -0
- package/dist/commands/daemon/local-daemon.d.ts +78 -0
- package/dist/commands/daemon/local-daemon.js +547 -0
- package/dist/commands/daemon/pair.d.ts +35 -0
- package/dist/commands/daemon/pair.js +167 -0
- package/dist/commands/daemon/reload.d.ts +10 -0
- package/dist/commands/daemon/reload.js +36 -0
- package/dist/commands/daemon/restart.d.ts +12 -0
- package/dist/commands/daemon/restart.js +99 -0
- package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
- package/dist/commands/daemon/runtime-toolchain.js +87 -0
- package/dist/commands/daemon/set-password.d.ts +17 -0
- package/dist/commands/daemon/set-password.js +82 -0
- package/dist/commands/daemon/start.d.ts +6 -0
- package/dist/commands/daemon/start.js +57 -0
- package/dist/commands/daemon/status.d.ts +21 -0
- package/dist/commands/daemon/status.js +363 -0
- package/dist/commands/daemon/stop.d.ts +15 -0
- package/dist/commands/daemon/stop.js +60 -0
- package/dist/commands/heartbeat/index.d.ts +3 -0
- package/dist/commands/heartbeat/index.js +139 -0
- package/dist/commands/hooks.d.ts +19 -0
- package/dist/commands/hooks.js +89 -0
- package/dist/commands/hub/authority.d.ts +17 -0
- package/dist/commands/hub/authority.js +18 -0
- package/dist/commands/hub/connect.d.ts +23 -0
- package/dist/commands/hub/connect.js +44 -0
- package/dist/commands/hub/credentials.d.ts +21 -0
- package/dist/commands/hub/credentials.js +143 -0
- package/dist/commands/hub/daemon-client.d.ts +40 -0
- package/dist/commands/hub/daemon-client.js +14 -0
- package/dist/commands/hub/deploy-bundle.d.ts +16 -0
- package/dist/commands/hub/deploy-bundle.js +248 -0
- package/dist/commands/hub/deploy-triggers.d.ts +6 -0
- package/dist/commands/hub/deploy-triggers.js +116 -0
- package/dist/commands/hub/deploy.d.ts +50 -0
- package/dist/commands/hub/deploy.js +159 -0
- package/dist/commands/hub/disconnect.d.ts +16 -0
- package/dist/commands/hub/disconnect.js +24 -0
- package/dist/commands/hub/error.d.ts +6 -0
- package/dist/commands/hub/error.js +9 -0
- package/dist/commands/hub/export.d.ts +28 -0
- package/dist/commands/hub/export.js +80 -0
- package/dist/commands/hub/help.d.ts +3 -0
- package/dist/commands/hub/help.js +5 -0
- package/dist/commands/hub/hub-client/index.d.ts +22 -0
- package/dist/commands/hub/hub-client/index.js +135 -0
- package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
- package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
- package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
- package/dist/commands/hub/hub-client/internal/problem.js +85 -0
- package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
- package/dist/commands/hub/hub-client/internal/transport.js +30 -0
- package/dist/commands/hub/index.d.ts +20 -0
- package/dist/commands/hub/index.js +94 -0
- package/dist/commands/hub/init-plan.d.ts +33 -0
- package/dist/commands/hub/init-plan.js +94 -0
- package/dist/commands/hub/init.d.ts +35 -0
- package/dist/commands/hub/init.js +524 -0
- package/dist/commands/hub/login-flow.d.ts +34 -0
- package/dist/commands/hub/login-flow.js +78 -0
- package/dist/commands/hub/login.d.ts +23 -0
- package/dist/commands/hub/login.js +40 -0
- package/dist/commands/hub/logout.d.ts +32 -0
- package/dist/commands/hub/logout.js +71 -0
- package/dist/commands/hub/origin.d.ts +2 -0
- package/dist/commands/hub/origin.js +27 -0
- package/dist/commands/hub/permissions.d.ts +21 -0
- package/dist/commands/hub/permissions.js +61 -0
- package/dist/commands/hub/projects.d.ts +24 -0
- package/dist/commands/hub/projects.js +49 -0
- package/dist/commands/hub/reporter.d.ts +10 -0
- package/dist/commands/hub/reporter.js +11 -0
- package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
- package/dist/commands/hub/starter-agent-runtime.js +49 -0
- package/dist/commands/hub/starter-trigger.d.ts +10 -0
- package/dist/commands/hub/starter-trigger.js +30 -0
- package/dist/commands/hub/status-output.d.ts +13 -0
- package/dist/commands/hub/status-output.js +30 -0
- package/dist/commands/onboard.d.ts +10 -0
- package/dist/commands/onboard.js +400 -0
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.js +89 -0
- package/dist/commands/permit/allow.d.ts +20 -0
- package/dist/commands/permit/allow.js +133 -0
- package/dist/commands/permit/deny.d.ts +12 -0
- package/dist/commands/permit/deny.js +105 -0
- package/dist/commands/permit/index.d.ts +3 -0
- package/dist/commands/permit/index.js +27 -0
- package/dist/commands/permit/ls.d.ts +18 -0
- package/dist/commands/permit/ls.js +66 -0
- package/dist/commands/plugin/index.d.ts +17 -0
- package/dist/commands/plugin/index.js +138 -0
- package/dist/commands/plugin/scaffold.d.ts +6 -0
- package/dist/commands/plugin/scaffold.js +162 -0
- package/dist/commands/plugin/shared.d.ts +5 -0
- package/dist/commands/plugin/shared.js +30 -0
- package/dist/commands/project/create.d.ts +10 -0
- package/dist/commands/project/create.js +41 -0
- package/dist/commands/project/delete.d.ts +9 -0
- package/dist/commands/project/delete.js +33 -0
- package/dist/commands/project/index.d.ts +3 -0
- package/dist/commands/project/index.js +28 -0
- package/dist/commands/project/ls.d.ts +5 -0
- package/dist/commands/project/ls.js +19 -0
- package/dist/commands/project/rename.d.ts +15 -0
- package/dist/commands/project/rename.js +50 -0
- package/dist/commands/project/shared.d.ts +11 -0
- package/dist/commands/project/shared.js +18 -0
- package/dist/commands/provider/add.d.ts +30 -0
- package/dist/commands/provider/add.js +123 -0
- package/dist/commands/provider/diagnostic.d.ts +12 -0
- package/dist/commands/provider/diagnostic.js +31 -0
- package/dist/commands/provider/index.d.ts +3 -0
- package/dist/commands/provider/index.js +38 -0
- package/dist/commands/provider/ls.d.ts +20 -0
- package/dist/commands/provider/ls.js +76 -0
- package/dist/commands/provider/models.d.ts +20 -0
- package/dist/commands/provider/models.js +53 -0
- package/dist/commands/provider/rm.d.ts +10 -0
- package/dist/commands/provider/rm.js +45 -0
- package/dist/commands/provider/shared.d.ts +7 -0
- package/dist/commands/provider/shared.js +10 -0
- package/dist/commands/schedule/create.d.ts +19 -0
- package/dist/commands/schedule/create.js +41 -0
- package/dist/commands/schedule/delete.d.ts +10 -0
- package/dist/commands/schedule/delete.js +32 -0
- package/dist/commands/schedule/index.d.ts +3 -0
- package/dist/commands/schedule/index.js +66 -0
- package/dist/commands/schedule/inspect.d.ts +6 -0
- package/dist/commands/schedule/inspect.js +27 -0
- package/dist/commands/schedule/logs.d.ts +6 -0
- package/dist/commands/schedule/logs.js +24 -0
- package/dist/commands/schedule/ls.d.ts +5 -0
- package/dist/commands/schedule/ls.js +25 -0
- package/dist/commands/schedule/pause.d.ts +5 -0
- package/dist/commands/schedule/pause.js +24 -0
- package/dist/commands/schedule/resume.d.ts +5 -0
- package/dist/commands/schedule/resume.js +24 -0
- package/dist/commands/schedule/run-once.d.ts +5 -0
- package/dist/commands/schedule/run-once.js +24 -0
- package/dist/commands/schedule/schema.d.ts +21 -0
- package/dist/commands/schedule/schema.js +67 -0
- package/dist/commands/schedule/shared.d.ts +59 -0
- package/dist/commands/schedule/shared.js +358 -0
- package/dist/commands/schedule/types.d.ts +165 -0
- package/dist/commands/schedule/types.js +2 -0
- package/dist/commands/schedule/update.d.ts +21 -0
- package/dist/commands/schedule/update.js +40 -0
- package/dist/commands/script/index.d.ts +3 -0
- package/dist/commands/script/index.js +19 -0
- package/dist/commands/script/ls.d.ts +6 -0
- package/dist/commands/script/ls.js +20 -0
- package/dist/commands/script/schema.d.ts +5 -0
- package/dist/commands/script/schema.js +13 -0
- package/dist/commands/script/shared.d.ts +11 -0
- package/dist/commands/script/shared.js +59 -0
- package/dist/commands/script/start.d.ts +6 -0
- package/dist/commands/script/start.js +23 -0
- package/dist/commands/script/stop.d.ts +6 -0
- package/dist/commands/script/stop.js +23 -0
- package/dist/commands/speech/index.d.ts +3 -0
- package/dist/commands/speech/index.js +5 -0
- package/dist/commands/terminal/capture.d.ts +10 -0
- package/dist/commands/terminal/capture.js +68 -0
- package/dist/commands/terminal/create.d.ts +11 -0
- package/dist/commands/terminal/create.js +29 -0
- package/dist/commands/terminal/index.d.ts +3 -0
- package/dist/commands/terminal/index.js +45 -0
- package/dist/commands/terminal/kill.d.ts +6 -0
- package/dist/commands/terminal/kill.js +36 -0
- package/dist/commands/terminal/ls.d.ts +11 -0
- package/dist/commands/terminal/ls.js +21 -0
- package/dist/commands/terminal/schema.d.ts +10 -0
- package/dist/commands/terminal/schema.js +17 -0
- package/dist/commands/terminal/send-keys.d.ts +7 -0
- package/dist/commands/terminal/send-keys.js +45 -0
- package/dist/commands/terminal/shared.d.ts +12 -0
- package/dist/commands/terminal/shared.js +62 -0
- package/dist/commands/workspace/archive.d.ts +12 -0
- package/dist/commands/workspace/archive.js +41 -0
- package/dist/commands/workspace/create.d.ts +49 -0
- package/dist/commands/workspace/create.js +114 -0
- package/dist/commands/workspace/index.d.ts +3 -0
- package/dist/commands/workspace/index.js +45 -0
- package/dist/commands/workspace/ls.d.ts +7 -0
- package/dist/commands/workspace/ls.js +28 -0
- package/dist/commands/workspace/rename.d.ts +22 -0
- package/dist/commands/workspace/rename.js +61 -0
- package/dist/commands/workspace/setup.d.ts +11 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/commands/workspace/shared.d.ts +12 -0
- package/dist/commands/workspace/shared.js +20 -0
- package/dist/commands/worktree/archive.d.ts +20 -0
- package/dist/commands/worktree/archive.js +104 -0
- package/dist/commands/worktree/create-input.d.ts +15 -0
- package/dist/commands/worktree/create-input.js +56 -0
- package/dist/commands/worktree/create.d.ts +11 -0
- package/dist/commands/worktree/create.js +58 -0
- package/dist/commands/worktree/index.d.ts +3 -0
- package/dist/commands/worktree/index.js +25 -0
- package/dist/commands/worktree/ls.d.ts +19 -0
- package/dist/commands/worktree/ls.js +97 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/output/index.d.ts +45 -0
- package/dist/output/index.js +47 -0
- package/dist/output/json.d.ts +11 -0
- package/dist/output/json.js +37 -0
- package/dist/output/pairing.d.ts +8 -0
- package/dist/output/pairing.js +24 -0
- package/dist/output/quiet.d.ts +9 -0
- package/dist/output/quiet.js +22 -0
- package/dist/output/render.d.ts +15 -0
- package/dist/output/render.js +84 -0
- package/dist/output/table.d.ts +13 -0
- package/dist/output/table.js +135 -0
- package/dist/output/types.d.ts +73 -0
- package/dist/output/types.js +8 -0
- package/dist/output/with-output.d.ts +41 -0
- package/dist/output/with-output.js +85 -0
- package/dist/output/yaml.d.ts +11 -0
- package/dist/output/yaml.js +38 -0
- package/dist/run.d.ts +14 -0
- package/dist/run.js +40 -0
- package/dist/ssh/ssh-tunnel.d.ts +9 -0
- package/dist/ssh/ssh-tunnel.js +79 -0
- package/dist/utils/client-id.d.ts +2 -0
- package/dist/utils/client-id.js +37 -0
- package/dist/utils/client.d.ts +54 -0
- package/dist/utils/client.js +363 -0
- package/dist/utils/command-options.d.ts +7 -0
- package/dist/utils/command-options.js +25 -0
- package/dist/utils/duration.d.ts +7 -0
- package/dist/utils/duration.js +39 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.js +10 -0
- package/dist/utils/paths.d.ts +12 -0
- package/dist/utils/paths.js +22 -0
- package/dist/utils/provider-model.d.ts +11 -0
- package/dist/utils/provider-model.js +49 -0
- package/dist/utils/timeline.d.ts +11 -0
- package/dist/utils/timeline.js +11 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +10 -0
- package/package.json +50 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
2
|
+
import { toWorkspaceRow, workspaceSchema } from "./shared.js";
|
|
3
|
+
function assertOptionsAbsent(values, message) {
|
|
4
|
+
if (values.some((value) => value !== undefined)) {
|
|
5
|
+
throw new Error(message);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function buildLocalWorkspaceSource(options, path) {
|
|
9
|
+
assertOptionsAbsent([
|
|
10
|
+
options.mode,
|
|
11
|
+
options.worktreeSlug,
|
|
12
|
+
options.newBranch,
|
|
13
|
+
options.base,
|
|
14
|
+
options.branch,
|
|
15
|
+
options.prNumber,
|
|
16
|
+
options.forge,
|
|
17
|
+
], "Worktree options require --isolation worktree");
|
|
18
|
+
return {
|
|
19
|
+
kind: "directory",
|
|
20
|
+
path,
|
|
21
|
+
...(options.project ? { projectId: options.project } : {}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function buildBranchOffSource(options, source) {
|
|
25
|
+
assertOptionsAbsent([options.branch, options.prNumber, options.forge], "--branch, --pr-number, and --forge require a checkout mode");
|
|
26
|
+
return {
|
|
27
|
+
...source,
|
|
28
|
+
action: "branch-off",
|
|
29
|
+
...(options.newBranch ? { branchName: options.newBranch } : {}),
|
|
30
|
+
...(options.base ? { baseBranch: options.base } : {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function buildBranchCheckoutSource(options, source) {
|
|
34
|
+
if (!options.branch) {
|
|
35
|
+
throw new Error("--branch is required for --mode checkout-branch");
|
|
36
|
+
}
|
|
37
|
+
assertOptionsAbsent([options.newBranch, options.base, options.prNumber, options.forge], "--new-branch, --base, --pr-number, and --forge are not valid for --mode checkout-branch");
|
|
38
|
+
return { ...source, action: "checkout", refName: options.branch };
|
|
39
|
+
}
|
|
40
|
+
function buildPullRequestCheckoutSource(options, source) {
|
|
41
|
+
if (options.prNumber === undefined || options.prNumber === "") {
|
|
42
|
+
throw new Error("--pr-number is required for --mode checkout-pr");
|
|
43
|
+
}
|
|
44
|
+
const prNumber = Number(options.prNumber);
|
|
45
|
+
if (!Number.isInteger(prNumber) || prNumber <= 0) {
|
|
46
|
+
throw new Error("--pr-number must be a positive integer");
|
|
47
|
+
}
|
|
48
|
+
assertOptionsAbsent([options.newBranch, options.base, options.branch], "--new-branch, --base, and --branch are not valid for --mode checkout-pr");
|
|
49
|
+
return {
|
|
50
|
+
...source,
|
|
51
|
+
action: "checkout",
|
|
52
|
+
checkoutSource: {
|
|
53
|
+
kind: "change_request",
|
|
54
|
+
...(options.forge ? { forge: options.forge } : {}),
|
|
55
|
+
number: prNumber,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function buildWorktreeWorkspaceSource(options, path) {
|
|
60
|
+
const source = {
|
|
61
|
+
kind: "worktree",
|
|
62
|
+
...(path ? { cwd: path } : {}),
|
|
63
|
+
...(options.project ? { projectId: options.project } : {}),
|
|
64
|
+
...(options.worktreeSlug ? { worktreeSlug: options.worktreeSlug } : {}),
|
|
65
|
+
};
|
|
66
|
+
switch (options.mode ?? "branch-off") {
|
|
67
|
+
case "branch-off":
|
|
68
|
+
return buildBranchOffSource(options, source);
|
|
69
|
+
case "checkout-branch":
|
|
70
|
+
return buildBranchCheckoutSource(options, source);
|
|
71
|
+
case "checkout-pr":
|
|
72
|
+
return buildPullRequestCheckoutSource(options, source);
|
|
73
|
+
default:
|
|
74
|
+
throw new Error(`Unsupported worktree mode: ${String(options.mode)}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function buildWorkspaceSource(options) {
|
|
78
|
+
if (options.isolation === "local") {
|
|
79
|
+
return buildLocalWorkspaceSource(options, options.path ?? process.cwd());
|
|
80
|
+
}
|
|
81
|
+
if (options.isolation === "worktree") {
|
|
82
|
+
const sourcePath = options.path ?? (options.project ? undefined : process.cwd());
|
|
83
|
+
return buildWorktreeWorkspaceSource(options, sourcePath);
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`Unsupported workspace isolation: ${String(options.isolation)}`);
|
|
86
|
+
}
|
|
87
|
+
export async function runCreateCommand(options, _command) {
|
|
88
|
+
const host = getDaemonHost({ host: options.host });
|
|
89
|
+
const client = await connectToDaemon({ host: options.host }).catch((error) => {
|
|
90
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
91
|
+
throw {
|
|
92
|
+
code: "DAEMON_NOT_RUNNING",
|
|
93
|
+
message: `Cannot connect to daemon at ${host}: ${message}`,
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
try {
|
|
97
|
+
const payload = await client.createWorkspace({
|
|
98
|
+
source: buildWorkspaceSource(options),
|
|
99
|
+
...(options.title ? { title: options.title } : {}),
|
|
100
|
+
});
|
|
101
|
+
if (!payload.workspace) {
|
|
102
|
+
throw new Error(payload.error ?? "Workspace creation failed");
|
|
103
|
+
}
|
|
104
|
+
return { type: "single", data: toWorkspaceRow(payload.workspace), schema: workspaceSchema };
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
108
|
+
throw { code: "WORKSPACE_CREATE_FAILED", message };
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
await client.close().catch(() => undefined);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { withOutput } from "../../output/index.js";
|
|
3
|
+
import { addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
|
|
4
|
+
import { runArchiveCommand } from "./archive.js";
|
|
5
|
+
import { runCreateCommand } from "./create.js";
|
|
6
|
+
import { runLsCommand } from "./ls.js";
|
|
7
|
+
import { runRenameCommand } from "./rename.js";
|
|
8
|
+
import { runSetupCommand } from "./setup.js";
|
|
9
|
+
export function createWorkspaceCommand() {
|
|
10
|
+
const workspace = new Command("workspace").description("Manage workspaces");
|
|
11
|
+
addJsonAndDaemonHostOptions(workspace
|
|
12
|
+
.command("setup")
|
|
13
|
+
.description("Allow and run setup for a workspace")
|
|
14
|
+
.argument("<workspace-id>", "Workspace id")).action(withOutput(runSetupCommand));
|
|
15
|
+
addJsonAndDaemonHostOptions(workspace
|
|
16
|
+
.command("create")
|
|
17
|
+
.description("Create a workspace")
|
|
18
|
+
.requiredOption("--isolation <local|worktree>", "Workspace isolation")
|
|
19
|
+
.option("--path <path>", "Local directory or source checkout (default: current)")
|
|
20
|
+
.option("--project <id>", "Existing project id")
|
|
21
|
+
.option("--title <title>", "Workspace title")
|
|
22
|
+
.option("--mode <mode>", "Worktree mode: branch-off, checkout-branch, or checkout-pr (default: branch-off)")
|
|
23
|
+
.option("--worktree-slug <slug>", "Managed worktree path slug")
|
|
24
|
+
.option("--new-branch <name>", "New branch name (--mode branch-off)")
|
|
25
|
+
.option("--base <ref>", "Base ref (--mode branch-off)")
|
|
26
|
+
.option("--branch <name>", "Existing branch (--mode checkout-branch)")
|
|
27
|
+
.option("--pr-number <n>", "Pull request or change request number (--mode checkout-pr)")
|
|
28
|
+
.option("--forge <forge>", "Forge for --mode checkout-pr (default: source checkout)")).action(withOutput(runCreateCommand));
|
|
29
|
+
addJsonAndDaemonHostOptions(workspace.command("ls").description("List active workspaces")).action(withOutput(runLsCommand));
|
|
30
|
+
addJsonAndDaemonHostOptions(workspace
|
|
31
|
+
.command("rename")
|
|
32
|
+
.description("Set a workspace's user-visible title")
|
|
33
|
+
.argument("<workspace-id>", "Workspace id")
|
|
34
|
+
.argument("[title]", "New workspace title")
|
|
35
|
+
.option("--reset", "Clear the title and revert to the branch or directory name")
|
|
36
|
+
// Commander 12 accepts excess positionals by default, which would rename to
|
|
37
|
+
// the first word of an unquoted multi-word title and silently drop the rest.
|
|
38
|
+
.allowExcessArguments(false)).action(withOutput(runRenameCommand));
|
|
39
|
+
addJsonAndDaemonHostOptions(workspace
|
|
40
|
+
.command("archive")
|
|
41
|
+
.description("Archive a workspace and everything it owns")
|
|
42
|
+
.argument("<workspace-id>", "Workspace id")).action(withOutput(runArchiveCommand));
|
|
43
|
+
return workspace;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { ListResult } from "../../output/index.js";
|
|
3
|
+
import { type WorkspaceRow } from "./shared.js";
|
|
4
|
+
export declare function runLsCommand(options: {
|
|
5
|
+
host?: string;
|
|
6
|
+
}, _command: Command): Promise<ListResult<WorkspaceRow>>;
|
|
7
|
+
//# sourceMappingURL=ls.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
2
|
+
import { toWorkspaceRow, workspaceSchema } from "./shared.js";
|
|
3
|
+
export async function runLsCommand(options, _command) {
|
|
4
|
+
const host = getDaemonHost({ host: options.host });
|
|
5
|
+
const client = await connectToDaemon({ host: options.host }).catch((error) => {
|
|
6
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
7
|
+
throw {
|
|
8
|
+
code: "DAEMON_NOT_RUNNING",
|
|
9
|
+
message: `Cannot connect to daemon at ${host}: ${message}`,
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
try {
|
|
13
|
+
const workspaces = [];
|
|
14
|
+
let cursor;
|
|
15
|
+
do {
|
|
16
|
+
const payload = await client.fetchWorkspaces({
|
|
17
|
+
page: { limit: 200, ...(cursor ? { cursor } : {}) },
|
|
18
|
+
});
|
|
19
|
+
workspaces.push(...payload.entries.map(toWorkspaceRow));
|
|
20
|
+
cursor = payload.pageInfo.nextCursor ?? undefined;
|
|
21
|
+
} while (cursor);
|
|
22
|
+
return { type: "list", data: workspaces, schema: workspaceSchema };
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
await client.close().catch(() => undefined);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ls.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
interface WorkspaceRenameResult {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
/** Raw title override; null once it has been reset to the derived name. */
|
|
6
|
+
title: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface WorkspaceRenameOptions {
|
|
9
|
+
host?: string;
|
|
10
|
+
reset?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the title to send to the daemon. Null clears the override and
|
|
14
|
+
* reverts the workspace to its branch- or directory-derived name.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveWorkspaceTitle(input: {
|
|
17
|
+
title?: string;
|
|
18
|
+
reset?: boolean;
|
|
19
|
+
}): string | null;
|
|
20
|
+
export declare function runRenameCommand(workspaceId: string, titleArg: string | undefined, options: WorkspaceRenameOptions, _command: Command): Promise<SingleResult<WorkspaceRenameResult>>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=rename.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
2
|
+
const workspaceRenameSchema = {
|
|
3
|
+
idField: "workspaceId",
|
|
4
|
+
columns: [
|
|
5
|
+
{ header: "WORKSPACE ID", field: "workspaceId", width: 20 },
|
|
6
|
+
{ header: "TITLE", field: "title", width: 30 },
|
|
7
|
+
],
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Resolve the title to send to the daemon. Null clears the override and
|
|
11
|
+
* reverts the workspace to its branch- or directory-derived name.
|
|
12
|
+
*/
|
|
13
|
+
export function resolveWorkspaceTitle(input) {
|
|
14
|
+
const title = input.title?.trim() ?? "";
|
|
15
|
+
if (input.reset) {
|
|
16
|
+
if (input.title !== undefined) {
|
|
17
|
+
throw {
|
|
18
|
+
code: "INVALID_OPTIONS",
|
|
19
|
+
message: "--reset cannot be combined with a title",
|
|
20
|
+
details: "Pass a title to rename the workspace, or --reset to revert to the derived name",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (title.length === 0) {
|
|
26
|
+
throw {
|
|
27
|
+
code: "MISSING_TITLE",
|
|
28
|
+
message: "Title cannot be empty",
|
|
29
|
+
details: "Usage: paseo workspace rename <workspace-id> <title> | --reset",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return title;
|
|
33
|
+
}
|
|
34
|
+
export async function runRenameCommand(workspaceId, titleArg, options, _command) {
|
|
35
|
+
const title = resolveWorkspaceTitle({ title: titleArg, reset: options.reset });
|
|
36
|
+
const host = getDaemonHost({ host: options.host });
|
|
37
|
+
const client = await connectToDaemon({ host: options.host }).catch((error) => {
|
|
38
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
39
|
+
throw {
|
|
40
|
+
code: "DAEMON_NOT_RUNNING",
|
|
41
|
+
message: `Cannot connect to daemon at ${host}: ${message}`,
|
|
42
|
+
details: "Start the daemon with: paseo daemon start",
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
try {
|
|
46
|
+
const applied = await client.setWorkspaceTitle(workspaceId, title);
|
|
47
|
+
return {
|
|
48
|
+
type: "single",
|
|
49
|
+
data: { workspaceId, title: applied.title },
|
|
50
|
+
schema: workspaceRenameSchema,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
55
|
+
throw { code: "WORKSPACE_RENAME_FAILED", message };
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
await client.close().catch(() => undefined);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=rename.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
interface WorkspaceSetupResult {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
status: "started" | "already_allowed";
|
|
6
|
+
}
|
|
7
|
+
export declare function runSetupCommand(workspaceId: string, options: {
|
|
8
|
+
host?: string;
|
|
9
|
+
}, _command: Command): Promise<SingleResult<WorkspaceSetupResult>>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
2
|
+
const workspaceSetupSchema = {
|
|
3
|
+
idField: "workspaceId",
|
|
4
|
+
columns: [
|
|
5
|
+
{ header: "WORKSPACE ID", field: "workspaceId", width: 20 },
|
|
6
|
+
{ header: "STATUS", field: "status", width: 18 },
|
|
7
|
+
],
|
|
8
|
+
};
|
|
9
|
+
export async function runSetupCommand(workspaceId, options, _command) {
|
|
10
|
+
const host = getDaemonHost({ host: options.host });
|
|
11
|
+
const client = await connectToDaemon({ host: options.host }).catch((error) => {
|
|
12
|
+
throw {
|
|
13
|
+
code: "DAEMON_NOT_RUNNING",
|
|
14
|
+
message: `Cannot connect to daemon at ${host}: ${error instanceof Error ? error.message : String(error)}`,
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
// COMPAT(workspaceSetupRun): added in v0.7.3, remove gate after 2027-09-02.
|
|
19
|
+
if (!client.getLastServerInfoMessage()?.features?.workspaceSetupRun) {
|
|
20
|
+
throw { code: "DAEMON_UPDATE_REQUIRED", message: "Update the host to run workspace setup." };
|
|
21
|
+
}
|
|
22
|
+
const payload = await client.runWorkspaceSetup(workspaceId);
|
|
23
|
+
if (payload.error)
|
|
24
|
+
throw new Error(payload.error);
|
|
25
|
+
return {
|
|
26
|
+
type: "single",
|
|
27
|
+
data: { workspaceId, status: payload.started ? "started" : "already_allowed" },
|
|
28
|
+
schema: workspaceSetupSchema,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error && typeof error === "object" && "code" in error)
|
|
33
|
+
throw error;
|
|
34
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
+
throw { code: "WORKSPACE_SETUP_FAILED", message };
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await client.close().catch(() => undefined);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WorkspaceDescriptorPayload } from "@camerontaylor/paseo-protocol/messages";
|
|
2
|
+
import type { OutputSchema } from "../../output/index.js";
|
|
3
|
+
export interface WorkspaceRow {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
project: string;
|
|
6
|
+
name: string;
|
|
7
|
+
isolation: "local" | "worktree";
|
|
8
|
+
cwd: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const workspaceSchema: OutputSchema<WorkspaceRow>;
|
|
11
|
+
export declare function toWorkspaceRow(workspace: WorkspaceDescriptorPayload): WorkspaceRow;
|
|
12
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const workspaceSchema = {
|
|
2
|
+
idField: "workspaceId",
|
|
3
|
+
columns: [
|
|
4
|
+
{ header: "WORKSPACE ID", field: "workspaceId", width: 20 },
|
|
5
|
+
{ header: "PROJECT", field: "project", width: 20 },
|
|
6
|
+
{ header: "NAME", field: "name", width: 22 },
|
|
7
|
+
{ header: "ISOLATION", field: "isolation", width: 10 },
|
|
8
|
+
{ header: "CWD", field: "cwd", width: 42 },
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
export function toWorkspaceRow(workspace) {
|
|
12
|
+
return {
|
|
13
|
+
workspaceId: workspace.id,
|
|
14
|
+
project: workspace.projectDisplayName,
|
|
15
|
+
name: workspace.name,
|
|
16
|
+
isolation: workspace.workspaceKind === "worktree" ? "worktree" : "local",
|
|
17
|
+
cwd: workspace.workspaceDirectory,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { connectToDaemon } from "../../utils/client.js";
|
|
3
|
+
import type { CommandOptions, SingleResult, OutputSchema } from "../../output/index.js";
|
|
4
|
+
/** Result type for worktree archive command */
|
|
5
|
+
export interface WorktreeArchiveResult {
|
|
6
|
+
name: string;
|
|
7
|
+
status: "archived";
|
|
8
|
+
removedAgents: string[];
|
|
9
|
+
}
|
|
10
|
+
/** Schema for archive command output */
|
|
11
|
+
export declare const archiveSchema: OutputSchema<WorktreeArchiveResult>;
|
|
12
|
+
export interface WorktreeArchiveOptions extends CommandOptions {
|
|
13
|
+
host?: string;
|
|
14
|
+
}
|
|
15
|
+
export type WorktreeArchiveCommandResult = SingleResult<WorktreeArchiveResult>;
|
|
16
|
+
export declare function runArchiveCommand(nameArg: string, options: WorktreeArchiveOptions, _command: Command): Promise<WorktreeArchiveCommandResult>;
|
|
17
|
+
export declare function runArchiveCommandWithDeps(nameArg: string, options: WorktreeArchiveOptions, deps: {
|
|
18
|
+
connectToDaemon: typeof connectToDaemon;
|
|
19
|
+
}): Promise<WorktreeArchiveCommandResult>;
|
|
20
|
+
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
3
|
+
/** Schema for archive command output */
|
|
4
|
+
export const archiveSchema = {
|
|
5
|
+
idField: "name",
|
|
6
|
+
columns: [
|
|
7
|
+
{ header: "NAME", field: "name" },
|
|
8
|
+
{ header: "STATUS", field: "status" },
|
|
9
|
+
{
|
|
10
|
+
header: "REMOVED AGENTS",
|
|
11
|
+
field: (item) => (item.removedAgents.length > 0 ? item.removedAgents.join(", ") : "-"),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
export async function runArchiveCommand(nameArg, options, _command) {
|
|
16
|
+
return runArchiveCommandWithDeps(nameArg, options, { connectToDaemon });
|
|
17
|
+
}
|
|
18
|
+
export async function runArchiveCommandWithDeps(nameArg, options, deps) {
|
|
19
|
+
const host = getDaemonHost({ host: options.host });
|
|
20
|
+
// Validate arguments
|
|
21
|
+
if (!nameArg || nameArg.trim().length === 0) {
|
|
22
|
+
const error = {
|
|
23
|
+
code: "MISSING_WORKTREE_NAME",
|
|
24
|
+
message: "Worktree name is required",
|
|
25
|
+
details: "Usage: paseo worktree archive <name>",
|
|
26
|
+
};
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
let client;
|
|
30
|
+
try {
|
|
31
|
+
client = await deps.connectToDaemon({ host: options.host });
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
35
|
+
const error = {
|
|
36
|
+
code: "DAEMON_NOT_RUNNING",
|
|
37
|
+
message: `Cannot connect to daemon at ${host}: ${message}`,
|
|
38
|
+
details: "Start the daemon with: paseo daemon start",
|
|
39
|
+
};
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
// Get the list of worktrees first to resolve the name
|
|
44
|
+
const listResponse = await client.getPaseoWorktreeList({});
|
|
45
|
+
if (listResponse.error) {
|
|
46
|
+
const error = {
|
|
47
|
+
code: "WORKTREE_LIST_FAILED",
|
|
48
|
+
message: `Failed to list worktrees: ${listResponse.error.message}`,
|
|
49
|
+
};
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
// Find the worktree by name or branch
|
|
53
|
+
const worktree = listResponse.worktrees.find((wt) => {
|
|
54
|
+
const name = path.basename(wt.worktreePath);
|
|
55
|
+
return name === nameArg || wt.branchName === nameArg;
|
|
56
|
+
});
|
|
57
|
+
if (!worktree) {
|
|
58
|
+
const error = {
|
|
59
|
+
code: "WORKTREE_NOT_FOUND",
|
|
60
|
+
message: `Worktree not found: ${nameArg}`,
|
|
61
|
+
details: 'Use "paseo worktree ls" to list available worktrees',
|
|
62
|
+
};
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
// Archive the worktree. scope:"worktree" archives every active workspace on
|
|
66
|
+
// the directory and then removes the directory (Paseo-owned gated).
|
|
67
|
+
const response = await client.archivePaseoWorktree({
|
|
68
|
+
worktreePath: worktree.worktreePath,
|
|
69
|
+
scope: "worktree",
|
|
70
|
+
});
|
|
71
|
+
await client.close();
|
|
72
|
+
if (response.error) {
|
|
73
|
+
const error = {
|
|
74
|
+
code: "WORKTREE_ARCHIVE_FAILED",
|
|
75
|
+
message: `Failed to archive worktree: ${response.error.message}`,
|
|
76
|
+
};
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
const worktreeName = path.basename(worktree.worktreePath) || nameArg;
|
|
80
|
+
return {
|
|
81
|
+
type: "single",
|
|
82
|
+
data: {
|
|
83
|
+
name: worktreeName,
|
|
84
|
+
status: "archived",
|
|
85
|
+
removedAgents: response.removedAgents ?? [],
|
|
86
|
+
},
|
|
87
|
+
schema: archiveSchema,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
await client.close().catch(() => { });
|
|
92
|
+
// Re-throw CommandError as-is
|
|
93
|
+
if (err && typeof err === "object" && "code" in err) {
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
97
|
+
const error = {
|
|
98
|
+
code: "WORKTREE_ARCHIVE_FAILED",
|
|
99
|
+
message: `Failed to archive worktree: ${message}`,
|
|
100
|
+
};
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=archive.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DaemonClient } from "@camerontaylor/paseo-client/internal/daemon-client";
|
|
2
|
+
import type { CommandOptions } from "../../output/index.js";
|
|
3
|
+
export interface WorktreeCreateOptions extends CommandOptions {
|
|
4
|
+
host?: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
mode?: string;
|
|
7
|
+
newBranch?: string;
|
|
8
|
+
base?: string;
|
|
9
|
+
branch?: string;
|
|
10
|
+
prNumber?: string;
|
|
11
|
+
}
|
|
12
|
+
type CreatePaseoWorktreeRequest = Parameters<DaemonClient["createPaseoWorktree"]>[0];
|
|
13
|
+
export declare function buildCreateWorktreeRequest(options: WorktreeCreateOptions, cwd: string): CreatePaseoWorktreeRequest;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=create-input.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const VALID_MODES = ["branch-off", "checkout-branch", "checkout-pr"];
|
|
2
|
+
export function buildCreateWorktreeRequest(options, cwd) {
|
|
3
|
+
const mode = options.mode;
|
|
4
|
+
if (!mode) {
|
|
5
|
+
throw cmdError("MISSING_MODE", "--mode is required", `Expected one of: ${VALID_MODES.join(", ")}`);
|
|
6
|
+
}
|
|
7
|
+
switch (mode) {
|
|
8
|
+
case "branch-off":
|
|
9
|
+
return buildBranchOffRequest(options, cwd);
|
|
10
|
+
case "checkout-branch":
|
|
11
|
+
return buildCheckoutBranchRequest(options, cwd);
|
|
12
|
+
case "checkout-pr":
|
|
13
|
+
return buildCheckoutPrRequest(options, cwd);
|
|
14
|
+
default:
|
|
15
|
+
throw cmdError("INVALID_MODE", `Invalid --mode: ${mode}`, `Expected one of: ${VALID_MODES.join(", ")}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function buildBranchOffRequest(options, cwd) {
|
|
19
|
+
if (!options.newBranch) {
|
|
20
|
+
throw cmdError("MISSING_NEW_BRANCH", "--new-branch is required for --mode branch-off");
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
cwd,
|
|
24
|
+
worktreeSlug: options.newBranch,
|
|
25
|
+
action: "branch-off",
|
|
26
|
+
...(options.base ? { refName: options.base } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function buildCheckoutBranchRequest(options, cwd) {
|
|
30
|
+
if (!options.branch) {
|
|
31
|
+
throw cmdError("MISSING_BRANCH", "--branch is required for --mode checkout-branch");
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
cwd,
|
|
35
|
+
action: "checkout",
|
|
36
|
+
refName: options.branch,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function buildCheckoutPrRequest(options, cwd) {
|
|
40
|
+
if (options.prNumber === undefined || options.prNumber === "") {
|
|
41
|
+
throw cmdError("MISSING_PR_NUMBER", "--pr-number is required for --mode checkout-pr");
|
|
42
|
+
}
|
|
43
|
+
const prNumber = Number(options.prNumber);
|
|
44
|
+
if (!Number.isInteger(prNumber) || prNumber <= 0) {
|
|
45
|
+
throw cmdError("INVALID_PR_NUMBER", `Invalid --pr-number: ${options.prNumber}`, "Expected a positive integer");
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
cwd,
|
|
49
|
+
action: "checkout",
|
|
50
|
+
githubPrNumber: prNumber,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function cmdError(code, message, details) {
|
|
54
|
+
return details ? { code, message, details } : { code, message };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=create-input.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { OutputSchema, SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type WorktreeCreateOptions } from "./create-input.js";
|
|
4
|
+
export interface WorktreeCreateResult {
|
|
5
|
+
name: string;
|
|
6
|
+
branchName: string;
|
|
7
|
+
worktreePath: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const createSchema: OutputSchema<WorktreeCreateResult>;
|
|
10
|
+
export declare function runCreateCommand(options: WorktreeCreateOptions, _command: Command): Promise<SingleResult<WorktreeCreateResult>>;
|
|
11
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
3
|
+
import { buildCreateWorktreeRequest } from "./create-input.js";
|
|
4
|
+
export const createSchema = {
|
|
5
|
+
idField: "worktreePath",
|
|
6
|
+
columns: [
|
|
7
|
+
{ header: "NAME", field: "name", width: 24 },
|
|
8
|
+
{ header: "BRANCH", field: "branchName", width: 28 },
|
|
9
|
+
{ header: "PATH", field: "worktreePath", width: 50 },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
function cmdError(code, message, details) {
|
|
13
|
+
return details ? { code, message, details } : { code, message };
|
|
14
|
+
}
|
|
15
|
+
export async function runCreateCommand(options, _command) {
|
|
16
|
+
const cwd = options.cwd ?? process.cwd();
|
|
17
|
+
const request = buildCreateWorktreeRequest(options, cwd);
|
|
18
|
+
const host = getDaemonHost({ host: options.host });
|
|
19
|
+
let client;
|
|
20
|
+
try {
|
|
21
|
+
client = await connectToDaemon({ host: options.host });
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
25
|
+
throw cmdError("DAEMON_NOT_RUNNING", `Cannot connect to daemon at ${host}: ${message}`, "Start the daemon with: paseo daemon start");
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const response = await client.createPaseoWorktree(request);
|
|
29
|
+
const workspace = response.workspace;
|
|
30
|
+
if (!workspace || response.error) {
|
|
31
|
+
throw cmdError("WORKTREE_CREATE_FAILED", `Failed to create worktree: ${response.error ?? "no workspace returned"}`);
|
|
32
|
+
}
|
|
33
|
+
if (!workspace.workspaceDirectory) {
|
|
34
|
+
throw cmdError("WORKTREE_CREATE_FAILED", "Failed to create worktree: workspace directory missing from daemon response");
|
|
35
|
+
}
|
|
36
|
+
const worktreePath = workspace.workspaceDirectory;
|
|
37
|
+
return {
|
|
38
|
+
type: "single",
|
|
39
|
+
data: {
|
|
40
|
+
name: path.basename(worktreePath),
|
|
41
|
+
branchName: workspace.name,
|
|
42
|
+
worktreePath,
|
|
43
|
+
},
|
|
44
|
+
schema: createSchema,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
if (err && typeof err === "object" && "code" in err) {
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
52
|
+
throw cmdError("WORKTREE_CREATE_FAILED", `Failed to create worktree: ${message}`);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
await client.close().catch(() => { });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=create.js.map
|