jettypod 4.4.55 → 4.4.56

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.
@@ -11,14 +11,40 @@
11
11
  const fs = require('fs');
12
12
  const path = require('path');
13
13
 
14
+ // Debug mode: set GUARDRAILS_DEBUG=1 to enable verbose logging
15
+ const DEBUG = process.env.GUARDRAILS_DEBUG === '1';
16
+
17
+ /**
18
+ * Structured debug logger - outputs to stderr to not interfere with JSON response
19
+ */
20
+ function debug(category, data) {
21
+ if (!DEBUG) return;
22
+ const timestamp = new Date().toISOString();
23
+ const logEntry = { timestamp, category, ...data };
24
+ console.error(`[guardrails] ${JSON.stringify(logEntry)}`);
25
+ }
26
+
14
27
  // Read hook input from stdin
15
28
  let input = '';
16
29
  process.stdin.on('data', chunk => input += chunk);
17
30
  process.stdin.on('end', () => {
18
31
  try {
19
32
  const hookInput = JSON.parse(input);
33
+ debug('input', {
34
+ tool: hookInput.tool_name,
35
+ cwd: hookInput.cwd,
36
+ active_worktree: hookInput.active_worktree_path,
37
+ branch: hookInput.current_branch
38
+ });
39
+
20
40
  const result = evaluateRequest(hookInput);
21
41
 
42
+ debug('decision', {
43
+ tool: hookInput.tool_name,
44
+ allowed: result.allowed,
45
+ message: result.message || null
46
+ });
47
+
22
48
  if (result.allowed) {
23
49
  allow();
24
50
  } else {
@@ -26,6 +52,7 @@ process.stdin.on('end', () => {
26
52
  }
27
53
  } catch (err) {
28
54
  // On parse error, allow (fail open)
55
+ debug('error', { type: 'parse', message: err.message });
29
56
  console.error('Hook error:', err.message);
30
57
  allow();
31
58
  }
@@ -159,6 +186,7 @@ function findDatabasePath(cwd) {
159
186
  function getActiveWorktreePathFromDB(cwd) {
160
187
  const dbPath = findDatabasePath(cwd);
161
188
  if (!dbPath) {
189
+ debug('db_lookup', { status: 'no_db_found', cwd });
162
190
  return null;
163
191
  }
164
192
 
@@ -170,8 +198,11 @@ function getActiveWorktreePathFromDB(cwd) {
170
198
  `SELECT worktree_path FROM worktrees WHERE status = 'active' LIMIT 1`
171
199
  ).get();
172
200
  db.close();
173
- return row ? row.worktree_path : null;
201
+ const result = row ? row.worktree_path : null;
202
+ debug('db_lookup', { status: 'success', method: 'better-sqlite3', worktree: result });
203
+ return result;
174
204
  } catch (err) {
205
+ debug('db_lookup', { status: 'fallback', reason: err.message });
175
206
  // Fall back to CLI
176
207
  const { spawnSync } = require('child_process');
177
208
  const result = spawnSync('sqlite3', [
@@ -180,9 +211,12 @@ function getActiveWorktreePathFromDB(cwd) {
180
211
  ], { encoding: 'utf-8' });
181
212
 
182
213
  if (result.error || result.status !== 0) {
214
+ debug('db_lookup', { status: 'cli_failed', error: result.error?.message || 'non-zero exit' });
183
215
  return null;
184
216
  }
185
- return result.stdout.trim() || null;
217
+ const worktree = result.stdout.trim() || null;
218
+ debug('db_lookup', { status: 'success', method: 'sqlite3-cli', worktree });
219
+ return worktree;
186
220
  }
187
221
  }
188
222
 
@@ -197,6 +231,13 @@ function evaluateWriteOperation(filePath, inputWorktreePath, cwd) {
197
231
  const normalizedPath = path.resolve(cwd || '.', filePath);
198
232
  const normalizedWorktree = activeWorktreePath ? path.resolve(cwd || '.', activeWorktreePath) : null;
199
233
 
234
+ debug('write_eval', {
235
+ filePath,
236
+ normalizedPath,
237
+ activeWorktreePath,
238
+ normalizedWorktree
239
+ });
240
+
200
241
  // BLOCKED: Protected files (skills, hooks)
201
242
  const protectedPatterns = [
202
243
  /\.claude\/skills\//i,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jettypod",
3
- "version": "4.4.55",
3
+ "version": "4.4.56",
4
4
  "description": "AI-powered development workflow manager with TDD, BDD, and automatic test generation",
5
5
  "main": "jettypod.js",
6
6
  "bin": {