agents-tool 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.
- agents_tool-0.1.0/.gitignore +40 -0
- agents_tool-0.1.0/LICENSE +21 -0
- agents_tool-0.1.0/PKG-INFO +64 -0
- agents_tool-0.1.0/README.md +52 -0
- agents_tool-0.1.0/design.md +132 -0
- agents_tool-0.1.0/proposal.md +46 -0
- agents_tool-0.1.0/pyproject.toml +22 -0
- agents_tool-0.1.0/specs/commands.md +32 -0
- agents_tool-0.1.0/specs/python-structure.md +24 -0
- agents_tool-0.1.0/src/agents_tool/__init__.py +3 -0
- agents_tool-0.1.0/src/agents_tool/cli.py +36 -0
- agents_tool-0.1.0/src/agents_tool/config.py +59 -0
- agents_tool-0.1.0/src/agents_tool/git.py +95 -0
- agents_tool-0.1.0/src/agents_tool/registry.py +229 -0
- agents_tool-0.1.0/src/agents_tool/validator.py +86 -0
- agents_tool-0.1.0/tasks.md +26 -0
- agents_tool-0.1.0/tests/test_cli.py +74 -0
- agents_tool-0.1.0/tests/test_config.py +75 -0
- agents_tool-0.1.0/tests/test_registry.py +137 -0
- agents_tool-0.1.0/tests/test_validator.py +120 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
ENV/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.vscode/
|
|
30
|
+
.idea/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
|
|
34
|
+
# Testing
|
|
35
|
+
.pytest_cache/
|
|
36
|
+
.coverage
|
|
37
|
+
htmlcov/
|
|
38
|
+
|
|
39
|
+
# Local agents config
|
|
40
|
+
.agents/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
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,64 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agents-tool
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI tool for managing AI agents, skills and harness
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: click>=8.1.0
|
|
9
|
+
Requires-Dist: gitpython>=3.1.0
|
|
10
|
+
Requires-Dist: pyyaml>=6.0
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# Agents Tool
|
|
14
|
+
|
|
15
|
+
CLI tool for managing AI agents, skills and harness.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install agents-tool
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Initialize configuration
|
|
27
|
+
agents init
|
|
28
|
+
|
|
29
|
+
# Edit config to add your repos
|
|
30
|
+
vim ~/.config/agents/config.yaml
|
|
31
|
+
|
|
32
|
+
# Import/update all agents
|
|
33
|
+
agents gou
|
|
34
|
+
|
|
35
|
+
# List installed agents/skills/harness
|
|
36
|
+
agents list
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Edit `~/.config/agents/config.yaml`:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
repos:
|
|
45
|
+
- url: git@github.com:your-username/your-agents.git
|
|
46
|
+
user: your-username
|
|
47
|
+
branch: main
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Agent Repo Structure
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
your-agents/
|
|
54
|
+
├── agents/
|
|
55
|
+
│ └── reviewer/
|
|
56
|
+
│ ├── agent.yaml
|
|
57
|
+
│ └── prompt.md
|
|
58
|
+
├── skills/
|
|
59
|
+
│ └── code-review/
|
|
60
|
+
│ └── SKILL.md
|
|
61
|
+
└── harness/
|
|
62
|
+
└── opencode/
|
|
63
|
+
└── config.json
|
|
64
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Agents Tool
|
|
2
|
+
|
|
3
|
+
CLI tool for managing AI agents, skills and harness.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install agents-tool
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Initialize configuration
|
|
15
|
+
agents init
|
|
16
|
+
|
|
17
|
+
# Edit config to add your repos
|
|
18
|
+
vim ~/.config/agents/config.yaml
|
|
19
|
+
|
|
20
|
+
# Import/update all agents
|
|
21
|
+
agents gou
|
|
22
|
+
|
|
23
|
+
# List installed agents/skills/harness
|
|
24
|
+
agents list
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Configuration
|
|
28
|
+
|
|
29
|
+
Edit `~/.config/agents/config.yaml`:
|
|
30
|
+
|
|
31
|
+
```yaml
|
|
32
|
+
repos:
|
|
33
|
+
- url: git@github.com:your-username/your-agents.git
|
|
34
|
+
user: your-username
|
|
35
|
+
branch: main
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Agent Repo Structure
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
your-agents/
|
|
42
|
+
├── agents/
|
|
43
|
+
│ └── reviewer/
|
|
44
|
+
│ ├── agent.yaml
|
|
45
|
+
│ └── prompt.md
|
|
46
|
+
├── skills/
|
|
47
|
+
│ └── code-review/
|
|
48
|
+
│ └── SKILL.md
|
|
49
|
+
└── harness/
|
|
50
|
+
└── opencode/
|
|
51
|
+
└── config.json
|
|
52
|
+
```
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Agents Tool - Design
|
|
2
|
+
|
|
3
|
+
## Arquitetura
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
+-----------------------------------------------------------+
|
|
7
|
+
| CLI (click) |
|
|
8
|
+
+-----------------------------------------------------------+
|
|
9
|
+
| |
|
|
10
|
+
| agents init Cria config.yaml (statico) |
|
|
11
|
+
| agents gou Get or Update (importa/atualiza) |
|
|
12
|
+
| agents list Mostra agents/skills instalados |
|
|
13
|
+
| |
|
|
14
|
+
+-----------------------------------------------------------+
|
|
15
|
+
|
|
|
16
|
+
v
|
|
17
|
+
+-----------------------------------------------------------+
|
|
18
|
+
| Core |
|
|
19
|
+
+-----------------------------------------------------------+
|
|
20
|
+
| |
|
|
21
|
+
| ConfigManager Le/escrive config.yaml |
|
|
22
|
+
| GitManager Operacoes git (clone, pull, auth) |
|
|
23
|
+
| Registry Indexa agents/skills disponiveis |
|
|
24
|
+
| Runner Executa agentes |
|
|
25
|
+
| |
|
|
26
|
+
+-----------------------------------------------------------+
|
|
27
|
+
|
|
|
28
|
+
v
|
|
29
|
+
+-----------------------------------------------------------+
|
|
30
|
+
| Storage |
|
|
31
|
+
+-----------------------------------------------------------+
|
|
32
|
+
| |
|
|
33
|
+
| ~/.config/agents/config.yaml Configuracao global |
|
|
34
|
+
| ~/.local/share/agents/ |
|
|
35
|
+
| repos/ Clones dos repos |
|
|
36
|
+
| installed/ Agents/skills disponiveis |
|
|
37
|
+
| |
|
|
38
|
+
+-----------------------------------------------------------+
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Estrutura do Repo Padronizado
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
meu-repo-agents/
|
|
45
|
+
├── agents/
|
|
46
|
+
│ ├── reviewer/
|
|
47
|
+
│ │ ├── agent.yaml
|
|
48
|
+
│ │ └── prompt.md
|
|
49
|
+
│ └── coder/
|
|
50
|
+
│ ├── agent.yaml
|
|
51
|
+
│ └── prompt.md
|
|
52
|
+
├── skills/
|
|
53
|
+
│ ├── code-review/
|
|
54
|
+
│ │ └── SKILL.md
|
|
55
|
+
│ └── refactor/
|
|
56
|
+
│ └── SKILL.md
|
|
57
|
+
└── harness/
|
|
58
|
+
├── opencode/
|
|
59
|
+
│ └── config.json
|
|
60
|
+
└── cursor/
|
|
61
|
+
└── rules.md
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## agent.yaml (exemplo)
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
name: reviewer
|
|
68
|
+
version: "1.0"
|
|
69
|
+
description: "Code reviewer agentic"
|
|
70
|
+
tools:
|
|
71
|
+
- read
|
|
72
|
+
- grep
|
|
73
|
+
- bash (readonly)
|
|
74
|
+
dependencies: []
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Config (~/.config/agents/config.yaml)
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
repos:
|
|
81
|
+
- url: git@github.com:meu-usuario/agents.git
|
|
82
|
+
user: meu-usuario
|
|
83
|
+
branch: main
|
|
84
|
+
last_updated: null
|
|
85
|
+
- url: git@github.com:equipe/shared.git
|
|
86
|
+
user: meu-usuario
|
|
87
|
+
branch: develop
|
|
88
|
+
last_updated: null
|
|
89
|
+
|
|
90
|
+
defaults:
|
|
91
|
+
branch: main
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Autenticacao
|
|
95
|
+
|
|
96
|
+
Duas opcoes:
|
|
97
|
+
|
|
98
|
+
### Opcao 1: Token via terminal (recomendado)
|
|
99
|
+
```
|
|
100
|
+
$ agents update
|
|
101
|
+
Repo: meu-usuario/agents
|
|
102
|
+
Token: ********
|
|
103
|
+
Pulling...
|
|
104
|
+
Done.
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Opcao 2: SSH key
|
|
108
|
+
```
|
|
109
|
+
$ agents update
|
|
110
|
+
Repo: meu-usuario/agents
|
|
111
|
+
Using SSH key...
|
|
112
|
+
Pulling...
|
|
113
|
+
Done.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Sincronizacao
|
|
117
|
+
|
|
118
|
+
Para cada repo, o `update` faz:
|
|
119
|
+
1. `git fetch` (com autenticacao)
|
|
120
|
+
2. `git pull` (atualiza)
|
|
121
|
+
3. Indexa agents/skills novos
|
|
122
|
+
4. Copia/gera links pra `installed/`
|
|
123
|
+
|
|
124
|
+
## Decisoes Tecnicas
|
|
125
|
+
|
|
126
|
+
| Decisao | Opcao | Justificativa |
|
|
127
|
+
|---------|-------|---------------|
|
|
128
|
+
| Linguagem | Python | Facil instalacao, pip/pipx |
|
|
129
|
+
| CLI | click | CLI framework popular e simples |
|
|
130
|
+
| Git | gitpython | Wrapper nativo do git |
|
|
131
|
+
| Storage | Local filesystem | Sem daemon necessario |
|
|
132
|
+
| Auth | Token interativo | Seguro, sem persistir senha |
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Agents Tool - Proposal
|
|
2
|
+
|
|
3
|
+
## O que e
|
|
4
|
+
|
|
5
|
+
Uma CLI para gerenciar agents, skills e harness de forma global. As pessoas criam seus repos no GitHub com uma estrutura padronizada e usam essa ferramenta pra instalar, atualizar e compartilhar.
|
|
6
|
+
|
|
7
|
+
## Problema
|
|
8
|
+
|
|
9
|
+
Hoje, quem usa agentes de IA (opencode, cursor, etc) tem seus agents/skills espalhados:
|
|
10
|
+
- Copy-paste entre projetos
|
|
11
|
+
- Sem versionamento
|
|
12
|
+
- Dificil de compartilhar com equipe
|
|
13
|
+
- Cada ferramenta tem seu proprio formato
|
|
14
|
+
|
|
15
|
+
## Solucao
|
|
16
|
+
|
|
17
|
+
Um gerenciador de dotfiles especifico para agentes:
|
|
18
|
+
- Estrutura padronizada (agents/, skills/, harness/)
|
|
19
|
+
- Git como backend de armazenamento
|
|
20
|
+
- Config global (~/.config/agents/)
|
|
21
|
+
- Comando unico pra atualizar tudo
|
|
22
|
+
|
|
23
|
+
## Publico-alvo
|
|
24
|
+
|
|
25
|
+
- Desenvolvedores que usam agentes de IA
|
|
26
|
+
- Equipes que querem compartilhar configs
|
|
27
|
+
- Quem quer manter seus agents versionados
|
|
28
|
+
|
|
29
|
+
## Exemplo de uso
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Primeira vez
|
|
33
|
+
pip install agents-tool
|
|
34
|
+
agents init
|
|
35
|
+
|
|
36
|
+
# Editar config
|
|
37
|
+
vim ~/.config/agents/config.yaml
|
|
38
|
+
|
|
39
|
+
# Importar/atualizar tudo
|
|
40
|
+
agents gou
|
|
41
|
+
|
|
42
|
+
# Listar o que esta instalado
|
|
43
|
+
agents list
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
A ferramenta so gerencia a instalacao. A execucao dos agents fica por conta de cada ferramenta (opencode, cursor, etc).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agents-tool"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "CLI tool for managing AI agents, skills and harness"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"click>=8.1.0",
|
|
14
|
+
"gitpython>=3.1.0",
|
|
15
|
+
"pyyaml>=6.0",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
agents = "agents_tool.cli:main"
|
|
20
|
+
|
|
21
|
+
[tool.hatch.build.targets.wheel]
|
|
22
|
+
packages = ["src/agents_tool"]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Agents Tool - Specs
|
|
2
|
+
|
|
3
|
+
## Comandos
|
|
4
|
+
|
|
5
|
+
### agents init
|
|
6
|
+
|
|
7
|
+
- Cria `~/.config/agents/config.yaml` com template vazio
|
|
8
|
+
- Mostra mensagem explicando pra editar o arquivo
|
|
9
|
+
- Nao clone nada (so cria o config)
|
|
10
|
+
|
|
11
|
+
### agents gou (get or update)
|
|
12
|
+
|
|
13
|
+
- Le `~/.config/agents/config.yaml`
|
|
14
|
+
- Para cada repo:
|
|
15
|
+
- Se nao existe localmente -> clone (get)
|
|
16
|
+
- Se ja existe -> pull (update)
|
|
17
|
+
- Pede token/senha via terminal (se necessario)
|
|
18
|
+
- Indexa agents/skills/harness encontrados
|
|
19
|
+
- Copia pra `installed/`
|
|
20
|
+
- Mostra resumo do que foi instalado/atualizado
|
|
21
|
+
|
|
22
|
+
### agents list
|
|
23
|
+
|
|
24
|
+
- Lista agents instalados
|
|
25
|
+
- Lista skills instalados
|
|
26
|
+
- Lista harness instalados
|
|
27
|
+
- Mostra versao e repo de origem
|
|
28
|
+
|
|
29
|
+
## Nao faz parte
|
|
30
|
+
|
|
31
|
+
- Execucao de agentes (ferramenta do usuario decide)
|
|
32
|
+
- Integracao com LLM (cada ferramenta tem seu jeito)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Agents Tool - Python Project Structure
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
agents-tool/
|
|
5
|
+
├── pyproject.toml
|
|
6
|
+
├── README.md
|
|
7
|
+
├── src/
|
|
8
|
+
│ └── agents_tool/
|
|
9
|
+
│ ├── __init__.py
|
|
10
|
+
│ ├── cli.py # Click commands
|
|
11
|
+
│ ├── config.py # ConfigManager
|
|
12
|
+
│ ├── git.py # GitManager
|
|
13
|
+
│ ├── registry.py # Registry
|
|
14
|
+
│ └── runner.py # Runner
|
|
15
|
+
└── tests/
|
|
16
|
+
└── ...
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Dependencias
|
|
20
|
+
|
|
21
|
+
- click - CLI framework
|
|
22
|
+
- gitpython - Git operations
|
|
23
|
+
- pyyaml - Config files
|
|
24
|
+
- rich - Terminal output (opcional)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""CLI entry point for agents-tool."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from . import __version__
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.group()
|
|
9
|
+
@click.version_option(version=__version__)
|
|
10
|
+
def main():
|
|
11
|
+
"""Agents Tool - Manage AI agents, skills and harness."""
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@main.command()
|
|
16
|
+
def init():
|
|
17
|
+
"""Initialize agents-tool configuration."""
|
|
18
|
+
from .config import init_config
|
|
19
|
+
|
|
20
|
+
init_config()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@main.command()
|
|
24
|
+
def gou():
|
|
25
|
+
"""Get or update agents from configured repos."""
|
|
26
|
+
from .git import process_repos
|
|
27
|
+
|
|
28
|
+
process_repos()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@main.command()
|
|
32
|
+
def list():
|
|
33
|
+
"""List installed agents, skills and harness."""
|
|
34
|
+
from .registry import list_installed
|
|
35
|
+
|
|
36
|
+
list_installed()
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Config management for agents-tool."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
import yaml
|
|
8
|
+
|
|
9
|
+
# Local config (in current directory)
|
|
10
|
+
CONFIG_DIR = Path.cwd() / ".agents"
|
|
11
|
+
CONFIG_FILE = CONFIG_DIR / "config.yaml"
|
|
12
|
+
LOCAL_DIR = Path.cwd() / ".agents"
|
|
13
|
+
REPOS_DIR = LOCAL_DIR / "repos"
|
|
14
|
+
INSTALLED_DIR = LOCAL_DIR / "installed"
|
|
15
|
+
|
|
16
|
+
CONFIG_TEMPLATE = """\
|
|
17
|
+
# Agents Tool Configuration
|
|
18
|
+
# Edit this file with your repos and preferences.
|
|
19
|
+
|
|
20
|
+
repos:
|
|
21
|
+
# Example:
|
|
22
|
+
# - url: git@github.com:your-username/your-agents.git
|
|
23
|
+
# user: your-username
|
|
24
|
+
# branch: main
|
|
25
|
+
#
|
|
26
|
+
# - url: git@github.com:team/shared-agents.git
|
|
27
|
+
# user: your-username
|
|
28
|
+
# branch: develop
|
|
29
|
+
|
|
30
|
+
defaults:
|
|
31
|
+
branch: main
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def init_config():
|
|
36
|
+
"""Initialize configuration and directories."""
|
|
37
|
+
if CONFIG_FILE.exists():
|
|
38
|
+
click.echo(f"Config already exists: {CONFIG_FILE}")
|
|
39
|
+
click.echo("Edit it manually to add your repos.")
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
43
|
+
REPOS_DIR.mkdir(parents=True, exist_ok=True)
|
|
44
|
+
INSTALLED_DIR.mkdir(parents=True, exist_ok=True)
|
|
45
|
+
|
|
46
|
+
CONFIG_FILE.write_text(CONFIG_TEMPLATE)
|
|
47
|
+
|
|
48
|
+
click.echo("Agents tool initialized!")
|
|
49
|
+
click.echo(f"Config: {CONFIG_FILE}")
|
|
50
|
+
click.echo("Edit it to add your repos, then run: agents gou")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def load_config():
|
|
54
|
+
"""Load configuration from YAML file."""
|
|
55
|
+
if not CONFIG_FILE.exists():
|
|
56
|
+
raise FileNotFoundError(f"Config not found: {CONFIG_FILE}")
|
|
57
|
+
|
|
58
|
+
with open(CONFIG_FILE) as f:
|
|
59
|
+
return yaml.safe_load(f)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""Git operations for agents-tool."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
from git import Repo
|
|
8
|
+
|
|
9
|
+
from .config import load_config, REPOS_DIR, INSTALLED_DIR
|
|
10
|
+
from .registry import sync_installed, update_registry
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def process_repos():
|
|
14
|
+
"""Process all repos from config (clone or update)."""
|
|
15
|
+
config = load_config()
|
|
16
|
+
repos = config.get("repos", [])
|
|
17
|
+
|
|
18
|
+
if not repos:
|
|
19
|
+
click.echo("No repos configured.")
|
|
20
|
+
click.echo("Edit .agents/config.yaml to add repos.")
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
for repo_config in repos:
|
|
24
|
+
process_repo(repo_config)
|
|
25
|
+
|
|
26
|
+
# Sync and update registry after all repos are processed
|
|
27
|
+
click.echo()
|
|
28
|
+
click.echo("Syncing installed...")
|
|
29
|
+
sync_installed()
|
|
30
|
+
|
|
31
|
+
click.echo("Updating registry...")
|
|
32
|
+
update_registry()
|
|
33
|
+
|
|
34
|
+
click.echo()
|
|
35
|
+
click.echo("Done!")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def process_repo(repo_config):
|
|
39
|
+
"""Process a single repo (clone or update)."""
|
|
40
|
+
url = repo_config.get("url")
|
|
41
|
+
user = repo_config.get("user", "")
|
|
42
|
+
branch = repo_config.get("branch", "main")
|
|
43
|
+
|
|
44
|
+
if not url:
|
|
45
|
+
click.echo("Warning: Repo without URL, skipping.")
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
repo_name = extract_repo_name(url)
|
|
49
|
+
repo_path = REPOS_DIR / repo_name
|
|
50
|
+
|
|
51
|
+
if repo_path.exists():
|
|
52
|
+
update_repo(repo_path, branch)
|
|
53
|
+
else:
|
|
54
|
+
clone_repo(url, repo_path, branch)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def extract_repo_name(url):
|
|
58
|
+
"""Extract repo name from git URL."""
|
|
59
|
+
# Handle SSH URLs
|
|
60
|
+
if url.endswith(".git"):
|
|
61
|
+
url = url[:-4]
|
|
62
|
+
# Get last part after /
|
|
63
|
+
return url.split("/")[-1]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def clone_repo(url, path, branch):
|
|
67
|
+
"""Clone a repo with authentication."""
|
|
68
|
+
click.echo(f"Cloning: {url}")
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
# Try cloning without auth first (public repos)
|
|
72
|
+
Repo.clone_from(url, str(path), branch=branch)
|
|
73
|
+
click.echo(f" Cloned to: {path}")
|
|
74
|
+
except Exception as e:
|
|
75
|
+
if "Authentication" in str(e) or "public" in str(e).lower():
|
|
76
|
+
# Need auth - ask for token
|
|
77
|
+
token = click.prompt("Token", hide_input=True)
|
|
78
|
+
auth_url = url.replace("git@", f"https://{token}@")
|
|
79
|
+
Repo.clone_from(auth_url, str(path), branch=branch)
|
|
80
|
+
click.echo(f" Cloned to: {path}")
|
|
81
|
+
else:
|
|
82
|
+
click.echo(f" Error: {e}")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def update_repo(path, branch):
|
|
86
|
+
"""Pull updates for an existing repo."""
|
|
87
|
+
click.echo(f"Updating: {path.name}")
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
repo = Repo(str(path))
|
|
91
|
+
origin = repo.remotes.origin
|
|
92
|
+
origin.pull(branch)
|
|
93
|
+
click.echo(" Updated")
|
|
94
|
+
except Exception as e:
|
|
95
|
+
click.echo(f" Error: {e}")
|