@bash0816/claude-code 2.1.154 → 2.1.156

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.
@@ -181,6 +181,13 @@
181
181
  "entry_js_offset": 222957396,
182
182
  "entry_end_offset": 238482842,
183
183
  "status": "termux_verified"
184
+ },
185
+ "2.1.156": {
186
+ "wrapper_spec": "@anthropic-ai/claude-code@2.1.156",
187
+ "native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.156",
188
+ "entry_js_offset": 222957812,
189
+ "entry_end_offset": 238483519,
190
+ "status": "termux_verified"
184
191
  }
185
192
  }
186
193
  }
@@ -4,10 +4,10 @@
4
4
  "canonical_package_name": "@bash0816/claude-code",
5
5
  "canonical_manifest_url": "https://raw.githubusercontent.com/bash0816/ClaudeCode-Termux/main/config/claude-termux-release-manifest.json",
6
6
  "canonical_repository_url": "https://github.com/bash0816/ClaudeCode-Termux",
7
- "bridge_package_version": "2.1.154",
8
- "default_native_version": "2.1.154",
9
- "latest_audited_version": "2.1.154",
10
- "latest_candidate_version": "2.1.154",
11
- "previous_stable_version": "2.1.126",
7
+ "bridge_package_version": "2.1.156",
8
+ "default_native_version": "2.1.156",
9
+ "latest_audited_version": "2.1.156",
10
+ "latest_candidate_version": "2.1.156",
11
+ "previous_stable_version": "2.1.154",
12
12
  "manifest_url": "https://raw.githubusercontent.com/bash0816/ClaudeCode-Termux/main/config/claude-termux-release-manifest.json"
13
13
  }
@@ -75,38 +75,6 @@ function ensureEntryFile() {
75
75
 
76
76
  function createFakeRequire(realRequire) {
77
77
  const realChild = realRequire('child_process');
78
- const realVm = realRequire('vm');
79
-
80
- function injectBunIntoContext(context) {
81
- if (!context || typeof context !== 'object') return context;
82
- try {
83
- if (!Object.prototype.hasOwnProperty.call(context, 'Bun')) {
84
- Object.defineProperty(context, 'Bun', {
85
- value: globalThis.Bun,
86
- configurable: true,
87
- writable: true,
88
- });
89
- }
90
- } catch {}
91
- return context;
92
- }
93
-
94
- if (!realVm.__bunShimPatched) {
95
- const origCreateContext = realVm.createContext.bind(realVm);
96
- const origRunInNewContext = realVm.runInNewContext.bind(realVm);
97
- realVm.createContext = (ctx, ...rest) => origCreateContext(injectBunIntoContext(ctx), ...rest);
98
- realVm.runInNewContext = (code, ctx, ...rest) => origRunInNewContext(code, injectBunIntoContext(ctx), ...rest);
99
- const ScriptProto = realVm.Script && realVm.Script.prototype;
100
- if (ScriptProto && !ScriptProto.__bunShimPatched) {
101
- const origRunInContext = ScriptProto.runInContext;
102
- const origRunInNewCtx = ScriptProto.runInNewContext;
103
- ScriptProto.runInContext = function(ctx, ...rest) { return origRunInContext.call(this, injectBunIntoContext(ctx), ...rest); };
104
- ScriptProto.runInNewContext = function(ctx, ...rest) { return origRunInNewCtx.call(this, injectBunIntoContext(ctx), ...rest); };
105
- Object.defineProperty(ScriptProto, '__bunShimPatched', { value: true });
106
- }
107
- Object.defineProperty(realVm, '__bunShimPatched', { value: true });
108
- }
109
-
110
78
  function rewriteArgs(args) {
111
79
  if (
112
80
  Array.isArray(args) &&
@@ -120,8 +88,6 @@ function createFakeRequire(realRequire) {
120
88
  }
121
89
 
122
90
  return function fakeRequire(id) {
123
- if (id === 'vm') return realVm;
124
-
125
91
  if (id === 'ws') {
126
92
  class WS {
127
93
  on() {}
@@ -153,321 +119,340 @@ function createFakeRequire(realRequire) {
153
119
  };
154
120
  }
155
121
 
156
- function createBunShim() {
157
- const childProcess = require('child_process');
158
- const crypto = require('crypto');
159
- const net = require('net');
160
- const os = require('os');
161
- const ansiPattern =
162
- /[\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;
163
-
164
- function stripANSI(value) {
165
- if (typeof value !== 'string' || value.length === 0) return '';
166
- return value.replace(ansiPattern, '');
167
- }
122
+ const ansiPattern =
123
+ /[\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;
124
+ const ansiPatternSingle = new RegExp(ansiPattern.source);
125
+ const debugBunShim = process.env.CLAUDE_TERMUX_DEBUG_BUN_SHIM === '1';
126
+
127
+ function stripANSI(text) {
128
+ if (typeof text !== 'string' || text.length === 0) return '';
129
+ return text.replace(ansiPattern, '');
130
+ }
168
131
 
169
- function isZeroWidth(codePoint) {
170
- return (
171
- codePoint <= 0x1f ||
172
- (codePoint >= 0x7f && codePoint <= 0x9f) ||
173
- (codePoint >= 0x300 && codePoint <= 0x36f) ||
174
- (codePoint >= 0x200b && codePoint <= 0x200f) ||
175
- codePoint === 0xfeff ||
176
- (codePoint >= 0xfe00 && codePoint <= 0xfe0f)
177
- );
132
+ function codePointWidth(codePoint) {
133
+ if (
134
+ codePoint <= 0x1f ||
135
+ (codePoint >= 0x7f && codePoint <= 0x9f) ||
136
+ (codePoint >= 0x300 && codePoint <= 0x36f) ||
137
+ (codePoint >= 0x200b && codePoint <= 0x200f) ||
138
+ codePoint === 0xfeff ||
139
+ (codePoint >= 0xfe00 && codePoint <= 0xfe0f)
140
+ ) {
141
+ return 0;
178
142
  }
179
143
 
180
- function isWide(codePoint) {
181
- return (
182
- (codePoint >= 0x1100 && codePoint <= 0x115f) ||
183
- (codePoint >= 0x2329 && codePoint <= 0x232a) ||
184
- (codePoint >= 0x2e80 && codePoint <= 0xa4cf && codePoint !== 0x303f) ||
185
- (codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
186
- (codePoint >= 0xf900 && codePoint <= 0xfaff) ||
187
- (codePoint >= 0xfe10 && codePoint <= 0xfe19) ||
188
- (codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||
189
- (codePoint >= 0xff00 && codePoint <= 0xff60) ||
190
- (codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
191
- (codePoint >= 0x1f300 && codePoint <= 0x1faf8) ||
192
- (codePoint >= 0x20000 && codePoint <= 0x3fffd)
193
- );
144
+ if (
145
+ (codePoint >= 0x1100 && codePoint <= 0x115f) ||
146
+ (codePoint >= 0x2329 && codePoint <= 0x232a) ||
147
+ (codePoint >= 0x2e80 && codePoint <= 0xa4cf && codePoint !== 0x303f) ||
148
+ (codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
149
+ (codePoint >= 0xf900 && codePoint <= 0xfaff) ||
150
+ (codePoint >= 0xfe10 && codePoint <= 0xfe19) ||
151
+ (codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||
152
+ (codePoint >= 0xff00 && codePoint <= 0xff60) ||
153
+ (codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
154
+ (codePoint >= 0x1f300 && codePoint <= 0x1faf8) ||
155
+ (codePoint >= 0x20000 && codePoint <= 0x3fffd)
156
+ ) {
157
+ return 2;
194
158
  }
195
159
 
196
- function stringWidth(value) {
197
- const text = stripANSI(typeof value === 'string' ? value : String(value ?? ''));
198
- let width = 0;
199
- for (const char of text) {
200
- const codePoint = char.codePointAt(0);
201
- if (isZeroWidth(codePoint)) continue;
202
- width += isWide(codePoint) ? 2 : 1;
203
- }
204
- return width;
160
+ return 1;
161
+ }
162
+
163
+ function stringWidth(value) {
164
+ const text = stripANSI(typeof value === 'string' ? value : String(value ?? ''));
165
+ let width = 0;
166
+ for (const char of text) {
167
+ const codePoint = char.codePointAt(0);
168
+ width += codePointWidth(codePoint);
205
169
  }
170
+ return width;
171
+ }
206
172
 
207
- function normalizeInput(value) {
208
- if (Buffer.isBuffer(value) || value instanceof Uint8Array) return Buffer.from(value);
209
- if (typeof value === 'string') return Buffer.from(value);
210
- return Buffer.from(String(value ?? ''));
173
+ function toHashBytes(value) {
174
+ if (Buffer.isBuffer(value)) return Buffer.from(value);
175
+ if (value instanceof Uint8Array) return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
176
+ if (value instanceof ArrayBuffer) return Buffer.from(value);
177
+ if (ArrayBuffer.isView(value)) {
178
+ return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
211
179
  }
180
+ return Buffer.from(String(value ?? ''));
181
+ }
212
182
 
213
- function hash(value) {
214
- const digest = crypto.createHash('sha256').update(normalizeInput(value)).digest();
215
- return digest.readUInt32LE(0);
183
+ function hashValue(value, seed = 0) {
184
+ const FNV_OFFSET_BASIS_64 = 0xcbf29ce484222325n;
185
+ const FNV_PRIME_64 = 0x100000001b3n;
186
+ const MASK_64 = 0xffffffffffffffffn;
187
+
188
+ const seedNumber = typeof seed === 'bigint' ? Number(seed) : Number(seed);
189
+ const seedValue = Number.isFinite(seedNumber) ? Math.trunc(seedNumber) : 0;
190
+ let result = BigInt.asUintN(64, FNV_OFFSET_BASIS_64 ^ BigInt(seedValue));
191
+
192
+ const bytes = toHashBytes(value);
193
+ for (const byte of bytes) {
194
+ result ^= BigInt(byte);
195
+ result = (result * FNV_PRIME_64) & MASK_64;
216
196
  }
217
197
 
218
- function which(command) {
219
- if (typeof command !== 'string' || command.length === 0) return null;
220
- const pathValue = process.env.PATH || '';
221
- const separator = os.platform() === 'win32' ? ';' : ':';
222
- for (const entry of pathValue.split(separator)) {
223
- if (!entry) continue;
224
- const candidate = path.join(entry, command);
225
- try {
226
- fs.accessSync(candidate, fs.constants.X_OK);
227
- return candidate;
228
- } catch {}
198
+ return BigInt(result);
199
+ }
200
+
201
+ function which(cmd) {
202
+ const fs = require('fs');
203
+ const path = require('path');
204
+
205
+ if (typeof cmd !== 'string' || cmd.length === 0) return null;
206
+
207
+ const isExecutable = candidate => {
208
+ try {
209
+ fs.accessSync(candidate, fs.constants.X_OK);
210
+ const stat = fs.statSync(candidate);
211
+ return stat.isFile();
212
+ } catch {
213
+ return false;
229
214
  }
230
- return null;
215
+ };
216
+
217
+ if (cmd.includes(path.sep)) {
218
+ return isExecutable(cmd) ? path.resolve(cmd) : null;
231
219
  }
232
220
 
233
- function spawn(argv, options = {}) {
234
- if (!Array.isArray(argv) || argv.length === 0) {
235
- throw new TypeError('Bun.spawn expects a non-empty argv array');
236
- }
237
- const [command, ...args] = argv;
238
- const terminal = options.terminal || null;
221
+ const searchPath = process.env.PATH || '';
222
+ for (const entry of searchPath.split(path.delimiter)) {
223
+ if (!entry) continue;
224
+ const candidate = path.join(entry, cmd);
225
+ if (isExecutable(candidate)) return candidate;
226
+ }
227
+ return null;
228
+ }
239
229
 
240
- function resolveStdio(val, fallback) {
241
- if (val === 'ignore' || val === 'inherit' || val === 'pipe') return val;
242
- return fallback;
243
- }
230
+ function wrapAnsi(str, columns, options) {
231
+ const input = typeof str === 'string' ? str : String(str ?? '');
232
+ const widthLimit = Number(columns);
233
+ if (!Number.isFinite(widthLimit) || widthLimit <= 0) return input;
244
234
 
245
- let stdioSpec;
246
- if (terminal) {
247
- stdioSpec = ['pipe', 'pipe', 'pipe'];
248
- } else if (Array.isArray(options.stdio)) {
249
- stdioSpec = options.stdio.map(s => resolveStdio(s, 'pipe'));
250
- } else {
251
- stdioSpec = [
252
- resolveStdio(options.stdin, 'pipe'),
253
- resolveStdio(options.stdout, 'pipe'),
254
- resolveStdio(options.stderr, 'pipe'),
255
- ];
256
- }
235
+ const wordWrap = !options || options.wordWrap !== false;
236
+ const hard = !!(options && options.hard);
257
237
 
258
- const nodeChild = childProcess.spawn(command, args, {
259
- cwd: options.cwd,
260
- env: options.env || process.env,
261
- detached: options.detached,
262
- windowsHide: options.windowsHide,
263
- stdio: stdioSpec,
264
- });
238
+ if (!wordWrap || hard) {
239
+ const result = [];
240
+ let width = 0;
265
241
 
266
- if (terminal) {
267
- const fireData = chunk => {
268
- if (!terminal._closed && terminal._options && typeof terminal._options.data === 'function') {
269
- terminal._options.data(terminal, Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
270
- }
271
- };
272
- nodeChild.stdout?.on('data', fireData);
273
- nodeChild.stderr?.on('data', fireData);
274
- const origWrite = terminal.write.bind(terminal);
275
- terminal.write = data => {
276
- if (nodeChild.stdin && !nodeChild.stdin.destroyed) {
277
- nodeChild.stdin.write(Buffer.isBuffer(data) ? data : Buffer.from(data));
242
+ for (let i = 0; i < input.length; ) {
243
+ const char = input[i];
244
+
245
+ if (char === '\u001b' || char === '\u009b') {
246
+ const match = input.slice(i).match(ansiPatternSingle);
247
+ if (match && match.index === 0) {
248
+ result.push(match[0]);
249
+ i += match[0].length;
250
+ continue;
278
251
  }
279
- return origWrite(data);
280
- };
281
- }
252
+ }
282
253
 
283
- nodeChild.exited = new Promise(resolve => {
284
- nodeChild.once('exit', (code, signal) => resolve(code != null ? code : (signal ? 1 : 0)));
285
- });
254
+ if (char === '\n') {
255
+ result.push(char);
256
+ width = 0;
257
+ i += 1;
258
+ continue;
259
+ }
286
260
 
287
- function makeTextReader(stream) {
288
- return {
289
- text() {
290
- return new Promise((resolve, reject) => {
291
- if (!stream) return resolve('');
292
- const chunks = [];
293
- stream.on('data', chunk => chunks.push(chunk));
294
- stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
295
- stream.on('error', reject);
296
- });
297
- },
298
- };
261
+ const codePoint = input.codePointAt(i);
262
+ const charText = String.fromCodePoint(codePoint);
263
+ const charWidth = codePointWidth(codePoint);
264
+
265
+ if (width > 0 && width + charWidth > widthLimit) {
266
+ result.push('\n');
267
+ width = 0;
268
+ }
269
+
270
+ result.push(charText);
271
+ width += charWidth;
272
+ i += charText.length;
299
273
  }
300
- if (nodeChild.stdout) Object.assign(nodeChild.stdout, makeTextReader(nodeChild.stdout));
301
- if (nodeChild.stderr) Object.assign(nodeChild.stderr, makeTextReader(nodeChild.stderr));
302
- return nodeChild;
274
+
275
+ return result.join('');
303
276
  }
304
277
 
305
- class TerminalShim {
306
- constructor(options = {}) {
307
- this._options = options;
308
- this._cols = options.cols || 80;
309
- this._rows = options.rows || 24;
310
- this._closed = false;
311
- }
312
- write(data) {
313
- if (this._closed) return;
314
- if (this._options.data) this._options.data(this, Buffer.isBuffer(data) ? data : Buffer.from(data));
278
+ const result = [];
279
+ let line = '';
280
+ let lineWidth = 0;
281
+ let pendingSpaces = '';
282
+
283
+ for (let i = 0; i < input.length; ) {
284
+ const char = input[i];
285
+
286
+ if (char === '\u001b' || char === '\u009b') {
287
+ const match = input.slice(i).match(ansiPatternSingle);
288
+ if (match && match.index === 0) {
289
+ line += match[0];
290
+ i += match[0].length;
291
+ continue;
292
+ }
315
293
  }
316
- resize(cols, rows) {
317
- this._cols = cols;
318
- this._rows = rows;
294
+
295
+ if (char === '\n') {
296
+ if (line.length > 0) result.push(line);
297
+ result.push('\n');
298
+ line = '';
299
+ lineWidth = 0;
300
+ pendingSpaces = '';
301
+ i += 1;
302
+ continue;
319
303
  }
320
- close() {
321
- this._closed = true;
304
+
305
+ const codePoint = input.codePointAt(i);
306
+ const charText = String.fromCodePoint(codePoint);
307
+ if (charText === ' ' || charText === '\t') {
308
+ pendingSpaces += charText;
309
+ i += charText.length;
310
+ continue;
322
311
  }
323
- }
324
312
 
325
- function listen(options) {
326
- const sockets = new Set();
327
- const server = net.createServer(socket => {
328
- sockets.add(socket);
329
- const connection = {
330
- data: undefined,
331
- write(chunk) {
332
- const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
333
- const ok = socket.write(buffer);
334
- return ok ? buffer.length : 0;
335
- },
336
- end(chunk) {
337
- socket.end(chunk);
338
- },
339
- destroy(error) {
340
- socket.destroy(error);
341
- },
342
- };
343
- socket.on('data', chunk => {
344
- if (options.socket && typeof options.socket.data === 'function') {
345
- options.socket.data(connection, chunk);
346
- }
347
- });
348
- socket.on('drain', () => {
349
- if (options.socket && typeof options.socket.drain === 'function') {
350
- options.socket.drain(connection);
351
- }
352
- });
353
- socket.on('close', () => {
354
- sockets.delete(socket);
355
- if (options.socket && typeof options.socket.close === 'function') {
356
- options.socket.close(connection);
357
- }
358
- });
359
- socket.on('error', error => {
360
- if (options.socket && typeof options.socket.error === 'function') {
361
- options.socket.error(connection, error);
362
- }
363
- });
364
- if (options.socket && typeof options.socket.open === 'function') {
365
- options.socket.open(connection);
313
+ let end = i + charText.length;
314
+ while (end < input.length) {
315
+ const nextChar = input[end];
316
+ if (nextChar === '\n' || nextChar === ' ' || nextChar === '\t' || nextChar === '\u001b' || nextChar === '\u009b') {
317
+ break;
366
318
  }
367
- });
319
+ const nextCodePoint = input.codePointAt(end);
320
+ end += String.fromCodePoint(nextCodePoint).length;
321
+ }
368
322
 
369
- server.listen(options.port || 0, options.hostname || '127.0.0.1');
323
+ const text = input.slice(i, end);
324
+ const textWidth = stringWidth(text);
325
+ const pendingWidth = pendingSpaces ? stringWidth(pendingSpaces) : 0;
370
326
 
371
- return {
372
- get port() {
373
- const address = server.address();
374
- return address && typeof address === 'object' ? address.port : 0;
375
- },
376
- stop(closeConnections) {
377
- server.close();
378
- if (closeConnections) {
379
- for (const socket of sockets) socket.destroy();
380
- }
381
- },
382
- };
383
- }
327
+ if (lineWidth > 0 && lineWidth + pendingWidth + textWidth > widthLimit) {
328
+ result.push(line);
329
+ result.push('\n');
330
+ line = '';
331
+ lineWidth = 0;
332
+ pendingSpaces = '';
333
+ }
384
334
 
385
- const semver = {
386
- order(left, right) {
387
- const leftParts = String(left).replace(/^[^0-9]*/, '').split('.').map(Number);
388
- const rightParts = String(right).replace(/^[^0-9]*/, '').split('.').map(Number);
389
- const size = Math.max(leftParts.length, rightParts.length);
390
- for (let index = 0; index < size; index += 1) {
391
- const diff = (leftParts[index] || 0) - (rightParts[index] || 0);
392
- if (diff !== 0) return diff > 0 ? 1 : -1;
393
- }
394
- return 0;
395
- },
396
- satisfies(version, range) {
397
- const v = String(version).replace(/^[^0-9]*/, '');
398
- const clean = String(range).trim();
399
- const match = clean.match(/^([><=!^~]+)\s*([0-9][^\s]*)/);
400
- if (!match) return true;
401
- const [, op, rv] = match;
402
- const cmp = semver.order(v, rv);
403
- if (op === '>=' || op === '=>') return cmp >= 0;
404
- if (op === '>') return cmp > 0;
405
- if (op === '<=' || op === '=<') return cmp <= 0;
406
- if (op === '<') return cmp < 0;
407
- if (op === '==' || op === '=') return cmp === 0;
408
- if (op === '!=') return cmp !== 0;
409
- return true;
410
- },
411
- };
335
+ if (lineWidth > 0 && pendingSpaces) {
336
+ line += pendingSpaces;
337
+ lineWidth += pendingWidth;
338
+ }
339
+ pendingSpaces = '';
412
340
 
413
- const YAML = {
414
- parse(text) {
415
- try {
416
- const lines = String(text).split('\n');
417
- const result = {};
418
- for (const line of lines) {
419
- const m = line.match(/^([^:#]+):\s*(.*)$/);
420
- if (m) result[m[1].trim()] = m[2].trim().replace(/^["']|["']$/g, '');
421
- }
422
- return result;
423
- } catch { return {}; }
424
- },
425
- stringify(obj) {
426
- try {
427
- return Object.entries(obj || {}).map(([k, v]) => `${k}: ${v}`).join('\n') + '\n';
428
- } catch { return ''; }
429
- },
430
- };
341
+ line += text;
342
+ lineWidth += textWidth;
343
+ i = end;
344
+ }
431
345
 
432
- class Transpiler {
433
- constructor(_options) {}
434
- transformSync(code) { return typeof code === 'string' ? code : ''; }
435
- scanImports(code) {
436
- const imports = [];
437
- const reStatic = /(?:^|[^.])import\s+(?:[^'"]+\s+from\s+)?['"]([^'"]+)['"]/gm;
438
- const reDynamic = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
439
- const reRequire = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
440
- let m;
441
- while ((m = reStatic.exec(String(code))) !== null) imports.push({ path: m[1], kind: 'import-statement' });
442
- while ((m = reDynamic.exec(String(code))) !== null) imports.push({ path: m[1], kind: 'dynamic-import' });
443
- while ((m = reRequire.exec(String(code))) !== null) imports.push({ path: m[1], kind: 'require-call' });
444
- return imports;
445
- }
346
+ if (pendingSpaces && lineWidth > 0) {
347
+ line += pendingSpaces;
446
348
  }
349
+ if (line.length > 0) result.push(line);
447
350
 
351
+ return result.join('');
352
+ }
353
+
354
+ const YAML = {
355
+ parse(text) {
356
+ try {
357
+ const lines = String(text).split('\n');
358
+ const result = {};
359
+ for (const line of lines) {
360
+ const m = line.match(/^([^:#]+):\s*(.*)$/);
361
+ if (m) result[m[1].trim()] = m[2].trim().replace(/^['"]|['"]$/g, '');
362
+ }
363
+ return result;
364
+ } catch { return {}; }
365
+ },
366
+ stringify(obj) {
367
+ try {
368
+ return Object.entries(obj || {}).map(([k, v]) => k + ': ' + v).join('\n') + '\n';
369
+ } catch { return ''; }
370
+ },
371
+ };
372
+
373
+ function parseSemverVersion(value) {
374
+ const text = String(value ?? '').trim().replace(/^[v=]/, '');
375
+ 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-]+)*)?$/);
376
+ if (!match) return null;
448
377
  return {
449
- version: '1.1.8',
450
- embeddedFiles: [],
451
- gc: typeof global.gc === 'function' ? () => global.gc() : () => {},
452
- generateHeapSnapshot: () => Buffer.alloc(0),
453
- hash,
454
- listen,
455
- semver,
456
- spawn,
457
- stdin: process.stdin,
458
- stripANSI,
459
- stringWidth,
460
- Terminal: TerminalShim,
461
- Transpiler,
462
- which,
463
- wrapAnsi: value => String(value ?? ''),
464
- YAML,
378
+ parts: [match[1], match[2] ?? '0', match[3] ?? '0'].map(Number),
379
+ pre: match[4] ? match[4].split('.') : null,
465
380
  };
466
381
  }
467
382
 
383
+ function comparePrerelease(a, b) {
384
+ const size = Math.max(a.length, b.length);
385
+ for (let i = 0; i < size; i++) {
386
+ if (a[i] === undefined) return -1;
387
+ if (b[i] === undefined) return 1;
388
+ const aNum = /^\d+$/.test(a[i]);
389
+ const bNum = /^\d+$/.test(b[i]);
390
+ if (aNum && bNum) { const d = Number(a[i]) - Number(b[i]); if (d) return d < 0 ? -1 : 1; }
391
+ else if (aNum) return -1;
392
+ else if (bNum) return 1;
393
+ else if (a[i] < b[i]) return -1;
394
+ else if (a[i] > b[i]) return 1;
395
+ }
396
+ return 0;
397
+ }
398
+
399
+ const semver = {
400
+ order(left, right) {
401
+ const a = parseSemverVersion(left), b = parseSemverVersion(right);
402
+ if (!a || !b) return NaN;
403
+ for (let i = 0; i < 3; i++) {
404
+ const d = a.parts[i] - b.parts[i];
405
+ if (d) return d < 0 ? -1 : 1;
406
+ }
407
+ if (a.pre && !b.pre) return -1;
408
+ if (!a.pre && b.pre) return 1;
409
+ if (a.pre && b.pre) return comparePrerelease(a.pre, b.pre);
410
+ return 0;
411
+ },
412
+ satisfies(version, range) {
413
+ if (!version || !range) return false;
414
+ const v = String(version).replace(/^[v=]/, '');
415
+ const clean = String(range).trim();
416
+ if (!clean) return false;
417
+ if (clean.includes('||')) return clean.split('||').some(r => semver.satisfies(v, r.trim()));
418
+ const parts = clean.split(/\s+/).filter(Boolean);
419
+ if (parts.length > 1) return parts.every(p => semver.satisfies(v, p));
420
+ const caret = clean.match(/^\^([0-9].*)$/);
421
+ if (caret) {
422
+ const p = parseSemverVersion(caret[1]);
423
+ if (!p) return false;
424
+ const upper = p.parts[0] > 0 ? (p.parts[0] + 1) + '.0.0'
425
+ : p.parts[1] > 0 ? '0.' + (p.parts[1] + 1) + '.0'
426
+ : '0.0.' + (p.parts[2] + 1);
427
+ return semver.satisfies(v, '>=' + caret[1]) && semver.satisfies(v, '<' + upper);
428
+ }
429
+ const tilde = clean.match(/^~([0-9].*)$/);
430
+ if (tilde) {
431
+ const p = parseSemverVersion(tilde[1]);
432
+ if (!p) return false;
433
+ const original = tilde[1].split('.');
434
+ const upper = original.length >= 2
435
+ ? p.parts[0] + '.' + (p.parts[1] + 1) + '.0'
436
+ : (p.parts[0] + 1) + '.0.0';
437
+ return semver.satisfies(v, '>=' + tilde[1]) && semver.satisfies(v, '<' + upper);
438
+ }
439
+ const m = clean.match(/^([><=!]{1,2})\s*([0-9].*)$/);
440
+ if (m) {
441
+ const cmp = semver.order(v, m[2]);
442
+ if (!Number.isFinite(cmp)) return false;
443
+ return m[1] === '>=' ? cmp >= 0 : m[1] === '>' ? cmp > 0 :
444
+ m[1] === '<=' ? cmp <= 0 : m[1] === '<' ? cmp < 0 :
445
+ m[1] === '=' || m[1] === '==' ? cmp === 0 : m[1] === '!=' ? cmp !== 0 : false;
446
+ }
447
+ const exact = parseSemverVersion(clean);
448
+ return exact ? semver.order(v, clean) === 0 : false;
449
+ },
450
+ };
451
+
468
452
  async function main() {
469
453
  const extractedFile = ensureEntryFile();
470
454
  const code = fs.readFileSync(extractedFile, 'utf8');
455
+ const fn = eval('(' + code);
471
456
 
472
457
  const originalArgv = process.argv.slice();
473
458
  const originalExit = process.exit;
@@ -476,6 +461,7 @@ async function main() {
476
461
  const originalGlobalBun = globalThis.Bun;
477
462
  const asyncErrors = [];
478
463
 
464
+ const fakeRequire = createFakeRequire(require);
479
465
  function onAsyncError(error) {
480
466
  asyncErrors.push(error);
481
467
  }
@@ -484,14 +470,38 @@ async function main() {
484
470
  process.once('uncaughtException', onAsyncError);
485
471
  process.once('unhandledRejection', onAsyncError);
486
472
  Object.defineProperty(process.versions, 'bun', { value: '1.1.8', configurable: true });
487
- globalThis.Bun = createBunShim();
488
- const fakeRequire = createFakeRequire(require);
473
+ const BunShim = {
474
+ version: '1.1.8',
475
+ stringWidth,
476
+ hash: hashValue,
477
+ which,
478
+ wrapAnsi,
479
+ stripANSI,
480
+ semver,
481
+ YAML,
482
+ gc: (sync) => {
483
+ try {
484
+ if (typeof global.gc === 'function') global.gc(sync === false ? false : true);
485
+ } catch {}
486
+ },
487
+ stdin: { stream: null },
488
+ embeddedFiles: [],
489
+ };
490
+ const BunProxy = new Proxy(BunShim, {
491
+ get(target, key, receiver) {
492
+ if (!(key in target) && typeof key !== 'symbol' && debugBunShim) {
493
+ console.error('[BunShim missing]', key);
494
+ }
495
+ return Reflect.get(target, key, receiver);
496
+ },
497
+ });
498
+ globalThis.Bun = BunProxy;
499
+
489
500
  process.argv = ['node', extractedFile, ...argv];
490
501
  process.exit = code => {
491
502
  throw new RequestedExit(code);
492
503
  };
493
504
 
494
- const fn = eval('(' + code);
495
505
  const moduleLike = { exports: {} };
496
506
  const maybePromise = fn(moduleLike.exports, fakeRequire, moduleLike, extractedFile, workdir);
497
507
  if (maybePromise && typeof maybePromise.then === 'function') await maybePromise;
@@ -515,10 +525,6 @@ async function main() {
515
525
  Object.defineProperty(process.versions, 'bun', { value: originalBun, configurable: true });
516
526
  }
517
527
  } catch {}
518
- try {
519
- if (hadGlobalBun) globalThis.Bun = originalGlobalBun;
520
- else delete globalThis.Bun;
521
- } catch {}
522
528
  }
523
529
  }
524
530
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bash0816/claude-code",
3
- "version": "2.1.154",
3
+ "version": "2.1.156",
4
4
  "description": "Termux-native Claude Code wrapper with audited native replay",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -17,6 +17,6 @@
17
17
  "README.md"
18
18
  ],
19
19
  "engines": {
20
- "node": ">=20"
20
+ "node": ">=18"
21
21
  }
22
22
  }