From 8db07e5d21d5d68739910437b47d16fba650be16 Mon Sep 17 00:00:00 2001 From: DoctoDre Date: Fri, 17 Jul 2026 20:27:01 +0200 Subject: [PATCH] feat: migrate agents to monorepo and update federation configs --- .agents/AGENTS.md | 24 ++++++ .agents/models_config.json | 11 +++ .agents/scripts/check_quotas.sh | 22 ++++++ .agents/scripts/install_clis.sh | 23 ++++++ .agents/scripts/setup_apis.sh | 23 ++++++ .agents/scripts/update_models_config.sh | 35 +++++++++ .agents/skills/model_advisor/SKILL.md | 35 +++++++++ SETUP_DEVICE.md | 76 +++++++++++++++++++ shared/config/team-repos.yaml | 23 ++---- .../tools/monorepo-cli/src/monorepo/models.py | 2 +- 10 files changed, 256 insertions(+), 18 deletions(-) create mode 100644 .agents/AGENTS.md create mode 100644 .agents/models_config.json create mode 100755 .agents/scripts/check_quotas.sh create mode 100755 .agents/scripts/install_clis.sh create mode 100755 .agents/scripts/setup_apis.sh create mode 100755 .agents/scripts/update_models_config.sh create mode 100644 .agents/skills/model_advisor/SKILL.md create mode 100644 SETUP_DEVICE.md diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md new file mode 100644 index 0000000..1b81274 --- /dev/null +++ b/.agents/AGENTS.md @@ -0,0 +1,24 @@ +# Agent Rules + +## Model Selection Advisor + +Whenever you receive a new user request or begin a new task, you MUST invoke the `model_advisor` skill to evaluate the optimal model and tool strategy before proceeding with any significant planning or code modifications. +## OKF Knowledge Base Access + +Whenever the user asks you to search, query, access, or update their "knowledge", "OKF", or "Wissensdatenbank", you MUST use the custom `ctx-guard` CLI tool. +The tool is executed from the Orchestrator's virtual environment: `/home/andre/coden/Orchestrator/.venv/bin/ctx-guard knowledge`. + +**Available commands:** +- `search`: e.g., `/home/andre/coden/Orchestrator/.venv/bin/ctx-guard knowledge search "query" --limit 5` +- `capture`: e.g., `/home/andre/coden/Orchestrator/.venv/bin/ctx-guard knowledge capture "Note" --context privat` +- `status`: e.g., `/home/andre/coden/Orchestrator/.venv/bin/ctx-guard knowledge status` +- `ingest`: e.g., `/home/andre/coden/Orchestrator/.venv/bin/ctx-guard knowledge ingest` + +Always run this command directly using your `run_command` tool to retrieve or update knowledge before answering the user's queries. + +## PR Workflow Rule + +All code changes or configurations made by agents MUST go through a Pull Request / Merge Request. +- You are not allowed to do quicksaves directly to the main branch. +- You must create a new branch, commit your changes, push to the remote, and open a PR. +- After creating the PR, you must review it for viability and only merge it once confirmed. diff --git a/.agents/models_config.json b/.agents/models_config.json new file mode 100644 index 0000000..e647fc8 --- /dev/null +++ b/.agents/models_config.json @@ -0,0 +1,11 @@ +{ + "last_updated": "2026-07-16T20:12:30Z", + "providers": { + "codex": { + "models": [] + }, + "antigravity": { + "models": [] + } + } +} diff --git a/.agents/scripts/check_quotas.sh b/.agents/scripts/check_quotas.sh new file mode 100755 index 0000000..daad0f0 --- /dev/null +++ b/.agents/scripts/check_quotas.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# check_quotas.sh - Modular script to check quotas +export PATH="$HOME/.local/bin:$PATH" + +check_codex_quota() { + if command -v codex &> /dev/null; then + echo "[Codex Quota]" + codex quota || echo "Failed to fetch Codex quota" + fi +} + +check_agy_quota() { + if command -v agy &> /dev/null; then + echo "[Antigravity Quota]" + agy quota || echo "Failed to fetch Antigravity quota" + fi +} + +echo "--- Current Quotas ---" +check_codex_quota +check_agy_quota +echo "----------------------" diff --git a/.agents/scripts/install_clis.sh b/.agents/scripts/install_clis.sh new file mode 100755 index 0000000..67358f5 --- /dev/null +++ b/.agents/scripts/install_clis.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# install_clis.sh - Install configured CLIs +set -e + +echo "Starting CLI installations..." + +echo "Checking codex..." +if command -v codex &> /dev/null; then + echo "codex is already installed. Version: $(codex --version 2>/dev/null || echo 'unknown')" +else + echo "Installing codex via curl..." + curl -fsSL https://chatgpt.com/codex/install.sh | sh + echo "codex installed successfully." +fi + +echo "Checking agy (antigravity)..." +if command -v agy &> /dev/null; then + echo "agy is already installed." +else + echo "Warning: agy is not installed. Please install it manually." +fi + +echo "All CLIs are set up." diff --git a/.agents/scripts/setup_apis.sh b/.agents/scripts/setup_apis.sh new file mode 100755 index 0000000..db0ed9b --- /dev/null +++ b/.agents/scripts/setup_apis.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# setup_apis.sh - Trigger browser login flows +set -e +export PATH="$HOME/.local/bin:$PATH" + +CLIS=("codex" "agy") + +echo "Starting API Configuration via Browser Login..." + +for cli in "${CLIS[@]}"; do + echo "Configuring $cli..." + if command -v "$cli" &> /dev/null; then + if [ "$cli" == "agy" ]; then + "$cli" auth + else + "$cli" login + fi + echo "$cli configured." + else + echo "Warning: $cli not installed. Please run install_clis.sh first." + fi +done +echo "API setup complete." diff --git a/.agents/scripts/update_models_config.sh b/.agents/scripts/update_models_config.sh new file mode 100755 index 0000000..2b25df2 --- /dev/null +++ b/.agents/scripts/update_models_config.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# update_models_config.sh - Fetches latest models and quotas +export PATH="$HOME/.local/bin:$PATH" + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +CONFIG_FILE="$DIR/../models_config.json" + +echo "{" > "$CONFIG_FILE" +echo " \"last_updated\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"," >> "$CONFIG_FILE" + +# Logic to update config +echo " \"providers\": {" >> "$CONFIG_FILE" + +# Codex Models +echo " \"codex\": {" >> "$CONFIG_FILE" +if command -v codex &> /dev/null; then + echo " \"models\": $(codex models --json 2>/dev/null || echo '[]')" >> "$CONFIG_FILE" +else + echo " \"models\": []" >> "$CONFIG_FILE" +fi +echo " }," >> "$CONFIG_FILE" + +# Antigravity Models +echo " \"antigravity\": {" >> "$CONFIG_FILE" +if command -v agy &> /dev/null; then + echo " \"models\": $(agy models --json 2>/dev/null || echo '[]')" >> "$CONFIG_FILE" +else + echo " \"models\": []" >> "$CONFIG_FILE" +fi +echo " }" >> "$CONFIG_FILE" + +echo " }" >> "$CONFIG_FILE" +echo "}" >> "$CONFIG_FILE" + +echo "Models config updated at $CONFIG_FILE" diff --git a/.agents/skills/model_advisor/SKILL.md b/.agents/skills/model_advisor/SKILL.md new file mode 100644 index 0000000..b1efeca --- /dev/null +++ b/.agents/skills/model_advisor/SKILL.md @@ -0,0 +1,35 @@ +--- +name: model_advisor +description: Evaluates a task and orchestrates execution across available CLI models based on cost, quotas, and strengths. +--- + +# Instructions + +You have been invoked to act as a central orchestrator. You must evaluate the task, check available models and quotas, and delegate the work via CLI. + +## Step 1: Check Quotas & Models +Run the following scripts from your workspace: +- `.agents/scripts/check_quotas.sh` +- Review `.agents/models_config.json` to see currently available models. + +## Step 2: Evaluate the Task +Consider the following criteria: +1. **Complexity & Context**: Does it require massive context (Gemini Pro) or deep nuance (Claude Sonnet)? +2. **Cost & Quota**: Are quotas low? Use cheaper models if the task is simple. + +## Step 3: Output a Recommendation & Delegate +If the task is best suited for a CLI-driven model (e.g., Codex or Antigravity with a specific model), you MUST proactively write and execute the terminal command to delegate the task. + +Example output: +> [!TIP] +> **Model Advisor Recommendation**: The quota for Antigravity is healthy. I am delegating this refactoring task to Claude 3.5 Sonnet via the CLI. + +Example command you might run: +```bash +agy run --model claude-3-5-sonnet "refactor the payment gateway" +``` + +If the task is best suited for the *current* IDE model, advise the user to proceed normally without CLI delegation. If it's suited for an IDE model you are *not* currently using, advise the user to switch models manually in the IDE. + +## Step 4: Proceed +Once the CLI command completes, or if you decided to handle it locally, complete the user's request. diff --git a/SETUP_DEVICE.md b/SETUP_DEVICE.md new file mode 100644 index 0000000..f31d6f3 --- /dev/null +++ b/SETUP_DEVICE.md @@ -0,0 +1,76 @@ +# New Device Setup Guide + +This guide explains how to get your full Monorepo, AI Orchestrator, CLI agents, and Knowledge Base (`ctx-guard`) up and running on a brand new device. + +## Prerequisites + +Ensure the following tools are installed on your new device: +- `git` +- `python3.12` or newer +- `pipx` +- `curl` + +## Step 1: Clone the Monorepo + +Clone the Orchestrator to your preferred workspace directory (e.g., `~/coden`): +```bash +mkdir -p ~/coden +cd ~/coden +git clone https://git.d-hive.de/ankn/Orchestrator.git +cd Orchestrator +``` + +## Step 2: Set up the Knowledge CLI (`ctx-guard`) + +The `ctx-guard` tool requires a Python virtual environment. + +```bash +cd ~/coden/Orchestrator +python3 -m venv .venv +source .venv/bin/activate + +# Install the monorepo-cli package in editable mode +cd shared/tools/monorepo-cli +pip install -e . +``` + +To register the new machine to your federation topology, run the built-in onboard command: +```bash +# Replace with your device name +ctx-guard onboard "privat,dhive,bahn,shared" +``` + +## Step 3: Install the AI CLIs + +Install the Codex CLI: +```bash +curl -fsSL https://chatgpt.com/codex/install.sh | sh +``` + +Install the Antigravity CLI: +```bash +curl -fsSL https://antigravity.google/cli/install.sh | bash +``` + +Run `codex login` and `agy login` in your terminal to authenticate via the browser. + +## Step 4: AI Agent Customizations + +Because the `.agents` folder is now version-controlled inside the Orchestrator monorepo (`~/coden/Orchestrator/.agents`), your AI agents will *automatically* discover your custom skills (like `model_advisor`) and rules (like strictly using `ctx-guard` for knowledge tasks). + +To ensure your models catalog is kept up to date, you can manually run the updater script: +```bash +cd ~/coden/Orchestrator +./.agents/scripts/update_models_config.sh +``` + +*(Note: In your primary environment, an agent has scheduled this as a daily cron job. You can instruct the agent to set up the same schedule on the new device by typing `/schedule daily run .agents/scripts/update_models_config.sh` in the chat).* + +## Step 5: Sync Federation Repositories + +Finally, pull down the rest of your private and shared federation repositories from the `dhive` GitLab: +```bash +ctx-guard fed-sync --context dhive +``` + +Your environment is now fully identical to your original machine! diff --git a/shared/config/team-repos.yaml b/shared/config/team-repos.yaml index b0acb38..eeae035 100644 --- a/shared/config/team-repos.yaml +++ b/shared/config/team-repos.yaml @@ -5,31 +5,20 @@ federation: conflict_strategy: "team-wins" team_repos: - - context: privat - url: "https://github.com/andreknie/privat-team.git" - branch: main - sync_direction: bidirectional - sync_frequency: "on-push" - shared_mirror: - enabled: true - paths: - - "shared/tools/common-scripts/" - - "shared/config/base-config.yaml" - mode: read-only - - context: dhive - url: "https://gitlab.dhive.io/team/dhive-mono.git" + url: "https://git.d-hive.de/team/dhive-mono.git" branch: main sync_direction: bidirectional sync_frequency: "on-push" shared_mirror: enabled: true paths: - - "shared/tools/" - - "shared/powers/db-dxp-platform/" - - "shared/mcp-servers/" + - "privat/" + - "shared/AI-Orchestrator/" - "shared/OrgMyLife/" - mode: read-only + - "shared/config/" + - "shared/tools/" + mode: bidirectional - context: bahn url: "https://gitlab.2700.2db.it/team/bahn-workspace.git" diff --git a/shared/tools/monorepo-cli/src/monorepo/models.py b/shared/tools/monorepo-cli/src/monorepo/models.py index ba8a649..fe0efcc 100644 --- a/shared/tools/monorepo-cli/src/monorepo/models.py +++ b/shared/tools/monorepo-cli/src/monorepo/models.py @@ -218,7 +218,7 @@ class SharedMirrorConfig: enabled: bool paths: list[str] = field(default_factory=list) - mode: Literal["read-only"] = "read-only" + mode: Literal["read-only", "bidirectional"] = "read-only" @dataclass