@bash0816/claude-code 2.1.159-2 → 2.1.159-4

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.
@@ -190,6 +190,24 @@
190
190
  "tarball_integrity": "sha512-c8dXbuQdrotGWll46GlnXm5IPpORK2VrBSosCmI6f8t7Snc/3F58fX0MbIjJ/ycXpY0aaKuOnufCuxf7wi1Xqw==",
191
191
  "tarball_sha256": "0b551634f11742310ba3b6344fb7912ba1ed8ee0ef4702eab0099d31b4eeb070",
192
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"
202
+ },
203
+ "2.1.159-4": {
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"
193
211
  }
194
212
  }
195
213
  }
@@ -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.159-2",
5
+ "latest_candidate_version": "2.1.159-4",
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
  }
@@ -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);
@@ -211,7 +557,9 @@ async function main() {
211
557
  }
212
558
  }
213
559
 
214
- main().catch(error => {
560
+ main().then(() => {
561
+ process.exit(process.exitCode ?? 0);
562
+ }).catch(error => {
215
563
  if (error && error.code === 'CLAUDE_TERMUX_OFFICIAL_UPDATE_BLOCKED') {
216
564
  console.error(BLOCK_MESSAGE);
217
565
  process.exit(error.status || 1);
@@ -264,17 +612,6 @@ function ensureEntryFile() {
264
612
  return extractedFile;
265
613
  }
266
614
 
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
615
  function createFakeRequire(realRequire) {
279
616
  const realChild = realRequire('child_process');
280
617
 
@@ -331,6 +668,337 @@ function createFakeRequire(realRequire) {
331
668
  };
332
669
  }
333
670
 
671
+ const ansiPattern =
672
+ /[\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;
673
+ const ansiPatternSingle = new RegExp(ansiPattern.source);
674
+ const debugBunShim = process.env.CLAUDE_TERMUX_DEBUG_BUN_SHIM === '1';
675
+
676
+ function stripANSI(text) {
677
+ if (typeof text !== 'string' || text.length === 0) return '';
678
+ return text.replace(ansiPattern, '');
679
+ }
680
+
681
+ function codePointWidth(codePoint) {
682
+ if (
683
+ codePoint <= 0x1f ||
684
+ (codePoint >= 0x7f && codePoint <= 0x9f) ||
685
+ (codePoint >= 0x300 && codePoint <= 0x36f) ||
686
+ (codePoint >= 0x200b && codePoint <= 0x200f) ||
687
+ codePoint === 0xfeff ||
688
+ (codePoint >= 0xfe00 && codePoint <= 0xfe0f)
689
+ ) {
690
+ return 0;
691
+ }
692
+
693
+ if (
694
+ (codePoint >= 0x1100 && codePoint <= 0x115f) ||
695
+ (codePoint >= 0x2329 && codePoint <= 0x232a) ||
696
+ (codePoint >= 0x2e80 && codePoint <= 0xa4cf && codePoint !== 0x303f) ||
697
+ (codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
698
+ (codePoint >= 0xf900 && codePoint <= 0xfaff) ||
699
+ (codePoint >= 0xfe10 && codePoint <= 0xfe19) ||
700
+ (codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||
701
+ (codePoint >= 0xff00 && codePoint <= 0xff60) ||
702
+ (codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
703
+ (codePoint >= 0x1f300 && codePoint <= 0x1faf8) ||
704
+ (codePoint >= 0x20000 && codePoint <= 0x3fffd)
705
+ ) {
706
+ return 2;
707
+ }
708
+
709
+ return 1;
710
+ }
711
+
712
+ function stringWidth(value) {
713
+ const text = stripANSI(typeof value === 'string' ? value : String(value ?? ''));
714
+ let width = 0;
715
+ for (const char of text) {
716
+ const codePoint = char.codePointAt(0);
717
+ width += codePointWidth(codePoint);
718
+ }
719
+ return width;
720
+ }
721
+
722
+ function toHashBytes(value) {
723
+ if (Buffer.isBuffer(value)) return Buffer.from(value);
724
+ if (value instanceof Uint8Array) return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
725
+ if (value instanceof ArrayBuffer) return Buffer.from(value);
726
+ if (ArrayBuffer.isView(value)) {
727
+ return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
728
+ }
729
+ return Buffer.from(String(value ?? ''));
730
+ }
731
+
732
+ function hashValue(value, seed = 0) {
733
+ const FNV_OFFSET_BASIS_64 = 0xcbf29ce484222325n;
734
+ const FNV_PRIME_64 = 0x100000001b3n;
735
+ const MASK_64 = 0xffffffffffffffffn;
736
+
737
+ const seedNumber = typeof seed === 'bigint' ? Number(seed) : Number(seed);
738
+ const seedValue = Number.isFinite(seedNumber) ? Math.trunc(seedNumber) : 0;
739
+ let result = BigInt.asUintN(64, FNV_OFFSET_BASIS_64 ^ BigInt(seedValue));
740
+
741
+ const bytes = toHashBytes(value);
742
+ for (const byte of bytes) {
743
+ result ^= BigInt(byte);
744
+ result = (result * FNV_PRIME_64) & MASK_64;
745
+ }
746
+
747
+ return BigInt(result);
748
+ }
749
+
750
+ function which(cmd) {
751
+ const fs = require('fs');
752
+ const path = require('path');
753
+
754
+ if (typeof cmd !== 'string' || cmd.length === 0) return null;
755
+
756
+ const isExecutable = candidate => {
757
+ try {
758
+ fs.accessSync(candidate, fs.constants.X_OK);
759
+ const stat = fs.statSync(candidate);
760
+ return stat.isFile();
761
+ } catch {
762
+ return false;
763
+ }
764
+ };
765
+
766
+ if (cmd.includes(path.sep)) {
767
+ return isExecutable(cmd) ? path.resolve(cmd) : null;
768
+ }
769
+
770
+ const searchPath = process.env.PATH || '';
771
+ for (const entry of searchPath.split(path.delimiter)) {
772
+ if (!entry) continue;
773
+ const candidate = path.join(entry, cmd);
774
+ if (isExecutable(candidate)) return candidate;
775
+ }
776
+ return null;
777
+ }
778
+
779
+ function wrapAnsi(str, columns, options) {
780
+ const input = typeof str === 'string' ? str : String(str ?? '');
781
+ const widthLimit = Number(columns);
782
+ if (!Number.isFinite(widthLimit) || widthLimit <= 0) return input;
783
+
784
+ const wordWrap = !options || options.wordWrap !== false;
785
+ const hard = !!(options && options.hard);
786
+
787
+ if (!wordWrap || hard) {
788
+ const result = [];
789
+ let width = 0;
790
+
791
+ for (let i = 0; i < input.length; ) {
792
+ const char = input[i];
793
+
794
+ if (char === '\u001b' || char === '\u009b') {
795
+ const match = input.slice(i).match(ansiPatternSingle);
796
+ if (match && match.index === 0) {
797
+ result.push(match[0]);
798
+ i += match[0].length;
799
+ continue;
800
+ }
801
+ }
802
+
803
+ if (char === '\n') {
804
+ result.push(char);
805
+ width = 0;
806
+ i += 1;
807
+ continue;
808
+ }
809
+
810
+ const codePoint = input.codePointAt(i);
811
+ const charText = String.fromCodePoint(codePoint);
812
+ const charWidth = codePointWidth(codePoint);
813
+
814
+ if (width > 0 && width + charWidth > widthLimit) {
815
+ result.push('\n');
816
+ width = 0;
817
+ }
818
+
819
+ result.push(charText);
820
+ width += charWidth;
821
+ i += charText.length;
822
+ }
823
+
824
+ return result.join('');
825
+ }
826
+
827
+ const result = [];
828
+ let line = '';
829
+ let lineWidth = 0;
830
+ let pendingSpaces = '';
831
+
832
+ for (let i = 0; i < input.length; ) {
833
+ const char = input[i];
834
+
835
+ if (char === '\u001b' || char === '\u009b') {
836
+ const match = input.slice(i).match(ansiPatternSingle);
837
+ if (match && match.index === 0) {
838
+ line += match[0];
839
+ i += match[0].length;
840
+ continue;
841
+ }
842
+ }
843
+
844
+ if (char === '\n') {
845
+ if (line.length > 0) result.push(line);
846
+ result.push('\n');
847
+ line = '';
848
+ lineWidth = 0;
849
+ pendingSpaces = '';
850
+ i += 1;
851
+ continue;
852
+ }
853
+
854
+ const codePoint = input.codePointAt(i);
855
+ const charText = String.fromCodePoint(codePoint);
856
+ if (charText === ' ' || charText === '\t') {
857
+ pendingSpaces += charText;
858
+ i += charText.length;
859
+ continue;
860
+ }
861
+
862
+ let end = i + charText.length;
863
+ while (end < input.length) {
864
+ const nextChar = input[end];
865
+ if (nextChar === '\n' || nextChar === ' ' || nextChar === '\t' || nextChar === '\u001b' || nextChar === '\u009b') {
866
+ break;
867
+ }
868
+ const nextCodePoint = input.codePointAt(end);
869
+ end += String.fromCodePoint(nextCodePoint).length;
870
+ }
871
+
872
+ const text = input.slice(i, end);
873
+ const textWidth = stringWidth(text);
874
+ const pendingWidth = pendingSpaces ? stringWidth(pendingSpaces) : 0;
875
+
876
+ if (lineWidth > 0 && lineWidth + pendingWidth + textWidth > widthLimit) {
877
+ result.push(line);
878
+ result.push('\n');
879
+ line = '';
880
+ lineWidth = 0;
881
+ pendingSpaces = '';
882
+ }
883
+
884
+ if (lineWidth > 0 && pendingSpaces) {
885
+ line += pendingSpaces;
886
+ lineWidth += pendingWidth;
887
+ }
888
+ pendingSpaces = '';
889
+
890
+ line += text;
891
+ lineWidth += textWidth;
892
+ i = end;
893
+ }
894
+
895
+ if (pendingSpaces && lineWidth > 0) {
896
+ line += pendingSpaces;
897
+ }
898
+ if (line.length > 0) result.push(line);
899
+
900
+ return result.join('');
901
+ }
902
+
903
+ const YAML = {
904
+ parse(text) {
905
+ try {
906
+ const lines = String(text).split('\n');
907
+ const result = {};
908
+ for (const line of lines) {
909
+ const m = line.match(/^([^:#]+):\s*(.*)$/);
910
+ if (m) result[m[1].trim()] = m[2].trim().replace(/^['"]|['"]$/g, '');
911
+ }
912
+ return result;
913
+ } catch { return {}; }
914
+ },
915
+ stringify(obj) {
916
+ try {
917
+ return Object.entries(obj || {}).map(([k, v]) => k + ': ' + v).join('\n') + '\n';
918
+ } catch { return ''; }
919
+ },
920
+ };
921
+
922
+ function parseSemverVersion(value) {
923
+ const text = String(value ?? '').trim().replace(/^[v=]/, '');
924
+ 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-]+)*)?$/);
925
+ if (!match) return null;
926
+ return {
927
+ parts: [match[1], match[2] ?? '0', match[3] ?? '0'].map(Number),
928
+ pre: match[4] ? match[4].split('.') : null,
929
+ };
930
+ }
931
+
932
+ function comparePrerelease(a, b) {
933
+ const size = Math.max(a.length, b.length);
934
+ for (let i = 0; i < size; i++) {
935
+ if (a[i] === undefined) return -1;
936
+ if (b[i] === undefined) return 1;
937
+ const aNum = /^\d+$/.test(a[i]);
938
+ const bNum = /^\d+$/.test(b[i]);
939
+ if (aNum && bNum) { const d = Number(a[i]) - Number(b[i]); if (d) return d < 0 ? -1 : 1; }
940
+ else if (aNum) return -1;
941
+ else if (bNum) return 1;
942
+ else if (a[i] < b[i]) return -1;
943
+ else if (a[i] > b[i]) return 1;
944
+ }
945
+ return 0;
946
+ }
947
+
948
+ const semver = {
949
+ order(left, right) {
950
+ const a = parseSemverVersion(left), b = parseSemverVersion(right);
951
+ if (!a || !b) return NaN;
952
+ for (let i = 0; i < 3; i++) {
953
+ const d = a.parts[i] - b.parts[i];
954
+ if (d) return d < 0 ? -1 : 1;
955
+ }
956
+ if (a.pre && !b.pre) return -1;
957
+ if (!a.pre && b.pre) return 1;
958
+ if (a.pre && b.pre) return comparePrerelease(a.pre, b.pre);
959
+ return 0;
960
+ },
961
+ satisfies(version, range) {
962
+ if (!version || !range) return false;
963
+ const v = String(version).replace(/^[v=]/, '');
964
+ const clean = String(range).trim();
965
+ if (!clean) return false;
966
+ if (clean.includes('||')) return clean.split('||').some(r => semver.satisfies(v, r.trim()));
967
+ const parts = clean.split(/\s+/).filter(Boolean);
968
+ if (parts.length > 1) return parts.every(p => semver.satisfies(v, p));
969
+ const caret = clean.match(/^\^([0-9].*)$/);
970
+ if (caret) {
971
+ const p = parseSemverVersion(caret[1]);
972
+ if (!p) return false;
973
+ const upper = p.parts[0] > 0 ? (p.parts[0] + 1) + '.0.0'
974
+ : p.parts[1] > 0 ? '0.' + (p.parts[1] + 1) + '.0'
975
+ : '0.0.' + (p.parts[2] + 1);
976
+ return semver.satisfies(v, '>=' + caret[1]) && semver.satisfies(v, '<' + upper);
977
+ }
978
+ const tilde = clean.match(/^~([0-9].*)$/);
979
+ if (tilde) {
980
+ const p = parseSemverVersion(tilde[1]);
981
+ if (!p) return false;
982
+ const original = tilde[1].split('.');
983
+ const upper = original.length >= 2
984
+ ? p.parts[0] + '.' + (p.parts[1] + 1) + '.0'
985
+ : (p.parts[0] + 1) + '.0.0';
986
+ return semver.satisfies(v, '>=' + tilde[1]) && semver.satisfies(v, '<' + upper);
987
+ }
988
+ const m = clean.match(/^([><=!]{1,2})\s*([0-9].*)$/);
989
+ if (m) {
990
+ const cmp = semver.order(v, m[2]);
991
+ if (!Number.isFinite(cmp)) return false;
992
+ return m[1] === '>=' ? cmp >= 0 : m[1] === '>' ? cmp > 0 :
993
+ m[1] === '<=' ? cmp <= 0 : m[1] === '<' ? cmp < 0 :
994
+ m[1] === '=' || m[1] === '==' ? cmp === 0 : m[1] === '!=' ? cmp !== 0 : false;
995
+ }
996
+ const exact = parseSemverVersion(clean);
997
+ return exact ? semver.order(v, clean) === 0 : false;
998
+ },
999
+ };
1000
+
1001
+
334
1002
  async function main() {
335
1003
  const extractedFile = ensureEntryFile();
336
1004
  const code = fs.readFileSync(extractedFile, 'utf8');
@@ -352,7 +1020,33 @@ async function main() {
352
1020
  process.once('uncaughtException', onAsyncError);
353
1021
  process.once('unhandledRejection', onAsyncError);
354
1022
  Object.defineProperty(process.versions, 'bun', { value: '1.1.8', configurable: true });
355
- globalThis.Bun = { version: '1.1.8', stringWidth };
1023
+ const BunShim = {
1024
+ version: '1.1.8',
1025
+ stringWidth,
1026
+ hash: hashValue,
1027
+ which,
1028
+ wrapAnsi,
1029
+ stripANSI,
1030
+ semver,
1031
+ YAML,
1032
+ gc: (sync) => {
1033
+ try {
1034
+ if (typeof global.gc === 'function') global.gc(sync === false ? false : true);
1035
+ } catch {}
1036
+ },
1037
+ stdin: { stream: null },
1038
+ embeddedFiles: [],
1039
+ };
1040
+ const BunProxy = new Proxy(BunShim, {
1041
+ get(target, key, receiver) {
1042
+ if (!(key in target) && typeof key !== 'symbol' && debugBunShim) {
1043
+ console.error('[BunShim missing]', key);
1044
+ }
1045
+ return Reflect.get(target, key, receiver);
1046
+ },
1047
+ });
1048
+ globalThis.Bun = BunProxy;
1049
+
356
1050
  process.argv = ['node', extractedFile, ...argv];
357
1051
  process.exit = code => {
358
1052
  throw new RequestedExit(code);
@@ -386,7 +1080,9 @@ async function main() {
386
1080
  }
387
1081
  }
388
1082
 
389
- main().catch(error => {
1083
+ main().then(() => {
1084
+ process.exit(process.exitCode ?? 0);
1085
+ }).catch(error => {
390
1086
  if (error && error.code === 'CLAUDE_TERMUX_OFFICIAL_UPDATE_BLOCKED') {
391
1087
  console.error(BLOCK_MESSAGE);
392
1088
  process.exit(error.status || 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bash0816/claude-code",
3
- "version": "2.1.159-2",
3
+ "version": "2.1.159-4",
4
4
  "description": "Unofficial Termux-native Claude Code wrapper with audited native replay",
5
5
  "license": "MIT",
6
6
  "bin": {