@asobacloud/nehanda 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,81 @@
1
+ #!/bin/bash
2
+ # build-artifacts.sh — one-command rebuild of all nehanda-cli distribution
3
+ # artifacts (#13): nehanda-cli-latest.tar.gz, nehanda-cli.bin (makeself),
4
+ # Nehanda-CLI.dmg (UDZO). Emits scripts/install.sh alongside.
5
+ #
6
+ # Behavioral spec (tests/unit/test-build-artifacts.mjs):
7
+ # BG-1 clean tree + green suite → builds all 3, payload diff clean vs repo
8
+ # BG-2 install.sh present in repo + tarball + makeself payload
9
+ # BG-3 refuses to build on red suite / dirty tree
10
+ set -euo pipefail
11
+
12
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
13
+ cd "$ROOT"
14
+
15
+ TEST_CMD="${NEHANDA_TEST_CMD:-node tests/unit/test-plan-gate-empty-retry.mjs}"
16
+ PAYLOAD_FILES=(bin lib templates schema.sql package.json package-lock.json)
17
+ LABEL="Nehanda CLI Installer"
18
+
19
+ green() { printf '\033[0;32m✓\033[0m %s\n' "$*"; }
20
+ bold() { printf '\033[1m%s\033[0m\n' "$*"; }
21
+ die() { printf '\033[0;31m✗ ERROR:\033[0m %s\n' "$*" >&2; exit 1; }
22
+
23
+ bold "── 1/4 preconditions ──"
24
+ # BG-3a: dirty tree refuses
25
+ if [ -n "$(git status --porcelain -- bin lib templates schema.sql package.json package-lock.json)" ]; then
26
+ die "refusing to build: payload sources are dirty — commit or stash first"
27
+ fi
28
+ # BG-3b: red suite refuses
29
+ if ! ( eval "$TEST_CMD" ) >/dev/null 2>&1; then
30
+ die "refusing to build: behavioral suite is red ($TEST_CMD)"
31
+ fi
32
+ green "clean tree, suite green ($TEST_CMD)"
33
+ command -v makeself >/dev/null 2>&1 || die "makeself not found (brew install makeself)"
34
+ command -v hdiutil >/dev/null 2>&1 || die "hdiutil not found — macOS only step"
35
+
36
+ bold "── 2/4 tarball (SHIP.md file set + install.sh) ──"
37
+ # BG-2: install.sh rides alongside, inside the tarball
38
+ cp scripts/install.sh ./install.sh
39
+ trap 'rm -f "$ROOT/install.sh"' EXIT
40
+ rm -f nehanda-cli-latest.tar.gz
41
+ tar -czf nehanda-cli-latest.tar.gz "${PAYLOAD_FILES[@]}" install.sh
42
+ tar tzf nehanda-cli-latest.tar.gz | grep -q '^install.sh$' || die "install.sh missing from tarball"
43
+ rm -f ./install.sh
44
+ green "nehanda-cli-latest.tar.gz built ($(du -h nehanda-cli-latest.tar.gz | cut -f1))"
45
+
46
+ bold "── 3/4 makeself linux installer ──"
47
+ STAGE="$(mktemp -d)"
48
+ trap 'rm -rf "$STAGE"; rm -f "$ROOT/install.sh"' EXIT
49
+ cp -R "${PAYLOAD_FILES[@]}" "$STAGE/"
50
+ cp scripts/install.sh "$STAGE/"
51
+ makeself --tar-extra --no-same-owner "$STAGE" nehanda-cli.bin "$LABEL" ./install.sh >/dev/null
52
+ rm -rf "$STAGE"
53
+ green "nehanda-cli.bin built"
54
+
55
+ bold "── 4/4 DMG + verification ──"
56
+ DMGROOT="$(mktemp -d)"
57
+ # Install.command is preserved from the previous DMG (source of truth for mac install UX)
58
+ hdiutil attach -mountpoint /tmp/dmg-old -nobrowse -quiet Nehanda-CLI.dmg
59
+ cp /tmp/dmg-old/Install.command "$DMGROOT/"
60
+ hdiutil detach /tmp/dmg-old -quiet
61
+ mkdir -p "$DMGROOT/nehanda-cli"
62
+ cp -R "${PAYLOAD_FILES[@]}" "$DMGROOT/nehanda-cli/"
63
+ cp scripts/install.sh "$DMGROOT/nehanda-cli/"
64
+ rm -f Nehanda-CLI.dmg
65
+ hdiutil create -volname "Nehanda CLI" -srcfolder "$DMGROOT" -format UDZO -quiet Nehanda-CLI.dmg
66
+ rm -rf "$DMGROOT"
67
+
68
+ # BG-1 verification: payload diff clean vs repo
69
+ VERIFY="$(mktemp -d)"
70
+ ./nehanda-cli.bin --noexec --nochown --target "$VERIFY" >/dev/null 2>&1
71
+ for f in "${PAYLOAD_FILES[@]}"; do
72
+ diff -rq "$VERIFY/$f" "$ROOT/$f" >/dev/null || die "payload drift detected in $f"
73
+ done
74
+ grep -q retryEmptyPlanningTurn "$VERIFY/lib/orchestrate.mjs" || die "payload missing #11 fix"
75
+ grep -q slashIdx "$VERIFY/bin/agent.mjs" || die "payload missing #12 fix"
76
+ test -f "$VERIFY/install.sh" || die "payload missing install.sh"
77
+ rm -rf "$VERIFY"
78
+ green "payload diff clean"
79
+
80
+ green "All artifacts rebuilt: tar.gz, .bin, .dmg (+ scripts/install.sh alongside)"
81
+ git status --porcelain -- nehanda-cli-latest.tar.gz nehanda-cli.bin Nehanda-CLI.dmg | awk '{print " rebuilt:", $2}'
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+ # nehanda-cli installer — curl | sh single-line install (#13)
3
+ #
4
+ # Served from the asoba.co /releases web root alongside nehanda-cli-latest.tar.gz.
5
+ # Downloads the tarball, unpacks to ~/.nehanda, installs deps, links `nehanda`.
6
+ #
7
+ # Usage: curl -fsSL https://asoba.co/releases/install.sh | sh
8
+ set -euo pipefail
9
+
10
+ INSTALL_DIR="${NEHANDA_INSTALL_DIR:-$HOME/.nehanda}"
11
+ RELEASE_URL="${NEHANDA_RELEASE_URL:-https://asoba.co/releases/nehanda-cli-latest.tar.gz}"
12
+ LINK_DIR="/usr/local/bin"
13
+
14
+ green() { printf '\033[0;32m✓\033[0m %s\n' "$*"; }
15
+ bold() { printf '\033[1m%s\033[0m\n' "$*"; }
16
+ die() { printf '\033[0;31m✗ ERROR:\033[0m %s\n' "$*" >&2; exit 1; }
17
+
18
+ command -v node >/dev/null 2>&1 || die "node not found — install Node.js >= 20 first"
19
+ command -v npm >/dev/null 2>&1 || die "npm not found — install Node.js >= 20 first"
20
+
21
+ bold "Installing Nehanda CLI…"
22
+ echo " install dir: $INSTALL_DIR"
23
+ echo " release: $RELEASE_URL"
24
+
25
+ command -v curl >/dev/null 2>&1 || die "curl not found"
26
+
27
+ TMP_TARBALL="$(mktemp -t nehanda-cli).tar.gz"
28
+ trap 'rm -f "$TMP_TARBALL"' EXIT
29
+ curl -fsSL "$RELEASE_URL" -o "$TMP_TARBALL" \
30
+ || die "download failed — check $RELEASE_URL"
31
+
32
+ mkdir -p "$INSTALL_DIR"
33
+ tar -xzf "$TMP_TARBALL" -C "$INSTALL_DIR"
34
+
35
+ ( cd "$INSTALL_DIR" && npm install --omit=dev --silent ) \
36
+ || die "npm install failed"
37
+
38
+ cat > "$INSTALL_DIR/bin/nehanda" <<LAUNCHER
39
+ #!/bin/sh
40
+ exec node "$HOME/.nehanda/bin/agent.mjs" "\$@"
41
+ LAUNCHER
42
+ chmod +x "$INSTALL_DIR/bin/nehanda"
43
+
44
+ if [ -w "$LINK_DIR" ]; then
45
+ ln -sf "$INSTALL_DIR/bin/nehanda" "$LINK_DIR/nehanda"
46
+ else
47
+ sudo ln -sf "$INSTALL_DIR/bin/nehanda" "$LINK_DIR/nehanda" \
48
+ || warn "could not symlink into $LINK_DIR — add $INSTALL_DIR/bin to PATH"
49
+ fi
50
+
51
+ green "Installation complete — run 'nehanda' in your terminal."