gemkit-cli 0.2.3 → 0.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 (160) hide show
  1. package/README.md +141 -7
  2. package/dist/commands/agent/index.d.ts +9 -0
  3. package/dist/commands/agent/index.js +1329 -0
  4. package/dist/commands/cache/index.d.ts +5 -0
  5. package/dist/commands/cache/index.js +43 -0
  6. package/dist/commands/catalog/index.d.ts +2 -0
  7. package/dist/commands/catalog/index.js +57 -0
  8. package/dist/commands/config/index.d.ts +7 -0
  9. package/dist/commands/config/index.js +122 -0
  10. package/dist/commands/convert/index.d.ts +8 -0
  11. package/dist/commands/convert/index.js +391 -0
  12. package/dist/commands/doctor/index.d.ts +2 -0
  13. package/dist/commands/doctor/index.js +243 -0
  14. package/dist/commands/extension/index.d.ts +5 -0
  15. package/dist/commands/extension/index.js +52 -0
  16. package/dist/commands/index.d.ts +5 -0
  17. package/dist/commands/index.js +37 -0
  18. package/dist/commands/init/index.d.ts +6 -0
  19. package/dist/commands/init/index.js +345 -0
  20. package/dist/commands/new/index.d.ts +5 -0
  21. package/dist/commands/new/index.js +49 -0
  22. package/dist/commands/office/index.d.ts +5 -0
  23. package/dist/commands/office/index.js +283 -0
  24. package/dist/commands/paste/index.d.ts +10 -0
  25. package/dist/commands/paste/index.js +533 -0
  26. package/dist/commands/plan/index.d.ts +8 -0
  27. package/dist/commands/plan/index.js +247 -0
  28. package/dist/commands/session/index.d.ts +8 -0
  29. package/dist/commands/session/index.js +289 -0
  30. package/dist/commands/tokens/index.d.ts +6 -0
  31. package/dist/commands/tokens/index.js +148 -0
  32. package/dist/commands/update/index.d.ts +26 -0
  33. package/dist/commands/update/index.js +199 -0
  34. package/dist/commands/versions/index.d.ts +5 -0
  35. package/dist/commands/versions/index.js +39 -0
  36. package/dist/domains/agent/index.d.ts +8 -0
  37. package/dist/domains/agent/index.js +8 -0
  38. package/dist/domains/agent/mappings.d.ts +32 -0
  39. package/dist/domains/agent/mappings.js +164 -0
  40. package/dist/domains/agent/profile.d.ts +26 -0
  41. package/dist/domains/agent/profile.js +225 -0
  42. package/dist/domains/agent/pty-context.d.ts +11 -0
  43. package/dist/domains/agent/pty-context.js +83 -0
  44. package/dist/domains/agent/pty-providers.d.ts +18 -0
  45. package/dist/domains/agent/pty-providers.js +66 -0
  46. package/dist/domains/agent/pty-session.d.ts +33 -0
  47. package/dist/domains/agent/pty-session.js +82 -0
  48. package/dist/domains/agent/pty-types.d.ts +127 -0
  49. package/dist/domains/agent/pty-types.js +4 -0
  50. package/dist/domains/agent/search.d.ts +45 -0
  51. package/dist/domains/agent/search.js +614 -0
  52. package/dist/domains/agent/types.d.ts +78 -0
  53. package/dist/domains/agent/types.js +5 -0
  54. package/dist/domains/agent-office/documents-scanner.d.ts +9 -0
  55. package/dist/domains/agent-office/documents-scanner.js +143 -0
  56. package/dist/domains/agent-office/event-emitter.d.ts +43 -0
  57. package/dist/domains/agent-office/event-emitter.js +86 -0
  58. package/dist/domains/agent-office/file-watcher.d.ts +40 -0
  59. package/dist/domains/agent-office/file-watcher.js +173 -0
  60. package/dist/domains/agent-office/icons.d.ts +11 -0
  61. package/dist/domains/agent-office/icons.js +36 -0
  62. package/dist/domains/agent-office/index.d.ts +12 -0
  63. package/dist/domains/agent-office/index.js +20 -0
  64. package/dist/domains/agent-office/renderer/web/assets.d.ts +11 -0
  65. package/dist/domains/agent-office/renderer/web/assets.js +3419 -0
  66. package/dist/domains/agent-office/renderer/web/server.d.ts +42 -0
  67. package/dist/domains/agent-office/renderer/web/server.js +228 -0
  68. package/dist/domains/agent-office/renderer/web.d.ts +30 -0
  69. package/dist/domains/agent-office/renderer/web.js +111 -0
  70. package/dist/domains/agent-office/session-bridge.d.ts +23 -0
  71. package/dist/domains/agent-office/session-bridge.js +171 -0
  72. package/dist/domains/agent-office/state-machine.d.ts +5 -0
  73. package/dist/domains/agent-office/state-machine.js +82 -0
  74. package/dist/domains/agent-office/types.d.ts +91 -0
  75. package/dist/domains/agent-office/types.js +4 -0
  76. package/dist/domains/cache/index.d.ts +1 -0
  77. package/dist/domains/cache/index.js +1 -0
  78. package/dist/domains/cache/manager.d.ts +22 -0
  79. package/dist/domains/cache/manager.js +84 -0
  80. package/dist/domains/config/index.d.ts +5 -0
  81. package/dist/domains/config/index.js +5 -0
  82. package/dist/domains/config/manager.d.ts +24 -0
  83. package/dist/domains/config/manager.js +85 -0
  84. package/dist/domains/config/schema.d.ts +17 -0
  85. package/dist/domains/config/schema.js +96 -0
  86. package/dist/domains/convert/converter.d.ts +78 -0
  87. package/dist/domains/convert/converter.js +471 -0
  88. package/dist/domains/convert/index.d.ts +5 -0
  89. package/dist/domains/convert/index.js +5 -0
  90. package/dist/domains/convert/types.d.ts +88 -0
  91. package/dist/domains/convert/types.js +18 -0
  92. package/dist/domains/github/download.d.ts +12 -0
  93. package/dist/domains/github/download.js +51 -0
  94. package/dist/domains/github/index.d.ts +2 -0
  95. package/dist/domains/github/index.js +2 -0
  96. package/dist/domains/github/releases.d.ts +16 -0
  97. package/dist/domains/github/releases.js +68 -0
  98. package/dist/domains/installation/conflict.d.ts +13 -0
  99. package/dist/domains/installation/conflict.js +38 -0
  100. package/dist/domains/installation/file-sync.d.ts +16 -0
  101. package/dist/domains/installation/file-sync.js +77 -0
  102. package/dist/domains/installation/index.d.ts +3 -0
  103. package/dist/domains/installation/index.js +3 -0
  104. package/dist/domains/installation/metadata.d.ts +20 -0
  105. package/dist/domains/installation/metadata.js +52 -0
  106. package/dist/domains/plan/index.d.ts +2 -0
  107. package/dist/domains/plan/index.js +2 -0
  108. package/dist/domains/plan/resolver.d.ts +24 -0
  109. package/dist/domains/plan/resolver.js +164 -0
  110. package/dist/domains/plan/types.d.ts +13 -0
  111. package/dist/domains/plan/types.js +4 -0
  112. package/dist/domains/session/env.d.ts +51 -0
  113. package/dist/domains/session/env.js +118 -0
  114. package/dist/domains/session/index.d.ts +8 -0
  115. package/dist/domains/session/index.js +8 -0
  116. package/dist/domains/session/manager.d.ts +56 -0
  117. package/dist/domains/session/manager.js +205 -0
  118. package/dist/domains/session/paths.d.ts +6 -0
  119. package/dist/domains/session/paths.js +6 -0
  120. package/dist/domains/session/types.d.ts +121 -0
  121. package/dist/domains/session/types.js +5 -0
  122. package/dist/domains/session/writer.d.ts +82 -0
  123. package/dist/domains/session/writer.js +431 -0
  124. package/dist/domains/tokens/index.d.ts +5 -0
  125. package/dist/domains/tokens/index.js +5 -0
  126. package/dist/domains/tokens/pricing.d.ts +38 -0
  127. package/dist/domains/tokens/pricing.js +129 -0
  128. package/dist/domains/tokens/scanner.d.ts +42 -0
  129. package/dist/domains/tokens/scanner.js +168 -0
  130. package/dist/index.d.ts +5 -0
  131. package/dist/index.js +87 -58
  132. package/dist/services/aipty.d.ts +76 -0
  133. package/dist/services/aipty.js +276 -0
  134. package/dist/services/archive.d.ts +22 -0
  135. package/dist/services/archive.js +53 -0
  136. package/dist/services/auto-update.d.ts +26 -0
  137. package/dist/services/auto-update.js +117 -0
  138. package/dist/services/hash.d.ts +36 -0
  139. package/dist/services/hash.js +63 -0
  140. package/dist/services/logger.d.ts +28 -0
  141. package/dist/services/logger.js +102 -0
  142. package/dist/services/music.d.ts +67 -0
  143. package/dist/services/music.js +290 -0
  144. package/dist/services/npm.d.ts +22 -0
  145. package/dist/services/npm.js +65 -0
  146. package/dist/services/pty-client.d.ts +66 -0
  147. package/dist/services/pty-client.js +154 -0
  148. package/dist/services/pty-server.d.ts +102 -0
  149. package/dist/services/pty-server.js +613 -0
  150. package/dist/types/index.d.ts +155 -0
  151. package/dist/types/index.js +4 -0
  152. package/dist/utils/colors.d.ts +43 -0
  153. package/dist/utils/colors.js +98 -0
  154. package/dist/utils/errors.d.ts +24 -0
  155. package/dist/utils/errors.js +56 -0
  156. package/dist/utils/paths.d.ts +46 -0
  157. package/dist/utils/paths.js +89 -0
  158. package/dist/utils/platform.d.ts +11 -0
  159. package/dist/utils/platform.js +31 -0
  160. package/package.json +55 -54
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Session domain exports
3
+ */
4
+ export * from './types.js';
5
+ export * from './env.js';
6
+ export * from './paths.js';
7
+ export * from './manager.js';
8
+ export * from './writer.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Session domain exports
3
+ */
4
+ export * from './types.js';
5
+ export * from './env.js';
6
+ export * from './paths.js';
7
+ export * from './manager.js';
8
+ export * from './writer.js';
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Session manager - READ-ONLY operations
3
+ * Reads session data created by gk-session-manager.cjs hooks
4
+ *
5
+ * Storage: ~/.gemkit/projects/{projectDir}/gk-session-{gkSessionId}.json
6
+ */
7
+ import { GkSession, GkAgent, GkProject, SessionListOptions, AgentFilterOptions, SessionMetrics } from './types.js';
8
+ /**
9
+ * Get session by ID
10
+ * Matches gk-session-manager.cjs getSession()
11
+ */
12
+ export declare function getSession(projectDir: string, gkSessionId: string): GkSession | null;
13
+ /**
14
+ * Get current active session
15
+ */
16
+ export declare function getActiveSession(): GkSession | null;
17
+ /**
18
+ * Check if session exists
19
+ */
20
+ export declare function sessionExists(projectDir: string, gkSessionId: string): boolean;
21
+ /**
22
+ * List all sessions for a project
23
+ */
24
+ export declare function listSessions(projectDir: string, options?: SessionListOptions): GkSession[];
25
+ /**
26
+ * List all projects
27
+ */
28
+ export declare function listProjects(): string[];
29
+ /**
30
+ * Get project metadata
31
+ * Matches gk-session-manager.cjs getProject()
32
+ */
33
+ export declare function getProject(projectDir: string, gkProjectHash: string): GkProject | null;
34
+ /**
35
+ * Get agents from session
36
+ * Matches gk-session-manager.cjs getAgents()
37
+ */
38
+ export declare function getAgents(projectDir: string, gkSessionId: string, filters?: AgentFilterOptions): GkAgent[];
39
+ /**
40
+ * Get session metrics
41
+ * Matches gk-session-manager.cjs getMetrics()
42
+ */
43
+ export declare function getMetrics(projectDir: string, gkSessionId: string): SessionMetrics;
44
+ /**
45
+ * Find session by Gemini session ID
46
+ * Matches gk-session-manager.cjs findSessionByGeminiId()
47
+ */
48
+ export declare function findSessionByGeminiId(projectDir: string, geminiSessionId: string): GkSession | null;
49
+ /**
50
+ * Get sub-agents from current session
51
+ */
52
+ export declare function getSubAgents(projectDir: string, gkSessionId: string): GkAgent[];
53
+ /**
54
+ * Get main agent from session
55
+ */
56
+ export declare function getMainAgent(projectDir: string, gkSessionId: string): GkAgent | null;
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Session manager - READ-ONLY operations
3
+ * Reads session data created by gk-session-manager.cjs hooks
4
+ *
5
+ * Storage: ~/.gemkit/projects/{projectDir}/gk-session-{gkSessionId}.json
6
+ */
7
+ import { existsSync, readFileSync, readdirSync } from 'fs';
8
+ import { join } from 'path';
9
+ import { getProjectDataDir, getSessionPath, getProjectPath, GEMKIT_PROJECTS_DIR } from '../../utils/paths.js';
10
+ import { getProjectDir, getActiveGkSessionId } from './env.js';
11
+ /**
12
+ * Get session by ID
13
+ * Matches gk-session-manager.cjs getSession()
14
+ */
15
+ export function getSession(projectDir, gkSessionId) {
16
+ if (!projectDir || !gkSessionId)
17
+ return null;
18
+ const sessionPath = getSessionPath(projectDir, gkSessionId);
19
+ if (!existsSync(sessionPath)) {
20
+ return null;
21
+ }
22
+ try {
23
+ const content = readFileSync(sessionPath, 'utf-8');
24
+ return JSON.parse(content);
25
+ }
26
+ catch (e) {
27
+ return null;
28
+ }
29
+ }
30
+ /**
31
+ * Get current active session
32
+ */
33
+ export function getActiveSession() {
34
+ const projectDir = getProjectDir();
35
+ const gkSessionId = getActiveGkSessionId();
36
+ if (!gkSessionId)
37
+ return null;
38
+ return getSession(projectDir, gkSessionId);
39
+ }
40
+ /**
41
+ * Check if session exists
42
+ */
43
+ export function sessionExists(projectDir, gkSessionId) {
44
+ if (!projectDir || !gkSessionId)
45
+ return false;
46
+ return existsSync(getSessionPath(projectDir, gkSessionId));
47
+ }
48
+ /**
49
+ * List all sessions for a project
50
+ */
51
+ export function listSessions(projectDir, options = {}) {
52
+ const { limit = 10, status = 'all' } = options;
53
+ const projectDataDir = getProjectDataDir(projectDir);
54
+ if (!existsSync(projectDataDir)) {
55
+ return [];
56
+ }
57
+ const sessions = [];
58
+ try {
59
+ const files = readdirSync(projectDataDir)
60
+ .filter(f => f.startsWith('gk-session-') && f.endsWith('.json'));
61
+ for (const file of files) {
62
+ const filePath = join(projectDataDir, file);
63
+ const content = readFileSync(filePath, 'utf-8');
64
+ const session = JSON.parse(content);
65
+ // Filter by status
66
+ if (status !== 'all') {
67
+ const mainAgent = session.agents?.find(a => a.agentType === 'Main Agent');
68
+ const sessionStatus = mainAgent?.status || 'active';
69
+ if (sessionStatus !== status)
70
+ continue;
71
+ }
72
+ sessions.push(session);
73
+ }
74
+ }
75
+ catch (e) {
76
+ // Return empty on error
77
+ }
78
+ // Sort by initTimestamp, newest first
79
+ sessions.sort((a, b) => new Date(b.initTimestamp).getTime() - new Date(a.initTimestamp).getTime());
80
+ return sessions.slice(0, limit);
81
+ }
82
+ /**
83
+ * List all projects
84
+ */
85
+ export function listProjects() {
86
+ if (!existsSync(GEMKIT_PROJECTS_DIR)) {
87
+ return [];
88
+ }
89
+ try {
90
+ return readdirSync(GEMKIT_PROJECTS_DIR, { withFileTypes: true })
91
+ .filter(d => d.isDirectory())
92
+ .map(d => d.name);
93
+ }
94
+ catch (e) {
95
+ return [];
96
+ }
97
+ }
98
+ /**
99
+ * Get project metadata
100
+ * Matches gk-session-manager.cjs getProject()
101
+ */
102
+ export function getProject(projectDir, gkProjectHash) {
103
+ if (!projectDir || !gkProjectHash)
104
+ return null;
105
+ const projectPath = getProjectPath(projectDir, gkProjectHash);
106
+ if (!existsSync(projectPath)) {
107
+ return null;
108
+ }
109
+ try {
110
+ const content = readFileSync(projectPath, 'utf-8');
111
+ return JSON.parse(content);
112
+ }
113
+ catch (e) {
114
+ return null;
115
+ }
116
+ }
117
+ /**
118
+ * Get agents from session
119
+ * Matches gk-session-manager.cjs getAgents()
120
+ */
121
+ export function getAgents(projectDir, gkSessionId, filters = {}) {
122
+ const session = getSession(projectDir, gkSessionId);
123
+ if (!session || !session.agents)
124
+ return [];
125
+ let agents = session.agents;
126
+ if (filters.agentType) {
127
+ agents = agents.filter(a => a.agentType === filters.agentType);
128
+ }
129
+ if (filters.status) {
130
+ agents = agents.filter(a => a.status === filters.status);
131
+ }
132
+ return agents;
133
+ }
134
+ /**
135
+ * Get session metrics
136
+ * Matches gk-session-manager.cjs getMetrics()
137
+ */
138
+ export function getMetrics(projectDir, gkSessionId) {
139
+ const agents = getAgents(projectDir, gkSessionId);
140
+ const metrics = {
141
+ total: agents.length,
142
+ active: 0,
143
+ completed: 0,
144
+ failed: 0,
145
+ mainAgents: 0,
146
+ subAgents: 0,
147
+ totalDurationMs: 0
148
+ };
149
+ agents.forEach(agent => {
150
+ if (agent.status === 'active')
151
+ metrics.active++;
152
+ else if (agent.status === 'completed')
153
+ metrics.completed++;
154
+ else if (agent.status === 'failed')
155
+ metrics.failed++;
156
+ if (agent.agentType === 'Main Agent')
157
+ metrics.mainAgents++;
158
+ else
159
+ metrics.subAgents++;
160
+ if (agent.startTime && agent.endTime) {
161
+ metrics.totalDurationMs += new Date(agent.endTime).getTime() - new Date(agent.startTime).getTime();
162
+ }
163
+ });
164
+ return metrics;
165
+ }
166
+ /**
167
+ * Find session by Gemini session ID
168
+ * Matches gk-session-manager.cjs findSessionByGeminiId()
169
+ */
170
+ export function findSessionByGeminiId(projectDir, geminiSessionId) {
171
+ if (!projectDir || !geminiSessionId)
172
+ return null;
173
+ const projectDataDir = getProjectDataDir(projectDir);
174
+ if (!existsSync(projectDataDir))
175
+ return null;
176
+ try {
177
+ const files = readdirSync(projectDataDir)
178
+ .filter(f => f.startsWith('gk-session-') && f.endsWith('.json'));
179
+ for (const file of files) {
180
+ const filePath = join(projectDataDir, file);
181
+ const content = readFileSync(filePath, 'utf-8');
182
+ const session = JSON.parse(content);
183
+ if (session.geminiSessionId === geminiSessionId) {
184
+ return session;
185
+ }
186
+ }
187
+ }
188
+ catch (e) {
189
+ // Ignore errors
190
+ }
191
+ return null;
192
+ }
193
+ /**
194
+ * Get sub-agents from current session
195
+ */
196
+ export function getSubAgents(projectDir, gkSessionId) {
197
+ return getAgents(projectDir, gkSessionId, { agentType: 'Sub Agent' });
198
+ }
199
+ /**
200
+ * Get main agent from session
201
+ */
202
+ export function getMainAgent(projectDir, gkSessionId) {
203
+ const agents = getAgents(projectDir, gkSessionId, { agentType: 'Main Agent' });
204
+ return agents[0] || null;
205
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Session path utilities
3
+ * Re-exports from utils/paths.ts for backwards compatibility
4
+ * Aligned with gk-session-manager.cjs
5
+ */
6
+ export { GEMKIT_PROJECTS_DIR, getProjectDataDir, getSessionPath, getProjectPath, sanitizeProjectPath } from '../../utils/paths.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Session path utilities
3
+ * Re-exports from utils/paths.ts for backwards compatibility
4
+ * Aligned with gk-session-manager.cjs
5
+ */
6
+ export { GEMKIT_PROJECTS_DIR, getProjectDataDir, getSessionPath, getProjectPath, sanitizeProjectPath } from '../../utils/paths.js';
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Session type definitions
3
+ * Aligned with gk-session-manager.cjs session structure
4
+ */
5
+ /**
6
+ * GK Session - matches gk-session-manager.cjs session structure
7
+ */
8
+ export interface GkSession {
9
+ gkSessionId: string;
10
+ gkProjectHash: string;
11
+ projectDir: string;
12
+ geminiSessionId: string | null;
13
+ geminiParentId: string | null;
14
+ geminiProjectHash: string | null;
15
+ geminiTempDir?: string;
16
+ initialized: boolean;
17
+ initTimestamp: string;
18
+ sessionType: 'gemini' | 'non-gemini';
19
+ appName: string;
20
+ pid: number;
21
+ activePlan: string | null;
22
+ suggestedPlan: string | null;
23
+ planDateFormat?: string;
24
+ agents: GkAgent[];
25
+ }
26
+ /**
27
+ * GK Agent - matches gk-session-manager.cjs agent structure
28
+ */
29
+ export interface GkAgent {
30
+ gkSessionId: string;
31
+ pid: number | null;
32
+ geminiSessionId: string | null;
33
+ geminiProjectHash: string | null;
34
+ parentGkSessionId: string | null;
35
+ agentType: 'Main Agent' | 'Sub Agent';
36
+ agentRole: string;
37
+ prompt: string | null;
38
+ model: string | null;
39
+ tokenUsage: TokenUsage | null;
40
+ retryCount: number;
41
+ resumeCount: number;
42
+ generation: number;
43
+ injected: InjectedContext | null;
44
+ startTime: string;
45
+ endTime: string | null;
46
+ status: 'active' | 'completed' | 'failed';
47
+ exitCode: number | null;
48
+ error: string | null;
49
+ }
50
+ /**
51
+ * Token usage structure
52
+ */
53
+ export interface TokenUsage {
54
+ input: number;
55
+ output: number;
56
+ cached: number;
57
+ thoughts: number;
58
+ tool: number;
59
+ total: number;
60
+ }
61
+ /**
62
+ * Injected context tracking
63
+ */
64
+ export interface InjectedContext {
65
+ skills: string[];
66
+ context: string[];
67
+ contextHash?: string;
68
+ }
69
+ /**
70
+ * GK Project - matches gk-session-manager.cjs project structure
71
+ */
72
+ export interface GkProject {
73
+ gkProjectHash: string;
74
+ projectDir: string;
75
+ projectPath: string;
76
+ geminiProjectHash: string | null;
77
+ initialized: boolean;
78
+ initTimestamp: string;
79
+ lastActiveTimestamp: string;
80
+ activeGkSessionId: string | null;
81
+ sessions: GkProjectSession[];
82
+ }
83
+ /**
84
+ * Session summary in project file
85
+ */
86
+ export interface GkProjectSession {
87
+ gkSessionId: string;
88
+ pid: number | null;
89
+ sessionType: 'gemini' | 'non-gemini';
90
+ appName: string;
91
+ prompt: string | null;
92
+ activePlan: string | null;
93
+ startTime: string;
94
+ endTime: string | null;
95
+ }
96
+ /**
97
+ * Session list options
98
+ */
99
+ export interface SessionListOptions {
100
+ limit?: number;
101
+ status?: 'active' | 'completed' | 'failed' | 'all';
102
+ }
103
+ /**
104
+ * Agent filter options
105
+ */
106
+ export interface AgentFilterOptions {
107
+ agentType?: 'Main Agent' | 'Sub Agent';
108
+ status?: 'active' | 'completed' | 'failed';
109
+ }
110
+ /**
111
+ * Session metrics
112
+ */
113
+ export interface SessionMetrics {
114
+ total: number;
115
+ active: number;
116
+ completed: number;
117
+ failed: number;
118
+ mainAgents: number;
119
+ subAgents: number;
120
+ totalDurationMs: number;
121
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Session type definitions
3
+ * Aligned with gk-session-manager.cjs session structure
4
+ */
5
+ export {};
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Session writer - WRITE operations
3
+ * Aligned with gk-session-manager.cjs write functions
4
+ *
5
+ * Used by:
6
+ * - gk session init (replaces gk-init.cjs)
7
+ * - gk plan set (replaces gk-set-active-plan.cjs)
8
+ */
9
+ import { GkSession, GkAgent, GkProject, GkProjectSession } from './types.js';
10
+ /**
11
+ * Get the terminal PID by walking up the process tree
12
+ * Matches gk-session-manager.cjs getTerminalPid()
13
+ */
14
+ export declare function getTerminalPid(): number;
15
+ /**
16
+ * Save session to file (atomic write)
17
+ * Matches gk-session-manager.cjs saveSession()
18
+ */
19
+ export declare function saveSession(projectDir: string, gkSessionId: string, data: GkSession): boolean;
20
+ /**
21
+ * Update .gemini/.env with session and project info
22
+ * Matches gk-session-manager.cjs updateEnv()
23
+ */
24
+ export declare function updateEnv(envData: {
25
+ gkSessionId?: string;
26
+ gkProjectHash?: string;
27
+ projectDir?: string;
28
+ geminiSessionId?: string;
29
+ geminiProjectHash?: string;
30
+ activePlan?: string;
31
+ suggestedPlan?: string;
32
+ planDateFormat?: string;
33
+ }): boolean;
34
+ /**
35
+ * Save project data
36
+ */
37
+ export declare function saveProject(projectDir: string, gkProjectHash: string, data: GkProject): boolean;
38
+ /**
39
+ * Create or get project
40
+ */
41
+ export declare function ensureProject(projectDir: string, gkProjectHash: string, projectPath?: string): GkProject;
42
+ /**
43
+ * Add session summary to project
44
+ */
45
+ export declare function addSessionToProject(projectDir: string, gkProjectHash: string, sessionSummary: Partial<GkProjectSession> & {
46
+ gkSessionId: string;
47
+ }): boolean;
48
+ /**
49
+ * Add agent to session
50
+ * Matches gk-session-manager.cjs addAgent()
51
+ */
52
+ export declare function addAgent(projectDir: string, gkSessionId: string, agentData: Partial<GkAgent>): boolean;
53
+ /**
54
+ * Initialize a non-Gemini session
55
+ * Matches gk-session-manager.cjs initializeNonGeminiSession()
56
+ */
57
+ export declare function initializeNonGeminiSession(appName: string, options?: {
58
+ cwd?: string;
59
+ activePlan?: string | null;
60
+ suggestedPlan?: string | null;
61
+ }): {
62
+ session: GkSession;
63
+ gkSessionId: string;
64
+ pid: number;
65
+ projectDir: string;
66
+ gkProjectHash: string;
67
+ };
68
+ /**
69
+ * Set active plan in session and .env
70
+ * Matches gk-session-manager.cjs setActivePlan()
71
+ */
72
+ export declare function setActivePlan(projectDir: string, gkSessionId: string, planPath: string): boolean;
73
+ /**
74
+ * Parse gkSessionId to extract components
75
+ * Matches gk-session-manager.cjs parseGkSessionId()
76
+ */
77
+ export declare function parseGkSessionId(gkSessionId: string): {
78
+ appName: string;
79
+ pid: number;
80
+ timestamp: string;
81
+ random: string;
82
+ } | null;