@yanzc/claude-pro 0.10.0 → 0.12.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/src/updater.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Manual update support for `npm i -g claude-pro`: the interactive session checks npm and installs a release only
2
- // when `/update` asks for it (App.updateFromNpm). Installation is serialized by a lock file and the session loads
2
+ // when `/update` or the web console's update button asks for it. Installation is serialized by a lock file and the session loads
3
3
  // the new package with a restart (the conversation carries over). A git checkout (the development copy) is never
4
4
  // touched.
5
5
 
@@ -100,19 +100,20 @@ function runNpm(args, { timeoutMs = 300_000 } = {}) {
100
100
 
101
101
  // Look for a newer version on npm. Resolves with {status: 'dev'|'current'|'available'|'installed', version}:
102
102
  // 'available' to be installed (installUpdate), 'installed' when it is on disk already (another session installed
103
- // it: a restart loads it). (The background checks every few minutes, with their state file and switches, are gone:
104
- // /update is the only caller.)
103
+ // it: a restart loads it). Checking does not install anything.
105
104
  export async function checkForUpdate() {
106
105
  if (!installedByNpm()) return { status: 'dev' };
106
+ const disk = installedVersion();
107
+ if (isNewer(disk, VERSION)) return { status: 'installed', version: disk };
107
108
  const latest = await latestVersion();
108
109
  if (!isNewer(latest, VERSION)) return { status: 'current', version: latest };
109
- if (!isNewer(latest, installedVersion())) return { status: 'installed', version: installedVersion() };
110
110
  return { status: 'available', version: latest };
111
111
  }
112
112
 
113
113
  // Install `version` with npm. Resolves with {status: 'updated'|'installed'|'locked'|'failed', version, error}:
114
114
  // 'locked' while another session of the machine is installing.
115
115
  export async function installUpdate(version) {
116
+ if (!/^\d+\.\d+\.\d+$/.test(String(version))) return { status: 'failed', error: 'invalid npm version' };
116
117
  if (!takeLock()) return { status: 'locked', version };
117
118
  try {
118
119
  if (!isNewer(version, installedVersion())) return { status: 'installed', version: installedVersion() };
@@ -279,7 +279,7 @@ export function hasRipgrep(config) { return ripgrepPath(config) !== null; }
279
279
 
280
280
  // `stdin`: text to feed the command on standard input (hooks get their event JSON this way).
281
281
  // Without it the command's stdin is closed, so nothing can hang waiting for input.
282
- export function spawnShell(shell, command, { cwd, env, cwdFile, stdin }) {
282
+ export function spawnShell(shell, command, { cwd, env, stdin }) {
283
283
  const withStdin = typeof stdin === 'string';
284
284
  const stdio = [withStdin ? 'pipe' : 'ignore', 'pipe', 'pipe'];
285
285
  const feed = (child) => {
@@ -291,20 +291,19 @@ export function spawnShell(shell, command, { cwd, env, cwdFile, stdin }) {
291
291
  cwd, env, windowsHide: true, windowsVerbatimArguments: true, stdio,
292
292
  }));
293
293
  }
294
- // The command is evaluated via an env var so no quoting is needed; afterwards we
295
- // record the final working directory so `cd` persists between calls. On Windows the script first
294
+ // The command is evaluated via an env var so no quoting is needed. Each command starts in the session's
295
+ // directory: a `cd` lasts for that command only (the user's choice, 2026-11-21). On Windows the script first
296
296
  // writes its own (MSYS) process id to a file, which is how killTree finds everything under it.
297
297
  const pidFile = isWin ? path.join(os.tmpdir(), `claude-pro-pid-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`) : null;
298
298
  const script = [
299
299
  ...(pidFile ? ['if [ -n "$CLAUDE_PRO_PID_FILE" ]; then echo $$ > "$CLAUDE_PRO_PID_FILE"; fi'] : []),
300
300
  `eval "$CLAUDE_PRO_COMMAND"${withStdin ? '' : ' < /dev/null'}`,
301
301
  '__ccc_status=$?',
302
- 'if [ -n "$CLAUDE_PRO_CWD_FILE" ]; then { pwd -W 2>/dev/null || pwd -P; } > "$CLAUDE_PRO_CWD_FILE" 2>/dev/null; fi',
303
302
  'exit $__ccc_status',
304
303
  ].join('\n');
305
304
  const child = spawn(shell.path, ['-c', script], {
306
305
  cwd,
307
- env: { ...env, CLAUDE_PRO_COMMAND: command, CLAUDE_PRO_CWD_FILE: cwdFile || '', CLAUDE_PRO_PID_FILE: pidFile || '' },
306
+ env: { ...env, CLAUDE_PRO_COMMAND: command, CLAUDE_PRO_PID_FILE: pidFile || '' },
308
307
  windowsHide: true,
309
308
  detached: !isWin,
310
309
  stdio,