any-buddy 1.0.7 → 1.0.8
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/lib/preflight.mjs +35 -14
- package/package.json +1 -1
package/lib/preflight.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { platform } from 'os';
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { ORIGINAL_SALT } from './constants.mjs';
|
|
6
6
|
import { findClaudeBinary, verifySalt } from './patcher.mjs';
|
|
7
|
-
import { getClaudeUserId } from './config.mjs';
|
|
7
|
+
import { getClaudeUserId, loadPetConfig } from './config.mjs';
|
|
8
8
|
|
|
9
9
|
const ISSUE_URL = 'https://github.com/cpaczek/any-buddy/issues';
|
|
10
10
|
|
|
@@ -60,22 +60,43 @@ export function runPreflight({ requireBinary = true } = {}) {
|
|
|
60
60
|
}
|
|
61
61
|
} catch { /* ignore */ }
|
|
62
62
|
|
|
63
|
-
// Check that
|
|
63
|
+
// Check that a known salt exists in the binary (original or previously patched)
|
|
64
64
|
try {
|
|
65
|
-
const
|
|
66
|
-
saltCount =
|
|
65
|
+
const origResult = verifySalt(binaryPath, ORIGINAL_SALT);
|
|
66
|
+
saltCount = origResult.found;
|
|
67
67
|
|
|
68
68
|
if (saltCount === 0) {
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
// Not original — check if it's already patched by any-buddy
|
|
70
|
+
const petConfig = loadPetConfig();
|
|
71
|
+
if (petConfig?.salt) {
|
|
72
|
+
const patchedResult = verifySalt(binaryPath, petConfig.salt);
|
|
73
|
+
if (patchedResult.found >= 2) {
|
|
74
|
+
// Already patched by us — that's fine, we can re-patch
|
|
75
|
+
saltCount = patchedResult.found;
|
|
76
|
+
warnings.push(
|
|
77
|
+
`Binary is already patched with a custom salt from a previous run.\n` +
|
|
78
|
+
' Re-patching will replace it with your new selection.'
|
|
79
|
+
);
|
|
80
|
+
} else {
|
|
81
|
+
errors.push(
|
|
82
|
+
`Neither the original salt nor your saved salt were found in ${binaryPath}.\n` +
|
|
83
|
+
' The binary may have been updated or patched by another tool.\n' +
|
|
84
|
+
' Try: any-buddy restore\n' +
|
|
85
|
+
`\n Platform: ${platform()}, binary: ${binaryPath}` +
|
|
86
|
+
`\n Please report this at: ${ISSUE_URL}`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
errors.push(
|
|
91
|
+
`Salt "${ORIGINAL_SALT}" not found in ${binaryPath}.\n` +
|
|
92
|
+
' Possible reasons:\n' +
|
|
93
|
+
' - Binary was patched by another tool\n' +
|
|
94
|
+
' - This binary format doesn\'t contain the salt as a plain string\n' +
|
|
95
|
+
' - Claude Code changed the salt in a new version\n' +
|
|
96
|
+
`\n Platform: ${platform()}, binary: ${binaryPath}` +
|
|
97
|
+
`\n Please report this at: ${ISSUE_URL}`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
79
100
|
} else if (saltCount < 2) {
|
|
80
101
|
warnings.push(
|
|
81
102
|
`Salt found only ${saltCount} time(s) in binary (expected 3 on Linux).\n` +
|