@stackmemoryai/stackmemory 0.5.57 → 0.5.58

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.
@@ -0,0 +1,123 @@
1
+ #!/bin/bash
2
+ # Test CLAUDE.md format effectiveness
3
+ # Compares compact vs verbose configurations
4
+
5
+ set -e
6
+
7
+ CLAUDE_DIR="$HOME/.claude"
8
+ VERBOSE_FILE="$CLAUDE_DIR/CLAUDE.md"
9
+ COMPACT_FILE="$CLAUDE_DIR/CLAUDE.compact.md"
10
+ BACKUP_FILE="$CLAUDE_DIR/CLAUDE.backup.md"
11
+ RESULTS_DIR="/tmp/claude-config-test-$(date +%Y%m%d-%H%M%S)"
12
+
13
+ mkdir -p "$RESULTS_DIR"
14
+
15
+ echo "=== CLAUDE.md A/B Test ==="
16
+ echo "Results: $RESULTS_DIR"
17
+ echo ""
18
+
19
+ # Test prompts that exercise CLAUDE.md rules
20
+ declare -a TEST_PROMPTS=(
21
+ "What's your communication style preference?"
22
+ "I want to add a feature. Should you ask clarifying questions or just start coding?"
23
+ "Write a function to hash a password"
24
+ "What should you do before editing a file?"
25
+ "How do you handle ESM imports in TypeScript?"
26
+ )
27
+
28
+ # Token counts
29
+ VERBOSE_TOKENS=$(cat "$VERBOSE_FILE" 2>/dev/null | wc -c | awk '{print int($1/3.5)}')
30
+ COMPACT_TOKENS=$(cat "$COMPACT_FILE" 2>/dev/null | wc -c | awk '{print int($1/3.5)}')
31
+
32
+ echo "Token comparison:"
33
+ echo " Verbose: ~$VERBOSE_TOKENS tokens"
34
+ echo " Compact: ~$COMPACT_TOKENS tokens"
35
+ echo " Savings: ~$((VERBOSE_TOKENS - COMPACT_TOKENS)) tokens ($(( (VERBOSE_TOKENS - COMPACT_TOKENS) * 100 / VERBOSE_TOKENS ))%)"
36
+ echo ""
37
+
38
+ # Backup current config
39
+ cp "$VERBOSE_FILE" "$BACKUP_FILE"
40
+
41
+ run_test() {
42
+ local config_name=$1
43
+ local config_file=$2
44
+ local output_dir="$RESULTS_DIR/$config_name"
45
+ mkdir -p "$output_dir"
46
+
47
+ echo "Testing with $config_name config..."
48
+
49
+ # Swap config
50
+ cp "$config_file" "$VERBOSE_FILE"
51
+
52
+ local i=0
53
+ for prompt in "${TEST_PROMPTS[@]}"; do
54
+ i=$((i + 1))
55
+ echo " Prompt $i: ${prompt:0:40}..."
56
+
57
+ # Run claude with prompt, capture output
58
+ # Using --print flag for non-interactive mode
59
+ claude --print "$prompt" > "$output_dir/prompt_$i.txt" 2>&1 || true
60
+
61
+ # Brief pause to avoid rate limiting
62
+ sleep 1
63
+ done
64
+
65
+ echo " Done. Outputs in $output_dir/"
66
+ }
67
+
68
+ # Test verbose config
69
+ if [ -f "$VERBOSE_FILE" ]; then
70
+ # Save original verbose as .verbose for testing
71
+ cp "$VERBOSE_FILE" "$CLAUDE_DIR/CLAUDE.verbose.md"
72
+ run_test "verbose" "$CLAUDE_DIR/CLAUDE.verbose.md"
73
+ fi
74
+
75
+ # Test compact config
76
+ if [ -f "$COMPACT_FILE" ]; then
77
+ run_test "compact" "$COMPACT_FILE"
78
+ fi
79
+
80
+ # Restore original config
81
+ cp "$BACKUP_FILE" "$VERBOSE_FILE"
82
+ rm -f "$BACKUP_FILE"
83
+
84
+ echo ""
85
+ echo "=== Analysis ==="
86
+
87
+ # Compare output lengths (proxy for verbosity)
88
+ echo "Output lengths (chars):"
89
+ echo " Verbose config:"
90
+ for f in "$RESULTS_DIR/verbose"/prompt_*.txt; do
91
+ [ -f "$f" ] && echo " $(basename $f): $(wc -c < "$f")"
92
+ done
93
+
94
+ echo " Compact config:"
95
+ for f in "$RESULTS_DIR/compact"/prompt_*.txt; do
96
+ [ -f "$f" ] && echo " $(basename $f): $(wc -c < "$f")"
97
+ done
98
+
99
+ # Check for key behaviors
100
+ echo ""
101
+ echo "Behavior checks:"
102
+
103
+ check_behavior() {
104
+ local name=$1
105
+ local pattern=$2
106
+ local verbose_match=$(grep -l "$pattern" "$RESULTS_DIR/verbose"/*.txt 2>/dev/null | wc -l)
107
+ local compact_match=$(grep -l "$pattern" "$RESULTS_DIR/compact"/*.txt 2>/dev/null | wc -l)
108
+ echo " $name: verbose=$verbose_match compact=$compact_match"
109
+ }
110
+
111
+ check_behavior "Concise style" "concise\|brief\|short"
112
+ check_behavior "Security mention" "security\|validate\|hash"
113
+ check_behavior "ESM/extension" "\.js\|extension\|ESM"
114
+ check_behavior "Read before edit" "read\|before\|first"
115
+
116
+ echo ""
117
+ echo "=== Summary ==="
118
+ echo "Config files preserved. Review outputs in:"
119
+ echo " $RESULTS_DIR/verbose/"
120
+ echo " $RESULTS_DIR/compact/"
121
+ echo ""
122
+ echo "To manually compare:"
123
+ echo " diff $RESULTS_DIR/verbose/prompt_1.txt $RESULTS_DIR/compact/prompt_1.txt"
@@ -0,0 +1,155 @@
1
+ #!/bin/bash
2
+ # Validate CLAUDE.md configurations - token counts and coverage
3
+ set -e
4
+
5
+ CLAUDE_DIR="$HOME/.claude"
6
+ AGENT_DOCS="$CLAUDE_DIR/agent_docs"
7
+
8
+ echo "=== CLAUDE.md Config Validation ==="
9
+ echo ""
10
+
11
+ # Token estimation function
12
+ count_tokens() {
13
+ local file=$1
14
+ if [ -f "$file" ]; then
15
+ local chars=$(wc -c < "$file")
16
+ echo $((chars / 4)) # ~4 chars per token estimate
17
+ else
18
+ echo "0"
19
+ fi
20
+ }
21
+
22
+ # 1. Token Comparison
23
+ echo "## Token Counts"
24
+ echo ""
25
+ printf "%-40s %8s %8s\n" "File" "Lines" "~Tokens"
26
+ printf "%-40s %8s %8s\n" "----" "-----" "-------"
27
+
28
+ total_verbose=0
29
+ total_compact=0
30
+
31
+ for file in "$CLAUDE_DIR"/*.md; do
32
+ [ -f "$file" ] || continue
33
+ name=$(basename "$file")
34
+ lines=$(wc -l < "$file" | tr -d ' ')
35
+ tokens=$(count_tokens "$file")
36
+ printf "%-40s %8s %8s\n" "$name" "$lines" "$tokens"
37
+
38
+ if [[ "$name" == *".compact.md" ]]; then
39
+ total_compact=$((total_compact + tokens))
40
+ else
41
+ total_verbose=$((total_verbose + tokens))
42
+ fi
43
+ done
44
+
45
+ echo ""
46
+
47
+ # 2. Agent Docs Comparison
48
+ echo "## Agent Docs"
49
+ echo ""
50
+ printf "%-40s %8s %8s\n" "File" "Lines" "~Tokens"
51
+ printf "%-40s %8s %8s\n" "----" "-----" "-------"
52
+
53
+ verbose_docs=0
54
+ compact_docs=0
55
+
56
+ for file in "$AGENT_DOCS"/*.md; do
57
+ [ -f "$file" ] || continue
58
+ name=$(basename "$file")
59
+ lines=$(wc -l < "$file" | tr -d ' ')
60
+ tokens=$(count_tokens "$file")
61
+ printf "%-40s %8s %8s\n" "$name" "$lines" "$tokens"
62
+
63
+ if [[ "$name" == *".compact.md" ]]; then
64
+ compact_docs=$((compact_docs + tokens))
65
+ else
66
+ verbose_docs=$((verbose_docs + tokens))
67
+ fi
68
+ done
69
+
70
+ echo ""
71
+
72
+ # 3. Summary
73
+ echo "## Summary"
74
+ echo ""
75
+ echo "Main configs:"
76
+ echo " Verbose total: ~$total_verbose tokens"
77
+ echo " Compact total: ~$total_compact tokens"
78
+ if [ $total_verbose -gt 0 ]; then
79
+ savings=$((100 - (total_compact * 100 / total_verbose)))
80
+ echo " Savings: ${savings}%"
81
+ fi
82
+
83
+ echo ""
84
+ echo "Agent docs:"
85
+ echo " Verbose total: ~$verbose_docs tokens"
86
+ echo " Compact total: ~$compact_docs tokens"
87
+ if [ $verbose_docs -gt 0 ]; then
88
+ savings=$((100 - (compact_docs * 100 / verbose_docs)))
89
+ echo " Savings: ${savings}%"
90
+ fi
91
+
92
+ echo ""
93
+
94
+ # 4. Reference Validation
95
+ echo "## Reference Validation"
96
+ echo ""
97
+
98
+ # Check CLAUDE.md references
99
+ if [ -f "$CLAUDE_DIR/CLAUDE.md" ]; then
100
+ echo "Checking CLAUDE.md references..."
101
+ refs=$(grep -oE '[A-Z_]+\.compact\.md' "$CLAUDE_DIR/CLAUDE.md" 2>/dev/null || true)
102
+
103
+ missing=0
104
+ for ref in $refs; do
105
+ if [ -f "$AGENT_DOCS/$ref" ]; then
106
+ echo " [OK] $ref"
107
+ else
108
+ echo " [MISSING] $ref"
109
+ missing=$((missing + 1))
110
+ fi
111
+ done
112
+
113
+ if [ $missing -eq 0 ] && [ -n "$refs" ]; then
114
+ echo " All references valid"
115
+ elif [ -z "$refs" ]; then
116
+ echo " No compact doc references found"
117
+ else
118
+ echo " WARNING: $missing missing references"
119
+ fi
120
+ else
121
+ echo " CLAUDE.md not found"
122
+ fi
123
+
124
+ echo ""
125
+
126
+ # 5. Key Rules Coverage
127
+ echo "## Key Rules Coverage"
128
+ echo ""
129
+
130
+ check_rule() {
131
+ local name=$1
132
+ local pattern=$2
133
+ local file=$3
134
+
135
+ if grep -qiE "$pattern" "$file" 2>/dev/null; then
136
+ echo " [OK] $name"
137
+ else
138
+ echo " [MISSING] $name"
139
+ fi
140
+ }
141
+
142
+ echo "CLAUDE.md rules:"
143
+ if [ -f "$CLAUDE_DIR/CLAUDE.md" ]; then
144
+ check_rule "Security/secrets" "secret|credential|api.?key" "$CLAUDE_DIR/CLAUDE.md"
145
+ check_rule "ESM imports" "\.js|ESM|extension" "$CLAUDE_DIR/CLAUDE.md"
146
+ check_rule "Validation" "lint|test|build" "$CLAUDE_DIR/CLAUDE.md"
147
+ check_rule "Git workflow" "commit|branch|push" "$CLAUDE_DIR/CLAUDE.md"
148
+ check_rule "Error handling" "error|throw|undefined" "$CLAUDE_DIR/CLAUDE.md"
149
+ check_rule "Thinking modes" "think|ultra" "$CLAUDE_DIR/CLAUDE.md"
150
+ check_rule "Coverage" "coverage|untested" "$CLAUDE_DIR/CLAUDE.md"
151
+ check_rule "Branch naming" "feature/|fix/|chore/" "$CLAUDE_DIR/CLAUDE.md"
152
+ fi
153
+
154
+ echo ""
155
+ echo "=== Validation Complete ==="