oneie 3.6.17 → 3.6.20
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/.claude/agents/agent-ops.md +63 -2
- package/.claude/commands/commit.md +95 -0
- package/.claude/commands/npx.md +2 -2
- package/.claude/commands/one.md +7 -1
- package/.claude/commands/push.md +113 -21
- package/.claude/commands/release.md +2 -2
- package/.claude/hooks/release-cli.sh +195 -0
- package/CLAUDE.md +119 -0
- package/README.md +778 -497
- package/package.json +1 -1
- package/.claude/agents/NEWS-QUICKSTART.md +0 -321
- package/.claude/agents/NEWS-README.md +0 -353
- package/.claude/hooks/README-knowledge-hooks.md +0 -451
- package/.claude/hooks/README-root-cleanup.md +0 -200
- package/.claude/hooks/README.md +0 -284
- package/.claude/hooks/__pycache__/done.cpython-313.pyc +0 -0
- package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
- package/.claude/hooks/check-filenames.py +0 -177
- package/.claude/hooks/clean-post.py +0 -468
- package/.claude/hooks/clean-pre.py +0 -393
- package/.claude/hooks/clean-root-markdown.sh +0 -73
- package/.claude/hooks/done.py +0 -236
- package/.claude/hooks/format-hook.sh +0 -163
- package/.claude/hooks/hook-logger.sh +0 -173
- package/.claude/hooks/knowledge-post.py +0 -355
- package/.claude/hooks/knowledge-pre.py +0 -245
- package/.claude/hooks/notification-hook.sh +0 -279
- package/.claude/hooks/root-cleanup.py +0 -217
- package/.claude/hooks/security-hook.sh +0 -397
- package/.claude/hooks/tag-all-docs.py +0 -464
- package/.claude/hooks/test-validate-ontology.sh +0 -170
- package/.claude/hooks/todo.py +0 -368
- package/.claude/hooks/track-changes.sh +0 -101
- package/.claude/hooks/validate-ontology-structure-summary.md +0 -243
- package/.claude/hooks/validate-ontology-structure.py +0 -518
- package/TESTING-ONBOARDING.md +0 -185
package/.claude/hooks/done.py
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
ONE Platform - Done Hook
|
|
4
|
-
Marks current inference complete and advances to next inference.
|
|
5
|
-
|
|
6
|
-
This hook runs on Stop event to:
|
|
7
|
-
- Mark current inference as complete
|
|
8
|
-
- Capture lessons learned (if any)
|
|
9
|
-
- Advance to next inference
|
|
10
|
-
- Save updated state
|
|
11
|
-
"""
|
|
12
|
-
import json
|
|
13
|
-
import sys
|
|
14
|
-
import os
|
|
15
|
-
import time
|
|
16
|
-
from pathlib import Path
|
|
17
|
-
from typing import Dict, Any
|
|
18
|
-
|
|
19
|
-
# Import task descriptions and helpers from todo hook
|
|
20
|
-
from todo import (
|
|
21
|
-
INFERENCE_TASKS,
|
|
22
|
-
get_dimensions_for_inference,
|
|
23
|
-
get_specialist_for_inference,
|
|
24
|
-
get_phase_for_inference,
|
|
25
|
-
get_parallel_opportunities
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def load_state() -> Dict[str, Any]:
|
|
30
|
-
"""Load current inference state from .claude/state/inference.json"""
|
|
31
|
-
state_file = Path(os.environ.get("CLAUDE_PROJECT_DIR", ".")) / ".claude" / "state" / "inference.json"
|
|
32
|
-
|
|
33
|
-
if not state_file.exists():
|
|
34
|
-
# Initialize default state
|
|
35
|
-
default_state = {
|
|
36
|
-
"current_inference": 1,
|
|
37
|
-
"completed_inferences": [],
|
|
38
|
-
"feature_name": "New Feature",
|
|
39
|
-
"organization": "Default Org",
|
|
40
|
-
"person_role": "platform_owner",
|
|
41
|
-
"lessons_learned": []
|
|
42
|
-
}
|
|
43
|
-
return default_state
|
|
44
|
-
|
|
45
|
-
return json.loads(state_file.read_text())
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def save_state(state: Dict[str, Any]):
|
|
49
|
-
"""Save inference state to .claude/state/inference.json"""
|
|
50
|
-
state_file = Path(os.environ.get("CLAUDE_PROJECT_DIR", ".")) / ".claude" / "state" / "inference.json"
|
|
51
|
-
state_file.parent.mkdir(parents=True, exist_ok=True)
|
|
52
|
-
state_file.write_text(json.dumps(state, indent=2))
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def extract_lesson_from_transcript(transcript_path: str, inference: int) -> str:
|
|
56
|
-
"""Extract lesson learned from conversation transcript"""
|
|
57
|
-
try:
|
|
58
|
-
if not transcript_path or not Path(transcript_path).exists():
|
|
59
|
-
return f"Completed Infer {inference}"
|
|
60
|
-
|
|
61
|
-
# Read transcript JSONL and extract key learnings
|
|
62
|
-
with open(transcript_path, 'r') as f:
|
|
63
|
-
lines = f.readlines()
|
|
64
|
-
|
|
65
|
-
# Look for key phrases in assistant responses
|
|
66
|
-
lessons = []
|
|
67
|
-
for line in lines[-10:]: # Last 10 messages
|
|
68
|
-
try:
|
|
69
|
-
msg = json.loads(line)
|
|
70
|
-
if msg.get("role") == "assistant":
|
|
71
|
-
content = msg.get("content", "")
|
|
72
|
-
# Extract lessons (simple heuristic)
|
|
73
|
-
if "learned" in content.lower() or "lesson" in content.lower():
|
|
74
|
-
lessons.append(content[:200]) # First 200 chars
|
|
75
|
-
elif "success" in content.lower() and len(content) < 300:
|
|
76
|
-
lessons.append(content)
|
|
77
|
-
except json.JSONDecodeError:
|
|
78
|
-
continue
|
|
79
|
-
|
|
80
|
-
if lessons:
|
|
81
|
-
return lessons[-1] # Most recent lesson
|
|
82
|
-
return f"Completed Infer {inference}"
|
|
83
|
-
|
|
84
|
-
except Exception as e:
|
|
85
|
-
return f"Completed Infer {inference} (lesson extraction failed: {str(e)[:50]})"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def mark_complete_and_advance(state: Dict[str, Any], transcript_path: str) -> Dict[str, Any]:
|
|
89
|
-
"""Mark current inference complete and advance to next"""
|
|
90
|
-
current = state["current_inference"]
|
|
91
|
-
|
|
92
|
-
# Mark current inference as complete
|
|
93
|
-
if current not in state["completed_inferences"]:
|
|
94
|
-
state["completed_inferences"].append(current)
|
|
95
|
-
state["completed_inferences"].sort()
|
|
96
|
-
|
|
97
|
-
# Extract lesson learned
|
|
98
|
-
lesson = extract_lesson_from_transcript(transcript_path, current)
|
|
99
|
-
state["lessons_learned"].append({
|
|
100
|
-
"inference": current,
|
|
101
|
-
"lesson": lesson,
|
|
102
|
-
"timestamp": int(time.time()) # Unix timestamp
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
# Advance to next inference (unless we're at 100)
|
|
106
|
-
if current < 100:
|
|
107
|
-
state["current_inference"] = current + 1
|
|
108
|
-
else:
|
|
109
|
-
# Feature complete!
|
|
110
|
-
state["current_inference"] = 100
|
|
111
|
-
state["feature_complete"] = True
|
|
112
|
-
|
|
113
|
-
return state
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
def generate_completion_message(state: Dict[str, Any]) -> str:
|
|
117
|
-
"""Generate message shown after marking complete"""
|
|
118
|
-
previous = state["current_inference"] - 1 if state["current_inference"] > 1 else 1
|
|
119
|
-
current = state["current_inference"]
|
|
120
|
-
completed_count = len(state["completed_inferences"])
|
|
121
|
-
progress_pct = (completed_count / 100) * 100
|
|
122
|
-
|
|
123
|
-
# Get info for next inference
|
|
124
|
-
task = INFERENCE_TASKS.get(current, "Unknown task")
|
|
125
|
-
phase = get_phase_for_inference(current)
|
|
126
|
-
dimensions = get_dimensions_for_inference(current)
|
|
127
|
-
specialist = get_specialist_for_inference(current)
|
|
128
|
-
parallel_ops = get_parallel_opportunities(current)
|
|
129
|
-
|
|
130
|
-
# Get most recent lesson
|
|
131
|
-
recent_lesson = None
|
|
132
|
-
if state.get("lessons_learned"):
|
|
133
|
-
for lesson in reversed(state["lessons_learned"]):
|
|
134
|
-
if lesson["inference"] == previous and lesson["lesson"] != f"Completed Infer {previous}":
|
|
135
|
-
recent_lesson = lesson["lesson"]
|
|
136
|
-
break
|
|
137
|
-
|
|
138
|
-
message = f"""
|
|
139
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
140
|
-
✅ INFERENCE COMPLETE: Infer {previous}/100
|
|
141
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
142
|
-
|
|
143
|
-
**Progress:** {completed_count}/100 inferences complete ({progress_pct:.0f}%)
|
|
144
|
-
**Feature:** {state["feature_name"]}
|
|
145
|
-
"""
|
|
146
|
-
|
|
147
|
-
if recent_lesson:
|
|
148
|
-
message += f"\n💡 **Lesson Captured:** {recent_lesson[:150]}...\n"
|
|
149
|
-
|
|
150
|
-
message += f"""
|
|
151
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
152
|
-
{phase['icon']} NEXT INFERENCE: Infer {current}/100
|
|
153
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
154
|
-
|
|
155
|
-
**Phase {phase['number']}/10:** {phase['name']} ({phase['progress']})
|
|
156
|
-
**Task:** {task}
|
|
157
|
-
|
|
158
|
-
**6-Dimension Ontology:** {", ".join(dimensions) if dimensions else "Foundation (all dimensions)"}
|
|
159
|
-
**Assigned Specialist:** {specialist if specialist else "director"}
|
|
160
|
-
"""
|
|
161
|
-
|
|
162
|
-
if parallel_ops:
|
|
163
|
-
message += f"\n⚡ **Parallel Opportunities:** {', '.join(parallel_ops)}\n"
|
|
164
|
-
|
|
165
|
-
message += """
|
|
166
|
-
Ready to continue? Type your next prompt or use:
|
|
167
|
-
/done - Mark this inference complete (when finished)
|
|
168
|
-
/next - Skip to next inference (if not applicable)
|
|
169
|
-
/reset - Start new feature (reset to Infer 1)
|
|
170
|
-
/plan - View complete 100-inference plan
|
|
171
|
-
|
|
172
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
173
|
-
"""
|
|
174
|
-
|
|
175
|
-
# Special message when feature is complete
|
|
176
|
-
if completed_count == 100:
|
|
177
|
-
meaningful_lessons = [l for l in state.get("lessons_learned", [])
|
|
178
|
-
if l["lesson"] != f"Completed Infer {l['inference']}"]
|
|
179
|
-
|
|
180
|
-
message = f"""
|
|
181
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
182
|
-
🎉 FEATURE COMPLETE: {state["feature_name"]}
|
|
183
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
184
|
-
|
|
185
|
-
**All 100 inferences completed successfully!**
|
|
186
|
-
|
|
187
|
-
**Final Stats:**
|
|
188
|
-
- Organization: {state["organization"]}
|
|
189
|
-
- Person Role: {state["person_role"]}
|
|
190
|
-
- Lessons Learned: {len(meaningful_lessons)} meaningful insights captured
|
|
191
|
-
|
|
192
|
-
**Next Steps:**
|
|
193
|
-
1. Start new feature: /reset (or create new conversation)
|
|
194
|
-
2. Review all lessons: Check .claude/state/inference.json
|
|
195
|
-
3. Deploy to production: /release
|
|
196
|
-
|
|
197
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
198
|
-
Congratulations! 🎊 Your feature is production-ready.
|
|
199
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
200
|
-
"""
|
|
201
|
-
|
|
202
|
-
return message
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
def main():
|
|
206
|
-
try:
|
|
207
|
-
# Load hook input from stdin
|
|
208
|
-
input_data = json.load(sys.stdin)
|
|
209
|
-
transcript_path = input_data.get("transcript_path", "")
|
|
210
|
-
|
|
211
|
-
# Load current state
|
|
212
|
-
state = load_state()
|
|
213
|
-
|
|
214
|
-
# Mark complete and advance
|
|
215
|
-
state = mark_complete_and_advance(state, transcript_path)
|
|
216
|
-
|
|
217
|
-
# Save updated state
|
|
218
|
-
save_state(state)
|
|
219
|
-
|
|
220
|
-
# Generate completion message
|
|
221
|
-
message = generate_completion_message(state)
|
|
222
|
-
|
|
223
|
-
# Output message (shown in transcript mode with Ctrl-R)
|
|
224
|
-
print(message)
|
|
225
|
-
|
|
226
|
-
# Exit with success
|
|
227
|
-
sys.exit(0)
|
|
228
|
-
|
|
229
|
-
except Exception as e:
|
|
230
|
-
# Log error but don't block
|
|
231
|
-
print(f"Error in done hook: {e}", file=sys.stderr)
|
|
232
|
-
sys.exit(0)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if __name__ == "__main__":
|
|
236
|
-
main()
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Format Hook - ONE Platform
|
|
4
|
-
# Auto-formats markdown and YAML files aligned with 6-dimension ontology
|
|
5
|
-
# Dimensions: groups, people, things, connections, events, knowledge
|
|
6
|
-
|
|
7
|
-
set -e
|
|
8
|
-
|
|
9
|
-
# Source the logger
|
|
10
|
-
source "$CLAUDE_PROJECT_DIR/.claude/hooks/hook-logger.sh"
|
|
11
|
-
|
|
12
|
-
# Get file path from stdin or argument
|
|
13
|
-
FILE_PATH="${1:-}"
|
|
14
|
-
|
|
15
|
-
# Log start
|
|
16
|
-
log_message "INFO" "Starting format-hook for: ${FILE_PATH:-all files}"
|
|
17
|
-
START_TIME=$(get_time_ms)
|
|
18
|
-
|
|
19
|
-
# 6-dimension ontology directories
|
|
20
|
-
ONTOLOGY_DIMENSIONS=("groups" "people" "things" "connections" "events" "knowledge")
|
|
21
|
-
|
|
22
|
-
# Function to format markdown files with ontology preservation
|
|
23
|
-
format_markdown() {
|
|
24
|
-
local file="$1"
|
|
25
|
-
|
|
26
|
-
# Extract dimension if file is in ontology structure
|
|
27
|
-
local dimension=""
|
|
28
|
-
for dim in "${ONTOLOGY_DIMENSIONS[@]}"; do
|
|
29
|
-
if [[ "$file" =~ /one/$dim/ ]] || [[ "$file" =~ /[^/]+/$dim/ ]]; then
|
|
30
|
-
dimension="[$dim]"
|
|
31
|
-
break
|
|
32
|
-
fi
|
|
33
|
-
done
|
|
34
|
-
|
|
35
|
-
if command -v prettier &> /dev/null; then
|
|
36
|
-
prettier --write "$file" --parser markdown 2>/dev/null && echo "✅ Formatted $dimension: $file"
|
|
37
|
-
else
|
|
38
|
-
echo "⚠️ prettier not found, skipping markdown formatting"
|
|
39
|
-
fi
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
# Function to format YAML files with ontology preservation
|
|
43
|
-
format_yaml() {
|
|
44
|
-
local file="$1"
|
|
45
|
-
|
|
46
|
-
# Extract dimension if file is in ontology structure
|
|
47
|
-
local dimension=""
|
|
48
|
-
for dim in "${ONTOLOGY_DIMENSIONS[@]}"; do
|
|
49
|
-
if [[ "$file" =~ /one/$dim/ ]] || [[ "$file" =~ /[^/]+/$dim/ ]]; then
|
|
50
|
-
dimension="[$dim]"
|
|
51
|
-
break
|
|
52
|
-
fi
|
|
53
|
-
done
|
|
54
|
-
|
|
55
|
-
if command -v prettier &> /dev/null; then
|
|
56
|
-
prettier --write "$file" --parser yaml 2>/dev/null && echo "✅ Formatted $dimension: $file"
|
|
57
|
-
else
|
|
58
|
-
echo "⚠️ prettier not found, skipping YAML formatting"
|
|
59
|
-
fi
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
EXIT_CODE=0
|
|
63
|
-
FILES_FORMATTED=0
|
|
64
|
-
|
|
65
|
-
# Check if specific file provided
|
|
66
|
-
if [ -n "$FILE_PATH" ]; then
|
|
67
|
-
# Format specific file
|
|
68
|
-
if [[ "$FILE_PATH" =~ \.md$ ]]; then
|
|
69
|
-
format_markdown "$FILE_PATH"
|
|
70
|
-
FILES_FORMATTED=$((FILES_FORMATTED + 1))
|
|
71
|
-
elif [[ "$FILE_PATH" =~ \.(yaml|yml)$ ]]; then
|
|
72
|
-
format_yaml "$FILE_PATH"
|
|
73
|
-
FILES_FORMATTED=$((FILES_FORMATTED + 1))
|
|
74
|
-
else
|
|
75
|
-
log_message "INFO" "File type not supported for formatting: $FILE_PATH"
|
|
76
|
-
fi
|
|
77
|
-
else
|
|
78
|
-
# Format all files in ontology-aligned directories
|
|
79
|
-
if command -v prettier &> /dev/null; then
|
|
80
|
-
|
|
81
|
-
# Format /one directory (global ontology)
|
|
82
|
-
if [ -d "$CLAUDE_PROJECT_DIR/one" ]; then
|
|
83
|
-
echo "🔧 Formatting global ontology: /one/"
|
|
84
|
-
|
|
85
|
-
# Format each dimension directory
|
|
86
|
-
for dim in "${ONTOLOGY_DIMENSIONS[@]}"; do
|
|
87
|
-
if [ -d "$CLAUDE_PROJECT_DIR/one/$dim" ]; then
|
|
88
|
-
echo " 📁 Formatting dimension: $dim"
|
|
89
|
-
find "$CLAUDE_PROJECT_DIR/one/$dim" -type f -name "*.md" 2>/dev/null | while read -r file; do
|
|
90
|
-
format_markdown "$file"
|
|
91
|
-
FILES_FORMATTED=$((FILES_FORMATTED + 1))
|
|
92
|
-
done
|
|
93
|
-
find "$CLAUDE_PROJECT_DIR/one/$dim" -type f \( -name "*.yaml" -o -name "*.yml" \) 2>/dev/null | while read -r file; do
|
|
94
|
-
format_yaml "$file"
|
|
95
|
-
FILES_FORMATTED=$((FILES_FORMATTED + 1))
|
|
96
|
-
done
|
|
97
|
-
fi
|
|
98
|
-
done
|
|
99
|
-
|
|
100
|
-
# Format root-level files in /one
|
|
101
|
-
find "$CLAUDE_PROJECT_DIR/one" -maxdepth 1 -type f \( -name "*.md" -o -name "*.yaml" -o -name "*.yml" \) 2>/dev/null | while read -r file; do
|
|
102
|
-
format_markdown "$file" 2>/dev/null || format_yaml "$file" 2>/dev/null
|
|
103
|
-
FILES_FORMATTED=$((FILES_FORMATTED + 1))
|
|
104
|
-
done
|
|
105
|
-
else
|
|
106
|
-
log_message "WARN" "/one directory not found"
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
# Format installation folders (e.g., /nine-padel, /one-inc)
|
|
110
|
-
# Look for directories with hyphenated names that aren't system directories
|
|
111
|
-
echo "🔧 Scanning for installation folders..."
|
|
112
|
-
for install_dir in "$CLAUDE_PROJECT_DIR"/*-*/; do
|
|
113
|
-
# Skip if not a directory or is a system directory
|
|
114
|
-
if [ ! -d "$install_dir" ] || [[ "$install_dir" =~ (node_modules|\.git|\.claude) ]]; then
|
|
115
|
-
continue
|
|
116
|
-
fi
|
|
117
|
-
|
|
118
|
-
install_name=$(basename "$install_dir")
|
|
119
|
-
echo " 🏢 Formatting installation: $install_name"
|
|
120
|
-
|
|
121
|
-
# Format knowledge directory in installation
|
|
122
|
-
if [ -d "$install_dir/knowledge" ]; then
|
|
123
|
-
echo " 📁 Formatting knowledge/"
|
|
124
|
-
find "$install_dir/knowledge" -type f \( -name "*.md" -o -name "*.yaml" -o -name "*.yml" \) 2>/dev/null | while read -r file; do
|
|
125
|
-
if [[ "$file" =~ \.md$ ]]; then
|
|
126
|
-
format_markdown "$file"
|
|
127
|
-
else
|
|
128
|
-
format_yaml "$file"
|
|
129
|
-
fi
|
|
130
|
-
FILES_FORMATTED=$((FILES_FORMATTED + 1))
|
|
131
|
-
done
|
|
132
|
-
fi
|
|
133
|
-
|
|
134
|
-
# Format dimension directories in installation (e.g., /nine-padel/groups/)
|
|
135
|
-
for dim in "${ONTOLOGY_DIMENSIONS[@]}"; do
|
|
136
|
-
if [ -d "$install_dir/$dim" ]; then
|
|
137
|
-
echo " 📁 Formatting $dim/"
|
|
138
|
-
find "$install_dir/$dim" -type f \( -name "*.md" -o -name "*.yaml" -o -name "*.yml" \) 2>/dev/null | while read -r file; do
|
|
139
|
-
if [[ "$file" =~ \.md$ ]]; then
|
|
140
|
-
format_markdown "$file"
|
|
141
|
-
else
|
|
142
|
-
format_yaml "$file"
|
|
143
|
-
fi
|
|
144
|
-
FILES_FORMATTED=$((FILES_FORMATTED + 1))
|
|
145
|
-
done
|
|
146
|
-
fi
|
|
147
|
-
done
|
|
148
|
-
done
|
|
149
|
-
|
|
150
|
-
echo ""
|
|
151
|
-
echo "✅ Formatting completed: $FILES_FORMATTED files processed"
|
|
152
|
-
|
|
153
|
-
else
|
|
154
|
-
echo "⚠️ prettier not installed. Install with: npm install -g prettier"
|
|
155
|
-
EXIT_CODE=0 # Don't fail if prettier not installed
|
|
156
|
-
fi
|
|
157
|
-
fi
|
|
158
|
-
|
|
159
|
-
# Log completion
|
|
160
|
-
END_TIME=$(get_time_ms)
|
|
161
|
-
log_hook_execution "format-hook" "$0 $*" "$START_TIME" "$END_TIME" "$EXIT_CODE"
|
|
162
|
-
|
|
163
|
-
exit $EXIT_CODE
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Claude Code Hook Logger - ONE Platform
|
|
4
|
-
# Handles logging for hook execution with 6-dimension ontology context
|
|
5
|
-
# Logs hook execution as EVENTS with dimension tracking
|
|
6
|
-
|
|
7
|
-
LOG_FILE="${LOG_FILE:-$CLAUDE_PROJECT_DIR/.claude/hooks.log}"
|
|
8
|
-
DEBUG_MODE="${DEBUG_MODE:-false}"
|
|
9
|
-
INFERENCE_STATE_FILE="${CLAUDE_PROJECT_DIR}/.claude/state/inference.json"
|
|
10
|
-
ONTOLOGY_VERSION="1.0.0"
|
|
11
|
-
|
|
12
|
-
# Create log directory if it doesn't exist
|
|
13
|
-
mkdir -p "$(dirname "$LOG_FILE")"
|
|
14
|
-
|
|
15
|
-
# Function to get current inference context from state
|
|
16
|
-
get_inference_context() {
|
|
17
|
-
if [ -f "$INFERENCE_STATE_FILE" ]; then
|
|
18
|
-
local current_inference=$(cat "$INFERENCE_STATE_FILE" | grep -o '"current_inference": [0-9]*' | awk '{print $2}')
|
|
19
|
-
echo "${current_inference:-0}"
|
|
20
|
-
else
|
|
21
|
-
echo "0"
|
|
22
|
-
fi
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
# Function to map inference number to dimension
|
|
26
|
-
# Based on 100-inference sequence in one/knowledge/todo.md
|
|
27
|
-
get_inference_dimension() {
|
|
28
|
-
local inference="$1"
|
|
29
|
-
|
|
30
|
-
if [ "$inference" -ge 1 ] && [ "$inference" -le 10 ]; then
|
|
31
|
-
echo "foundation"
|
|
32
|
-
elif [ "$inference" -ge 11 ] && [ "$inference" -le 20 ]; then
|
|
33
|
-
echo "things" # Backend Schema & Services
|
|
34
|
-
elif [ "$inference" -ge 21 ] && [ "$inference" -le 30 ]; then
|
|
35
|
-
echo "things" # Frontend Pages & Components
|
|
36
|
-
elif [ "$inference" -ge 31 ] && [ "$inference" -le 40 ]; then
|
|
37
|
-
echo "connections" # Integration & Connections
|
|
38
|
-
elif [ "$inference" -ge 41 ] && [ "$inference" -le 50 ]; then
|
|
39
|
-
echo "people" # Authentication & Authorization
|
|
40
|
-
elif [ "$inference" -ge 51 ] && [ "$inference" -le 60 ]; then
|
|
41
|
-
echo "knowledge" # Knowledge & RAG
|
|
42
|
-
elif [ "$inference" -ge 61 ] && [ "$inference" -le 70 ]; then
|
|
43
|
-
echo "quality" # Quality & Testing
|
|
44
|
-
elif [ "$inference" -ge 71 ] && [ "$inference" -le 80 ]; then
|
|
45
|
-
echo "design" # Design & Wireframes
|
|
46
|
-
elif [ "$inference" -ge 81 ] && [ "$inference" -le 90 ]; then
|
|
47
|
-
echo "events" # Performance & Optimization
|
|
48
|
-
elif [ "$inference" -ge 91 ] && [ "$inference" -le 100 ]; then
|
|
49
|
-
echo "deployment" # Deployment & Documentation
|
|
50
|
-
else
|
|
51
|
-
echo "unknown"
|
|
52
|
-
fi
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
# Function to detect specialist agent from hook name or context
|
|
56
|
-
get_specialist_agent() {
|
|
57
|
-
local hook_name="$1"
|
|
58
|
-
|
|
59
|
-
case "$hook_name" in
|
|
60
|
-
*backend*|*mutation*|*query*|*schema*)
|
|
61
|
-
echo "agent-backend"
|
|
62
|
-
;;
|
|
63
|
-
*frontend*|*component*|*page*|*ui*)
|
|
64
|
-
echo "agent-frontend"
|
|
65
|
-
;;
|
|
66
|
-
*integration*|*webhook*|*sync*)
|
|
67
|
-
echo "agent-integrator"
|
|
68
|
-
;;
|
|
69
|
-
*test*|*quality*)
|
|
70
|
-
echo "agent-quality"
|
|
71
|
-
;;
|
|
72
|
-
*design*|*wireframe*)
|
|
73
|
-
echo "agent-designer"
|
|
74
|
-
;;
|
|
75
|
-
*clean*|*refactor*)
|
|
76
|
-
echo "agent-clean"
|
|
77
|
-
;;
|
|
78
|
-
*deploy*|*release*)
|
|
79
|
-
echo "agent-ops"
|
|
80
|
-
;;
|
|
81
|
-
*problem*|*debug*)
|
|
82
|
-
echo "agent-problem-solver"
|
|
83
|
-
;;
|
|
84
|
-
*document*|*doc*)
|
|
85
|
-
echo "agent-documenter"
|
|
86
|
-
;;
|
|
87
|
-
*)
|
|
88
|
-
echo "agent-director"
|
|
89
|
-
;;
|
|
90
|
-
esac
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
# Function to log messages with ontology context
|
|
94
|
-
log_message() {
|
|
95
|
-
local level="$1"
|
|
96
|
-
local message="$2"
|
|
97
|
-
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
|
98
|
-
local inference=$(get_inference_context)
|
|
99
|
-
local dimension=$(get_inference_dimension "$inference")
|
|
100
|
-
|
|
101
|
-
# Format: [timestamp] [level] [Infer N] [dimension] message
|
|
102
|
-
echo "[$timestamp] [$level] [Infer $inference] [$dimension] $message" >> "$LOG_FILE"
|
|
103
|
-
|
|
104
|
-
if [ "$DEBUG_MODE" = "true" ]; then
|
|
105
|
-
echo "[$timestamp] [$level] [Infer $inference] [$dimension] $message" >&2
|
|
106
|
-
fi
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
# Function to log hook execution as EVENT
|
|
110
|
-
log_hook_execution() {
|
|
111
|
-
local hook_name="$1"
|
|
112
|
-
local command="$2"
|
|
113
|
-
local start_time="$3"
|
|
114
|
-
local end_time="$4"
|
|
115
|
-
local exit_code="$5"
|
|
116
|
-
|
|
117
|
-
local duration=$((end_time - start_time))
|
|
118
|
-
local inference=$(get_inference_context)
|
|
119
|
-
local dimension=$(get_inference_dimension "$inference")
|
|
120
|
-
local agent=$(get_specialist_agent "$hook_name")
|
|
121
|
-
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
|
122
|
-
|
|
123
|
-
# Create structured event log entry
|
|
124
|
-
local event_log="[$timestamp] [EVENT] hook_executed | "
|
|
125
|
-
event_log+="hook=$hook_name | "
|
|
126
|
-
event_log+="inference=$inference | "
|
|
127
|
-
event_log+="dimension=$dimension | "
|
|
128
|
-
event_log+="agent=$agent | "
|
|
129
|
-
event_log+="duration=${duration}ms | "
|
|
130
|
-
event_log+="exit_code=$exit_code | "
|
|
131
|
-
event_log+="ontology_version=$ONTOLOGY_VERSION"
|
|
132
|
-
|
|
133
|
-
echo "$event_log" >> "$LOG_FILE"
|
|
134
|
-
|
|
135
|
-
if [ "$DEBUG_MODE" = "true" ]; then
|
|
136
|
-
echo "$event_log" >&2
|
|
137
|
-
fi
|
|
138
|
-
|
|
139
|
-
# Log performance warning if execution took too long
|
|
140
|
-
if [ "$duration" -gt 5000 ]; then
|
|
141
|
-
log_message "WARN" "Hook execution exceeded 5 seconds: $hook_name (${duration}ms)"
|
|
142
|
-
fi
|
|
143
|
-
|
|
144
|
-
# Log success or failure
|
|
145
|
-
if [ "$exit_code" -eq 0 ]; then
|
|
146
|
-
log_message "INFO" "Hook completed successfully: $hook_name"
|
|
147
|
-
else
|
|
148
|
-
log_message "ERROR" "Hook failed with exit code $exit_code: $hook_name"
|
|
149
|
-
fi
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
# Function to get current time in milliseconds
|
|
153
|
-
get_time_ms() {
|
|
154
|
-
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
155
|
-
# macOS
|
|
156
|
-
python3 -c "import time; print(int(time.time() * 1000))" 2>/dev/null || echo $(($(date +%s) * 1000))
|
|
157
|
-
else
|
|
158
|
-
# Linux
|
|
159
|
-
echo $(($(date +%s%N) / 1000000))
|
|
160
|
-
fi
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
# Export functions for use in other scripts
|
|
164
|
-
export -f log_message
|
|
165
|
-
export -f log_hook_execution
|
|
166
|
-
export -f get_time_ms
|
|
167
|
-
export -f get_inference_context
|
|
168
|
-
export -f get_inference_dimension
|
|
169
|
-
export -f get_specialist_agent
|
|
170
|
-
export LOG_FILE
|
|
171
|
-
export DEBUG_MODE
|
|
172
|
-
export INFERENCE_STATE_FILE
|
|
173
|
-
export ONTOLOGY_VERSION
|