From 410e903f4f908850983e281de645bf404196be35 Mon Sep 17 00:00:00 2001 From: Oskar Kapala Date: Sun, 3 May 2026 19:37:40 +0200 Subject: [PATCH] Initial shared homelab agent workspace --- .gitignore | 1 + .idea/.gitignore | 10 +++++ .idea/codeStyles/codeStyleConfig.xml | 5 +++ .idea/homelab-codex-ws.iml | 9 +++++ .idea/misc.xml | 7 ++++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ __pycache__/ollama_client.cpython-313.pyc | Bin 0 -> 2460 bytes codex_context.yaml | 20 ++++++++- ollama_client.py | 5 ++- start-aider.sh | 47 ++++++++++++++++++++++ start-codex.sh | 4 ++ update-context.md | 8 ++++ 13 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/homelab-codex-ws.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 __pycache__/ollama_client.cpython-313.pyc create mode 100755 start-aider.sh create mode 100644 update-context.md diff --git a/.gitignore b/.gitignore index 4c49bd7..de6a291 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .env +.aider* diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/homelab-codex-ws.iml b/.idea/homelab-codex-ws.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/homelab-codex-ws.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..51da044 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8247b25 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/__pycache__/ollama_client.cpython-313.pyc b/__pycache__/ollama_client.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d1935064b2e13cb93a9aeeb74c2fbdc46cf5d030 GIT binary patch literal 2460 zcmah~OKcNI7@qa6ch`@#v7LkvXuNp7O}-ey5w-a94?yAA$HDDM(>XB2rly!Z>>uVV#vD>==`9bk)QwYb#P* z3ft?d>=M$yxpb#+y-Woqg5n+%6@EUE+vm%&UlfpChCO5gPNgqA?F>^wcD3 ztBfX@NhaofMHLO%-r-ZHj(m1xd?axy-!NraMqfOh(UWRsN;j>(J$rh(du%3d^9Iqg zhGp{vTREa7t8O^X2r#qoTj_@xf@c)h2vXQiSDaBe#oftj%&2paPKj!Gs{qAn>01Mi z^0iF>DSWqURIKecPTdGo3vk242{o=FDxNMz@hZLpoaSmq|Kk~?^4&4wQv8Z^z~w?3 zJHjSH@A47qtwM>&dY-cCiN--Wz*oC)8Lf%2ZoOnHI=g!PntQ~p1ZdinAf4M$3)+o7 ztO}*zb|zdhiXs`lq1}hrD4Jke*2dbfUVox-JtiP^2SOUJY#QMcP3!q^HzD9`+lbT6 znXV|rr}0Pl_UbyZwh}h-p?SR~@L`MNL-@UxTpL>Yr()y{wZh#(WRVd*fVwx<&{~rl zZLd*1F7T%!S@$23khRKKJq_N!&&~v@+)%83C?7~+Y?v5d?nvq>Ol&S^ViI%N9MLn_ z7LvMVVa+-gV{La94rFXGi%nCV#HP)g7Qt#Z?}@8MI-ZU8(z7_Oo0nA*hemq| zCoR*#GU`RA4z71xGvj(Dqh{6dWF`$2&}o1o)x1o)K#>Q2<^;U@o9JbzrQF;;-%zUG zU#vS&4sZTb;DY?kPhNYGFErOV+qvYGOJ4bfuYP9t?Q~I;Ur3?3^S90ygat`nl6ID) zo%ez4Du<%QmhR%Fo^r5$*@Jv7%gF8HZw@T`1McVxDKd9q_QI0XR+8H84a|p&ll-s%IT*QpeD+3Rx)h8R z#n>AG4lGJNZ(obZAD-)lzc5Kh;i>NhdwAI?@ryBDxAM}<$mO+rUy;;{l#GK zqS*WP1;pf>mPZm}}QCM)#+*lNw-!8L&{AGRx`F_~gJRqTmd*zS&*+&iA zfqvBQ9q(ChQuDE`?BiWqkNVjsJOlI-e+!*E0)q_u str: payload = { @@ -10,7 +13,7 @@ def ask(prompt: str) -> str: "stream": False, } req = urllib.request.Request( - "http://localhost:11434/api/chat", + f"{OLLAMA_URL}/api/chat", data=json.dumps(payload).encode("utf-8"), headers={"Content-Type": "application/json"}, method="POST", diff --git a/start-aider.sh b/start-aider.sh new file mode 100755 index 0000000..42fc1fc --- /dev/null +++ b/start-aider.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +STATE_FILE="$SCRIPT_DIR/codex_context.yaml" +DEFAULT_OLLAMA_API_BASE="http://100.100.231.104:11434" +AIDER_BIN="${AIDER_BIN:-$HOME/.local/bin/aider}" + +usage() { + cat <<'EOF' +Usage: ./start-aider.sh [aider-args...] + +Starts Aider from this repository with shared project context. +EOF +} + +if (($# > 0)); then + case "$1" in + -h|--help) + usage + exit 0 + ;; + esac +fi + +export OLLAMA_API_BASE="${OLLAMA_API_BASE:-$DEFAULT_OLLAMA_API_BASE}" + +cd "$SCRIPT_DIR" +printf 'Loading %s\n' "$STATE_FILE" + +if [[ ! -x "$AIDER_BIN" ]]; then + echo "Aider executable not found at $AIDER_BIN" >&2 + exit 1 +fi + +if "$AIDER_BIN" --help 2>/dev/null | grep -q -- '--read FILE'; then + printf '%s\n' 'Starting Aider with codex_context.yaml attached as read-only shared context.' + exec "$AIDER_BIN" \ + --model ollama/deepseek-coder:latest \ + --read "$STATE_FILE" \ + "$@" +fi + +printf '%s\n' 'Aider does not support read-only context files in this environment.' +printf '%s\n' 'Ask Aider to read codex_context.yaml first, then continue with your task.' +exec "$AIDER_BIN" --model qwen2.5-coder:14b"$@" diff --git a/start-codex.sh b/start-codex.sh index bf259c7..3188bc6 100755 --- a/start-codex.sh +++ b/start-codex.sh @@ -4,6 +4,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" STATE_FILE="$SCRIPT_DIR/codex_context.yaml" +INITIAL_INSTRUCTION="Before doing any task, read codex_context.yaml and treat it as shared project memory." MEMORY_POLICY_PROMPT=$(cat <<'EOF' You are an autonomous coding agent with persistent memory. @@ -76,6 +77,7 @@ EOF } build_prompt() { + printf '%s\n\n' "$INITIAL_INSTRUCTION" printf '%s\n\n' "$MEMORY_POLICY_PROMPT" if [[ -f "$STATE_FILE" ]]; then @@ -114,6 +116,8 @@ main() { exit 0 fi + cd "$SCRIPT_DIR" + printf 'Loading %s\n' "$STATE_FILE" exec codex --cd "$SCRIPT_DIR" "${codex_args[@]}" "$prompt" } diff --git a/update-context.md b/update-context.md new file mode 100644 index 0000000..03838fd --- /dev/null +++ b/update-context.md @@ -0,0 +1,8 @@ +# Shared Context Protocol + +- Shared memory file: `codex_context.yaml` +- Codex and Aider must both read `codex_context.yaml` before starting work. +- After any meaningful work, update `codex_context.yaml`. +- Record decisions, todos, issues, and host-specific state. +- Keep the file compressed, structured, and lossless. +- Do not store secrets in `codex_context.yaml`.