@claudetools/tools 0.7.8 → 0.7.9
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/setup.js +33 -8
- package/package.json +1 -1
package/dist/setup.js
CHANGED
|
@@ -771,10 +771,10 @@ fi
|
|
|
771
771
|
}
|
|
772
772
|
writeFileSync(userPromptPath, userPromptHook, { mode: 0o755 });
|
|
773
773
|
success('Installed user-prompt-submit.sh hook');
|
|
774
|
-
// Post tool use hook -
|
|
774
|
+
// Post tool use hook - extracts learnings from tool executions via AI
|
|
775
775
|
const postToolHook = `#!/bin/bash
|
|
776
|
-
# ClaudeTools
|
|
777
|
-
#
|
|
776
|
+
# ClaudeTools Observation Extractor
|
|
777
|
+
# Captures tool executions and extracts learnings via AI
|
|
778
778
|
|
|
779
779
|
# Prevent recursion
|
|
780
780
|
LOCK_FILE="/tmp/claude-tool-hook.lock"
|
|
@@ -785,8 +785,9 @@ trap "rm -f $LOCK_FILE" EXIT
|
|
|
785
785
|
# Skip if disabled
|
|
786
786
|
if [ "$CLAUDE_DISABLE_HOOKS" = "1" ]; then exit 0; fi
|
|
787
787
|
|
|
788
|
-
# Read input from stdin
|
|
788
|
+
# Read input from stdin (Claude Code passes tool_name, tool_input, tool_result)
|
|
789
789
|
INPUT=$(cat)
|
|
790
|
+
if [ -z "$INPUT" ]; then exit 0; fi
|
|
790
791
|
|
|
791
792
|
# Read config
|
|
792
793
|
CONFIG_FILE="$HOME/.claudetools/config.json"
|
|
@@ -797,12 +798,36 @@ API_KEY=$(jq -r '.apiKey // empty' "$CONFIG_FILE")
|
|
|
797
798
|
|
|
798
799
|
if [ -z "$API_KEY" ]; then exit 0; fi
|
|
799
800
|
|
|
800
|
-
#
|
|
801
|
-
|
|
801
|
+
# Get current project
|
|
802
|
+
CWD=$(pwd)
|
|
803
|
+
PROJECT_ID=""
|
|
804
|
+
|
|
805
|
+
CLAUDE_MD="$CWD/.claude/CLAUDE.md"
|
|
806
|
+
if [ -f "$CLAUDE_MD" ]; then
|
|
807
|
+
PROJECT_ID=$(grep "Project ID" "$CLAUDE_MD" 2>/dev/null | sed -n 's/.*\\\`\\([a-z0-9_]*\\)\\\`.*/\\1/p' | head -1)
|
|
808
|
+
fi
|
|
809
|
+
|
|
810
|
+
if [ -z "$PROJECT_ID" ]; then
|
|
811
|
+
PROJECT_FILE="$HOME/.claudetools/projects.json"
|
|
812
|
+
if [ -f "$PROJECT_FILE" ]; then
|
|
813
|
+
PROJECT_ID=$(jq -r --arg cwd "$CWD" '
|
|
814
|
+
.bindings[]? | select(.local_path) |
|
|
815
|
+
. as $b | select($cwd | startswith($b.local_path)) |
|
|
816
|
+
.project_id' "$PROJECT_FILE" 2>/dev/null | head -1)
|
|
817
|
+
fi
|
|
818
|
+
fi
|
|
819
|
+
|
|
820
|
+
# Add project_id to the input and send to API (async, don't block)
|
|
821
|
+
ENHANCED_INPUT=$(echo "$INPUT" | jq --arg pid "$PROJECT_ID" --arg cwd "$CWD" '. + {project_id: $pid, cwd: $cwd}' 2>/dev/null || echo "$INPUT")
|
|
822
|
+
|
|
823
|
+
# Send to observation extraction endpoint (background, non-blocking)
|
|
824
|
+
curl -s --max-time 10 -X POST "$API_URL/api/v1/tools/observe" \\
|
|
802
825
|
-H "Authorization: Bearer $API_KEY" \\
|
|
803
826
|
-H "Content-Type: application/json" \\
|
|
804
|
-
-d "$
|
|
805
|
-
2>/dev/null
|
|
827
|
+
-d "$ENHANCED_INPUT" \\
|
|
828
|
+
2>/dev/null &
|
|
829
|
+
|
|
830
|
+
exit 0
|
|
806
831
|
`;
|
|
807
832
|
const postToolPath = join(HOOKS_DIR, 'post-tool-use.sh');
|
|
808
833
|
if (existsSync(postToolPath)) {
|