Commit d7337681f2ad

Vincent Demeester <vincent@sbr.pm>
2026-02-13 13:42:04
feat(pi): added settings management for pi agent
Added ensure-settings.sh script that merges required pi agent settings into the runtime settings.json without overwriting user preferences. Required settings: - hideThinkingBlock: true (cleaner output) - quietStartup: true (custom header only) - skills: ~/.config/claude/skills (share with Claude Code) The script uses jq to merge settings, preserving user customizations while ensuring required values are present. Updated dots/Makefile to run ensure-settings.sh as part of pi-agent target, so 'make dots' will configure pi agent settings automatically. Template settings.json is tracked in git, runtime ~/.pi/agent/settings.json is managed by pi and merged with required values by ensure-settings.sh.
1 parent 8df356e
Changed files (3)
dots/pi/agent/ensure-settings.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+# Ensure pi agent settings.json has required values without overwriting user preferences
+# This script merges required settings into ~/.pi/agent/settings.json
+
+set -euo pipefail
+
+RUNTIME_SETTINGS="$HOME/.pi/agent/settings.json"
+TEMPLATE_SETTINGS="$(dirname "$0")/settings.json"
+
+# Required settings that should always be present
+REQUIRED_SETTINGS='{
+  "hideThinkingBlock": true,
+  "quietStartup": true,
+  "skills": ["~/.config/claude/skills"]
+}'
+
+# Create runtime settings directory if it doesn't exist
+mkdir -p "$(dirname "$RUNTIME_SETTINGS")"
+
+# If runtime settings doesn't exist, copy from template
+if [ ! -f "$RUNTIME_SETTINGS" ]; then
+  echo "๐Ÿ“ Creating $RUNTIME_SETTINGS from template..."
+  cp "$TEMPLATE_SETTINGS" "$RUNTIME_SETTINGS"
+  exit 0
+fi
+
+# Use jq to merge required settings into existing settings
+# This preserves user settings while ensuring required ones are present
+if command -v jq >/dev/null 2>&1; then
+  echo "๐Ÿ”ง Ensuring required pi agent settings..."
+  
+  TEMP_FILE=$(mktemp)
+  jq -s '.[0] * .[1]' "$RUNTIME_SETTINGS" <(echo "$REQUIRED_SETTINGS") > "$TEMP_FILE"
+  mv "$TEMP_FILE" "$RUNTIME_SETTINGS"
+  
+  echo "โœ… Pi agent settings updated:"
+  echo "   - hideThinkingBlock: true"
+  echo "   - quietStartup: true"
+  echo "   - skills: ~/.config/claude/skills"
+else
+  echo "โš ๏ธ  jq not found - cannot merge settings automatically"
+  echo "   Please ensure these settings are in $RUNTIME_SETTINGS:"
+  echo "   - hideThinkingBlock: true"
+  echo "   - quietStartup: true"
+  echo "   - skills: [\"~/.config/claude/skills\"]"
+  exit 1
+fi
dots/pi/agent/settings.json
@@ -11,6 +11,7 @@
   "steeringMode": "one-at-a-time",
   "followUpMode": "one-at-a-time",
   "quietStartup": true,
+  "hideThinkingBlock": true,
   "skills": [
     "~/.config/claude/skills"
   ]
dots/Makefile
@@ -58,11 +58,13 @@ gh-news : ~/.config/gh-news/config.toml
 all += github-notif-manager
 github-notif-manager : ~/.config/github-notif-manager/config.yaml
 
-all += git-template copilot-hooks opencode-plugin pi-agent agent-skills agent-skill-manager-bin ai-config
+all += git-template copilot-hooks opencode-plugin pi-agent pi-agent-settings agent-skills agent-skill-manager-bin ai-config
 git-template : ~/.config/git/template
 copilot-hooks : ~/.config/copilot-hooks
 opencode-plugin : ~/.config/opencode/plugin
 pi-agent : ~/.pi/agent/extensions ~/.pi/agent/agents ~/.pi/agent/AGENTS.md ~/.pi/agent/README.md ~/.pi/agent/keybindings.json ~/.pi/agent/sessions
+pi-agent-settings : pi-agent
+	@$(dotfiles)/pi/agent/ensure-settings.sh
 agent-skills : ~/.config/agent-skills
 agent-skill-manager-bin : ~/bin/agent-skill-manager
 ai-config : ~/.config/ai/skills ~/.config/ai/path-policies.json