From 3585924e81695271ea127e6539f1410142d848bf Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Sat, 31 Oct 2026 19:51:36 -0400 Subject: [PATCH] Use the shared semantic version tool --- .agents | 1 + .circleci/config.yml | 5 ++ .circleci/init-agent-skills.sh | 28 +++++++++ .claude/settings.json | 14 +++++ .claude/skills | 1 + .github/workflows/agents.yml | 74 ++++++++++++++++++++++++ .gitmodules | 3 + AGENTS.md | 1 + AGENTS.project.md | 34 +++++++++++ CLAUDE.md | 1 + build.gradle | 21 ++++--- version.sh | 101 --------------------------------- 12 files changed, 174 insertions(+), 110 deletions(-) create mode 160000 .agents create mode 100644 .circleci/init-agent-skills.sh create mode 100644 .claude/settings.json create mode 120000 .claude/skills create mode 100644 .github/workflows/agents.yml create mode 100644 .gitmodules create mode 120000 AGENTS.md create mode 100644 AGENTS.project.md create mode 120000 CLAUDE.md delete mode 100755 version.sh diff --git a/.agents b/.agents new file mode 160000 index 0000000..60986ed --- /dev/null +++ b/.agents @@ -0,0 +1 @@ +Subproject commit 60986ed0018283a8978f2567e4babad1036fb0c7 diff --git a/.circleci/config.yml b/.circleci/config.yml index e66196c..5d3fd7d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,6 +10,11 @@ jobs: steps: - checkout: path: ~/$CIRCLE_PROJECT_REPONAME + - run: + name: Initialize shared build tools + command: | + cd ~/$CIRCLE_PROJECT_REPONAME + bash .circleci/init-agent-skills.sh - run: name: Build and Upload context: bintray-creds diff --git a/.circleci/init-agent-skills.sh b/.circleci/init-agent-skills.sh new file mode 100644 index 0000000..d7b0a79 --- /dev/null +++ b/.circleci/init-agent-skills.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Check out the pinned private build tools with the existing checkout identity +# or an optional read-only identity. Remove temporary key material on every exit. +set +x +set -euo pipefail +cd "$(dirname "$0")/.." + +if [ -n "${CINCHAPI_AGENT_SKILLS_READ_KEY:-}" ]; then + umask 077 + key_file=$(mktemp) + trap 'rm -f "$key_file"' EXIT + printf '%s\n' "$CINCHAPI_AGENT_SKILLS_READ_KEY" > "$key_file" + if GIT_SSH_COMMAND="ssh -i '$key_file' -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" \ + git submodule update --init .agents; then + : + else + printf '%s\n' 'The configured read key cannot fetch the pinned agent tools.' >&2 + exit 1 + fi +else + if git submodule update --init .agents; then + : + else + printf '%s\n' 'The checkout identity needs read access to cinchapi-agent-skills.' \ + 'Set CINCHAPI_AGENT_SKILLS_READ_KEY to a dedicated read-only key if needed.' >&2 + exit 1 + fi +fi diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..ee40286 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,14 @@ +{ + "hooks" : { + "SessionStart" : [ + { + "hooks" : [ + { + "command" : "[ -e .agents/.git ] || { git submodule update --init .agents >&2 && cat .agents/instructions/AGENTS.md; }", + "type" : "command" + } + ] + } + ] + } +} diff --git a/.claude/skills b/.claude/skills new file mode 120000 index 0000000..2b7a412 --- /dev/null +++ b/.claude/skills @@ -0,0 +1 @@ +../.agents/skills \ No newline at end of file diff --git a/.github/workflows/agents.yml b/.github/workflows/agents.yml new file mode 100644 index 0000000..8f8e6a3 --- /dev/null +++ b/.github/workflows/agents.yml @@ -0,0 +1,74 @@ +# Written by .agents/setup.sh, which rewrites it on every skills pull. +# Change the shared workflows in cinchapi/cinchapi-agent-skills instead. Keep +# the name, because the CodeBuild runners start only for a workflow whose name +# begins with "Agent ". +name: Agent skills + +on: + pull_request: + types: [opened, reopened, ready_for_review, labeled, synchronize] + pull_request_review: + types: [submitted] + issues: + types: [labeled] + issue_comment: + types: [created] + workflow_dispatch: + inputs: + skill: + description: Skill to run + type: choice + options: + - review-pipeline + - code-review + - code-comment-cleanup + - test-cleanup + - fix + - fix-conflicts + - work-on + - implement + number: + description: Pull request or issue number + type: number + required: true + args: + description: Extra instructions for the skill + type: string + required: false + +permissions: {} + +jobs: + agents: + # New commits on a pull request marked pipeline:done reach the router whoever + # pushed them, so it takes the label off. Dependabot's do not, because GitHub + # gives Dependabot's runs no Actions secrets, so the router could not act. + if: >- + (github.event_name == 'pull_request' && github.event.action == 'synchronize' && + github.actor != 'dependabot[bot]' && + github.event.pull_request.head.repo.full_name == github.repository && + contains(github.event.pull_request.labels.*.name, 'pipeline:done')) || + (github.event.sender.type != 'Bot' && + (github.event_name == 'workflow_dispatch' || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository && + ((github.event.action == 'labeled' && + startsWith(github.event.label.name, 'agent:')) || + (github.event.action != 'labeled' && !github.event.pull_request.draft))) || + (github.event_name == 'pull_request_review' && + github.event.pull_request.head.repo.full_name == github.repository && + (github.event.review.state == 'changes_requested' || + github.event.review.user.login == github.event.pull_request.user.login)) || + (github.event_name == 'issues' && + startsWith(github.event.label.name, 'agent:')) || + (github.event_name == 'issue_comment' && + (startsWith(github.event.comment.body, '/agent') || + startsWith(github.event.comment.body, '/approve'))))) + concurrency: + group: agents-${{ github.event.pull_request.number || github.event.issue.number || github.event.inputs.number }} + queue: max + uses: cinchapi/cinchapi-agent-skills/.github/workflows/router.yml@60986ed0018283a8978f2567e4babad1036fb0c7 + permissions: + contents: read + id-token: write + secrets: inherit diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3276f4a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".agents"] + path = .agents + url = git@github.com:cinchapi/cinchapi-agent-skills.git diff --git a/AGENTS.md b/AGENTS.md new file mode 120000 index 0000000..c5293dc --- /dev/null +++ b/AGENTS.md @@ -0,0 +1 @@ +.agents/instructions/AGENTS.md \ No newline at end of file diff --git a/AGENTS.project.md b/AGENTS.project.md new file mode 100644 index 0000000..e28765f --- /dev/null +++ b/AGENTS.project.md @@ -0,0 +1,34 @@ +# Project instructions + +Instructions specific to this repo. The shared instructions in `AGENTS.md` apply +first. Rules here add to them and win on conflict. + +Keep this file to what an agent cannot learn from the shared guides or from the +code: how to build and test here, facts that differ by repo, where the project's +own docs live, and any shared rule this repo overrides. + +## Build and quality gates + +The commands to build, compile, format, lint, and type check, how to run one +test class or file, and which of them must pass before delivery. The full test +suite runs in CI, not on a developer's machine; name a fast test tier here only +when it is a delivery gate. + +## Repo layout + +The modules or packages and what each one holds. + +## Facts that differ by repo + +The language and runtime version, the package manager, the framework and the +test runner, the formatter's width, the integration branch, the test base class, +the label set, and anything else the shared guides say to resolve per repo. + +## Where to look + +The project docs to read before working in a subsystem, and when to read each +one. + +## Overrides + +Shared rules this repo relaxes or tightens, and why. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 120000 index 0000000..47dc3e3 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +AGENTS.md \ No newline at end of file diff --git a/build.gradle b/build.gradle index fa23988..ceb6da7 100644 --- a/build.gradle +++ b/build.gradle @@ -39,11 +39,19 @@ publishing { } } -// The project version is controlled externally by the "version.sh" script. -def getVersion = { -> +/** + * Create one semantic build version, or convert a supplied build version for + * publication without changing its counter. Fail when the shared tool fails. + */ +def getVersion = { String buildVersion = null -> def stdout = new ByteArrayOutputStream() + def arguments = ['bash', rootProject.file('.agents/tools/version').path, + '--root', rootProject.projectDir.path] + if (buildVersion != null) { + arguments += ['--published', buildVersion] + } exec { - commandLine 'bash', 'version.sh' + commandLine arguments standardOutput = stdout } return stdout.toString().trim() @@ -51,12 +59,7 @@ def getVersion = { -> group = 'com.cinchapi' version = getVersion() -// Drop the build component from version number and use that for -// publishing -ext.mavenVersion = version.split('\\.') -ext.mavenVersion[3] = ext.mavenVersion[3].replaceAll("[0-9]+-", "-") -ext.mavenVersion[3] = ext.mavenVersion[3].replaceAll("[0-9]+", "").trim() -ext.mavenVersion = ext.mavenVersion.join(".").replace(".-", "-").replaceAll('\\.$', "") +ext.mavenVersion = getVersion(version.toString()) repositories { mavenCentral() diff --git a/version.sh b/version.sh deleted file mode 100755 index 324626f..0000000 --- a/version.sh +++ /dev/null @@ -1,101 +0,0 @@ -# Cinchapi Inc. CONFIDENTIAL -# Copyright (c) 2016 Cinchapi Inc. All Rights Reserved. -# -# All information contained herein is, and remains the property of Cinchapi. -# The intellectual and technical concepts contained herein are proprietary to -# Cinchapi and may be covered by U.S. and Foreign Patents, patents in process, -# and are protected by trade secret or copyright law. Dissemination of this -# information or reproduction of this material is strictly forbidden unless -# prior written permission is obtained from Cinchapi. Access to the source code -# contained herein is hereby forbidden to anyone except current Cinchapi -# employees, managers or contractors who have executed Confidentiality and -# Non-disclosure agreements explicitly covering such access. -# -# The copyright notice above does not evidence any actual or intended -# publication or disclosure of this source code, which includes information -# that is confidential and/or proprietary, and is a trade secret, of Cinchapi. -# -# ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE, OR PUBLIC -# DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE EXPRESS WRITTEN -# CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE -# LAWS AND INTERNATIONAL TREATIES. THE RECEIPT OR POSSESSION OF THIS SOURCE -# CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS TO -# REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR -# SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART. - -################################################# -### Script to get or set the current version ### -################################################# - -#Ensure that this script operates from the directory in which it resides -cd "$(dirname "$0")" - -# Bootstrap Git's ability to give the branch, if necessary -git rev-parse --abbrev-ref HEAD > /dev/null 2>&1 -if [ $? -ne 0 ]; then - git commit --allow-empty -m "Bootstrapping version.sh" -fi - -BASE_VERSION_FILE=".version" -JENKINS_HOME="/opt/jenkins" -if [ -w $JENKINS_HOME ]; then - COUNTER_FILE="$JENKINS_HOME/.counter" -else - COUNTER_FILE=".counter" -fi - -if [ -z "$1" ] ; then - VERSION=`cat $BASE_VERSION_FILE` - BRANCH=`git rev-parse --abbrev-ref HEAD` - COMMIT=`git rev-parse HEAD | cut -c1-10` - - # Get counter value - if [ ! -f $COUNTER_FILE ] ; then - echo 0 > $COUNTER_FILE - fi - if [ -z ${CONTAINER_BUILD+x} ]; then - COUNTER=`cat $COUNTER_FILE` - ((COUNTER++)) - else - # If the build is run in a container, the COUNTER_FILE will be wiped - # away on each build, so we'll use the current unix timestamp for the - # counter. - COUNTER=`date +%s` - fi - echo $COUNTER > $COUNTER_FILE - VERSION=$VERSION.$COUNTER - case $BRANCH in - develop ) - EXTRA="-SNAPSHOT" - ;; - feature* ) - IFS='/' - PARTS=( $BRANCH ) - EXTRA="-${PARTS[1]}" - EXTRA=`echo $EXTRA | tr '[:lower:]' '[:upper:]'` - ;; - release* ) - EXTRA="" - ;; - * ) - # At this point we do not need to refer - # to any commit hash since we'll have a - # tag that represents the overall release - EXTRA="" - ;; - esac - echo $VERSION$EXTRA -else - NEW_VERSION=$1 - if [[ $NEW_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then - echo $NEW_VERSION > $BASE_VERSION_FILE - rm $COUNTER_FILE 2>/dev/null - sed -i '' -E "s/[0-9]+\.[0-9]+\.[0-9]+/$NEW_VERSION/g" README.md - - echo "The version has been set to $NEW_VERSION" - else - echo "Please specify a valid version .." - exit 1 - fi -fi -exit 0