@xurxuo/claude-code-termux 2.1.140

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/LICENSE.md ADDED
@@ -0,0 +1 @@
1
+ © Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # @xurxuo/claude-code-termux
2
+
3
+ Claude Code for Termux/Android ARM64 - with Termux patches.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pkg update && pkg upgrade -y
9
+ pkg install nodejs-lts -y
10
+ npm install -g @xurxuo/claude-code-termux
11
+ claude --version
12
+ claude
13
+ ```
14
+
15
+ ## Termux Patches
16
+
17
+ - Platform detection: android → linux
18
+ - Uses `@anthropic-ai/claude-code-linux-arm64` native binary
19
+ - Compatible with Termux environment
20
+
21
+ ## Requirements
22
+
23
+ - Android ARM64 (aarch64)
24
+ - Termux from F-Droid
25
+ - Node.js >= 18
26
+
27
+ ## Usage
28
+
29
+ ```bash
30
+ claude # Start Claude Code
31
+ claude --version # Check version
32
+ ```
33
+
34
+ ## Auth
35
+
36
+ Set your API key:
37
+ ```bash
38
+ export ANTHROPIC_API_KEY=sk-ant-...
39
+ ```
40
+
41
+ Or run `claude` and follow auth flow.
42
+
43
+ ## Source
44
+
45
+ Based on @anthropic-ai/claude-code with Termux patches.
package/bin/claude.exe ADDED
@@ -0,0 +1,11 @@
1
+ echo "Error: claude native binary not installed." >&2
2
+ echo "" >&2
3
+ echo "Either postinstall did not run (--ignore-scripts, some pnpm configs)" >&2
4
+ echo "or the platform-native optional dependency was not downloaded" >&2
5
+ echo "(--omit=optional)." >&2
6
+ echo "" >&2
7
+ echo "Run the postinstall manually (adjust path for local vs global install):" >&2
8
+ echo " node node_modules/@anthropic-ai/claude-code/install.cjs" >&2
9
+ echo "" >&2
10
+ echo "Or reinstall without --ignore-scripts / --omit=optional." >&2
11
+ exit 1
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+ // Termux/Android patched launcher
3
+ // Patches: android -> linux for platform detection
4
+
5
+ const { spawnSync } = require('child_process')
6
+ const { arch, constants } = require('os')
7
+ const path = require('path')
8
+
9
+ const PACKAGE_PREFIX = '@anthropic-ai/claude-code'
10
+ const BINARY_NAME = 'claude'
11
+ const WRAPPER_NAME = require('./package.json').name
12
+
13
+ const PLATFORMS = {
14
+ 'darwin-arm64': { pkg: PACKAGE_PREFIX + '-darwin-arm64', bin: BINARY_NAME },
15
+ 'darwin-x64': { pkg: PACKAGE_PREFIX + '-darwin-x64', bin: BINARY_NAME },
16
+ 'linux-x64': { pkg: PACKAGE_PREFIX + '-linux-x64', bin: BINARY_NAME },
17
+ 'linux-arm64': { pkg: PACKAGE_PREFIX + '-linux-arm64', bin: BINARY_NAME },
18
+ 'linux-x64-musl': {
19
+ pkg: PACKAGE_PREFIX + '-linux-x64-musl',
20
+ bin: BINARY_NAME,
21
+ },
22
+ 'linux-arm64-musl': {
23
+ pkg: PACKAGE_PREFIX + '-linux-arm64-musl',
24
+ bin: BINARY_NAME,
25
+ },
26
+ 'win32-x64': {
27
+ pkg: PACKAGE_PREFIX + '-win32-x64',
28
+ bin: BINARY_NAME + '.exe',
29
+ },
30
+ 'win32-arm64': {
31
+ pkg: PACKAGE_PREFIX + '-win32-arm64',
32
+ bin: BINARY_NAME + '.exe',
33
+ },
34
+ }
35
+
36
+ function detectMusl() {
37
+ // Termux: android is actually linux
38
+ const platform = process.platform === 'android' ? 'linux' : process.platform
39
+ if (platform !== 'linux') {
40
+ return false
41
+ }
42
+ const report =
43
+ typeof process.report?.getReport === 'function'
44
+ ? process.report.getReport()
45
+ : null
46
+ return report != null && report.header?.glibcVersionRuntime === undefined
47
+ }
48
+
49
+ function getPlatformKey() {
50
+ // Termux patch: android -> linux
51
+ let platform = process.platform
52
+ if (platform === 'android') {
53
+ platform = 'linux'
54
+ }
55
+ let cpu = arch()
56
+
57
+ // Termux is always arm64
58
+ if (platform === 'linux' && cpu === 'arm64') {
59
+ return 'linux-arm64'
60
+ }
61
+
62
+ if (platform === 'linux') {
63
+ return 'linux-' + cpu + (detectMusl() ? '-musl' : '')
64
+ }
65
+ if (platform === 'darwin' && cpu === 'x64') {
66
+ const r = spawnSync('sysctl', ['-n', 'sysctl.proc_translated'], {
67
+ encoding: 'utf8',
68
+ })
69
+ if (r.stdout?.trim() === '1') {
70
+ cpu = 'arm64'
71
+ }
72
+ }
73
+ return platform + '-' + cpu
74
+ }
75
+
76
+ function getBinaryPath() {
77
+ const platformKey = getPlatformKey()
78
+ const info = PLATFORMS[platformKey]
79
+ if (!info) {
80
+ console.error(
81
+ `[${WRAPPER_NAME}] Unsupported platform: ${process.platform} ${arch()}. Supported: ${Object.keys(PLATFORMS).join(', ')}`,
82
+ )
83
+ process.exit(1)
84
+ }
85
+ try {
86
+ const pkgDir = path.dirname(require.resolve(info.pkg + '/package.json'))
87
+ return path.join(pkgDir, info.bin)
88
+ } catch {
89
+ console.error(
90
+ `[${WRAPPER_NAME}] Could not find native binary package "${info.pkg}".`,
91
+ )
92
+ console.error(' Try reinstalling with: npm install')
93
+ process.exit(1)
94
+ }
95
+ }
96
+
97
+ function main() {
98
+ const binaryPath = getBinaryPath()
99
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
100
+ stdio: 'inherit',
101
+ env: { ...process.env, CLAUDE_CODE_INSTALLED_VIA_NPM_WRAPPER: '1' },
102
+ })
103
+ if (result.error) {
104
+ console.error(
105
+ `[${WRAPPER_NAME}] Failed to execute native binary at ` + binaryPath,
106
+ )
107
+ console.error(' ' + result.error.message)
108
+ process.exit(1)
109
+ }
110
+ if (result.signal) {
111
+ const signum = constants.signals[result.signal] ?? 0
112
+ process.exit(128 + signum)
113
+ } else {
114
+ process.exit(result.status ?? 1)
115
+ }
116
+ }
117
+
118
+ main()
package/install.cjs ADDED
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env node
2
+ // Termux/Android patched postinstall
3
+ // Patches: android -> linux for platform detection
4
+
5
+ const { spawnSync } = require('child_process')
6
+ const {
7
+ copyFileSync,
8
+ linkSync,
9
+ unlinkSync,
10
+ chmodSync,
11
+ readFileSync,
12
+ writeFileSync,
13
+ statSync,
14
+ } = require('fs')
15
+ const { arch } = require('os')
16
+ const path = require('path')
17
+
18
+ const PACKAGE_PREFIX = '@anthropic-ai/claude-code'
19
+ const BINARY_NAME = 'claude'
20
+ const WRAPPER_NAME = require('./package.json').name
21
+
22
+ const PLATFORMS = {
23
+ 'darwin-arm64': { pkg: PACKAGE_PREFIX + '-darwin-arm64', bin: BINARY_NAME },
24
+ 'darwin-x64': { pkg: PACKAGE_PREFIX + '-darwin-x64', bin: BINARY_NAME },
25
+ 'linux-x64': { pkg: PACKAGE_PREFIX + '-linux-x64', bin: BINARY_NAME },
26
+ 'linux-arm64': { pkg: PACKAGE_PREFIX + '-linux-arm64', bin: BINARY_NAME },
27
+ 'linux-x64-musl': {
28
+ pkg: PACKAGE_PREFIX + '-linux-x64-musl',
29
+ bin: BINARY_NAME,
30
+ },
31
+ 'linux-arm64-musl': {
32
+ pkg: PACKAGE_PREFIX + '-linux-arm64-musl',
33
+ bin: BINARY_NAME,
34
+ },
35
+ 'win32-x64': {
36
+ pkg: PACKAGE_PREFIX + '-win32-x64',
37
+ bin: BINARY_NAME + '.exe',
38
+ },
39
+ 'win32-arm64': {
40
+ pkg: PACKAGE_PREFIX + '-win32-arm64',
41
+ bin: BINARY_NAME + '.exe',
42
+ },
43
+ }
44
+
45
+ function detectMusl() {
46
+ // Termux: android is actually linux
47
+ const platform = process.platform === 'android' ? 'linux' : process.platform
48
+ if (platform !== 'linux') {
49
+ return false
50
+ }
51
+ const report =
52
+ typeof process.report?.getReport === 'function'
53
+ ? process.report.getReport()
54
+ : null
55
+ return report != null && report.header?.glibcVersionRuntime === undefined
56
+ }
57
+
58
+ function getPlatformKey() {
59
+ // Termux patch: android -> linux
60
+ let platform = process.platform
61
+ if (platform === 'android') {
62
+ platform = 'linux'
63
+ }
64
+ let cpu = arch()
65
+
66
+ // Termux is always arm64
67
+ if (platform === 'linux' && cpu === 'arm64') {
68
+ return 'linux-arm64'
69
+ }
70
+
71
+ if (platform === 'linux') {
72
+ return 'linux-' + cpu + (detectMusl() ? '-musl' : '')
73
+ }
74
+ if (platform === 'darwin' && cpu === 'x64') {
75
+ const r = spawnSync('sysctl', ['-n', 'sysctl.proc_translated'], {
76
+ encoding: 'utf8',
77
+ })
78
+ if (r.stdout?.trim() === '1') {
79
+ cpu = 'arm64'
80
+ }
81
+ }
82
+ return platform + '-' + cpu
83
+ }
84
+
85
+ function placeBinary(src, dest) {
86
+ try {
87
+ linkSync(src, dest)
88
+ } catch (err) {
89
+ if (err.code === 'EEXIST') {
90
+ const stub = statSync(dest).size < 4096 ? readFileSync(dest) : null
91
+ unlinkSync(dest)
92
+ try {
93
+ linkSync(src, dest)
94
+ } catch {
95
+ try {
96
+ copyFileSync(src, dest)
97
+ } catch (copyErr) {
98
+ if (stub) {
99
+ try {
100
+ writeFileSync(dest, stub, { mode: 0o755 })
101
+ } catch {}
102
+ }
103
+ throw copyErr
104
+ }
105
+ }
106
+ } else if (err.code === 'EXDEV' || err.code === 'EPERM') {
107
+ copyFileSync(src, dest)
108
+ } else {
109
+ throw err
110
+ }
111
+ }
112
+ if (process.platform !== 'win32') {
113
+ chmodSync(dest, 0o755)
114
+ }
115
+ }
116
+
117
+ function main() {
118
+ const platformKey = getPlatformKey()
119
+ const info = PLATFORMS[platformKey]
120
+
121
+ if (!info) {
122
+ console.error(
123
+ `[${WRAPPER_NAME} postinstall] Unsupported platform: ${process.platform} ${arch()}`,
124
+ )
125
+ console.error(` Supported: ${Object.keys(PLATFORMS).join(', ')}`)
126
+ return
127
+ }
128
+
129
+ let src
130
+ try {
131
+ const pkgDir = path.dirname(require.resolve(info.pkg + '/package.json'))
132
+ src = path.join(pkgDir, info.bin)
133
+ } catch {
134
+ console.error(
135
+ `[${WRAPPER_NAME} postinstall] Native package "${info.pkg}" not found.`,
136
+ )
137
+ console.error(
138
+ ' The `claude` command will print instructions when invoked.',
139
+ )
140
+ console.error(' Fallback: node ' + path.join(__dirname, 'cli-wrapper.cjs'))
141
+ return
142
+ }
143
+
144
+ const dest = path.join(__dirname, 'bin', 'claude.exe')
145
+
146
+ try {
147
+ placeBinary(src, dest)
148
+ } catch (err) {
149
+ console.error(
150
+ `[${WRAPPER_NAME} postinstall] Failed to place binary: ${err.message}`,
151
+ )
152
+ console.error(' Fallback: node ' + path.join(__dirname, 'cli-wrapper.cjs'))
153
+ process.exitCode = 1
154
+ }
155
+ }
156
+
157
+ main()
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@xurxuo/claude-code-termux",
3
+ "version": "2.1.140",
4
+ "bin": {
5
+ "claude": "bin/claude.exe"
6
+ },
7
+ "scripts": {
8
+ "postinstall": "node install.cjs"
9
+ },
10
+ "engines": {
11
+ "node": ">=18.0.0"
12
+ },
13
+ "type": "module",
14
+ "author": "XurXuo <dimarlin65@gmail.com>",
15
+ "license": "SEE LICENSE IN README.md",
16
+ "description": "Claude Code for Termux/Android - with Termux patches",
17
+ "homepage": "https://github.com/DamnSit/claude-code-termux",
18
+ "bugs": {
19
+ "url": "https://github.com/DamnSit/claude-code-termux/issues"
20
+ },
21
+ "dependencies": {},
22
+ "optionalDependencies": {
23
+ "@anthropic-ai/claude-code-linux-arm64": "2.1.140"
24
+ },
25
+ "files": [
26
+ "bin/claude.exe",
27
+ "install.cjs",
28
+ "cli-wrapper.cjs",
29
+ "sdk-tools.d.ts"
30
+ ]
31
+ }