From edf5df3aefd7d3b5aef903ebf218cf9631f638ba Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 14:05:49 +0000 Subject: [PATCH 01/11] Add Dockerfile and gemini-sandbox script for agentic development --- GEMINI.md | 63 +++++++++++++++++++++++++++++++++++++++ MODULE.bazel.lock | 10 ++++--- agents/Dockerfile | 61 +++++++++++++++++++++++++++++++++++++ scripts/gemini-sandbox.sh | 31 +++++++++++++++++++ 4 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 GEMINI.md create mode 100644 agents/Dockerfile create mode 100755 scripts/gemini-sandbox.sh diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 00000000..9365a92b --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,63 @@ +# Project Overview + +**value_types** is a C++ header-only library that provides two class templates: +`xyz::indirect` and `xyz::polymorphic`. These templates are designed for member +data in composite types to act as value types, managing object ownership and +significantly reducing the boilerplate required for special member functions. + +Both `std::indirect` and `std::polymorphic` have been accepted into the C++ +draft standard for C++26. This repository provides implementations for C++20 and +also C++14 (`indirect_cxx14.h` and `polymorphic_cxx14.h`). + +## Main Technologies + +- **Language**: C++ (C++14 and C++20) +- **Build Systems**: CMake and Bazel +- **Tools**: `uv` (for Python virtual environments), `pre-commit`, + `clang-format` (v17), GitHub Actions for CI. + +## Building and Testing + +### Using CMake + +To build and test using CMake, you can utilize the provided presets: + +```bash +mkdir build # Make a build directory +cmake --list-presets # View the available presets +cmake --preset # Generate build system specified in build directory with cmake +cmake --build --preset # Build the underlying build system via CMake +ctest --preset # Run the tests +``` + +### Using Bazel + +To build and test using Bazel: + +```bash +bazel build //... # Build the project +bazel test //... # Run the tests +``` + +## Development Conventions + +- **Ambiguity**: If any instructions are unclear or ambiguous, then you must ask + the user to clarify before executing any actions. + +- **Build Systems Synchronization**: Both CMake and Bazel are used as primary + build systems. Whenever adding new targets or files, they must be manually + added to both `CMakeLists.txt` and `BUILD.bazel`. + +- **Git Hooks**: The repository uses `pre-commit` managed via the `uv` tool to + run git hooks prior to commits. Install it using: + + ```bash + uv run pre-commit install + ``` + +- **Code Formatting**: Code is formatted using `clang-format` (v17). This is + enforced by GitHub actions and `pre-commit` hooks. + +- **Testing**: All changes must have test coverage, ensured by GitHub actions. + Ensure that any code changes are accompanied by corresponding tests. Tests and + pre-commit checks must pass after any change. diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 9e01516c..ff574efe 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -32,8 +32,9 @@ "https://bcr.bazel.build/modules/bazel_features/1.30.0/MODULE.bazel": "a14b62d05969a293b80257e72e597c2da7f717e1e69fa8b339703ed6731bec87", "https://bcr.bazel.build/modules/bazel_features/1.33.0/MODULE.bazel": "8b8dc9d2a4c88609409c3191165bccec0e4cb044cd7a72ccbe826583303459f6", "https://bcr.bazel.build/modules/bazel_features/1.36.0/MODULE.bazel": "596cb62090b039caf1cad1d52a8bc35cf188ca9a4e279a828005e7ee49a1bec3", - "https://bcr.bazel.build/modules/bazel_features/1.36.0/source.json": "279625cafa5b63cc0a8ee8448d93bc5ac1431f6000c50414051173fd22a6df3c", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", + "https://bcr.bazel.build/modules/bazel_features/1.42.1/MODULE.bazel": "275a59b5406ff18c01739860aa70ad7ccb3cfb474579411decca11c93b951080", + "https://bcr.bazel.build/modules/bazel_features/1.42.1/source.json": "fcd4396b2df85f64f2b3bb436ad870793ecf39180f1d796f913cc9276d355309", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", "https://bcr.bazel.build/modules/bazel_skylib/1.2.0/MODULE.bazel": "44fe84260e454ed94ad326352a698422dbe372b21a1ac9f3eab76eb531223686", @@ -48,8 +49,8 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.8.1/MODULE.bazel": "88ade7293becda963e0e3ea33e7d54d3425127e0a326e0d17da085a5f1f03ff6", "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67", "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/source.json": "34a3c8bcf233b835eb74be9d628899bb32999d3e0eadef1947a0a562a2b16ffb", - "https://bcr.bazel.build/modules/buildozer/8.2.1/MODULE.bazel": "61e9433c574c2bd9519cad7fa66b9c1d2b8e8d5f3ae5d6528a2c2d26e68d874d", - "https://bcr.bazel.build/modules/buildozer/8.2.1/source.json": "7c33f6a26ee0216f85544b4bca5e9044579e0219b6898dd653f5fb449cf2e484", + "https://bcr.bazel.build/modules/buildozer/8.5.1/MODULE.bazel": "a35d9561b3fc5b18797c330793e99e3b834a473d5fbd3d7d7634aafc9bdb6f8f", + "https://bcr.bazel.build/modules/buildozer/8.5.1/source.json": "e3386e6ff4529f2442800dee47ad28d3e6487f36a1f75ae39ae56c70f0cd2fbd", "https://bcr.bazel.build/modules/google_benchmark/1.9.4/MODULE.bazel": "3bab7c17c10580f87b647478a72a05621f88abc275afb97b578c828f56e59d45", "https://bcr.bazel.build/modules/google_benchmark/1.9.4/source.json": "8e0036f76a5c2aa9c16ca0da57d8065cff69edeed58f1f85584c588c0ef723a5", "https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075", @@ -104,7 +105,8 @@ "https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c", "https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37", "https://bcr.bazel.build/modules/rules_cc/0.2.14/MODULE.bazel": "353c99ed148887ee89c54a17d4100ae7e7e436593d104b668476019023b58df8", - "https://bcr.bazel.build/modules/rules_cc/0.2.14/source.json": "55d0a4587c5592fad350f6e698530f4faf0e7dd15e69d43f8d87e220c78bea54", + "https://bcr.bazel.build/modules/rules_cc/0.2.17/MODULE.bazel": "1849602c86cb60da8613d2de887f9566a6d354a6df6d7009f9d04a14402f9a84", + "https://bcr.bazel.build/modules/rules_cc/0.2.17/source.json": "3832f45d145354049137c0090df04629d9c2b5493dc5c2bf46f1834040133a07", "https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642", "https://bcr.bazel.build/modules/rules_cc/0.2.9/MODULE.bazel": "34263f1dca62ea664265438cef714d7db124c03e1ed55ebb4f1dc860164308d1", "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", diff --git a/agents/Dockerfile b/agents/Dockerfile new file mode 100644 index 00000000..01baf42a --- /dev/null +++ b/agents/Dockerfile @@ -0,0 +1,61 @@ +FROM python:3.12-slim + +# Install gcc, clang and some supporting tools for downloading/installing later tools. +RUN apt-get update && apt-get install -y --no-install-recommends \ + cmake \ + curl \ + g++ \ + git \ + gpg \ + lcov \ + llvm \ + ninja-build \ + python-is-python3 \ + python3-pip \ + ssh \ + unzip \ + wget \ +&& rm -rf /var/lib/apt/lists/* + +# Install bazel. +RUN wget https://github.com/bazelbuild/bazel/releases/download/9.0.1/bazel-9.0.1-installer-linux-x86_64.sh \ + && bash bazel-9.0.1-installer-linux-x86_64.sh && rm bazel-9.0.1-installer-linux-x86_64.sh; + + +# Create non-root user +RUN useradd -m -s /bin/bash vscode \ + && mkdir -p /workspace \ + && chown vscode:vscode /workspace \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /workspace + +# Switch to non-root user +USER vscode + +# Set up uv and Python environment +RUN curl -LsSf https://astral.sh/uv/install.sh | sh + +# Set up environment variables +ENV PATH="/home/vscode/.local/bin:${PATH}" +ENV UV_PROJECT_ENVIRONMENT="/home/vscode/.venv" +ENV TERM="xterm-256color" +ENV COLORTERM="truecolor" + +# Switch back to root to install Node.js and Gemini CLI +USER root + +# Install Node.js (required for Gemini CLI) +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get install -y --no-install-recommends nodejs + +# Install Gemini CLI globally +RUN npm install -g @google/gemini-cli + +# Switch back to non-root user +USER vscode + +# Pre-configure Gemini CLI +RUN mkdir -p /home/vscode/.gemini \ + && echo '{"/workspace": "TRUST_FOLDER"}' > /home/vscode/.gemini/trustedFolders.json \ + && echo '{"security": {"auth": {"selectedType": "gemini-api-key"}}}' > /home/vscode/.gemini/settings.json diff --git a/scripts/gemini-sandbox.sh b/scripts/gemini-sandbox.sh new file mode 100755 index 00000000..bed8b19f --- /dev/null +++ b/scripts/gemini-sandbox.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Exit on error +set -euo pipefail + +# Check if GEMINI_API_KEY is set +if [ -z "$GEMINI_API_KEY" ]; then + echo "Error: GEMINI_API_KEY environment variable is not set." + echo "Please set it before running this script:" + echo " export GEMINI_API_KEY='your_api_key_here'" + exit 1 +fi + +IMAGE_NAME="value-types-sandbox" +DOCKERFILE="agents/Dockerfile" + +# Build the image +echo "--- Building Docker Sandbox: $IMAGE_NAME ---" +docker build -t "$IMAGE_NAME" -f "$DOCKERFILE" . + +# Run the container +echo "--- Starting Sandboxed Gemini Session ---" +echo "Note: Your current directory $(pwd) is mounted to /workspace" + +docker run -it --rm \ + -v "$(pwd):/workspace" \ + -e GEMINI_API_KEY="$GEMINI_API_KEY" \ + "$IMAGE_NAME" \ + gemini + # -e TERM=xterm-256color \ + # -e COLORTERM=truecolor \ From 99ca87870959907b0c06790a23ede2472eaca286 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 16:23:02 +0000 Subject: [PATCH 02/11] Consolidate Dockerfiles --- .devcontainer/Dockerfile | 36 ------------------------------- .devcontainer/devcontainer.json | 7 +++--- {agents => docker}/Dockerfile | 38 +++++++++++++++------------------ scripts/gemini-sandbox.sh | 2 +- 4 files changed, 22 insertions(+), 61 deletions(-) delete mode 100644 .devcontainer/Dockerfile rename {agents => docker}/Dockerfile (69%) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 8d1c5c29..00000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -# Dockerfile for Ubuntu 24.04 with C++ development tools. - -# Set the base image. -FROM ubuntu:24.04 - -# Install gcc, clang and some supporting tools for downloading/installing later tools. -RUN apt-get update && apt-get install -y --no-install-recommends \ - g++ \ - git \ - gpg \ - lcov \ - llvm \ - ninja-build \ - python-is-python3 \ - python3-pip \ - software-properties-common \ - ssh \ - unzip\ - wget \ -&& rm -rf /var/lib/apt/lists/* - -# Install uv -RUN curl -LsSf https://astral.sh/uv/install.sh | sh - -# Install newer CMake from kitware. -RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null \ -&& apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ noble main' \ -&& apt-get update && apt-get install -y --no-install-recommends cmake \ -&& rm -rf /var/lib/apt/lists/* - -# Install bazel. -RUN wget https://github.com/bazelbuild/bazel/releases/download/7.3.1/bazel-7.3.1-installer-linux-x86_64.sh \ -&& bash bazel-7.3.1-installer-linux-x86_64.sh && rm bazel-7.3.1-installer-linux-x86_64.sh \ -&& rm -rf /var/lib/apt/lists/* - -ENV PATH="/usr/local/bin:$PATH" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bf1d94a5..3ceb9cd8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,10 @@ { "name": "xyz.value-types", "build": { - "dockerfile": "Dockerfile" + "dockerfile": "../docker/Dockerfile" }, + "remoteUser": "vscode", "mounts": [ - "type=bind,source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/root/.ssh,readonly" - ] + "type=bind,source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,readonly" + ] } diff --git a/agents/Dockerfile b/docker/Dockerfile similarity index 69% rename from agents/Dockerfile rename to docker/Dockerfile index 01baf42a..58efee73 100644 --- a/agents/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,5 @@ -FROM python:3.12-slim +# Dockerfile for Ubuntu 24.04 with C++ development tools. +FROM ubuntu:24.04 # Install gcc, clang and some supporting tools for downloading/installing later tools. RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -12,49 +13,44 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ninja-build \ python-is-python3 \ python3-pip \ + python3-venv \ + software-properties-common \ ssh \ unzip \ wget \ && rm -rf /var/lib/apt/lists/* -# Install bazel. -RUN wget https://github.com/bazelbuild/bazel/releases/download/9.0.1/bazel-9.0.1-installer-linux-x86_64.sh \ - && bash bazel-9.0.1-installer-linux-x86_64.sh && rm bazel-9.0.1-installer-linux-x86_64.sh; - +# Install bazelisk. +RUN wget https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 -O /usr/local/bin/bazelisk \ + && chmod +x /usr/local/bin/bazelisk \ + && ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel # Create non-root user RUN useradd -m -s /bin/bash vscode \ && mkdir -p /workspace \ - && chown vscode:vscode /workspace \ + && chown vscode:vscode /workspace + +# Install Node.js (required for Gemini CLI) +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get install -y --no-install-recommends nodejs \ && rm -rf /var/lib/apt/lists/* -WORKDIR /workspace +# Install Gemini CLI globally +RUN npm install -g @google/gemini-cli # Switch to non-root user USER vscode +WORKDIR /workspace # Set up uv and Python environment RUN curl -LsSf https://astral.sh/uv/install.sh | sh # Set up environment variables -ENV PATH="/home/vscode/.local/bin:${PATH}" +ENV PATH="/home/vscode/.local/bin:/usr/local/bin:${PATH}" ENV UV_PROJECT_ENVIRONMENT="/home/vscode/.venv" ENV TERM="xterm-256color" ENV COLORTERM="truecolor" -# Switch back to root to install Node.js and Gemini CLI -USER root - -# Install Node.js (required for Gemini CLI) -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ - && apt-get install -y --no-install-recommends nodejs - -# Install Gemini CLI globally -RUN npm install -g @google/gemini-cli - -# Switch back to non-root user -USER vscode - # Pre-configure Gemini CLI RUN mkdir -p /home/vscode/.gemini \ && echo '{"/workspace": "TRUST_FOLDER"}' > /home/vscode/.gemini/trustedFolders.json \ diff --git a/scripts/gemini-sandbox.sh b/scripts/gemini-sandbox.sh index bed8b19f..e2ce2f78 100755 --- a/scripts/gemini-sandbox.sh +++ b/scripts/gemini-sandbox.sh @@ -12,7 +12,7 @@ if [ -z "$GEMINI_API_KEY" ]; then fi IMAGE_NAME="value-types-sandbox" -DOCKERFILE="agents/Dockerfile" +DOCKERFILE="docker/Dockerfile" # Build the image echo "--- Building Docker Sandbox: $IMAGE_NAME ---" From 78e5d3c176e9bf139288730bb84fa690cea929a2 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 17:56:45 +0000 Subject: [PATCH 03/11] Fix odd colours in gemini-sandbox --- docker/Dockerfile | 2 -- scripts/gemini-sandbox.sh | 2 -- 2 files changed, 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 58efee73..3d62f6a1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -48,8 +48,6 @@ RUN curl -LsSf https://astral.sh/uv/install.sh | sh # Set up environment variables ENV PATH="/home/vscode/.local/bin:/usr/local/bin:${PATH}" ENV UV_PROJECT_ENVIRONMENT="/home/vscode/.venv" -ENV TERM="xterm-256color" -ENV COLORTERM="truecolor" # Pre-configure Gemini CLI RUN mkdir -p /home/vscode/.gemini \ diff --git a/scripts/gemini-sandbox.sh b/scripts/gemini-sandbox.sh index e2ce2f78..fd420db2 100755 --- a/scripts/gemini-sandbox.sh +++ b/scripts/gemini-sandbox.sh @@ -27,5 +27,3 @@ docker run -it --rm \ -e GEMINI_API_KEY="$GEMINI_API_KEY" \ "$IMAGE_NAME" \ gemini - # -e TERM=xterm-256color \ - # -e COLORTERM=truecolor \ From 2011e616d38c67e41062e6ed2aafa5e64c74d4b1 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 18:01:41 +0000 Subject: [PATCH 04/11] Fix odd colours in gemini-sandbox v2 --- docker/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 3d62f6a1..fa8205aa 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -48,6 +48,8 @@ RUN curl -LsSf https://astral.sh/uv/install.sh | sh # Set up environment variables ENV PATH="/home/vscode/.local/bin:/usr/local/bin:${PATH}" ENV UV_PROJECT_ENVIRONMENT="/home/vscode/.venv" +ENV TERM=xterm-256color +ENV COLORTERM=truecolor # Pre-configure Gemini CLI RUN mkdir -p /home/vscode/.gemini \ From 98a067d07d89f77ea6841a0b57b46980525e2cd6 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 18:16:00 +0000 Subject: [PATCH 05/11] Tweak GEMINI.md --- GEMINI.md | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/GEMINI.md b/GEMINI.md index 9365a92b..5e482468 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -18,16 +18,16 @@ also C++14 (`indirect_cxx14.h` and `polymorphic_cxx14.h`). ## Building and Testing +Tests can be built and run using either CMake or Bazel. Both build systems are +kept in sync manually, so any new targets or files must be added to both +`CMakeLists.txt` and `BUILD.bazel`. + ### Using CMake -To build and test using CMake, you can utilize the provided presets: +To build and test using CMake: ```bash -mkdir build # Make a build directory -cmake --list-presets # View the available presets -cmake --preset # Generate build system specified in build directory with cmake -cmake --build --preset # Build the underlying build system via CMake -ctest --preset # Run the tests +./scripts/cmake.sh ``` ### Using Bazel @@ -35,8 +35,7 @@ ctest --preset # Run the tests To build and test using Bazel: ```bash -bazel build //... # Build the project -bazel test //... # Run the tests +./scripts/bazel.sh ``` ## Development Conventions @@ -44,6 +43,13 @@ bazel test //... # Run the tests - **Ambiguity**: If any instructions are unclear or ambiguous, then you must ask the user to clarify before executing any actions. +- **Git Usage**: Never commit code or add files using git unless very explicitly + asked to do so by the user. + +- **Consistency and Minimization**: Unless otherwise instructed, all changes + should be consistent with the existing code style and architectural patterns. + Minimize changes to only what is necessary to fulfill the request. + - **Build Systems Synchronization**: Both CMake and Bazel are used as primary build systems. Whenever adding new targets or files, they must be manually added to both `CMakeLists.txt` and `BUILD.bazel`. @@ -59,5 +65,6 @@ bazel test //... # Run the tests enforced by GitHub actions and `pre-commit` hooks. - **Testing**: All changes must have test coverage, ensured by GitHub actions. - Ensure that any code changes are accompanied by corresponding tests. Tests and - pre-commit checks must pass after any change. + Ensure that any code changes are accompanied by corresponding tests. Both + CMake and Bazel builds and tests must pass after any change. Pre-commit checks + must also pass. From 9f1053f9fe644b93b1ad8934e4652b7402b5c239 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 18:28:20 +0000 Subject: [PATCH 06/11] Fix odd colours in gemini-sandbox v3 --- docker/Dockerfile | 2 -- scripts/gemini-sandbox.sh | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index fa8205aa..3d62f6a1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -48,8 +48,6 @@ RUN curl -LsSf https://astral.sh/uv/install.sh | sh # Set up environment variables ENV PATH="/home/vscode/.local/bin:/usr/local/bin:${PATH}" ENV UV_PROJECT_ENVIRONMENT="/home/vscode/.venv" -ENV TERM=xterm-256color -ENV COLORTERM=truecolor # Pre-configure Gemini CLI RUN mkdir -p /home/vscode/.gemini \ diff --git a/scripts/gemini-sandbox.sh b/scripts/gemini-sandbox.sh index fd420db2..85878b10 100755 --- a/scripts/gemini-sandbox.sh +++ b/scripts/gemini-sandbox.sh @@ -25,5 +25,7 @@ echo "Note: Your current directory $(pwd) is mounted to /workspace" docker run -it --rm \ -v "$(pwd):/workspace" \ -e GEMINI_API_KEY="$GEMINI_API_KEY" \ + -e TERM=$TERM \ + -e COLORTERM=$COLORTERM \ "$IMAGE_NAME" \ gemini From 68fce3fdf994dce46c1f789c3931d0679d71ece9 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 18:32:17 +0000 Subject: [PATCH 07/11] Fix odd colours in gemini-sandbox v4 --- scripts/gemini-sandbox.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/gemini-sandbox.sh b/scripts/gemini-sandbox.sh index 85878b10..955c04c5 100755 --- a/scripts/gemini-sandbox.sh +++ b/scripts/gemini-sandbox.sh @@ -25,7 +25,7 @@ echo "Note: Your current directory $(pwd) is mounted to /workspace" docker run -it --rm \ -v "$(pwd):/workspace" \ -e GEMINI_API_KEY="$GEMINI_API_KEY" \ - -e TERM=$TERM \ - -e COLORTERM=$COLORTERM \ + -e TERM=${TERM:-} \ + -e COLORTERM=${COLORTERM:-} \ "$IMAGE_NAME" \ gemini From 5ad199b17700ac4c03ce5037acfa1f593150aceb Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 18:47:32 +0000 Subject: [PATCH 08/11] Clean up documentation and minimise GEMINI.md --- CONTRIBUTING.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ DEVELOPMENT.md | 69 --------------------------------------- GEMINI.md | 70 ++++++---------------------------------- README.md | 4 +-- 4 files changed, 97 insertions(+), 132 deletions(-) create mode 100644 CONTRIBUTING.md delete mode 100644 DEVELOPMENT.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..8d4b0e5b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,86 @@ +# Contributing Guide + +## Main Technologies + +- **Language**: C++ (C++14 and C++20) +- **Build Systems**: CMake and Bazel +- **Tools**: `uv` (for Python virtual environments), `pre-commit`, + `clang-format` (v17), GitHub Actions for CI. + +## Using pre-commit for git hooks + +This repository uses the Python `pre-commit` library to manage git hooks run as +part of the commit process. + +Install the `uv` tool if you don't have it already: +. + +Install pre-commit as a pre-commit hook: + +```bash +uv run pre-commit install +``` + +## Building and testing + +Tests can be built and run using either CMake or Bazel. Both build systems are +kept in sync manually. + +### Building with CMake + +To build and test using CMake via the provided script: + +```bash +./scripts/cmake.sh +``` + +Or manually: + +```bash +mkdir build +cmake --list-presets +cmake --preset +cmake --build --preset +ctest --preset +``` + +### Building with Bazel + +To build and test using Bazel via the provided script: + +```bash +./scripts/bazel.sh +``` + +Or manually: + +```bash +bazel build //... +bazel test //... +``` + +## Including value_types in your own project + +To use the value types code in your own CMake project, use `FetchContent`: + +```txt +FetchContent_Declare( + value_types + GIT_REPOSITORY https://github.com/jbcoe/value_types +) +FetchContent_MakeAvailable(value_types) + +target_link_libraries(my_program PUBLIC value_types::value_types) +``` + +## Contributing Guidelines + +- **Build Systems Synchronization**: Both CMake and Bazel are used as primary + build systems. Whenever adding new targets or files, they must be manually + added to both `CMakeLists.txt` and `BUILD.bazel`. + +- **Code Formatting**: Code is formatted using `clang-format` (v17). This is + enforced by GitHub actions and `pre-commit` hooks. + +- **Testing**: All changes must have test coverage. Both CMake and Bazel builds + and tests must pass after any change. diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md deleted file mode 100644 index 24b8e2d2..00000000 --- a/DEVELOPMENT.md +++ /dev/null @@ -1,69 +0,0 @@ -# Developer Guide - -## Using pre-commit for git hooks - -This repository uses the Python `pre-commit` library to manage git hook run as -part of the commit process. Use the following steps from the project root to -install a virtual environment with pre-commmit set up, and then use precommit to -install git hooks it to your local repository: - -Install the `uv` tool if you don't have it already: . - -Install pre-commit as a pre-commit hook: - -```bash -uv run pre-commit install # Use pre-commit to install git hooks into the working repository. -``` - -## Building and testing - -### Building with CMake - -To build the repository with CMake use the following steps from the project root: - -```bash -mkdir build # Make a build directory -cmake --list-presets # View the available presets -cmake --preset # Generate build system specified in build directory with cmake -cmake --build --preset # Build the underlying build system via CMake -ctest --preset # Run the tests -``` - -To install CMake see: . - -### Building with Bazel - -To build the repository with Bazel use the following steps from the project root: - -```bash -bazel build //... # Build the project -bazel test //... # Run the tests -``` - -To install Bazel see . - -## Including value_types to your own project - -To use the value types code in your own CMake project then you can pull -the project in as a dependency via CMake's FetchContent module as follows: - -```txt -FetchContent_Declare( - value_types - GIT_REPOSITORY https://github.com/jbcoe/value_types -) -FetchContent_MakeAvailable(value_types) - -add_executable(my_program) -target_link_libraries(my_program - PUBLIC - value_types::value_types -) -``` - -## Contributing - -We use GitHub actions to ensure that all changes have test coverage and that -source code is formatted with clang-format (v17). - -We use CMake and Bazel. New targets are manually added to both. diff --git a/GEMINI.md b/GEMINI.md index 5e482468..b3c7ce0d 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -1,70 +1,18 @@ -# Project Overview +# Agent Instructions -**value_types** is a C++ header-only library that provides two class templates: -`xyz::indirect` and `xyz::polymorphic`. These templates are designed for member -data in composite types to act as value types, managing object ownership and -significantly reducing the boilerplate required for special member functions. +This repository defines instructions for the Gemini CLI and any other AI agents that operate within this workspace. -Both `std::indirect` and `std::polymorphic` have been accepted into the C++ -draft standard for C++26. This repository provides implementations for C++20 and -also C++14 (`indirect_cxx14.h` and `polymorphic_cxx14.h`). +**Agent Action Required:** Before executing any tasks, you must read and understand the following files: -## Main Technologies - -- **Language**: C++ (C++14 and C++20) -- **Build Systems**: CMake and Bazel -- **Tools**: `uv` (for Python virtual environments), `pre-commit`, - `clang-format` (v17), GitHub Actions for CI. - -## Building and Testing - -Tests can be built and run using either CMake or Bazel. Both build systems are -kept in sync manually, so any new targets or files must be added to both -`CMakeLists.txt` and `BUILD.bazel`. - -### Using CMake - -To build and test using CMake: - -```bash -./scripts/cmake.sh -``` - -### Using Bazel - -To build and test using Bazel: - -```bash -./scripts/bazel.sh -``` +1. `README.md`: Provides the project overview and use cases. +2. `CONTRIBUTING.md`: Contains technical details, build/test instructions, and contribution guidelines. ## Development Conventions -- **Ambiguity**: If any instructions are unclear or ambiguous, then you must ask - the user to clarify before executing any actions. - -- **Git Usage**: Never commit code or add files using git unless very explicitly - asked to do so by the user. - -- **Consistency and Minimization**: Unless otherwise instructed, all changes - should be consistent with the existing code style and architectural patterns. - Minimize changes to only what is necessary to fulfill the request. - -- **Build Systems Synchronization**: Both CMake and Bazel are used as primary - build systems. Whenever adding new targets or files, they must be manually - added to both `CMakeLists.txt` and `BUILD.bazel`. - -- **Git Hooks**: The repository uses `pre-commit` managed via the `uv` tool to - run git hooks prior to commits. Install it using: +- **Ambiguity**: If any instructions are unclear or ambiguous, you must ask for clarification before executing any actions. - ```bash - uv run pre-commit install - ``` +- **Git Usage**: Never commit code or add files using git unless very explicitly asked to do so by the user. -- **Code Formatting**: Code is formatted using `clang-format` (v17). This is - enforced by GitHub actions and `pre-commit` hooks. +- **Surgical Changes**: Unless otherwise instructed, all changes should be consistent with the existing code style and architectural patterns. Minimize changes to only what is necessary to fulfill the request. -- **Testing**: All changes must have test coverage, ensured by GitHub actions. - Ensure that any code changes are accompanied by corresponding tests. Both - CMake and Bazel builds and tests must pass after any change. Pre-commit checks - must also pass. +- **Validation**: You are responsible for ensuring your changes follow the rules in `CONTRIBUTING.md`. Always verify that changes are formatted correctly and that both CMake and Bazel tests pass. diff --git a/README.md b/README.md index b871134e..02341041 100644 --- a/README.md +++ b/README.md @@ -131,9 +131,9 @@ There are some significant design changes since this talk was given (after feedb and discussion at a C++ London meetup). We've pared down the number of constructors and made the null state unobservable. -## Developer Guide +## Contributing -For building and working with the project, please see the [developer guide](DEVELOPMENT.md). +For building and working with the project, please see the [contributing guide](CONTRIBUTING.md). ## GitHub codespaces From eaaa50472506d03ab5741605b556af80fca08004 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 19:01:34 +0000 Subject: [PATCH 09/11] Add gdb to docker --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 3d62f6a1..f57a6eff 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ cmake \ curl \ g++ \ + gdb \ git \ gpg \ lcov \ From 3bcb54aa72015b2555c096bed65cbf6ca6e30a6a Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 19:50:11 +0000 Subject: [PATCH 10/11] Fix dockerfile --- docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f57a6eff..1aeb43a4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -22,7 +22,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* # Install bazelisk. -RUN wget https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 -O /usr/local/bin/bazelisk \ +RUN ARCH=$(dpkg --print-architecture) && \ + wget https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-${ARCH} -O /usr/local/bin/bazelisk \ && chmod +x /usr/local/bin/bazelisk \ && ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel From f7c9f388d9e04427dcc56caa33f9724579fef948 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Sun, 15 Mar 2026 20:05:10 +0000 Subject: [PATCH 11/11] Refer to GEMINI.md from copilot instructions --- .github/copilot-instructions.md | 206 +------------------------------- 1 file changed, 1 insertion(+), 205 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 8d2e4d44..da6314a5 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,205 +1 @@ -# Copilot Instructions for value_types - -## Repository Overview - -This repository contains C++ header-only library implementations of two class templates: `indirect` and `polymorphic`. These are designed for composite class design to provide value semantics for types that require indirect storage or polymorphic behavior. - -### Purpose -- `indirect`: Owns an object of class `T` with value semantics (useful for PIMPL idiom, incomplete types) -- `polymorphic`: Owns an object of class `T` or a class derived from `T` with value semantics (useful for open-set polymorphism) - -### Standardization Status -`std::indirect` and `std::polymorphic` have been **accepted** into the C++ draft standard and should be available in C++26. The final proposal [P3019r14](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3019r14.pdf) was accepted in Plenary in Hagenburg 2025, following the initial acceptance of [P3019r11](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3019r11.pdf) in Wrocław 2024. - -This repository provides a reference implementation that influenced the standard library design. The implementation documented in `DRAFT.md` follows strict standardization requirements and serves as a basis for the standardized versions. - -#### Standard Library Documentation -- [`std::indirect`](https://en.cppreference.com/w/cpp/memory/indirect) - cppreference documentation -- [`std::polymorphic`](https://en.cppreference.com/w/cpp/memory/polymorphic) - cppreference documentation - -## Development Environment - -### Development Container -This repository includes a `.devcontainer` configuration that can and should be used for development work. The Docker container it defines sets up the build environment for both CMake and Bazel, ensuring consistent development across different systems. - -### Language and Standards -- **Primary Language**: C++ -- **Minimum Standard**: C++14 -- **Supported Standards**: C++14, C++17, C++20, C++23 -- **Style**: Follow the existing codebase style, which uses clang-format configuration - -### Build Systems -This project supports **dual build systems** - both must be maintained: - -1. **CMake** (Primary) - ```bash - cmake --preset Debug - cmake --build --preset Debug - ctest --preset Debug - ``` - -2. **Bazel** (Secondary) - ```bash - bazel build //... - bazel test //... - ``` - -### Testing Framework -- **Primary**: Google Test (gtest/gmock) -- **Coverage**: Comprehensive test suite with 400+ tests -- **Pattern**: Each feature should have corresponding tests -- **Naming**: Use descriptive test names following existing patterns - -## Code Organization - -### Core Files -- `indirect.h` / `indirect.cc` - Main indirect implementation -- `polymorphic.h` / `polymorphic.cc` - Main polymorphic implementation -- `indirect_cxx14.h` / `indirect_cxx14.cc` - C++14 compatible version -- `polymorphic_cxx14.h` / `polymorphic_cxx14.cc` - C++14 compatible version -- `polymorphic_no_vtable.h` / `polymorphic_no_vtable.cc` - Alternative implementation - -### Test Files -- `indirect_test.cc` - Tests for all indirect implementations -- `polymorphic_test.cc` - Tests for all polymorphic implementations - -### Support Files -- `feature_check.h` - Feature detection macros -- `test_helpers.h` - Common test utilities -- `tagged_allocator.h` / `tracking_allocator.h` - Custom allocators for testing - -## Coding Conventions - -### Header Guards and Includes -- Use traditional `#ifndef`/`#define` header guards following existing patterns (e.g., `#ifndef XYZ_INDIRECT_H`) -- Include system headers first, then project headers -- Use forward declarations when possible - -### Naming Conventions -- **Classes/Types**: `snake_case` (e.g., `indirect`, `polymorphic`) -- **Functions/Methods**: `snake_case` (e.g., `has_value`, `value_or`) -- **Template Parameters**: `PascalCase` (e.g., `T`, `Allocator`) -- **Namespaces**: Use `xyz` namespace for library code - -### Code Style -- Follow the `.clang-format` configuration -- Use `const` and `constexpr` where appropriate -- Prefer RAII and value semantics -- Use standard library features when available -- Write exception-safe code - -### Template and Generic Programming -- Use SFINAE and concepts for template constraints -- Provide clear error messages for template instantiation failures -- Support custom allocators following standard library patterns -- Use tag dispatching for constructor overload resolution - -## Standard Library Compatibility - -### Allocator Support -- Both `indirect` and `polymorphic` support custom allocators -- Follow standard allocator-aware container patterns -- Use `std::allocator_traits` for allocator operations -- Support both traditional and PMR allocators - -### Special Member Functions -- Follow the Rule of Five/Zero -- Provide proper `noexcept` specifications -- Support move semantics with proper exception safety -- Implement copy/move constructors and assignment operators - -### Value Semantics -- Maintain deep copy semantics for owned objects -- Ensure const-correctness throughout -- Support comparison operators (`==`, `!=`, `<`, etc.) - -## Testing Patterns - -### Test Structure -```cpp -TEST(ClassNameTest, DescriptiveFunctionality) { - // Arrange - // Act - // Assert -} -``` - -### Common Test Categories -- **Construction**: Default, copy, move, in-place, allocator-extended -- **Assignment**: Copy, move, converting, self-assignment -- **Observers**: `has_value()`, `operator*`, `operator->` -- **Modifiers**: `swap()`, `reset()`, assignment operators -- **Comparison**: Equality, ordering, comparison with T -- **Exception Safety**: Strong exception guarantee verification -- **Allocator Integration**: Custom allocator behavior - -### Memory Management Testing -- Use `tracking_allocator` to verify allocation patterns -- Test allocator propagation in copy/move operations -- Verify no memory leaks with RAII patterns -- Test exception safety with throwing allocators - -## Implementation Guidelines - -### Error Handling -- Use exceptions for error conditions (following standard library conventions) -- Provide strong exception safety guarantee -- Use `assert` for precondition checks in debug builds -- Avoid throwing from destructors - -### Performance Considerations -- Minimize dynamic allocations -- Use move semantics to avoid unnecessary copies -- Provide `noexcept` operations where possible -- Consider cache locality in data layout - -### Platform Support -- Write portable C++ code -- Use standard library features over platform-specific code -- Test on multiple compilers (GCC, Clang, MSVC) -- Support both 32-bit and 64-bit platforms - -## Documentation - -### Code Documentation -- Use clear, descriptive names for functions and variables -- Add comments for complex algorithms or non-obvious behavior -- Document template parameters and requirements -- Include usage examples in headers - -### API Documentation -- Follow standard library documentation patterns -- Document preconditions, postconditions, and exception guarantees -- Provide complexity guarantees where relevant -- Include rationale for design decisions - -## Common Development Tasks - -### Adding New Features -1. Update both main and C++14 versions if needed -2. Add corresponding tests in the appropriate test file -3. Update both CMake and Bazel build files -4. Update documentation if API changes -5. Run full test suite and check formatting - -### Debugging Issues -- Use the compile checks in `compile_checks/` directory -- Check allocator tracking tests for memory issues -- Verify exception safety with throwing operations -- Use static_assert for compile-time validation - -## Review and Quality Assurance - -### Before Submitting Changes -- Run both CMake and Bazel builds -- Execute full test suite (should be 400+ tests passing) -- Check code formatting with clang-format -- Run clang-tidy for static analysis -- Verify no new compiler warnings -- Update documentation if needed - -### Continuous Integration -- GitHub Actions run multiple build configurations -- Tests run on different platforms and compilers -- Code coverage is tracked and should not decrease -- Pre-commit hooks enforce formatting and basic checks +Read ../GEMINI.md.