agloop 0.6.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.
- agloop-0.6.0.dist-info/METADATA +43 -0
- agloop-0.6.0.dist-info/RECORD +21 -0
- agloop-0.6.0.dist-info/WHEEL +5 -0
- agloop-0.6.0.dist-info/entry_points.txt +4 -0
- agloop-0.6.0.dist-info/licenses/LICENSE +21 -0
- agloop-0.6.0.dist-info/top_level.txt +3 -0
- core/agent.py +523 -0
- core/git_lock.py +406 -0
- core/init_scaffold.py +59 -0
- core/mcp_server.py +224 -0
- core/privacy_audit.py +87 -0
- core/runner.py +267 -0
- core/scan.py +108 -0
- core/templates/HISTORICO.md +3 -0
- core/templates/gestao/backlog-produto.md +3 -0
- core/templates/gestao/matriz-riscos.md +5 -0
- core/templates/gestao/roadmap.md +5 -0
- core/templates/war_room.md +3 -0
- core/war_room.py +196 -0
- main.py +83 -0
- scripts/vigia.py +72 -0
main.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from core.agent import Agent, configure_json_logging
|
|
6
|
+
from core.init_scaffold import run_init
|
|
7
|
+
from core.privacy_audit import run_privacy_audit
|
|
8
|
+
from core.runner import run_agent_loop
|
|
9
|
+
from core.scan import run_scan
|
|
10
|
+
|
|
11
|
+
# Load environment variables
|
|
12
|
+
load_dotenv()
|
|
13
|
+
|
|
14
|
+
# Structured JSON logs on stderr (Issue #11) — never stdout, so `agloop-mcp` (which
|
|
15
|
+
# writes JSON-RPC replies to stdout) is never corrupted even if it imports this module.
|
|
16
|
+
configure_json_logging()
|
|
17
|
+
|
|
18
|
+
# Define roles for our agents
|
|
19
|
+
ROLES = {
|
|
20
|
+
"Alice": "You are a senior software architect. You focus on structure, scalability, and robust design. You like to propose high-level ideas.",
|
|
21
|
+
"Bob": "You are a pragmatic developer. You focus on implementation details, edge cases, and code simplicity. You like to challenge complex architectures."
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _build_parser() -> argparse.ArgumentParser:
|
|
26
|
+
parser = argparse.ArgumentParser(description="Run or audit an AgLoop agent")
|
|
27
|
+
subparsers = parser.add_subparsers(dest="command")
|
|
28
|
+
|
|
29
|
+
run_parser = subparsers.add_parser("run", help="Run an AgLoop agent loop (default).")
|
|
30
|
+
run_parser.add_argument("--name", type=str, required=True, help="Name of the agent (e.g., Alice or Bob)")
|
|
31
|
+
run_parser.add_argument("--model", type=str, default="gemini/gemini-1.5-pro-latest", help="LLM model to use")
|
|
32
|
+
run_parser.add_argument("--sleep", type=int, default=10, help="Seconds to sleep between loop iterations")
|
|
33
|
+
run_parser.add_argument("--room", type=str, default="war_room.md", help="The markdown file for IPC")
|
|
34
|
+
|
|
35
|
+
audit_parser = subparsers.add_parser("audit", help="Run local diagnostics (no LLM calls).")
|
|
36
|
+
audit_parser.add_argument("--privacy", action="store_true", help="Run the LGPD-04 privacy diagnostic report.")
|
|
37
|
+
|
|
38
|
+
subparsers.add_parser("init", help="Scaffold a clean war_room.md and governance templates in this repo.")
|
|
39
|
+
|
|
40
|
+
subparsers.add_parser("scan", help="Read-only scan of the repository structure and known stack manifests.")
|
|
41
|
+
|
|
42
|
+
return parser
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def parse_cli_args(argv=None):
|
|
46
|
+
"""
|
|
47
|
+
Parses `run`/`audit` subcommands, defaulting to `run` for backward compatibility:
|
|
48
|
+
`python3 main.py --name Alice` keeps working exactly like before E04 added subcommands.
|
|
49
|
+
"""
|
|
50
|
+
argv = sys.argv[1:] if argv is None else list(argv)
|
|
51
|
+
if not argv or argv[0].startswith("-"):
|
|
52
|
+
argv = ["run", *argv]
|
|
53
|
+
return _build_parser().parse_args(argv)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def main():
|
|
57
|
+
args = parse_cli_args()
|
|
58
|
+
|
|
59
|
+
if args.command == "audit":
|
|
60
|
+
if args.privacy:
|
|
61
|
+
print(run_privacy_audit(repo_root="."))
|
|
62
|
+
else:
|
|
63
|
+
print("Nothing to audit: pass --privacy.")
|
|
64
|
+
return
|
|
65
|
+
|
|
66
|
+
if args.command == "init":
|
|
67
|
+
print(run_init(repo_root="."))
|
|
68
|
+
return
|
|
69
|
+
|
|
70
|
+
if args.command == "scan":
|
|
71
|
+
print(run_scan(repo_root="."))
|
|
72
|
+
return
|
|
73
|
+
|
|
74
|
+
agent_name = args.name
|
|
75
|
+
role_prompt = ROLES.get(agent_name, "You are a helpful AI assistant.")
|
|
76
|
+
|
|
77
|
+
agent = Agent(name=agent_name, role_prompt=role_prompt, model=args.model)
|
|
78
|
+
|
|
79
|
+
run_agent_loop(agent=agent, war_room_file=args.room, sleep_time=args.sleep)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == "__main__":
|
|
83
|
+
main()
|
scripts/vigia.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Vigia Híbrida do AgLoop (Thin Wrapper DRY sobre `core.runner.watch_war_room`).
|
|
4
|
+
Monitora localmente (`mtime` do `war_room.md`) e remotamente (`GitLock.sync_if_needed`).
|
|
5
|
+
Suporta `--agent <Nome>` e `--once` (`exit 0` assim que outro agente responde,
|
|
6
|
+
acordando a sessão da LLM sem custo de tokens em ociosidade).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
# Garante que a raiz do repositório esteja no sys.path quando invocado via `python3 scripts/vigia.py`
|
|
14
|
+
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
15
|
+
if REPO_ROOT not in sys.path:
|
|
16
|
+
sys.path.insert(0, REPO_ROOT)
|
|
17
|
+
|
|
18
|
+
from core.runner import watch_war_room
|
|
19
|
+
|
|
20
|
+
ROOM_FILE = "war_room.md"
|
|
21
|
+
LOCAL_POLL_INTERVAL = 2.0
|
|
22
|
+
REMOTE_POLL_INTERVAL = 30.0
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def parse_args(argv=None):
|
|
26
|
+
parser = argparse.ArgumentParser(description="Vigia Híbrida Passiva do AgLoop")
|
|
27
|
+
parser.add_argument(
|
|
28
|
+
"--agent",
|
|
29
|
+
type=str,
|
|
30
|
+
default=os.getenv("AGLOOP_AGENT", "Gemini"),
|
|
31
|
+
help="Nome do agente desta sessão (default: Gemini ou $AGLOOP_AGENT)",
|
|
32
|
+
)
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
"--once",
|
|
35
|
+
action="store_true",
|
|
36
|
+
help="Encerra com exit 0 assim que o último orador mudar para outro agente",
|
|
37
|
+
)
|
|
38
|
+
parser.add_argument("--room", type=str, default=ROOM_FILE, help="Arquivo da Sala de Guerra")
|
|
39
|
+
parser.add_argument("--local-poll", type=float, default=LOCAL_POLL_INTERVAL, help="Intervalo local (s)")
|
|
40
|
+
parser.add_argument("--remote-poll", type=float, default=REMOTE_POLL_INTERVAL, help="Intervalo remoto (s)")
|
|
41
|
+
return parser.parse_args(argv)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def main(argv=None):
|
|
45
|
+
args = parse_args(argv)
|
|
46
|
+
print("=" * 60)
|
|
47
|
+
print(" [VIGIA AG-LOOP] Modo Vigília Híbrida Ativado (DRY core.runner) ")
|
|
48
|
+
print(f" Agente local : {args.agent}")
|
|
49
|
+
print(f" Modo de execução : {'one-shot (--once)' if args.once else 'contínuo'}")
|
|
50
|
+
print(f" Arquivo monitorado : {args.room}")
|
|
51
|
+
print(f" Checagem local : a cada {args.local_poll}s (mtime)")
|
|
52
|
+
print(f" Checagem remota : a cada {args.remote_poll}s (git fetch)")
|
|
53
|
+
print("=" * 60, flush=True)
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
watch_war_room(
|
|
57
|
+
war_room_file=args.room,
|
|
58
|
+
agent_name=args.agent,
|
|
59
|
+
local_poll=args.local_poll,
|
|
60
|
+
remote_poll=args.remote_poll,
|
|
61
|
+
once=args.once,
|
|
62
|
+
repo_path=REPO_ROOT,
|
|
63
|
+
)
|
|
64
|
+
sys.exit(0)
|
|
65
|
+
except KeyboardInterrupt:
|
|
66
|
+
print("\n[Vigia] Vigília encerrada pelo usuário.", flush=True)
|
|
67
|
+
sys.exit(0)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
main()
|
|
72
|
+
|