@cli-remote/local 0.3.1 → 0.3.3

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/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- '#!/usr/bin/env node'
1
+ #!/usr/bin/env node
2
2
  "use strict";
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
@@ -10042,6 +10042,10 @@ function buildEnv() {
10042
10042
  }
10043
10043
  delete env.NO_COLOR;
10044
10044
  env.COLORTERM = "truecolor";
10045
+ if (!env.LC_ALL && !env.LANG) {
10046
+ env.LANG = process.env.PTY_LANG || "zh_CN.UTF-8";
10047
+ }
10048
+ env.TERM ||= "xterm-256color";
10045
10049
  if (process.env.PTY_HOME) env.HOME = process.env.PTY_HOME;
10046
10050
  return env;
10047
10051
  }
@@ -11559,7 +11563,7 @@ function resolveHere() {
11559
11563
  var argUrl = process.argv[2];
11560
11564
  var argMatch = argUrl && (argUrl.startsWith("ws://") || argUrl.startsWith("wss://"));
11561
11565
  function readVersion() {
11562
- if (true) return "0.3.1";
11566
+ if (true) return "0.3.3";
11563
11567
  try {
11564
11568
  const pkg = JSON.parse(
11565
11569
  (0, import_node_fs5.readFileSync)(new URL("../package.json", import_meta.url), "utf-8")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cli-remote/local",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Local PTY agent for cli-remote — exposes your local CLI tools (claude/codex/kimi-cli/shell) to the mobile web client via a self-hosted hub.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,11 +22,13 @@
22
22
  "cli-local": "./dist/index.cjs"
23
23
  },
24
24
  "files": [
25
- "dist"
25
+ "dist",
26
+ "scripts"
26
27
  ],
27
28
  "scripts": {
28
29
  "dev": "tsx watch src/index.ts",
29
30
  "build": "node scripts/build.mjs",
31
+ "postinstall": "node scripts/fix-spawn-helper.mjs",
30
32
  "typecheck": "tsc --noEmit",
31
33
  "prepublishOnly": "pnpm build"
32
34
  },
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ // esbuild wrapper: bundles src/index.ts → dist/index.cjs, injecting the
3
+ // package version as CLI_LOCAL_VERSION (consumed by the -v/--version
4
+ // handler in src/index.ts — single source of truth stays package.json).
5
+ import { spawnSync } from 'node:child_process'
6
+ import { readFileSync } from 'node:fs'
7
+
8
+ const version = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8')).version
9
+
10
+ const res = spawnSync(
11
+ 'esbuild',
12
+ [
13
+ 'src/index.ts',
14
+ '--bundle',
15
+ '--platform=node',
16
+ '--format=cjs',
17
+ '--outfile=dist/index.cjs',
18
+ `--define:CLI_LOCAL_VERSION=${JSON.stringify(version)}`,
19
+ '--external:node-pty',
20
+ // NOTE: argv array goes straight to esbuild (no shell except win32), so
21
+ // the banner text must NOT be wrapped in quotes — literal quotes end up
22
+ // in the output and break the shebang.
23
+ '--banner:js=#!/usr/bin/env node',
24
+ ],
25
+ { stdio: 'inherit', shell: process.platform === 'win32' },
26
+ )
27
+ process.exit(res.status ?? 1)
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ // Install-time fix: npm's tarball unpack sometimes strips the exec bit from
3
+ // node-pty's spawn-helper, which makes every PTY spawn fail on macOS with
4
+ // "posix_spawnp failed." (pit #1 in docs/HANDOFF.md). The runtime fallback in
5
+ // src/index.ts (fixSpawnHelperPerms) only runs when the gateway process
6
+ // starts — it cannot cover "npm i -g 升级后老 daemon 还在跑" — so this script
7
+ // runs as the package's own postinstall to chmod +x at install time.
8
+ import { chmodSync, existsSync, readdirSync } from 'node:fs'
9
+ import { dirname, join } from 'node:path'
10
+ import { fileURLToPath } from 'node:url'
11
+
12
+ const here = dirname(fileURLToPath(import.meta.url))
13
+
14
+ // <pkg>/scripts → node-pty, for npm -g (deps nest under the package) and
15
+ // plain `npm install <pkg>` (deps hoist to the project root).
16
+ const candidates = [
17
+ join(here, '..', 'node_modules', 'node-pty', 'prebuilds'),
18
+ join(here, '..', '..', 'node_modules', 'node-pty', 'prebuilds'),
19
+ join(here, '..', '..', '..', 'node-pty', 'prebuilds'),
20
+ ]
21
+
22
+ // pnpm keeps deps under .pnpm — scan both likely locations.
23
+ for (const base of [join(here, '..', 'node_modules'), join(here, '..', '..', 'node_modules')]) {
24
+ const pnpmDir = join(base, '.pnpm')
25
+ if (!existsSync(pnpmDir)) continue
26
+ for (const d of readdirSync(pnpmDir)) {
27
+ if (d.startsWith('node-pty@')) {
28
+ candidates.push(join(pnpmDir, d, 'node_modules', 'node-pty', 'prebuilds'))
29
+ }
30
+ }
31
+ }
32
+
33
+ let n = 0
34
+ for (const dir of candidates) {
35
+ if (!existsSync(dir)) continue
36
+ for (const sub of readdirSync(dir)) {
37
+ const helper = join(dir, sub, 'spawn-helper')
38
+ if (!existsSync(helper)) continue
39
+ try {
40
+ chmodSync(helper, 0o755)
41
+ n++
42
+ } catch {
43
+ // best effort — runtime chmod in index.ts is the second line of defense
44
+ }
45
+ }
46
+ }
47
+ if (n) console.log(`[cli-local postinstall] chmod +x spawn-helper (${n} files)`)