interplane.Get Omega
Read in your language

omega-harness

Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories

Brought by drakestapleton

branch main Branches Tags History

omega-harness / tools / regen.sh

43 lines · 2379 bytes Raw Blame History
1#!/bin/sh
2# regen.sh OMC [OMEGA_MCP]: after PIN changes, regenerate everything derived from it.
3#
4# Builds tools/jflat.om and tools/guides.om with OMC (its sha256 must be PIN's omc-sha256), finds the
5# newest omega-mcp commit whose data/reference.json is the reference data for PIN (guides pinof decides),
6# writes it flattened to data/reference.tsv with its provenance in data/SOURCE, then rewrites every
7# generated block (`git ls-files | guides gen`). OMEGA_MCP is a clone URL or git directory of omega-mcp:
8# default the Interplane git repository. Run in the repository root.
9# This file is invocation glue; the decisions are made by the Omega programs it builds.
10# Exit 0 regenerated, 1 guides gen reported findings, 2 usage, pin or I/O error.
11set -u
12[ "$#" -ge 1 ] || { sed -n '2,10s/^# \{0,1\}//p' "$0" >&2; exit 2; }
13omc=$1
14mcp=${2:-}
15forge=https://interplane.io/projects/omega-mcp/repo.git
16if [ -z "$mcp" ]; then
17 mcp=$forge
18fi
19[ -f PIN ] && [ -d tools ] || { echo "regen: run in the omega-harness root" >&2; exit 2; }
20want=$(sed -n 's/^omc-sha256 //p' PIN)
21got=$(sha256sum "$omc" 2>/dev/null | cut -d' ' -f1)
22[ -n "$want" ] && [ "$got" = "$want" ] || { echo "regen: omc sha256 ${got:-unreadable}, PIN wants $want" >&2; exit 2; }
23unset GIT_DIR GIT_NAMESPACE GIT_WORK_TREE
24export GIT_TERMINAL_PROMPT=0
25tmp=$(mktemp -d) || exit 2
26trap 'rm -rf "$tmp"' EXIT
27mkdir -p build
28for t in jflat guides; do
29 "$omc" < "tools/$t.om" > "build/$t" && chmod +x "build/$t" || { echo "regen: tools/$t.om does not compile" >&2; exit 2; }
30done
31git clone -q --bare "$mcp" "$tmp/mcp" || { echo "regen: cannot clone $mcp" >&2; exit 2; }
32found=
33for c in $(git --git-dir "$tmp/mcp" log --format=%H main -- data/reference.json); do
34 git --git-dir "$tmp/mcp" show "$c:data/reference.json" > "$tmp/ref.json" || continue
35 build/jflat < "$tmp/ref.json" > "$tmp/ref.tsv" || continue
36 if build/guides pinof < "$tmp/ref.tsv"; then found=$c; break; fi
37done
38[ -n "$found" ] || { echo "regen: no omega-mcp commit holds reference data for PIN; generate it there first (omega-mcp tools/gen-reference.py)" >&2; exit 2; }
39mkdir -p data
40cp "$tmp/ref.tsv" data/reference.tsv
41printf 'omega-mcp %s %s data/reference.json sha256 %s\n' "$forge" "$found" "$(sha256sum "$tmp/ref.json" | cut -d' ' -f1)" > data/SOURCE
42echo "regen: data/reference.tsv from omega-mcp $found"
43git ls-files | build/guides gen