@bash0816/claude-code 2.1.159-1 → 2.1.159-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/README.md CHANGED
@@ -68,8 +68,8 @@ Normal launch also checks the same manifest with a short timeout and prints a no
68
68
 
69
69
  - Only audited versions in `config/claude-native-audited-versions.json` can run.
70
70
  - `config/claude-native-audited-versions.json` にある監査済み version だけを実行できます。
71
- - `2.1.150-1`, `2.1.150-2`, `2.1.150-3`, `2.1.153-1`, `2.1.153-2`, `2.1.153-3`, `2.1.153-4`, `2.1.118`, `2.1.119`, `2.1.121`, `2.1.122`, `2.1.123`, `2.1.126`, `2.1.128`, `2.1.136`, `2.1.137`, `2.1.138`, `2.1.139`, `2.1.140`, `2.1.141`, `2.1.142`, `2.1.143`, `2.1.144`, `2.1.150`, `2.1.153`, `2.1.157` are included in the package metadata.
72
- - `2.1.150-1`、`2.1.150-2`、`2.1.150-3`、`2.1.153-1`、`2.1.153-2`、`2.1.153-3`、`2.1.153-4`、`2.1.118`、`2.1.119`、`2.1.121`、`2.1.122`、`2.1.123`、`2.1.126`、`2.1.128`、`2.1.136`、`2.1.137`、`2.1.138`、`2.1.139`、`2.1.140`、`2.1.141`、`2.1.142`、`2.1.143`、`2.1.144`、`2.1.150`、`2.1.153`、`2.1.157` を package metadata に含めています。
71
+ - `2.1.118`, `2.1.119`, `2.1.121`, `2.1.122`, `2.1.123`, `2.1.126`, `2.1.128`, `2.1.136`, `2.1.137`, `2.1.138`, `2.1.139`, `2.1.140`, `2.1.141`, `2.1.142`, `2.1.143`, `2.1.144`, `2.1.150`, `2.1.150-1`, `2.1.150-2`, `2.1.150-3`, `2.1.153`, `2.1.153-1`, `2.1.153-2`, `2.1.153-3`, `2.1.153-4`, `2.1.157` are included in the package metadata.
72
+ - `2.1.118`、`2.1.119`、`2.1.121`、`2.1.122`、`2.1.123`、`2.1.126`、`2.1.128`、`2.1.136`、`2.1.137`、`2.1.138`、`2.1.139`、`2.1.140`、`2.1.141`、`2.1.142`、`2.1.143`、`2.1.144`、`2.1.150`、`2.1.150-1`、`2.1.150-2`、`2.1.150-3`、`2.1.153`、`2.1.153-1`、`2.1.153-2`、`2.1.153-3`、`2.1.153-4`、`2.1.157` を package metadata に含めています。
73
73
  - The metadata file is the source of truth for the currently audited set.
74
74
  - 現在の監査済み version 集合の source of truth は metadata file です。
75
75
  - Native artifacts are cached under `${HOME}/.claude-termux-native-package`.
@@ -181,6 +181,24 @@
181
181
  "entry_js_offset": 223210916,
182
182
  "entry_end_offset": 238725072,
183
183
  "status": "termux_verified"
184
+ },
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
+ "status": "offset_discovered"
193
+ },
194
+ "2.1.159-3": {
195
+ "wrapper_spec": "@anthropic-ai/claude-code@2.1.159",
196
+ "native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.159",
197
+ "entry_js_offset": 223232708,
198
+ "entry_end_offset": 238749397,
199
+ "tarball_integrity": "sha512-c8dXbuQdrotGWll46GlnXm5IPpORK2VrBSosCmI6f8t7Snc/3F58fX0MbIjJ/ycXpY0aaKuOnufCuxf7wi1Xqw==",
200
+ "tarball_sha256": "0b551634f11742310ba3b6344fb7912ba1ed8ee0ef4702eab0099d31b4eeb070",
201
+ "status": "offset_discovered"
184
202
  }
185
203
  }
186
204
  }
@@ -2,7 +2,7 @@
2
2
  "manifest_version": 1,
3
3
  "package_name": "@bash0816/claude-code",
4
4
  "latest_audited_version": "2.1.157",
5
- "latest_candidate_version": "2.1.157",
5
+ "latest_candidate_version": "2.1.159-3",
6
6
  "previous_stable_version": "2.1.153-4",
7
7
  "manifest_url": "https://raw.githubusercontent.com/bash0816/ClaudeCode-Termux/main/config/claude-termux-release-manifest.json"
8
8
  }
@@ -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'));
@@ -89,17 +89,6 @@ function ensureEntryFile() {
89
89
  return extractedFile;
90
90
  }
91
91
 
92
- function stringWidth(value) {
93
- const text = String(value ?? '');
94
- if (typeof Intl !== 'undefined' && typeof Intl.Segmenter === 'function') {
95
- const segmenter = new Intl.Segmenter('en', { granularity: 'grapheme' });
96
- let width = 0;
97
- for (const _segment of segmenter.segment(text)) width += 1;
98
- return width;
99
- }
100
- return Array.from(text).length;
101
- }
102
-
103
92
  function createFakeRequire(realRequire) {
104
93
  const realChild = realRequire('child_process');
105
94
 
@@ -156,6 +145,337 @@ function createFakeRequire(realRequire) {
156
145
  };
157
146
  }
158
147
 
148
+ const ansiPattern =
149
+ /[\u001B\u009B][[\]()#;?]*(?:(?:(?:;[-a-zA-Z\d\/\#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/\#&.:=?%@~_]*)*)?(?:\u0007|\u001B\u005C|\u009C)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))/g;
150
+ const ansiPatternSingle = new RegExp(ansiPattern.source);
151
+ const debugBunShim = process.env.CLAUDE_TERMUX_DEBUG_BUN_SHIM === '1';
152
+
153
+ function stripANSI(text) {
154
+ if (typeof text !== 'string' || text.length === 0) return '';
155
+ return text.replace(ansiPattern, '');
156
+ }
157
+
158
+ function codePointWidth(codePoint) {
159
+ if (
160
+ codePoint <= 0x1f ||
161
+ (codePoint >= 0x7f && codePoint <= 0x9f) ||
162
+ (codePoint >= 0x300 && codePoint <= 0x36f) ||
163
+ (codePoint >= 0x200b && codePoint <= 0x200f) ||
164
+ codePoint === 0xfeff ||
165
+ (codePoint >= 0xfe00 && codePoint <= 0xfe0f)
166
+ ) {
167
+ return 0;
168
+ }
169
+
170
+ if (
171
+ (codePoint >= 0x1100 && codePoint <= 0x115f) ||
172
+ (codePoint >= 0x2329 && codePoint <= 0x232a) ||
173
+ (codePoint >= 0x2e80 && codePoint <= 0xa4cf && codePoint !== 0x303f) ||
174
+ (codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
175
+ (codePoint >= 0xf900 && codePoint <= 0xfaff) ||
176
+ (codePoint >= 0xfe10 && codePoint <= 0xfe19) ||
177
+ (codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||
178
+ (codePoint >= 0xff00 && codePoint <= 0xff60) ||
179
+ (codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
180
+ (codePoint >= 0x1f300 && codePoint <= 0x1faf8) ||
181
+ (codePoint >= 0x20000 && codePoint <= 0x3fffd)
182
+ ) {
183
+ return 2;
184
+ }
185
+
186
+ return 1;
187
+ }
188
+
189
+ function stringWidth(value) {
190
+ const text = stripANSI(typeof value === 'string' ? value : String(value ?? ''));
191
+ let width = 0;
192
+ for (const char of text) {
193
+ const codePoint = char.codePointAt(0);
194
+ width += codePointWidth(codePoint);
195
+ }
196
+ return width;
197
+ }
198
+
199
+ function toHashBytes(value) {
200
+ if (Buffer.isBuffer(value)) return Buffer.from(value);
201
+ if (value instanceof Uint8Array) return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
202
+ if (value instanceof ArrayBuffer) return Buffer.from(value);
203
+ if (ArrayBuffer.isView(value)) {
204
+ return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
205
+ }
206
+ return Buffer.from(String(value ?? ''));
207
+ }
208
+
209
+ function hashValue(value, seed = 0) {
210
+ const FNV_OFFSET_BASIS_64 = 0xcbf29ce484222325n;
211
+ const FNV_PRIME_64 = 0x100000001b3n;
212
+ const MASK_64 = 0xffffffffffffffffn;
213
+
214
+ const seedNumber = typeof seed === 'bigint' ? Number(seed) : Number(seed);
215
+ const seedValue = Number.isFinite(seedNumber) ? Math.trunc(seedNumber) : 0;
216
+ let result = BigInt.asUintN(64, FNV_OFFSET_BASIS_64 ^ BigInt(seedValue));
217
+
218
+ const bytes = toHashBytes(value);
219
+ for (const byte of bytes) {
220
+ result ^= BigInt(byte);
221
+ result = (result * FNV_PRIME_64) & MASK_64;
222
+ }
223
+
224
+ return BigInt(result);
225
+ }
226
+
227
+ function which(cmd) {
228
+ const fs = require('fs');
229
+ const path = require('path');
230
+
231
+ if (typeof cmd !== 'string' || cmd.length === 0) return null;
232
+
233
+ const isExecutable = candidate => {
234
+ try {
235
+ fs.accessSync(candidate, fs.constants.X_OK);
236
+ const stat = fs.statSync(candidate);
237
+ return stat.isFile();
238
+ } catch {
239
+ return false;
240
+ }
241
+ };
242
+
243
+ if (cmd.includes(path.sep)) {
244
+ return isExecutable(cmd) ? path.resolve(cmd) : null;
245
+ }
246
+
247
+ const searchPath = process.env.PATH || '';
248
+ for (const entry of searchPath.split(path.delimiter)) {
249
+ if (!entry) continue;
250
+ const candidate = path.join(entry, cmd);
251
+ if (isExecutable(candidate)) return candidate;
252
+ }
253
+ return null;
254
+ }
255
+
256
+ function wrapAnsi(str, columns, options) {
257
+ const input = typeof str === 'string' ? str : String(str ?? '');
258
+ const widthLimit = Number(columns);
259
+ if (!Number.isFinite(widthLimit) || widthLimit <= 0) return input;
260
+
261
+ const wordWrap = !options || options.wordWrap !== false;
262
+ const hard = !!(options && options.hard);
263
+
264
+ if (!wordWrap || hard) {
265
+ const result = [];
266
+ let width = 0;
267
+
268
+ for (let i = 0; i < input.length; ) {
269
+ const char = input[i];
270
+
271
+ if (char === '\u001b' || char === '\u009b') {
272
+ const match = input.slice(i).match(ansiPatternSingle);
273
+ if (match && match.index === 0) {
274
+ result.push(match[0]);
275
+ i += match[0].length;
276
+ continue;
277
+ }
278
+ }
279
+
280
+ if (char === '\n') {
281
+ result.push(char);
282
+ width = 0;
283
+ i += 1;
284
+ continue;
285
+ }
286
+
287
+ const codePoint = input.codePointAt(i);
288
+ const charText = String.fromCodePoint(codePoint);
289
+ const charWidth = codePointWidth(codePoint);
290
+
291
+ if (width > 0 && width + charWidth > widthLimit) {
292
+ result.push('\n');
293
+ width = 0;
294
+ }
295
+
296
+ result.push(charText);
297
+ width += charWidth;
298
+ i += charText.length;
299
+ }
300
+
301
+ return result.join('');
302
+ }
303
+
304
+ const result = [];
305
+ let line = '';
306
+ let lineWidth = 0;
307
+ let pendingSpaces = '';
308
+
309
+ for (let i = 0; i < input.length; ) {
310
+ const char = input[i];
311
+
312
+ if (char === '\u001b' || char === '\u009b') {
313
+ const match = input.slice(i).match(ansiPatternSingle);
314
+ if (match && match.index === 0) {
315
+ line += match[0];
316
+ i += match[0].length;
317
+ continue;
318
+ }
319
+ }
320
+
321
+ if (char === '\n') {
322
+ if (line.length > 0) result.push(line);
323
+ result.push('\n');
324
+ line = '';
325
+ lineWidth = 0;
326
+ pendingSpaces = '';
327
+ i += 1;
328
+ continue;
329
+ }
330
+
331
+ const codePoint = input.codePointAt(i);
332
+ const charText = String.fromCodePoint(codePoint);
333
+ if (charText === ' ' || charText === '\t') {
334
+ pendingSpaces += charText;
335
+ i += charText.length;
336
+ continue;
337
+ }
338
+
339
+ let end = i + charText.length;
340
+ while (end < input.length) {
341
+ const nextChar = input[end];
342
+ if (nextChar === '\n' || nextChar === ' ' || nextChar === '\t' || nextChar === '\u001b' || nextChar === '\u009b') {
343
+ break;
344
+ }
345
+ const nextCodePoint = input.codePointAt(end);
346
+ end += String.fromCodePoint(nextCodePoint).length;
347
+ }
348
+
349
+ const text = input.slice(i, end);
350
+ const textWidth = stringWidth(text);
351
+ const pendingWidth = pendingSpaces ? stringWidth(pendingSpaces) : 0;
352
+
353
+ if (lineWidth > 0 && lineWidth + pendingWidth + textWidth > widthLimit) {
354
+ result.push(line);
355
+ result.push('\n');
356
+ line = '';
357
+ lineWidth = 0;
358
+ pendingSpaces = '';
359
+ }
360
+
361
+ if (lineWidth > 0 && pendingSpaces) {
362
+ line += pendingSpaces;
363
+ lineWidth += pendingWidth;
364
+ }
365
+ pendingSpaces = '';
366
+
367
+ line += text;
368
+ lineWidth += textWidth;
369
+ i = end;
370
+ }
371
+
372
+ if (pendingSpaces && lineWidth > 0) {
373
+ line += pendingSpaces;
374
+ }
375
+ if (line.length > 0) result.push(line);
376
+
377
+ return result.join('');
378
+ }
379
+
380
+ const YAML = {
381
+ parse(text) {
382
+ try {
383
+ const lines = String(text).split('\n');
384
+ const result = {};
385
+ for (const line of lines) {
386
+ const m = line.match(/^([^:#]+):\s*(.*)$/);
387
+ if (m) result[m[1].trim()] = m[2].trim().replace(/^['"]|['"]$/g, '');
388
+ }
389
+ return result;
390
+ } catch { return {}; }
391
+ },
392
+ stringify(obj) {
393
+ try {
394
+ return Object.entries(obj || {}).map(([k, v]) => k + ': ' + v).join('\n') + '\n';
395
+ } catch { return ''; }
396
+ },
397
+ };
398
+
399
+ function parseSemverVersion(value) {
400
+ const text = String(value ?? '').trim().replace(/^[v=]/, '');
401
+ const match = text.match(/^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/);
402
+ if (!match) return null;
403
+ return {
404
+ parts: [match[1], match[2] ?? '0', match[3] ?? '0'].map(Number),
405
+ pre: match[4] ? match[4].split('.') : null,
406
+ };
407
+ }
408
+
409
+ function comparePrerelease(a, b) {
410
+ const size = Math.max(a.length, b.length);
411
+ for (let i = 0; i < size; i++) {
412
+ if (a[i] === undefined) return -1;
413
+ if (b[i] === undefined) return 1;
414
+ const aNum = /^\d+$/.test(a[i]);
415
+ const bNum = /^\d+$/.test(b[i]);
416
+ if (aNum && bNum) { const d = Number(a[i]) - Number(b[i]); if (d) return d < 0 ? -1 : 1; }
417
+ else if (aNum) return -1;
418
+ else if (bNum) return 1;
419
+ else if (a[i] < b[i]) return -1;
420
+ else if (a[i] > b[i]) return 1;
421
+ }
422
+ return 0;
423
+ }
424
+
425
+ const semver = {
426
+ order(left, right) {
427
+ const a = parseSemverVersion(left), b = parseSemverVersion(right);
428
+ if (!a || !b) return NaN;
429
+ for (let i = 0; i < 3; i++) {
430
+ const d = a.parts[i] - b.parts[i];
431
+ if (d) return d < 0 ? -1 : 1;
432
+ }
433
+ if (a.pre && !b.pre) return -1;
434
+ if (!a.pre && b.pre) return 1;
435
+ if (a.pre && b.pre) return comparePrerelease(a.pre, b.pre);
436
+ return 0;
437
+ },
438
+ satisfies(version, range) {
439
+ if (!version || !range) return false;
440
+ const v = String(version).replace(/^[v=]/, '');
441
+ const clean = String(range).trim();
442
+ if (!clean) return false;
443
+ if (clean.includes('||')) return clean.split('||').some(r => semver.satisfies(v, r.trim()));
444
+ const parts = clean.split(/\s+/).filter(Boolean);
445
+ if (parts.length > 1) return parts.every(p => semver.satisfies(v, p));
446
+ const caret = clean.match(/^\^([0-9].*)$/);
447
+ if (caret) {
448
+ const p = parseSemverVersion(caret[1]);
449
+ if (!p) return false;
450
+ const upper = p.parts[0] > 0 ? (p.parts[0] + 1) + '.0.0'
451
+ : p.parts[1] > 0 ? '0.' + (p.parts[1] + 1) + '.0'
452
+ : '0.0.' + (p.parts[2] + 1);
453
+ return semver.satisfies(v, '>=' + caret[1]) && semver.satisfies(v, '<' + upper);
454
+ }
455
+ const tilde = clean.match(/^~([0-9].*)$/);
456
+ if (tilde) {
457
+ const p = parseSemverVersion(tilde[1]);
458
+ if (!p) return false;
459
+ const original = tilde[1].split('.');
460
+ const upper = original.length >= 2
461
+ ? p.parts[0] + '.' + (p.parts[1] + 1) + '.0'
462
+ : (p.parts[0] + 1) + '.0.0';
463
+ return semver.satisfies(v, '>=' + tilde[1]) && semver.satisfies(v, '<' + upper);
464
+ }
465
+ const m = clean.match(/^([><=!]{1,2})\s*([0-9].*)$/);
466
+ if (m) {
467
+ const cmp = semver.order(v, m[2]);
468
+ if (!Number.isFinite(cmp)) return false;
469
+ return m[1] === '>=' ? cmp >= 0 : m[1] === '>' ? cmp > 0 :
470
+ m[1] === '<=' ? cmp <= 0 : m[1] === '<' ? cmp < 0 :
471
+ m[1] === '=' || m[1] === '==' ? cmp === 0 : m[1] === '!=' ? cmp !== 0 : false;
472
+ }
473
+ const exact = parseSemverVersion(clean);
474
+ return exact ? semver.order(v, clean) === 0 : false;
475
+ },
476
+ };
477
+
478
+
159
479
  async function main() {
160
480
  const extractedFile = ensureEntryFile();
161
481
  const code = fs.readFileSync(extractedFile, 'utf8');
@@ -177,7 +497,33 @@ async function main() {
177
497
  process.once('uncaughtException', onAsyncError);
178
498
  process.once('unhandledRejection', onAsyncError);
179
499
  Object.defineProperty(process.versions, 'bun', { value: '1.1.8', configurable: true });
180
- globalThis.Bun = { version: '1.1.8', stringWidth };
500
+ const BunShim = {
501
+ version: '1.1.8',
502
+ stringWidth,
503
+ hash: hashValue,
504
+ which,
505
+ wrapAnsi,
506
+ stripANSI,
507
+ semver,
508
+ YAML,
509
+ gc: (sync) => {
510
+ try {
511
+ if (typeof global.gc === 'function') global.gc(sync === false ? false : true);
512
+ } catch {}
513
+ },
514
+ stdin: { stream: null },
515
+ embeddedFiles: [],
516
+ };
517
+ const BunProxy = new Proxy(BunShim, {
518
+ get(target, key, receiver) {
519
+ if (!(key in target) && typeof key !== 'symbol' && debugBunShim) {
520
+ console.error('[BunShim missing]', key);
521
+ }
522
+ return Reflect.get(target, key, receiver);
523
+ },
524
+ });
525
+ globalThis.Bun = BunProxy;
526
+
181
527
  process.argv = ['node', extractedFile, ...argv];
182
528
  process.exit = code => {
183
529
  throw new RequestedExit(code);
@@ -264,17 +610,6 @@ function ensureEntryFile() {
264
610
  return extractedFile;
265
611
  }
266
612
 
267
- function stringWidth(value) {
268
- const text = String(value ?? '');
269
- if (typeof Intl !== 'undefined' && typeof Intl.Segmenter === 'function') {
270
- const segmenter = new Intl.Segmenter('en', { granularity: 'grapheme' });
271
- let width = 0;
272
- for (const _segment of segmenter.segment(text)) width += 1;
273
- return width;
274
- }
275
- return Array.from(text).length;
276
- }
277
-
278
613
  function createFakeRequire(realRequire) {
279
614
  const realChild = realRequire('child_process');
280
615
 
@@ -331,6 +666,337 @@ function createFakeRequire(realRequire) {
331
666
  };
332
667
  }
333
668
 
669
+ const ansiPattern =
670
+ /[\u001B\u009B][[\]()#;?]*(?:(?:(?:;[-a-zA-Z\d\/\#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/\#&.:=?%@~_]*)*)?(?:\u0007|\u001B\u005C|\u009C)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))/g;
671
+ const ansiPatternSingle = new RegExp(ansiPattern.source);
672
+ const debugBunShim = process.env.CLAUDE_TERMUX_DEBUG_BUN_SHIM === '1';
673
+
674
+ function stripANSI(text) {
675
+ if (typeof text !== 'string' || text.length === 0) return '';
676
+ return text.replace(ansiPattern, '');
677
+ }
678
+
679
+ function codePointWidth(codePoint) {
680
+ if (
681
+ codePoint <= 0x1f ||
682
+ (codePoint >= 0x7f && codePoint <= 0x9f) ||
683
+ (codePoint >= 0x300 && codePoint <= 0x36f) ||
684
+ (codePoint >= 0x200b && codePoint <= 0x200f) ||
685
+ codePoint === 0xfeff ||
686
+ (codePoint >= 0xfe00 && codePoint <= 0xfe0f)
687
+ ) {
688
+ return 0;
689
+ }
690
+
691
+ if (
692
+ (codePoint >= 0x1100 && codePoint <= 0x115f) ||
693
+ (codePoint >= 0x2329 && codePoint <= 0x232a) ||
694
+ (codePoint >= 0x2e80 && codePoint <= 0xa4cf && codePoint !== 0x303f) ||
695
+ (codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
696
+ (codePoint >= 0xf900 && codePoint <= 0xfaff) ||
697
+ (codePoint >= 0xfe10 && codePoint <= 0xfe19) ||
698
+ (codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||
699
+ (codePoint >= 0xff00 && codePoint <= 0xff60) ||
700
+ (codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
701
+ (codePoint >= 0x1f300 && codePoint <= 0x1faf8) ||
702
+ (codePoint >= 0x20000 && codePoint <= 0x3fffd)
703
+ ) {
704
+ return 2;
705
+ }
706
+
707
+ return 1;
708
+ }
709
+
710
+ function stringWidth(value) {
711
+ const text = stripANSI(typeof value === 'string' ? value : String(value ?? ''));
712
+ let width = 0;
713
+ for (const char of text) {
714
+ const codePoint = char.codePointAt(0);
715
+ width += codePointWidth(codePoint);
716
+ }
717
+ return width;
718
+ }
719
+
720
+ function toHashBytes(value) {
721
+ if (Buffer.isBuffer(value)) return Buffer.from(value);
722
+ if (value instanceof Uint8Array) return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
723
+ if (value instanceof ArrayBuffer) return Buffer.from(value);
724
+ if (ArrayBuffer.isView(value)) {
725
+ return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
726
+ }
727
+ return Buffer.from(String(value ?? ''));
728
+ }
729
+
730
+ function hashValue(value, seed = 0) {
731
+ const FNV_OFFSET_BASIS_64 = 0xcbf29ce484222325n;
732
+ const FNV_PRIME_64 = 0x100000001b3n;
733
+ const MASK_64 = 0xffffffffffffffffn;
734
+
735
+ const seedNumber = typeof seed === 'bigint' ? Number(seed) : Number(seed);
736
+ const seedValue = Number.isFinite(seedNumber) ? Math.trunc(seedNumber) : 0;
737
+ let result = BigInt.asUintN(64, FNV_OFFSET_BASIS_64 ^ BigInt(seedValue));
738
+
739
+ const bytes = toHashBytes(value);
740
+ for (const byte of bytes) {
741
+ result ^= BigInt(byte);
742
+ result = (result * FNV_PRIME_64) & MASK_64;
743
+ }
744
+
745
+ return BigInt(result);
746
+ }
747
+
748
+ function which(cmd) {
749
+ const fs = require('fs');
750
+ const path = require('path');
751
+
752
+ if (typeof cmd !== 'string' || cmd.length === 0) return null;
753
+
754
+ const isExecutable = candidate => {
755
+ try {
756
+ fs.accessSync(candidate, fs.constants.X_OK);
757
+ const stat = fs.statSync(candidate);
758
+ return stat.isFile();
759
+ } catch {
760
+ return false;
761
+ }
762
+ };
763
+
764
+ if (cmd.includes(path.sep)) {
765
+ return isExecutable(cmd) ? path.resolve(cmd) : null;
766
+ }
767
+
768
+ const searchPath = process.env.PATH || '';
769
+ for (const entry of searchPath.split(path.delimiter)) {
770
+ if (!entry) continue;
771
+ const candidate = path.join(entry, cmd);
772
+ if (isExecutable(candidate)) return candidate;
773
+ }
774
+ return null;
775
+ }
776
+
777
+ function wrapAnsi(str, columns, options) {
778
+ const input = typeof str === 'string' ? str : String(str ?? '');
779
+ const widthLimit = Number(columns);
780
+ if (!Number.isFinite(widthLimit) || widthLimit <= 0) return input;
781
+
782
+ const wordWrap = !options || options.wordWrap !== false;
783
+ const hard = !!(options && options.hard);
784
+
785
+ if (!wordWrap || hard) {
786
+ const result = [];
787
+ let width = 0;
788
+
789
+ for (let i = 0; i < input.length; ) {
790
+ const char = input[i];
791
+
792
+ if (char === '\u001b' || char === '\u009b') {
793
+ const match = input.slice(i).match(ansiPatternSingle);
794
+ if (match && match.index === 0) {
795
+ result.push(match[0]);
796
+ i += match[0].length;
797
+ continue;
798
+ }
799
+ }
800
+
801
+ if (char === '\n') {
802
+ result.push(char);
803
+ width = 0;
804
+ i += 1;
805
+ continue;
806
+ }
807
+
808
+ const codePoint = input.codePointAt(i);
809
+ const charText = String.fromCodePoint(codePoint);
810
+ const charWidth = codePointWidth(codePoint);
811
+
812
+ if (width > 0 && width + charWidth > widthLimit) {
813
+ result.push('\n');
814
+ width = 0;
815
+ }
816
+
817
+ result.push(charText);
818
+ width += charWidth;
819
+ i += charText.length;
820
+ }
821
+
822
+ return result.join('');
823
+ }
824
+
825
+ const result = [];
826
+ let line = '';
827
+ let lineWidth = 0;
828
+ let pendingSpaces = '';
829
+
830
+ for (let i = 0; i < input.length; ) {
831
+ const char = input[i];
832
+
833
+ if (char === '\u001b' || char === '\u009b') {
834
+ const match = input.slice(i).match(ansiPatternSingle);
835
+ if (match && match.index === 0) {
836
+ line += match[0];
837
+ i += match[0].length;
838
+ continue;
839
+ }
840
+ }
841
+
842
+ if (char === '\n') {
843
+ if (line.length > 0) result.push(line);
844
+ result.push('\n');
845
+ line = '';
846
+ lineWidth = 0;
847
+ pendingSpaces = '';
848
+ i += 1;
849
+ continue;
850
+ }
851
+
852
+ const codePoint = input.codePointAt(i);
853
+ const charText = String.fromCodePoint(codePoint);
854
+ if (charText === ' ' || charText === '\t') {
855
+ pendingSpaces += charText;
856
+ i += charText.length;
857
+ continue;
858
+ }
859
+
860
+ let end = i + charText.length;
861
+ while (end < input.length) {
862
+ const nextChar = input[end];
863
+ if (nextChar === '\n' || nextChar === ' ' || nextChar === '\t' || nextChar === '\u001b' || nextChar === '\u009b') {
864
+ break;
865
+ }
866
+ const nextCodePoint = input.codePointAt(end);
867
+ end += String.fromCodePoint(nextCodePoint).length;
868
+ }
869
+
870
+ const text = input.slice(i, end);
871
+ const textWidth = stringWidth(text);
872
+ const pendingWidth = pendingSpaces ? stringWidth(pendingSpaces) : 0;
873
+
874
+ if (lineWidth > 0 && lineWidth + pendingWidth + textWidth > widthLimit) {
875
+ result.push(line);
876
+ result.push('\n');
877
+ line = '';
878
+ lineWidth = 0;
879
+ pendingSpaces = '';
880
+ }
881
+
882
+ if (lineWidth > 0 && pendingSpaces) {
883
+ line += pendingSpaces;
884
+ lineWidth += pendingWidth;
885
+ }
886
+ pendingSpaces = '';
887
+
888
+ line += text;
889
+ lineWidth += textWidth;
890
+ i = end;
891
+ }
892
+
893
+ if (pendingSpaces && lineWidth > 0) {
894
+ line += pendingSpaces;
895
+ }
896
+ if (line.length > 0) result.push(line);
897
+
898
+ return result.join('');
899
+ }
900
+
901
+ const YAML = {
902
+ parse(text) {
903
+ try {
904
+ const lines = String(text).split('\n');
905
+ const result = {};
906
+ for (const line of lines) {
907
+ const m = line.match(/^([^:#]+):\s*(.*)$/);
908
+ if (m) result[m[1].trim()] = m[2].trim().replace(/^['"]|['"]$/g, '');
909
+ }
910
+ return result;
911
+ } catch { return {}; }
912
+ },
913
+ stringify(obj) {
914
+ try {
915
+ return Object.entries(obj || {}).map(([k, v]) => k + ': ' + v).join('\n') + '\n';
916
+ } catch { return ''; }
917
+ },
918
+ };
919
+
920
+ function parseSemverVersion(value) {
921
+ const text = String(value ?? '').trim().replace(/^[v=]/, '');
922
+ const match = text.match(/^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/);
923
+ if (!match) return null;
924
+ return {
925
+ parts: [match[1], match[2] ?? '0', match[3] ?? '0'].map(Number),
926
+ pre: match[4] ? match[4].split('.') : null,
927
+ };
928
+ }
929
+
930
+ function comparePrerelease(a, b) {
931
+ const size = Math.max(a.length, b.length);
932
+ for (let i = 0; i < size; i++) {
933
+ if (a[i] === undefined) return -1;
934
+ if (b[i] === undefined) return 1;
935
+ const aNum = /^\d+$/.test(a[i]);
936
+ const bNum = /^\d+$/.test(b[i]);
937
+ if (aNum && bNum) { const d = Number(a[i]) - Number(b[i]); if (d) return d < 0 ? -1 : 1; }
938
+ else if (aNum) return -1;
939
+ else if (bNum) return 1;
940
+ else if (a[i] < b[i]) return -1;
941
+ else if (a[i] > b[i]) return 1;
942
+ }
943
+ return 0;
944
+ }
945
+
946
+ const semver = {
947
+ order(left, right) {
948
+ const a = parseSemverVersion(left), b = parseSemverVersion(right);
949
+ if (!a || !b) return NaN;
950
+ for (let i = 0; i < 3; i++) {
951
+ const d = a.parts[i] - b.parts[i];
952
+ if (d) return d < 0 ? -1 : 1;
953
+ }
954
+ if (a.pre && !b.pre) return -1;
955
+ if (!a.pre && b.pre) return 1;
956
+ if (a.pre && b.pre) return comparePrerelease(a.pre, b.pre);
957
+ return 0;
958
+ },
959
+ satisfies(version, range) {
960
+ if (!version || !range) return false;
961
+ const v = String(version).replace(/^[v=]/, '');
962
+ const clean = String(range).trim();
963
+ if (!clean) return false;
964
+ if (clean.includes('||')) return clean.split('||').some(r => semver.satisfies(v, r.trim()));
965
+ const parts = clean.split(/\s+/).filter(Boolean);
966
+ if (parts.length > 1) return parts.every(p => semver.satisfies(v, p));
967
+ const caret = clean.match(/^\^([0-9].*)$/);
968
+ if (caret) {
969
+ const p = parseSemverVersion(caret[1]);
970
+ if (!p) return false;
971
+ const upper = p.parts[0] > 0 ? (p.parts[0] + 1) + '.0.0'
972
+ : p.parts[1] > 0 ? '0.' + (p.parts[1] + 1) + '.0'
973
+ : '0.0.' + (p.parts[2] + 1);
974
+ return semver.satisfies(v, '>=' + caret[1]) && semver.satisfies(v, '<' + upper);
975
+ }
976
+ const tilde = clean.match(/^~([0-9].*)$/);
977
+ if (tilde) {
978
+ const p = parseSemverVersion(tilde[1]);
979
+ if (!p) return false;
980
+ const original = tilde[1].split('.');
981
+ const upper = original.length >= 2
982
+ ? p.parts[0] + '.' + (p.parts[1] + 1) + '.0'
983
+ : (p.parts[0] + 1) + '.0.0';
984
+ return semver.satisfies(v, '>=' + tilde[1]) && semver.satisfies(v, '<' + upper);
985
+ }
986
+ const m = clean.match(/^([><=!]{1,2})\s*([0-9].*)$/);
987
+ if (m) {
988
+ const cmp = semver.order(v, m[2]);
989
+ if (!Number.isFinite(cmp)) return false;
990
+ return m[1] === '>=' ? cmp >= 0 : m[1] === '>' ? cmp > 0 :
991
+ m[1] === '<=' ? cmp <= 0 : m[1] === '<' ? cmp < 0 :
992
+ m[1] === '=' || m[1] === '==' ? cmp === 0 : m[1] === '!=' ? cmp !== 0 : false;
993
+ }
994
+ const exact = parseSemverVersion(clean);
995
+ return exact ? semver.order(v, clean) === 0 : false;
996
+ },
997
+ };
998
+
999
+
334
1000
  async function main() {
335
1001
  const extractedFile = ensureEntryFile();
336
1002
  const code = fs.readFileSync(extractedFile, 'utf8');
@@ -352,7 +1018,33 @@ async function main() {
352
1018
  process.once('uncaughtException', onAsyncError);
353
1019
  process.once('unhandledRejection', onAsyncError);
354
1020
  Object.defineProperty(process.versions, 'bun', { value: '1.1.8', configurable: true });
355
- globalThis.Bun = { version: '1.1.8', stringWidth };
1021
+ const BunShim = {
1022
+ version: '1.1.8',
1023
+ stringWidth,
1024
+ hash: hashValue,
1025
+ which,
1026
+ wrapAnsi,
1027
+ stripANSI,
1028
+ semver,
1029
+ YAML,
1030
+ gc: (sync) => {
1031
+ try {
1032
+ if (typeof global.gc === 'function') global.gc(sync === false ? false : true);
1033
+ } catch {}
1034
+ },
1035
+ stdin: { stream: null },
1036
+ embeddedFiles: [],
1037
+ };
1038
+ const BunProxy = new Proxy(BunShim, {
1039
+ get(target, key, receiver) {
1040
+ if (!(key in target) && typeof key !== 'symbol' && debugBunShim) {
1041
+ console.error('[BunShim missing]', key);
1042
+ }
1043
+ return Reflect.get(target, key, receiver);
1044
+ },
1045
+ });
1046
+ globalThis.Bun = BunProxy;
1047
+
356
1048
  process.argv = ['node', extractedFile, ...argv];
357
1049
  process.exit = code => {
358
1050
  throw new RequestedExit(code);
@@ -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,28 @@
1
1
  {
2
2
  "name": "@bash0816/claude-code",
3
- "version": "2.1.159-1",
4
- "description": "Termux-native Claude Code wrapper with audited native replay",
3
+ "version": "2.1.159-3",
4
+ "description": "Unofficial Termux-native Claude Code wrapper with audited native replay",
5
5
  "license": "MIT",
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",
11
+ "bin/",
12
+ "lib/",
13
+ "config/",
17
14
  "README.md"
18
15
  ],
19
16
  "engines": {
20
17
  "node": ">=18"
18
+ },
19
+ "keywords": [
20
+ "claude-code",
21
+ "termux",
22
+ "android",
23
+ "wrapper"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
21
27
  }
22
28
  }