any-buddy 1.0.3 → 1.0.4

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 CHANGED
@@ -85,6 +85,9 @@ claude-code-any-buddy apply --silent
85
85
  # Restore original pet
86
86
  claude-code-any-buddy restore
87
87
 
88
+ # Delete companion so Claude Code re-hatches a fresh one on next /buddy
89
+ claude-code-any-buddy rehatch
90
+
88
91
  # Non-interactive with flags (skip prompts you already know the answer to)
89
92
  claude-code-any-buddy --species dragon --rarity legendary --eye '✦' --hat wizard --name Draco --yes
90
93
  ```
package/bin/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { runInteractive, runPreview, runCurrent, runApply, runRestore } from '../lib/tui.mjs';
3
+ import { runInteractive, runPreview, runCurrent, runApply, runRestore, runRehatch } from '../lib/tui.mjs';
4
4
 
5
5
  function parseArgs(argv) {
6
6
  const args = argv.slice(2);
@@ -43,6 +43,9 @@ try {
43
43
  case 'restore':
44
44
  await runRestore();
45
45
  break;
46
+ case 'rehatch':
47
+ await runRehatch();
48
+ break;
46
49
  case 'help':
47
50
  printHelp();
48
51
  break;
@@ -78,6 +81,7 @@ Usage:
78
81
  claude-code-any-buddy current Show your current pet
79
82
  claude-code-any-buddy apply [--silent] Re-apply saved pet after update
80
83
  claude-code-any-buddy restore Restore original pet
84
+ claude-code-any-buddy rehatch Delete companion to re-hatch via /buddy
81
85
 
82
86
  Options:
83
87
  -s, --species <name> Species (duck, goose, blob, cat, dragon, octopus, owl,
package/lib/config.mjs CHANGED
@@ -104,6 +104,17 @@ export function setCompanionPersonality(personality) {
104
104
  writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
105
105
  }
106
106
 
107
+ // Delete the companion from ~/.claude.json so Claude Code re-hatches on next /buddy
108
+ export function deleteCompanion() {
109
+ const configPath = getClaudeConfigPath();
110
+ if (!existsSync(configPath)) return false;
111
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'));
112
+ if (!config.companion) return false;
113
+ delete config.companion;
114
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
115
+ return true;
116
+ }
117
+
107
118
  // Read or write Claude Code's settings.json for hooks
108
119
  const SETTINGS_PATH = join(homedir(), '.claude', 'settings.json');
109
120
 
package/lib/tui.mjs CHANGED
@@ -5,7 +5,7 @@ import { roll } from './generation.mjs';
5
5
  import { renderSprite, renderFace } from './sprites.mjs';
6
6
  import { findSalt } from './finder.mjs';
7
7
  import { findClaudeBinary, getCurrentSalt, patchBinary, verifySalt, restoreBinary, isClaudeRunning } from './patcher.mjs';
8
- import { getClaudeUserId, savePetConfig, loadPetConfig, isHookInstalled, installHook, removeHook, getCompanionName, renameCompanion, getCompanionPersonality, setCompanionPersonality } from './config.mjs';
8
+ import { getClaudeUserId, savePetConfig, loadPetConfig, isHookInstalled, installHook, removeHook, getCompanionName, renameCompanion, getCompanionPersonality, setCompanionPersonality, deleteCompanion } from './config.mjs';
9
9
  import { DEFAULT_PERSONALITIES } from './personalities.mjs';
10
10
 
11
11
  const RARITY_CHALK = {
@@ -180,6 +180,37 @@ export async function runRestore() {
180
180
  console.log();
181
181
  }
182
182
 
183
+ export async function runRehatch() {
184
+ banner();
185
+
186
+ const name = getCompanionName();
187
+ if (!name) {
188
+ console.log(chalk.dim(' No companion found — nothing to delete.\n'));
189
+ return;
190
+ }
191
+
192
+ const personality = getCompanionPersonality();
193
+ console.log(chalk.dim(` Current companion: "${name}"`));
194
+ if (personality) {
195
+ console.log(chalk.dim(` Personality: "${personality}"`));
196
+ }
197
+ console.log();
198
+
199
+ const proceed = await confirm({
200
+ message: `Delete "${name}" so Claude Code generates a fresh companion on next /buddy?`,
201
+ default: false,
202
+ });
203
+
204
+ if (!proceed) {
205
+ console.log(chalk.dim('\n Cancelled.\n'));
206
+ return;
207
+ }
208
+
209
+ deleteCompanion();
210
+ console.log(chalk.green(`\n Companion "${name}" deleted.`));
211
+ console.log(chalk.dim(' Run /buddy in Claude Code to hatch a new one.\n'));
212
+ }
213
+
183
214
  export async function runInteractive(flags = {}) {
184
215
  banner();
185
216
 
@@ -352,8 +383,10 @@ export async function runInteractive(flags = {}) {
352
383
  // ─── Rename & Personality ───
353
384
  const currentName = getCompanionName();
354
385
  const currentPersonality = getCompanionPersonality();
386
+ const hasCompanion = !!(currentName && currentPersonality);
355
387
 
356
- if (currentName) {
388
+ if (hasCompanion) {
389
+ // ── Name ──
357
390
  const newName = flags.name ?? await input({
358
391
  message: `Rename your companion? (current: "${currentName}", leave blank to keep)`,
359
392
  default: '',
@@ -367,14 +400,10 @@ export async function runInteractive(flags = {}) {
367
400
  console.log(chalk.yellow(` Could not rename: ${err.message}`));
368
401
  }
369
402
  }
370
- } else if (flags.name) {
371
- console.log(chalk.dim(' No companion hatched yet — name will be set when you run /buddy'));
372
- }
373
403
 
374
- if (currentPersonality) {
404
+ // ── Personality ──
375
405
  console.log(chalk.dim(`\n Current personality: "${currentPersonality}"`));
376
406
 
377
- // Determine the species — use the desired species from the selection above
378
407
  const selectedSpecies = desired.species;
379
408
  const speciesDefault = DEFAULT_PERSONALITIES[selectedSpecies] || null;
380
409
 
@@ -407,8 +436,13 @@ export async function runInteractive(flags = {}) {
407
436
  console.log(chalk.yellow(` Could not update personality: ${err.message}`));
408
437
  }
409
438
  }
410
- } else if (flags.personality) {
411
- console.log(chalk.dim(' No companion hatched yet — personality will be set when you run /buddy'));
439
+ } else {
440
+ console.log(chalk.dim('\n No companion hatched yet — the visual patch has been applied.'));
441
+ console.log(chalk.dim(' Run /buddy in Claude Code to hatch your companion and get a name & personality.'));
442
+ console.log(chalk.dim(' Then run any-buddy again to customize the name and personality.'));
443
+ if (flags.name || flags.personality) {
444
+ console.log(chalk.yellow(' --name and --personality are ignored until after hatching.'));
445
+ }
412
446
  }
413
447
 
414
448
  if (running) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "any-buddy",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Pick any Claude Code companion pet you want",
5
5
  "type": "module",
6
6
  "bin": {