mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 21:03:05 -07:00
feat(core): Add support for transcript_path in hooks for git-ai/Gemini extension (#14663)
Co-authored-by: Christian Gunderman <gundermanc@gmail.com>
This commit is contained in:
@@ -45,6 +45,13 @@ describe('HookEventHandler', () => {
|
|||||||
mockConfig = {
|
mockConfig = {
|
||||||
getSessionId: vi.fn().mockReturnValue('test-session'),
|
getSessionId: vi.fn().mockReturnValue('test-session'),
|
||||||
getWorkingDir: vi.fn().mockReturnValue('/test/project'),
|
getWorkingDir: vi.fn().mockReturnValue('/test/project'),
|
||||||
|
getGeminiClient: vi.fn().mockReturnValue({
|
||||||
|
getChatRecordingService: vi.fn().mockReturnValue({
|
||||||
|
getConversationFilePath: vi
|
||||||
|
.fn()
|
||||||
|
.mockReturnValue('/test/project/.gemini/tmp/chats/session.json'),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
mockLogger = {} as Logger;
|
mockLogger = {} as Logger;
|
||||||
@@ -513,7 +520,7 @@ describe('HookEventHandler', () => {
|
|||||||
HookEventName.BeforeTool,
|
HookEventName.BeforeTool,
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
session_id: 'test-session',
|
session_id: 'test-session',
|
||||||
transcript_path: '',
|
transcript_path: '/test/project/.gemini/tmp/chats/session.json',
|
||||||
cwd: '/test/project',
|
cwd: '/test/project',
|
||||||
hook_event_name: 'BeforeTool',
|
hook_event_name: 'BeforeTool',
|
||||||
timestamp: expect.any(String),
|
timestamp: expect.any(String),
|
||||||
|
|||||||
@@ -548,9 +548,16 @@ export class HookEventHandler {
|
|||||||
* Create base hook input with common fields
|
* Create base hook input with common fields
|
||||||
*/
|
*/
|
||||||
private createBaseInput(eventName: HookEventName): HookInput {
|
private createBaseInput(eventName: HookEventName): HookInput {
|
||||||
|
// Get the transcript path from the ChatRecordingService if available
|
||||||
|
const transcriptPath =
|
||||||
|
this.config
|
||||||
|
.getGeminiClient()
|
||||||
|
?.getChatRecordingService()
|
||||||
|
?.getConversationFilePath() ?? '';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
session_id: this.config.getSessionId(),
|
session_id: this.config.getSessionId(),
|
||||||
transcript_path: '', // TODO: Implement transcript path when supported
|
transcript_path: transcriptPath,
|
||||||
cwd: this.config.getWorkingDir(),
|
cwd: this.config.getWorkingDir(),
|
||||||
hook_event_name: eventName,
|
hook_event_name: eventName,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
|
|||||||
@@ -468,6 +468,14 @@ export class ChatRecordingService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the path to the current conversation file.
|
||||||
|
* Returns null if the service hasn't been initialized yet.
|
||||||
|
*/
|
||||||
|
getConversationFilePath(): string | null {
|
||||||
|
return this.conversationFile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a session file by session ID.
|
* Deletes a session file by session ID.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user