closecode-ai 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 (31) hide show
  1. closecode_ai-0.2.1/PKG-INFO +252 -0
  2. closecode_ai-0.2.1/README.md +229 -0
  3. closecode_ai-0.2.1/closecode_ai.egg-info/PKG-INFO +252 -0
  4. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/closecode_ai.egg-info/SOURCES.txt +3 -0
  5. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/closecode_ai.egg-info/requires.txt +1 -0
  6. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/closecode_ai.egg-info/top_level.txt +3 -0
  7. closecode_ai-0.2.1/config.py +60 -0
  8. closecode_ai-0.2.1/main.py +628 -0
  9. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/pyproject.toml +7 -3
  10. closecode_ai-0.2.1/render.py +98 -0
  11. closecode_ai-0.2.1/tui.py +1041 -0
  12. closecode_ai-0.1.0/PKG-INFO +0 -138
  13. closecode_ai-0.1.0/README.md +0 -116
  14. closecode_ai-0.1.0/closecode_ai.egg-info/PKG-INFO +0 -138
  15. closecode_ai-0.1.0/main.py +0 -520
  16. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/agent.py +0 -0
  17. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/closecode_ai.egg-info/dependency_links.txt +0 -0
  18. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/closecode_ai.egg-info/entry_points.txt +0 -0
  19. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/debug_response.py +0 -0
  20. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/guardrails.py +0 -0
  21. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/harness.py +0 -0
  22. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/llm.py +0 -0
  23. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/mcp_tools.py +0 -0
  24. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/modes.py +0 -0
  25. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/search.py +0 -0
  26. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/session.py +0 -0
  27. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/setup.cfg +0 -0
  28. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/todos.py +0 -0
  29. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/token_tracker.py +0 -0
  30. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/tools.py +0 -0
  31. {closecode_ai-0.1.0 → closecode_ai-0.2.1}/ui.py +0 -0
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.4
2
+ Name: closecode-ai
3
+ Version: 0.2.1
4
+ Summary: CloseCode — an agentic terminal coding assistant (LangGraph + OpenRouter + MCP)
5
+ Author: Om Gite
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: langchain
10
+ Requires-Dist: langgraph
11
+ Requires-Dist: langchain-huggingface
12
+ Requires-Dist: langsmith
13
+ Requires-Dist: huggingface_hub
14
+ Requires-Dist: python-dotenv
15
+ Requires-Dist: requests
16
+ Requires-Dist: langchain-openai
17
+ Requires-Dist: langchain-mcp-adapters
18
+ Requires-Dist: mcp-server-git
19
+ Requires-Dist: langchain-openrouter
20
+ Requires-Dist: rich
21
+ Requires-Dist: pyfiglet
22
+ Requires-Dist: textual
23
+
24
+ # terminal-agent
25
+
26
+ ## Your AI Coding Assistant
27
+
28
+ **terminal-agent** is a helpful AI coding partner that lives right in your terminal. It can read your code, make changes, run tests, and help you debug—all through natural language commands.
29
+
30
+ Think of it as having a smart programmer buddy who can:
31
+ - 📖 Read and understand your code
32
+ - ✏️ Make changes to files
33
+ - ▶️ Run commands and tests
34
+ - 🔍 Search for information online
35
+ - 💾 Remember your work across sessions
36
+
37
+ ## How It Works (Simple Explanation)
38
+
39
+ The agent follows a simple loop:
40
+ 1. **You give it a task** (like "fix this bug" or "add a login feature")
41
+ 2. **It thinks about what to do** and picks the right tools
42
+ 3. **It does the work** (reads files, runs commands, makes changes)
43
+ 4. **It sees what happened** and adjusts if needed
44
+ 5. **It repeats until the task is done**
45
+
46
+ This is similar to how other AI coding assistants work, but built with modern AI frameworks.
47
+
48
+ ## Quick Start Guide
49
+
50
+ ### Step 1: Install Everything
51
+ ```bash
52
+ pip install -r requirements.txt
53
+ ```
54
+
55
+ ### Step 2: Get Your API Key
56
+ You need an API key from [OpenRouter](https://openrouter.ai/settings/keys) (it's free to sign up).
57
+
58
+ ### Step 3: Set Up Your Environment
59
+ ```bash
60
+ cp .env.example .env
61
+ ```
62
+
63
+ Edit the `.env` file and add your OpenRouter API key:
64
+ ```
65
+ OPENROUTER_API_KEY=your_actual_api_key_here
66
+ ```
67
+
68
+ ### Step 4: Run the Agent
69
+ ```bash
70
+ python main.py
71
+ ```
72
+
73
+ The agent will start and ask for your API key if you haven't set it up yet.
74
+
75
+ ## Two Modes for Safe Work
76
+
77
+ The agent has two modes to help you work safely:
78
+
79
+ ### 🔍 **Plan Mode** (`/plan`)
80
+ - **What it is**: Safe, look-but-don't-touch mode
81
+ - **What you can do**: Read files, search for information, explore code
82
+ - **What you CANNOT do**: Change files, run commands, make modifications
83
+ - **Best for**: Understanding a codebase before making changes
84
+
85
+ ### 🛠️ **Build Mode** (`/build`)
86
+ - **What it is**: Full access mode
87
+ - **What you can do**: Everything in Plan mode PLUS edit files, run commands, make changes
88
+ - **Best for**: Actually implementing fixes and features
89
+
90
+ Switch modes anytime with `/plan` or `/build`.
91
+
92
+ ## What the Agent Can Do (Tools)
93
+
94
+ | Tool | What it does | Example use |
95
+ |------|-------------|-------------|
96
+ | `read_file` | Look at any text file | "Show me the main.py file" |
97
+ | `write_file` | Create or replace files | "Create a new config file" |
98
+ | `edit_file` | Make precise changes | "Fix the typo in line 42" |
99
+ | `list_dir` | See what's in a folder | "What files are in src/?" |
100
+ | `bash` | Run terminal commands | "Run the tests" or "Install this package" |
101
+ | `run_tests` | Run your test suite | "Are all tests passing?" |
102
+ | `tavily_search` | Search the web | "How do I use React hooks?" |
103
+ | `todo_write` / `todo_read` | Manage task lists | "Break this feature into steps" |
104
+
105
+ ## Helpful Commands
106
+
107
+ ### Managing Your Work
108
+ - `/sessions` - See all your saved conversations
109
+ - `/resume <id>` - Continue a previous session
110
+ - `/delete <id>` - Delete a saved session
111
+ - `--continue` - Automatically resume last session when starting
112
+
113
+ ### Choosing Your AI
114
+ - `/models` - See available AI models (free ones first)
115
+ - `/model <number>` - Switch to a different model
116
+ - `/key` - Change your API key
117
+
118
+ ### Other Useful Commands
119
+ - `/help` - Show all available commands
120
+ - `/clear` - Start fresh with a new session
121
+ - `/usage` - Check how much AI you've used
122
+ - `/compact` - Clean up old session data
123
+
124
+ ## Saving and Coming Back Later
125
+
126
+ Your work is automatically saved! You can:
127
+ 1. **Start fresh**: Just type your first task when you run the agent
128
+ 2. **Come back later**: Use `/sessions` to see past work, then `/resume <number>`
129
+ 3. **Auto-continue**: Run `python main.py --continue` to pick up where you left off
130
+
131
+ Each session remembers:
132
+ - Which AI model you were using
133
+ - Whether you were in Plan or Build mode
134
+ - A name based on what you first asked for
135
+
136
+ ## Safety First
137
+
138
+ The agent has built-in protections to keep you safe:
139
+
140
+ ### 🛡️ **Smart Input Filtering**
141
+ - Blocks requests for harmful things (like hacking tools)
142
+ - Redirects off-topic chat back to coding tasks
143
+ - Prevents obvious security risks
144
+
145
+ ### ⚠️ **Command Safety**
146
+ - Blocks dangerous commands (like deleting your whole system)
147
+ - Stops reverse shells and other risky operations
148
+ - Works even if you turn on auto-approval
149
+
150
+ ### 🔍 **Content Checking**
151
+ - Scans file changes for malicious code patterns
152
+ - Prevents creating harmful software
153
+ - Asks for confirmation before risky actions
154
+
155
+ ### ✋ **Permission Prompts**
156
+ - Asks before running commands: "Allow agent to run: `npm install`?"
157
+ - Asks before writing files: "Allow agent to write 500 chars to `config.json`?"
158
+ - You can skip these with `AGENT_AUTO_APPROVE=true` in `.env` (not recommended for beginners)
159
+
160
+ ## Choosing an AI Model
161
+
162
+ Different AI models work better for coding. Here's a quick guide:
163
+
164
+ ### 🏆 **Top Recommendations**
165
+ 1. **Qwen/Qwen2.5-72B-Instruct** - Great balance of ability and speed
166
+ 2. **meta-llama/Meta-Llama-3.1-70B-Instruct** - Very reliable for coding tasks
167
+ 3. **meta-llama/Meta-Llama-3.1-8B-Instruct** - Fastest/cheapest, but less reliable
168
+
169
+ ### 💰 **Free vs Paid**
170
+ - **Free models** (marked `:free`): Cost nothing to use
171
+ - **Paid models**: More consistent, but charge per usage
172
+
173
+ ### 🔄 **How to Switch Models**
174
+ 1. Type `/models` to see the list
175
+ 2. Type `/model 3` to use the 3rd model in the list
176
+ 3. Or type the full name: `/model qwen/qwen-2.5-72b-instruct`
177
+
178
+ ## Common Things You Can Do
179
+
180
+ ### 🐛 **Fixing Bugs**
181
+ > "Why is my login function throwing an error on line 23?"
182
+
183
+ ### 🔍 **Exploring Code**
184
+ > "Show me all the Python files and explain what each one does"
185
+
186
+ ### ✨ **Adding Features**
187
+ > "Add a dark mode toggle to this website"
188
+
189
+ ### 🧹 **Cleaning Up Code**
190
+ > "Refactor this function to be easier to read"
191
+
192
+ ### 📚 **Writing Documentation**
193
+ > "Create a README explaining how to install and use this project"
194
+
195
+ ### ✅ **Testing**
196
+ > "Run all the tests and tell me what's failing"
197
+
198
+ ## Troubleshooting Tips
199
+
200
+ ### ❌ "Agent isn't responding"
201
+ - Check your internet connection (needed for AI calls)
202
+ - Verify your API key is correct in `.env`
203
+ - Try a different model: `/model meta-llama/Meta-Llama-3.1-70B-Instruct`
204
+
205
+ ### ⚙️ "Commands aren't working"
206
+ - Make sure you're in the right project folder
207
+ - Check if files exist: try `list_dir` first
208
+ - Start in Plan mode (`/plan`) to explore safely
209
+
210
+ ### 💾 "My work isn't saving"
211
+ - Work saves automatically after each turn
212
+ - Use `/sessions` to see all saved conversations
213
+ - Use `--continue` when starting to resume previous work
214
+
215
+ ### 🤖 "AI keeps making mistakes"
216
+ - Try a more reliable model (the paid ones often work better)
217
+ - Break your task into smaller steps
218
+ - Use Plan mode first to understand the problem
219
+
220
+ ## Advanced Features (When You're Ready)
221
+
222
+ ### 📊 **See What the Agent is Doing**
223
+ If you get a LangChain API key (free at smith.langchain.com):
224
+ 1. Add `LANGCHAIN_API_KEY=your_key` to `.env`
225
+ 2. Watch detailed traces at https://smith.langchain.com
226
+
227
+ ### 📂 **Work with Git**
228
+ Enable with `AGENT_ENABLE_GIT=true` to use:
229
+ - `git status` - See what changed
230
+ - `git diff` - View exact changes
231
+ - `git commit` - Save your work
232
+
233
+ ### 🗂️ **Use a Sandbox Folder**
234
+ Keep experiments separate:
235
+ ```bash
236
+ AGENT_WORKDIR=./sandbox python main.py
237
+ ```
238
+ This keeps the agent confined to a specific folder.
239
+
240
+ ## Ready to Try?
241
+
242
+ Just run:
243
+ ```bash
244
+ python main.py
245
+ ```
246
+
247
+ Then try something simple like:
248
+ - "What files are in this project?"
249
+ - "Explain what this code does" (point it at a file)
250
+ - "Help me fix this error" (share the error message)
251
+
252
+ The agent is here to help you code better and faster. Happy coding! 🚀
@@ -0,0 +1,229 @@
1
+ # terminal-agent
2
+
3
+ ## Your AI Coding Assistant
4
+
5
+ **terminal-agent** is a helpful AI coding partner that lives right in your terminal. It can read your code, make changes, run tests, and help you debug—all through natural language commands.
6
+
7
+ Think of it as having a smart programmer buddy who can:
8
+ - 📖 Read and understand your code
9
+ - ✏️ Make changes to files
10
+ - ▶️ Run commands and tests
11
+ - 🔍 Search for information online
12
+ - 💾 Remember your work across sessions
13
+
14
+ ## How It Works (Simple Explanation)
15
+
16
+ The agent follows a simple loop:
17
+ 1. **You give it a task** (like "fix this bug" or "add a login feature")
18
+ 2. **It thinks about what to do** and picks the right tools
19
+ 3. **It does the work** (reads files, runs commands, makes changes)
20
+ 4. **It sees what happened** and adjusts if needed
21
+ 5. **It repeats until the task is done**
22
+
23
+ This is similar to how other AI coding assistants work, but built with modern AI frameworks.
24
+
25
+ ## Quick Start Guide
26
+
27
+ ### Step 1: Install Everything
28
+ ```bash
29
+ pip install -r requirements.txt
30
+ ```
31
+
32
+ ### Step 2: Get Your API Key
33
+ You need an API key from [OpenRouter](https://openrouter.ai/settings/keys) (it's free to sign up).
34
+
35
+ ### Step 3: Set Up Your Environment
36
+ ```bash
37
+ cp .env.example .env
38
+ ```
39
+
40
+ Edit the `.env` file and add your OpenRouter API key:
41
+ ```
42
+ OPENROUTER_API_KEY=your_actual_api_key_here
43
+ ```
44
+
45
+ ### Step 4: Run the Agent
46
+ ```bash
47
+ python main.py
48
+ ```
49
+
50
+ The agent will start and ask for your API key if you haven't set it up yet.
51
+
52
+ ## Two Modes for Safe Work
53
+
54
+ The agent has two modes to help you work safely:
55
+
56
+ ### 🔍 **Plan Mode** (`/plan`)
57
+ - **What it is**: Safe, look-but-don't-touch mode
58
+ - **What you can do**: Read files, search for information, explore code
59
+ - **What you CANNOT do**: Change files, run commands, make modifications
60
+ - **Best for**: Understanding a codebase before making changes
61
+
62
+ ### 🛠️ **Build Mode** (`/build`)
63
+ - **What it is**: Full access mode
64
+ - **What you can do**: Everything in Plan mode PLUS edit files, run commands, make changes
65
+ - **Best for**: Actually implementing fixes and features
66
+
67
+ Switch modes anytime with `/plan` or `/build`.
68
+
69
+ ## What the Agent Can Do (Tools)
70
+
71
+ | Tool | What it does | Example use |
72
+ |------|-------------|-------------|
73
+ | `read_file` | Look at any text file | "Show me the main.py file" |
74
+ | `write_file` | Create or replace files | "Create a new config file" |
75
+ | `edit_file` | Make precise changes | "Fix the typo in line 42" |
76
+ | `list_dir` | See what's in a folder | "What files are in src/?" |
77
+ | `bash` | Run terminal commands | "Run the tests" or "Install this package" |
78
+ | `run_tests` | Run your test suite | "Are all tests passing?" |
79
+ | `tavily_search` | Search the web | "How do I use React hooks?" |
80
+ | `todo_write` / `todo_read` | Manage task lists | "Break this feature into steps" |
81
+
82
+ ## Helpful Commands
83
+
84
+ ### Managing Your Work
85
+ - `/sessions` - See all your saved conversations
86
+ - `/resume <id>` - Continue a previous session
87
+ - `/delete <id>` - Delete a saved session
88
+ - `--continue` - Automatically resume last session when starting
89
+
90
+ ### Choosing Your AI
91
+ - `/models` - See available AI models (free ones first)
92
+ - `/model <number>` - Switch to a different model
93
+ - `/key` - Change your API key
94
+
95
+ ### Other Useful Commands
96
+ - `/help` - Show all available commands
97
+ - `/clear` - Start fresh with a new session
98
+ - `/usage` - Check how much AI you've used
99
+ - `/compact` - Clean up old session data
100
+
101
+ ## Saving and Coming Back Later
102
+
103
+ Your work is automatically saved! You can:
104
+ 1. **Start fresh**: Just type your first task when you run the agent
105
+ 2. **Come back later**: Use `/sessions` to see past work, then `/resume <number>`
106
+ 3. **Auto-continue**: Run `python main.py --continue` to pick up where you left off
107
+
108
+ Each session remembers:
109
+ - Which AI model you were using
110
+ - Whether you were in Plan or Build mode
111
+ - A name based on what you first asked for
112
+
113
+ ## Safety First
114
+
115
+ The agent has built-in protections to keep you safe:
116
+
117
+ ### 🛡️ **Smart Input Filtering**
118
+ - Blocks requests for harmful things (like hacking tools)
119
+ - Redirects off-topic chat back to coding tasks
120
+ - Prevents obvious security risks
121
+
122
+ ### ⚠️ **Command Safety**
123
+ - Blocks dangerous commands (like deleting your whole system)
124
+ - Stops reverse shells and other risky operations
125
+ - Works even if you turn on auto-approval
126
+
127
+ ### 🔍 **Content Checking**
128
+ - Scans file changes for malicious code patterns
129
+ - Prevents creating harmful software
130
+ - Asks for confirmation before risky actions
131
+
132
+ ### ✋ **Permission Prompts**
133
+ - Asks before running commands: "Allow agent to run: `npm install`?"
134
+ - Asks before writing files: "Allow agent to write 500 chars to `config.json`?"
135
+ - You can skip these with `AGENT_AUTO_APPROVE=true` in `.env` (not recommended for beginners)
136
+
137
+ ## Choosing an AI Model
138
+
139
+ Different AI models work better for coding. Here's a quick guide:
140
+
141
+ ### 🏆 **Top Recommendations**
142
+ 1. **Qwen/Qwen2.5-72B-Instruct** - Great balance of ability and speed
143
+ 2. **meta-llama/Meta-Llama-3.1-70B-Instruct** - Very reliable for coding tasks
144
+ 3. **meta-llama/Meta-Llama-3.1-8B-Instruct** - Fastest/cheapest, but less reliable
145
+
146
+ ### 💰 **Free vs Paid**
147
+ - **Free models** (marked `:free`): Cost nothing to use
148
+ - **Paid models**: More consistent, but charge per usage
149
+
150
+ ### 🔄 **How to Switch Models**
151
+ 1. Type `/models` to see the list
152
+ 2. Type `/model 3` to use the 3rd model in the list
153
+ 3. Or type the full name: `/model qwen/qwen-2.5-72b-instruct`
154
+
155
+ ## Common Things You Can Do
156
+
157
+ ### 🐛 **Fixing Bugs**
158
+ > "Why is my login function throwing an error on line 23?"
159
+
160
+ ### 🔍 **Exploring Code**
161
+ > "Show me all the Python files and explain what each one does"
162
+
163
+ ### ✨ **Adding Features**
164
+ > "Add a dark mode toggle to this website"
165
+
166
+ ### 🧹 **Cleaning Up Code**
167
+ > "Refactor this function to be easier to read"
168
+
169
+ ### 📚 **Writing Documentation**
170
+ > "Create a README explaining how to install and use this project"
171
+
172
+ ### ✅ **Testing**
173
+ > "Run all the tests and tell me what's failing"
174
+
175
+ ## Troubleshooting Tips
176
+
177
+ ### ❌ "Agent isn't responding"
178
+ - Check your internet connection (needed for AI calls)
179
+ - Verify your API key is correct in `.env`
180
+ - Try a different model: `/model meta-llama/Meta-Llama-3.1-70B-Instruct`
181
+
182
+ ### ⚙️ "Commands aren't working"
183
+ - Make sure you're in the right project folder
184
+ - Check if files exist: try `list_dir` first
185
+ - Start in Plan mode (`/plan`) to explore safely
186
+
187
+ ### 💾 "My work isn't saving"
188
+ - Work saves automatically after each turn
189
+ - Use `/sessions` to see all saved conversations
190
+ - Use `--continue` when starting to resume previous work
191
+
192
+ ### 🤖 "AI keeps making mistakes"
193
+ - Try a more reliable model (the paid ones often work better)
194
+ - Break your task into smaller steps
195
+ - Use Plan mode first to understand the problem
196
+
197
+ ## Advanced Features (When You're Ready)
198
+
199
+ ### 📊 **See What the Agent is Doing**
200
+ If you get a LangChain API key (free at smith.langchain.com):
201
+ 1. Add `LANGCHAIN_API_KEY=your_key` to `.env`
202
+ 2. Watch detailed traces at https://smith.langchain.com
203
+
204
+ ### 📂 **Work with Git**
205
+ Enable with `AGENT_ENABLE_GIT=true` to use:
206
+ - `git status` - See what changed
207
+ - `git diff` - View exact changes
208
+ - `git commit` - Save your work
209
+
210
+ ### 🗂️ **Use a Sandbox Folder**
211
+ Keep experiments separate:
212
+ ```bash
213
+ AGENT_WORKDIR=./sandbox python main.py
214
+ ```
215
+ This keeps the agent confined to a specific folder.
216
+
217
+ ## Ready to Try?
218
+
219
+ Just run:
220
+ ```bash
221
+ python main.py
222
+ ```
223
+
224
+ Then try something simple like:
225
+ - "What files are in this project?"
226
+ - "Explain what this code does" (point it at a file)
227
+ - "Help me fix this error" (share the error message)
228
+
229
+ The agent is here to help you code better and faster. Happy coding! 🚀