Add .loop-build harness and IntelliJ project configuration files

This commit is contained in:
2026-02-25 01:18:49 +08:00
commit 6f02ef607f
27 changed files with 1792 additions and 0 deletions

44
.loop-build/scripts/snapshot.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
LB_DIR="$ROOT_DIR/.loop-build"
SNAP_DIR="$LB_DIR/state/snapshots"
mkdir -p "$SNAP_DIR"
label="${1:-manual}"
mkdir -p "$LB_DIR/state"
stamp="$(date -u +%Y%m%dT%H%M%SZ)"
out="$SNAP_DIR/snapshot-${stamp}-${label}.json"
if [[ -d "$ROOT_DIR/.git" ]]; then
head="$(git -C "$ROOT_DIR" rev-parse --short HEAD 2>/dev/null || true)"
if [[ -z "$head" ]]; then
head="NO_HEAD"
fi
else
head="UNKNOWN"
fi
changed_lines=""
if [[ -d "$ROOT_DIR/.git" ]]; then
changed_lines="$(git -C "$ROOT_DIR" status --porcelain --untracked-files=normal | cut -c4- | sed '/^$/d' | sort -u || true)"
fi
changed_json='[]'
if [[ -n "$changed_lines" ]]; then
changed_json="$(printf '%s\n' "$changed_lines" | jq -R -s 'split("\n") | map(select(length > 0))')"
fi
jq -n \
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg snap_label "$label" \
--arg repo "$ROOT_DIR" \
--arg head "$head" \
--argjson changed_files "$changed_json" \
'{timestamp:$timestamp,label:$snap_label,repo:$repo,head:$head,changed_files:$changed_files}' \
> "$out"
echo "[snapshot] created: $out"
if [[ -d "$ROOT_DIR/.git" ]]; then
git -C "$ROOT_DIR" status --short --untracked-files=normal
fi