gemcode 0.2.2__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 (79) hide show
  1. gemcode-0.2.2/LICENSE +151 -0
  2. gemcode-0.2.2/MANIFEST.in +9 -0
  3. gemcode-0.2.2/PKG-INFO +440 -0
  4. gemcode-0.2.2/README.md +250 -0
  5. gemcode-0.2.2/pyproject.toml +60 -0
  6. gemcode-0.2.2/setup.cfg +4 -0
  7. gemcode-0.2.2/src/gemcode/__init__.py +3 -0
  8. gemcode-0.2.2/src/gemcode/__main__.py +3 -0
  9. gemcode-0.2.2/src/gemcode/agent.py +146 -0
  10. gemcode-0.2.2/src/gemcode/audit.py +16 -0
  11. gemcode-0.2.2/src/gemcode/callbacks.py +473 -0
  12. gemcode-0.2.2/src/gemcode/capability_routing.py +137 -0
  13. gemcode-0.2.2/src/gemcode/cli.py +658 -0
  14. gemcode-0.2.2/src/gemcode/compaction.py +35 -0
  15. gemcode-0.2.2/src/gemcode/computer_use/__init__.py +0 -0
  16. gemcode-0.2.2/src/gemcode/computer_use/browser_computer.py +275 -0
  17. gemcode-0.2.2/src/gemcode/config.py +247 -0
  18. gemcode-0.2.2/src/gemcode/interactions.py +15 -0
  19. gemcode-0.2.2/src/gemcode/invoke.py +151 -0
  20. gemcode-0.2.2/src/gemcode/kairos_daemon.py +221 -0
  21. gemcode-0.2.2/src/gemcode/limits.py +83 -0
  22. gemcode-0.2.2/src/gemcode/live_audio_engine.py +124 -0
  23. gemcode-0.2.2/src/gemcode/mcp_loader.py +57 -0
  24. gemcode-0.2.2/src/gemcode/memory/__init__.py +0 -0
  25. gemcode-0.2.2/src/gemcode/memory/embedding_memory_service.py +292 -0
  26. gemcode-0.2.2/src/gemcode/memory/file_memory_service.py +176 -0
  27. gemcode-0.2.2/src/gemcode/modality_tools.py +216 -0
  28. gemcode-0.2.2/src/gemcode/model_routing.py +179 -0
  29. gemcode-0.2.2/src/gemcode/paths.py +29 -0
  30. gemcode-0.2.2/src/gemcode/permissions.py +5 -0
  31. gemcode-0.2.2/src/gemcode/plugins/__init__.py +0 -0
  32. gemcode-0.2.2/src/gemcode/plugins/terminal_hooks_plugin.py +168 -0
  33. gemcode-0.2.2/src/gemcode/plugins/tool_recovery_plugin.py +135 -0
  34. gemcode-0.2.2/src/gemcode/prompt_suggestions.py +80 -0
  35. gemcode-0.2.2/src/gemcode/query/__init__.py +36 -0
  36. gemcode-0.2.2/src/gemcode/query/config.py +35 -0
  37. gemcode-0.2.2/src/gemcode/query/deps.py +20 -0
  38. gemcode-0.2.2/src/gemcode/query/engine.py +55 -0
  39. gemcode-0.2.2/src/gemcode/query/stop_hooks.py +63 -0
  40. gemcode-0.2.2/src/gemcode/query/token_budget.py +109 -0
  41. gemcode-0.2.2/src/gemcode/query/transitions.py +41 -0
  42. gemcode-0.2.2/src/gemcode/session_runtime.py +81 -0
  43. gemcode-0.2.2/src/gemcode/thinking.py +136 -0
  44. gemcode-0.2.2/src/gemcode/tool_prompt_manifest.py +118 -0
  45. gemcode-0.2.2/src/gemcode/tool_registry.py +50 -0
  46. gemcode-0.2.2/src/gemcode/tools/__init__.py +25 -0
  47. gemcode-0.2.2/src/gemcode/tools/edit.py +53 -0
  48. gemcode-0.2.2/src/gemcode/tools/filesystem.py +73 -0
  49. gemcode-0.2.2/src/gemcode/tools/search.py +85 -0
  50. gemcode-0.2.2/src/gemcode/tools/shell.py +73 -0
  51. gemcode-0.2.2/src/gemcode/tools_inspector.py +132 -0
  52. gemcode-0.2.2/src/gemcode/trust.py +54 -0
  53. gemcode-0.2.2/src/gemcode/tui/app.py +697 -0
  54. gemcode-0.2.2/src/gemcode/tui/scrollback.py +312 -0
  55. gemcode-0.2.2/src/gemcode/vertex.py +22 -0
  56. gemcode-0.2.2/src/gemcode/web/__init__.py +2 -0
  57. gemcode-0.2.2/src/gemcode/web/claude_sse_adapter.py +282 -0
  58. gemcode-0.2.2/src/gemcode/web/terminal_repl.py +147 -0
  59. gemcode-0.2.2/src/gemcode.egg-info/PKG-INFO +440 -0
  60. gemcode-0.2.2/src/gemcode.egg-info/SOURCES.txt +77 -0
  61. gemcode-0.2.2/src/gemcode.egg-info/dependency_links.txt +1 -0
  62. gemcode-0.2.2/src/gemcode.egg-info/entry_points.txt +2 -0
  63. gemcode-0.2.2/src/gemcode.egg-info/requires.txt +14 -0
  64. gemcode-0.2.2/src/gemcode.egg-info/top_level.txt +1 -0
  65. gemcode-0.2.2/tests/test_capability_routing.py +104 -0
  66. gemcode-0.2.2/tests/test_claude_web_adapter_sse.py +64 -0
  67. gemcode-0.2.2/tests/test_computer_use_permissions.py +48 -0
  68. gemcode-0.2.2/tests/test_interactive_permission_ask.py +131 -0
  69. gemcode-0.2.2/tests/test_kairos_scheduler.py +85 -0
  70. gemcode-0.2.2/tests/test_modality_tools.py +26 -0
  71. gemcode-0.2.2/tests/test_model_routing.py +83 -0
  72. gemcode-0.2.2/tests/test_paths.py +16 -0
  73. gemcode-0.2.2/tests/test_permissions.py +25 -0
  74. gemcode-0.2.2/tests/test_prompt_suggestions.py +23 -0
  75. gemcode-0.2.2/tests/test_thinking_config.py +100 -0
  76. gemcode-0.2.2/tests/test_token_budget.py +41 -0
  77. gemcode-0.2.2/tests/test_tool_context_circulation.py +62 -0
  78. gemcode-0.2.2/tests/test_tools.py +22 -0
  79. gemcode-0.2.2/tests/test_tools_inspector.py +59 -0
gemcode-0.2.2/LICENSE ADDED
@@ -0,0 +1,151 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
124
+ any Contribution intentionally submitted for inclusion in the Work
125
+ by You to the Licensor shall be under the terms and conditions of
126
+ this License, without any additional terms or conditions.
127
+
128
+ 6. Trademarks. This License does not grant permission to use the trade
129
+ names, trademarks, service marks, or product names of the Licensor.
130
+
131
+ 7. Disclaimer of Warranty. Unless required by applicable law or
132
+ agreed to in writing, Licensor provides the Work (and each
133
+ Contributor provides its Contributions) on an "AS IS" BASIS,
134
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135
+
136
+ 8. Limitation of Liability. In no event and under no legal theory,
137
+ whether in tort (including negligence), contract, or otherwise,
138
+ unless required by applicable law, shall any Contributor be liable
139
+ to You for damages, including any direct, indirect, special,
140
+ incidental, or consequential damages arising in any way out of the
141
+ use of the Work.
142
+
143
+ 9. Accepting Warranty or Additional Liability. While redistributing
144
+ the Work or Derivative Works thereof, You may choose to offer,
145
+ and charge a fee for, acceptance of support, warranty, indemnity,
146
+ or other liability obligations and/or rights consistent with this
147
+ License. However, in accepting such obligations, You may act only
148
+ on Your own behalf and on Your sole responsibility.
149
+
150
+ END OF TERMS AND CONDITIONS
151
+
@@ -0,0 +1,9 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ recursive-include src *.py
5
+
6
+ # Keep sdists lean: exclude common non-package artifacts.
7
+ global-exclude *.pyc
8
+ global-exclude *.pyo
9
+ global-exclude __pycache__/*
gemcode-0.2.2/PKG-INFO ADDED
@@ -0,0 +1,440 @@
1
+ Metadata-Version: 2.4
2
+ Name: gemcode
3
+ Version: 0.2.2
4
+ Summary: Local-first coding agent on Google Gemini + ADK
5
+ Author: GemCode Contributors
6
+ License: Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship, whether in Source or
41
+ Object form, made available under the License, as indicated by a
42
+ copyright notice that is included in or attached to the work
43
+ (an example is provided in the Appendix below).
44
+
45
+ "Derivative Works" shall mean any work, whether in Source or Object
46
+ form, that is based on (or derived from) the Work and for which the
47
+ editorial revisions, annotations, elaborations, or other modifications
48
+ represent, as a whole, an original work of authorship. For the purposes
49
+ of this License, Derivative Works shall not include works that remain
50
+ separable from, or merely link (or bind by name) to the interfaces of,
51
+ the Work and Derivative Works thereof.
52
+
53
+ "Contribution" shall mean any work of authorship, including
54
+ the original version of the Work and any modifications or additions
55
+ to that Work or Derivative Works thereof, that is intentionally
56
+ submitted to Licensor for inclusion in the Work by the copyright owner
57
+ or by an individual or Legal Entity authorized to submit on behalf of
58
+ the copyright owner. For the purposes of this definition, "submitted"
59
+ means any form of electronic, verbal, or written communication sent
60
+ to the Licensor or its representatives, including but not limited to
61
+ communication on electronic mailing lists, source code control systems,
62
+ and issue tracking systems that are managed by, or on behalf of, the
63
+ Licensor for the purpose of discussing and improving the Work, but
64
+ excluding communication that is conspicuously marked or otherwise
65
+ designated in writing by the copyright owner as "Not a Contribution."
66
+
67
+ "Contributor" shall mean Licensor and any individual or Legal Entity
68
+ on behalf of whom a Contribution has been received by Licensor and
69
+ subsequently incorporated within the Work.
70
+
71
+ 2. Grant of Copyright License. Subject to the terms and conditions of
72
+ this License, each Contributor hereby grants to You a perpetual,
73
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
74
+ copyright license to reproduce, prepare Derivative Works of,
75
+ publicly display, publicly perform, sublicense, and distribute the
76
+ Work and such Derivative Works in Source or Object form.
77
+
78
+ 3. Grant of Patent License. Subject to the terms and conditions of
79
+ this License, each Contributor hereby grants to You a perpetual,
80
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81
+ (except as stated in this section) patent license to make, have made,
82
+ use, offer to sell, sell, import, and otherwise transfer the Work,
83
+ where such license applies only to those patent claims licensable
84
+ by such Contributor that are necessarily infringed by their
85
+ Contribution(s) alone or by combination of their Contribution(s)
86
+ with the Work to which such Contribution(s) was submitted. If You
87
+ institute patent litigation against any entity (including a
88
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
89
+ or a Contribution incorporated within the Work constitutes direct
90
+ or contributory patent infringement, then any patent licenses
91
+ granted to You under this License for that Work shall terminate
92
+ as of the date such litigation is filed.
93
+
94
+ 4. Redistribution. You may reproduce and distribute copies of the
95
+ Work or Derivative Works thereof in any medium, with or without
96
+ modifications, and in Source or Object form, provided that You
97
+ meet the following conditions:
98
+
99
+ (a) You must give any other recipients of the Work or
100
+ Derivative Works a copy of this License; and
101
+
102
+ (b) You must cause any modified files to carry prominent notices
103
+ stating that You changed the files; and
104
+
105
+ (c) You must retain, in the Source form of any Derivative Works
106
+ that You distribute, all copyright, patent, trademark, and
107
+ attribution notices from the Source form of the Work,
108
+ excluding those notices that do not pertain to any part of
109
+ the Derivative Works; and
110
+
111
+ (d) If the Work includes a "NOTICE" text file as part of its
112
+ distribution, then any Derivative Works that You distribute must
113
+ include a readable copy of the attribution notices contained
114
+ within such NOTICE file, excluding those notices that do not
115
+ pertain to any part of the Derivative Works, in at least one
116
+ of the following places: within a NOTICE text file distributed
117
+ as part of the Derivative Works; within the Source form or
118
+ documentation, if provided along with the Derivative Works; or,
119
+ within a display generated by the Derivative Works, if and
120
+ wherever such third-party notices normally appear. The contents
121
+ of the NOTICE file are for informational purposes only and
122
+ do not modify the License. You may add Your own attribution
123
+ notices within Derivative Works that You distribute, alongside
124
+ or as an addendum to the NOTICE text from the Work, provided
125
+ that such additional attribution notices cannot be construed
126
+ as modifying the License.
127
+
128
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
129
+ any Contribution intentionally submitted for inclusion in the Work
130
+ by You to the Licensor shall be under the terms and conditions of
131
+ this License, without any additional terms or conditions.
132
+
133
+ 6. Trademarks. This License does not grant permission to use the trade
134
+ names, trademarks, service marks, or product names of the Licensor.
135
+
136
+ 7. Disclaimer of Warranty. Unless required by applicable law or
137
+ agreed to in writing, Licensor provides the Work (and each
138
+ Contributor provides its Contributions) on an "AS IS" BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
140
+
141
+ 8. Limitation of Liability. In no event and under no legal theory,
142
+ whether in tort (including negligence), contract, or otherwise,
143
+ unless required by applicable law, shall any Contributor be liable
144
+ to You for damages, including any direct, indirect, special,
145
+ incidental, or consequential damages arising in any way out of the
146
+ use of the Work.
147
+
148
+ 9. Accepting Warranty or Additional Liability. While redistributing
149
+ the Work or Derivative Works thereof, You may choose to offer,
150
+ and charge a fee for, acceptance of support, warranty, indemnity,
151
+ or other liability obligations and/or rights consistent with this
152
+ License. However, in accepting such obligations, You may act only
153
+ on Your own behalf and on Your sole responsibility.
154
+
155
+ END OF TERMS AND CONDITIONS
156
+
157
+
158
+ Project-URL: Homepage, https://github.com/spiderdev27/GemCode
159
+ Project-URL: Repository, https://github.com/spiderdev27/GemCode
160
+ Project-URL: Issues, https://github.com/spiderdev27/GemCode/issues
161
+ Keywords: ai,agent,coding,gemini,adk,cli,tui
162
+ Classifier: Development Status :: 3 - Alpha
163
+ Classifier: Environment :: Console
164
+ Classifier: Intended Audience :: Developers
165
+ Classifier: License :: OSI Approved :: Apache Software License
166
+ Classifier: Operating System :: OS Independent
167
+ Classifier: Programming Language :: Python :: 3
168
+ Classifier: Programming Language :: Python :: 3 :: Only
169
+ Classifier: Programming Language :: Python :: 3.11
170
+ Classifier: Programming Language :: Python :: 3.12
171
+ Classifier: Programming Language :: Python :: 3.13
172
+ Classifier: Topic :: Software Development
173
+ Classifier: Topic :: Software Development :: Libraries
174
+ Classifier: Topic :: Terminals
175
+ Requires-Python: >=3.11
176
+ Description-Content-Type: text/markdown
177
+ License-File: LICENSE
178
+ Requires-Dist: google-adk>=1.0.0
179
+ Requires-Dist: google-genai>=1.0.0
180
+ Requires-Dist: python-dotenv>=1.0.0
181
+ Provides-Extra: dev
182
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
183
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
184
+ Provides-Extra: mcp
185
+ Requires-Dist: mcp>=1.0.0; extra == "mcp"
186
+ Provides-Extra: tui
187
+ Requires-Dist: prompt_toolkit>=3.0.0; extra == "tui"
188
+ Requires-Dist: rich>=13.0.0; extra == "tui"
189
+ Dynamic: license-file
190
+
191
+ # GemCode
192
+
193
+ Local-first coding agent: **Gemini** + **[Google ADK](https://google.github.io/adk-docs/)**, with repo tools, permissions, session persistence, and optional MCP. Implemented in clean-room fashion (reference only to third-party Claude Code trees).
194
+
195
+ ## Requirements
196
+
197
+ - Python 3.11+
198
+ - A [Google AI Studio API key](https://aistudio.google.com/app/apikey) (`GOOGLE_API_KEY`)
199
+
200
+ ## Install
201
+
202
+ ```bash
203
+ cd gemcode
204
+ python3 -m venv .venv
205
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
206
+ pip install -e ".[dev]"
207
+ ```
208
+
209
+ Copy `.env.example` to `.env` and set `GOOGLE_API_KEY`.
210
+
211
+ ## Usage
212
+
213
+ From a git repository root (or pass `-C /path/to/repo`):
214
+
215
+ ```bash
216
+ gemcode "Explain the structure of src/"
217
+ gemcode --yes "Add a module docstring to src/foo.py"
218
+ gemcode --session mysess --yes "Continue: run tests and fix failures"
219
+ ```
220
+
221
+ - **`--yes`**: allow mutating tools (`write_file`, `search_replace`). Shell execution is still restricted by the `.env.example` allowlist.
222
+ - **`--session`**: Conversation history is stored under `.gemcode/sessions.sqlite` (ADK `SqliteSessionService`). Reuse the same `--session` id to continue.
223
+ - **`--max-llm-calls`**: cap model↔tool iterations for this message (maps to ADK `RunConfig.max_llm_calls`). You can also set `GEMCODE_MAX_LLM_CALLS`.
224
+ - **`--model-mode`**: choose model routing mode (`auto|fast|balanced|quality`, default `fast`). In `auto`, GemCode heuristically picks a model for the prompt.
225
+ - **Gemini family routing**: set `GEMCODE_MODEL_FAMILY_MODE=auto|primary|alt`.
226
+ - `primary` uses the `GEMCODE_MODEL*` ids (Gemini 3.x defaults)
227
+ - `alt` uses the `GEMCODE_MODEL_ALT*` ids (Gemini 2.5 family defaults)
228
+ - `auto` uses a cheap prompt heuristic to prefer Gemini 3.x for complex tasks and Gemini 2.5 for simpler ones.
229
+ - **Deep research**: set `--deep-research` (or `GEMCODE_ENABLE_DEEP_RESEARCH=1`) to enable research tools and route to `GEMCODE_MODEL_DEEP_RESEARCH` (default: `travel_explore`).
230
+ - Gemini 3.x tool context circulation (built-in tools + custom/function tools)
231
+ - Enabled by default for `--deep-research` runs, so Search/URL/Maps results can be combined with your custom tools in the same workflow.
232
+ - Controlled by `GEMCODE_TOOL_COMBINATION_MODE` / `--tool-combination-mode` (`deep_research|always|never|auto`, default: `deep_research`).
233
+ - **Embeddings**: set `--embeddings` (or `GEMCODE_ENABLE_EMBEDDINGS=1`) to enable embeddings-based semantic retrieval (and embedding-backed memory when `GEMCODE_ENABLE_MEMORY=1`).
234
+ - **Capability routing**: set `--capability-mode` (or `GEMCODE_CAPABILITY_MODE`) to `auto|research|embeddings|computer|audio|all` to enable the right toolsets (deep research / embeddings / computer-use) and route to role-appropriate models when applicable.
235
+ - **Tool inventory / validation**:
236
+ - `gemcode tools list` prints the exact tool inventory and whether each tool can build a Gemini tool declaration
237
+ - `gemcode tools smoke` fails non-zero if any tool’s declaration compilation fails
238
+ - Optional inspection flags: `--deep-research`, `--maps-grounding`, `--embeddings`, `--memory`
239
+ - **Optional compaction**: set `GEMCODE_ENABLE_COMPACT=1` to trim old `Content` entries before each model call (MVP sliding window; can break complex tool chains if too aggressive—tune `GEMCODE_MAX_CONTENT_ITEMS`).
240
+ - **Session token ceiling**: set `GEMCODE_MAX_SESSION_TOKENS` to stop the next LLM call when cumulative `usage_metadata.total_token_count` exceeds the limit.
241
+ - **Token budget tracking**: set `GEMCODE_TOKEN_BUDGET` to enforce continuation/stop decisions per user turn (token-budget audit in `.gemcode/audit.log`).
242
+ - **Stop-the-loop hooks**: set `GEMCODE_POST_TURN_HOOK=/path/to/hook.sh` (or place an executable at `.gemcode/hooks/post_turn`) to run after each user message.
243
+ - **Circuit breaker**: set `GEMCODE_MAX_CONSECUTIVE_TOOL_FAILURES` to block further tools after N consecutive tool errors.
244
+ - **Recovery-loop**: ADK `ReflectAndRetryToolPlugin`-based retries on tool failures.
245
+ - Set `GEMCODE_ENABLE_TOOL_RECOVERY_RETRY=0` to disable.
246
+ - Set `GEMCODE_TOOL_REFLECT_MAX_RETRIES=1` to control retries per tool.
247
+ - **Gemini thinking controls (Claude-like)**:
248
+ - By default GemCode lets Gemini use its dynamic/adaptive thinking behavior.
249
+ - Set `GEMCODE_DISABLE_THINKING=1` to force a best-effort “low thinking” mode:
250
+ - Gemini 3.x: uses `thinkingLevel=minimal` (can't fully disable)
251
+ - Gemini 2.5: uses `thinkingBudget=0` (disables thinking where supported)
252
+ - Enable thought summaries for debugging with `GEMCODE_INCLUDE_THOUGHT_SUMMARIES=1` (increases tokens/cost).
253
+ - Fine-tune explicitly:
254
+ - `GEMCODE_THINKING_LEVEL=minimal|low|medium|high` (Gemini 3.x only)
255
+ - `GEMCODE_THINKING_BUDGET=0|-1|1024` (Gemini 2.5 only)
256
+ - Additionally, when `model_mode` is set to `fast|balanced|quality` and you
257
+ haven't provided explicit `GEMCODE_THINKING_*` overrides:
258
+ - Gemini 3.x auto-maps `fast|balanced|quality` to `thinkingLevel`
259
+ - Gemini 2.5 auto-maps `fast|balanced|quality` to `thinkingBudget`
260
+ - If `model_mode=auto`, GemCode leaves thinking unmodified.
261
+ - **Persistent memory (optional)**: set `GEMCODE_ENABLE_MEMORY=1` to ingest conversation snippets and retrieve relevant memories on future turns.
262
+ - **Project context**: optional `GEMINI.md` in the project root is injected into the system instruction.
263
+
264
+ ### Permissions
265
+
266
+ - **`GEMCODE_PERMISSION_MODE=strict`**: writes and `run_command` are blocked unless the command name is in `GEMCODE_ALLOW_COMMANDS`.
267
+ - **`default`**: reads always allowed; writes require `--yes`; shell runs only allowlisted commands (see `.env.example`).
268
+ - **In-run HITL permission ask (optional)**:
269
+ - Enable with `--interactive-ask` or `GEMCODE_INTERACTIVE_PERMISSION_ASK=1`.
270
+ - When enabled and you did NOT pass `--yes`, GemCode prompts you in the terminal to approve mutating tools (`write_file`, `search_replace`) and computer-use actions (browser automation).
271
+ - If you don’t approve, the tool call is blocked (no silent re-execution).
272
+
273
+ When tools are blocked by policy, the consecutive-tool circuit breaker does not count those policy rejections as “tool failures”.
274
+
275
+ Optional debugging: set `GEMCODE_EMIT_TOOL_USE_SUMMARIES=1` to write a lightweight `tool_result` record per tool into `.gemcode/audit.log`.
276
+
277
+ ### Optional MCP
278
+
279
+ Install with `pip install -e ".[mcp]"` and create `.gemcode/mcp.json` (see [gemcode/mcp_loader.py](src/gemcode/mcp_loader.py)). Run with `--mcp` to attach configured servers.
280
+
281
+ ### Vertex AI / Interactions API
282
+
283
+ See [src/gemcode/vertex.py](src/gemcode/vertex.py) and [src/gemcode/interactions.py](src/gemcode/interactions.py) for environment variables and future wiring.
284
+
285
+ ## Tools and “Powers”
286
+
287
+ GemCode wires tools into Gemini via ADK in a Claude Code–style outer/inner
288
+ loop:
289
+
290
+ - **Outer loop** (your CLI / session) sets model + tools + safety gates and
291
+ then streams the resulting Events.
292
+ - **Inner loop** (inside ADK) repeatedly calls the model and executes tools
293
+ until completion or stop conditions.
294
+
295
+ ### Core function tools (custom, always available)
296
+
297
+ GemCode always exposes a set of function tools you can use to read and edit
298
+ the user’s project.
299
+
300
+ - Read-only tools (typically allowed without `--yes`):
301
+ - `read_file`
302
+ - `list_directory`
303
+ - `glob_files`
304
+ - `grep_content`
305
+ - Mutating tools (require `--yes` unless your policy blocks them):
306
+ - `write_file`
307
+ - `search_replace`
308
+ - Shell execution:
309
+ - `run_command` (guarded by `GEMCODE_ALLOW_COMMANDS` from `.env.example` and
310
+ `GEMCODE_PERMISSION_MODE`).
311
+
312
+ Tool execution is still controlled by permission gates and then governed by
313
+ GemCode’s circuit breaker + recovery behavior.
314
+
315
+ ### In-run interactive permission ask (HITL)
316
+
317
+ GemCode can switch from “fail closed unless you re-run with `--yes`” to an
318
+ in-run approval workflow:
319
+
320
+ - If enabled (`--interactive-ask` / `GEMCODE_INTERACTIVE_PERMISSION_ASK=1`) and you did not pass `--yes`,
321
+ any mutating tool call or computer-use action will trigger a terminal prompt.
322
+ - Approving continues the same run; rejecting blocks the tool call.
323
+
324
+ This applies to both the standard CLI (`gemcode "..."`) and the Kairos daemon (`gemcode kairos`).
325
+
326
+ ### Kairos proactive scheduler (daemon)
327
+
328
+ `gemcode kairos` runs a long-lived scheduler that turns prompts into queued
329
+ jobs:
330
+
331
+ - You type one prompt per line into stdin; each line becomes a job.
332
+ - Jobs are run with a priority queue; the daemon also exposes Kairos tools so
333
+ the model itself can `kairos_enqueue_prompt()` additional work.
334
+
335
+ Kairos tools available to the model (per job):
336
+
337
+ - `kairos_sleep_ms(duration_ms: int)`: pauses just that job for `duration_ms` without blocking other queued jobs.
338
+ - `kairos_enqueue_prompt(prompt: str, priority: int = 0, session_id: str | None = None)`:
339
+ enqueues a new job. If `session_id` is omitted, it defaults to the current job’s session.
340
+
341
+ Priority defaults for stdin-enqueued jobs are controlled by `--default-priority`.
342
+
343
+ ### Deep research (built-in Gemini tools + optional tool combination)
344
+
345
+ When deep research is enabled (CLI `--deep-research` or `GEMCODE_ENABLE_DEEP_RESEARCH=1`),
346
+ GemCode injects Gemini built-in tools:
347
+
348
+ - `google_search`
349
+ - `url_context`
350
+ - `google_maps_grounding` (optional; only injected when explicitly enabled via
351
+ `--maps-grounding` or `GEMCODE_ENABLE_MAPS_GROUNDING=1`)
352
+
353
+ On Gemini **3.x** models, GemCode can additionally enable Gemini’s built-in
354
+ tool context circulation so built-in results (Search/URL/Maps) can be
355
+ combined with your custom tools in the same workflow:
356
+
357
+ - Controlled by `GEMCODE_TOOL_COMBINATION_MODE` / `--tool-combination-mode`
358
+ (`deep_research|always|never|auto`, default: `deep_research`).
359
+
360
+ ### Embeddings (semantic retrieval + embedding-backed memory)
361
+
362
+ When embeddings are enabled (`--embeddings` or `GEMCODE_ENABLE_EMBEDDINGS=1`),
363
+ GemCode injects a semantic retrieval tool:
364
+
365
+ - `semantic_search_files` (embeds query + candidate file chunks, ranks via cosine similarity).
366
+
367
+ If you also enable persistent memory ingestion (`GEMCODE_ENABLE_MEMORY=1`),
368
+ GemCode uses embedding-backed memory storage:
369
+
370
+ - `EmbeddingFileMemoryService` stores both text and vectors in `.gemcode/memories.jsonl`.
371
+ - Retrieval uses cosine similarity and falls back to keyword search when needed.
372
+
373
+ ### Computer Use (optional, gated browser automation)
374
+
375
+ When computer use is enabled (`GEMCODE_ENABLE_COMPUTER_USE=1` or `--capability-mode computer`),
376
+ GemCode adds an ADK `ComputerUseToolset` backed by Playwright (`BrowserComputer`).
377
+
378
+ Notes:
379
+
380
+ - Requires optional deps: `playwright` (and you should run `playwright install`).
381
+ - Browser automation actions are **still permission-gated**:
382
+ - In `default` permission mode, computer-use tool calls require `--yes`.
383
+ - In `strict` mode, computer use is denied.
384
+ - Headless mode is controlled by `GEMCODE_COMPUTER_HEADLESS`.
385
+
386
+ ### Live audio (Gemini Live API via ADK)
387
+
388
+ GemCode also supports real-time audio sessions via `gemcode live-audio`.
389
+ It streams microphone audio to Gemini using ADK’s `Runner.run_live()` and
390
+ prints model text parts.
391
+
392
+ This MVP requires optional deps:
393
+
394
+ - `sounddevice`
395
+ - `numpy`
396
+
397
+ You can configure:
398
+
399
+ - record duration (`--seconds`)
400
+ - PCM sample rate (`--rate`)
401
+ - optional language (`--language`)
402
+ - optional model override (`--model`, must support AUDIO streaming)
403
+
404
+ ### Memory ingestion + prompt suggestions
405
+
406
+ After each run, `GemCodeTerminalHooksPlugin`:
407
+
408
+ - writes a structured terminal reason to `.gemcode/audit.log`
409
+ - optionally ingests the session into memory (via ADK memory integration)
410
+ - optionally generates “next-step” prompt suggestions:
411
+ - uses `gemcode/prompt_suggestions.py` heuristics
412
+ - if `GEMCODE_PROMPT_SUGGESTIONS_USE_INTERACTIONS=1`, it can also call Gemini
413
+ using the Interactions API to produce a better suggestion
414
+ - runs your stopHooks-like post-turn script from `GEMCODE_POST_TURN_HOOK` (or
415
+ `.gemcode/hooks/post_turn`)
416
+
417
+ ### Safety, circuit breaker, and recovery
418
+
419
+ GemCode enforces:
420
+
421
+ - **Permission gates** via ADK callbacks:
422
+ - `GEMCODE_PERMISSION_MODE=strict` blocks writes and shell (unless allowlisted)
423
+ - mutating + computer-use tool calls require `--yes` in default mode
424
+ - **Consecutive tool failure circuit breaker**:
425
+ - capped by `GEMCODE_MAX_CONSECUTIVE_TOOL_FAILURES`
426
+ - policy rejections don’t increment the streak
427
+ - **Recovery-loop**:
428
+ - ADK `ReflectAndRetryToolPlugin`-based retries on retryable tool errors
429
+ - recovery skips policy denials and circuit breaker blocks
430
+
431
+ ## Development
432
+
433
+ ```bash
434
+ pip install -e ".[dev]"
435
+ pytest
436
+ ```
437
+
438
+ ## References (local only)
439
+
440
+ Do not commit proprietary leaked trees into this package. Keep `claude-code-leaked/` and similar folders outside version control or in a private mirror.