oneie 3.6.18 → 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.
Files changed (36) hide show
  1. package/.claude/agents/agent-ops.md +63 -2
  2. package/.claude/commands/commit.md +95 -0
  3. package/.claude/commands/npx.md +2 -2
  4. package/.claude/commands/one.md +7 -1
  5. package/.claude/commands/push.md +113 -21
  6. package/.claude/commands/release.md +2 -2
  7. package/.claude/hooks/release-cli.sh +195 -0
  8. package/CLAUDE.md +119 -0
  9. package/README.md +778 -497
  10. package/package.json +1 -1
  11. package/.claude/agents/NEWS-QUICKSTART.md +0 -321
  12. package/.claude/agents/NEWS-README.md +0 -353
  13. package/.claude/hooks/README-knowledge-hooks.md +0 -451
  14. package/.claude/hooks/README-root-cleanup.md +0 -200
  15. package/.claude/hooks/README.md +0 -284
  16. package/.claude/hooks/__pycache__/done.cpython-313.pyc +0 -0
  17. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  18. package/.claude/hooks/check-filenames.py +0 -177
  19. package/.claude/hooks/clean-post.py +0 -468
  20. package/.claude/hooks/clean-pre.py +0 -393
  21. package/.claude/hooks/clean-root-markdown.sh +0 -73
  22. package/.claude/hooks/done.py +0 -236
  23. package/.claude/hooks/format-hook.sh +0 -163
  24. package/.claude/hooks/hook-logger.sh +0 -173
  25. package/.claude/hooks/knowledge-post.py +0 -355
  26. package/.claude/hooks/knowledge-pre.py +0 -245
  27. package/.claude/hooks/notification-hook.sh +0 -279
  28. package/.claude/hooks/root-cleanup.py +0 -217
  29. package/.claude/hooks/security-hook.sh +0 -397
  30. package/.claude/hooks/tag-all-docs.py +0 -464
  31. package/.claude/hooks/test-validate-ontology.sh +0 -170
  32. package/.claude/hooks/todo.py +0 -368
  33. package/.claude/hooks/track-changes.sh +0 -101
  34. package/.claude/hooks/validate-ontology-structure-summary.md +0 -243
  35. package/.claude/hooks/validate-ontology-structure.py +0 -518
  36. package/TESTING-ONBOARDING.md +0 -185
@@ -1,397 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Security Hook - ONE Platform
4
- # Protects sensitive files and scans for credentials
5
- # Enforces 6-dimension ontology security patterns
6
-
7
- set -e
8
-
9
- # Get project directory
10
- SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
11
- CLAUDE_PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
12
-
13
- # Source the logger
14
- source "$CLAUDE_PROJECT_DIR/.claude/hooks/hook-logger.sh"
15
-
16
- # Configuration
17
- FILE_PATH="${1:-}"
18
- MODE="${2:-protect}" # protect, scan, audit, ontology
19
- ACTION="${3:-warn}" # warn, block, log
20
-
21
- # Sensitive file patterns
22
- SENSITIVE_PATTERNS=(
23
- "**/.env*"
24
- "**/secrets/**"
25
- "**/*secret*"
26
- "**/.ssh/**"
27
- "**/*.pem"
28
- "**/*.p12"
29
- "**/credentials/**"
30
- "**/*token*"
31
- "**/*apikey*"
32
- "**/*private*"
33
- "**/installation/**/secrets/**"
34
- )
35
-
36
- # Credential regex patterns
37
- CREDENTIAL_PATTERNS=(
38
- "api[_-]?key[s]?\s*[:=]\s*['\"]?[a-zA-Z0-9_-]{16,}"
39
- "secret[_-]?key[s]?\s*[:=]\s*['\"]?[a-zA-Z0-9_-]{16,}"
40
- "password[s]?\s*[:=]\s*['\"]?[a-zA-Z0-9!@#$%^&*()_+-=]{8,}"
41
- "Bearer [a-zA-Z0-9_.-]{16,}"
42
- "mongodb://[a-zA-Z0-9_:/@.-]+"
43
- "postgres://[a-zA-Z0-9_:/@.-]+"
44
- "CLOUDFLARE_[A-Z_]*=.*"
45
- "CONVEX_[A-Z_]*=.*"
46
- "RESEND_[A-Z_]*=.*"
47
- )
48
-
49
- # 6-DIMENSION ONTOLOGY SECURITY PATTERNS
50
- # Validates code follows security patterns for each dimension
51
-
52
- # GROUPS: Multi-tenant isolation patterns
53
- GROUPS_PATTERNS=(
54
- "groupId:\s*v\.id\(\"groups\"\)" # groupId required in args
55
- "\.get\(args\.groupId\)" # Group validation
56
- "group\.status\s*!==\s*['\"]active['\"]" # Active group check
57
- "withIndex\(['\"]group_" # Group-scoped indexes
58
- )
59
-
60
- # PEOPLE: Authorization patterns
61
- PEOPLE_PATTERNS=(
62
- "ctx\.auth\.getUserIdentity\(\)" # Authentication check
63
- "if\s*\(!identity\)" # Auth validation
64
- "properties\.role" # Role checking
65
- "properties\.userId" # User identity linking
66
- )
67
-
68
- # THINGS: Entity permission patterns
69
- THINGS_PATTERNS=(
70
- "isThingType\(args\.type\)" # Type validation
71
- "thing\.groupId\s*!==\s*args\.groupId" # Group ownership check
72
- "\.get\(.*entityId" # Entity access validation
73
- )
74
-
75
- # CONNECTIONS: Relationship authorization patterns
76
- CONNECTIONS_PATTERNS=(
77
- "isConnectionType\(args\.relationshipType\)" # Type validation
78
- "fromEntityId.*toEntityId" # Bidirectional validation
79
- "validateConnection" # Connection validator
80
- )
81
-
82
- # EVENTS: Actor tracking patterns
83
- EVENTS_PATTERNS=(
84
- "actorId:\s*actor\._id" # Actor logging
85
- "await ctx\.db\.insert\(['\"]events['\"]" # Event creation
86
- "type:\s*['\"].*_(created|updated|deleted)" # Event type pattern
87
- "timestamp:\s*Date\.now\(\)" # Timestamp required
88
- )
89
-
90
- # KNOWLEDGE: Embedding security patterns
91
- KNOWLEDGE_PATTERNS=(
92
- "embedding:\s*v\.optional" # Vector storage
93
- "groupId:\s*v\.id\(\"groups\"\)" # Knowledge scoped to groups
94
- "sourceThingId" # Source tracking
95
- )
96
-
97
- # Log start
98
- log_message "INFO" "security-hook: $MODE mode for ${FILE_PATH:-all files}"
99
- START_TIME=$(get_time_ms)
100
-
101
- # Check if file matches sensitive patterns
102
- is_sensitive_file() {
103
- local file="$1"
104
-
105
- for pattern in "${SENSITIVE_PATTERNS[@]}"; do
106
- # Convert glob to regex
107
- local regex=$(echo "$pattern" | sed 's/\*\*/.*/' | sed 's/\*/[^\/]*/')
108
- if [[ "$file" =~ $regex ]]; then
109
- return 0
110
- fi
111
- done
112
- return 1
113
- }
114
-
115
- # Scan file content for credentials
116
- scan_credentials() {
117
- local file="$1"
118
-
119
- if [ ! -f "$file" ]; then
120
- return 0
121
- fi
122
-
123
- local found=0
124
- for pattern in "${CREDENTIAL_PATTERNS[@]}"; do
125
- if grep -qE "$pattern" "$file" 2>/dev/null; then
126
- local line_num=$(grep -nE "$pattern" "$file" | head -1 | cut -d: -f1)
127
- echo "⚠️ Line $line_num: Potential credential detected"
128
- log_message "WARN" "Credential pattern in $file:$line_num"
129
- found=1
130
- fi
131
- done
132
-
133
- return $found
134
- }
135
-
136
- # Validate ontology security patterns for a specific dimension
137
- validate_dimension() {
138
- local file="$1"
139
- local dimension="$2"
140
-
141
- if [ ! -f "$file" ]; then
142
- return 0
143
- fi
144
-
145
- local violations=0
146
-
147
- # Only check TypeScript files in backend/convex
148
- if [[ ! "$file" =~ backend/convex/.*\.(ts|js)$ ]]; then
149
- return 0
150
- fi
151
-
152
- # Detect if file is a mutation (requires stricter checks)
153
- local is_mutation=0
154
- if [[ "$file" =~ mutations/ ]]; then
155
- is_mutation=1
156
- fi
157
-
158
- # Check for required patterns based on dimension
159
- case "$dimension" in
160
- "GROUPS")
161
- # Mutations must validate groupId
162
- if [ $is_mutation -eq 1 ]; then
163
- if ! grep -q "groupId:" "$file" 2>/dev/null; then
164
- echo "❌ GROUPS: Missing groupId parameter in mutation"
165
- violations=1
166
- fi
167
- if ! grep -qE "\.get\(.*groupId\)" "$file" 2>/dev/null; then
168
- echo "⚠️ GROUPS: No group validation detected"
169
- violations=1
170
- fi
171
- fi
172
- ;;
173
- "PEOPLE")
174
- # Mutations must authenticate
175
- if [ $is_mutation -eq 1 ]; then
176
- if ! grep -q "getUserIdentity()" "$file" 2>/dev/null; then
177
- echo "❌ PEOPLE: Missing authentication check in mutation"
178
- violations=1
179
- fi
180
- fi
181
- ;;
182
- "EVENTS")
183
- # Mutations creating/updating entities should log events
184
- if [ $is_mutation -eq 1 ]; then
185
- if grep -qE "ctx\.db\.insert\(['\"]entities['\"]" "$file" 2>/dev/null; then
186
- if ! grep -qE "ctx\.db\.insert\(['\"]events['\"]" "$file" 2>/dev/null; then
187
- echo "⚠️ EVENTS: Entity mutation without event logging"
188
- violations=1
189
- fi
190
- if ! grep -q "actorId:" "$file" 2>/dev/null; then
191
- echo "⚠️ EVENTS: Event logging without actorId"
192
- violations=1
193
- fi
194
- fi
195
- fi
196
- ;;
197
- esac
198
-
199
- return $violations
200
- }
201
-
202
- # Comprehensive ontology security scan
203
- scan_ontology_security() {
204
- local file="$1"
205
-
206
- if [ ! -f "$file" ]; then
207
- return 0
208
- fi
209
-
210
- # Only check backend TypeScript files
211
- if [[ ! "$file" =~ backend/convex/.*\.(ts|js)$ ]]; then
212
- return 0
213
- fi
214
-
215
- echo "🔒 Scanning ontology security patterns: $file"
216
-
217
- local violations=0
218
-
219
- # Check each dimension
220
- validate_dimension "$file" "GROUPS" GROUPS_PATTERNS
221
- violations=$((violations + $?))
222
-
223
- validate_dimension "$file" "PEOPLE" PEOPLE_PATTERNS
224
- violations=$((violations + $?))
225
-
226
- validate_dimension "$file" "EVENTS" EVENTS_PATTERNS
227
- violations=$((violations + $?))
228
-
229
- # Check for cross-group data leakage patterns (CRITICAL)
230
- if grep -qE "ctx\.db\.query\(['\"]entities['\"]\)" "$file" 2>/dev/null; then
231
- if ! grep -q "withIndex" "$file" 2>/dev/null; then
232
- echo "❌ CRITICAL: Unscoped query detected (potential data leakage)"
233
- echo " Use .withIndex('group_type', ...) to scope by groupId"
234
- violations=$((violations + 1))
235
- fi
236
- fi
237
-
238
- # Check for missing soft delete filtering
239
- if grep -qE "ctx\.db\.query\(['\"]entities['\"]\)" "$file" 2>/dev/null; then
240
- if ! grep -q "deletedAt" "$file" 2>/dev/null; then
241
- echo "⚠️ WARNING: Query may return soft-deleted entities"
242
- echo " Add .filter(q => q.eq(q.field('deletedAt'), undefined))"
243
- violations=$((violations + 1))
244
- fi
245
- fi
246
-
247
- if [ $violations -eq 0 ]; then
248
- echo "✅ Ontology security patterns validated"
249
- else
250
- log_message "WARN" "Ontology violations in $file: $violations"
251
- fi
252
-
253
- return $violations
254
- }
255
-
256
- # Create audit entry
257
- audit() {
258
- local file="$1"
259
- local event="$2"
260
- local action="$3"
261
-
262
- local audit_file="$CLAUDE_PROJECT_DIR/.claude/security-audit.log"
263
- local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
264
-
265
- echo "[$timestamp] $event | $file | $action" >> "$audit_file"
266
- }
267
-
268
- EXIT_CODE=0
269
-
270
- case "$MODE" in
271
- "protect")
272
- if [ -n "$FILE_PATH" ] && is_sensitive_file "$FILE_PATH"; then
273
- case "$ACTION" in
274
- "block")
275
- echo "🚫 BLOCKED: Cannot modify sensitive file: $FILE_PATH"
276
- log_message "ERROR" "Blocked: $FILE_PATH"
277
- audit "$FILE_PATH" "BLOCKED" "sensitive file"
278
- EXIT_CODE=2
279
- ;;
280
- "warn")
281
- echo "⚠️ WARNING: Modifying sensitive file: $FILE_PATH"
282
- echo " Ensure no secrets are being committed"
283
- log_message "WARN" "Sensitive file modified: $FILE_PATH"
284
- audit "$FILE_PATH" "WARNED" "sensitive file"
285
- ;;
286
- "log")
287
- log_message "INFO" "Sensitive file access: $FILE_PATH"
288
- audit "$FILE_PATH" "LOGGED" "sensitive file"
289
- ;;
290
- esac
291
- fi
292
- ;;
293
-
294
- "scan")
295
- if [ -n "$FILE_PATH" ] && [ -f "$FILE_PATH" ]; then
296
- echo "🔍 Scanning $FILE_PATH for credentials..."
297
- if ! scan_credentials "$FILE_PATH"; then
298
- echo "✅ No credentials detected"
299
- audit "$FILE_PATH" "SCAN_PASSED" "clean"
300
- else
301
- audit "$FILE_PATH" "SCAN_FAILED" "credentials found"
302
- if [ "$ACTION" = "block" ]; then
303
- EXIT_CODE=2
304
- fi
305
- fi
306
- fi
307
- ;;
308
-
309
- "ontology")
310
- if [ -n "$FILE_PATH" ] && [ -f "$FILE_PATH" ]; then
311
- echo "🔒 Validating ontology security patterns..."
312
- if ! scan_ontology_security "$FILE_PATH"; then
313
- audit "$FILE_PATH" "ONTOLOGY_PASSED" "compliant"
314
- else
315
- echo ""
316
- echo "📖 Ontology Security Reference:"
317
- echo " GROUPS: All mutations must validate groupId and check group.status === 'active'"
318
- echo " PEOPLE: All mutations must call ctx.auth.getUserIdentity() and check authentication"
319
- echo " THINGS: Use isThingType() to validate entity types from ontology"
320
- echo " CONNECTIONS: Validate both fromEntityId and toEntityId belong to same group"
321
- echo " EVENTS: Log events with actorId after successful mutations"
322
- echo " KNOWLEDGE: Scope embeddings to groupId and track sourceThingId"
323
- echo ""
324
- echo " For details, see: one/knowledge/ontology.md"
325
- audit "$FILE_PATH" "ONTOLOGY_VIOLATIONS" "security issues found"
326
- if [ "$ACTION" = "block" ]; then
327
- EXIT_CODE=2
328
- else
329
- EXIT_CODE=1
330
- fi
331
- fi
332
- else
333
- echo "❌ File not found: $FILE_PATH"
334
- EXIT_CODE=1
335
- fi
336
- ;;
337
-
338
- "audit")
339
- echo "📋 Security Audit Summary"
340
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
341
- echo ""
342
- echo "6-DIMENSION ONTOLOGY SECURITY MODEL"
343
- echo "───────────────────────────────────────"
344
- echo "1. GROUPS: Multi-tenant isolation (groupId scoping)"
345
- echo "2. PEOPLE: Authentication & authorization (role-based access)"
346
- echo "3. THINGS: Entity permissions (type validation)"
347
- echo "4. CONNECTIONS: Relationship authorization (bidirectional validation)"
348
- echo "5. EVENTS: Actor tracking (audit trail)"
349
- echo "6. KNOWLEDGE: Embedding security (source tracking)"
350
- echo ""
351
-
352
- AUDIT_FILE="$CLAUDE_PROJECT_DIR/.claude/security-audit.log"
353
-
354
- if [ -f "$AUDIT_FILE" ]; then
355
- echo "Recent security events (last 10):"
356
- echo "───────────────────────────────────────"
357
- tail -10 "$AUDIT_FILE"
358
- echo ""
359
- echo "Statistics:"
360
- echo "───────────────────────────────────────"
361
- echo " Blocked: $(grep -c "BLOCKED" "$AUDIT_FILE" 2>/dev/null || echo 0)"
362
- echo " Warned: $(grep -c "WARNED" "$AUDIT_FILE" 2>/dev/null || echo 0)"
363
- echo " Credential scans failed: $(grep -c "SCAN_FAILED" "$AUDIT_FILE" 2>/dev/null || echo 0)"
364
- echo " Ontology violations: $(grep -c "ONTOLOGY_VIOLATIONS" "$AUDIT_FILE" 2>/dev/null || echo 0)"
365
- echo " Ontology compliant: $(grep -c "ONTOLOGY_PASSED" "$AUDIT_FILE" 2>/dev/null || echo 0)"
366
- else
367
- echo "No audit log found"
368
- echo "Run security scans to generate audit trail"
369
- fi
370
- echo ""
371
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
372
- ;;
373
-
374
- *)
375
- echo "❌ Unknown security mode: $MODE"
376
- echo ""
377
- echo "Usage: security-hook.sh <file> <mode> <action>"
378
- echo ""
379
- echo "Modes:"
380
- echo " protect - Protect sensitive files from modification"
381
- echo " scan - Scan files for hardcoded credentials"
382
- echo " ontology - Validate 6-dimension ontology security patterns"
383
- echo " audit - Display security audit summary"
384
- echo ""
385
- echo "Actions:"
386
- echo " warn - Display warnings (default)"
387
- echo " block - Block operations that fail validation"
388
- echo " log - Log events only"
389
- EXIT_CODE=1
390
- ;;
391
- esac
392
-
393
- # Log completion
394
- END_TIME=$(get_time_ms)
395
- log_hook_execution "security-hook" "$MODE $FILE_PATH" "$START_TIME" "$END_TIME" "$EXIT_CODE"
396
-
397
- exit $EXIT_CODE