@bash0816/claude-code 2.1.159-2 → 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.
@@ -190,6 +190,15 @@
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"
193
202
  }
194
203
  }
195
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.159-2",
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
  }
@@ -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);
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-3",
4
4
  "description": "Unofficial Termux-native Claude Code wrapper with audited native replay",
5
5
  "license": "MIT",
6
6
  "bin": {