bharatcode 0.1.0__py3-none-any.whl

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.
bharatcode/ui.py ADDED
@@ -0,0 +1,72 @@
1
+ """Terminal UI using Rich — inspired by Claude Code's clean terminal interface."""
2
+ import sys
3
+ import io
4
+ from rich.console import Console
5
+ from rich.panel import Panel
6
+ from rich.markdown import Markdown
7
+ from rich.syntax import Syntax
8
+ from rich.text import Text
9
+ from rich.prompt import Prompt, Confirm
10
+ from rich.rule import Rule
11
+ from rich import box
12
+
13
+ if sys.platform == "win32":
14
+ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
15
+ sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
16
+
17
+ console = Console(highlight=False)
18
+
19
+ TOOL_ICONS = {
20
+ "bash": "[yellow]⚡[/yellow]",
21
+ "read_file": "[blue]📖[/blue]",
22
+ "write_file": "[green]✏️[/green]",
23
+ "edit_file": "[cyan]🔧[/cyan]",
24
+ "glob": "[magenta]📁[/magenta]",
25
+ "grep": "[white]🔍[/white]",
26
+ }
27
+
28
+ def show_banner():
29
+ console.print(Panel(
30
+ "[bold green]Sylithe Code[/bold green] [dim]AI Coding Agent for Indian Developers[/dim]\n"
31
+ "[dim]Powered by Sylithe | Type /help for commands | Ctrl+C to exit[/dim]",
32
+ border_style="green",
33
+ padding=(0, 2),
34
+ ))
35
+
36
+ def show_tool_call(name: str, args: dict):
37
+ icon = TOOL_ICONS.get(name, "[dim]🔧[/dim]")
38
+ first_arg = list(args.values())[0] if args else ""
39
+ preview = str(first_arg)[:80].replace("\n", "↵")
40
+ console.print(f" {icon} [dim]{name}[/dim] [cyan]{preview}[/cyan]")
41
+
42
+ def show_response(text: str):
43
+ console.print(Panel(
44
+ Markdown(text),
45
+ border_style="green",
46
+ title="[bold green]Sylithe Code[/bold green]",
47
+ padding=(0, 1),
48
+ ))
49
+
50
+ def show_error(msg: str):
51
+ console.print(f"[red]✗[/red] {msg}")
52
+
53
+ def show_success(msg: str):
54
+ console.print(f"[green]✓[/green] {msg}")
55
+
56
+ def show_warning(msg: str):
57
+ console.print(f"[yellow]⚠[/yellow] {msg}")
58
+
59
+ def show_info(msg: str):
60
+ console.print(f"[blue]ℹ[/blue] {msg}")
61
+
62
+ def show_separator():
63
+ console.print(Rule(style="dim"))
64
+
65
+ def spinner(message: str):
66
+ return console.status(f"[green]{message}[/green]", spinner="dots")
67
+
68
+ def ask_input(prompt_text: str = "") -> str:
69
+ return Prompt.ask(f"[bold green]>[/bold green] {prompt_text}")
70
+
71
+ def confirm(msg: str) -> bool:
72
+ return Confirm.ask(f"[yellow]{msg}[/yellow]")
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: bharatcode
3
+ Version: 0.1.0
4
+ Summary: AI Coding Agent for Indian Developers — powered by DeepSeek
5
+ License: MIT
6
+ Project-URL: Repository, https://github.com/chhelurathore/bharatcode
7
+ Keywords: ai,coding-agent,deepseek,india,cli,developer-tools
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Code Generators
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: click>=8.0
21
+ Requires-Dist: rich>=13.0
22
+ Requires-Dist: openai>=1.0
23
+ Requires-Dist: python-dotenv>=1.0
24
+ Requires-Dist: questionary>=1.10
25
+
26
+ # BharatCode 🇮🇳
27
+
28
+ **AI Coding Agent for Indian Developers — powered by DeepSeek**
29
+
30
+ BharatCode is a terminal-based AI coding agent that understands Indian tech stacks (Razorpay, UIDAI, GST, UPI), runs tools autonomously, and orchestrates parallel specialist workers for complex tasks.
31
+
32
+ ---
33
+
34
+ ## Features
35
+
36
+ - **Autonomous agent loop** — reads files, writes code, runs bash, fixes tests end-to-end
37
+ - **Coordinator mode** — spawns parallel background workers, synthesizes results in one shot
38
+ - **Plan mode** — read-only exploration + approval gate before any writes
39
+ - **Persistent memory** — remembers project facts across sessions
40
+ - **Project symbol index** — scans codebase at session start, injects file/symbol map into context
41
+ - **Grep-before-Read discipline** — built-in rule to grep for symbols before cold-reading files
42
+ - **Auto-read before edit** — auto-fetches file into cache before any edit_file call
43
+ - **old_string verification** — edit_file fails fast if the string isn't found or is ambiguous
44
+ - **Post-write syntax check** — Python AST parse after every write/edit; flags errors immediately
45
+ - **Context-aware compaction** — file knowledge (paths, symbols, sizes) survives auto-compaction
46
+ - **Change tracking** — tracks every file touched, shows diff summary on `/changes` and on exit
47
+ - **Auto-compaction** — summarises long sessions to stay under context limits
48
+ - **Indian expertise** — Razorpay, Aadhaar/UIDAI, GST, UPI, IndiaStack built-in knowledge
49
+ - **Cost tracking** — per-session token and rupee cost display
50
+
51
+ ---
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ git clone <repo>
57
+ cd bharatcode
58
+ pip install -e .
59
+ ```
60
+
61
+ Set your DeepSeek API key:
62
+
63
+ ```bash
64
+ # .env in any project directory, or export globally
65
+ DEEPSEEK_API_KEY=sk-...
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Usage
71
+
72
+ ```bash
73
+ # Start interactive mode in your project directory
74
+ cd /path/to/your/project
75
+ bharatcode
76
+
77
+ # One-shot task
78
+ bharatcode run "add input validation to the signup form"
79
+ ```
80
+
81
+ ### Key Commands
82
+
83
+ | Command | Description |
84
+ |---------|-------------|
85
+ | `/help` | Show all commands |
86
+ | `/coordinator` | Enter multi-worker orchestration mode |
87
+ | `/plan` | Toggle plan mode (read-only until approved) |
88
+ | `/compact` | Summarise conversation history |
89
+ | `/changes` | Show all files modified this session |
90
+ | `/cost` | Show session token + cost breakdown |
91
+ | `/memory` | View persistent memories |
92
+ | `/workers` | Show coordinator worker status |
93
+ | `/exit-coordinator` | Leave coordinator mode |
94
+
95
+ ---
96
+
97
+ ## Project Config
98
+
99
+ Create a `BHARATCODE.md` file in any project to give BharatCode custom instructions for that project:
100
+
101
+ ```markdown
102
+ # My Project — BharatCode Config
103
+
104
+ ## Tech Stack
105
+ Python 3.11 / FastAPI / PostgreSQL / React 18
106
+
107
+ ## Coding Standards
108
+ - Use Black for formatting
109
+ - Type hints on all functions
110
+ - Run pytest after every fix
111
+
112
+ ## Notes
113
+ - Never commit .env files
114
+ - Payments via Razorpay v2
115
+ - GST: 18% on services
116
+ ```
117
+
118
+ ---
119
+
120
+ ## Architecture
121
+
122
+ ```
123
+ bharatcode/
124
+ main.py CLI entry + interactive loop + coordinator notification loop
125
+ agent.py Core agent loop — streaming, tool execution, auto-compaction
126
+ coordinator.py WorkerPool, Worker dataclass, notification queue, prompts
127
+ tools.py Tool definitions (JSON schema) + execute_tool dispatcher
128
+ commands.py Slash command handlers (/plan, /memory, /coordinator, ...)
129
+ memory.py Persistent memory read/write (~/.bharatcode/memory/)
130
+ permissions.py Tool approval — ask_permission, needs_approval
131
+ subagent.py spawn_agent tool — single-use focused sub-agents
132
+ project.py Auto-detect project type from package.json / requirements.txt
133
+ config.py Load/save ~/.bharatcode/config.json
134
+ cost.py Token + cost tracking per session
135
+ diff.py Coloured file diff display on write/edit
136
+ hooks.py Pre/post tool hooks for extensibility
137
+ skills.py /skill command — load skills from ~/.bharatcode/skills/
138
+ ui.py Rich console helpers — banner, panels, errors
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Environment Variables
144
+
145
+ | Variable | Required | Description |
146
+ |----------|----------|-------------|
147
+ | `DEEPSEEK_API_KEY` | ✅ | DeepSeek API key |
148
+ | `BHARATCODE_MODEL` | No | Override model (`deepseek-v4-pro` / `deepseek-v4-flash`) |
149
+ | `BHARATCODE_DEBUG` | No | Set to `1` for full tracebacks |
150
+ | `BHARATCODE_AUTO_APPROVE` | No | Set to `1` to skip all permission prompts |
@@ -0,0 +1,23 @@
1
+ bharatcode/__init__.py,sha256=hbNd7AKShL4p71Q1RmyJak07gXwk3hAdr40swuSsVVY,427
2
+ bharatcode/agent.py,sha256=fIK46y27ojOvOmFOge1j9g2T_JPPOrXeYS7tcrZ0p0Q,98965
3
+ bharatcode/commands.py,sha256=CnrRqJUTJaSxS7z0GdnCUdJWWUWTPQ9ytfti42tOiTw,44503
4
+ bharatcode/config.py,sha256=V0HrZV8dMceWdUu_ulbaeqaJwi-2ntim7RxtZoaXSAY,3145
5
+ bharatcode/coordinator.py,sha256=tAu0GJL0pwZ023ohF3bBZBZZDMhh_r2oPF1FqImKgRM,31526
6
+ bharatcode/cost.py,sha256=2i00DbOCjltaAILxhq_5kAn_T5Hu9FqFn7opRg0e3Hs,2602
7
+ bharatcode/diff.py,sha256=R_Yt2D4eFBU3z5W6Lj7nqCvE5yTEkGtqX2Z3ZICE1ms,4355
8
+ bharatcode/hooks.py,sha256=VMBja00fjRXHJULZZUjMoAqz-z546XFeJqEwHG70Vs8,2593
9
+ bharatcode/index.py,sha256=6a1yG92mizVThPHceSnmhl5cNamKh-zZnTO6eDDklI4,5651
10
+ bharatcode/main.py,sha256=vsvZbbTcHGxImMSkuiwTJaYs4kPNjwuq2SnRxrxmItw,33494
11
+ bharatcode/memory.py,sha256=QOvCIzFTE_wuFX8Sn3-3iPPF3oOc3qEkISp01i9QmRw,10606
12
+ bharatcode/permissions.py,sha256=bB4m1w1DOxGlGb9V9YlfF5gBCQ8-UtUvH8y414v2m18,2966
13
+ bharatcode/project.py,sha256=Jh6aHOHidfmkQlm-B-Jq-JMLV9FbNh2d7cBvjsG1QLQ,6277
14
+ bharatcode/session_storage.py,sha256=H1VlbxqioSDJXQx2H_uwYgVKquxw0tf0hzHXwBXAHI4,3867
15
+ bharatcode/skills.py,sha256=Y1xam_oi1-8ZNEuSGs5WBZzDFl3zS7OBDc8EAkMnN-g,76014
16
+ bharatcode/subagent.py,sha256=s0CyRfc-2MJhdN5_nHtUsE1JQSU6tSLh3gFSXYBA-g0,15097
17
+ bharatcode/tools.py,sha256=KjjRRx0PU4ZvpOI9baBir5uHzqJoBLFiKf-UXm75eTM,47672
18
+ bharatcode/ui.py,sha256=jN__JDP5rJQyGnhcq4c61NqK3DTN0JduW2xhRnNkFy8,2282
19
+ bharatcode-0.1.0.dist-info/METADATA,sha256=mPVzixo2A3h_JXvrVOuoQpg--hBXh-hmYgNad-ej4lI,5450
20
+ bharatcode-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
21
+ bharatcode-0.1.0.dist-info/entry_points.txt,sha256=tPSiEtKomiAyy70yObEScC-F0ur4rDWGERqGRhLrsK8,85
22
+ bharatcode-0.1.0.dist-info/top_level.txt,sha256=-XYYeG2Wzr5gU0aHVH5hmz86bHgOZEv0y6JurgroblE,11
23
+ bharatcode-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ bharatcode = bharatcode.main:cli
3
+ sylithecode = bharatcode.main:cli
@@ -0,0 +1 @@
1
+ bharatcode