Skip to content

Commit b17eb50

Browse files
konardclaude
andcommitted
feat(session-gists): add Gemini support and context-doc reference
- Add ~/.gemini to session backup directories for Gemini CLI sessions - Extract SessionGistCommand types to dedicated session-gist-domain.ts module - Add context-doc reference link for extracting session dialogs - Update restore instructions to include .gemini files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3459984 commit b17eb50

File tree

5 files changed

+56
-42
lines changed

5 files changed

+56
-42
lines changed

.githooks/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fi
1111

1212
node scripts/pre-push-knowledge-guard.js "$@"
1313

14-
# CHANGE: backup AI session to private gist on push
14+
# CHANGE: backup AI session to private gist on push (supports Claude, Codex, Gemini)
1515
# WHY: allows returning to old AI sessions and provides PR context
1616
# QUOTE(ТЗ): "когда происходит push мы сразу заливаем текущую сессию с AI агентом в gits приватный"
1717
# REF: issue-143

packages/lib/src/core/domain.ts

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { SessionGistCommand } from "./session-gist-domain.js"
2+
13
export type { MenuAction, ParseError } from "./menu.js"
24
export { parseMenuSelection } from "./menu.js"
35
export { deriveRepoPathParts, deriveRepoSlug, resolveRepoInput } from "./repo.js"
@@ -271,44 +273,13 @@ export interface AuthGeminiLogoutCommand {
271273
readonly geminiAuthPath: string
272274
}
273275

274-
// CHANGE: add session gist backup commands for PR-based session history
275-
// WHY: enables returning to old AI sessions via private gists linked to PRs
276-
// QUOTE(ТЗ): "иметь возможность возвращаться ко всем старым сессиям с агентами"
277-
// REF: issue-143
278-
// PURITY: CORE
279-
// EFFECT: n/a
280-
// INVARIANT: gist commands are always tied to a repository context
281-
// COMPLEXITY: O(1)
282-
export interface SessionGistBackupCommand {
283-
readonly _tag: "SessionGistBackup"
284-
readonly projectDir: string
285-
readonly prNumber: number | null
286-
readonly repo: string | null
287-
readonly postComment: boolean
288-
}
289-
290-
export interface SessionGistListCommand {
291-
readonly _tag: "SessionGistList"
292-
readonly limit: number
293-
readonly repo: string | null
294-
}
295-
296-
export interface SessionGistViewCommand {
297-
readonly _tag: "SessionGistView"
298-
readonly gistId: string
299-
}
300-
301-
export interface SessionGistDownloadCommand {
302-
readonly _tag: "SessionGistDownload"
303-
readonly gistId: string
304-
readonly outputDir: string
305-
}
306-
307-
export type SessionGistCommand =
308-
| SessionGistBackupCommand
309-
| SessionGistListCommand
310-
| SessionGistViewCommand
311-
| SessionGistDownloadCommand
276+
export type {
277+
SessionGistBackupCommand,
278+
SessionGistCommand,
279+
SessionGistDownloadCommand,
280+
SessionGistListCommand,
281+
SessionGistViewCommand
282+
} from "./session-gist-domain.js"
312283
export type SessionsCommand =
313284
| SessionsListCommand
314285
| SessionsKillCommand
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// CHANGE: session gist backup commands for PR-based session history
2+
// WHY: enables returning to old AI sessions via private gists linked to PRs
3+
// QUOTE(ТЗ): "иметь возможность возвращаться ко всем старым сессиям с агентами"
4+
// REF: issue-143
5+
// PURITY: CORE
6+
7+
export interface SessionGistBackupCommand {
8+
readonly _tag: "SessionGistBackup"
9+
readonly projectDir: string
10+
readonly prNumber: number | null
11+
readonly repo: string | null
12+
readonly postComment: boolean
13+
}
14+
15+
export interface SessionGistListCommand {
16+
readonly _tag: "SessionGistList"
17+
readonly limit: number
18+
readonly repo: string | null
19+
}
20+
21+
export interface SessionGistViewCommand {
22+
readonly _tag: "SessionGistView"
23+
readonly gistId: string
24+
}
25+
26+
export interface SessionGistDownloadCommand {
27+
readonly _tag: "SessionGistDownload"
28+
readonly gistId: string
29+
readonly outputDir: string
30+
}
31+
32+
export type SessionGistCommand =
33+
| SessionGistBackupCommand
34+
| SessionGistListCommand
35+
| SessionGistViewCommand
36+
| SessionGistDownloadCommand

scripts/session-backup-gist.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/**
44
* Session Backup to GitHub Gist
55
*
6-
* This script backs up AI agent session files (~/.codex, ~/.claude) to a private GitHub Gist
6+
* This script backs up AI agent session files (~/.codex, ~/.claude, ~/.gemini) to a private GitHub Gist
77
* and optionally posts a comment to the associated PR with the gist link.
88
*
99
* Usage:
1010
* node scripts/session-backup-gist.js [options]
1111
*
1212
* Options:
13-
* --session-dir <path> Path to session directory (default: auto-detect ~/.codex or ~/.claude)
13+
* --session-dir <path> Path to session directory (default: auto-detect ~/.codex, ~/.claude, or ~/.gemini)
1414
* --pr-number <number> PR number to post comment to (optional, auto-detected from branch)
1515
* --repo <owner/repo> Repository (optional, auto-detected from git remote)
1616
* --no-comment Skip posting PR comment
@@ -31,7 +31,7 @@ const os = require("node:os");
3131

3232
// Configuration
3333
const MAX_GIST_FILE_SIZE = 10 * 1024 * 1024; // 10MB per file limit for gists
34-
const SESSION_DIR_NAMES = [".codex", ".claude"];
34+
const SESSION_DIR_NAMES = [".codex", ".claude", ".gemini"];
3535
const KNOWLEDGE_DIR_NAME = ".knowledge";
3636

3737
/**
@@ -337,8 +337,13 @@ codex resume <session-id>
337337
338338
# For Claude
339339
claude --resume <session-id>
340+
341+
# For Gemini
342+
gemini --resume <session-id>
340343
\`\`\`
341344
345+
For extracting session dialogs, see: https://github.com/ProverCoderAI/context-doc
346+
342347
---
343348
*Backup created at: ${timestamp}*`;
344349

scripts/session-list-gists.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ const downloadGist = (gistId, outputDir, verbose) => {
251251
console.log("\nTo restore session files, copy them to the appropriate location:");
252252
console.log(" - .codex/* files -> ~/.codex/");
253253
console.log(" - .claude/* files -> ~/.claude/");
254+
console.log(" - .gemini/* files -> ~/.gemini/");
254255
console.log(" - .knowledge/* files -> ./.knowledge/");
256+
console.log("\nFor extracting session dialogs, see: https://github.com/ProverCoderAI/context-doc");
255257
};
256258

257259
/**

0 commit comments

Comments
 (0)