@bash0816/claude-code 2.1.159 → 2.1.161-1
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 +198 -0
- package/README.md +12 -10
- package/config/claude-native-audited-versions.json +65 -8
- package/config/claude-termux-release-manifest.json +3 -3
- package/lib/check-updates.js +1 -11
- package/lib/prepare-native.js +32 -4
- package/lib/termux-run-claude-native.sh +669 -6
- package/lib/version-utils.js +24 -0
- package/lib/version-utils.test.js +25 -0
- package/package.json +18 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable by
|
|
79
|
+
such Contributor that are necessarily infringed by their Contribution(s)
|
|
80
|
+
alone or by combination of their Contribution(s) with the Work to
|
|
81
|
+
which such Contribution(s) was submitted. If You institute patent
|
|
82
|
+
litigation against any entity (including a cross-claim or counterclaim
|
|
83
|
+
in a lawsuit) alleging that the Work or a Contribution incorporated
|
|
84
|
+
within the Work constitutes direct or contributory patent infringement,
|
|
85
|
+
then any patent licenses granted to You under this License for that
|
|
86
|
+
Work shall terminate as of the date such litigation is filed.
|
|
87
|
+
|
|
88
|
+
4. Redistribution. You may reproduce and distribute copies of the Work
|
|
89
|
+
or Derivative Works thereof in any medium, with or without
|
|
90
|
+
modifications, and in Source or Object form, provided that You meet
|
|
91
|
+
the following conditions:
|
|
92
|
+
|
|
93
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
94
|
+
a copy of this License; and
|
|
95
|
+
|
|
96
|
+
(b) You must cause any modified files to carry prominent notices stating
|
|
97
|
+
that You changed the files; and
|
|
98
|
+
|
|
99
|
+
(c) You must retain, in the Source form of any Derivative Works that
|
|
100
|
+
You distribute, all copyright, patent, trademark, and attribution
|
|
101
|
+
notices from the Source form of the Work, excluding those notices
|
|
102
|
+
that do not pertain to any part of the Derivative Works; and
|
|
103
|
+
|
|
104
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
105
|
+
distribution, then any Derivative Works that You distribute must
|
|
106
|
+
include a readable copy of the attribution notices contained
|
|
107
|
+
within such NOTICE file, excluding those notices that do not
|
|
108
|
+
pertain to any part of the Derivative Works, in at least one of
|
|
109
|
+
the following places: within a NOTICE text file distributed as part
|
|
110
|
+
of the Derivative Works; within the Source form or documentation,
|
|
111
|
+
if provided along with the Derivative Works; or, within a display
|
|
112
|
+
generated by the Derivative Works, if and wherever such third-party
|
|
113
|
+
notices normally appear. The contents of the NOTICE file are for
|
|
114
|
+
informational purposes only and do not modify the License. You may
|
|
115
|
+
add Your own attribution notices within Derivative Works that You
|
|
116
|
+
distribute, alongside or as an addendum to the NOTICE text from the
|
|
117
|
+
Work, provided that such additional attribution notices cannot be
|
|
118
|
+
construed as modifying the License.
|
|
119
|
+
|
|
120
|
+
You may add Your own copyright statement to Your modifications and may
|
|
121
|
+
provide additional or different license terms and conditions for use,
|
|
122
|
+
reproduction, or distribution of your modifications, or for any such
|
|
123
|
+
Derivative Works as a whole, provided Your use, reproduction, and
|
|
124
|
+
distribution of the Work otherwise complies with the conditions stated
|
|
125
|
+
in this License.
|
|
126
|
+
|
|
127
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
128
|
+
any Contribution intentionally submitted for inclusion in the Work by
|
|
129
|
+
You to the Licensor shall be under the terms and conditions of this
|
|
130
|
+
License, without any additional terms or conditions. Notwithstanding
|
|
131
|
+
the above, nothing herein shall supersede or modify the terms of any
|
|
132
|
+
separate license agreement you may have executed with Licensor
|
|
133
|
+
regarding such Contributions.
|
|
134
|
+
|
|
135
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
136
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
137
|
+
except as required for reasonable and customary use in describing the
|
|
138
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
139
|
+
|
|
140
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to
|
|
141
|
+
in writing, Licensor provides the Work (and each Contributor provides
|
|
142
|
+
its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
143
|
+
CONDITIONS OF ANY KIND, either express or implied, including, without
|
|
144
|
+
limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
|
|
145
|
+
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
|
|
146
|
+
responsible for determining the appropriateness of using or
|
|
147
|
+
redistributing the Work and assume any risks associated with Your
|
|
148
|
+
exercise of permissions under this License.
|
|
149
|
+
|
|
150
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
151
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
152
|
+
unless required by applicable law (such as deliberate and grossly
|
|
153
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
154
|
+
liable to You for damages, including any direct, indirect, special,
|
|
155
|
+
incidental, or consequential damages of any character arising as a
|
|
156
|
+
result of this License or out of the use or inability to use the
|
|
157
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
158
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
159
|
+
other commercial damages or losses), even if such Contributor
|
|
160
|
+
has been advised of the possibility of such damages.
|
|
161
|
+
|
|
162
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
163
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
164
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
165
|
+
or other liability obligations and/or rights consistent with this
|
|
166
|
+
License. However, in accepting such obligations, You may act only
|
|
167
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
168
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
169
|
+
defend, and hold each Contributor harmless for any liability
|
|
170
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
171
|
+
of your accepting any such warranty or additional liability.
|
|
172
|
+
|
|
173
|
+
END OF TERMS AND CONDITIONS
|
|
174
|
+
|
|
175
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
176
|
+
|
|
177
|
+
To apply the Apache License to your work, attach the following
|
|
178
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
179
|
+
replaced with your own identifying information. (Don't include
|
|
180
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
181
|
+
comment syntax for the file format. We also recommend that a
|
|
182
|
+
file or class name and description of purpose be included on the
|
|
183
|
+
same "printed page" as the copyright notice for easier
|
|
184
|
+
identification within third-party archives.
|
|
185
|
+
|
|
186
|
+
Copyright {yyyy} {name of copyright owner}
|
|
187
|
+
|
|
188
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
189
|
+
you may not use this file except in compliance with the License.
|
|
190
|
+
You may obtain a copy of the License at
|
|
191
|
+
|
|
192
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
193
|
+
|
|
194
|
+
Unless required by applicable law or agreed to in writing, software
|
|
195
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
196
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
197
|
+
See the License for the specific language governing permissions and
|
|
198
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -34,16 +34,10 @@ After npm owns the `claude` bin link, normal `npm install -g` updates work.
|
|
|
34
34
|
|
|
35
35
|
npm が `claude` bin link を管理する状態になれば、通常の `npm install -g` 更新が使えます。
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
監査済みの固定 version:
|
|
40
|
-
|
|
41
|
-
Current quick examples:
|
|
42
|
-
|
|
43
|
-
現在の quick example:
|
|
37
|
+
Latest audited version / 最新監査済み版:
|
|
44
38
|
|
|
45
39
|
```sh
|
|
46
|
-
npm install -g @bash0816/claude-code@2.1.
|
|
40
|
+
npm install -g @bash0816/claude-code@2.1.161-1
|
|
47
41
|
```
|
|
48
42
|
|
|
49
43
|
## Update / 更新
|
|
@@ -60,6 +54,14 @@ claude update
|
|
|
60
54
|
npm install -g @bash0816/claude-code@<latest_audited_version>
|
|
61
55
|
```
|
|
62
56
|
|
|
57
|
+
If you already have the repo's `2.1.161` release or the official upstream
|
|
58
|
+
`2.1.165` installed, install `2.1.161-1` explicitly. `claude update` will not
|
|
59
|
+
roll a newer installed terminal back to this repo's current audited release.
|
|
60
|
+
|
|
61
|
+
この repo の `2.1.161` release または official upstream の `2.1.165` を
|
|
62
|
+
すでに入れている端末では、`2.1.161-1` を明示 install してください。
|
|
63
|
+
`claude update` だけでは、より新しい端末をこの repo の現在の audited release に戻しません。
|
|
64
|
+
|
|
63
65
|
Normal launch also checks the same manifest with a short timeout and prints a notice when a newer audited version is available.
|
|
64
66
|
|
|
65
67
|
通常起動時も、同じ manifest を短い timeout で確認し、新しい監査済み version があれば通知します。
|
|
@@ -68,8 +70,8 @@ Normal launch also checks the same manifest with a short timeout and prints a no
|
|
|
68
70
|
|
|
69
71
|
- Only audited versions in `config/claude-native-audited-versions.json` can run.
|
|
70
72
|
- `config/claude-native-audited-versions.json` にある監査済み version だけを実行できます。
|
|
71
|
-
-
|
|
72
|
-
- `
|
|
73
|
+
- See `config/claude-native-audited-versions.json` for the full list of included versions.
|
|
74
|
+
- 含まれるバージョンの全リストは `config/claude-native-audited-versions.json` を参照してください。
|
|
73
75
|
- The metadata file is the source of truth for the currently audited set.
|
|
74
76
|
- 現在の監査済み version 集合の source of truth は metadata file です。
|
|
75
77
|
- Native artifacts are cached under `${HOME}/.claude-termux-native-package`.
|
|
@@ -182,22 +182,79 @@
|
|
|
182
182
|
"entry_end_offset": 238725072,
|
|
183
183
|
"status": "termux_verified"
|
|
184
184
|
},
|
|
185
|
-
"2.1.
|
|
186
|
-
"wrapper_spec": "@anthropic-ai/claude-code@2.1.
|
|
187
|
-
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.
|
|
188
|
-
"entry_js_offset":
|
|
189
|
-
"entry_end_offset":
|
|
190
|
-
"
|
|
191
|
-
"
|
|
185
|
+
"2.1.159-2": {
|
|
186
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.159",
|
|
187
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.159",
|
|
188
|
+
"entry_js_offset": 223232708,
|
|
189
|
+
"entry_end_offset": 238749397,
|
|
190
|
+
"tarball_integrity": "sha512-c8dXbuQdrotGWll46GlnXm5IPpORK2VrBSosCmI6f8t7Snc/3F58fX0MbIjJ/ycXpY0aaKuOnufCuxf7wi1Xqw==",
|
|
191
|
+
"tarball_sha256": "0b551634f11742310ba3b6344fb7912ba1ed8ee0ef4702eab0099d31b4eeb070",
|
|
192
192
|
"status": "offset_discovered"
|
|
193
193
|
},
|
|
194
|
-
"2.1.159": {
|
|
194
|
+
"2.1.159-4": {
|
|
195
195
|
"wrapper_spec": "@anthropic-ai/claude-code@2.1.159",
|
|
196
196
|
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.159",
|
|
197
197
|
"entry_js_offset": 223232708,
|
|
198
198
|
"entry_end_offset": 238749397,
|
|
199
|
+
"tarball_integrity": "sha512-c8dXbuQdrotGWll46GlnXm5IPpORK2VrBSosCmI6f8t7Snc/3F58fX0MbIjJ/ycXpY0aaKuOnufCuxf7wi1Xqw==",
|
|
199
200
|
"tarball_sha256": "0b551634f11742310ba3b6344fb7912ba1ed8ee0ef4702eab0099d31b4eeb070",
|
|
201
|
+
"status": "termux_verified"
|
|
202
|
+
},
|
|
203
|
+
"2.1.159-5": {
|
|
204
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.159",
|
|
205
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.159",
|
|
206
|
+
"entry_js_offset": 223232708,
|
|
207
|
+
"entry_end_offset": 238749397,
|
|
208
|
+
"tarball_integrity": "sha512-c8dXbuQdrotGWll46GlnXm5IPpORK2VrBSosCmI6f8t7Snc/3F58fX0MbIjJ/ycXpY0aaKuOnufCuxf7wi1Xqw==",
|
|
209
|
+
"tarball_sha256": "0b551634f11742310ba3b6344fb7912ba1ed8ee0ef4702eab0099d31b4eeb070",
|
|
210
|
+
"status": "offset_discovered"
|
|
211
|
+
},
|
|
212
|
+
"2.1.159-8": {
|
|
213
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.159",
|
|
214
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.159",
|
|
215
|
+
"entry_js_offset": 223232708,
|
|
216
|
+
"entry_end_offset": 238749397,
|
|
200
217
|
"tarball_integrity": "sha512-c8dXbuQdrotGWll46GlnXm5IPpORK2VrBSosCmI6f8t7Snc/3F58fX0MbIjJ/ycXpY0aaKuOnufCuxf7wi1Xqw==",
|
|
218
|
+
"tarball_sha256": "0b551634f11742310ba3b6344fb7912ba1ed8ee0ef4702eab0099d31b4eeb070",
|
|
219
|
+
"status": "termux_verified"
|
|
220
|
+
},
|
|
221
|
+
"2.1.159-13": {
|
|
222
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.159",
|
|
223
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.159",
|
|
224
|
+
"entry_js_offset": 223232708,
|
|
225
|
+
"entry_end_offset": 238749397,
|
|
226
|
+
"tarball_integrity": "sha512-P6fld9U2MQWZfdEskwjWar4r/wXPQRiYXnwn/TVN2rURHiII0xJuWS/PeTICXMiOZYTbjEGXvPWj/N/FK9YnHA==",
|
|
227
|
+
"tarball_sha256": "634d412b07f04cd43ceefacd8f13166d30d8b47adb8dc2e25a7786eebc598d70",
|
|
228
|
+
"tarball_size": 14768,
|
|
229
|
+
"status": "termux_verified"
|
|
230
|
+
},
|
|
231
|
+
"2.1.161": {
|
|
232
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.161",
|
|
233
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.161",
|
|
234
|
+
"entry_js_offset": 225551924,
|
|
235
|
+
"entry_end_offset": 241503454,
|
|
236
|
+
"tarball_integrity": "sha512-rLEzd8/q4UnTLDSAd3eYgog+G0iZ8y6K8yh0gSxf82d7uOkypYaBUkbmFENuHuzIzCIf9Yy/utCJfp6kQFjUow==",
|
|
237
|
+
"tarball_sha256": "e87d973bbe58593e06c101196f6417f7d950bf777cb9f1a8ff002ebf987ea066",
|
|
238
|
+
"tarball_size": 74314760,
|
|
239
|
+
"status": "offset_discovered"
|
|
240
|
+
},
|
|
241
|
+
"2.1.161-1": {
|
|
242
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.161",
|
|
243
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.161",
|
|
244
|
+
"entry_js_offset": 225551924,
|
|
245
|
+
"entry_end_offset": 241503454,
|
|
246
|
+
"tarball_integrity": "sha512-rLEzd8/q4UnTLDSAd3eYgog+G0iZ8y6K8yh0gSxf82d7uOkypYaBUkbmFENuHuzIzCIf9Yy/utCJfp6kQFjUow==",
|
|
247
|
+
"tarball_sha256": "e87d973bbe58593e06c101196f6417f7d950bf777cb9f1a8ff002ebf987ea066",
|
|
248
|
+
"tarball_size": 74314760,
|
|
249
|
+
"status": "termux_verified"
|
|
250
|
+
},
|
|
251
|
+
"2.1.165": {
|
|
252
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.165",
|
|
253
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.165",
|
|
254
|
+
"entry_js_offset": 226798932,
|
|
255
|
+
"entry_end_offset": 242980856,
|
|
256
|
+
"tarball_integrity": "sha512-uGwKxRQGTxh3BZGnX096CLf/2us5lUFnk4KerWhG4WCpRiEUSu4TUDojp/S3SUzA//FpM57fViUW07XL3T19lw==",
|
|
257
|
+
"tarball_sha256": "6dc6d84624bedaf5ff0948b178fdfc9c2724d8051cb00e70559e292055f7155e",
|
|
201
258
|
"status": "offset_discovered"
|
|
202
259
|
}
|
|
203
260
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 1,
|
|
3
3
|
"package_name": "@bash0816/claude-code",
|
|
4
|
-
"latest_audited_version": "2.1.
|
|
5
|
-
"latest_candidate_version": "2.1.
|
|
6
|
-
"previous_stable_version": "2.1.
|
|
4
|
+
"latest_audited_version": "2.1.161-1",
|
|
5
|
+
"latest_candidate_version": "2.1.165",
|
|
6
|
+
"previous_stable_version": "2.1.159-13",
|
|
7
7
|
"manifest_url": "https://raw.githubusercontent.com/bash0816/ClaudeCode-Termux/main/config/claude-termux-release-manifest.json"
|
|
8
8
|
}
|
package/lib/check-updates.js
CHANGED
|
@@ -10,6 +10,7 @@ const path = require('path');
|
|
|
10
10
|
const packageDir = path.resolve(__dirname, '..');
|
|
11
11
|
const pkg = require(path.join(packageDir, 'package.json'));
|
|
12
12
|
const localManifest = require(path.join(packageDir, 'config', 'claude-termux-release-manifest.json'));
|
|
13
|
+
const { compareVersions } = require('./version-utils');
|
|
13
14
|
const mode = process.argv[2] || 'notify';
|
|
14
15
|
const currentVersion = process.argv[3] || pkg.version;
|
|
15
16
|
const dryRun = process.argv.includes('--dry-run');
|
|
@@ -20,17 +21,6 @@ const ttlMs = Number(process.env.CLAUDE_TERMUX_UPDATE_CACHE_TTL_MS || String(24
|
|
|
20
21
|
const skipCheck = process.env.CLAUDE_TERMUX_SKIP_UPDATE_CHECK === '1';
|
|
21
22
|
const manifestUrl = process.env.CLAUDE_TERMUX_MANIFEST_URL || localManifest.manifest_url;
|
|
22
23
|
|
|
23
|
-
function compareVersions(a, b) {
|
|
24
|
-
const aParts = String(a).split('.').map(Number);
|
|
25
|
-
const bParts = String(b).split('.').map(Number);
|
|
26
|
-
const len = Math.max(aParts.length, bParts.length);
|
|
27
|
-
for (let index = 0; index < len; index += 1) {
|
|
28
|
-
const diff = (aParts[index] || 0) - (bParts[index] || 0);
|
|
29
|
-
if (diff !== 0) return diff;
|
|
30
|
-
}
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
24
|
function readCache() {
|
|
35
25
|
try {
|
|
36
26
|
return JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
|
package/lib/prepare-native.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const cp = require('child_process');
|
|
5
|
+
const crypto = require('crypto');
|
|
5
6
|
const fs = require('fs');
|
|
6
7
|
const os = require('os');
|
|
7
8
|
const path = require('path');
|
|
@@ -35,6 +36,7 @@ const packDir = fs.mkdtempSync(path.join(os.tmpdir(), `claude-code-${version}-`)
|
|
|
35
36
|
|
|
36
37
|
try {
|
|
37
38
|
const tgzPath = fetchNativeTarball(item.native_spec, packDir);
|
|
39
|
+
verifyTarball(tgzPath, item);
|
|
38
40
|
|
|
39
41
|
const extractDir = path.join(packDir, 'native');
|
|
40
42
|
fs.mkdirSync(extractDir, { recursive: true });
|
|
@@ -89,14 +91,40 @@ function fetchNativeTarball(spec, packDir) {
|
|
|
89
91
|
} catch (error) {
|
|
90
92
|
console.error(`Direct tarball fetch failed for ${spec}; falling back to npm pack.`);
|
|
91
93
|
console.error(error && error.message ? error.message : String(error));
|
|
94
|
+
fs.rmSync(directTarball, { force: true });
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
const packJson = runCapture('npm', ['pack', spec, '--pack-destination', packDir, '--json']);
|
|
98
|
+
let packEntries;
|
|
99
|
+
try {
|
|
100
|
+
packEntries = JSON.parse(packJson);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
throw new Error(`npm pack did not return valid JSON for ${spec}`);
|
|
103
|
+
}
|
|
104
|
+
const packEntry = Array.isArray(packEntries) ? packEntries.find(entry => entry && entry.filename) : null;
|
|
105
|
+
if (!packEntry || !packEntry.filename) {
|
|
97
106
|
throw new Error('npm pack did not produce a tgz');
|
|
98
107
|
}
|
|
99
|
-
return path.join(packDir,
|
|
108
|
+
return path.join(packDir, packEntry.filename);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function verifyTarball(file, audited) {
|
|
112
|
+
const buf = fs.readFileSync(file);
|
|
113
|
+
if (audited.tarball_sha256) {
|
|
114
|
+
const sha256 = crypto.createHash('sha256').update(buf).digest('hex');
|
|
115
|
+
if (sha256 !== audited.tarball_sha256) {
|
|
116
|
+
throw new Error(`tarball sha256 mismatch for ${version}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (audited.tarball_integrity) {
|
|
120
|
+
const sha512 = `sha512-${crypto.createHash('sha512').update(buf).digest('base64')}`;
|
|
121
|
+
if (sha512 !== audited.tarball_integrity) {
|
|
122
|
+
throw new Error(`tarball integrity mismatch for ${version}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (audited.tarball_size !== undefined && Number(audited.tarball_size) !== buf.length) {
|
|
126
|
+
throw new Error(`tarball size mismatch for ${version}`);
|
|
127
|
+
}
|
|
100
128
|
}
|
|
101
129
|
|
|
102
130
|
function validateOffsets(file, audited) {
|
|
@@ -40,7 +40,18 @@ export ENTRY_JS_OFFSET
|
|
|
40
40
|
export ENTRY_END_OFFSET
|
|
41
41
|
export CURRENT_CLAUDE_VERSION
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
_pf=0
|
|
44
|
+
for _a in "$@"; do
|
|
45
|
+
case "$_a" in
|
|
46
|
+
-p|--print) _pf=1; break ;;
|
|
47
|
+
--) break ;;
|
|
48
|
+
esac
|
|
49
|
+
done
|
|
50
|
+
|
|
51
|
+
if [ "$_pf" = "1" ] && [ "${CLAUDE_TERMUX_STDIN:-}" != "inherit" ]; then
|
|
52
|
+
_helper=$(mktemp "${TMPDIR:-/tmp}/claude-helper.XXXXXX.js")
|
|
53
|
+
trap 'rm -f "$_helper"' EXIT HUP INT TERM
|
|
54
|
+
cat <<'NODE' > "$_helper"
|
|
44
55
|
const fs = require('fs');
|
|
45
56
|
const path = require('path');
|
|
46
57
|
const {
|
|
@@ -64,8 +75,6 @@ class RequestedExit extends Error {
|
|
|
64
75
|
|
|
65
76
|
function ensureEntryFile() {
|
|
66
77
|
const extractedFile = path.join(workdir, `cli.${entryJsOffset}.${entryEndOffset}.bare-path.js`);
|
|
67
|
-
if (fs.existsSync(extractedFile)) return extractedFile;
|
|
68
|
-
|
|
69
78
|
const len = entryEndOffset - entryJsOffset;
|
|
70
79
|
if (!(len > 0)) throw new Error('invalid replay offsets');
|
|
71
80
|
|
|
@@ -89,8 +98,155 @@ function stringWidth(value) {
|
|
|
89
98
|
return Array.from(text).length;
|
|
90
99
|
}
|
|
91
100
|
|
|
101
|
+
function parseScalar(value) {
|
|
102
|
+
const text = String(value ?? '').trim();
|
|
103
|
+
if (text === '') return '';
|
|
104
|
+
if (text === 'true') return true;
|
|
105
|
+
if (text === 'false') return false;
|
|
106
|
+
if (text === 'null' || text === '~') return null;
|
|
107
|
+
if (/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(text)) return Number(text);
|
|
108
|
+
if (
|
|
109
|
+
(text.startsWith('"') && text.endsWith('"')) ||
|
|
110
|
+
(text.startsWith("'") && text.endsWith("'"))
|
|
111
|
+
) {
|
|
112
|
+
return text.slice(1, -1);
|
|
113
|
+
}
|
|
114
|
+
return text;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function parseInlineArray(value) {
|
|
118
|
+
const inner = String(value ?? '').trim().slice(1, -1).trim();
|
|
119
|
+
if (inner === '') return [];
|
|
120
|
+
const items = [];
|
|
121
|
+
let current = '';
|
|
122
|
+
let quote = null;
|
|
123
|
+
|
|
124
|
+
for (let i = 0; i < inner.length; i += 1) {
|
|
125
|
+
const ch = inner[i];
|
|
126
|
+
if (quote) {
|
|
127
|
+
if (ch === quote && inner[i - 1] !== '\\') quote = null;
|
|
128
|
+
current += ch;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (ch === '"' || ch === "'") {
|
|
132
|
+
quote = ch;
|
|
133
|
+
current += ch;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (ch === ',') {
|
|
137
|
+
items.push(parseScalar(current));
|
|
138
|
+
current = '';
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
current += ch;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (current !== '') items.push(parseScalar(current));
|
|
145
|
+
return items;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function yamlParse(text) {
|
|
149
|
+
const source = String(text ?? '');
|
|
150
|
+
const result = {};
|
|
151
|
+
for (const rawLine of source.split(/\r?\n/)) {
|
|
152
|
+
const line = rawLine.trim();
|
|
153
|
+
if (!line || line.startsWith('#')) continue;
|
|
154
|
+
const idx = line.indexOf(':');
|
|
155
|
+
if (idx < 0) continue;
|
|
156
|
+
const key = line.slice(0, idx).trim();
|
|
157
|
+
const rawValue = line.slice(idx + 1).trim();
|
|
158
|
+
if (!key) continue;
|
|
159
|
+
result[key] = rawValue.startsWith('[') && rawValue.endsWith(']')
|
|
160
|
+
? parseInlineArray(rawValue)
|
|
161
|
+
: parseScalar(rawValue);
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function yamlStringify(value) {
|
|
167
|
+
if (!value || typeof value !== 'object') return String(value ?? '');
|
|
168
|
+
const lines = [];
|
|
169
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
170
|
+
if (Array.isArray(raw)) {
|
|
171
|
+
lines.push(`${key}: [${raw.map(item => JSON.stringify(String(item))).join(', ')}]`);
|
|
172
|
+
} else if (raw === null) {
|
|
173
|
+
lines.push(`${key}: null`);
|
|
174
|
+
} else if (typeof raw === 'string') {
|
|
175
|
+
lines.push(`${key}: ${JSON.stringify(raw)}`);
|
|
176
|
+
} else {
|
|
177
|
+
lines.push(`${key}: ${String(raw)}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return lines.join('\n');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function createYamlShim() {
|
|
184
|
+
const yaml = {
|
|
185
|
+
parse: yamlParse,
|
|
186
|
+
stringify: yamlStringify,
|
|
187
|
+
};
|
|
188
|
+
yaml.YAML = yaml;
|
|
189
|
+
yaml.default = yaml;
|
|
190
|
+
return yaml;
|
|
191
|
+
}
|
|
192
|
+
|
|
92
193
|
function createFakeRequire(realRequire) {
|
|
93
194
|
const realChild = realRequire('child_process');
|
|
195
|
+
const realVm = realRequire('vm');
|
|
196
|
+
|
|
197
|
+
function injectBunIntoContext(context) {
|
|
198
|
+
if (!context || typeof context !== 'object') return context;
|
|
199
|
+
try {
|
|
200
|
+
if (!Object.prototype.hasOwnProperty.call(context, '__claudeYaml')) {
|
|
201
|
+
Object.defineProperty(context, '__claudeYaml', {
|
|
202
|
+
value: globalThis.__claudeYaml,
|
|
203
|
+
configurable: true,
|
|
204
|
+
writable: true,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if (!Object.prototype.hasOwnProperty.call(context, '__claudeBunShim')) {
|
|
208
|
+
Object.defineProperty(context, '__claudeBunShim', {
|
|
209
|
+
value: globalThis.__claudeBunShim,
|
|
210
|
+
configurable: true,
|
|
211
|
+
writable: true,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
if (!Object.prototype.hasOwnProperty.call(context, '__claudeBun')) {
|
|
215
|
+
Object.defineProperty(context, '__claudeBun', {
|
|
216
|
+
value: globalThis.__claudeBunShim,
|
|
217
|
+
configurable: true,
|
|
218
|
+
writable: true,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
if (Object.prototype.hasOwnProperty.call(context, 'Bun')) {
|
|
222
|
+
if (context.Bun && typeof context.Bun === 'object' && context.Bun !== globalThis.Bun) {
|
|
223
|
+
try {
|
|
224
|
+
context.Bun = globalThis.Bun;
|
|
225
|
+
} catch {
|
|
226
|
+
Object.defineProperty(context, 'Bun', {
|
|
227
|
+
value: globalThis.Bun,
|
|
228
|
+
configurable: true,
|
|
229
|
+
writable: true,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (!context.Bun || typeof context.Bun !== 'object') {
|
|
234
|
+
Object.defineProperty(context, 'Bun', {
|
|
235
|
+
value: globalThis.Bun,
|
|
236
|
+
configurable: true,
|
|
237
|
+
writable: true,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
Object.defineProperty(context, 'Bun', {
|
|
242
|
+
value: globalThis.Bun,
|
|
243
|
+
configurable: true,
|
|
244
|
+
writable: true,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
} catch {}
|
|
248
|
+
return context;
|
|
249
|
+
}
|
|
94
250
|
|
|
95
251
|
function rewriteArgs(args) {
|
|
96
252
|
if (
|
|
@@ -129,6 +285,49 @@ function createFakeRequire(realRequire) {
|
|
|
129
285
|
return { default: WS, WebSocket: WS };
|
|
130
286
|
}
|
|
131
287
|
|
|
288
|
+
if (id === 'vm' || id === 'node:vm') {
|
|
289
|
+
if (!realVm.__claudeBunShimPatched) {
|
|
290
|
+
const originalCreateContext = realVm.createContext.bind(realVm);
|
|
291
|
+
const originalRunInNewContext = realVm.runInNewContext.bind(realVm);
|
|
292
|
+
const originalRunInContext = realVm.runInContext.bind(realVm);
|
|
293
|
+
const originalRunInThisContext = realVm.runInThisContext && realVm.runInThisContext.bind(realVm);
|
|
294
|
+
const scriptProto = realVm.Script && realVm.Script.prototype;
|
|
295
|
+
|
|
296
|
+
realVm.createContext = (contextObject, ...rest) =>
|
|
297
|
+
originalCreateContext(injectBunIntoContext(contextObject), ...rest);
|
|
298
|
+
realVm.runInNewContext = (code, contextObject, ...rest) =>
|
|
299
|
+
originalRunInNewContext(code, injectBunIntoContext(contextObject), ...rest);
|
|
300
|
+
realVm.runInContext = (code, contextObject, ...rest) =>
|
|
301
|
+
originalRunInContext(code, injectBunIntoContext(contextObject), ...rest);
|
|
302
|
+
if (originalRunInThisContext) {
|
|
303
|
+
realVm.runInThisContext = (code, ...rest) => originalRunInThisContext(code, ...rest);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (scriptProto && !scriptProto.__claudeBunShimPatched) {
|
|
307
|
+
const originalScriptRunInContext = scriptProto.runInContext;
|
|
308
|
+
const originalScriptRunInNewContext = scriptProto.runInNewContext;
|
|
309
|
+
const originalScriptRunInThisContext = scriptProto.runInThisContext;
|
|
310
|
+
|
|
311
|
+
scriptProto.runInContext = function (contextObject, ...rest) {
|
|
312
|
+
return originalScriptRunInContext.call(this, injectBunIntoContext(contextObject), ...rest);
|
|
313
|
+
};
|
|
314
|
+
scriptProto.runInNewContext = function (contextObject, ...rest) {
|
|
315
|
+
return originalScriptRunInNewContext.call(this, injectBunIntoContext(contextObject), ...rest);
|
|
316
|
+
};
|
|
317
|
+
if (originalScriptRunInThisContext) {
|
|
318
|
+
scriptProto.runInThisContext = function (...rest) {
|
|
319
|
+
return originalScriptRunInThisContext.call(this, ...rest);
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
Object.defineProperty(scriptProto, '__claudeBunShimPatched', { value: true });
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
Object.defineProperty(realVm, '__claudeBunShimPatched', { value: true });
|
|
327
|
+
}
|
|
328
|
+
return realVm;
|
|
329
|
+
}
|
|
330
|
+
|
|
132
331
|
if (id === 'child_process') {
|
|
133
332
|
return guardedChild;
|
|
134
333
|
}
|
|
@@ -148,7 +347,23 @@ function createFakeRequire(realRequire) {
|
|
|
148
347
|
async function main() {
|
|
149
348
|
const extractedFile = ensureEntryFile();
|
|
150
349
|
const code = fs.readFileSync(extractedFile, 'utf8');
|
|
151
|
-
const
|
|
350
|
+
const patchedCode = code.replace(
|
|
351
|
+
/^function\(exports, require, module, __filename, __dirname\) \{/,
|
|
352
|
+
'function(exports, require, module, __filename, __dirname) {var __claudeBun = globalThis.__claudeBunShim;',
|
|
353
|
+
).replace(
|
|
354
|
+
/\btypeof Bun\b/g,
|
|
355
|
+
'typeof __claudeBun',
|
|
356
|
+
).replace(
|
|
357
|
+
/\bBun\./g,
|
|
358
|
+
'__claudeBun.',
|
|
359
|
+
).replace(
|
|
360
|
+
/function t5q\(q\)\{return Bun\.YAML\.parse\(q\)\}/g,
|
|
361
|
+
'function t5q(q){return globalThis.__claudeYaml.parse(q)}',
|
|
362
|
+
).replace(
|
|
363
|
+
/function VK6\(q\)\{return Bun\.YAML\.stringify\(q,null,2\)\+`/g,
|
|
364
|
+
'function VK6(q){return globalThis.__claudeYaml.stringify(q,null,2)+`',
|
|
365
|
+
);
|
|
366
|
+
const fn = eval('(' + patchedCode.replace(/\)\s*$/, '') + ')');
|
|
152
367
|
|
|
153
368
|
const originalArgv = process.argv.slice();
|
|
154
369
|
const originalExit = process.exit;
|
|
@@ -157,6 +372,10 @@ async function main() {
|
|
|
157
372
|
const originalGlobalBun = globalThis.Bun;
|
|
158
373
|
const asyncErrors = [];
|
|
159
374
|
|
|
375
|
+
globalThis.__claudeYaml = createYamlShim();
|
|
376
|
+
if (!globalThis.__claudeBunShim || typeof globalThis.__claudeBunShim !== 'object') {
|
|
377
|
+
globalThis.__claudeBunShim = {};
|
|
378
|
+
}
|
|
160
379
|
const fakeRequire = createFakeRequire(require);
|
|
161
380
|
function onAsyncError(error) {
|
|
162
381
|
asyncErrors.push(error);
|
|
@@ -166,7 +385,55 @@ async function main() {
|
|
|
166
385
|
process.once('uncaughtException', onAsyncError);
|
|
167
386
|
process.once('unhandledRejection', onAsyncError);
|
|
168
387
|
Object.defineProperty(process.versions, 'bun', { value: '1.1.8', configurable: true });
|
|
169
|
-
|
|
388
|
+
const _realChild = require('child_process');
|
|
389
|
+
globalThis.Bun = {
|
|
390
|
+
version: '1.1.8',
|
|
391
|
+
stringWidth,
|
|
392
|
+
which: (cmd) => {
|
|
393
|
+
try {
|
|
394
|
+
return _realChild.execFileSync('which', [String(cmd)], { encoding: 'utf8' }).trim() || null;
|
|
395
|
+
} catch { return null; }
|
|
396
|
+
},
|
|
397
|
+
semver: (() => {
|
|
398
|
+
const _cmp = (a, b) => {
|
|
399
|
+
const pa = String(a).replace(/[^0-9.]/g,'').split('.').map(Number);
|
|
400
|
+
const pb = String(b).replace(/[^0-9.]/g,'').split('.').map(Number);
|
|
401
|
+
for (let i = 0; i < 3; i++) { const d = (pa[i]||0)-(pb[i]||0); if (d) return d > 0 ? 1 : -1; }
|
|
402
|
+
return 0;
|
|
403
|
+
};
|
|
404
|
+
const _satisfies = (ver, range) => {
|
|
405
|
+
const s = String(range).trim();
|
|
406
|
+
const m = s.match(/^([><=!]{1,2})\s*([\d]+(?:\.[\d]+){0,2})$/);
|
|
407
|
+
if (m) {
|
|
408
|
+
const op = m[1], c = _cmp(ver, m[2]);
|
|
409
|
+
if (op === '>') return c > 0;
|
|
410
|
+
if (op === '>=') return c >= 0;
|
|
411
|
+
if (op === '<') return c < 0;
|
|
412
|
+
if (op === '<=') return c <= 0;
|
|
413
|
+
if (op === '=' || op === '==') return c === 0;
|
|
414
|
+
if (op === '!=') return c !== 0;
|
|
415
|
+
}
|
|
416
|
+
if (/^[\d]+(?:\.[\d]+){0,2}$/.test(s)) return _cmp(ver, s) === 0;
|
|
417
|
+
return false;
|
|
418
|
+
};
|
|
419
|
+
return {
|
|
420
|
+
order: (a, b) => _cmp(a, b),
|
|
421
|
+
compare: (a, b) => _cmp(a, b),
|
|
422
|
+
satisfies: (ver, range) => _satisfies(ver, range),
|
|
423
|
+
gt: (a, b) => _cmp(a, b) > 0,
|
|
424
|
+
gte: (a, b) => _cmp(a, b) >= 0,
|
|
425
|
+
lt: (a, b) => _cmp(a, b) < 0,
|
|
426
|
+
lte: (a, b) => _cmp(a, b) <= 0,
|
|
427
|
+
};
|
|
428
|
+
})(),
|
|
429
|
+
YAML: globalThis.__claudeYaml,
|
|
430
|
+
};
|
|
431
|
+
Object.assign(globalThis.__claudeBunShim, globalThis.Bun);
|
|
432
|
+
if (typeof globalThis.__claudeBunShim.gc !== 'function') {
|
|
433
|
+
globalThis.__claudeBunShim.gc = () => {};
|
|
434
|
+
}
|
|
435
|
+
globalThis.__claudeBun = globalThis.__claudeBunShim;
|
|
436
|
+
globalThis.Bun = globalThis.__claudeBunShim;
|
|
170
437
|
process.argv = ['node', extractedFile, ...argv];
|
|
171
438
|
process.exit = code => {
|
|
172
439
|
throw new RequestedExit(code);
|
|
@@ -175,7 +442,7 @@ async function main() {
|
|
|
175
442
|
const moduleLike = { exports: {} };
|
|
176
443
|
const maybePromise = fn(moduleLike.exports, fakeRequire, moduleLike, extractedFile, workdir);
|
|
177
444
|
if (maybePromise && typeof maybePromise.then === 'function') await maybePromise;
|
|
178
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
445
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
179
446
|
if (asyncErrors.length > 0) throw asyncErrors[0];
|
|
180
447
|
} catch (error) {
|
|
181
448
|
if (error instanceof RequestedExit) {
|
|
@@ -195,6 +462,9 @@ async function main() {
|
|
|
195
462
|
Object.defineProperty(process.versions, 'bun', { value: originalBun, configurable: true });
|
|
196
463
|
}
|
|
197
464
|
} catch {}
|
|
465
|
+
delete globalThis.__claudeYaml;
|
|
466
|
+
delete globalThis.__claudeBunShim;
|
|
467
|
+
delete globalThis.__claudeBun;
|
|
198
468
|
if (hadGlobalBun) globalThis.Bun = originalGlobalBun;
|
|
199
469
|
else delete globalThis.Bun;
|
|
200
470
|
}
|
|
@@ -209,3 +479,396 @@ main().catch(error => {
|
|
|
209
479
|
process.exit(1);
|
|
210
480
|
});
|
|
211
481
|
NODE
|
|
482
|
+
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="${CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:-1}"
|
|
483
|
+
export ENABLE_CLAUDEAI_MCP_SERVERS="${ENABLE_CLAUDEAI_MCP_SERVERS:-0}"
|
|
484
|
+
export CLAUDE_CODE_SIMPLE="${CLAUDE_CODE_SIMPLE:-0}"
|
|
485
|
+
node "$_helper" "$@" </dev/null
|
|
486
|
+
_status=$?
|
|
487
|
+
rm -f "$_helper"
|
|
488
|
+
trap - EXIT HUP INT TERM
|
|
489
|
+
exit "$_status"
|
|
490
|
+
else
|
|
491
|
+
_bootstrap=$(mktemp "${TMPDIR:-/tmp}/claude-bootstrap.XXXXXX.js")
|
|
492
|
+
trap 'rm -f "$_bootstrap"' EXIT HUP INT TERM
|
|
493
|
+
cat <<'NODE' > "$_bootstrap"
|
|
494
|
+
const fs = require('fs');
|
|
495
|
+
const path = require('path');
|
|
496
|
+
const {
|
|
497
|
+
BLOCK_MESSAGE,
|
|
498
|
+
createGuardedChildProcess,
|
|
499
|
+
} = require(path.join(process.env.CLAUDE_TERMUX_PACKAGE_DIR, 'lib', 'native-update-guard.js'));
|
|
500
|
+
|
|
501
|
+
const sourceBin = process.env.SOURCE_BIN;
|
|
502
|
+
const workdir = process.env.WORKDIR;
|
|
503
|
+
const entryJsOffset = Number(process.env.ENTRY_JS_OFFSET);
|
|
504
|
+
const entryEndOffset = Number(process.env.ENTRY_END_OFFSET);
|
|
505
|
+
const argv = process.argv.slice(2);
|
|
506
|
+
|
|
507
|
+
class RequestedExit extends Error {
|
|
508
|
+
constructor(code) {
|
|
509
|
+
super(`process.exit ${code}`);
|
|
510
|
+
this.name = 'RequestedExit';
|
|
511
|
+
this.code = code;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function ensureEntryFile() {
|
|
516
|
+
const extractedFile = path.join(workdir, `cli.${entryJsOffset}.${entryEndOffset}.bare-path.js`);
|
|
517
|
+
const len = entryEndOffset - entryJsOffset;
|
|
518
|
+
if (!(len > 0)) throw new Error('invalid replay offsets');
|
|
519
|
+
|
|
520
|
+
const fd = fs.openSync(sourceBin, 'r');
|
|
521
|
+
const buf = Buffer.alloc(len);
|
|
522
|
+
fs.readSync(fd, buf, 0, len, entryJsOffset);
|
|
523
|
+
fs.closeSync(fd);
|
|
524
|
+
|
|
525
|
+
fs.writeFileSync(extractedFile, buf.toString('utf8').replace(/[\0\s]+$/g, ''));
|
|
526
|
+
return extractedFile;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function stringWidth(value) {
|
|
530
|
+
const text = String(value ?? '');
|
|
531
|
+
if (typeof Intl !== 'undefined' && typeof Intl.Segmenter === 'function') {
|
|
532
|
+
const segmenter = new Intl.Segmenter('en', { granularity: 'grapheme' });
|
|
533
|
+
let width = 0;
|
|
534
|
+
for (const _segment of segmenter.segment(text)) width += 1;
|
|
535
|
+
return width;
|
|
536
|
+
}
|
|
537
|
+
return Array.from(text).length;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function parseScalar(value) {
|
|
541
|
+
const text = String(value ?? '').trim();
|
|
542
|
+
if (text === '') return '';
|
|
543
|
+
if (text === 'true') return true;
|
|
544
|
+
if (text === 'false') return false;
|
|
545
|
+
if (text === 'null' || text === '~') return null;
|
|
546
|
+
if (/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(text)) return Number(text);
|
|
547
|
+
if (
|
|
548
|
+
(text.startsWith('"') && text.endsWith('"')) ||
|
|
549
|
+
(text.startsWith("'") && text.endsWith("'"))
|
|
550
|
+
) {
|
|
551
|
+
return text.slice(1, -1);
|
|
552
|
+
}
|
|
553
|
+
return text;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function parseInlineArray(value) {
|
|
557
|
+
const inner = String(value ?? '').trim().slice(1, -1).trim();
|
|
558
|
+
if (inner === '') return [];
|
|
559
|
+
const items = [];
|
|
560
|
+
let current = '';
|
|
561
|
+
let quote = null;
|
|
562
|
+
|
|
563
|
+
for (let i = 0; i < inner.length; i += 1) {
|
|
564
|
+
const ch = inner[i];
|
|
565
|
+
if (quote) {
|
|
566
|
+
if (ch === quote && inner[i - 1] !== '\\') quote = null;
|
|
567
|
+
current += ch;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
if (ch === '"' || ch === "'") {
|
|
571
|
+
quote = ch;
|
|
572
|
+
current += ch;
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
if (ch === ',') {
|
|
576
|
+
items.push(parseScalar(current));
|
|
577
|
+
current = '';
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
current += ch;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (current !== '') items.push(parseScalar(current));
|
|
584
|
+
return items;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function yamlParse(text) {
|
|
588
|
+
const source = String(text ?? '');
|
|
589
|
+
const result = {};
|
|
590
|
+
for (const rawLine of source.split(/\r?\n/)) {
|
|
591
|
+
const line = rawLine.trim();
|
|
592
|
+
if (!line || line.startsWith('#')) continue;
|
|
593
|
+
const idx = line.indexOf(':');
|
|
594
|
+
if (idx < 0) continue;
|
|
595
|
+
const key = line.slice(0, idx).trim();
|
|
596
|
+
const rawValue = line.slice(idx + 1).trim();
|
|
597
|
+
if (!key) continue;
|
|
598
|
+
result[key] = rawValue.startsWith('[') && rawValue.endsWith(']')
|
|
599
|
+
? parseInlineArray(rawValue)
|
|
600
|
+
: parseScalar(rawValue);
|
|
601
|
+
}
|
|
602
|
+
return result;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function yamlStringify(value) {
|
|
606
|
+
if (!value || typeof value !== 'object') return String(value ?? '');
|
|
607
|
+
const lines = [];
|
|
608
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
609
|
+
if (Array.isArray(raw)) {
|
|
610
|
+
lines.push(`${key}: [${raw.map(item => JSON.stringify(String(item))).join(', ')}]`);
|
|
611
|
+
} else if (raw === null) {
|
|
612
|
+
lines.push(`${key}: null`);
|
|
613
|
+
} else if (typeof raw === 'string') {
|
|
614
|
+
lines.push(`${key}: ${JSON.stringify(raw)}`);
|
|
615
|
+
} else {
|
|
616
|
+
lines.push(`${key}: ${String(raw)}`);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return lines.join('\n');
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function createYamlShim() {
|
|
623
|
+
const yaml = {
|
|
624
|
+
parse: yamlParse,
|
|
625
|
+
stringify: yamlStringify,
|
|
626
|
+
};
|
|
627
|
+
yaml.YAML = yaml;
|
|
628
|
+
yaml.default = yaml;
|
|
629
|
+
return yaml;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function createFakeRequire(realRequire) {
|
|
633
|
+
const realChild = realRequire('child_process');
|
|
634
|
+
const realVm = realRequire('vm');
|
|
635
|
+
|
|
636
|
+
function rewriteArgs(args) {
|
|
637
|
+
if (
|
|
638
|
+
Array.isArray(args) &&
|
|
639
|
+
args[0] === 'xdg-open' &&
|
|
640
|
+
Array.isArray(args[1]) &&
|
|
641
|
+
typeof args[1][0] === 'string'
|
|
642
|
+
) {
|
|
643
|
+
return ['termux-open-url', [args[1][0]], ...args.slice(2)];
|
|
644
|
+
}
|
|
645
|
+
return args;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
const guardedChild = createGuardedChildProcess(
|
|
649
|
+
{
|
|
650
|
+
spawn: (...args) => realChild.spawn(...rewriteArgs(args)),
|
|
651
|
+
execFile: (...args) => realChild.execFile(...args),
|
|
652
|
+
exec: (...args) => realChild.exec(...args),
|
|
653
|
+
spawnSync: (...args) => realChild.spawnSync(...rewriteArgs(args)),
|
|
654
|
+
execFileSync: (...args) => realChild.execFileSync(...args),
|
|
655
|
+
execSync: (...args) => realChild.execSync(...args),
|
|
656
|
+
},
|
|
657
|
+
value => process.stderr.write(value),
|
|
658
|
+
);
|
|
659
|
+
|
|
660
|
+
return function fakeRequire(id) {
|
|
661
|
+
if (id === 'ws') {
|
|
662
|
+
class WS {
|
|
663
|
+
on() {}
|
|
664
|
+
once() {}
|
|
665
|
+
addEventListener() {}
|
|
666
|
+
close() {}
|
|
667
|
+
send() {}
|
|
668
|
+
ping() {}
|
|
669
|
+
}
|
|
670
|
+
return { default: WS, WebSocket: WS };
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
if (id === 'vm' || id === 'node:vm') {
|
|
674
|
+
if (!realVm.__claudeBunShimPatched) {
|
|
675
|
+
const originalCreateContext = realVm.createContext.bind(realVm);
|
|
676
|
+
const originalRunInNewContext = realVm.runInNewContext.bind(realVm);
|
|
677
|
+
const originalRunInContext = realVm.runInContext.bind(realVm);
|
|
678
|
+
const originalRunInThisContext = realVm.runInThisContext && realVm.runInThisContext.bind(realVm);
|
|
679
|
+
const scriptProto = realVm.Script && realVm.Script.prototype;
|
|
680
|
+
|
|
681
|
+
realVm.createContext = (contextObject, ...rest) =>
|
|
682
|
+
originalCreateContext(injectBunIntoContext(contextObject), ...rest);
|
|
683
|
+
realVm.runInNewContext = (code, contextObject, ...rest) =>
|
|
684
|
+
originalRunInNewContext(code, injectBunIntoContext(contextObject), ...rest);
|
|
685
|
+
realVm.runInContext = (code, contextObject, ...rest) =>
|
|
686
|
+
originalRunInContext(code, injectBunIntoContext(contextObject), ...rest);
|
|
687
|
+
if (originalRunInThisContext) {
|
|
688
|
+
realVm.runInThisContext = (code, ...rest) => originalRunInThisContext(code, ...rest);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (scriptProto && !scriptProto.__claudeBunShimPatched) {
|
|
692
|
+
const originalScriptRunInContext = scriptProto.runInContext;
|
|
693
|
+
const originalScriptRunInNewContext = scriptProto.runInNewContext;
|
|
694
|
+
const originalScriptRunInThisContext = scriptProto.runInThisContext;
|
|
695
|
+
|
|
696
|
+
scriptProto.runInContext = function (contextObject, ...rest) {
|
|
697
|
+
return originalScriptRunInContext.call(this, injectBunIntoContext(contextObject), ...rest);
|
|
698
|
+
};
|
|
699
|
+
scriptProto.runInNewContext = function (contextObject, ...rest) {
|
|
700
|
+
return originalScriptRunInNewContext.call(this, injectBunIntoContext(contextObject), ...rest);
|
|
701
|
+
};
|
|
702
|
+
if (originalScriptRunInThisContext) {
|
|
703
|
+
scriptProto.runInThisContext = function (...rest) {
|
|
704
|
+
return originalScriptRunInThisContext.call(this, ...rest);
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
Object.defineProperty(scriptProto, '__claudeBunShimPatched', { value: true });
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
Object.defineProperty(realVm, '__claudeBunShimPatched', { value: true });
|
|
712
|
+
}
|
|
713
|
+
return realVm;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
if (id === 'child_process') {
|
|
717
|
+
return guardedChild;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (id === 'node:child_process') {
|
|
721
|
+
return guardedChild;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
if (id.startsWith('/$bunfs/root/')) {
|
|
725
|
+
throw new Error('bunfs require blocked: ' + id);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
return realRequire(id);
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
async function main() {
|
|
733
|
+
const extractedFile = ensureEntryFile();
|
|
734
|
+
const code = fs.readFileSync(extractedFile, 'utf8');
|
|
735
|
+
const patchedCode = code.replace(
|
|
736
|
+
/^function\(exports, require, module, __filename, __dirname\) \{/,
|
|
737
|
+
'function(exports, require, module, __filename, __dirname) {var __claudeBun = globalThis.__claudeBunShim;',
|
|
738
|
+
).replace(
|
|
739
|
+
/\btypeof Bun\b/g,
|
|
740
|
+
'typeof __claudeBun',
|
|
741
|
+
).replace(
|
|
742
|
+
/\bBun\./g,
|
|
743
|
+
'__claudeBun.',
|
|
744
|
+
).replace(
|
|
745
|
+
/function t5q\(q\)\{return Bun\.YAML\.parse\(q\)\}/g,
|
|
746
|
+
'function t5q(q){return globalThis.__claudeYaml.parse(q)}',
|
|
747
|
+
).replace(
|
|
748
|
+
/function VK6\(q\)\{return Bun\.YAML\.stringify\(q,null,2\)\+`/g,
|
|
749
|
+
'function VK6(q){return globalThis.__claudeYaml.stringify(q,null,2)+`',
|
|
750
|
+
);
|
|
751
|
+
const fn = eval('(' + patchedCode.replace(/\)\s*$/, '') + ')');
|
|
752
|
+
|
|
753
|
+
const originalArgv = process.argv.slice();
|
|
754
|
+
const originalExit = process.exit;
|
|
755
|
+
const originalBun = process.versions.bun;
|
|
756
|
+
const hadGlobalBun = Object.prototype.hasOwnProperty.call(globalThis, 'Bun');
|
|
757
|
+
const originalGlobalBun = globalThis.Bun;
|
|
758
|
+
const asyncErrors = [];
|
|
759
|
+
|
|
760
|
+
globalThis.__claudeYaml = createYamlShim();
|
|
761
|
+
if (!globalThis.__claudeBunShim || typeof globalThis.__claudeBunShim !== 'object') {
|
|
762
|
+
globalThis.__claudeBunShim = {};
|
|
763
|
+
}
|
|
764
|
+
const fakeRequire = createFakeRequire(require);
|
|
765
|
+
function onAsyncError(error) {
|
|
766
|
+
asyncErrors.push(error);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
try {
|
|
770
|
+
process.once('uncaughtException', onAsyncError);
|
|
771
|
+
process.once('unhandledRejection', onAsyncError);
|
|
772
|
+
Object.defineProperty(process.versions, 'bun', { value: '1.1.8', configurable: true });
|
|
773
|
+
const _realChild = require('child_process');
|
|
774
|
+
globalThis.Bun = {
|
|
775
|
+
version: '1.1.8',
|
|
776
|
+
stringWidth,
|
|
777
|
+
which: (cmd) => {
|
|
778
|
+
try {
|
|
779
|
+
return _realChild.execFileSync('which', [String(cmd)], { encoding: 'utf8' }).trim() || null;
|
|
780
|
+
} catch { return null; }
|
|
781
|
+
},
|
|
782
|
+
semver: (() => {
|
|
783
|
+
const _cmp = (a, b) => {
|
|
784
|
+
const pa = String(a).replace(/[^0-9.]/g,'').split('.').map(Number);
|
|
785
|
+
const pb = String(b).replace(/[^0-9.]/g,'').split('.').map(Number);
|
|
786
|
+
for (let i = 0; i < 3; i++) { const d = (pa[i]||0)-(pb[i]||0); if (d) return d > 0 ? 1 : -1; }
|
|
787
|
+
return 0;
|
|
788
|
+
};
|
|
789
|
+
const _satisfies = (ver, range) => {
|
|
790
|
+
const s = String(range).trim();
|
|
791
|
+
const m = s.match(/^([><=!]{1,2})\s*([\d]+(?:\.[\d]+){0,2})$/);
|
|
792
|
+
if (m) {
|
|
793
|
+
const op = m[1], c = _cmp(ver, m[2]);
|
|
794
|
+
if (op === '>') return c > 0;
|
|
795
|
+
if (op === '>=') return c >= 0;
|
|
796
|
+
if (op === '<') return c < 0;
|
|
797
|
+
if (op === '<=') return c <= 0;
|
|
798
|
+
if (op === '=' || op === '==') return c === 0;
|
|
799
|
+
if (op === '!=') return c !== 0;
|
|
800
|
+
}
|
|
801
|
+
if (/^[\d]+(?:\.[\d]+){0,2}$/.test(s)) return _cmp(ver, s) === 0;
|
|
802
|
+
return false;
|
|
803
|
+
};
|
|
804
|
+
return {
|
|
805
|
+
order: (a, b) => _cmp(a, b),
|
|
806
|
+
compare: (a, b) => _cmp(a, b),
|
|
807
|
+
satisfies: (ver, range) => _satisfies(ver, range),
|
|
808
|
+
gt: (a, b) => _cmp(a, b) > 0,
|
|
809
|
+
gte: (a, b) => _cmp(a, b) >= 0,
|
|
810
|
+
lt: (a, b) => _cmp(a, b) < 0,
|
|
811
|
+
lte: (a, b) => _cmp(a, b) <= 0,
|
|
812
|
+
};
|
|
813
|
+
})(),
|
|
814
|
+
YAML: globalThis.__claudeYaml,
|
|
815
|
+
};
|
|
816
|
+
Object.assign(globalThis.__claudeBunShim, globalThis.Bun);
|
|
817
|
+
if (typeof globalThis.__claudeBunShim.gc !== 'function') {
|
|
818
|
+
globalThis.__claudeBunShim.gc = () => {};
|
|
819
|
+
}
|
|
820
|
+
globalThis.__claudeBun = globalThis.__claudeBunShim;
|
|
821
|
+
globalThis.Bun = globalThis.__claudeBunShim;
|
|
822
|
+
process.argv = ['node', extractedFile, ...argv];
|
|
823
|
+
process.exit = code => {
|
|
824
|
+
throw new RequestedExit(code);
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
const moduleLike = { exports: {} };
|
|
828
|
+
const maybePromise = fn(moduleLike.exports, fakeRequire, moduleLike, extractedFile, workdir);
|
|
829
|
+
if (maybePromise && typeof maybePromise.then === 'function') await maybePromise;
|
|
830
|
+
const _waitMs = Number(process.env.CLAUDE_TERMUX_PRINT_WAIT_MS || 200);
|
|
831
|
+
await new Promise(resolve => setTimeout(resolve, _waitMs));
|
|
832
|
+
if (asyncErrors.length > 0) throw asyncErrors[0];
|
|
833
|
+
} catch (error) {
|
|
834
|
+
if (error instanceof RequestedExit) {
|
|
835
|
+
process.exitCode = error.code;
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
throw error;
|
|
839
|
+
} finally {
|
|
840
|
+
process.removeListener('uncaughtException', onAsyncError);
|
|
841
|
+
process.removeListener('unhandledRejection', onAsyncError);
|
|
842
|
+
process.argv = originalArgv;
|
|
843
|
+
process.exit = originalExit;
|
|
844
|
+
try {
|
|
845
|
+
if (originalBun === undefined) {
|
|
846
|
+
delete process.versions.bun;
|
|
847
|
+
} else {
|
|
848
|
+
Object.defineProperty(process.versions, 'bun', { value: originalBun, configurable: true });
|
|
849
|
+
}
|
|
850
|
+
} catch {}
|
|
851
|
+
delete globalThis.__claudeYaml;
|
|
852
|
+
delete globalThis.__claudeBunShim;
|
|
853
|
+
delete globalThis.__claudeBun;
|
|
854
|
+
if (hadGlobalBun) globalThis.Bun = originalGlobalBun;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
main().catch(error => {
|
|
859
|
+
if (error && error.code === 'CLAUDE_TERMUX_OFFICIAL_UPDATE_BLOCKED') {
|
|
860
|
+
console.error(BLOCK_MESSAGE);
|
|
861
|
+
process.exit(error.status || 1);
|
|
862
|
+
}
|
|
863
|
+
console.error(error && error.stack ? error.stack : String(error));
|
|
864
|
+
process.exit(1);
|
|
865
|
+
});
|
|
866
|
+
NODE
|
|
867
|
+
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="${CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:-1}"
|
|
868
|
+
export ENABLE_CLAUDEAI_MCP_SERVERS="${ENABLE_CLAUDEAI_MCP_SERVERS:-0}"
|
|
869
|
+
node "$_bootstrap" "$@"
|
|
870
|
+
_status=$?
|
|
871
|
+
rm -f "$_bootstrap"
|
|
872
|
+
trap - EXIT HUP INT TERM
|
|
873
|
+
exit "$_status"
|
|
874
|
+
fi
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function parseVersion(v) {
|
|
4
|
+
const str = String(v);
|
|
5
|
+
const dashIdx = str.lastIndexOf('-');
|
|
6
|
+
if (dashIdx !== -1) {
|
|
7
|
+
const base = str.slice(0, dashIdx);
|
|
8
|
+
const suffix = Number(str.slice(dashIdx + 1));
|
|
9
|
+
return { parts: base.split('.').map(Number), suffix: isNaN(suffix) ? 0 : suffix };
|
|
10
|
+
}
|
|
11
|
+
return { parts: str.split('.').map(Number), suffix: 0 };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function compareVersions(a, b) {
|
|
15
|
+
const ap = parseVersion(a), bp = parseVersion(b);
|
|
16
|
+
const len = Math.max(ap.parts.length, bp.parts.length);
|
|
17
|
+
for (let i = 0; i < len; i++) {
|
|
18
|
+
const diff = (ap.parts[i] || 0) - (bp.parts[i] || 0);
|
|
19
|
+
if (diff !== 0) return diff;
|
|
20
|
+
}
|
|
21
|
+
return ap.suffix - bp.suffix;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = { parseVersion, compareVersions };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const test = require('node:test');
|
|
4
|
+
const assert = require('node:assert/strict');
|
|
5
|
+
|
|
6
|
+
const { parseVersion, compareVersions } = require('./version-utils');
|
|
7
|
+
|
|
8
|
+
test('parseVersion splits suffix versions', () => {
|
|
9
|
+
assert.deepEqual(parseVersion('2.1.159-2'), {
|
|
10
|
+
parts: [2, 1, 159],
|
|
11
|
+
suffix: 2,
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('compareVersions orders suffix versions after the base release', () => {
|
|
16
|
+
assert.equal(compareVersions('2.1.159', '2.1.159-1') < 0, true);
|
|
17
|
+
assert.equal(compareVersions('2.1.159-1', '2.1.159-2') < 0, true);
|
|
18
|
+
assert.equal(compareVersions('2.1.159-2', '2.1.159') > 0, true);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('compareVersions preserves numeric ordering across patch versions', () => {
|
|
22
|
+
assert.equal(compareVersions('2.1.136', '2.1.137') < 0, true);
|
|
23
|
+
assert.equal(compareVersions('2.1.137', '2.1.136') > 0, true);
|
|
24
|
+
assert.equal(compareVersions('2.1.137', '2.1.137'), 0);
|
|
25
|
+
});
|
package/package.json
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bash0816/claude-code",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Termux-native Claude Code wrapper with audited native replay",
|
|
5
|
-
"license": "
|
|
3
|
+
"version": "2.1.161-1",
|
|
4
|
+
"description": "Unofficial Termux-native Claude Code wrapper with audited native replay",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"bin": {
|
|
7
7
|
"claude": "bin/claude"
|
|
8
8
|
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"preinstall": "node lib/preinstall.js",
|
|
11
|
-
"postinstall": "node lib/postinstall.js"
|
|
12
|
-
},
|
|
9
|
+
"scripts": {},
|
|
13
10
|
"files": [
|
|
14
|
-
"bin",
|
|
15
|
-
"lib",
|
|
16
|
-
"config",
|
|
17
|
-
"README.md"
|
|
11
|
+
"bin/",
|
|
12
|
+
"lib/",
|
|
13
|
+
"config/",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
18
16
|
],
|
|
19
17
|
"engines": {
|
|
20
18
|
"node": ">=18"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"claude-code",
|
|
22
|
+
"termux",
|
|
23
|
+
"android",
|
|
24
|
+
"wrapper"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
21
28
|
}
|
|
22
29
|
}
|