-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger.ps1
More file actions
79 lines (63 loc) · 3.48 KB
/
trigger.ps1
File metadata and controls
79 lines (63 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Test ADHD Trigger System
# Run this to see exactly how the trigger system behaves
# Get current time components
$now = Get-Date
$sessionStart = [datetime]::Parse("2000-01-01 00:00:01") # Replace with actual session start
$minutesElapsed = [int]($now - $sessionStart).TotalMinutes
Write-Host "=== ADHD Trigger System Test ===" -ForegroundColor Cyan
Write-Host "Current Time: $($now.ToString('yyyy-MM-dd HH:mm:ss'))" -ForegroundColor Yellow
Write-Host "Session Start: $($sessionStart.ToString('yyyy-MM-dd HH:mm:ss'))" -ForegroundColor Yellow
Write-Host "Minutes Elapsed: $minutesElapsed" -ForegroundColor Yellow
# Log all actions
$logDir = "..\study_logs\logs"
$logPath = Join-Path $logDir "trigger-log-$(Get-Date -Format 'yyyy-MM-dd-HHmmss').md"
$logContent = @"
# ADHD Trigger System Log
## Session Info
- **Date**: $(Get-Date -Format 'yyyy-MM-dd')
- **Time**: $(Get-Date -Format 'HH:mm:ss')
- **Session Start**: $($sessionStart.ToString('yyyy-MM-dd HH:mm:ss'))
- **Minutes Elapsed**: $minutesElapsed
## Trigger Analysis
"@
# Check if sustained session (10+ minutes) and interval passed
$interval = ($sessionStart.Minute % 3) + 3
Write-Host "`n=== Analysis ===" -ForegroundColor Cyan
Write-Host "Interval: $interval minutes" -ForegroundColor White
Write-Host "Sustained Session (10+ min): $(if($minutesElapsed -ge 10) {'YES'} else {'NO'})" -ForegroundColor $(if($minutesElapsed -ge 10) {'Green'} else {'Red'})
Write-Host "Interval Check: $(if($minutesElapsed % $interval -eq 0) {'PASS'} else {'FAIL'})" -ForegroundColor $(if($minutesElapsed % $interval -eq 0) {'Green'} else {'Red'})
$logContent += "`n- **Interval**: $interval minutes"
$logContent += "`n- **Sustained Session**: $(if($minutesElapsed -ge 10) {'YES'} else {'NO'})"
$logContent += "`n- **Interval Check**: $(if($minutesElapsed % $interval -eq 0) {'PASS'} else {'FAIL'})"
if ($minutesElapsed -ge 10 -and $minutesElapsed % $interval -eq 0) {
# Check for recent logs (within last 3 minutes)
$recentLogs = Get-ChildItem -Path $logDir -Filter "*.md" | Where-Object { $_.LastWriteTime -gt $now.AddMinutes(-3) }
Write-Host "`n=== Recent Logs Check ===" -ForegroundColor Cyan
Write-Host "Recent logs found: $($recentLogs.Count)" -ForegroundColor White
$logContent += "`n- **Recent Logs Found**: $($recentLogs.Count)"
if ($recentLogs.Count -eq 0) {
# Select card deterministically
$cardNumber = (($sessionStart.Minute + $now.Minute) % 66) + 1
Write-Host "`n=== DECISION ===" -ForegroundColor Green
Write-Host "TRIGGER: $cardNumber" -ForegroundColor Green
Write-Host "Card Selected: $cardNumber" -ForegroundColor Green
$logContent += "`n- **Decision**: TRIGGER:$cardNumber"
$logContent += "`n- **Card Selected**: $cardNumber"
Write-Output "TRIGGER:$cardNumber"
} else {
Write-Host "`n=== DECISION ===" -ForegroundColor Yellow
Write-Host "SKIP: Recent tip found" -ForegroundColor Yellow
$logContent += "`n- **Decision**: SKIP:Recent"
Write-Output "SKIP:Recent"
}
} else {
Write-Host "`n=== DECISION ===" -ForegroundColor Red
Write-Host "SKIP: Timing conditions not met" -ForegroundColor Red
$logContent += "`n- **Decision**: SKIP:Timing"
Write-Output "SKIP:Timing"
}
# Write log file
$logContent += "`n`n---`n*Auto-generated by ADHD Trigger System*"
$logContent | Out-File -FilePath $logPath -Encoding UTF8
Write-Host "`n=== Log Created ===" -ForegroundColor Cyan
Write-Host "Log file: $logPath" -ForegroundColor White