codeam-cli 2.4.4 → 2.4.5

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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to `codeam-cli` are documented here.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [2.4.3] — 2026-05-03
8
+
9
+ ### Fixed
10
+
11
+ - **cli:** Refresh missing `codespace` scope on existing gh logins (v2.4.3)
12
+
7
13
  ## [2.4.2] — 2026-05-03
8
14
 
9
15
  ### Fixed
package/dist/index.js CHANGED
@@ -179,7 +179,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
179
179
  // package.json
180
180
  var package_default = {
181
181
  name: "codeam-cli",
182
- version: "2.4.4",
182
+ version: "2.4.5",
183
183
  description: "Remote control Claude Code (and other AI coding agents) from your mobile phone. Pair your device, send prompts, stream responses in real-time, and approve commands \u2014 from anywhere.",
184
184
  main: "dist/index.js",
185
185
  bin: {
@@ -5143,27 +5143,71 @@ var GitHubCodespacesProvider = class {
5143
5143
  }
5144
5144
  const hasScope = await this.hasCodespaceScope();
5145
5145
  if (!hasScope) {
5146
- wt(
5147
- [
5148
- "Your existing GitHub login is missing the `codespace` scope.",
5149
- "I'll run `gh auth refresh` to add it \u2014 your browser will open",
5150
- "for a one-tap approval."
5151
- ].join("\n"),
5152
- "One more permission needed"
5153
- );
5146
+ const expectedUser = await this.getActiveGhUser();
5147
+ const noteLines = [
5148
+ "Your existing GitHub login is missing the `codespace` scope.",
5149
+ "I'll run `gh auth refresh` to add it \u2014 your browser will open",
5150
+ "for a one-tap approval."
5151
+ ];
5152
+ if (expectedUser) {
5153
+ noteLines.push("");
5154
+ noteLines.push(
5155
+ `${import_picocolors7.default.yellow("\u26A0")} Sign in as ${import_picocolors7.default.cyan(expectedUser)} in the browser.`
5156
+ );
5157
+ noteLines.push(
5158
+ " If a different GitHub account is already signed in, sign out"
5159
+ );
5160
+ noteLines.push(
5161
+ " of it first \u2014 or open the URL in an incognito/private window."
5162
+ );
5163
+ }
5164
+ wt(noteLines.join("\n"), "One more permission needed");
5154
5165
  resetStdinForChild();
5155
- await new Promise((resolve2, reject) => {
5166
+ const refreshCode = await new Promise((resolve2, reject) => {
5156
5167
  const proc = (0, import_child_process5.spawn)(
5157
5168
  "gh",
5158
5169
  ["auth", "refresh", "-h", "github.com", "-s", "codespace"],
5159
5170
  { stdio: "inherit" }
5160
5171
  );
5161
- proc.on("exit", (code) => {
5162
- if (code === 0) resolve2();
5163
- else reject(new Error("gh auth refresh failed \u2014 re-run `gh auth refresh -h github.com -s codespace` manually."));
5164
- });
5172
+ proc.on("exit", (code) => resolve2(code ?? 1));
5165
5173
  proc.on("error", reject);
5166
5174
  });
5175
+ if (refreshCode !== 0) {
5176
+ const lines = [
5177
+ "The browser approval came back for a different GitHub account",
5178
+ `than the one gh is configured for${expectedUser ? ` (${import_picocolors7.default.cyan(expectedUser)})` : ""}.`,
5179
+ "",
5180
+ "To recover:",
5181
+ " 1. Open https://github.com and sign out of any non-target",
5182
+ ` account${expectedUser ? ` (or open the URL in an incognito window)` : ""}.`,
5183
+ " 2. Re-run codeam deploy.",
5184
+ "",
5185
+ "You can also grant the scope manually first and skip this step",
5186
+ "on the next run:",
5187
+ ` ${import_picocolors7.default.cyan("gh auth refresh -h github.com -s codespace")}`
5188
+ ];
5189
+ throw new Error(lines.join("\n"));
5190
+ }
5191
+ }
5192
+ }
5193
+ /**
5194
+ * Return the GitHub login that the current `gh` token belongs to,
5195
+ * or `null` if the call fails. Used to tell the user which account
5196
+ * they need to authenticate as in the browser when refreshing
5197
+ * scopes — multi-account browser sessions are the #1 cause of
5198
+ * `gh auth refresh` failures.
5199
+ */
5200
+ async getActiveGhUser() {
5201
+ try {
5202
+ const { stdout } = await execFileP2(
5203
+ "gh",
5204
+ ["api", "user", "--jq", ".login"],
5205
+ { maxBuffer: MAX_BUFFER }
5206
+ );
5207
+ const login = stdout.trim();
5208
+ return login.length > 0 ? login : null;
5209
+ } catch {
5210
+ return null;
5167
5211
  }
5168
5212
  }
5169
5213
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "Remote control Claude Code (and other AI coding agents) from your mobile phone. Pair your device, send prompts, stream responses in real-time, and approve commands — from anywhere.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {