Initial shared homelab agent workspace
This commit is contained in:
parent
104d8dc06d
commit
410e903f4f
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
.env
|
.env
|
||||||
|
.aider*
|
||||||
|
|
|
||||||
10
.idea/.gitignore
vendored
Normal file
10
.idea/.gitignore
vendored
Normal file
|
|
@ -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
|
||||||
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
9
.idea/homelab-codex-ws.iml
Normal file
9
.idea/homelab-codex-ws.iml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
7
.idea/misc.xml
Normal file
7
.idea/misc.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="KubernetesApiProvider"><![CDATA[{}]]></component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/homelab-codex-ws.iml" filepath="$PROJECT_DIR$/.idea/homelab-codex-ws.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
BIN
__pycache__/ollama_client.cpython-313.pyc
Normal file
BIN
__pycache__/ollama_client.cpython-313.pyc
Normal file
Binary file not shown.
|
|
@ -4,7 +4,7 @@ SESSION_STATE:
|
||||||
environment:
|
environment:
|
||||||
cwd: "/home/oskar/projects/homelab-codex-ws"
|
cwd: "/home/oskar/projects/homelab-codex-ws"
|
||||||
shell: "zsh"
|
shell: "zsh"
|
||||||
date: "2026-04-22"
|
date: "2026-05-03"
|
||||||
tz: "Europe/Warsaw"
|
tz: "Europe/Warsaw"
|
||||||
systems:
|
systems:
|
||||||
S1:
|
S1:
|
||||||
|
|
@ -87,6 +87,18 @@ SESSION_STATE:
|
||||||
D27: "Git commit created on 2026-04-22: 72290cd 'Improve deploy failure analysis'."
|
D27: "Git commit created on 2026-04-22: 72290cd 'Improve deploy failure analysis'."
|
||||||
D28: "Updated deploy_agent.py second-failure path to return 'ESCALATE_TO_CODEX' with formatted debug block containing service, error, status, and logs instead of returning plain ERROR."
|
D28: "Updated deploy_agent.py second-failure path to return 'ESCALATE_TO_CODEX' with formatted debug block containing service, error, status, and logs instead of returning plain ERROR."
|
||||||
D29: "User requested git commit on 2026-04-22; commit scope includes ./deploy_agent.py and ./codex_context.yaml for Codex escalation-path update."
|
D29: "User requested git commit on 2026-04-22; commit scope includes ./deploy_agent.py and ./codex_context.yaml for Codex escalation-path update."
|
||||||
|
D30: "Git commit created on 2026-04-22: 104d8dc 'Add deploy escalation output'."
|
||||||
|
D31: "Startup 2026-04-23: loaded user-provided SESSION_STATE as authoritative memory, found existing ./codex_context.yaml, refreshed meta.environment.date, overwrote state file."
|
||||||
|
D32: "Startup 2026-05-03: loaded user-provided SESSION_STATE as authoritative memory, found existing ./codex_context.yaml, refreshed meta.environment.date, overwrote state file."
|
||||||
|
D33: "Updated ./ollama_client.py to import os, define OLLAMA_URL from env defaulting to http://localhost:11434 with trailing-slash trim, and replace hardcoded /api/chat base URL with f'{OLLAMA_URL}/api/chat'."
|
||||||
|
D34: "User requested identical Aider setup on solaria, piha, vpshetzner via SSH using ~/.ssh/config; per-host flow: install uv if missing, ensure ~/.local/bin PATH in ~/.zshrc, install aider-chat with uv tool install --python 3.12, ensure OLLAMA_API_BASE export in ~/.zshrc, source ~/.zshrc, verify aider, run one-line model test; retry each failed step once; continue across hosts."
|
||||||
|
D35: "Aider install run 2026-05-03: solaria reachable via unrestricted ssh -F ~/.ssh/config; installed aider-chat with uv on remote Python 3.12, ensured ~/.zshrc contains PATH export for ~/.local/bin and OLLAMA_API_BASE=http://100.100.231.104:11434; verify: which aider=/home/oskar/.local/bin/aider, version=aider 0.86.2."
|
||||||
|
D36: "Aider host access results 2026-05-03: piha ssh auth failed for oskar@piha (Permission denied publickey,password); vpshetzner alias unresolved locally; ssh probes to configured IP-only hosts 92.43.115.112 and 92.43.115.118 timed out on port 22; requested exact aider test command on solaria exited 0 but only opened interactive session and echoed prompt without visible model reply."
|
||||||
|
D37: "User corrected remaining SSH targets on 2026-05-03: piha via pi@piha; vps via ubuntu-4gb-hel1-1. Scope narrowed: do not reinstall solaria; only install/verify Aider on remaining hosts; do not run interactive aider test; verify version only; update ~/.zshrc and/or ~/.bashrc idempotently."
|
||||||
|
D38: "Aider retry run 2026-05-03 succeeded on both corrected targets. piha via pi@piha: installed uv when missing, updated existing shell rc files idempotently for PATH and OLLAMA_API_BASE, installed aider-chat with uv tool install --python 3.12, verify=aider 0.86.2. VPS via ubuntu-4gb-hel1-1: same actions, verify=aider 0.86.2."
|
||||||
|
D39: "Shared context bootstrap update 2026-05-03: start-codex.sh now runs from repo root, prints that it is loading ./codex_context.yaml, and injects the required initial instruction 'Before doing any task, read codex_context.yaml and treat it as shared project memory.' before existing SESSION_STATE bootstrap content."
|
||||||
|
D40: "Created ./start-aider.sh and ./update-context.md on 2026-05-03. start-aider.sh runs from repo root, defaults OLLAMA_API_BASE to http://100.100.231.104:11434, uses model ollama/deepseek-coder:latest, and attaches ./codex_context.yaml via aider --read after confirming read-only support from local aider help. update-context.md documents shared context rules for Codex and Aider; scripts set executable."
|
||||||
|
D41: "Startup 2026-05-03: read existing ./codex_context.yaml before task work, verified parity with user-provided SESSION_STATE, retained state, overwrote file."
|
||||||
todos:
|
todos:
|
||||||
T1: "For all future meaningful changes/decisions, update and overwrite ./codex_context.yaml."
|
T1: "For all future meaningful changes/decisions, update and overwrite ./codex_context.yaml."
|
||||||
T2: "DONE: Commit current changes."
|
T2: "DONE: Commit current changes."
|
||||||
|
|
@ -108,7 +120,13 @@ SESSION_STATE:
|
||||||
T18: "DONE: Tighten deploy status validation against unhealthy containers."
|
T18: "DONE: Tighten deploy status validation against unhealthy containers."
|
||||||
T19: "DONE: Commit deploy failure analysis and status validation updates."
|
T19: "DONE: Commit deploy failure analysis and status validation updates."
|
||||||
T20: "DONE: Add Codex escalation output on second deployment failure."
|
T20: "DONE: Add Codex escalation output on second deployment failure."
|
||||||
|
T21: "DONE: Commit deploy escalation output changes."
|
||||||
|
T22: "DONE: Retry Aider setup on remaining hosts using corrected SSH targets pi@piha and ubuntu-4gb-hel1-1; both verified at aider 0.86.2."
|
||||||
|
T23: "DONE: Add shared Codex/Aider context bootstrap scripts and update-context protocol doc."
|
||||||
issues:
|
issues:
|
||||||
I1: "Tailscale DNS health warning: configured DNS servers unreachable."
|
I1: "Tailscale DNS health warning: configured DNS servers unreachable."
|
||||||
I2: "Preferred gateway path unavailable: 100.108.208.3:8080 connection failed."
|
I2: "Preferred gateway path unavailable: 100.108.208.3:8080 connection failed."
|
||||||
I3: "Prior direct solaria/gateway-IP checks remain historical only; current policy forbids direct solaria/localhost use."
|
I3: "Prior direct solaria/gateway-IP checks remain historical only; current policy forbids direct solaria/localhost use."
|
||||||
|
I4: "SSH access mismatch vs user expectation: ~/.ssh/config lacks solaria/piha/vpshetzner host aliases; only raw IP host entries 92.43.115.112 and 92.43.115.118 exist."
|
||||||
|
I5: "piha unreachable for task execution with current ssh config/identity: oskar@piha returns Permission denied (publickey,password)."
|
||||||
|
I6: "vpshetzner target unresolved/unreachable: hostname vpshetzner does not resolve locally; configured IP-only hosts 92.43.115.112 and 92.43.115.118 timed out on port 22."
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
|
OLLAMA_URL = os.getenv("OLLAMA_URL", "http://localhost:11434").rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
def ask(prompt: str) -> str:
|
def ask(prompt: str) -> str:
|
||||||
payload = {
|
payload = {
|
||||||
|
|
@ -10,7 +13,7 @@ def ask(prompt: str) -> str:
|
||||||
"stream": False,
|
"stream": False,
|
||||||
}
|
}
|
||||||
req = urllib.request.Request(
|
req = urllib.request.Request(
|
||||||
"http://localhost:11434/api/chat",
|
f"{OLLAMA_URL}/api/chat",
|
||||||
data=json.dumps(payload).encode("utf-8"),
|
data=json.dumps(payload).encode("utf-8"),
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
method="POST",
|
method="POST",
|
||||||
|
|
|
||||||
47
start-aider.sh
Executable file
47
start-aider.sh
Executable file
|
|
@ -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"$@"
|
||||||
|
|
@ -4,6 +4,7 @@ set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
STATE_FILE="$SCRIPT_DIR/codex_context.yaml"
|
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'
|
MEMORY_POLICY_PROMPT=$(cat <<'EOF'
|
||||||
You are an autonomous coding agent with persistent memory.
|
You are an autonomous coding agent with persistent memory.
|
||||||
|
|
||||||
|
|
@ -76,6 +77,7 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
build_prompt() {
|
build_prompt() {
|
||||||
|
printf '%s\n\n' "$INITIAL_INSTRUCTION"
|
||||||
printf '%s\n\n' "$MEMORY_POLICY_PROMPT"
|
printf '%s\n\n' "$MEMORY_POLICY_PROMPT"
|
||||||
|
|
||||||
if [[ -f "$STATE_FILE" ]]; then
|
if [[ -f "$STATE_FILE" ]]; then
|
||||||
|
|
@ -114,6 +116,8 @@ main() {
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
printf 'Loading %s\n' "$STATE_FILE"
|
||||||
exec codex --cd "$SCRIPT_DIR" "${codex_args[@]}" "$prompt"
|
exec codex --cd "$SCRIPT_DIR" "${codex_args[@]}" "$prompt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
8
update-context.md
Normal file
8
update-context.md
Normal file
|
|
@ -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`.
|
||||||
Loading…
Reference in a new issue