agent-recon 1.0.1
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/hooks/send-event-wsl.py +339 -0
- package/.claude/hooks/send-event.py +334 -0
- package/CHANGELOG.md +66 -0
- package/CONTRIBUTING.md +70 -0
- package/EULA.md +223 -0
- package/INSTALL.md +193 -0
- package/LICENSE +287 -0
- package/LICENSE-COMMERCIAL +241 -0
- package/PRIVACY.md +115 -0
- package/README.md +182 -0
- package/SECURITY.md +63 -0
- package/TERMS.md +233 -0
- package/install-service.ps1 +302 -0
- package/installer/cli.js +177 -0
- package/installer/detect.js +355 -0
- package/installer/install.js +195 -0
- package/installer/manifest.js +140 -0
- package/installer/package.json +12 -0
- package/installer/steps/api-keys.js +59 -0
- package/installer/steps/directory.js +41 -0
- package/installer/steps/env-report.js +48 -0
- package/installer/steps/hooks.js +149 -0
- package/installer/steps/service.js +159 -0
- package/installer/steps/tls.js +104 -0
- package/installer/steps/verify.js +117 -0
- package/installer/steps/welcome.js +46 -0
- package/installer/ui.js +133 -0
- package/installer/uninstall.js +233 -0
- package/installer/upgrade.js +289 -0
- package/package.json +58 -0
- package/public/index.html +13953 -0
- package/server/fixtures/allowlist-profiles.json +185 -0
- package/server/package.json +34 -0
- package/server/platform.js +270 -0
- package/server/rules/gitleaks.toml +3214 -0
- package/server/rules/security.yara +579 -0
- package/server/start.js +178 -0
- package/service/agent-recon.service +30 -0
- package/service/com.agent-recon.server.plist +56 -0
- package/setup-linux.sh +259 -0
- package/setup-macos.sh +264 -0
- package/setup-wsl.sh +248 -0
- package/setup.ps1 +171 -0
- package/start-agent-recon.bat +4 -0
package/setup.ps1
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#Requires -Version 5.1
|
|
2
|
+
<#
|
|
3
|
+
.SYNOPSIS
|
|
4
|
+
Installs Agent Recon hooks into the user-global Claude Code settings
|
|
5
|
+
so that ALL Claude Code sessions on this computer are tracked, regardless of
|
|
6
|
+
which project directory they run from.
|
|
7
|
+
|
|
8
|
+
.DESCRIPTION
|
|
9
|
+
1. Copies send-event.py to $HOME\.claude\hooks\
|
|
10
|
+
2. Auto-detects the Python executable (tries 'python', falls back to 'py')
|
|
11
|
+
3. Safely MERGES the 13 Agent Recon hook registrations into
|
|
12
|
+
$HOME\.claude\settings.json -- preserving any hooks you already have.
|
|
13
|
+
4. Writes the merged result back atomically.
|
|
14
|
+
|
|
15
|
+
.NOTES
|
|
16
|
+
Run once from the repo root: .\setup.ps1
|
|
17
|
+
Re-run any time to update the hook script or add missing hook entries.
|
|
18
|
+
#>
|
|
19
|
+
|
|
20
|
+
$ErrorActionPreference = 'Stop'
|
|
21
|
+
|
|
22
|
+
# -- Paths -------------------------------------------------------------------
|
|
23
|
+
$RepoRoot = $PSScriptRoot
|
|
24
|
+
$HookSrc = Join-Path $RepoRoot '.claude\hooks\send-event.py'
|
|
25
|
+
$GlobalHooksDir = Join-Path $HOME '.claude\hooks'
|
|
26
|
+
$GlobalHookScript = Join-Path $GlobalHooksDir 'send-event.py'
|
|
27
|
+
$GlobalSettings = Join-Path $HOME '.claude\settings.json'
|
|
28
|
+
|
|
29
|
+
# -- Detect Python -----------------------------------------------------------
|
|
30
|
+
Write-Host ''
|
|
31
|
+
Write-Host '[SEARCH] Detecting Python executable...' -ForegroundColor Cyan
|
|
32
|
+
$PythonExe = $null
|
|
33
|
+
|
|
34
|
+
foreach ($candidate in @('python', 'py')) {
|
|
35
|
+
$found = Get-Command $candidate -ErrorAction SilentlyContinue
|
|
36
|
+
if ($found) {
|
|
37
|
+
try {
|
|
38
|
+
$ver = (& $found.Source --version 2>&1).ToString()
|
|
39
|
+
if ($ver -match 'Python 3') {
|
|
40
|
+
$PythonExe = $found.Source
|
|
41
|
+
Write-Host " [OK] Found: $PythonExe ($ver)" -ForegroundColor Green
|
|
42
|
+
break
|
|
43
|
+
}
|
|
44
|
+
} catch { }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (-not $PythonExe) {
|
|
49
|
+
Write-Error "[FAIL] Could not find Python 3. Install Python 3 and ensure 'python' or 'py' is on your PATH."
|
|
50
|
+
exit 1
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# -- Copy / sync hook script --------------------------------------------------
|
|
54
|
+
Write-Host ''
|
|
55
|
+
Write-Host '[COPY] Installing hook script...' -ForegroundColor Cyan
|
|
56
|
+
if (-not (Test-Path $GlobalHooksDir)) {
|
|
57
|
+
New-Item -ItemType Directory -Path $GlobalHooksDir -Force | Out-Null
|
|
58
|
+
}
|
|
59
|
+
# Drift detection: only copy if the deployed script differs from the repo source
|
|
60
|
+
$needsCopy = $true
|
|
61
|
+
if (Test-Path $GlobalHookScript) {
|
|
62
|
+
$srcHash = (Get-FileHash $HookSrc -Algorithm SHA256).Hash
|
|
63
|
+
$dstHash = (Get-FileHash $GlobalHookScript -Algorithm SHA256).Hash
|
|
64
|
+
if ($srcHash -eq $dstHash) {
|
|
65
|
+
$needsCopy = $false
|
|
66
|
+
Write-Host " [OK] Hook script already up-to-date: $GlobalHookScript" -ForegroundColor Green
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if ($needsCopy) {
|
|
70
|
+
Copy-Item -Path $HookSrc -Destination $GlobalHookScript -Force
|
|
71
|
+
Write-Host " [OK] Synced to: $GlobalHookScript" -ForegroundColor Green
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# -- Build hook command string -----------------------------------------------
|
|
75
|
+
# Use full absolute paths so the hook fires from any working directory.
|
|
76
|
+
$HookCommand = '"' + $PythonExe + '" "' + $GlobalHookScript + '"'
|
|
77
|
+
|
|
78
|
+
# -- Load or initialise settings.json ----------------------------------------
|
|
79
|
+
Write-Host ''
|
|
80
|
+
Write-Host "[MERGE] Merging into: $GlobalSettings" -ForegroundColor Cyan
|
|
81
|
+
|
|
82
|
+
$settings = $null
|
|
83
|
+
if (Test-Path $GlobalSettings) {
|
|
84
|
+
$raw = Get-Content -Path $GlobalSettings -Raw -Encoding UTF8
|
|
85
|
+
try {
|
|
86
|
+
$settings = $raw | ConvertFrom-Json
|
|
87
|
+
} catch {
|
|
88
|
+
$backup = $GlobalSettings + '.bak_' + (Get-Date -Format 'yyyyMMdd_HHmmss')
|
|
89
|
+
Copy-Item $GlobalSettings $backup
|
|
90
|
+
Write-Host " [WARN] Could not parse existing settings.json -- backed up to:" -ForegroundColor Yellow
|
|
91
|
+
Write-Host " $backup" -ForegroundColor Yellow
|
|
92
|
+
$settings = $null
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ($null -eq $settings) {
|
|
97
|
+
$settings = New-Object PSObject
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# Ensure top-level 'hooks' property exists
|
|
101
|
+
if (-not ($settings | Get-Member -Name 'hooks' -MemberType NoteProperty -ErrorAction SilentlyContinue)) {
|
|
102
|
+
$settings | Add-Member -NotePropertyName 'hooks' -NotePropertyValue (New-Object PSObject)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# -- Events to register ------------------------------------------------------
|
|
106
|
+
$allEvents = @(
|
|
107
|
+
'SessionStart', 'SessionEnd', 'UserPromptSubmit',
|
|
108
|
+
'SubagentStart', 'SubagentStop', 'Stop',
|
|
109
|
+
'TeammateIdle', 'TaskCompleted',
|
|
110
|
+
'PreToolUse', 'PostToolUse', 'PostToolUseFailure',
|
|
111
|
+
'Notification', 'PreCompact'
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
$added = 0
|
|
115
|
+
$skipped = 0
|
|
116
|
+
|
|
117
|
+
foreach ($eventName in $allEvents) {
|
|
118
|
+
$hooksObj = $settings.hooks
|
|
119
|
+
|
|
120
|
+
$alreadyPresent = $false
|
|
121
|
+
if ($hooksObj | Get-Member -Name $eventName -MemberType NoteProperty -ErrorAction SilentlyContinue) {
|
|
122
|
+
$existing = $hooksObj.$eventName
|
|
123
|
+
foreach ($group in $existing) {
|
|
124
|
+
if ($group | Get-Member -Name 'hooks' -MemberType NoteProperty -ErrorAction SilentlyContinue) {
|
|
125
|
+
foreach ($h in $group.hooks) {
|
|
126
|
+
if (($h | Get-Member -Name 'command' -MemberType NoteProperty -ErrorAction SilentlyContinue) -and
|
|
127
|
+
$h.command -eq $HookCommand) {
|
|
128
|
+
$alreadyPresent = $true
|
|
129
|
+
break
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if ($alreadyPresent) { break }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if ($alreadyPresent) {
|
|
138
|
+
$skipped++
|
|
139
|
+
} else {
|
|
140
|
+
$newHook = [PSCustomObject]@{ type = 'command'; command = $HookCommand; async = $true; timeout = 10 }
|
|
141
|
+
$newGroup = [PSCustomObject]@{ hooks = @($newHook) }
|
|
142
|
+
|
|
143
|
+
if ($hooksObj | Get-Member -Name $eventName -MemberType NoteProperty -ErrorAction SilentlyContinue) {
|
|
144
|
+
# Append to existing list
|
|
145
|
+
$hooksObj.$eventName = @($hooksObj.$eventName) + @($newGroup)
|
|
146
|
+
} else {
|
|
147
|
+
$hooksObj | Add-Member -NotePropertyName $eventName -NotePropertyValue @($newGroup)
|
|
148
|
+
}
|
|
149
|
+
$added++
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# -- Write atomically --------------------------------------------------------
|
|
154
|
+
$json = $settings | ConvertTo-Json -Depth 20
|
|
155
|
+
$tmp = $GlobalSettings + '.tmp'
|
|
156
|
+
[System.IO.File]::WriteAllText($tmp, $json, [System.Text.Encoding]::UTF8)
|
|
157
|
+
Move-Item -Path $tmp -Destination $GlobalSettings -Force
|
|
158
|
+
|
|
159
|
+
Write-Host " [OK] Added $added hook(s), skipped $skipped already-present." -ForegroundColor Green
|
|
160
|
+
|
|
161
|
+
Write-Host ''
|
|
162
|
+
Write-Host '+----------------------------------------------------------+' -ForegroundColor Cyan
|
|
163
|
+
Write-Host '| Agent Recon -- Global Hooks Installed |' -ForegroundColor Cyan
|
|
164
|
+
Write-Host '| |' -ForegroundColor Cyan
|
|
165
|
+
Write-Host '| Every Claude Code session on this machine will now |' -ForegroundColor Cyan
|
|
166
|
+
Write-Host '| forward events to http://localhost:3131 |' -ForegroundColor Cyan
|
|
167
|
+
Write-Host '| |' -ForegroundColor Cyan
|
|
168
|
+
Write-Host '| Start the server: cd server ; node start.js |' -ForegroundColor Cyan
|
|
169
|
+
Write-Host '| Open dashboard: http://localhost:3131 |' -ForegroundColor Cyan
|
|
170
|
+
Write-Host '+----------------------------------------------------------+' -ForegroundColor Cyan
|
|
171
|
+
Write-Host ''
|