@paleo/workspace 0.20.0 → 0.21.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/README.md CHANGED
@@ -26,7 +26,8 @@ The agent reads the skill, adapts the reference scripts to your stack, installs
26
26
  ## Workflow
27
27
 
28
28
  ```sh
29
- npm run workspace -- setup feat/42 -c # new branch + worktree + isolated env
29
+ npm run workspace -- setup feat/42 -c # new branch + worktree + isolated env
30
+ npm run workspace -- setup feat/42 -c --go # …then drop into a shell there (exit to return)
30
31
  npm run dev # foreground: stream logs, CTRL+C stops; attaches if already running
31
32
  npm run dev -- up # start in the background (no-op if already running here)
32
33
  npm run dev -- up --restart # stop the dev-server in this worktree if running, then start fresh
package/dist/cli.d.ts CHANGED
@@ -7,6 +7,7 @@ export type WorkspaceCommand = {
7
7
  slot?: string;
8
8
  force: boolean;
9
9
  wait: boolean;
10
+ go: boolean;
10
11
  } | {
11
12
  kind: "remove";
12
13
  branch?: string;
package/dist/cli.js CHANGED
@@ -53,6 +53,7 @@ function parseSetup(tokens) {
53
53
  slot: { type: "string", short: "s" },
54
54
  force: { type: "boolean" },
55
55
  wait: { type: "boolean" },
56
+ go: { type: "boolean" },
56
57
  verbose: { type: "boolean", short: "v" },
57
58
  },
58
59
  allowPositionals: true,
@@ -60,12 +61,16 @@ function parseSetup(tokens) {
60
61
  });
61
62
  const branch = takeOptionalPositional(positionals, "setup");
62
63
  const newBranch = values["new-branch"] ?? false;
64
+ const go = values.go ?? false;
63
65
  if (newBranch && branch === undefined) {
64
66
  throw new ConfigError("`workspace setup <branch> -c` requires a branch name.");
65
67
  }
66
68
  if (values.from !== undefined && !newBranch) {
67
69
  throw new ConfigError("`--from` requires `-c`/`--new-branch`.");
68
70
  }
71
+ if (go && branch === undefined) {
72
+ throw new ConfigError("`--go` requires a branch (the worktree to enter).");
73
+ }
69
74
  return {
70
75
  command: {
71
76
  kind: "setup",
@@ -76,6 +81,7 @@ function parseSetup(tokens) {
76
81
  slot: values.slot,
77
82
  force: values.force ?? false,
78
83
  wait: values.wait ?? false,
84
+ go,
79
85
  },
80
86
  verbose: values.verbose ?? false,
81
87
  };
@@ -196,12 +202,14 @@ export function printWorkspaceHelp() {
196
202
  "Manage workspaces: a git worktree plus its own dev setup (ports, config, database, dev server).",
197
203
  "",
198
204
  "Commands:",
199
- " setup [<branch>] [-c|--new-branch] [--from <ref>] [--owner <name>] [-s|--slot <port>] [--force] [--wait]",
205
+ " setup [<branch>] [-c|--new-branch] [--from <ref>] [--owner <name>] [-s|--slot <port>] [--force] [--wait] [--go]",
200
206
  " Set up the workspace. With <branch>, create a sibling worktree for it",
201
207
  " (add -c to create the branch first). Without, set up the current worktree",
202
208
  " (idempotent; bootstrap and retry path).",
203
209
  " With -c, the new branch starts at the current worktree's HEAD, or at <ref> with --from.",
204
210
  " Finalize runs in the background; add --wait to block until it reaches READY.",
211
+ " With --go, drop into an interactive shell in the new worktree (exit to return);",
212
+ " combine with --wait to enter only once it is READY. Requires a branch and $SHELL.",
205
213
  " remove [<branch>] [--force]",
206
214
  " Remove a workspace by branch, or the current one when omitted.",
207
215
  " Refuses on uncommitted changes unless --force.",
package/dist/workspace.js CHANGED
@@ -71,13 +71,29 @@ export async function runWorkspace(config) {
71
71
  handleSetOwnerMode(command, ctx, registryDir);
72
72
  return;
73
73
  case "setup": {
74
- const { slot } = await runSetup(command, ctx, run, config, registryDir);
74
+ const { slot, worktree } = await runSetup(command, ctx, run, config, registryDir);
75
75
  if (command.wait)
76
76
  await waitForSlot(slot, config, registryDir, { printSummary: false });
77
+ if (command.go)
78
+ enterWorktree(worktree);
77
79
  return;
78
80
  }
79
81
  }
80
82
  }
83
+ /**
84
+ * `--go`: open an interactive shell in the freshly set-up worktree (exit to return). Falls back to
85
+ * printing a `cd` hint when there is no `$SHELL` or stdin is not a tty (scripts, pipes) — dropping
86
+ * into an interactive shell there would hang.
87
+ */
88
+ function enterWorktree(worktree) {
89
+ const shell = process.env.SHELL;
90
+ if (shell === undefined || !process.stdin.isTTY) {
91
+ console.log(`Now run: cd ${worktree}`);
92
+ return;
93
+ }
94
+ console.error(`Entering ${worktree} (exit to return).`);
95
+ spawnSync(shell, [], { cwd: worktree, stdio: "inherit" });
96
+ }
81
97
  async function runSetup(command, ctx, run, config, registryDir) {
82
98
  const scheme = resolvePortScheme(config);
83
99
  const portsFn = resolvePortsFn(config);
@@ -158,7 +174,7 @@ async function runSetup(command, ctx, run, config, registryDir) {
158
174
  });
159
175
  child.unref();
160
176
  closeSync(logFd);
161
- return { slot };
177
+ return { slot, worktree: setupCtx.currentWorktree };
162
178
  }
163
179
  function refuseIfFinalizePending(ctx, registryDir, force) {
164
180
  if (force)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paleo/workspace",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Run multiple git-worktree dev environments side by side.",
5
5
  "keywords": [
6
6
  "workspace",