bharatcode 0.1.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.
@@ -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,125 @@
1
+ # BharatCode 🇮🇳
2
+
3
+ **AI Coding Agent for Indian Developers — powered by DeepSeek**
4
+
5
+ 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.
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - **Autonomous agent loop** — reads files, writes code, runs bash, fixes tests end-to-end
12
+ - **Coordinator mode** — spawns parallel background workers, synthesizes results in one shot
13
+ - **Plan mode** — read-only exploration + approval gate before any writes
14
+ - **Persistent memory** — remembers project facts across sessions
15
+ - **Project symbol index** — scans codebase at session start, injects file/symbol map into context
16
+ - **Grep-before-Read discipline** — built-in rule to grep for symbols before cold-reading files
17
+ - **Auto-read before edit** — auto-fetches file into cache before any edit_file call
18
+ - **old_string verification** — edit_file fails fast if the string isn't found or is ambiguous
19
+ - **Post-write syntax check** — Python AST parse after every write/edit; flags errors immediately
20
+ - **Context-aware compaction** — file knowledge (paths, symbols, sizes) survives auto-compaction
21
+ - **Change tracking** — tracks every file touched, shows diff summary on `/changes` and on exit
22
+ - **Auto-compaction** — summarises long sessions to stay under context limits
23
+ - **Indian expertise** — Razorpay, Aadhaar/UIDAI, GST, UPI, IndiaStack built-in knowledge
24
+ - **Cost tracking** — per-session token and rupee cost display
25
+
26
+ ---
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ git clone <repo>
32
+ cd bharatcode
33
+ pip install -e .
34
+ ```
35
+
36
+ Set your DeepSeek API key:
37
+
38
+ ```bash
39
+ # .env in any project directory, or export globally
40
+ DEEPSEEK_API_KEY=sk-...
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Usage
46
+
47
+ ```bash
48
+ # Start interactive mode in your project directory
49
+ cd /path/to/your/project
50
+ bharatcode
51
+
52
+ # One-shot task
53
+ bharatcode run "add input validation to the signup form"
54
+ ```
55
+
56
+ ### Key Commands
57
+
58
+ | Command | Description |
59
+ |---------|-------------|
60
+ | `/help` | Show all commands |
61
+ | `/coordinator` | Enter multi-worker orchestration mode |
62
+ | `/plan` | Toggle plan mode (read-only until approved) |
63
+ | `/compact` | Summarise conversation history |
64
+ | `/changes` | Show all files modified this session |
65
+ | `/cost` | Show session token + cost breakdown |
66
+ | `/memory` | View persistent memories |
67
+ | `/workers` | Show coordinator worker status |
68
+ | `/exit-coordinator` | Leave coordinator mode |
69
+
70
+ ---
71
+
72
+ ## Project Config
73
+
74
+ Create a `BHARATCODE.md` file in any project to give BharatCode custom instructions for that project:
75
+
76
+ ```markdown
77
+ # My Project — BharatCode Config
78
+
79
+ ## Tech Stack
80
+ Python 3.11 / FastAPI / PostgreSQL / React 18
81
+
82
+ ## Coding Standards
83
+ - Use Black for formatting
84
+ - Type hints on all functions
85
+ - Run pytest after every fix
86
+
87
+ ## Notes
88
+ - Never commit .env files
89
+ - Payments via Razorpay v2
90
+ - GST: 18% on services
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Architecture
96
+
97
+ ```
98
+ bharatcode/
99
+ main.py CLI entry + interactive loop + coordinator notification loop
100
+ agent.py Core agent loop — streaming, tool execution, auto-compaction
101
+ coordinator.py WorkerPool, Worker dataclass, notification queue, prompts
102
+ tools.py Tool definitions (JSON schema) + execute_tool dispatcher
103
+ commands.py Slash command handlers (/plan, /memory, /coordinator, ...)
104
+ memory.py Persistent memory read/write (~/.bharatcode/memory/)
105
+ permissions.py Tool approval — ask_permission, needs_approval
106
+ subagent.py spawn_agent tool — single-use focused sub-agents
107
+ project.py Auto-detect project type from package.json / requirements.txt
108
+ config.py Load/save ~/.bharatcode/config.json
109
+ cost.py Token + cost tracking per session
110
+ diff.py Coloured file diff display on write/edit
111
+ hooks.py Pre/post tool hooks for extensibility
112
+ skills.py /skill command — load skills from ~/.bharatcode/skills/
113
+ ui.py Rich console helpers — banner, panels, errors
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Environment Variables
119
+
120
+ | Variable | Required | Description |
121
+ |----------|----------|-------------|
122
+ | `DEEPSEEK_API_KEY` | ✅ | DeepSeek API key |
123
+ | `BHARATCODE_MODEL` | No | Override model (`deepseek-v4-pro` / `deepseek-v4-flash`) |
124
+ | `BHARATCODE_DEBUG` | No | Set to `1` for full tracebacks |
125
+ | `BHARATCODE_AUTO_APPROVE` | No | Set to `1` to skip all permission prompts |
@@ -0,0 +1,13 @@
1
+ """Sylithe Code — AI Coding Agent for Indian Developers"""
2
+ __version__ = "0.1.0"
3
+
4
+ # Force UTF-8 output streams so emoji/Unicode never crash on cp1252 consoles
5
+ # (legacy Windows terminals, piped output, CI). Must run before any rich
6
+ # Console is created.
7
+ import sys as _sys
8
+
9
+ for _stream in (_sys.stdout, _sys.stderr):
10
+ try:
11
+ _stream.reconfigure(encoding="utf-8", errors="replace")
12
+ except Exception:
13
+ pass