oneie 3.6.24 → 3.6.26
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-backend.md +2 -2
- package/.claude/agents/agent-builder.md +226 -198
- package/.claude/agents/agent-designer.md +167 -11
- package/.claude/agents/agent-director.md +180 -112
- package/.claude/agents/agent-frontend.md +154 -8
- package/.claude/agents/agent-onboard.md +1 -1
- package/.claude/agents/agent-ontology.md +2 -2
- package/.claude/agents/agent-ops.md +58 -38
- package/.claude/agents/agent-quality.md +377 -0
- package/.claude/agents/agent-sales.md +3 -3
- package/.claude/commands/cascade.md +21 -21
- package/.claude/commands/create.md +19 -19
- package/.claude/commands/deploy.md +82 -104
- package/.claude/commands/mcp-on.md +191 -0
- package/.claude/commands/one.md +267 -92
- package/.claude/commands/plan.md +17 -17
- package/.claude/commands/release.md +65 -14
- package/.claude/hooks/PULL-BEFORE-PUSH-GUIDE.md +473 -0
- package/.claude/hooks/README-knowledge-hooks.md +451 -0
- package/.claude/hooks/README-root-cleanup.md +200 -0
- package/.claude/hooks/README.md +284 -0
- 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 +177 -0
- package/.claude/hooks/clean-post.py +468 -0
- package/.claude/hooks/clean-pre.py +393 -0
- package/.claude/hooks/clean-root-markdown.sh +73 -0
- package/.claude/hooks/commit-push.sh +95 -0
- package/.claude/hooks/done.py +236 -0
- package/.claude/hooks/format-hook.sh +163 -0
- package/.claude/hooks/hook-logger.sh +173 -0
- package/.claude/hooks/knowledge-post.py +355 -0
- package/.claude/hooks/knowledge-pre.py +245 -0
- package/.claude/hooks/mcp-on.sh +134 -0
- package/.claude/hooks/notification-hook.sh +279 -0
- package/.claude/hooks/push.sh +101 -0
- package/.claude/hooks/release-cli.sh +16 -8
- package/.claude/hooks/root-cleanup.py +217 -0
- package/.claude/hooks/security-hook.sh +397 -0
- package/.claude/hooks/tag-all-docs.py +464 -0
- package/.claude/hooks/test-validate-ontology.sh +170 -0
- package/.claude/hooks/todo.py +368 -0
- package/.claude/hooks/track-changes.sh +101 -0
- package/.claude/hooks/validate-ontology-structure-summary.md +243 -0
- package/.claude/hooks/validate-ontology-structure.py +518 -0
- package/.claude/skills/INDEX.md +1 -1
- package/.claude/skills/ontology/README.md +1 -1
- package/CLAUDE.md +105 -0
- package/dist/commands/agent.d.ts +18 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +271 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-detection.d.ts +19 -0
- package/dist/lib/agent-detection.d.ts.map +1 -0
- package/dist/lib/agent-detection.js +87 -0
- package/dist/lib/agent-detection.js.map +1 -0
- package/dist/lib/detect.d.ts +45 -0
- package/dist/lib/detect.d.ts.map +1 -0
- package/dist/lib/detect.js +221 -0
- package/dist/lib/detect.js.map +1 -0
- package/llms.txt +257 -0
- package/one/knowledge/games-english.md +691 -0
- package/one/knowledge/games.md +1082 -0
- package/one/things/plans/npx-agent-safety.md +785 -0
- package/one/things/plans/npx-agent.md +1089 -0
- package/one/things/plans/remove-backend-development-from-agents.md +1331 -0
- package/package.json +3 -2
- package/.claude/commands/mcp-toggle.md +0 -93
- package/.claude/commands/npx.md +0 -84
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
ONE Platform - Done Hook
|
|
4
|
+
Marks current cycle complete and advances to next cycle.
|
|
5
|
+
|
|
6
|
+
This hook runs on Stop event to:
|
|
7
|
+
- Mark current cycle as complete
|
|
8
|
+
- Capture lessons learned (if any)
|
|
9
|
+
- Advance to next cycle
|
|
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
|
+
CYCLEENCE_TASKS,
|
|
22
|
+
get_dimensions_for_cycle,
|
|
23
|
+
get_specialist_for_cycle,
|
|
24
|
+
get_phase_for_cycle,
|
|
25
|
+
get_parallel_opportunities
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def load_state() -> Dict[str, Any]:
|
|
30
|
+
"""Load current cycle state from .claude/state/cycle.json"""
|
|
31
|
+
state_file = Path(os.environ.get("CLAUDE_PROJECT_DIR", ".")) / ".claude" / "state" / "cycle.json"
|
|
32
|
+
|
|
33
|
+
if not state_file.exists():
|
|
34
|
+
# Initialize default state
|
|
35
|
+
default_state = {
|
|
36
|
+
"current_cycle": 1,
|
|
37
|
+
"completed_cycles": [],
|
|
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 cycle state to .claude/state/cycle.json"""
|
|
50
|
+
state_file = Path(os.environ.get("CLAUDE_PROJECT_DIR", ".")) / ".claude" / "state" / "cycle.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, cycle: 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 Cycle {cycle}"
|
|
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 Cycle {cycle}"
|
|
83
|
+
|
|
84
|
+
except Exception as e:
|
|
85
|
+
return f"Completed Cycle {cycle} (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 cycle complete and advance to next"""
|
|
90
|
+
current = state["current_cycle"]
|
|
91
|
+
|
|
92
|
+
# Mark current cycle as complete
|
|
93
|
+
if current not in state["completed_cycles"]:
|
|
94
|
+
state["completed_cycles"].append(current)
|
|
95
|
+
state["completed_cycles"].sort()
|
|
96
|
+
|
|
97
|
+
# Extract lesson learned
|
|
98
|
+
lesson = extract_lesson_from_transcript(transcript_path, current)
|
|
99
|
+
state["lessons_learned"].append({
|
|
100
|
+
"cycle": current,
|
|
101
|
+
"lesson": lesson,
|
|
102
|
+
"timestamp": int(time.time()) # Unix timestamp
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
# Advance to next cycle (unless we're at 100)
|
|
106
|
+
if current < 100:
|
|
107
|
+
state["current_cycle"] = current + 1
|
|
108
|
+
else:
|
|
109
|
+
# Feature complete!
|
|
110
|
+
state["current_cycle"] = 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_cycle"] - 1 if state["current_cycle"] > 1 else 1
|
|
119
|
+
current = state["current_cycle"]
|
|
120
|
+
completed_count = len(state["completed_cycles"])
|
|
121
|
+
progress_pct = (completed_count / 100) * 100
|
|
122
|
+
|
|
123
|
+
# Get info for next cycle
|
|
124
|
+
task = CYCLEENCE_TASKS.get(current, "Unknown task")
|
|
125
|
+
phase = get_phase_for_cycle(current)
|
|
126
|
+
dimensions = get_dimensions_for_cycle(current)
|
|
127
|
+
specialist = get_specialist_for_cycle(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["cycle"] == previous and lesson["lesson"] != f"Completed Cycle {previous}":
|
|
135
|
+
recent_lesson = lesson["lesson"]
|
|
136
|
+
break
|
|
137
|
+
|
|
138
|
+
message = f"""
|
|
139
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
140
|
+
✅ CYCLEENCE COMPLETE: Cycle {previous}/100
|
|
141
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
142
|
+
|
|
143
|
+
**Progress:** {completed_count}/100 cycles 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 CYCLEENCE: Cycle {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 cycle complete (when finished)
|
|
168
|
+
/next - Skip to next cycle (if not applicable)
|
|
169
|
+
/reset - Start new feature (reset to Cycle 1)
|
|
170
|
+
/plan - View complete 100-cycle 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 Cycle {l['cycle']}"]
|
|
179
|
+
|
|
180
|
+
message = f"""
|
|
181
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
182
|
+
🎉 FEATURE COMPLETE: {state["feature_name"]}
|
|
183
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
184
|
+
|
|
185
|
+
**All 100 cycles 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/cycle.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()
|
|
@@ -0,0 +1,163 @@
|
|
|
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
|
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
CYCLE_STATE_FILE="${CLAUDE_PROJECT_DIR}/.claude/state/cycle.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 cycle context from state
|
|
16
|
+
get_cycle_context() {
|
|
17
|
+
if [ -f "$CYCLE_STATE_FILE" ]; then
|
|
18
|
+
local current_cycle=$(cat "$CYCLE_STATE_FILE" | grep -o '"current_cycle": [0-9]*' | awk '{print $2}')
|
|
19
|
+
echo "${current_cycle:-0}"
|
|
20
|
+
else
|
|
21
|
+
echo "0"
|
|
22
|
+
fi
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Function to map cycle number to dimension
|
|
26
|
+
# Based on 100-cycle sequence in one/knowledge/todo.md
|
|
27
|
+
get_cycle_dimension() {
|
|
28
|
+
local cycle="$1"
|
|
29
|
+
|
|
30
|
+
if [ "$cycle" -ge 1 ] && [ "$cycle" -le 10 ]; then
|
|
31
|
+
echo "foundation"
|
|
32
|
+
elif [ "$cycle" -ge 11 ] && [ "$cycle" -le 20 ]; then
|
|
33
|
+
echo "things" # Backend Schema & Services
|
|
34
|
+
elif [ "$cycle" -ge 21 ] && [ "$cycle" -le 30 ]; then
|
|
35
|
+
echo "things" # Frontend Pages & Components
|
|
36
|
+
elif [ "$cycle" -ge 31 ] && [ "$cycle" -le 40 ]; then
|
|
37
|
+
echo "connections" # Integration & Connections
|
|
38
|
+
elif [ "$cycle" -ge 41 ] && [ "$cycle" -le 50 ]; then
|
|
39
|
+
echo "people" # Authentication & Authorization
|
|
40
|
+
elif [ "$cycle" -ge 51 ] && [ "$cycle" -le 60 ]; then
|
|
41
|
+
echo "knowledge" # Knowledge & RAG
|
|
42
|
+
elif [ "$cycle" -ge 61 ] && [ "$cycle" -le 70 ]; then
|
|
43
|
+
echo "quality" # Quality & Testing
|
|
44
|
+
elif [ "$cycle" -ge 71 ] && [ "$cycle" -le 80 ]; then
|
|
45
|
+
echo "design" # Design & Wireframes
|
|
46
|
+
elif [ "$cycle" -ge 81 ] && [ "$cycle" -le 90 ]; then
|
|
47
|
+
echo "events" # Performance & Optimization
|
|
48
|
+
elif [ "$cycle" -ge 91 ] && [ "$cycle" -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 cycle=$(get_cycle_context)
|
|
99
|
+
local dimension=$(get_cycle_dimension "$cycle")
|
|
100
|
+
|
|
101
|
+
# Format: [timestamp] [level] [Cycle N] [dimension] message
|
|
102
|
+
echo "[$timestamp] [$level] [Cycle $cycle] [$dimension] $message" >> "$LOG_FILE"
|
|
103
|
+
|
|
104
|
+
if [ "$DEBUG_MODE" = "true" ]; then
|
|
105
|
+
echo "[$timestamp] [$level] [Cycle $cycle] [$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 cycle=$(get_cycle_context)
|
|
119
|
+
local dimension=$(get_cycle_dimension "$cycle")
|
|
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+="cycle=$cycle | "
|
|
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_cycle_context
|
|
168
|
+
export -f get_cycle_dimension
|
|
169
|
+
export -f get_specialist_agent
|
|
170
|
+
export LOG_FILE
|
|
171
|
+
export DEBUG_MODE
|
|
172
|
+
export CYCLE_STATE_FILE
|
|
173
|
+
export ONTOLOGY_VERSION
|