@birdybeep/cli 0.3.0 → 0.4.0

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.cjs CHANGED
@@ -575,12 +575,29 @@ function withTimeout(promise, ms, fallback) {
575
575
  function isHarnessName(value) {
576
576
  return value === "claude" || value === "codex" || value === "opencode" || value === "cursor" || value === "copilot";
577
577
  }
578
+ function resolveHookHarness(harness, payload) {
579
+ return harness === "claude" && (0, import_cursor3.isCursorHookPayload)(payload) ? "cursor" : harness;
580
+ }
581
+ function recognizesPayload(harness, payload) {
582
+ if (harness === "claude") return (0, import_claude_code3.isClaudeCodeHookPayload)(payload);
583
+ if (harness === "cursor") return (0, import_cursor3.isCursorHookEventName)(asRecord(payload)["hook_event_name"]);
584
+ return true;
585
+ }
586
+ function asRecord(value) {
587
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
588
+ }
589
+ function describeEventName(payload) {
590
+ const name = asRecord(payload)["hook_event_name"];
591
+ if (typeof name !== "string") return "(absent)";
592
+ return JSON.stringify(name.length > 64 ? `${name.slice(0, 63)}\u2026` : name);
593
+ }
578
594
  function runHookCommand(harness, payload, sender, copilotEventName) {
579
- if (harness === "copilot") {
595
+ const handler = resolveHookHarness(harness, payload);
596
+ if (handler === "copilot") {
580
597
  if (copilotEventName === void 0) return Promise.resolve({ outcome: "skipped" });
581
598
  return (0, import_copilot3.runCopilotHook)(copilotEventName, payload, { sender });
582
599
  }
583
- return RUNNERS[harness](payload, { sender });
600
+ return RUNNERS[handler](payload, { sender });
584
601
  }
585
602
  function readStdinDefault() {
586
603
  return new Promise((resolve) => {
@@ -687,15 +704,23 @@ function createHookCommand(deps = {}) {
687
704
  return EXIT.OK;
688
705
  }
689
706
  const sender = makeSender(resolveApiUrl());
707
+ const handler = resolveHookHarness(harness, payload);
690
708
  const result = await runHookCommand(harness, payload, sender, copilotEventName);
691
709
  ctx.io.result({
692
- harness,
710
+ harness: handler,
711
+ ...handler !== harness ? { routedFrom: harness } : {},
693
712
  ...copilotEventName !== void 0 ? { event: copilotEventName } : {},
694
713
  outcome: result.outcome,
695
714
  eventType: result.eventType,
696
715
  ...result.send?.decision ? { decision: result.send.decision } : {},
697
716
  ...result.send?.status !== void 0 ? { status: result.send.status } : {}
698
717
  });
718
+ if (result.outcome === "skipped" && !recognizesPayload(handler, payload)) {
719
+ ctx.io.errline(
720
+ `birdybeep hook ${harness}: hook_event_name ${describeEventName(payload)} is not a ${handler} hook event \u2014 nothing was sent. Check which tool is running this hook.`
721
+ );
722
+ return EXIT.ERROR;
723
+ }
699
724
  return EXIT.OK;
700
725
  }
701
726
  };
@@ -828,7 +853,7 @@ async function pairTokenPoll(apiUrl, deviceCode, fetchImpl, machineFingerprint,
828
853
  }
829
854
 
830
855
  // src/version.ts
831
- var CLI_VERSION = "0.3.0".length > 0 ? "0.3.0" : "0.0.0";
856
+ var CLI_VERSION = "0.4.0".length > 0 ? "0.4.0" : "0.0.0";
832
857
 
833
858
  // src/commands/pair.ts
834
859
  var DEFAULT_POLL_INTERVAL_MS = 2e3;