bardgent 1.0.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 (35) hide show
  1. bardgent-1.0.0/LICENSE +21 -0
  2. bardgent-1.0.0/PKG-INFO +113 -0
  3. bardgent-1.0.0/README.md +85 -0
  4. bardgent-1.0.0/bardgent/__init__.py +3 -0
  5. bardgent-1.0.0/bardgent/__main__.py +5 -0
  6. bardgent-1.0.0/bardgent/checkpoints.py +132 -0
  7. bardgent-1.0.0/bardgent/commands.py +335 -0
  8. bardgent-1.0.0/bardgent/config.py +190 -0
  9. bardgent-1.0.0/bardgent/exec_tools.py +246 -0
  10. bardgent-1.0.0/bardgent/fs_tools.py +386 -0
  11. bardgent-1.0.0/bardgent/main.py +258 -0
  12. bardgent-1.0.0/bardgent/memory.py +75 -0
  13. bardgent-1.0.0/bardgent/model.py +218 -0
  14. bardgent-1.0.0/bardgent/permissions.py +55 -0
  15. bardgent-1.0.0/bardgent/project_instructions.py +91 -0
  16. bardgent-1.0.0/bardgent/scheduler.py +1003 -0
  17. bardgent-1.0.0/bardgent/session.py +463 -0
  18. bardgent-1.0.0/bardgent/skills.py +275 -0
  19. bardgent-1.0.0/bardgent/state.py +71 -0
  20. bardgent-1.0.0/bardgent/status_bar.py +262 -0
  21. bardgent-1.0.0/bardgent/subagents.py +220 -0
  22. bardgent-1.0.0/bardgent/system_prompt.py +249 -0
  23. bardgent-1.0.0/bardgent/telegram.py +183 -0
  24. bardgent-1.0.0/bardgent/tool_schemas.py +356 -0
  25. bardgent-1.0.0/bardgent/ui.py +11 -0
  26. bardgent-1.0.0/bardgent/utils.py +31 -0
  27. bardgent-1.0.0/bardgent/web_tools.py +69 -0
  28. bardgent-1.0.0/bardgent.egg-info/PKG-INFO +113 -0
  29. bardgent-1.0.0/bardgent.egg-info/SOURCES.txt +33 -0
  30. bardgent-1.0.0/bardgent.egg-info/dependency_links.txt +1 -0
  31. bardgent-1.0.0/bardgent.egg-info/entry_points.txt +2 -0
  32. bardgent-1.0.0/bardgent.egg-info/requires.txt +6 -0
  33. bardgent-1.0.0/bardgent.egg-info/top_level.txt +1 -0
  34. bardgent-1.0.0/pyproject.toml +44 -0
  35. bardgent-1.0.0/setup.cfg +4 -0
bardgent-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bardia Emamgholizadeh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: bardgent
3
+ Version: 1.0.0
4
+ Summary: A command-line coding agent (OpenAI-compatible API; default NVIDIA Nemotron)
5
+ Author-email: Bardia Emamgholizadeh <bardia.egzz@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/bardiaegz/BardGent
8
+ Project-URL: Repository, https://github.com/bardiaegz/BardGent
9
+ Project-URL: Issues, https://github.com/bardiaegz/BardGent/issues
10
+ Keywords: cli,agent,coding-agent,llm
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Topic :: Software Development
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: openai
22
+ Requires-Dist: requests
23
+ Requires-Dist: beautifulsoup4
24
+ Requires-Dist: rich
25
+ Requires-Dist: prompt-toolkit
26
+ Requires-Dist: python-dotenv
27
+ Dynamic: license-file
28
+
29
+ # Bardgent
30
+
31
+ A terminal coding agent with tools for files, shell, web, memory, skills, sub-agents, and scheduled tasks.
32
+
33
+ ## Setup
34
+
35
+ ```bash
36
+ python -m venv venv
37
+ source venv/bin/activate
38
+ pip install -e .
39
+ ```
40
+
41
+ Set an API key (env name is historical; any OpenAI-compatible key works with the configured base URL):
42
+
43
+ ```bash
44
+ # ~/.bardgent/.env or export in your shell
45
+ GEMINI_API_KEY=your_key_here
46
+ ```
47
+
48
+ Then run:
49
+
50
+ ```bash
51
+ bardgent
52
+ ```
53
+
54
+ ## Defaults
55
+
56
+ | Setting | Value |
57
+ |---------|--------|
58
+ | API base | `https://integrate.api.nvidia.com/v1` |
59
+ | Model | `nvidia/nemotron-3-ultra-550b-a55b` |
60
+ | Config dir | `~/.bardgent/` |
61
+
62
+ ## Modes
63
+
64
+ | Mode | Behavior |
65
+ |------|----------|
66
+ | **normal** | Approve Write/Edit/Bash (and similar) per action |
67
+ | **auto** | Auto-approve non-dangerous actions; dangerous shell still prompts |
68
+ | **plan** | Read-only tools only; agent proposes a plan, then you choose how to execute |
69
+
70
+ Cycle with **Shift+Tab** or `/normal`, `/auto`, `/plan`.
71
+
72
+ ## Tools (high level)
73
+
74
+ - **Files:** Read, Write, Edit, Undo, Glob, Grep
75
+ - **Shell:** Bash (cwd persists), background jobs via `ListJobs` / `Await`
76
+ - **Web:** WebSearch (DuckDuckGo), Fetch
77
+ - **Memory:** save / list / delete long-term notes (`~/.bardgent/Bardgent.md`)
78
+ - **Skills:** Claude Code–style `SKILL.md` packs; `/skills`, `/skill install <github_url>`
79
+ - **Delegation:** `Task` / `Tasks` (parallel sub-agents)
80
+ - **Schedule:** recurring or one-off tasks; `/schedule`, `/schedules`. A detached **scheduler daemon** keeps firing tasks after you close the terminal (auto-started with Bardgent). Manage with `/schedule daemon status|start|stop`. Log: `~/.bardgent/scheduler.log`.
81
+
82
+ ## Project instructions
83
+
84
+ Place any of these in the project root (all that exist are loaded):
85
+
86
+ - `AGENTS.md`
87
+ - `.bardgent/AGENTS.md`, `.bardgent/instructions.md`, `.bardgent/RULES.md`
88
+
89
+ ## Skills locations
90
+
91
+ 1. `./.bardgent/skills/<name>/SKILL.md` (project)
92
+ 2. `~/.bardgent/skills/<name>/SKILL.md` (user)
93
+ 3. Package `skills/` (optional bundled defaults)
94
+
95
+ ## Permissions
96
+
97
+ Per-project file: `.bardgent/permissions.json`
98
+
99
+ ```json
100
+ {
101
+ "auto_approve_bash_prefixes": ["git status", "pytest"],
102
+ "auto_approve_tools": ["Fetch", "Write", "Edit"],
103
+ "extra_dangerous_patterns": []
104
+ }
105
+ ```
106
+
107
+ ## Useful commands
108
+
109
+ Type `/help` in the REPL for the full list. Highlights: `/resume`, `/checkpoints`, `/restore`, `/telegram`, `/summary`, `/clear`.
110
+
111
+ ## License
112
+
113
+ Use and modify as you like for personal / project use.
@@ -0,0 +1,85 @@
1
+ # Bardgent
2
+
3
+ A terminal coding agent with tools for files, shell, web, memory, skills, sub-agents, and scheduled tasks.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ python -m venv venv
9
+ source venv/bin/activate
10
+ pip install -e .
11
+ ```
12
+
13
+ Set an API key (env name is historical; any OpenAI-compatible key works with the configured base URL):
14
+
15
+ ```bash
16
+ # ~/.bardgent/.env or export in your shell
17
+ GEMINI_API_KEY=your_key_here
18
+ ```
19
+
20
+ Then run:
21
+
22
+ ```bash
23
+ bardgent
24
+ ```
25
+
26
+ ## Defaults
27
+
28
+ | Setting | Value |
29
+ |---------|--------|
30
+ | API base | `https://integrate.api.nvidia.com/v1` |
31
+ | Model | `nvidia/nemotron-3-ultra-550b-a55b` |
32
+ | Config dir | `~/.bardgent/` |
33
+
34
+ ## Modes
35
+
36
+ | Mode | Behavior |
37
+ |------|----------|
38
+ | **normal** | Approve Write/Edit/Bash (and similar) per action |
39
+ | **auto** | Auto-approve non-dangerous actions; dangerous shell still prompts |
40
+ | **plan** | Read-only tools only; agent proposes a plan, then you choose how to execute |
41
+
42
+ Cycle with **Shift+Tab** or `/normal`, `/auto`, `/plan`.
43
+
44
+ ## Tools (high level)
45
+
46
+ - **Files:** Read, Write, Edit, Undo, Glob, Grep
47
+ - **Shell:** Bash (cwd persists), background jobs via `ListJobs` / `Await`
48
+ - **Web:** WebSearch (DuckDuckGo), Fetch
49
+ - **Memory:** save / list / delete long-term notes (`~/.bardgent/Bardgent.md`)
50
+ - **Skills:** Claude Code–style `SKILL.md` packs; `/skills`, `/skill install <github_url>`
51
+ - **Delegation:** `Task` / `Tasks` (parallel sub-agents)
52
+ - **Schedule:** recurring or one-off tasks; `/schedule`, `/schedules`. A detached **scheduler daemon** keeps firing tasks after you close the terminal (auto-started with Bardgent). Manage with `/schedule daemon status|start|stop`. Log: `~/.bardgent/scheduler.log`.
53
+
54
+ ## Project instructions
55
+
56
+ Place any of these in the project root (all that exist are loaded):
57
+
58
+ - `AGENTS.md`
59
+ - `.bardgent/AGENTS.md`, `.bardgent/instructions.md`, `.bardgent/RULES.md`
60
+
61
+ ## Skills locations
62
+
63
+ 1. `./.bardgent/skills/<name>/SKILL.md` (project)
64
+ 2. `~/.bardgent/skills/<name>/SKILL.md` (user)
65
+ 3. Package `skills/` (optional bundled defaults)
66
+
67
+ ## Permissions
68
+
69
+ Per-project file: `.bardgent/permissions.json`
70
+
71
+ ```json
72
+ {
73
+ "auto_approve_bash_prefixes": ["git status", "pytest"],
74
+ "auto_approve_tools": ["Fetch", "Write", "Edit"],
75
+ "extra_dangerous_patterns": []
76
+ }
77
+ ```
78
+
79
+ ## Useful commands
80
+
81
+ Type `/help` in the REPL for the full list. Highlights: `/resume`, `/checkpoints`, `/restore`, `/telegram`, `/summary`, `/clear`.
82
+
83
+ ## License
84
+
85
+ Use and modify as you like for personal / project use.
@@ -0,0 +1,3 @@
1
+ """BardGent - a small terminal coding agent."""
2
+
3
+ __version__ = "1.0.0"
@@ -0,0 +1,5 @@
1
+ """Allow `python -m bardgent` (and the scheduler daemon spawn) to work."""
2
+ from bardgent.main import main
3
+
4
+ if __name__ == '__main__':
5
+ main()
@@ -0,0 +1,132 @@
1
+ """
2
+ Silent, git-backed project checkpoints. Every applied Write/Edit inside a
3
+ git repo gets snapshotted onto a side ref (refs/bardgent/checkpoints) via a
4
+ throwaway index file, so it never touches the user's real HEAD, branch, or
5
+ staged changes. /checkpoints lists them, /restore <n> rolls the working
6
+ tree back to one.
7
+ """
8
+
9
+ import os
10
+ import json
11
+ import time
12
+ import subprocess
13
+
14
+ from bardgent import config
15
+ from bardgent.config import log_event
16
+
17
+
18
+ def _git_root(path):
19
+ try:
20
+ result = subprocess.run(
21
+ ['git', 'rev-parse', '--show-toplevel'],
22
+ cwd=os.path.dirname(os.path.abspath(path)) or '.',
23
+ capture_output=True, text=True, timeout=5,
24
+ )
25
+ if result.returncode == 0:
26
+ return result.stdout.strip()
27
+ except (OSError, subprocess.SubprocessError):
28
+ pass
29
+ return None
30
+
31
+
32
+ def _load_checkpoint_log():
33
+ if config.CHECKPOINT_LOG.exists():
34
+ try:
35
+ return json.loads(config.CHECKPOINT_LOG.read_text(encoding='utf-8'))
36
+ except (OSError, json.JSONDecodeError):
37
+ return []
38
+ return []
39
+
40
+
41
+ def _save_checkpoint_log(entries):
42
+ try:
43
+ config.PERMISSIONS_DIR.mkdir(exist_ok=True)
44
+ config.CHECKPOINT_LOG.write_text(json.dumps(entries, indent=2), encoding='utf-8')
45
+ except OSError as e:
46
+ log_event(f"CHECKPOINT LOG SAVE FAILED: {e}")
47
+
48
+
49
+ def make_git_checkpoint(path, message):
50
+ root = _git_root(path)
51
+ if not root:
52
+ return None
53
+ try:
54
+ env = os.environ.copy()
55
+ env['GIT_INDEX_FILE'] = str(config.CHECKPOINT_INDEX_FILE)
56
+ subprocess.run(['git', 'add', '-A'], cwd=root, env=env, capture_output=True, text=True, timeout=20)
57
+ tree = subprocess.run(['git', 'write-tree'], cwd=root, env=env, capture_output=True, text=True, timeout=20)
58
+ if tree.returncode != 0:
59
+ log_event(f"CHECKPOINT write-tree failed: {tree.stderr.strip()}")
60
+ return None
61
+ tree_hash = tree.stdout.strip()
62
+
63
+ parent_args = []
64
+ parent = subprocess.run(['git', 'rev-parse', config.CHECKPOINT_REF], cwd=root, capture_output=True, text=True, timeout=5)
65
+ if parent.returncode == 0:
66
+ parent_args = ['-p', parent.stdout.strip()]
67
+ else:
68
+ head = subprocess.run(['git', 'rev-parse', 'HEAD'], cwd=root, capture_output=True, text=True, timeout=5)
69
+ if head.returncode == 0:
70
+ parent_args = ['-p', head.stdout.strip()]
71
+
72
+ commit = subprocess.run(
73
+ ['git', 'commit-tree', tree_hash, *parent_args, '-m', message],
74
+ cwd=root, env=env, capture_output=True, text=True, timeout=20,
75
+ )
76
+ if commit.returncode != 0:
77
+ log_event(f"CHECKPOINT commit-tree failed: {commit.stderr.strip()}")
78
+ return None
79
+ commit_hash = commit.stdout.strip()
80
+
81
+ upd = subprocess.run(['git', 'update-ref', config.CHECKPOINT_REF, commit_hash], cwd=root, capture_output=True, text=True, timeout=10)
82
+ if upd.returncode != 0:
83
+ log_event(f"CHECKPOINT update-ref failed: {upd.stderr.strip()}")
84
+ return None
85
+
86
+ entries = _load_checkpoint_log()
87
+ entries.append({
88
+ 'time': time.strftime('%Y-%m-%d %H:%M:%S'),
89
+ 'message': message,
90
+ 'commit': commit_hash,
91
+ 'root': root,
92
+ })
93
+ entries = entries[-100:]
94
+ _save_checkpoint_log(entries)
95
+ log_event(f"CHECKPOINT {commit_hash[:10]} ({message})")
96
+ return commit_hash
97
+ except (OSError, subprocess.SubprocessError) as e:
98
+ log_event(f"CHECKPOINT failed: {type(e).__name__}: {e}")
99
+ return None
100
+
101
+
102
+ def list_checkpoints():
103
+ entries = _load_checkpoint_log()
104
+ if not entries:
105
+ return '(no checkpoints yet. checkpoints are created automatically on Write/Edit inside a git repo)'
106
+ lines = []
107
+ for i, e in enumerate(entries, 1):
108
+ lines.append(f"{i}. {e['time']} {e['commit'][:10]} {e['message']}")
109
+ return '\n'.join(lines)
110
+
111
+
112
+ def restore_checkpoint(index):
113
+ entries = _load_checkpoint_log()
114
+ try:
115
+ idx = int(index)
116
+ except (TypeError, ValueError):
117
+ return f"Invalid checkpoint index: {index!r}"
118
+ if idx < 1 or idx > len(entries):
119
+ return f"No checkpoint at index {idx}. Use /checkpoints to see valid indices."
120
+ entry = entries[idx - 1]
121
+ root, commit = entry['root'], entry['commit']
122
+ try:
123
+ result = subprocess.run(
124
+ ['git', 'checkout', commit, '--', '.'],
125
+ cwd=root, capture_output=True, text=True, timeout=30,
126
+ )
127
+ if result.returncode != 0:
128
+ return f"Restore failed: {result.stderr.strip()}"
129
+ except (OSError, subprocess.SubprocessError) as e:
130
+ return f"Restore failed: {type(e).__name__}: {e}"
131
+ log_event(f"RESTORED checkpoint #{idx} ({commit[:10]})")
132
+ return f"Working tree in {root} restored to checkpoint #{idx} ({entry['time']}, {commit[:10]}). Your git branch/HEAD/index are untouched. only file contents were overwritten."