@ekkos/cli 0.2.9 → 0.2.10
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/dist/cache/LocalSessionStore.d.ts +34 -21
- package/dist/cache/LocalSessionStore.js +169 -53
- package/dist/cache/capture.d.ts +19 -11
- package/dist/cache/capture.js +243 -76
- package/dist/cache/types.d.ts +14 -1
- package/dist/commands/doctor.d.ts +10 -0
- package/dist/commands/doctor.js +148 -73
- package/dist/commands/hooks.d.ts +109 -0
- package/dist/commands/hooks.js +668 -0
- package/dist/commands/run.d.ts +1 -0
- package/dist/commands/run.js +69 -21
- package/dist/index.js +42 -1
- package/dist/restore/RestoreOrchestrator.d.ts +17 -3
- package/dist/restore/RestoreOrchestrator.js +64 -22
- package/dist/utils/paths.d.ts +125 -0
- package/dist/utils/paths.js +283 -0
- package/package.json +1 -1
- package/templates/ekkos-manifest.json +223 -0
- package/templates/helpers/json-parse.cjs +101 -0
- package/templates/hooks/assistant-response.ps1 +256 -0
- package/templates/hooks/assistant-response.sh +124 -64
- package/templates/hooks/session-start.ps1 +107 -2
- package/templates/hooks/session-start.sh +201 -166
- package/templates/hooks/stop.ps1 +124 -3
- package/templates/hooks/stop.sh +470 -843
- package/templates/hooks/user-prompt-submit.ps1 +107 -22
- package/templates/hooks/user-prompt-submit.sh +403 -393
- package/templates/project-stubs/session-start.ps1 +63 -0
- package/templates/project-stubs/session-start.sh +55 -0
- package/templates/project-stubs/stop.ps1 +63 -0
- package/templates/project-stubs/stop.sh +55 -0
- package/templates/project-stubs/user-prompt-submit.ps1 +63 -0
- package/templates/project-stubs/user-prompt-submit.sh +55 -0
- package/templates/shared/hooks-enabled.json +22 -0
- package/templates/shared/session-words.json +45 -0
package/templates/hooks/stop.ps1
CHANGED
|
@@ -1,14 +1,135 @@
|
|
|
1
1
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
-
# ekkOS_ Hook: Stop - Session cleanup (Windows)
|
|
2
|
+
# ekkOS_ Hook: Stop - Session cleanup and capture finalization (Windows)
|
|
3
|
+
# MANAGED BY ekkos-connect - DO NOT EDIT DIRECTLY
|
|
4
|
+
# EKKOS_MANAGED=1
|
|
5
|
+
# EKKOS_MANIFEST_SHA256=<computed-at-build>
|
|
6
|
+
# EKKOS_TEMPLATE_VERSION=1.0.0
|
|
7
|
+
#
|
|
8
|
+
# Per ekkOS Onboarding Spec v1.2 FINAL + ADDENDUM:
|
|
9
|
+
# - All persisted records MUST include: instanceId, sessionId, sessionName
|
|
10
|
+
# - Uses EKKOS_INSTANCE_ID env var for multi-session isolation
|
|
3
11
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
4
12
|
|
|
5
13
|
$ErrorActionPreference = "SilentlyContinue"
|
|
6
14
|
|
|
7
|
-
#
|
|
15
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
16
|
+
# CONFIG PATHS
|
|
17
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
18
|
+
$EkkosConfigDir = if ($env:EKKOS_CONFIG_DIR) { $env:EKKOS_CONFIG_DIR } else { "$env:USERPROFILE\.ekkos" }
|
|
19
|
+
$SessionWordsJson = "$EkkosConfigDir\session-words.json"
|
|
20
|
+
$SessionWordsDefault = "$EkkosConfigDir\.defaults\session-words.json"
|
|
21
|
+
|
|
22
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
23
|
+
# INSTANCE ID - Multi-session isolation per v1.2 ADDENDUM
|
|
24
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
25
|
+
$EkkosInstanceId = if ($env:EKKOS_INSTANCE_ID) { $env:EKKOS_INSTANCE_ID } else { "default" }
|
|
26
|
+
|
|
27
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
28
|
+
# Load session words from JSON file - NO HARDCODED ARRAYS
|
|
29
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
30
|
+
$script:SessionWords = $null
|
|
31
|
+
|
|
32
|
+
function Load-SessionWords {
|
|
33
|
+
$wordsFile = $SessionWordsJson
|
|
34
|
+
|
|
35
|
+
if (-not (Test-Path $wordsFile)) {
|
|
36
|
+
$wordsFile = $SessionWordsDefault
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (-not (Test-Path $wordsFile)) {
|
|
40
|
+
return $null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
$script:SessionWords = Get-Content $wordsFile -Raw | ConvertFrom-Json
|
|
45
|
+
} catch {
|
|
46
|
+
return $null
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function Convert-UuidToWords {
|
|
51
|
+
param([string]$uuid)
|
|
52
|
+
|
|
53
|
+
if (-not $script:SessionWords) {
|
|
54
|
+
Load-SessionWords
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (-not $script:SessionWords) {
|
|
58
|
+
return "unknown-session"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
$adjectives = $script:SessionWords.adjectives
|
|
62
|
+
$nouns = $script:SessionWords.nouns
|
|
63
|
+
$verbs = $script:SessionWords.verbs
|
|
64
|
+
|
|
65
|
+
if (-not $adjectives -or -not $nouns -or -not $verbs) {
|
|
66
|
+
return "unknown-session"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (-not $uuid -or $uuid -eq "unknown") { return "unknown-session" }
|
|
70
|
+
|
|
71
|
+
$clean = $uuid -replace "-", ""
|
|
72
|
+
if ($clean.Length -lt 6) { return "unknown-session" }
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
$a = [Convert]::ToInt32($clean.Substring(0,2), 16) % $adjectives.Length
|
|
76
|
+
$n = [Convert]::ToInt32($clean.Substring(2,2), 16) % $nouns.Length
|
|
77
|
+
$an = [Convert]::ToInt32($clean.Substring(4,2), 16) % $verbs.Length
|
|
78
|
+
|
|
79
|
+
return "$($adjectives[$a])-$($nouns[$n])-$($verbs[$an])"
|
|
80
|
+
} catch {
|
|
81
|
+
return "unknown-session"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
86
|
+
# READ INPUT
|
|
87
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
8
88
|
$inputJson = [Console]::In.ReadToEnd()
|
|
9
89
|
|
|
10
|
-
#
|
|
90
|
+
# Get session ID from state
|
|
11
91
|
$stateFile = Join-Path $env:USERPROFILE ".claude\state\hook-state.json"
|
|
92
|
+
$sessionFile = Join-Path $env:USERPROFILE ".claude\state\current-session.json"
|
|
93
|
+
$rawSessionId = "unknown"
|
|
94
|
+
$turn = 0
|
|
95
|
+
|
|
96
|
+
if (Test-Path $stateFile) {
|
|
97
|
+
try {
|
|
98
|
+
$hookState = Get-Content $stateFile -Raw | ConvertFrom-Json
|
|
99
|
+
$rawSessionId = $hookState.session_id
|
|
100
|
+
$turn = [int]$hookState.turn
|
|
101
|
+
} catch {}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if ($rawSessionId -eq "unknown" -and (Test-Path $sessionFile)) {
|
|
105
|
+
try {
|
|
106
|
+
$sessionData = Get-Content $sessionFile -Raw | ConvertFrom-Json
|
|
107
|
+
$rawSessionId = $sessionData.session_id
|
|
108
|
+
} catch {}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
$sessionName = Convert-UuidToWords $rawSessionId
|
|
112
|
+
|
|
113
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
114
|
+
# LOCAL CACHE: ACK turn to mark as synced
|
|
115
|
+
# Per v1.2 ADDENDUM: Pass instanceId for namespacing
|
|
116
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
117
|
+
$captureCmd = Get-Command "ekkos-capture" -ErrorAction SilentlyContinue
|
|
118
|
+
if ($captureCmd -and $rawSessionId -ne "unknown") {
|
|
119
|
+
try {
|
|
120
|
+
# ACK format: ekkos-capture ack <session_id> <turn_id> --instance=ID
|
|
121
|
+
Start-Job -ScriptBlock {
|
|
122
|
+
param($instanceId, $sessionId, $turnNum)
|
|
123
|
+
try {
|
|
124
|
+
& ekkos-capture ack $sessionId $turnNum "--instance=$instanceId" 2>&1 | Out-Null
|
|
125
|
+
} catch {}
|
|
126
|
+
} -ArgumentList $EkkosInstanceId, $rawSessionId, $turn | Out-Null
|
|
127
|
+
} catch {}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
131
|
+
# CLEAN UP STATE FILES
|
|
132
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
12
133
|
if (Test-Path $stateFile) {
|
|
13
134
|
Remove-Item $stateFile -Force
|
|
14
135
|
}
|