tweakcc-fixed 2.0.10 → 2.0.12
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 +46 -5
- package/dist/config-C2GrLEMy.mjs +723 -0
- package/dist/{content-BgJRG9G4.mjs → content-CIILIs3n.mjs} +5 -5
- package/dist/index.mjs +14 -11
- package/dist/lib/index.d.mts +23 -4
- package/dist/lib/index.mjs +1 -1
- package/dist/nativeInstallation-CnZgAk8S.mjs +4 -0
- package/package.json +3 -2
- package/dist/config-Cm9ucz0_.mjs +0 -723
- package/dist/nativeInstallation-DEA12AqK.mjs +0 -4
package/dist/lib/index.d.mts
CHANGED
|
@@ -127,6 +127,7 @@ interface MiscConfig {
|
|
|
127
127
|
enableVoiceConciseOutput: boolean;
|
|
128
128
|
enableChannelsMode: boolean;
|
|
129
129
|
maxEffortDefault: boolean;
|
|
130
|
+
autonomousOperationAllModels: boolean;
|
|
130
131
|
autoModeClassifierModel: AutoModeClassifierModel;
|
|
131
132
|
suppressDeferredTools: boolean;
|
|
132
133
|
claudemdContextOncePerConversation: boolean;
|
|
@@ -206,12 +207,23 @@ interface Installation {
|
|
|
206
207
|
*/
|
|
207
208
|
declare function findAllInstallations(): Promise<Installation[]>;
|
|
208
209
|
/**
|
|
209
|
-
* Options for tryDetectInstallation
|
|
210
|
+
* Options for {@link tryDetectInstallation}.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* import { tryDetectInstallation, type DetectInstallationOptions } from 'tweakcc';
|
|
215
|
+
*
|
|
216
|
+
* const opts: DetectInstallationOptions = { interactive: true };
|
|
217
|
+
* const installation = await tryDetectInstallation(opts);
|
|
218
|
+
* ```
|
|
210
219
|
*/
|
|
211
220
|
interface DetectInstallationOptions {
|
|
212
|
-
/** Explicit path to Claude Code
|
|
221
|
+
/** Explicit path to a Claude Code installation — skips auto-detection. */
|
|
213
222
|
path?: string;
|
|
214
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* Show the interactive picker when multiple installations are found, instead
|
|
225
|
+
* of throwing with the list. Default: `false`.
|
|
226
|
+
*/
|
|
215
227
|
interactive?: boolean;
|
|
216
228
|
}
|
|
217
229
|
/**
|
|
@@ -242,7 +254,10 @@ declare function showInteractiveInstallationPicker(candidates: Installation[]):
|
|
|
242
254
|
* - native installs: extracts embedded JS from binary
|
|
243
255
|
*
|
|
244
256
|
* @param installation - The installation to read from
|
|
245
|
-
* @returns
|
|
257
|
+
* @returns An object with `content` (the JavaScript as a string) and
|
|
258
|
+
* `clearBytecode`, a flag that must be passed back to {@link writeContent}.
|
|
259
|
+
* It is `true` only for native Bun installs whose embedded bytecode cache
|
|
260
|
+
* must be invalidated after the JS changes; always `false` for npm installs.
|
|
246
261
|
*/
|
|
247
262
|
declare function readContent(installation: Installation): Promise<{
|
|
248
263
|
content: string;
|
|
@@ -256,6 +271,10 @@ declare function readContent(installation: Installation): Promise<{
|
|
|
256
271
|
*
|
|
257
272
|
* @param installation - The installation to write to
|
|
258
273
|
* @param content - The modified JavaScript content
|
|
274
|
+
* @param clearBytecode - Pass the value returned by {@link readContent}. For
|
|
275
|
+
* native Bun installs it clears the embedded bytecode cache so the new JS is
|
|
276
|
+
* re-parsed (stale bytecode would otherwise keep running the OLD code);
|
|
277
|
+
* ignored for npm installs.
|
|
259
278
|
*/
|
|
260
279
|
declare function writeContent(installation: Installation, content: string, clearBytecode: boolean): Promise<void>;
|
|
261
280
|
//#endregion
|
package/dist/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,
|
|
1
|
+
import{B as e,H as t,I as n,J as r,L as i,R as a,V as o,a as s,c,h as l,k as u,l as d,q as f,r as p,z as m}from"../config-C2GrLEMy.mjs";import{a as h,i as g,n as _,r as v,t as y}from"../content-CIILIs3n.mjs";import*as b from"node:fs/promises";import*as x from"node:path";async function S(e,t){let n=x.dirname(t);await b.mkdir(n,{recursive:!0}),await b.copyFile(e,t)}async function C(e,t){if(!await l(e))throw Error(`Backup file does not exist: ${e}`);await u(t,await b.readFile(e),`restore`)}function w(){return c()}function T(){return p}function E(){return s}async function D(){return await d()}const O={findChalkVar:a,getModuleLoaderFunction:e,getReactVar:o,getRequireFuncName:t,findTextComponent:m,findBoxComponent:i,clearCaches:n,globalReplace:f,showDiff:r};export{S as backupFile,v as findAllInstallations,w as getTweakccConfigDir,T as getTweakccConfigPath,E as getTweakccSystemPromptsDir,O as helpers,y as readContent,D as readTweakccConfig,C as restoreBackup,g as showInteractiveInstallationPicker,h as tryDetectInstallation,_ as writeContent};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{C as e,p as t}from"./config-C2GrLEMy.mjs";import n from"node:os";import r from"node:fs";import i from"node:path";import{execFileSync as a,execSync as o}from"node:child_process";import s from"node-lief";function c(e){try{if(r.statSync(e).size>2e5)return null;s.logging.disable();let n=s.parse(e);if(!n.symbols().some(e=>{let t=e.name;return t===`execv`||t===`_execv`}))return t(`resolveNixBinaryWrapper: no execv import found, not a Nix wrapper`),null;t(`resolveNixBinaryWrapper: execv import found, checking for Nix wrapper DOCSTRING`);let i=null;if(n.format===`ELF`){let e=n.sections().find(e=>e.name===`.rodata`);e&&(i=e.content)}else if(n.format===`MachO`){let e=n.getSegment(`__TEXT`);if(e){let t=e.getSection(`__cstring`);t&&(i=t.content)}}if(!i||i.length===0)return t(`resolveNixBinaryWrapper: could not read string section`),null;let a=i.toString(`utf-8`),o=a.match(/makeCWrapper\s+'(\/nix\/store\/[^']+)'/);if(o){let e=o[1];return t(`resolveNixBinaryWrapper: found wrapped executable via DOCSTRING: ${e}`),e}let c=a.match(/makeCWrapper\s+(\/nix\/store\/\S+)/);if(c){let e=c[1];return t(`resolveNixBinaryWrapper: found wrapped executable via unquoted DOCSTRING: ${e}`),e}let l=a.match(/\/nix\/store\/[^\0\n\r]+/g);if(l){for(let e of l)if(e.includes(`/bin/`))return t(`resolveNixBinaryWrapper: found wrapped executable via /bin/ heuristic: ${e}`),e}return t(`resolveNixBinaryWrapper: has execv but no Nix store paths found`),null}catch(e){return t(`resolveNixBinaryWrapper: error during detection:`,e),null}}const l=Buffer.from(`
|
|
2
|
+
---- Bun! ----
|
|
3
|
+
`);function u(e,t){return e.subarray(t.offset,t.offset+t.length)}function d(e,t){return{offset:e.readUInt32LE(t),length:e.readUInt32LE(t+4)}}function f(e){return e.endsWith(`/claude`)||e===`claude`||e.endsWith(`/claude.exe`)||e===`claude.exe`||e.endsWith(`/src/entrypoints/cli.js`)||e===`src/entrypoints/cli.js`}function p(e){let n=e%52==0,r=e%36==0;return n&&!r?52:r&&!n?36:n&&r?(t(`detectModuleStructSize: Ambiguous module list length ${e}, assuming new format`),52):(t(`detectModuleStructSize: Module list length ${e} doesn't cleanly divide by either struct size, assuming new format`),52)}function m(e,t,n,r){let i=u(e,t.modulesPtr),a=Math.floor(i.length/n);for(let t=0;t<a;t++){let a=g(i,t*n,n),o=r(a,u(e,a.name).toString(`utf-8`),t);if(o!==void 0)return o}}function h(e){let t=0,n=e.readBigUInt64LE(t);t+=8;let r=d(e,t);t+=8;let i=e.readUInt32LE(t);t+=4;let a=d(e,t);return t+=8,{byteCount:n,modulesPtr:r,entryPointId:i,compileExecArgvPtr:a,flags:e.readUInt32LE(t)}}function g(e,t,n){let r=t,i=d(e,r);r+=8;let a=d(e,r);r+=8;let o=d(e,r);r+=8;let s=d(e,r);r+=8;let c,l;n===52?(c=d(e,r),r+=8,l=d(e,r),r+=8):(c={offset:0,length:0},l={offset:0,length:0});let u=e.readUInt8(r);r+=1;let f=e.readUInt8(r);r+=1;let p=e.readUInt8(r);r+=1;let m=e.readUInt8(r);return{name:i,contents:a,sourcemap:o,bytecode:s,moduleInfo:c,bytecodeOriginPath:l,encoding:u,loader:f,moduleFormat:p,side:m}}function _(e){if(e.length<32+l.length)throw Error(`BUN data is too small to contain trailer and offsets`);let n=e.length-l.length,r=e.subarray(n);if(t(`parseBunDataBlob: Expected trailer: ${l.toString(`hex`)}`),t(`parseBunDataBlob: Got trailer: ${r.toString(`hex`)}`),!r.equals(l))throw Error(`BUN trailer bytes do not match trailer`);let i=e.length-32-l.length,a=h(e.subarray(i,i+32));return{bunOffsets:a,bunData:e,moduleStructSize:p(a.modulesPtr.length)}}function v(e){if(e.length<4)throw Error(`Section data too small`);t(`extractBunDataFromSection: sectionData.length=${e.length}`);let n=e.readUInt32LE(0),r=4+n,i=e.length>=8?Number(e.readBigUInt64LE(0)):0,a=8+i;t(`extractBunDataFromSection: u32 header would give size=${n}, expected total=${r}`),t(`extractBunDataFromSection: u64 header would give size=${i}, expected total=${a}`);let o,s;if(e.length>=8&&a<=e.length&&a>=e.length-4096)o=8,s=i,t(`extractBunDataFromSection: detected u64 header format (Bun >= 1.3.4)`);else if(r<=e.length&&r>=e.length-4096)o=4,s=n,t(`extractBunDataFromSection: detected u32 header format (Bun < 1.3.4)`);else throw Error(`Cannot determine section header format: sectionData.length=${e.length}, u64 would expect ${a}, u32 would expect ${r}`);t(`extractBunDataFromSection: bunDataSize from header=${s}`);let c=e.subarray(o,o+s);t(`extractBunDataFromSection: bunDataContent.length=${c.length}`);let{bunOffsets:l,bunData:u,moduleStructSize:d}=_(c);return{bunOffsets:l,bunData:u,sectionHeaderSize:o,moduleStructSize:d}}function y(e){try{let n=e.getSection(`.bun`);if(!n)return t(`extractBunDataFromELFSection: .bun section not found`),null;let r=n.content;if(r.length<8)return t(`extractBunDataFromELFSection: .bun section too small`),null;t(`extractBunDataFromELFSection: .bun section found, size=${r.length}`);let i=v(r);return t(`extractBunDataFromELFSection: successfully extracted data`),i}catch(e){return t(`extractBunDataFromELFSection: failed to extract:`,e),null}}function b(e){if(!e.hasOverlay)throw Error(`ELF binary has no overlay data`);let n=e.overlay;if(t(`extractBunDataFromELFOverlay: Overlay size=${n.length} bytes`),n.length<l.length+8+32)throw Error(`ELF overlay data is too small`);let r=n.readBigUInt64LE(n.length-8);if(t(`extractBunDataFromELFOverlay: Total byte count from tail=${r}`),r<4096n||r>2n**32n-1n)throw Error(`ELF total byte count is out of range: ${r}`);let i=n.length-8-l.length,a=n.subarray(i,n.length-8);if(t(`extractBunDataFromELFOverlay: Expected trailer: ${l.toString(`hex`)}`),t(`extractBunDataFromELFOverlay: Got trailer: ${a.toString(`hex`)}`),!a.equals(l))throw Error(`BUN trailer bytes do not match trailer`);let o=n.length-8-l.length-32,s=n.subarray(o,n.length-8-l.length),c=h(s);t(`extractBunDataFromELFOverlay: Offsets.byteCount=${c.byteCount}`);let u=typeof c.byteCount==`bigint`?c.byteCount:BigInt(c.byteCount);if(u>=r)throw Error(`ELF total byte count is out of range`);let d=8+l.length+32,f=n.length-d-Number(u),m=n.subarray(f,n.length-d);return t(`extractBunDataFromELFOverlay: Extracted ${m.length} bytes of data`),{bunOffsets:c,bunData:Buffer.concat([m,s,a]),moduleStructSize:p(c.modulesPtr.length)}}function x(e){let t=e.getSegment(`__BUN`);if(!t)throw Error(`__BUN segment not found`);let n=t.getSection(`__bun`);if(!n)throw Error(`__bun section not found`);return v(n.content)}function S(e){let t=e.sections().find(e=>e.name===`.bun`);if(!t)throw Error(`.bun section not found`);return v(t.content)}function C(){switch(process.platform){case`darwin`:return`MachO`;case`linux`:return`ELF`;case`win32`:return`PE`;default:return null}}function w(e){let t=C();if(t&&e.format!==t)throw Error(`Native binary format ${e.format} does not match ${process.platform} (${t})`)}function T(e,n){switch(t(`locateBundle: Binary format detected as ${e.format}`),w(e),e.format){case`MachO`:{let t=e,r=x(t);if(!r.sectionHeaderSize)throw Error(`sectionHeaderSize is required for Mach-O binaries`);let i=t.getSegment(`__BUN`).getSection(`__bun`);return{...r,offset:Number(i.fileOffset),length:i.content.length,write:(e,i)=>j(t,n,e,i,r.sectionHeaderSize)}}case`PE`:{let t=e,r=S(t);if(!r.sectionHeaderSize)throw Error(`sectionHeaderSize is required for PE binaries`);let i=t.sections().find(e=>e.name===`.bun`);return{...r,offset:Number(i.fileOffset),length:i.content.length,write:(e,i)=>M(t,n,e,i,r.sectionHeaderSize)}}case`ELF`:{let i=e,a=y(i);if(a){if(t(`locateBundle: Using new ELF .bun section format`),!a.sectionHeaderSize)throw Error(`sectionHeaderSize is required for ELF .bun section`);return{...a,offset:Number(i.getSection(`.bun`).fileOffset),length:i.getSection(`.bun`).content.length,write:(e,t)=>F(i,n,e,t,a.sectionHeaderSize)}}t(`locateBundle: Falling back to legacy ELF overlay format`);let o=b(i),s=r.statSync(n);return{...o,offset:s.size-i.overlay.length,length:i.overlay.length,write:(e,t)=>I(i,n,e,t)}}default:{let t=e;throw Error(`Unsupported binary format: ${t.format}`)}}}function E(e){let o=r.mkdtempSync(i.join(n.tmpdir(),`tweakcc-npm-`));try{t(`fetchNpmSource: Downloading @anthropic-ai/claude-code@${e}`),a(`npm`,[`pack`,`@anthropic-ai/claude-code@${e}`,`--pack-destination`,o],{stdio:`pipe`,timeout:3e4,cwd:o});let n=r.readdirSync(o).find(e=>e.endsWith(`.tgz`));if(!n)return t(`fetchNpmSource: No .tgz file found after npm pack`),null;a(`tar`,[`xzf`,i.join(o,n),`package/cli.js`],{stdio:`pipe`,timeout:3e4,cwd:o});let s=i.join(o,`package`,`cli.js`);if(!r.existsSync(s))return t(`fetchNpmSource: cli.js not found in extracted package`),null;let c=r.readFileSync(s);return t(`fetchNpmSource: Got cli.js, ${c.length} bytes`),c}catch(e){return t(`fetchNpmSource: Failed to fetch npm source:`,e),null}finally{try{r.rmSync(o,{recursive:!0,force:!0})}catch{}}}function D(e,n){try{s.logging.disable();let{bunOffsets:r,bunData:i,moduleStructSize:a}=T(s.parse(e),e);t(`extractClaudeJsFromNativeInstallation: Got bunData, size=${i.length} bytes, moduleStructSize=${a}`);let o=m(i,r,a,(e,n,r)=>{if(t(`extractClaudeJsFromNativeInstallation: Module ${r}: ${n}`),!f(n))return;let a=u(i,e.contents);return t(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${a.length}`),a.length>0?a:void 0});if(o){let e=o.subarray(0,64).toString(`utf8`);if(e.startsWith(`// @bun @bytecode`)&&!e.includes(`@bun-cjs`))if(t(`extractClaudeJsFromNativeInstallation: Extracted content is Bun bytecode — falling back to npm source`),n){let e=E(n);if(e)return t(`extractClaudeJsFromNativeInstallation: Using npm source (${e.length} bytes) instead of bytecode`),{data:e,clearBytecode:!0};t(`extractClaudeJsFromNativeInstallation: npm source fetch failed, returning bytecode content as-is`)}else t(`extractClaudeJsFromNativeInstallation: No version provided, cannot fetch npm source`);return{data:o,clearBytecode:!1}}return t(`extractClaudeJsFromNativeInstallation: claude module not found in any module`),{data:null,clearBytecode:!1,error:`claude module not found in any of the binary modules`}}catch(e){return t(`extractClaudeJsFromNativeInstallation: Error during extraction:`,e),{data:null,clearBytecode:!1,error:`extraction threw: ${e instanceof Error?e.message:String(e)}`}}}function O(e,t,n,r,i){let a=[],o=[];m(e,t,r,(t,s)=>{let c=u(e,t.name),l,d;n&&f(s)?(l=n,d=i?Buffer.alloc(0):u(e,t.bytecode)):(l=u(e,t.contents),d=u(e,t.bytecode));let p=u(e,t.sourcemap),m=u(e,t.moduleInfo),h=u(e,t.bytecodeOriginPath);o.push({name:c,contents:l,sourcemap:p,bytecode:d,moduleInfo:m,bytecodeOriginPath:h,encoding:t.encoding,loader:t.loader,moduleFormat:t.moduleFormat,side:t.side}),r===52?a.push(c,l,p,d,m,h):a.push(c,l,p,d)});let s=r===52?6:4,c=0,d=[];for(let e of a)d.push({offset:c,length:e.length}),c+=e.length+1;let p=c,h=o.length*r;c+=h;let g=u(e,t.compileExecArgvPtr),_=c,v=g.length;c+=v+1;let y=c;c+=32;let b=c;c+=l.length;let x=Buffer.allocUnsafe(c);x.fill(0);let S=0;for(let{offset:e,length:t}of d)t>0&&a[S].copy(x,e,0,t),x[e+t]=0,S++;v>0&&(g.copy(x,_,0,v),x[_+v]=0);for(let e=0;e<o.length;e++){let t=o[e],n=e*s,i={name:d[n],contents:d[n+1],sourcemap:d[n+2],bytecode:d[n+3],moduleInfo:r===52?d[n+4]:{offset:0,length:0},bytecodeOriginPath:r===52?d[n+5]:{offset:0,length:0},encoding:t.encoding,loader:t.loader,moduleFormat:t.moduleFormat,side:t.side},a=p+e*r;x.writeUInt32LE(i.name.offset,a),x.writeUInt32LE(i.name.length,a+4),a+=8,x.writeUInt32LE(i.contents.offset,a),x.writeUInt32LE(i.contents.length,a+4),a+=8,x.writeUInt32LE(i.sourcemap.offset,a),x.writeUInt32LE(i.sourcemap.length,a+4),a+=8,x.writeUInt32LE(i.bytecode.offset,a),x.writeUInt32LE(i.bytecode.length,a+4),a+=8,r===52&&(x.writeUInt32LE(i.moduleInfo.offset,a),x.writeUInt32LE(i.moduleInfo.length,a+4),a+=8,x.writeUInt32LE(i.bytecodeOriginPath.offset,a),x.writeUInt32LE(i.bytecodeOriginPath.length,a+4),a+=8),x.writeUInt8(i.encoding,a),x.writeUInt8(i.loader,a+1),x.writeUInt8(i.moduleFormat,a+2),x.writeUInt8(i.side,a+3)}let C={byteCount:y,modulesPtr:{offset:p,length:h},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:_,length:v},flags:t.flags},w=y,T=typeof C.byteCount==`bigint`?C.byteCount:BigInt(C.byteCount);return x.writeBigUInt64LE(T,w),w+=8,x.writeUInt32LE(C.modulesPtr.offset,w),x.writeUInt32LE(C.modulesPtr.length,w+4),w+=8,x.writeUInt32LE(C.entryPointId,w),w+=4,x.writeUInt32LE(C.compileExecArgvPtr.offset,w),x.writeUInt32LE(C.compileExecArgvPtr.length,w+4),w+=8,x.writeUInt32LE(C.flags,w),l.copy(x,b),x}function k(e,t,n,i=!0){let a=t+`.tmp`;if(e.write(a),i){let e=r.statSync(n);r.chmodSync(a,e.mode)}try{r.renameSync(a,t)}catch(e){try{r.existsSync(a)&&r.unlinkSync(a)}catch{}throw e instanceof Error&&`code`in e&&(e.code===`ETXTBSY`||e.code===`EBUSY`||e.code===`EPERM`)?Error(`Cannot update the Claude executable while it is running.
|
|
4
|
+
Please close all Claude instances and try again.`):e}}function A(e,t=8){let n=Buffer.allocUnsafe(t+e.length);return t===8?n.writeBigUInt64LE(BigInt(e.length),0):n.writeUInt32LE(e.length,0),e.copy(n,t),n}function j(n,r,i,a,c){try{t(`repackMachO: Has code signature: ${n.hasCodeSignature}`),n.hasCodeSignature&&(t(`repackMachO: Removing code signature...`),n.removeSignature());let l=n.getSegment(`__BUN`);if(!l)throw Error(`__BUN segment not found`);let u=l.getSection(`__bun`);if(!u)throw Error(`__bun section not found`);let d=A(i,c);t(`repackMachO: Original section size: ${u.size}`),t(`repackMachO: Original segment fileSize: ${l.fileSize}`),t(`repackMachO: Original segment virtualSize: ${l.virtualSize}`),t(`repackMachO: New data size: ${d.length}`),t(`repackMachO: Using header size: ${c}`);let f=d.length-Number(u.size);if(f>0){let e=n.header.cpuType===s.MachO.Header.CPU_TYPE.ARM64,r=e?16384:4096,i=Math.ceil(f/r)*r;t(`repackMachO: CPU type: ${e?`ARM64`:`x86_64`}`),t(`repackMachO: Page size: ${r} bytes`),t(`repackMachO: Need to expand by ${f} bytes`),t(`repackMachO: Rounding up to page-aligned: ${i} bytes`);let a=n.extendSegment(l,i);if(t(`repackMachO: extendSegment returned: ${a}`),!a)throw Error(`Failed to extend __BUN segment`);t(`repackMachO: Section size after extend: ${u.size}`),t(`repackMachO: Segment fileSize after extend: ${l.fileSize}`),t(`repackMachO: Segment virtualSize after extend: ${l.virtualSize}`)}u.content=d,u.size=BigInt(d.length),t(`repackMachO: Final section size: ${u.size}`),t(`repackMachO: Writing modified binary to ${a}...`),k(n,a,r);try{t(`repackMachO: Re-signing binary with ad-hoc signature...`),o(`codesign -s - -f "${a}"`,{stdio:e()?`inherit`:`ignore`}),t(`repackMachO: Code signing completed successfully`)}catch(e){console.warn(`Warning: Failed to re-sign binary. The binary may not run correctly on macOS:`,e)}t(`repackMachO: Write completed successfully`)}catch(e){throw console.error(`repackMachO failed:`,e),e}}function M(e,n,r,i,a){try{let o=e.sections().find(e=>e.name===`.bun`);if(!o)throw Error(`.bun section not found`);let s=A(r,a);t(`repackPE: Original section size: ${o.size}, virtual size: ${o.virtualSize}`),t(`repackPE: New data size: ${s.length}`),t(`repackPE: Using header size: ${a}`),o.content=s,o.virtualSize=BigInt(s.length),o.size=BigInt(s.length),t(`repackPE: Writing modified binary to ${i}...`),k(e,i,n,!1),t(`repackPE: Write completed successfully`)}catch(e){throw console.error(`repackPE failed:`,e),e}}const N=16384;function P(e,t){return(e+t-1n)/t*t}function F(e,n,r,i,a){try{let o=e.getSection(`.bun`);if(!o)throw Error(`.bun section not found`);let s=e.segments().find(e=>e.type===`LOAD`&&(e.flags&2)!=0);if(!s)throw Error(`No writable ELF PT_LOAD segment found`);let c=A(r,a),l=o.virtualAddress,u=Buffer.alloc(8);u.writeBigUInt64LE(l);let d=null,f=s.content,p=s.virtualAddress,m=P(p,BigInt(N)),h=p+BigInt(f.length)-8n;for(let e=m;e<=h;e+=BigInt(N)){let t=Number(e-p);if(f.subarray(t,t+8).equals(u)){d=e;break}}if(d===null)throw Error(`Could not find original BUN_COMPILED location in binary (searched for 0x${l.toString(16)})`);let g=e.pageSize(),_=BigInt(c.length),v=P(_,g),y=P(e.nextVirtualAddress(),g),b=y-s.virtualAddress,x=s.fileOffset+b,S=s.fileOffset+s.fileSize,C=x+v-S;if(C<0n)throw Error(`New .bun location overlaps existing writable ELF segment`);if(t(`repackELFSection: moving .bun to offset=0x${x.toString(16)}, vaddr=0x${y.toString(16)}, size=0x${_.toString(16)}`),C>0n&&!e.extend(s,C))throw Error(`Failed to extend writable ELF PT_LOAD segment`);o.fileOffset=x,o.virtualAddress=y,o.content=c,o.size=_;let w=Buffer.alloc(8);w.writeBigUInt64LE(y),e.patchAddress(d,w),t(`repackELFSection: Patched BUN_COMPILED at vaddr 0x${d.toString(16)} -> 0x${y.toString(16)}`),k(e,i,n),t(`repackELFSection: Write completed successfully`)}catch(e){throw console.error(`repackELFSection failed:`,e),e}}function I(e,n,r,i){try{let a=Buffer.allocUnsafe(r.length+8);r.copy(a,0),a.writeBigUInt64LE(BigInt(r.length),r.length),t(`repackELFOverlay: Setting overlay data (${a.length} bytes)`),e.overlay=a,t(`repackELFOverlay: Writing modified binary to ${i}...`),k(e,i,n),t(`repackELFOverlay: Write completed successfully`)}catch(e){throw console.error(`repackELFOverlay failed:`,e),e}}function L(e,t,n,r){s.logging.disable();let i=T(s.parse(e),e),a=O(i.bunData,i.bunOffsets,t,i.moduleStructSize,r);i.write(a,n)}export{D as extractClaudeJsFromNativeInstallation,L as repackNativeInstallation,c as resolveNixBinaryWrapper};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tweakcc-fixed",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Maintained fork of tweakcc — patch an installed Claude Code (npm or native binary) with curated system-prompt overrides, system-reminder overrides, and fork-only patches. Pairs with skrabe/lobotomized-claude-code.",
|
|
6
6
|
"main": "dist/lib/index.mjs",
|
|
@@ -95,7 +95,8 @@
|
|
|
95
95
|
"build:dev": "node tools/generateIdentifierUnion.mjs && tsdown --dts src/index.tsx src/lib/index.ts",
|
|
96
96
|
"watch": "tsdown --watch --dts src/index.tsx src/lib/index.ts",
|
|
97
97
|
"start": "node dist/index.mjs",
|
|
98
|
-
"
|
|
98
|
+
"prelint": "node tools/generateIdentifierUnion.mjs",
|
|
99
|
+
"lint": "tsc --noEmit && eslint src tools",
|
|
99
100
|
"test": "vitest run",
|
|
100
101
|
"test:dev": "vitest",
|
|
101
102
|
"pretest": "node tools/generateIdentifierUnion.mjs",
|