From b3ebf4a5960e0dec57ff0ecf82ad2b28679e5fc0 Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Tue, 21 Apr 2026 12:44:32 +1000 Subject: [PATCH] create codex configuration --- AGENTS.md | 69 +++++++++++++++++++++++++++++++++++++ codex/doctor.sh | 39 +++++++++++++++++++++ codex/lib.sh | 44 ++++++++++++++++++++++++ codex/maintain.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++++ codex/setup.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 324 insertions(+) create mode 100644 AGENTS.md create mode 100755 codex/doctor.sh create mode 100755 codex/lib.sh create mode 100755 codex/maintain.sh create mode 100755 codex/setup.sh diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..cff7cd6 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,69 @@ +# AGENTS.md + +## Goal +Build a Terraform provider for Dynu DNS and domains. + +## Scope for current phase +Read-only only. Implement provider configuration and data sources first. +Do not implement any writable Terraform resources in the first phase. + +## Language and framework +- Language: Go +- Terraform provider framework: HashiCorp Terraform Plugin Framework +- Do not use the legacy SDK unless explicitly requested. + +## API usage +- Use Dynu's public API. +- Prefer stable, documented endpoints. +- Build a small internal API client package rather than scattering HTTP calls across resources/data sources. +- Add clear handling for pagination, 4xx/5xx responses, and malformed responses. +- Never log secrets. + +## Provider design +Implement: +- Provider configuration +- Environment variable support for credentials +- Read-only data sources: + - dynu_domains + - dynu_domain + - dynu_dns_records + +Do not implement: +- resource_dynu_dns_record +- any create/update/delete flows +- any speculative unsupported resources + +## Safety +- Read-only phase only. +- No write HTTP methods in this phase. +- Acceptance tests must only cover provider auth and read-only data sources. +- Any future write support must be added in a separate phase. + +## Code quality +- Keep code modular and idiomatic Go. +- Use strong typing for API models. +- Prefer explicit schema definitions with clear descriptions. +- Return actionable diagnostics. +- Keep public documentation accurate to actual implementation. + +## Testing +- Add unit tests where practical. +- Add acceptance tests gated behind environment variables. +- Do not require live credentials for normal unit tests. + +## Documentation +- Add examples for every implemented data source. +- Update README with provider configuration and environment variables. +- Document limitations and unsupported areas clearly. + +## Output expectations +Create a provider skeleton that can compile and expose the provider plus read-only data sources. + +## Codex environment +- Use `codex/setup.sh` to prepare the repository-local Codex environment. +- Use `codex/maintain.sh` to refresh and validate the environment. +- Use `codex/doctor.sh` for troubleshooting. +- Do not install global packages unless explicitly required. +- Prefer repo-local state under `.codex/`. +- Do not run `docker compose up`, `down`, or `pull` unless explicitly requested. +- Safe validation via `./services-up.sh --profile all config` is allowed. diff --git a/codex/doctor.sh b/codex/doctor.sh new file mode 100755 index 0000000..ca17d58 --- /dev/null +++ b/codex/doctor.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=./lib.sh +source "$SCRIPT_DIR/lib.sh" + +cd_repo_root + +echo "=== codex doctor ===" +echo "repo: $(pwd)" +echo "time: $(date -u +%FT%TZ)" +echo + +echo "--- tools ---" +for cmd in bash git python3 docker; do + if have "$cmd"; then + echo "$cmd: $(command -v "$cmd")" + else + echo "$cmd: MISSING" + fi +done +echo + +echo "--- repo ---" +[[ -f services-up.sh ]] && echo "services-up.sh: present" || echo "services-up.sh: missing" +[[ -d core ]] && echo "core/: present" || true +[[ -d apps ]] && echo "apps/: present" || true +[[ -d monitoring ]] && echo "monitoring/: present" || true +echo + +echo "--- git status ---" +git status --short || true +echo + +if have docker && docker compose version >/dev/null 2>&1; then + echo "--- docker compose ---" + docker compose version || true +fi diff --git a/codex/lib.sh b/codex/lib.sh new file mode 100755 index 0000000..b0da6aa --- /dev/null +++ b/codex/lib.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -euo pipefail + +log() { + printf '[codex] %s\n' "$*" +} + +warn() { + printf '[codex][warn] %s\n' "$*" >&2 +} + +die() { + printf '[codex][error] %s\n' "$*" >&2 + exit 1 +} + +have() { + command -v "$1" >/dev/null 2>&1 +} + +repo_root() { + git rev-parse --show-toplevel 2>/dev/null || pwd +} + +cd_repo_root() { + cd "$(repo_root)" +} + +ensure_file() { + local path="$1" + [[ -f "$path" ]] || die "Required file not found: $path" +} + +ensure_dir() { + local path="$1" + mkdir -p "$path" +} + +append_if_missing() { + local line="$1" + local file="$2" + touch "$file" + grep -Fqx "$line" "$file" || printf '%s\n' "$line" >> "$file" +} diff --git a/codex/maintain.sh b/codex/maintain.sh new file mode 100755 index 0000000..4e41d77 --- /dev/null +++ b/codex/maintain.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=./lib.sh +source "$SCRIPT_DIR/lib.sh" + +cd_repo_root + +log "Starting Codex environment setup in $(pwd)" + +if ! have git; then + die "git is required" +fi + +if ! have bash; then + die "bash is required" +fi + +# Keep all Codex-local state inside the repo or user home. +ensure_dir .codex +ensure_dir .codex/bin +ensure_dir .codex/cache +ensure_dir .codex/tmp +ensure_dir .codex/logs + +# Useful environment defaults for repeatable non-interactive runs. +cat > .codex/env <<'EOF' +export CI=1 +export TERM=xterm-256color +export PYTHONDONTWRITEBYTECODE=1 +export PIP_DISABLE_PIP_VERSION_CHECK=1 +export PIP_NO_INPUT=1 +export GIT_PAGER=cat +EOF + +# Optional Python venv for helper tooling. +if have python3; then + log "python3 detected" + if [[ ! -d .codex/venv ]]; then + python3 -m venv .codex/venv + fi + # shellcheck disable=SC1091 + source .codex/venv/bin/activate + python -m pip install --upgrade pip setuptools wheel >/dev/null + + # Install only lightweight tooling that is broadly useful. + python -m pip install \ + pyyaml \ + requests \ + jinja2 \ + >/dev/null +else + warn "python3 not found; skipping virtualenv setup" +fi + +# Basic repo checks based on your environment style. +if [[ -f services-up.sh ]]; then + log "Found services-up.sh" + chmod +x services-up.sh || true +else + warn "services-up.sh not found at repo root" +fi + +# Make codex scripts executable. +find codex -maxdepth 1 -type f -name '*.sh' -exec chmod +x {} + + +# Create a simple local ignore file for Codex-generated junk if needed. +touch .git/info/exclude +append_if_missing ".codex/" .git/info/exclude +append_if_missing ".pytest_cache/" .git/info/exclude +append_if_missing "__pycache__/" .git/info/exclude + +# Helpful summary file for Codex tasks. +cat > .codex/README.md <<'EOF' +This directory contains local, disposable Codex environment state. + +Contents: +- env: shell exports for non-interactive work +- venv: optional Python virtual environment +- cache/: tool cache +- tmp/: temporary files +- logs/: script logs +EOF + +log "Setup complete" diff --git a/codex/setup.sh b/codex/setup.sh new file mode 100755 index 0000000..4e41d77 --- /dev/null +++ b/codex/setup.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=./lib.sh +source "$SCRIPT_DIR/lib.sh" + +cd_repo_root + +log "Starting Codex environment setup in $(pwd)" + +if ! have git; then + die "git is required" +fi + +if ! have bash; then + die "bash is required" +fi + +# Keep all Codex-local state inside the repo or user home. +ensure_dir .codex +ensure_dir .codex/bin +ensure_dir .codex/cache +ensure_dir .codex/tmp +ensure_dir .codex/logs + +# Useful environment defaults for repeatable non-interactive runs. +cat > .codex/env <<'EOF' +export CI=1 +export TERM=xterm-256color +export PYTHONDONTWRITEBYTECODE=1 +export PIP_DISABLE_PIP_VERSION_CHECK=1 +export PIP_NO_INPUT=1 +export GIT_PAGER=cat +EOF + +# Optional Python venv for helper tooling. +if have python3; then + log "python3 detected" + if [[ ! -d .codex/venv ]]; then + python3 -m venv .codex/venv + fi + # shellcheck disable=SC1091 + source .codex/venv/bin/activate + python -m pip install --upgrade pip setuptools wheel >/dev/null + + # Install only lightweight tooling that is broadly useful. + python -m pip install \ + pyyaml \ + requests \ + jinja2 \ + >/dev/null +else + warn "python3 not found; skipping virtualenv setup" +fi + +# Basic repo checks based on your environment style. +if [[ -f services-up.sh ]]; then + log "Found services-up.sh" + chmod +x services-up.sh || true +else + warn "services-up.sh not found at repo root" +fi + +# Make codex scripts executable. +find codex -maxdepth 1 -type f -name '*.sh' -exec chmod +x {} + + +# Create a simple local ignore file for Codex-generated junk if needed. +touch .git/info/exclude +append_if_missing ".codex/" .git/info/exclude +append_if_missing ".pytest_cache/" .git/info/exclude +append_if_missing "__pycache__/" .git/info/exclude + +# Helpful summary file for Codex tasks. +cat > .codex/README.md <<'EOF' +This directory contains local, disposable Codex environment state. + +Contents: +- env: shell exports for non-interactive work +- venv: optional Python virtual environment +- cache/: tool cache +- tmp/: temporary files +- logs/: script logs +EOF + +log "Setup complete"