vouchington-tooling 0.61.0 → 0.61.1

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.
@@ -3,6 +3,8 @@ export declare function isRecord(value: unknown): value is Record<string, unknow
3
3
  export declare function hookToolInput(payload: HookPayload): Record<string, unknown> | undefined;
4
4
  export declare function extractToolCommand(payload: HookPayload): string;
5
5
  export declare function hookToolName(payload: HookPayload): string;
6
+ /** A numeric `exit_code` from the response shapes that carry one; undefined otherwise. */
7
+ export declare function hookToolExitCode(payload: HookPayload): number | undefined;
6
8
  export declare function hookSessionId(payload: HookPayload): string;
7
9
  export declare function hookFilePath(payload: HookPayload): string;
8
10
  export declare function hookCwd(payload: HookPayload, fallback?: string): string;
@@ -26,6 +26,14 @@ function firstString(values) {
26
26
  export function hookToolName(payload) {
27
27
  return firstString([payload.tool_name, payload.toolName]);
28
28
  }
29
+ /** A numeric `exit_code` from the response shapes that carry one; undefined otherwise. */
30
+ export function hookToolExitCode(payload) {
31
+ for (const response of [payload.tool_response, payload.toolResponse, payload.toolResult]) {
32
+ if (isRecord(response) && typeof response.exit_code === 'number')
33
+ return response.exit_code;
34
+ }
35
+ return undefined;
36
+ }
29
37
  export function hookSessionId(payload) {
30
38
  return firstString([payload.session_id, payload.sessionId, payload.conversation_id]);
31
39
  }
package/dist/tmux/cli.mjs CHANGED
@@ -2,7 +2,7 @@ import { readFileSync } from 'node:fs';
2
2
  import { runScript } from "../cli/commands/spawn-script.mjs";
3
3
  import { packageScriptPath } from "../cli/script-path.mjs";
4
4
  import { TMUX_USAGE } from "./cli-shared.mjs";
5
- import { parseHookPayload } from "./hook-payload.mjs";
5
+ import { parseHookPayload } from "../command-policy/hook/harness.mjs";
6
6
  import { renderPostToolReminder } from "./reminder-post-tool.mjs";
7
7
  import { runUp } from "./up.mjs";
8
8
  export { TMUX_USAGE };
@@ -1,4 +1,4 @@
1
- import { type HookPayload } from './hook-payload.mts';
1
+ import type { HookPayload } from '../command-policy/types.mts';
2
2
  export type PaneTitleSpawnResult = {
3
3
  error?: NodeJS.ErrnoException | null | undefined;
4
4
  status: number | null;
@@ -1,6 +1,6 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { packageScriptPath } from "../cli/script-path.mjs";
3
- import { extractToolCommand, hookToolName, toolExitCode, } from "./hook-payload.mjs";
3
+ import { extractToolCommand, hookToolExitCode, hookToolName } from "../command-policy/payload.mjs";
4
4
  const PR_CREATE_COMMAND_PATTERN = /(^|[;&|])\s*gh\s+pr\s+create(\s|$)/;
5
5
  const GIT_PUSH_COMMAND_PATTERN = /(^|[;&|])\s*git\s+push(\s|$)/;
6
6
  const RESET_WORKTREE_PATTERN = /(^|[;&|])\s*(?:\S*\/)?reset-worktree(?:\.sh)?(?:\s+(--help|-h))?(?=[;&|]|\s|$)/g;
@@ -64,7 +64,7 @@ export function renderPostToolReminder(payload, options = {}) {
64
64
  if (!SHELL_TOOLS.has(toolName))
65
65
  return null;
66
66
  const command = extractToolCommand(payload);
67
- const exitCode = toolExitCode(payload);
67
+ const exitCode = hookToolExitCode(payload);
68
68
  if (command === '' || (exitCode !== undefined && exitCode !== 0))
69
69
  return null;
70
70
  if (PR_CREATE_COMMAND_PATTERN.test(command)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vouchington-tooling",
3
- "version": "0.61.0",
3
+ "version": "0.61.1",
4
4
  "description": "Vouchington CLI and extractable tooling libraries.",
5
5
  "homepage": "https://github.com/vouchington/vouchington-tooling/tree/main/packages/vouchington-tooling#readme",
6
6
  "bugs": {
@@ -1,8 +0,0 @@
1
- export type HookPayload = Record<string, unknown>;
2
- /** Tool name across Claude-compatible (`tool_name`), camelCase and bare (`name`) payloads. */
3
- export declare function hookToolName(payload: HookPayload): string;
4
- /** The shell command a tool call ran, or '' when the payload carries none. */
5
- export declare function extractToolCommand(payload: HookPayload): string;
6
- /** A numeric `exit_code` from the response shapes that carry one; undefined otherwise. */
7
- export declare function toolExitCode(payload: HookPayload): number | undefined;
8
- export declare function parseHookPayload(raw: string): HookPayload;
@@ -1,39 +0,0 @@
1
- function isRecord(value) {
2
- return typeof value === 'object' && value !== null && !Array.isArray(value);
3
- }
4
- /** Tool name across Claude-compatible (`tool_name`), camelCase and bare (`name`) payloads. */
5
- export function hookToolName(payload) {
6
- for (const key of ['tool_name', 'toolName', 'name']) {
7
- const value = payload[key];
8
- if (typeof value === 'string')
9
- return value;
10
- }
11
- return '';
12
- }
13
- /** The shell command a tool call ran, or '' when the payload carries none. */
14
- export function extractToolCommand(payload) {
15
- for (const key of ['tool_input', 'toolInput', 'input']) {
16
- const input = payload[key];
17
- if (isRecord(input) && typeof input.command === 'string')
18
- return input.command;
19
- }
20
- return typeof payload.command === 'string' ? payload.command : '';
21
- }
22
- /** A numeric `exit_code` from the response shapes that carry one; undefined otherwise. */
23
- export function toolExitCode(payload) {
24
- for (const key of ['tool_response', 'toolResponse', 'toolResult']) {
25
- const response = payload[key];
26
- if (isRecord(response) && typeof response.exit_code === 'number')
27
- return response.exit_code;
28
- }
29
- return undefined;
30
- }
31
- export function parseHookPayload(raw) {
32
- try {
33
- const parsed = JSON.parse(raw);
34
- return isRecord(parsed) ? parsed : {};
35
- }
36
- catch {
37
- return {};
38
- }
39
- }