Commit 9172f59b12aa

Vincent Demeester <vincent@sbr.pm>
2026-02-02 12:05:12
feat(pi): add skills config and improve hooks extension
- Configure skills path to load Claude Code skills - Add quietStartup for cleaner experience - Cache binary existence checks for performance - Use node:child_process import - Update README with skills configuration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent eabf513
Changed files (3)
dots
dots/.config/pi/agent/extensions/claude-hooks.ts
@@ -9,14 +9,20 @@
  * - session_shutdown -> claude-hooks-save-session
  * - tool_call -> claude-hooks-validate-git-push (PreToolUse equivalent)
  * - tool_result -> claude-hooks-capture-tool-output, claude-hooks-update-terminal-title
+ *
+ * Requirements:
+ * - claude-hooks-* binaries must be in PATH (installed via home-manager)
  */
 
 import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
-import { execSync, spawn } from "child_process";
+import { execSync, spawn } from "node:child_process";
 
 // Track if session has been initialized
 let sessionInitialized = false;
 
+// Cache binary existence checks
+const binaryCache = new Map<string, boolean>();
+
 // Convert Pi event format to Claude Code JSON format
 function toClaudePreToolUse(event: { toolName: string; input: any }): string {
   return JSON.stringify({
@@ -81,12 +87,17 @@ async function runHook(
   });
 }
 
-// Check if a binary exists in PATH
+// Check if a binary exists in PATH (cached)
 function binaryExists(name: string): boolean {
+  if (binaryCache.has(name)) {
+    return binaryCache.get(name)!;
+  }
   try {
     execSync(`which ${name}`, { stdio: "ignore" });
+    binaryCache.set(name, true);
     return true;
   } catch {
+    binaryCache.set(name, false);
     return false;
   }
 }
dots/.config/pi/agent/README.md
@@ -30,18 +30,18 @@ Wraps the Go-based Claude Code hook binaries to provide consistent hook behavior
 
 ## Skills
 
-Pi is compatible with Claude Code skills format. To use Claude skills with pi:
+Pi is compatible with Claude Code skills format. Skills are configured in `settings.json`:
 
-```bash
-# Option 1: Symlink individual skills
-ln -s ~/.config/claude/skills/Git ~/.config/pi/agent/skills/Git
-ln -s ~/.config/claude/skills/Nix ~/.config/pi/agent/skills/Nix
-
-# Option 2: Symlink entire skills directory
-rm -rf ~/.config/pi/agent/skills
-ln -s ~/.config/claude/skills ~/.config/pi/agent/skills
+```json
+{
+  "skills": [
+    "~/.config/claude/skills"
+  ]
+}
 ```
 
+This loads all skills from the Claude skills directory automatically.
+
 ## Settings
 
 The `settings.json` configures:
dots/.config/pi/agent/settings.json
@@ -9,5 +9,9 @@
   ],
   "defaultThinkingLevel": "low",
   "steeringMode": "one-at-a-time",
-  "followUpMode": "one-at-a-time"
+  "followUpMode": "one-at-a-time",
+  "quietStartup": true,
+  "skills": [
+    "~/.config/claude/skills"
+  ]
 }