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.
Files changed (2) hide show
  1. package/lib/preflight.mjs +35 -14
  2. 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 the salt exists in the binary
63
+ // Check that a known salt exists in the binary (original or previously patched)
64
64
  try {
65
- const result = verifySalt(binaryPath, ORIGINAL_SALT);
66
- saltCount = result.found;
65
+ const origResult = verifySalt(binaryPath, ORIGINAL_SALT);
66
+ saltCount = origResult.found;
67
67
 
68
68
  if (saltCount === 0) {
69
- // Check if it might already be patched with a different salt
70
- errors.push(
71
- `Salt "${ORIGINAL_SALT}" not found in ${binaryPath}.\n` +
72
- ' Possible reasons:\n' +
73
- ' - Binary is already patched with a custom salt (run `any-buddy restore` first)\n' +
74
- ' - This binary format doesn\'t contain the salt as a plain string\n' +
75
- ' - Claude Code changed the salt in a new version\n' +
76
- `\n Platform: ${platform()}, binary: ${binaryPath}` +
77
- `\n Please report this at: ${ISSUE_URL}`
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` +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "any-buddy",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Pick any Claude Code companion pet you want",
5
5
  "type": "module",
6
6
  "bin": {