browse-code 0.1.0__tar.gz → 0.1.3__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 (22) hide show
  1. {browse_code-0.1.0 → browse_code-0.1.3}/PKG-INFO +9 -9
  2. browse_code-0.1.3/README.md +106 -0
  3. browse_code-0.1.3/browse_code/__init__.py +1 -0
  4. browse_code-0.1.3/browse_code/cli.py +133 -0
  5. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code/extension/content.js +362 -355
  6. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code/extension/manifest.json +29 -29
  7. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code/extension/popup.html +108 -108
  8. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code/extension/popup.js +89 -89
  9. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code/extension/spoof.js +2 -2
  10. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code/server.py +597 -573
  11. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code.egg-info/PKG-INFO +9 -9
  12. {browse_code-0.1.0 → browse_code-0.1.3}/setup.cfg +4 -4
  13. {browse_code-0.1.0 → browse_code-0.1.3}/setup.py +1 -1
  14. browse_code-0.1.0/README.md +0 -61
  15. browse_code-0.1.0/browse_code/__init__.py +0 -1
  16. browse_code-0.1.0/browse_code/cli.py +0 -75
  17. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code.egg-info/SOURCES.txt +0 -0
  18. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code.egg-info/dependency_links.txt +0 -0
  19. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code.egg-info/entry_points.txt +0 -0
  20. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code.egg-info/requires.txt +0 -0
  21. {browse_code-0.1.0 → browse_code-0.1.3}/browse_code.egg-info/top_level.txt +0 -0
  22. {browse_code-0.1.0 → browse_code-0.1.3}/pyproject.toml +0 -0
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.4
2
- Name: browse_code
3
- Version: 0.1.0
4
- Summary: A local AI bridge package
5
- Requires-Dist: fastapi
6
- Requires-Dist: uvicorn
7
- Requires-Dist: pydantic
8
- Dynamic: requires-dist
9
- Dynamic: summary
1
+ Metadata-Version: 2.4
2
+ Name: browse_code
3
+ Version: 0.1.3
4
+ Summary: A local AI bridge package
5
+ Requires-Dist: fastapi
6
+ Requires-Dist: uvicorn
7
+ Requires-Dist: pydantic
8
+ Dynamic: requires-dist
9
+ Dynamic: summary
@@ -0,0 +1,106 @@
1
+ # Browse Code
2
+
3
+ ![PyPI version](https://badge.fury.io/py/browse-code.svg)
4
+ ![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)
5
+ ![License](https://img.shields.io/badge/license-MIT-green)
6
+
7
+ **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.
8
+
9
+ ## How It Works
10
+
11
+ Browse Code has two parts:
12
+
13
+ 1. **A local server** that exposes your file system and terminal to the AI via a secure API.
14
+ 2. **A Chrome extension** that injects agent capabilities into AI chat interfaces.
15
+
16
+ When connected, you can ask ChatGPT/Gemini/Claude to edit files, run scripts, search code, and more — all executed locally on your machine.
17
+
18
+ ## Setup
19
+
20
+ ### Step 1: Install the package
21
+
22
+ ```bash
23
+ pip install browse-code
24
+ ```
25
+
26
+ ### Step 2: Run the CLI
27
+
28
+ ```bash
29
+ bc
30
+ ```
31
+
32
+ > If `bc` is not found, add your Python Scripts folder to PATH:
33
+ > ```bash
34
+ > # Windows (PowerShell)
35
+ > $env:Path += ";$env:APPDATA\Python\Python312\Scripts"
36
+ >
37
+ > # Or run directly
38
+ > python -m browse_code.cli
39
+ > ```
40
+
41
+ ### Step 3: First-run extension setup
42
+
43
+ On the first run, `bc` will guide you through a one-time Chrome extension setup:
44
+
45
+ 1. It asks for your permission to extract the extension files.
46
+ 2. It copies the extension to `~/.browse_code/extension/` and copies the path to your clipboard.
47
+ 3. It opens `chrome://extensions/` in your browser automatically.
48
+ 4. You enable **Developer mode** (top-right toggle), click **Load unpacked**, and paste the path.
49
+ 5. Press Enter in the terminal and the server starts.
50
+
51
+ **You only do this once.** The extension stays loaded in Chrome across sessions.
52
+
53
+ ### Step 4: Start an AI session
54
+
55
+ 1. Open any supported AI chat (ChatGPT, Gemini, Claude, or HuggingFace Chat).
56
+ 2. Click the Browse Code Bridge extension icon and set your workspace directory.
57
+ 3. Click "Initialize Agent in Chat".
58
+ 4. Start coding with AI — it now has full access to your local environment.
59
+
60
+ ## Subsequent Usage
61
+
62
+ After the first-time setup, just run:
63
+
64
+ ```bash
65
+ bc
66
+ ```
67
+
68
+ The server starts immediately. Open your AI chat tab and you're ready to go. The server terminal will show:
69
+ - A startup banner with your workspace and endpoint
70
+ - `[+] Extension connected` when the browser extension connects
71
+ - Real-time logs of every file read, write, command execution, and diff
72
+
73
+ ## Features
74
+
75
+ - **File Operations:** Read, write, and patch files with inline terminal diffs
76
+ - **Code Search:** Search across your entire codebase by keyword
77
+ - **Terminal Commands:** Run shell commands with full stdout/stderr capture
78
+ - **Background Processes:** Start, monitor, and kill long-running processes
79
+ - **Multi-Platform AI:** Works with ChatGPT, Gemini, Claude, and HuggingFace Chat
80
+ - **Extension Heartbeat:** Server detects when the browser extension connects/disconnects
81
+
82
+ ## For Developers
83
+
84
+ 1. Clone the repository:
85
+ ```bash
86
+ git clone https://github.com/Dedeep007/browse_code.git
87
+ cd browse_code
88
+ ```
89
+ 2. Install in editable mode:
90
+ ```bash
91
+ pip install -e .
92
+ ```
93
+
94
+ ## Contributing
95
+
96
+ Contributions are welcome! Please feel free to submit a Pull Request.
97
+
98
+ 1. Fork the repository.
99
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`).
100
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).
101
+ 4. Push to the branch (`git push origin feature/AmazingFeature`).
102
+ 5. Open a Pull Request.
103
+
104
+ ## License
105
+
106
+ Distributed under the MIT License.
@@ -0,0 +1 @@
1
+ __version__ = "0.1.3"
@@ -0,0 +1,133 @@
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
+
10
+ def get_data_dir():
11
+ """Return ~/.browse_code, creating it if needed."""
12
+ data_dir = Path.home() / ".browse_code"
13
+ data_dir.mkdir(exist_ok=True)
14
+ return data_dir
15
+
16
+
17
+ def copy_to_clipboard(text):
18
+ """Copy text to the system clipboard (cross-platform)."""
19
+ try:
20
+ system = platform.system()
21
+ if system == "Windows":
22
+ subprocess.run("clip", input=text.encode("utf-8"), check=True)
23
+ elif system == "Darwin":
24
+ subprocess.run("pbcopy", input=text.encode("utf-8"), check=True)
25
+ else:
26
+ # Linux — try xclip, fall back to xsel
27
+ try:
28
+ subprocess.run(
29
+ ["xclip", "-selection", "clipboard"],
30
+ input=text.encode("utf-8"),
31
+ check=True,
32
+ )
33
+ except FileNotFoundError:
34
+ subprocess.run(
35
+ ["xsel", "--clipboard", "--input"],
36
+ input=text.encode("utf-8"),
37
+ check=True,
38
+ )
39
+ return True
40
+ except Exception:
41
+ return False
42
+
43
+
44
+ def setup_extension():
45
+ """First-time setup: extract extension, open Chrome, guide the user."""
46
+ data_dir = get_data_dir()
47
+ ext_dest = data_dir / "extension"
48
+ pkg_ext_dir = Path(__file__).parent / "extension"
49
+
50
+ print()
51
+ print("=" * 60)
52
+ print(" Browse Code - First Time Setup")
53
+ print("=" * 60)
54
+ print()
55
+ print("Browse Code needs a Chrome extension to connect your")
56
+ print("browser to the local server.")
57
+ print()
58
+
59
+ ans = input("Do you want to set up the extension now? (y/n): ")
60
+ if ans.strip().lower() != "y":
61
+ print("Skipped. You can re-run 'bc' anytime to set it up.")
62
+ return False
63
+
64
+ # Extract extension files
65
+ print()
66
+ print("Extracting extension files...")
67
+ if ext_dest.exists():
68
+ shutil.rmtree(ext_dest)
69
+ shutil.copytree(pkg_ext_dir, ext_dest)
70
+
71
+ ext_path_str = str(ext_dest)
72
+ print(f" Extension extracted to: {ext_path_str}")
73
+ print()
74
+
75
+ # Copy path to clipboard
76
+ copied = copy_to_clipboard(ext_path_str)
77
+
78
+ # Open chrome://extensions
79
+ print("Opening Chrome extensions page...")
80
+ webbrowser.open("chrome://extensions/")
81
+
82
+ print()
83
+ print("-" * 60)
84
+ print(" QUICK SETUP (one-time, takes 30 seconds):")
85
+ print("-" * 60)
86
+ print(' 1. Enable "Developer mode" toggle (top-right corner)')
87
+ print(' 2. Click "Load unpacked"')
88
+ if copied:
89
+ print(" 3. Paste the path (already copied to your clipboard)")
90
+ else:
91
+ print(f" 3. Select this folder: {ext_path_str}")
92
+ print("-" * 60)
93
+ print()
94
+
95
+ input("Press Enter after you've loaded the extension...")
96
+
97
+ # Mark as installed
98
+ marker = data_dir / ".installed"
99
+ marker.touch()
100
+
101
+ print()
102
+ print("Extension setup complete!")
103
+ return True
104
+
105
+
106
+ def main():
107
+ data_dir = get_data_dir()
108
+ marker = data_dir / ".installed"
109
+
110
+ if not marker.exists():
111
+ result = setup_extension()
112
+ if not result:
113
+ return
114
+
115
+ print()
116
+ print("=" * 60)
117
+ print(" Browse Code")
118
+ print("=" * 60)
119
+ print()
120
+ print("Starting server...")
121
+ print()
122
+
123
+ try:
124
+ from .server import app
125
+ except ImportError:
126
+ from server import app
127
+
128
+ import uvicorn
129
+ uvicorn.run(app, host="127.0.0.1", port=5505, access_log=False)
130
+
131
+
132
+ if __name__ == "__main__":
133
+ main()