context-forge-cli 0.1.0__tar.gz → 0.2.1__tar.gz

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 (54) hide show
  1. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/PKG-INFO +7 -6
  2. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/README.md +6 -5
  3. context_forge_cli-0.2.1/contextforge/adapters/gemini.py +188 -0
  4. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/adapters/registry.py +2 -0
  5. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/pyproject.toml +1 -1
  6. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/.contextforge.toml +0 -0
  7. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/.github/workflows/publish.yml +0 -0
  8. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/.gitignore +0 -0
  9. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/.python-version +0 -0
  10. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/AGENTS.md +0 -0
  11. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/PLAN.md +0 -0
  12. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/__init__.py +0 -0
  13. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/adapters/__init__.py +0 -0
  14. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/adapters/altimate_code.py +0 -0
  15. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/adapters/base.py +0 -0
  16. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/adapters/claude_code.py +0 -0
  17. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/adapters/claude_desktop.py +0 -0
  18. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/adapters/codex.py +0 -0
  19. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/cli.py +0 -0
  20. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/core/__init__.py +0 -0
  21. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/core/analytics.py +0 -0
  22. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/core/compactor.py +0 -0
  23. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/core/db.py +0 -0
  24. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/core/injector.py +0 -0
  25. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/core/scanner.py +0 -0
  26. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/core/summarizer.py +0 -0
  27. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/core/token_analyzer.py +0 -0
  28. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/models/__init__.py +0 -0
  29. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/models/config.py +0 -0
  30. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/models/session.py +0 -0
  31. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/__init__.py +0 -0
  32. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/app.py +0 -0
  33. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/styles.tcss +0 -0
  34. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/widgets/__init__.py +0 -0
  35. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/widgets/session_detail.py +0 -0
  36. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/widgets/session_table.py +0 -0
  37. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/widgets/stats_panel.py +0 -0
  38. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/widgets/status_bar.py +0 -0
  39. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/widgets/tokens_panel.py +0 -0
  40. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/tui/widgets/transfer_panel.py +0 -0
  41. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/utils/__init__.py +0 -0
  42. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/utils/display.py +0 -0
  43. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/contextforge/utils/tokens.py +0 -0
  44. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/__init__.py +0 -0
  45. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/adapters/__init__.py +0 -0
  46. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/adapters/test_claude_code.py +0 -0
  47. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/core/__init__.py +0 -0
  48. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/core/test_compactor.py +0 -0
  49. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/core/test_db.py +0 -0
  50. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/core/test_injector.py +0 -0
  51. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/core/test_summarizer.py +0 -0
  52. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/core/test_token_analyzer.py +0 -0
  53. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/tests/fixtures/claude_session_sample.jsonl +0 -0
  54. {context_forge_cli-0.1.0 → context_forge_cli-0.2.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: context-forge-cli
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: Session manager and context bridge for agentic CLI tools
5
5
  Project-URL: Homepage, https://github.com/emmver/contextforge
6
6
  Project-URL: Repository, https://github.com/emmver/contextforge
@@ -30,14 +30,14 @@ Description-Content-Type: text/markdown
30
30
 
31
31
  **Session manager and context bridge for agentic CLI tools.**
32
32
 
33
- ContextForge (`cf`) tracks sessions from Claude Code, Codex, altimate-code, and other
33
+ ContextForge (`cf`) tracks sessions from Claude Code, Claude Desktop, Codex, Gemini, altimate-code, and other
34
34
  agentic CLI tools. It generates plain-English summaries of each session and can compact
35
35
  and transfer context from one or more sessions into a new session — within the same tool
36
36
  or across different tools.
37
37
 
38
38
  ## What it does
39
39
 
40
- - **Discovers sessions** from Claude Code (`~/.claude/projects/`), Codex (`~/.codex/state_5.sqlite`), and altimate-code (`~/.local/share/altimate-code/`)
40
+ - **Discovers sessions** from Claude Code (`~/.claude/projects/`), Claude Desktop, Codex (`~/.codex/state_5.sqlite`), Gemini (`~/.gemini/tmp/<project_hash>/chats/`), and altimate-code (`~/.local/share/altimate-code/`)
41
41
  - **Generates summaries** of what each session accomplished (with optional Claude API integration)
42
42
  - **Compacts context** intelligently, reducing multi-turn conversations to a token-efficient ContextBundle
43
43
  - **Transfers context** across tools and sessions (Claude Code → Codex, Codex → altimate-code, etc.)
@@ -47,7 +47,7 @@ or across different tools.
47
47
 
48
48
  - **Python 3.13+** (ContextForge requires Python 3.13 or later)
49
49
  - **uv** or **pipx** (for installation as a tool)
50
- - At least one of: Claude Code, Codex, or altimate-code installed and with session history
50
+ - At least one of: Claude Code, Claude Desktop, Codex, Gemini, or altimate-code installed and with session history
51
51
 
52
52
  ## Install
53
53
 
@@ -167,6 +167,7 @@ The method is chosen automatically based on token count and whether a target ses
167
167
  | Claude Code (CLI) | `~/.claude/projects/` JSONL | `--system-prompt` / `--resume` |
168
168
  | Claude Desktop | `~/Library/Application Support/Claude/local-agent-mode-sessions/` | `--system-prompt` |
169
169
  | Codex | `~/.codex/state_5.sqlite` | `resume` / `fork` |
170
+ | Gemini | `~/.gemini/tmp/<project_hash>/chats/` JSON | New session / `/resume` |
170
171
  | altimate-code | `~/.local/share/altimate-code/opencode.db` | `run -s` / `import` |
171
172
 
172
173
  ## Session Summaries
@@ -261,7 +262,7 @@ A full-screen Textual dashboard with live session browsing, filtering, and analy
261
262
  │ │ Worked on UTASTAR ensemble │
262
263
  │ │ pruning framework... │
263
264
  └──────────────────────────┴─────────────────────────────────┘
264
- Sessions — CC:12 │ Codex:4 │ Alt:3 │ Total:19 │ 129M tok 14:32:01
265
+ Sessions — CC:12 │ Codex:4 │ Gemini:2 │ Alt:3 │ Total:21 │ 129M tok 14:32:01
265
266
  ```
266
267
 
267
268
  ### Key bindings
@@ -298,7 +299,7 @@ Press `/` to open the filter bar above the session list:
298
299
  ### Transfer modal (`t`)
299
300
 
300
301
  Press `t` on any session to open the transfer panel. Choose:
301
- - **Target tool** — Claude Code, Codex, or altimate-code
302
+ - **Target tool** — Claude Code, Claude Desktop, Codex, Gemini, or altimate-code
302
303
  - **Strategy** — `summary_only`, `key_messages`, or `full_recent`
303
304
  - **Preview** — shows the exact shell command (no side effects)
304
305
  - **Execute** — builds the bundle and launches the target tool
@@ -2,14 +2,14 @@
2
2
 
3
3
  **Session manager and context bridge for agentic CLI tools.**
4
4
 
5
- ContextForge (`cf`) tracks sessions from Claude Code, Codex, altimate-code, and other
5
+ ContextForge (`cf`) tracks sessions from Claude Code, Claude Desktop, Codex, Gemini, altimate-code, and other
6
6
  agentic CLI tools. It generates plain-English summaries of each session and can compact
7
7
  and transfer context from one or more sessions into a new session — within the same tool
8
8
  or across different tools.
9
9
 
10
10
  ## What it does
11
11
 
12
- - **Discovers sessions** from Claude Code (`~/.claude/projects/`), Codex (`~/.codex/state_5.sqlite`), and altimate-code (`~/.local/share/altimate-code/`)
12
+ - **Discovers sessions** from Claude Code (`~/.claude/projects/`), Claude Desktop, Codex (`~/.codex/state_5.sqlite`), Gemini (`~/.gemini/tmp/<project_hash>/chats/`), and altimate-code (`~/.local/share/altimate-code/`)
13
13
  - **Generates summaries** of what each session accomplished (with optional Claude API integration)
14
14
  - **Compacts context** intelligently, reducing multi-turn conversations to a token-efficient ContextBundle
15
15
  - **Transfers context** across tools and sessions (Claude Code → Codex, Codex → altimate-code, etc.)
@@ -19,7 +19,7 @@ or across different tools.
19
19
 
20
20
  - **Python 3.13+** (ContextForge requires Python 3.13 or later)
21
21
  - **uv** or **pipx** (for installation as a tool)
22
- - At least one of: Claude Code, Codex, or altimate-code installed and with session history
22
+ - At least one of: Claude Code, Claude Desktop, Codex, Gemini, or altimate-code installed and with session history
23
23
 
24
24
  ## Install
25
25
 
@@ -139,6 +139,7 @@ The method is chosen automatically based on token count and whether a target ses
139
139
  | Claude Code (CLI) | `~/.claude/projects/` JSONL | `--system-prompt` / `--resume` |
140
140
  | Claude Desktop | `~/Library/Application Support/Claude/local-agent-mode-sessions/` | `--system-prompt` |
141
141
  | Codex | `~/.codex/state_5.sqlite` | `resume` / `fork` |
142
+ | Gemini | `~/.gemini/tmp/<project_hash>/chats/` JSON | New session / `/resume` |
142
143
  | altimate-code | `~/.local/share/altimate-code/opencode.db` | `run -s` / `import` |
143
144
 
144
145
  ## Session Summaries
@@ -233,7 +234,7 @@ A full-screen Textual dashboard with live session browsing, filtering, and analy
233
234
  │ │ Worked on UTASTAR ensemble │
234
235
  │ │ pruning framework... │
235
236
  └──────────────────────────┴─────────────────────────────────┘
236
- Sessions — CC:12 │ Codex:4 │ Alt:3 │ Total:19 │ 129M tok 14:32:01
237
+ Sessions — CC:12 │ Codex:4 │ Gemini:2 │ Alt:3 │ Total:21 │ 129M tok 14:32:01
237
238
  ```
238
239
 
239
240
  ### Key bindings
@@ -270,7 +271,7 @@ Press `/` to open the filter bar above the session list:
270
271
  ### Transfer modal (`t`)
271
272
 
272
273
  Press `t` on any session to open the transfer panel. Choose:
273
- - **Target tool** — Claude Code, Codex, or altimate-code
274
+ - **Target tool** — Claude Code, Claude Desktop, Codex, Gemini, or altimate-code
274
275
  - **Strategy** — `summary_only`, `key_messages`, or `full_recent`
275
276
  - **Preview** — shows the exact shell command (no side effects)
276
277
  - **Execute** — builds the bundle and launches the target tool
@@ -0,0 +1,188 @@
1
+ """Adapter for Google Gemini CLI sessions."""
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ import shlex
6
+ from datetime import datetime, timezone
7
+ from pathlib import Path
8
+
9
+ from contextforge.adapters.base import ToolAdapter
10
+ from contextforge.models.session import Message, Session
11
+
12
+ _GEMINI_TMP_BASE = Path.home() / ".gemini" / "tmp"
13
+
14
+
15
+ class GeminiAdapter(ToolAdapter):
16
+ tool_name = "gemini"
17
+ default_paths = [_GEMINI_TMP_BASE]
18
+
19
+ def discover_sessions(self) -> list[Session]:
20
+ """Discover Gemini sessions from ~/.gemini/tmp/<project_hash>/chats/."""
21
+ sessions: list[Session] = []
22
+
23
+ if not _GEMINI_TMP_BASE.exists():
24
+ return sessions
25
+
26
+ # Scan all project hash directories
27
+ for project_dir in _GEMINI_TMP_BASE.iterdir():
28
+ if not project_dir.is_dir():
29
+ continue
30
+
31
+ chats_dir = project_dir / "chats"
32
+ if not chats_dir.exists():
33
+ continue
34
+
35
+ # Scan for session JSON files in format: session-<timestamp>-<hash>.json
36
+ for session_file in sorted(chats_dir.glob("session-*.json")):
37
+ try:
38
+ with session_file.open() as f:
39
+ data = json.load(f)
40
+ except (json.JSONDecodeError, OSError):
41
+ continue
42
+
43
+ session_id = data.get("sessionId")
44
+ if not session_id:
45
+ continue
46
+
47
+ # Extract timestamps
48
+ start_time_str = data.get("startTime")
49
+ last_updated_str = data.get("lastUpdated")
50
+
51
+ created_at = None
52
+ updated_at = None
53
+
54
+ if start_time_str:
55
+ try:
56
+ created_at = datetime.fromisoformat(
57
+ start_time_str.replace("Z", "+00:00")
58
+ )
59
+ except (ValueError, AttributeError):
60
+ pass
61
+
62
+ if last_updated_str:
63
+ try:
64
+ updated_at = datetime.fromisoformat(
65
+ last_updated_str.replace("Z", "+00:00")
66
+ )
67
+ except (ValueError, AttributeError):
68
+ pass
69
+
70
+ if created_at is None:
71
+ created_at = datetime.now(timezone.utc)
72
+ if updated_at is None:
73
+ updated_at = created_at
74
+
75
+ # Extract title from first user message
76
+ title = None
77
+ messages = data.get("messages", [])
78
+ for msg in messages:
79
+ if msg.get("type") == "user":
80
+ content = msg.get("content", [])
81
+ if isinstance(content, list) and content:
82
+ text = content[0].get("text", "")
83
+ if text:
84
+ title = text[:100]
85
+ break
86
+
87
+ sessions.append(
88
+ Session(
89
+ id=session_id,
90
+ tool=self.tool_name,
91
+ title=title,
92
+ cwd=None,
93
+ created_at=created_at,
94
+ updated_at=updated_at,
95
+ raw_path=str(session_file),
96
+ status="unknown",
97
+ )
98
+ )
99
+
100
+ return sessions
101
+
102
+ def load_messages(self, session_id: str) -> list[Message]:
103
+ """Load messages for a given session ID by scanning all projects."""
104
+ if not _GEMINI_TMP_BASE.exists():
105
+ return []
106
+
107
+ # Brute-force search across all projects to find the session
108
+ for project_dir in _GEMINI_TMP_BASE.iterdir():
109
+ if not project_dir.is_dir():
110
+ continue
111
+
112
+ chats_dir = project_dir / "chats"
113
+ if not chats_dir.exists():
114
+ continue
115
+
116
+ for session_file in chats_dir.glob("session-*.json"):
117
+ try:
118
+ with session_file.open() as f:
119
+ data = json.load(f)
120
+ except (json.JSONDecodeError, OSError):
121
+ continue
122
+
123
+ if data.get("sessionId") == session_id:
124
+ return self._parse_session_data(data)
125
+
126
+ return []
127
+
128
+ def _parse_session_data(self, data: dict) -> list[Message]:
129
+ """Parse Gemini session JSON object into Message list."""
130
+ messages: list[Message] = []
131
+
132
+ for msg in data.get("messages", []):
133
+ msg_type = msg.get("type", "")
134
+ if msg_type not in ("user", "gemini"):
135
+ continue
136
+
137
+ # Extract content
138
+ content_raw = msg.get("content", "")
139
+ if isinstance(content_raw, list):
140
+ # User messages: content is list of {text: ...}
141
+ parts = []
142
+ for item in content_raw:
143
+ if isinstance(item, dict) and "text" in item:
144
+ parts.append(item["text"])
145
+ content = " ".join(parts)
146
+ else:
147
+ # Gemini messages: content is a string
148
+ content = str(content_raw)
149
+
150
+ if not content or not content.strip():
151
+ continue
152
+
153
+ ts_str = msg.get("timestamp")
154
+ ts = None
155
+ if ts_str:
156
+ try:
157
+ ts = datetime.fromisoformat(ts_str.replace("Z", "+00:00"))
158
+ except (ValueError, AttributeError):
159
+ pass
160
+
161
+ messages.append(
162
+ Message(
163
+ role="user" if msg_type == "user" else "assistant",
164
+ content=content,
165
+ timestamp=ts,
166
+ )
167
+ )
168
+
169
+ return messages
170
+
171
+ def build_inject_command(
172
+ self,
173
+ context: str,
174
+ target_session_id: str | None = None,
175
+ cwd: str | None = None,
176
+ method: str = "system_prompt",
177
+ ) -> str:
178
+ """Build a shell command to start/resume a Gemini session with context."""
179
+ safe_ctx = shlex.quote(context)
180
+
181
+ if method == "resume" and target_session_id:
182
+ return f"gemini /resume {target_session_id}"
183
+
184
+ # Default: new session with context injected via system prompt
185
+ cmd = f"gemini {safe_ctx}"
186
+ if cwd:
187
+ cmd = f"cd {shlex.quote(cwd)} && {cmd}"
188
+ return cmd
@@ -6,12 +6,14 @@ from contextforge.adapters.base import ToolAdapter
6
6
  from contextforge.adapters.claude_code import ClaudeCodeAdapter
7
7
  from contextforge.adapters.claude_desktop import ClaudeDesktopAdapter
8
8
  from contextforge.adapters.codex import CodexAdapter
9
+ from contextforge.adapters.gemini import GeminiAdapter
9
10
 
10
11
  ADAPTERS: dict[str, type[ToolAdapter]] = {
11
12
  "claude_code": ClaudeCodeAdapter,
12
13
  "claude_desktop": ClaudeDesktopAdapter,
13
14
  "codex": CodexAdapter,
14
15
  "altimate_code": AltimateCodeAdapter,
16
+ "gemini": GeminiAdapter,
15
17
  }
16
18
 
17
19
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "context-forge-cli"
3
- version = "0.1.0"
3
+ version = "0.2.1"
4
4
  description = "Session manager and context bridge for agentic CLI tools"
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }