@ekkos/cli 1.2.17 → 1.3.0

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 (47) hide show
  1. package/dist/cache/capture.js +0 -0
  2. package/dist/commands/dashboard.js +57 -49
  3. package/dist/commands/hooks.d.ts +25 -36
  4. package/dist/commands/hooks.js +43 -615
  5. package/dist/commands/init.js +7 -23
  6. package/dist/commands/run.js +97 -11
  7. package/dist/commands/setup.js +10 -352
  8. package/dist/deploy/hooks.d.ts +8 -5
  9. package/dist/deploy/hooks.js +12 -105
  10. package/dist/deploy/settings.d.ts +8 -2
  11. package/dist/deploy/settings.js +22 -51
  12. package/dist/index.js +17 -39
  13. package/dist/utils/state.js +7 -2
  14. package/package.json +1 -1
  15. package/templates/CLAUDE.md +82 -292
  16. package/templates/cursor-rules/ekkos-memory.md +48 -108
  17. package/templates/windsurf-rules/ekkos-memory.md +62 -64
  18. package/templates/cursor-hooks/after-agent-response.sh +0 -117
  19. package/templates/cursor-hooks/before-submit-prompt.sh +0 -419
  20. package/templates/cursor-hooks/hooks.json +0 -20
  21. package/templates/cursor-hooks/lib/contract.sh +0 -320
  22. package/templates/cursor-hooks/stop.sh +0 -75
  23. package/templates/hooks/assistant-response.ps1 +0 -256
  24. package/templates/hooks/assistant-response.sh +0 -160
  25. package/templates/hooks/hooks.json +0 -40
  26. package/templates/hooks/lib/contract.sh +0 -332
  27. package/templates/hooks/lib/count-tokens.cjs +0 -86
  28. package/templates/hooks/lib/ekkos-reminders.sh +0 -98
  29. package/templates/hooks/lib/state.sh +0 -210
  30. package/templates/hooks/session-start.ps1 +0 -146
  31. package/templates/hooks/session-start.sh +0 -353
  32. package/templates/hooks/stop.ps1 +0 -349
  33. package/templates/hooks/stop.sh +0 -382
  34. package/templates/hooks/user-prompt-submit.ps1 +0 -419
  35. package/templates/hooks/user-prompt-submit.sh +0 -516
  36. package/templates/project-stubs/session-start.ps1 +0 -63
  37. package/templates/project-stubs/session-start.sh +0 -55
  38. package/templates/project-stubs/stop.ps1 +0 -63
  39. package/templates/project-stubs/stop.sh +0 -55
  40. package/templates/project-stubs/user-prompt-submit.ps1 +0 -63
  41. package/templates/project-stubs/user-prompt-submit.sh +0 -55
  42. package/templates/windsurf-hooks/README.md +0 -212
  43. package/templates/windsurf-hooks/hooks.json +0 -17
  44. package/templates/windsurf-hooks/install.sh +0 -148
  45. package/templates/windsurf-hooks/lib/contract.sh +0 -322
  46. package/templates/windsurf-hooks/post-cascade-response.sh +0 -251
  47. package/templates/windsurf-hooks/pre-user-prompt.sh +0 -435
@@ -1,24 +1,23 @@
1
1
  ---
2
- description: "ekkOS Memory - 11-layer cognitive memory with 31 MCP tools"
2
+ description: "ekkOS Memory 11-layer cognitive memory with 29 MCP tools"
3
3
  alwaysApply: true
4
4
  ---
5
5
 
6
6
  # ekkOS Memory System
7
7
 
8
- You have access to **ekkOS memory** via 31 MCP tools. This is an 11-layer cognitive memory system that makes AI smarter over time by learning from past sessions.
8
+ You have access to **ekkOS memory** via 29 MCP tools. This is an 11-layer cognitive memory system that makes AI smarter over time by learning from past sessions.
9
9
 
10
10
  ## MANDATORY RULES
11
11
 
12
12
  ### RULE 1: SEARCH BEFORE ANSWERING
13
13
  Before answering ANY technical question, call `ekkOS_Search` first.
14
- Do not skip this. Do not assume you know the answer.
15
14
 
16
15
  ### RULE 2: ACKNOWLEDGE RETRIEVED PATTERNS
17
16
  When patterns are retrieved, acknowledge each one:
18
17
  ```
19
18
  [ekkOS_SELECT]
20
19
  - id: <pattern_id>
21
- reason: <why using this>
20
+ reason: <why using>
22
21
  confidence: <0.0-1.0>
23
22
  [/ekkOS_SELECT]
24
23
 
@@ -28,64 +27,66 @@ When patterns are retrieved, acknowledge each one:
28
27
  [/ekkOS_SKIP]
29
28
  ```
30
29
 
30
+ Suppress SELECT/SKIP blocks for non-technical turns (acknowledgments, affirmations).
31
+
31
32
  ### RULE 3: FORGE WHAT YOU LEARN
32
33
  When you fix a bug, get corrected, or learn something new, call `ekkOS_Forge` immediately.
34
+ When something DOESN'T work, forge it as an anti-pattern.
33
35
 
34
- ### RULE 4: FAILURES ARE VALUABLE
35
- When something DOES NOT work, forge it as an anti-pattern.
36
-
37
- ## MCP Tools (31 Total)
36
+ ## MCP Tools 29 Visible
38
37
 
39
- ### Core Memory Tools
38
+ ### Core Memory (6)
40
39
  | Tool | Description |
41
40
  |------|-------------|
42
41
  | `ekkOS_Search` | Search across all 11 memory layers |
43
- | `ekkOS_Context` | Get relevant context for a task |
44
- | `ekkOS_Capture` | Capture memory events |
45
42
  | `ekkOS_Forge` | Create pattern from learned solution |
46
- | `ekkOS_Directive` | Create MUST/NEVER/PREFER/AVOID rules |
47
- | `ekkOS_Outcome` | Track if pattern worked or failed |
48
- | `ekkOS_Detect` | Auto-detect which patterns were used |
49
- | `ekkOS_Summary` | Get summary of recent MCP activity |
50
- | `ekkOS_Conflict` | Check for directive/pattern conflicts |
51
- | `ekkOS_Recall` | Recall past conversations by time |
52
- | `ekkOS_Codebase` | Search project code embeddings |
43
+ | `ekkOS_Track` | Track when a pattern is applied |
44
+ | `ekkOS_Outcome` | Record if pattern worked or failed |
53
45
  | `ekkOS_Stats` | Get statistics for all layers |
54
- | `ekkOS_Track` | Track when pattern is applied |
55
- | `ekkOS_Reflect` | Analyze response for improvements |
46
+ | `ekkOS_Context` | Get relevant context for a task |
47
+
48
+ ### Retrieval (4)
49
+ | Tool | Description |
50
+ |------|-------------|
51
+ | `ekkOS_Codebase` | Search project code embeddings |
52
+ | `ekkOS_Recall` | Recall past conversations by time |
53
+ | `ekkOS_PreserveContext` | Preserve working memory before compaction |
54
+ | `ekkOS_RestoreContext` | Restore context after compaction |
56
55
 
57
- ### Schema Awareness Tools
56
+ ### Directives (4)
58
57
  | Tool | Description |
59
58
  |------|-------------|
60
- | `ekkOS_IndexSchema` | Index database schemas (Supabase/Prisma/TS) |
61
- | `ekkOS_GetSchema` | Get schema for a specific table/type |
59
+ | `ekkOS_Directive` | Create MUST/NEVER/PREFER/AVOID rules |
60
+ | `ekkOS_UpdateDirective` | Update an existing directive |
61
+ | `ekkOS_DeleteDirective` | Remove a directive |
62
+ | `ekkOS_UniversalDirectives` | Get directives that apply across all projects |
62
63
 
63
- ### Portability Tools
64
+ ### Utility (5)
64
65
  | Tool | Description |
65
66
  |------|-------------|
66
- | `ekkOS_Export` | Export your memory data as portable JSON backup |
67
+ | `ekkOS_Summary` | Get summary of recent memory activity |
68
+ | `ekkOS_Conflict` | Check for conflicts before destructive actions |
69
+ | `ekkOS_Export` | Export patterns, directives, plans as JSON backup |
67
70
  | `ekkOS_Import` | Import memory from backup (auto-deduplication) |
71
+ | `ekkOS_Health` | System health check |
68
72
 
69
- ### Plan Management
73
+ ### Plans (5)
70
74
  | Tool | Description |
71
75
  |------|-------------|
72
76
  | `ekkOS_Plan` | Create structured task plan |
73
- | `ekkOS_Plans` | List user's plans |
77
+ | `ekkOS_Plans` | List your plans |
74
78
  | `ekkOS_PlanStatus` | Update plan status |
75
79
  | `ekkOS_PlanStep` | Mark step complete/incomplete |
76
80
  | `ekkOS_Generate` | AI-generate plan from context |
77
- | `ekkOS_SaveTemplate` | Save plan as reusable template |
78
- | `ekkOS_Templates` | List available templates |
79
- | `ekkOS_FromTemplate` | Create plan from template |
80
81
 
81
- ### Secrets Management (Layer 11)
82
+ ### Secrets (5)
82
83
  | Tool | Description |
83
84
  |------|-------------|
84
85
  | `ekkOS_StoreSecret` | Encrypt and store sensitive data |
85
86
  | `ekkOS_GetSecret` | Retrieve and decrypt a secret |
86
- | `ekkOS_ListSecrets` | List secrets metadata (no values) |
87
+ | `ekkOS_ListSecrets` | List secrets metadata (no values exposed) |
87
88
  | `ekkOS_DeleteSecret` | Permanently delete a secret |
88
- | `ekkOS_RotateSecret` | Update secret with new value |
89
+ | `ekkOS_RotateSecret` | Update a secret with a new value |
89
90
 
90
91
  ## 11-Layer Architecture
91
92
 
@@ -93,33 +94,27 @@ When something DOES NOT work, forge it as an anti-pattern.
93
94
  |---|-------|---------|
94
95
  | 1 | Working | Current session state |
95
96
  | 2 | Episodic | Past conversations |
96
- | 3 | Semantic | Embeddings/knowledge |
97
+ | 3 | Semantic | Embeddings & knowledge |
97
98
  | 4 | Patterns | Proven solutions |
98
99
  | 5 | Procedural | Step-by-step guides |
99
100
  | 6 | Collective | Cross-project wisdom |
100
101
  | 7 | Meta | Pattern effectiveness |
101
102
  | 8 | Codebase | Project-specific code |
102
- | 9 | Directives | MUST/NEVER/PREFER/AVOID rules |
103
- | 10 | Conflict Resolution | Auto-resolves contradictions |
103
+ | 9 | Directives | User rules (MUST/NEVER/PREFER/AVOID) |
104
+ | 10 | Conflict | Auto-resolves contradictions |
104
105
  | 11 | Secrets | Encrypted credentials (AES-256-GCM) |
105
106
 
106
- ## FORGE TRIGGERS
107
-
108
- Call `ekkOS_Forge` when you:
109
- - Fix a bug (especially non-obvious)
110
- - Discover a better approach
111
- - Find a pitfall or gotcha
112
- - Get corrected by the user
113
- - Solve auth/config issues
114
- - Make architectural decisions
115
- - Debug non-trivially
116
- - Find something that DOESN'T work
107
+ ## When To Use What
117
108
 
118
- Call `ekkOS_Directive` when user says:
119
- - "always..." → MUST
120
- - "never..." NEVER
121
- - "I prefer..." PREFER
122
- - "don't..." / "avoid..." → AVOID
109
+ | Tool | Trigger |
110
+ |------|---------|
111
+ | `ekkOS_Search` | Technical question, past discussion, architecture, debugging |
112
+ | `ekkOS_Forge` | Bug fixed, better approach, gotcha, correction, anti-pattern |
113
+ | `ekkOS_Directive` | User says "always" MUST, "never" → NEVER, "prefer" → PREFER, "avoid" → AVOID |
114
+ | `ekkOS_Conflict` | Before delete, deploy, config change, destructive commands |
115
+ | Plan tools | Task has 3+ steps, complex feature request |
116
+ | Secret tools | User shares API key/token/password, need stored credentials |
117
+ | `ekkOS_Recall` | "yesterday", "last week", "remember when", "what did we discuss" |
123
118
 
124
119
  ## Response Format
125
120
 
@@ -129,59 +124,4 @@ End every response with:
129
124
  🧠 **ekkOS_™** · 📅 YYYY-MM-DD H:MM AM/PM TZ
130
125
  ```
131
126
 
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
127
+ For more info: https://docs.ekkos.dev
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  trigger: always_on
3
- description: ekkOS Memory - 11-layer cognitive memory with 31 MCP tools
3
+ description: ekkOS Memory 11-layer cognitive memory with 29 MCP tools
4
4
  ---
5
5
 
6
6
  # ekkOS Memory System
7
7
 
8
- You have access to **ekkOS memory** via 31 MCP tools. This is an 11-layer cognitive memory system that makes AI smarter over time by learning from past sessions.
8
+ You have access to **ekkOS memory** via 29 MCP tools. This is an 11-layer cognitive memory system that makes AI smarter over time by learning from past sessions.
9
9
 
10
10
  ## MANDATORY RULES
11
11
 
@@ -13,7 +13,7 @@ You have access to **ekkOS memory** via 31 MCP tools. This is an 11-layer cognit
13
13
  Before answering ANY technical question, call `ekkOS_Search` first.
14
14
 
15
15
  ### RULE 2: ACKNOWLEDGE RETRIEVED PATTERNS
16
- When patterns are retrieved:
16
+ When patterns are retrieved, acknowledge each one:
17
17
  ```
18
18
  [ekkOS_SELECT]
19
19
  - id: <pattern_id>
@@ -27,98 +27,94 @@ When patterns are retrieved:
27
27
  [/ekkOS_SKIP]
28
28
  ```
29
29
 
30
- ### RULE 3: FORGE WHAT YOU LEARN
31
- When you fix a bug or learn something new, call `ekkOS_Forge` immediately.
30
+ Suppress SELECT/SKIP blocks for non-technical turns (acknowledgments, affirmations).
32
31
 
33
- ### RULE 4: FAILURES ARE VALUABLE
32
+ ### RULE 3: FORGE WHAT YOU LEARN
33
+ When you fix a bug, get corrected, or learn something new, call `ekkOS_Forge` immediately.
34
34
  When something DOESN'T work, forge it as an anti-pattern.
35
35
 
36
- ## MCP Tools (31 Total)
36
+ ## MCP Tools 29 Visible
37
37
 
38
- ### Core Memory Tools
38
+ ### Core Memory (6)
39
39
  | Tool | Description |
40
40
  |------|-------------|
41
- | `ekkOS_Search` | Search all 11 memory layers |
42
- | `ekkOS_Context` | Get relevant task context |
43
- | `ekkOS_Capture` | Capture memory events |
44
- | `ekkOS_Forge` | Create pattern from solution |
45
- | `ekkOS_Directive` | Create MUST/NEVER/PREFER/AVOID rules |
46
- | `ekkOS_Outcome` | Track success/failure |
47
- | `ekkOS_Detect` | Auto-detect pattern usage |
48
- | `ekkOS_Summary` | Get activity summary |
49
- | `ekkOS_Conflict` | Check for conflicts |
50
- | `ekkOS_Recall` | Recall past conversations |
51
- | `ekkOS_Codebase` | Search code embeddings |
52
- | `ekkOS_Stats` | Get layer statistics |
53
- | `ekkOS_Track` | Track pattern application |
54
- | `ekkOS_Reflect` | Analyze response for improvements |
55
-
56
- ### Schema Awareness Tools
41
+ | `ekkOS_Search` | Search across all 11 memory layers |
42
+ | `ekkOS_Forge` | Create pattern from learned solution |
43
+ | `ekkOS_Track` | Track when a pattern is applied |
44
+ | `ekkOS_Outcome` | Record if pattern worked or failed |
45
+ | `ekkOS_Stats` | Get statistics for all layers |
46
+ | `ekkOS_Context` | Get relevant context for a task |
47
+
48
+ ### Retrieval (4)
57
49
  | Tool | Description |
58
50
  |------|-------------|
59
- | `ekkOS_IndexSchema` | Index database schemas (Supabase/Prisma/TS) |
60
- | `ekkOS_GetSchema` | Get schema for a specific table/type |
51
+ | `ekkOS_Codebase` | Search project code embeddings |
52
+ | `ekkOS_Recall` | Recall past conversations by time |
53
+ | `ekkOS_PreserveContext` | Preserve working memory before compaction |
54
+ | `ekkOS_RestoreContext` | Restore context after compaction |
61
55
 
62
- ### Portability
56
+ ### Directives (4)
63
57
  | Tool | Description |
64
58
  |------|-------------|
65
- | `ekkOS_Export` | Export data as portable backup |
66
- | `ekkOS_Import` | Import from backup |
59
+ | `ekkOS_Directive` | Create MUST/NEVER/PREFER/AVOID rules |
60
+ | `ekkOS_UpdateDirective` | Update an existing directive |
61
+ | `ekkOS_DeleteDirective` | Remove a directive |
62
+ | `ekkOS_UniversalDirectives` | Get directives that apply across all projects |
67
63
 
68
- ### Plan Management
64
+ ### Utility (5)
69
65
  | Tool | Description |
70
66
  |------|-------------|
71
- | `ekkOS_Plan` | Create task plan |
72
- | `ekkOS_Plans` | List user plans |
67
+ | `ekkOS_Summary` | Get summary of recent memory activity |
68
+ | `ekkOS_Conflict` | Check for conflicts before destructive actions |
69
+ | `ekkOS_Export` | Export patterns, directives, plans as JSON backup |
70
+ | `ekkOS_Import` | Import memory from backup (auto-deduplication) |
71
+ | `ekkOS_Health` | System health check |
72
+
73
+ ### Plans (5)
74
+ | Tool | Description |
75
+ |------|-------------|
76
+ | `ekkOS_Plan` | Create structured task plan |
77
+ | `ekkOS_Plans` | List your plans |
73
78
  | `ekkOS_PlanStatus` | Update plan status |
74
- | `ekkOS_PlanStep` | Mark step done |
75
- | `ekkOS_Generate` | AI-generate plan |
76
- | `ekkOS_SaveTemplate` | Save as template |
77
- | `ekkOS_Templates` | List templates |
78
- | `ekkOS_FromTemplate` | Create from template |
79
+ | `ekkOS_PlanStep` | Mark step complete/incomplete |
80
+ | `ekkOS_Generate` | AI-generate plan from context |
79
81
 
80
- ### Secrets (Layer 11)
82
+ ### Secrets (5)
81
83
  | Tool | Description |
82
84
  |------|-------------|
83
- | `ekkOS_StoreSecret` | Encrypt and store |
84
- | `ekkOS_GetSecret` | Retrieve and decrypt |
85
- | `ekkOS_ListSecrets` | List metadata |
86
- | `ekkOS_DeleteSecret` | Delete secret |
87
- | `ekkOS_RotateSecret` | Rotate value |
85
+ | `ekkOS_StoreSecret` | Encrypt and store sensitive data |
86
+ | `ekkOS_GetSecret` | Retrieve and decrypt a secret |
87
+ | `ekkOS_ListSecrets` | List secrets metadata (no values exposed) |
88
+ | `ekkOS_DeleteSecret` | Permanently delete a secret |
89
+ | `ekkOS_RotateSecret` | Update a secret with a new value |
88
90
 
89
91
  ## 11-Layer Architecture
90
92
 
91
93
  | # | Layer | Purpose |
92
94
  |---|-------|---------|
93
- | 1 | Working | Current session |
95
+ | 1 | Working | Current session state |
94
96
  | 2 | Episodic | Past conversations |
95
- | 3 | Semantic | Embeddings |
97
+ | 3 | Semantic | Embeddings & knowledge |
96
98
  | 4 | Patterns | Proven solutions |
97
99
  | 5 | Procedural | Step-by-step guides |
98
100
  | 6 | Collective | Cross-project wisdom |
99
101
  | 7 | Meta | Pattern effectiveness |
100
- | 8 | Codebase | Project code |
101
- | 9 | Directives | User rules |
102
- | 10 | Conflict | Auto-resolution |
102
+ | 8 | Codebase | Project-specific code |
103
+ | 9 | Directives | User rules (MUST/NEVER/PREFER/AVOID) |
104
+ | 10 | Conflict | Auto-resolves contradictions |
103
105
  | 11 | Secrets | Encrypted credentials (AES-256-GCM) |
104
106
 
105
- ## FORGE TRIGGERS
107
+ ## When To Use What
106
108
 
107
- **forge_pattern** when you:
108
- - Fix a bug
109
- - Find better approach
110
- - Discover gotcha
111
- - Get corrected
112
- - Solve auth/config
113
- - Make architecture decision
114
- - Debug non-trivially
115
- - Find anti-pattern
116
-
117
- **forge_directive** when user says:
118
- - "always..." → MUST
119
- - "never..." → NEVER
120
- - "I prefer..." → PREFER
121
- - "don't..." → AVOID
109
+ | Tool | Trigger |
110
+ |------|---------|
111
+ | `ekkOS_Search` | Technical question, past discussion, architecture, debugging |
112
+ | `ekkOS_Forge` | Bug fixed, better approach, gotcha, correction, anti-pattern |
113
+ | `ekkOS_Directive` | User says "always" → MUST, "never" → NEVER, "prefer" → PREFER, "avoid" → AVOID |
114
+ | `ekkOS_Conflict` | Before delete, deploy, config change, destructive commands |
115
+ | Plan tools | Task has 3+ steps, complex feature request |
116
+ | Secret tools | User shares API key/token/password, need stored credentials |
117
+ | `ekkOS_Recall` | "yesterday", "last week", "remember when", "what did we discuss" |
122
118
 
123
119
  ## Response Format
124
120
 
@@ -127,3 +123,5 @@ End every response with:
127
123
  ---
128
124
  🧠 **ekkOS_™** · 📅 YYYY-MM-DD H:MM AM/PM TZ
129
125
  ```
126
+
127
+ For more info: https://docs.ekkos.dev
@@ -1,117 +0,0 @@
1
- #!/bin/bash
2
- # ═══════════════════════════════════════════════════════════════════════════
3
- # ekkOS_ Hook: AfterAgentResponse (Cursor Agent Mode)
4
- #
5
- # Captures agent responses for turn storage in ekkOS L2 (episodic memory)
6
- # This enables Time Machine to work with Cursor Agent conversations
7
- # ═══════════════════════════════════════════════════════════════════════════
8
-
9
- set +e
10
-
11
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
- PROJECT_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
13
- STATE_DIR="$PROJECT_ROOT/.cursor/state"
14
- mkdir -p "$STATE_DIR" 2>/dev/null || true
15
-
16
- # Read JSON input
17
- INPUT=$(cat)
18
-
19
- # Extract response text
20
- RESPONSE_TEXT=$(echo "$INPUT" | jq -r '.text // ""' 2>/dev/null || echo "")
21
-
22
- # Skip if empty
23
- if [ -z "$RESPONSE_TEXT" ] || [ "$RESPONSE_TEXT" = "null" ]; then
24
- exit 0
25
- fi
26
-
27
- # ═══════════════════════════════════════════════════════════════════════════
28
- # Load auth
29
- # ═══════════════════════════════════════════════════════════════════════════
30
- EKKOS_CONFIG="$HOME/.ekkos/config.json"
31
- AUTH_TOKEN=""
32
- USER_ID=""
33
-
34
- if [ -f "$EKKOS_CONFIG" ]; then
35
- AUTH_TOKEN=$(jq -r '.hookApiKey // .apiKey // ""' "$EKKOS_CONFIG" 2>/dev/null || echo "")
36
- USER_ID=$(jq -r '.userId // ""' "$EKKOS_CONFIG" 2>/dev/null || echo "")
37
- fi
38
-
39
- if [ -z "$AUTH_TOKEN" ] && [ -f "$PROJECT_ROOT/.env.local" ]; then
40
- AUTH_TOKEN=$(grep -E "^SUPABASE_SECRET_KEY=" "$PROJECT_ROOT/.env.local" | cut -d'=' -f2- | tr -d '"' | tr -d "'" | tr -d '\r')
41
- fi
42
-
43
- [ -z "$AUTH_TOKEN" ] && exit 0
44
-
45
- MEMORY_API_URL="https://mcp.ekkos.dev"
46
-
47
- # ═══════════════════════════════════════════════════════════════════════════
48
- # Load session state
49
- # ═══════════════════════════════════════════════════════════════════════════
50
- SESSION_ID=""
51
- LAST_QUERY=""
52
-
53
- if [ -f "$STATE_DIR/current_session_id.txt" ]; then
54
- SESSION_ID=$(cat "$STATE_DIR/current_session_id.txt" 2>/dev/null || echo "")
55
- fi
56
-
57
- if [ -f "$STATE_DIR/last_query.txt" ]; then
58
- LAST_QUERY=$(cat "$STATE_DIR/last_query.txt" 2>/dev/null || echo "")
59
- fi
60
-
61
- # Generate session ID if missing
62
- if [ -z "$SESSION_ID" ]; then
63
- SESSION_ID="cursor-agent-$(date +%s)-$$"
64
- echo "$SESSION_ID" > "$STATE_DIR/current_session_id.txt"
65
- fi
66
-
67
- # ═══════════════════════════════════════════════════════════════════════════
68
- # Get turn number
69
- # ═══════════════════════════════════════════════════════════════════════════
70
- TURN_FILE="$STATE_DIR/turn_${SESSION_ID}.txt"
71
- TURN_NUMBER=1
72
- if [ -f "$TURN_FILE" ]; then
73
- TURN_NUMBER=$(cat "$TURN_FILE" 2>/dev/null || echo "0")
74
- TURN_NUMBER=$((TURN_NUMBER + 1))
75
- fi
76
- echo "$TURN_NUMBER" > "$TURN_FILE"
77
-
78
- # ═══════════════════════════════════════════════════════════════════════════
79
- # Capture turn to ekkOS L2
80
- # ═══════════════════════════════════════════════════════════════════════════
81
- # Only capture if we have a query to pair with
82
- if [ -n "$LAST_QUERY" ]; then
83
- # Truncate for API limits
84
- QUERY_TRUNCATED="${LAST_QUERY:0:10000}"
85
- RESPONSE_TRUNCATED="${RESPONSE_TEXT:0:50000}"
86
-
87
- CAPTURE_PAYLOAD=$(jq -n \
88
- --arg session_id "cursor-agent-$SESSION_ID" \
89
- --arg user_id "${USER_ID:-system}" \
90
- --arg user_query "$QUERY_TRUNCATED" \
91
- --arg assistant_response "$RESPONSE_TRUNCATED" \
92
- --argjson turn_number "$TURN_NUMBER" \
93
- '{
94
- session_id: $session_id,
95
- user_id: $user_id,
96
- user_query: $user_query,
97
- assistant_response: $assistant_response,
98
- metadata: {
99
- source: "cursor-agent",
100
- turn_number: $turn_number,
101
- agent_mode: true
102
- }
103
- }' 2>/dev/null || echo '{}')
104
-
105
- # Fire and forget - don't block agent
106
- curl -s -X POST "$MEMORY_API_URL/api/v1/capture" \
107
- -H "Authorization: Bearer $AUTH_TOKEN" \
108
- -H "Content-Type: application/json" \
109
- -d "$CAPTURE_PAYLOAD" \
110
- --connect-timeout 2 \
111
- --max-time 3 >/dev/null 2>&1 &
112
-
113
- # Clear last query
114
- rm -f "$STATE_DIR/last_query.txt" 2>/dev/null || true
115
- fi
116
-
117
- exit 0