@rlabs-inc/memory 0.3.2 → 0.3.5

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.
@@ -1,146 +0,0 @@
1
- // ============================================================================
2
- // INSTALL GEMINI COMMAND - Set up Gemini CLI hooks
3
- // ============================================================================
4
-
5
- import { homedir } from 'os'
6
- import { join } from 'path'
7
- import { existsSync, mkdirSync } from 'fs'
8
- import { c, symbols, fmt } from '../colors.ts'
9
-
10
- interface InstallOptions {
11
- verbose?: boolean
12
- force?: boolean
13
- }
14
-
15
- export async function installGemini(options: InstallOptions) {
16
- console.log()
17
- console.log(c.header(`${symbols.brain} Memory - Install Gemini Hooks`))
18
- console.log()
19
-
20
- const geminiDir = join(homedir(), '.gemini')
21
- const settingsPath = join(geminiDir, 'settings.json')
22
-
23
- // Find the hooks directory (relative to this CLI)
24
- const cliPath = import.meta.dir
25
- const packageRoot = join(cliPath, '..', '..', '..')
26
- const hooksDir = join(packageRoot, 'gemini-hooks')
27
-
28
- console.log(` ${fmt.kv('Gemini config', geminiDir)}`)
29
- console.log(` ${fmt.kv('Hooks source', hooksDir)}`)
30
- console.log()
31
-
32
- // Check if hooks directory exists
33
- if (!existsSync(hooksDir)) {
34
- console.log(c.error(` ${symbols.cross} Hooks directory not found at ${hooksDir}`))
35
- process.exit(1)
36
- }
37
-
38
- // Ensure .gemini directory exists
39
- if (!existsSync(geminiDir)) {
40
- try {
41
- mkdirSync(geminiDir, { recursive: true })
42
- console.log(` ${c.success(symbols.tick)} Created ${geminiDir}`)
43
- } catch {
44
- console.log(` ${c.warn(symbols.warning)} Could not create ${geminiDir} (sandbox restriction?)`)
45
- console.log(` ${c.muted('Skipping config write, printing manual instructions instead.')}`)
46
- }
47
- }
48
-
49
- // Read existing settings or create new
50
- let settings: any = {}
51
- if (existsSync(settingsPath)) {
52
- try {
53
- const content = await Bun.file(settingsPath).text()
54
- settings = JSON.parse(content)
55
- console.log(` ${c.success(symbols.tick)} Found existing settings.json`)
56
- } catch {
57
- console.log(` ${c.warn(symbols.warning)} Could not parse settings.json`)
58
- }
59
- }
60
-
61
- // Build hooks configuration
62
- const sessionStartHook = join(hooksDir, 'session-start.ts')
63
- const userPromptHook = join(hooksDir, 'user-prompt.ts')
64
- const curationHook = join(hooksDir, 'curation.ts')
65
-
66
- // Based on Gemini CLI documentation
67
- const hooksConfig = {
68
- SessionStart: [
69
- {
70
- matcher: 'startup|resume',
71
- hooks: [
72
- {
73
- type: 'command',
74
- command: `bun "${sessionStartHook}"`,
75
- timeout: 10000
76
- }
77
- ]
78
- }
79
- ],
80
- BeforeAgent: [
81
- {
82
- hooks: [
83
- {
84
- type: 'command',
85
- command: `bun "${userPromptHook}"`,
86
- timeout: 10000
87
- }
88
- ]
89
- }
90
- ],
91
- PreCompress: [
92
- {
93
- matcher: 'auto|manual',
94
- hooks: [
95
- {
96
- type: 'command',
97
- command: `bun "${curationHook}"`,
98
- timeout: 120000
99
- }
100
- ]
101
- }
102
- ],
103
- SessionEnd: [
104
- {
105
- hooks: [
106
- {
107
- type: 'command',
108
- command: `bun "${curationHook}"`,
109
- timeout: 120000
110
- }
111
- ]
112
- }
113
- ]
114
- }
115
-
116
- // Merge hooks
117
- if (!settings.hooks) {
118
- settings.hooks = {}
119
- }
120
-
121
- settings.hooks = {
122
- ...settings.hooks,
123
- ...hooksConfig
124
- }
125
-
126
- // Write settings
127
- try {
128
- if (existsSync(geminiDir)) {
129
- await Bun.write(settingsPath, JSON.stringify(settings, null, 2))
130
- console.log(` ${c.success(symbols.tick)} Updated ${settingsPath}`)
131
- } else {
132
- throw new Error("Gemini directory does not exist")
133
- }
134
- } catch (error: any) {
135
- console.log(c.error(` ${symbols.cross} Failed to write settings: ${error.message}`))
136
- console.log()
137
- console.log(c.bold('Manual Installation Instructions:'))
138
- console.log('Add the following to your ~/.gemini/settings.json:')
139
- console.log()
140
- console.log(JSON.stringify({ hooks: hooksConfig }, null, 2))
141
- console.log()
142
- }
143
-
144
- console.log()
145
- console.log(c.success(`${symbols.sparkles} Gemini hooks configured!`))
146
- }
File without changes
File without changes