feat: auto-update harness files when plugin version changes
setup.sh now stamps .harness-version in .loop/ at scaffold time. On each /agent-loop:run, Phase 1 compares the installed harness version against the plugin version and auto-updates lib/, prompts/, and loop.sh if stale. Run state (prd.json, contracts, config.json) is preserved. Also adds setup.sh --update mode for refreshing harness files without re-scaffolding. Bump to 0.10.0.
This commit is contained in:
44
setup.sh
44
setup.sh
@@ -10,10 +10,17 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# --- Parse arguments ---
|
||||
UPDATE_ONLY=false
|
||||
MODE="${1:-implement}"
|
||||
|
||||
if [ "$MODE" = "--update" ]; then
|
||||
UPDATE_ONLY=true
|
||||
MODE="${2:-implement}" # mode not used in update, but keep arg parsing clean
|
||||
fi
|
||||
|
||||
# --- Validate mode ---
|
||||
if [[ ! "$MODE" =~ ^(implement|explore|fix)$ ]]; then
|
||||
if [ "$UPDATE_ONLY" = false ] && [[ ! "$MODE" =~ ^(implement|explore|fix)$ ]]; then
|
||||
echo "[setup] ERROR: Invalid mode '$MODE'. Must be: implement, explore, fix"
|
||||
exit 1
|
||||
fi
|
||||
@@ -45,6 +52,37 @@ fi
|
||||
|
||||
echo "[setup] Harness source: $HARNESS_SRC"
|
||||
|
||||
# Read plugin version from source
|
||||
PLUGIN_VERSION=""
|
||||
if [ -f "$HARNESS_SRC/.claude-plugin/plugin.json" ]; then
|
||||
if command -v jq &>/dev/null; then
|
||||
PLUGIN_VERSION=$(jq -r '.version // empty' "$HARNESS_SRC/.claude-plugin/plugin.json" 2>/dev/null)
|
||||
elif command -v python3 &>/dev/null; then
|
||||
PLUGIN_VERSION=$(python3 -c "import json; print(json.load(open('$HARNESS_SRC/.claude-plugin/plugin.json')).get('version',''),end='')" 2>/dev/null)
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Update-only mode: refresh harness files without touching run state ---
|
||||
if [ "$UPDATE_ONLY" = true ]; then
|
||||
LOOP_DIR="$(pwd)/.loop"
|
||||
if [ ! -d "$LOOP_DIR" ]; then
|
||||
echo "[setup] ERROR: No .loop/ directory found. Run setup first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[setup] Updating harness files..."
|
||||
cp -r "$HARNESS_SRC/prompts" "$LOOP_DIR/"
|
||||
cp -r "$HARNESS_SRC/templates" "$LOOP_DIR/"
|
||||
cp -r "$HARNESS_SRC/lib" "$LOOP_DIR/"
|
||||
cp "$HARNESS_SRC/loop.sh" "$LOOP_DIR/"
|
||||
chmod +x "$LOOP_DIR/loop.sh"
|
||||
|
||||
[ -n "$PLUGIN_VERSION" ] && echo "$PLUGIN_VERSION" > "$LOOP_DIR/.harness-version"
|
||||
|
||||
echo "[setup] Harness updated to ${PLUGIN_VERSION:-unknown}. Run state (prd.json, contracts, config.json) unchanged."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# --- Ensure git repo exists ---
|
||||
if ! git rev-parse --git-dir &>/dev/null; then
|
||||
echo "[setup] No git repo found. Initializing..."
|
||||
@@ -79,6 +117,9 @@ cp -r "$HARNESS_SRC/lib" "$LOOP_DIR/"
|
||||
cp "$HARNESS_SRC/loop.sh" "$LOOP_DIR/"
|
||||
chmod +x "$LOOP_DIR/loop.sh"
|
||||
|
||||
# Stamp harness version
|
||||
[ -n "$PLUGIN_VERSION" ] && echo "$PLUGIN_VERSION" > "$LOOP_DIR/.harness-version"
|
||||
|
||||
# Verify critical files
|
||||
for f in prompts/generator/_base.md prompts/evaluator/_base.md templates/progress.md.template lib/state.sh loop.sh; do
|
||||
if [ ! -f "$LOOP_DIR/$f" ]; then
|
||||
@@ -99,6 +140,7 @@ triage/
|
||||
archive/
|
||||
.archive-staging/
|
||||
.last-branch
|
||||
.harness-version
|
||||
.loop.lock
|
||||
GITIGNORE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user