@mutagent/cli 0.1.132 → 0.1.133

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/dist/bin/cli.js CHANGED
@@ -11346,6 +11346,9 @@ async function handlePostToolUseFailure() {
11346
11346
  // src/commands/hooks/install.ts
11347
11347
  import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, existsSync as existsSync14, mkdirSync as mkdirSync5 } from "fs";
11348
11348
  import { join as join9 } from "path";
11349
+ var V1_MIGRATIONS = {
11350
+ Stop: ["mutagent hooks claude-code session-end"]
11351
+ };
11349
11352
  var MUTAGENT_HOOKS = {
11350
11353
  SessionStart: [{ matcher: "startup", hooks: [{ type: "command", command: "mutagent hooks claude-code session-start" }] }],
11351
11354
  PreToolUse: [{ hooks: [{ type: "command", command: "mutagent hooks claude-code pre-tool-use" }] }],
@@ -11362,6 +11365,32 @@ var MUTAGENT_HOOKS = {
11362
11365
  function hasCommand(matchers, command) {
11363
11366
  return matchers.some((m) => m.hooks.some((h) => h.command === command));
11364
11367
  }
11368
+ function migrateV1Hooks(settings) {
11369
+ const migrated = [];
11370
+ if (!settings.hooks)
11371
+ return migrated;
11372
+ for (const [event, commandsToRemove] of Object.entries(V1_MIGRATIONS)) {
11373
+ const matchers = settings.hooks[event];
11374
+ if (!matchers)
11375
+ continue;
11376
+ const filtered = matchers.map((matcher) => {
11377
+ const keptHooks = matcher.hooks.filter((h) => {
11378
+ if (commandsToRemove.includes(h.command)) {
11379
+ migrated.push({ event, command: h.command });
11380
+ return false;
11381
+ }
11382
+ return true;
11383
+ });
11384
+ return keptHooks.length > 0 ? { ...matcher, hooks: keptHooks } : null;
11385
+ }).filter(Boolean);
11386
+ if (filtered.length === 0) {
11387
+ delete settings.hooks[event];
11388
+ } else {
11389
+ settings.hooks[event] = filtered;
11390
+ }
11391
+ }
11392
+ return migrated;
11393
+ }
11365
11394
  function installHooks(cwd) {
11366
11395
  const claudeDir = join9(cwd, ".claude");
11367
11396
  const settingsPath = join9(claudeDir, "settings.local.json");
@@ -11376,6 +11405,7 @@ function installHooks(cwd) {
11376
11405
  }
11377
11406
  const added = [];
11378
11407
  const alreadyPresent = [];
11408
+ const migrated = migrateV1Hooks(settings);
11379
11409
  for (const [event, newMatchers] of Object.entries(MUTAGENT_HOOKS)) {
11380
11410
  if (!newMatchers)
11381
11411
  continue;
@@ -11397,14 +11427,14 @@ function installHooks(cwd) {
11397
11427
  }
11398
11428
  }
11399
11429
  }
11400
- if (added.length > 0) {
11430
+ if (added.length > 0 || migrated.length > 0) {
11401
11431
  if (!existsSync14(claudeDir)) {
11402
11432
  mkdirSync5(claudeDir, { recursive: true });
11403
11433
  }
11404
11434
  writeFileSync7(settingsPath, JSON.stringify(settings, null, 2) + `
11405
11435
  `, "utf-8");
11406
11436
  }
11407
- return { settingsPath, existed, added, alreadyPresent };
11437
+ return { settingsPath, existed, added, alreadyPresent, migrated };
11408
11438
  }
11409
11439
 
11410
11440
  // src/commands/hooks/index.ts
@@ -11440,6 +11470,10 @@ times is safe.
11440
11470
  `).action((opts) => {
11441
11471
  const targetDir = opts.cwd ?? process.cwd();
11442
11472
  const result = installHooks(targetDir);
11473
+ for (const { event, command } of result.migrated) {
11474
+ process.stderr.write(`[mutagent hooks install] ⚠️ Migrated v1 hook: removed '${event} → ${command}' (v2 wires this as 'SessionEnd')
11475
+ `);
11476
+ }
11443
11477
  if (result.added.length === 0 && result.alreadyPresent.length === 0) {
11444
11478
  process.stdout.write(JSON.stringify({
11445
11479
  success: true,
@@ -11816,5 +11850,5 @@ if (isInteractive && !isSkillCommand) {
11816
11850
  }
11817
11851
  program.parse();
11818
11852
 
11819
- //# debugId=599B825650E0CCDF64756E2164756E21
11853
+ //# debugId=A1F82C134C46598C64756E2164756E21
11820
11854
  //# sourceMappingURL=cli.js.map