browse-code 0.1.1__tar.gz → 0.2.0__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 (27) hide show
  1. browse_code-0.2.0/PKG-INFO +124 -0
  2. browse_code-0.2.0/README.md +110 -0
  3. browse_code-0.2.0/browse_code/__init__.py +1 -0
  4. browse_code-0.2.0/browse_code/cli.py +204 -0
  5. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code/extension/content.js +362 -362
  6. browse_code-0.2.0/browse_code/extension/icon128.png +0 -0
  7. browse_code-0.2.0/browse_code/extension/icon16.png +0 -0
  8. browse_code-0.2.0/browse_code/extension/icon48.png +0 -0
  9. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code/extension/manifest.json +39 -29
  10. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code/extension/popup.html +108 -108
  11. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code/extension/popup.js +89 -89
  12. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code/extension/spoof.js +2 -2
  13. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code/server.py +597 -597
  14. browse_code-0.2.0/browse_code.egg-info/PKG-INFO +124 -0
  15. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code.egg-info/SOURCES.txt +3 -0
  16. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code.egg-info/requires.txt +1 -0
  17. {browse_code-0.1.1 → browse_code-0.2.0}/setup.cfg +4 -4
  18. {browse_code-0.1.1 → browse_code-0.2.0}/setup.py +6 -3
  19. browse_code-0.1.1/PKG-INFO +0 -9
  20. browse_code-0.1.1/README.md +0 -69
  21. browse_code-0.1.1/browse_code/__init__.py +0 -1
  22. browse_code-0.1.1/browse_code/cli.py +0 -133
  23. browse_code-0.1.1/browse_code.egg-info/PKG-INFO +0 -9
  24. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code.egg-info/dependency_links.txt +0 -0
  25. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code.egg-info/entry_points.txt +0 -0
  26. {browse_code-0.1.1 → browse_code-0.2.0}/browse_code.egg-info/top_level.txt +0 -0
  27. {browse_code-0.1.1 → browse_code-0.2.0}/pyproject.toml +0 -0
@@ -0,0 +1,124 @@
1
+ Metadata-Version: 2.4
2
+ Name: browse_code
3
+ Version: 0.2.0
4
+ Summary: Turn any AI chatbot into an autonomous coding agent
5
+ Description-Content-Type: text/markdown
6
+ Requires-Dist: fastapi
7
+ Requires-Dist: uvicorn
8
+ Requires-Dist: pydantic
9
+ Requires-Dist: rich
10
+ Dynamic: description
11
+ Dynamic: description-content-type
12
+ Dynamic: requires-dist
13
+ Dynamic: summary
14
+
15
+ <p align="center">
16
+ <img src="logo.png" alt="Browse Code" width="200">
17
+ </p>
18
+
19
+ # Browse Code
20
+
21
+ ![PyPI version](https://badge.fury.io/py/browse-code.svg)
22
+ ![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)
23
+ ![License](https://img.shields.io/badge/license-MIT-green)
24
+
25
+ **Browse Code** is a CLI tool that turns any AI chatbot (ChatGPT, Gemini, Claude, HuggingFace) into an autonomous coding agent. It bridges your browser and local terminal, letting AI read/write files, run commands, and manage processes on your machine.
26
+
27
+ ## How It Works
28
+
29
+ Browse Code has two parts:
30
+
31
+ 1. **A local server** that exposes your file system and terminal to the AI via a secure API.
32
+ 2. **A Chrome extension** that injects agent capabilities into AI chat interfaces.
33
+
34
+ When connected, you can ask ChatGPT/Gemini/Claude to edit files, run scripts, search code, and more — all executed locally on your machine.
35
+
36
+ ## Setup
37
+
38
+ ### Step 1: Install the package
39
+
40
+ ```bash
41
+ pip install browse-code
42
+ ```
43
+
44
+ ### Step 2: Run the CLI
45
+
46
+ ```bash
47
+ bc
48
+ ```
49
+
50
+ > If `bc` is not found, add your Python Scripts folder to PATH:
51
+ > ```bash
52
+ > # Windows (PowerShell)
53
+ > $env:Path += ";$env:APPDATA\Python\Python312\Scripts"
54
+ >
55
+ > # Or run directly
56
+ > python -m browse_code.cli
57
+ > ```
58
+
59
+ ### Step 3: First-run extension setup
60
+
61
+ On the first run, `bc` will guide you through a one-time Chrome extension setup:
62
+
63
+ 1. It asks for your permission to extract the extension files.
64
+ 2. It copies the extension to `~/.browse_code/extension/` and copies the path to your clipboard.
65
+ 3. It opens `chrome://extensions/` in your browser automatically.
66
+ 4. You enable **Developer mode** (top-right toggle), click **Load unpacked**, and paste the path.
67
+ 5. Press Enter in the terminal and the server starts.
68
+
69
+ **You only do this once.** The extension stays loaded in Chrome across sessions.
70
+
71
+ ### Step 4: Start an AI session
72
+
73
+ 1. Open any supported AI chat (ChatGPT, Gemini, Claude, or HuggingFace Chat).
74
+ 2. Click the Browse Code Bridge extension icon and set your workspace directory.
75
+ 3. Click "Initialize Agent in Chat".
76
+ 4. Start coding with AI — it now has full access to your local environment.
77
+
78
+ ## Subsequent Usage
79
+
80
+ After the first-time setup, just run:
81
+
82
+ ```bash
83
+ bc
84
+ ```
85
+
86
+ The server starts immediately. Open your AI chat tab and you're ready to go. The server terminal will show:
87
+ - A startup banner with your workspace and endpoint
88
+ - `[+] Extension connected` when the browser extension connects
89
+ - Real-time logs of every file read, write, command execution, and diff
90
+
91
+ ## Features
92
+
93
+ - **File Operations:** Read, write, and patch files with inline terminal diffs
94
+ - **Code Search:** Search across your entire codebase by keyword
95
+ - **Terminal Commands:** Run shell commands with full stdout/stderr capture
96
+ - **Background Processes:** Start, monitor, and kill long-running processes
97
+ - **Multi-Platform AI:** Works with ChatGPT, Gemini, Claude, and HuggingFace Chat
98
+ - **Extension Heartbeat:** Server detects when the browser extension connects/disconnects
99
+
100
+ ## For Developers
101
+
102
+ 1. Clone the repository:
103
+ ```bash
104
+ git clone https://github.com/Dedeep007/browse_code.git
105
+ cd browse_code
106
+ ```
107
+ 2. Install in editable mode:
108
+ ```bash
109
+ pip install -e .
110
+ ```
111
+
112
+ ## Contributing
113
+
114
+ Contributions are welcome! Please feel free to submit a Pull Request.
115
+
116
+ 1. Fork the repository.
117
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`).
118
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).
119
+ 4. Push to the branch (`git push origin feature/AmazingFeature`).
120
+ 5. Open a Pull Request.
121
+
122
+ ## License
123
+
124
+ Distributed under the MIT License.
@@ -0,0 +1,110 @@
1
+ <p align="center">
2
+ <img src="logo.png" alt="Browse Code" width="200">
3
+ </p>
4
+
5
+ # Browse Code
6
+
7
+ ![PyPI version](https://badge.fury.io/py/browse-code.svg)
8
+ ![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)
9
+ ![License](https://img.shields.io/badge/license-MIT-green)
10
+
11
+ **Browse Code** is a CLI tool that turns any AI chatbot (ChatGPT, Gemini, Claude, HuggingFace) into an autonomous coding agent. It bridges your browser and local terminal, letting AI read/write files, run commands, and manage processes on your machine.
12
+
13
+ ## How It Works
14
+
15
+ Browse Code has two parts:
16
+
17
+ 1. **A local server** that exposes your file system and terminal to the AI via a secure API.
18
+ 2. **A Chrome extension** that injects agent capabilities into AI chat interfaces.
19
+
20
+ When connected, you can ask ChatGPT/Gemini/Claude to edit files, run scripts, search code, and more — all executed locally on your machine.
21
+
22
+ ## Setup
23
+
24
+ ### Step 1: Install the package
25
+
26
+ ```bash
27
+ pip install browse-code
28
+ ```
29
+
30
+ ### Step 2: Run the CLI
31
+
32
+ ```bash
33
+ bc
34
+ ```
35
+
36
+ > If `bc` is not found, add your Python Scripts folder to PATH:
37
+ > ```bash
38
+ > # Windows (PowerShell)
39
+ > $env:Path += ";$env:APPDATA\Python\Python312\Scripts"
40
+ >
41
+ > # Or run directly
42
+ > python -m browse_code.cli
43
+ > ```
44
+
45
+ ### Step 3: First-run extension setup
46
+
47
+ On the first run, `bc` will guide you through a one-time Chrome extension setup:
48
+
49
+ 1. It asks for your permission to extract the extension files.
50
+ 2. It copies the extension to `~/.browse_code/extension/` and copies the path to your clipboard.
51
+ 3. It opens `chrome://extensions/` in your browser automatically.
52
+ 4. You enable **Developer mode** (top-right toggle), click **Load unpacked**, and paste the path.
53
+ 5. Press Enter in the terminal and the server starts.
54
+
55
+ **You only do this once.** The extension stays loaded in Chrome across sessions.
56
+
57
+ ### Step 4: Start an AI session
58
+
59
+ 1. Open any supported AI chat (ChatGPT, Gemini, Claude, or HuggingFace Chat).
60
+ 2. Click the Browse Code Bridge extension icon and set your workspace directory.
61
+ 3. Click "Initialize Agent in Chat".
62
+ 4. Start coding with AI — it now has full access to your local environment.
63
+
64
+ ## Subsequent Usage
65
+
66
+ After the first-time setup, just run:
67
+
68
+ ```bash
69
+ bc
70
+ ```
71
+
72
+ The server starts immediately. Open your AI chat tab and you're ready to go. The server terminal will show:
73
+ - A startup banner with your workspace and endpoint
74
+ - `[+] Extension connected` when the browser extension connects
75
+ - Real-time logs of every file read, write, command execution, and diff
76
+
77
+ ## Features
78
+
79
+ - **File Operations:** Read, write, and patch files with inline terminal diffs
80
+ - **Code Search:** Search across your entire codebase by keyword
81
+ - **Terminal Commands:** Run shell commands with full stdout/stderr capture
82
+ - **Background Processes:** Start, monitor, and kill long-running processes
83
+ - **Multi-Platform AI:** Works with ChatGPT, Gemini, Claude, and HuggingFace Chat
84
+ - **Extension Heartbeat:** Server detects when the browser extension connects/disconnects
85
+
86
+ ## For Developers
87
+
88
+ 1. Clone the repository:
89
+ ```bash
90
+ git clone https://github.com/Dedeep007/browse_code.git
91
+ cd browse_code
92
+ ```
93
+ 2. Install in editable mode:
94
+ ```bash
95
+ pip install -e .
96
+ ```
97
+
98
+ ## Contributing
99
+
100
+ Contributions are welcome! Please feel free to submit a Pull Request.
101
+
102
+ 1. Fork the repository.
103
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`).
104
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).
105
+ 4. Push to the branch (`git push origin feature/AmazingFeature`).
106
+ 5. Open a Pull Request.
107
+
108
+ ## License
109
+
110
+ Distributed under the MIT License.
@@ -0,0 +1 @@
1
+ __version__ = "0.2.0"
@@ -0,0 +1,204 @@
1
+ import os
2
+ import sys
3
+ import shutil
4
+ import platform
5
+ import subprocess
6
+ import webbrowser
7
+ from pathlib import Path
8
+
9
+ # ── Rich TUI imports ──────────────────────────────────────
10
+ from rich.console import Console
11
+ from rich.panel import Panel
12
+ from rich.text import Text
13
+ from rich.table import Table
14
+ from rich.prompt import Prompt, Confirm
15
+ from rich import box
16
+
17
+ console = Console()
18
+
19
+ PORT = 5505
20
+ HOST = "127.0.0.1"
21
+
22
+
23
+ def get_data_dir():
24
+ """Return ~/.browse_code, creating it if needed."""
25
+ data_dir = Path.home() / ".browse_code"
26
+ data_dir.mkdir(exist_ok=True)
27
+ return data_dir
28
+
29
+
30
+ def copy_to_clipboard(text):
31
+ """Copy text to the system clipboard (cross-platform)."""
32
+ try:
33
+ system = platform.system()
34
+ if system == "Windows":
35
+ subprocess.run("clip", input=text.encode("utf-8"), check=True)
36
+ elif system == "Darwin":
37
+ subprocess.run("pbcopy", input=text.encode("utf-8"), check=True)
38
+ else:
39
+ try:
40
+ subprocess.run(
41
+ ["xclip", "-selection", "clipboard"],
42
+ input=text.encode("utf-8"),
43
+ check=True,
44
+ )
45
+ except FileNotFoundError:
46
+ subprocess.run(
47
+ ["xsel", "--clipboard", "--input"],
48
+ input=text.encode("utf-8"),
49
+ check=True,
50
+ )
51
+ return True
52
+ except Exception:
53
+ return False
54
+
55
+
56
+ def print_banner():
57
+ """Print the Browse Code ASCII art banner."""
58
+ banner_text = Text()
59
+ banner_text.append(" { ", style="bold cyan")
60
+ banner_text.append("Browse Code", style="bold white")
61
+ banner_text.append(" }", style="bold cyan")
62
+
63
+ console.print()
64
+ console.print(
65
+ Panel(
66
+ banner_text,
67
+ box=box.DOUBLE,
68
+ border_style="cyan",
69
+ padding=(1, 4),
70
+ )
71
+ )
72
+
73
+
74
+ def setup_extension():
75
+ """First-time setup: extract extension, open Chrome, guide the user."""
76
+ data_dir = get_data_dir()
77
+ ext_dest = data_dir / "extension"
78
+ pkg_ext_dir = Path(__file__).parent / "extension"
79
+
80
+ print_banner()
81
+ console.print()
82
+ console.print(
83
+ Panel(
84
+ "[bold]First Time Setup[/bold]\n\n"
85
+ "Browse Code needs a Chrome extension to connect\n"
86
+ "your browser to the local server.",
87
+ border_style="yellow",
88
+ box=box.ROUNDED,
89
+ padding=(1, 2),
90
+ )
91
+ )
92
+
93
+ if not Confirm.ask("\n Do you want to set up the extension now?", default=True):
94
+ console.print(" [dim]Skipped. Re-run 'bc' anytime to set it up.[/dim]")
95
+ return False
96
+
97
+ # Extract extension files
98
+ console.print()
99
+ with console.status("[cyan]Extracting extension files...[/cyan]"):
100
+ if ext_dest.exists():
101
+ shutil.rmtree(ext_dest)
102
+ shutil.copytree(pkg_ext_dir, ext_dest)
103
+
104
+ ext_path_str = str(ext_dest)
105
+ console.print(f" [green]Extracted to:[/green] [bold]{ext_path_str}[/bold]")
106
+ console.print()
107
+
108
+ # Copy path to clipboard
109
+ copied = copy_to_clipboard(ext_path_str)
110
+
111
+ # Open chrome://extensions
112
+ console.print(" [cyan]Opening Chrome extensions page...[/cyan]")
113
+ webbrowser.open("chrome://extensions/")
114
+
115
+ # Setup instructions
116
+ steps = Table(
117
+ show_header=False,
118
+ box=box.SIMPLE,
119
+ padding=(0, 2),
120
+ show_edge=False,
121
+ )
122
+ steps.add_column("step", style="bold cyan", width=4)
123
+ steps.add_column("instruction")
124
+
125
+ steps.add_row("1.", 'Enable [bold]"Developer mode"[/bold] toggle (top-right corner)')
126
+ steps.add_row("2.", 'Click [bold]"Load unpacked"[/bold]')
127
+ if copied:
128
+ steps.add_row("3.", "Paste the path [green](already copied to your clipboard)[/green]")
129
+ else:
130
+ steps.add_row("3.", f"Select this folder: [bold]{ext_path_str}[/bold]")
131
+
132
+ console.print()
133
+ console.print(
134
+ Panel(
135
+ steps,
136
+ title="[bold]Quick Setup[/bold]",
137
+ title_align="left",
138
+ border_style="cyan",
139
+ box=box.ROUNDED,
140
+ padding=(1, 1),
141
+ )
142
+ )
143
+ console.print()
144
+
145
+ Prompt.ask(" Press [bold]Enter[/bold] after you've loaded the extension")
146
+
147
+ # Mark as installed
148
+ marker = data_dir / ".installed"
149
+ marker.touch()
150
+
151
+ console.print(" [bold green]Extension setup complete![/bold green]")
152
+ return True
153
+
154
+
155
+ def print_server_header():
156
+ """Print the server status panel before starting."""
157
+ info = Table(show_header=False, box=None, padding=(0, 1), show_edge=False)
158
+ info.add_column("key", style="dim", width=12)
159
+ info.add_column("value")
160
+
161
+ info.add_row("Endpoint", f"[bold]http://{HOST}:{PORT}[/bold]")
162
+ info.add_row("Extension", "[yellow]Waiting for connection...[/yellow]")
163
+ info.add_row("Status", "[green]Running[/green]")
164
+
165
+ console.print(
166
+ Panel(
167
+ info,
168
+ title="[bold cyan]{ [/bold cyan][bold white]Browse Code[/bold white][bold cyan] }[/bold cyan]",
169
+ title_align="left",
170
+ subtitle="[dim]Press Ctrl+C to stop[/dim]",
171
+ subtitle_align="right",
172
+ border_style="cyan",
173
+ box=box.ROUNDED,
174
+ padding=(1, 2),
175
+ )
176
+ )
177
+ console.print()
178
+
179
+
180
+ def main():
181
+ data_dir = get_data_dir()
182
+ marker = data_dir / ".installed"
183
+
184
+ if not marker.exists():
185
+ result = setup_extension()
186
+ if not result:
187
+ return
188
+ else:
189
+ print_banner()
190
+
191
+ console.print()
192
+ print_server_header()
193
+
194
+ try:
195
+ from .server import app
196
+ except ImportError:
197
+ from server import app
198
+
199
+ import uvicorn
200
+ uvicorn.run(app, host=HOST, port=PORT, access_log=False)
201
+
202
+
203
+ if __name__ == "__main__":
204
+ main()