Save in-progress keysat integration and StartOS 0.4 work

Snapshot of the working tree before cleanup. Captures:
- Keysat licensing: server/license.js, /api/license/* endpoints in
  server/index.js, activation modal in public/index.html, embedded
  Ed25519 issuer key (assets/issuer.pub).
- StartOS 0.4 expansion: setApiKey action, version files v0.1.1
  through v0.1.15, file-models/config.json.ts, manifest updates.
- Self-hosted registry server (startos-registry/).
- Build/deploy scripts (bin/bump-version.sh, bin/deploy.sh, vendored
  yt-dlp binary), .gitignore, .deploy.env.example.
- Recent design docs (KEYSAT_INTEGRATION.md, UPGRADE-DESIGN.md) —
  retained here so they remain recoverable when removed in the
  follow-up cleanup commit.
This commit is contained in:
Keysat
2026-05-08 09:39:17 -05:00
parent 8298c083c7
commit 574a16d9fa
666 changed files with 71889 additions and 724 deletions
+151
View File
@@ -0,0 +1,151 @@
#!/usr/bin/env bash
# Interactive version bump.
#
# Shows the current version, asks for the new version (with a sensible default:
# patch-level bump), and asks for release notes. Then:
# 1. Creates startos/versions/v<new>.ts
# 2. Updates startos/versions/index.ts (adds import, updates `current:`,
# pushes old current into `other:`)
#
# If the file .release-notes-pending.txt exists in the project root, its
# contents are shown as the default release notes (just press Enter to accept).
# This is the convention Claude uses after making code changes. The file is
# deleted on a successful bump.
#
# Run standalone with `make bump`, or as the first step of `make deploy`.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
VERSIONS_DIR="$PROJECT_ROOT/startos/versions"
INDEX_FILE="$VERSIONS_DIR/index.ts"
PENDING_NOTES_FILE="$PROJECT_ROOT/.release-notes-pending.txt"
# --- Discover current version ---
CURRENT_VAR="$(sed -nE "s/.*current:[[:space:]]*(v_[0-9_]+).*/\1/p" "$INDEX_FILE" | head -1)"
if [ -z "$CURRENT_VAR" ]; then
echo "X Could not find current version in $INDEX_FILE" >&2
exit 1
fi
CURRENT_DOT="$(echo "$CURRENT_VAR" | sed 's/^v_//; s/_/./g')"
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_DOT"
SUGGESTED="$MAJOR.$MINOR.$((PATCH + 1))"
echo ""
echo "═══════════════════════════════════════════"
echo " Bumping version"
echo "═══════════════════════════════════════════"
echo ""
echo " Current: $CURRENT_DOT"
echo ""
# --- Prompt for new version ---
read -r -p " New version [$SUGGESTED]: " NEW_VERSION
NEW_VERSION="${NEW_VERSION:-$SUGGESTED}"
if ! [[ "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "X Invalid version: '$NEW_VERSION' (expected format: x.y.z, e.g. 0.1.10)" >&2
exit 1
fi
NEW_FILE="$VERSIONS_DIR/v${NEW_VERSION}.ts"
if [ -f "$NEW_FILE" ]; then
echo "X Version file already exists: $NEW_FILE" >&2
echo " (If you want to re-run, delete that file first.)" >&2
exit 1
fi
NEW_VAR="v_$(echo "$NEW_VERSION" | tr '.' '_')"
# --- Prompt for release notes ---
# If Claude (or you) left suggested notes in .release-notes-pending.txt, show
# them as the default. Press Enter to accept, or type something different.
SUGGESTED_NOTES=""
if [ -f "$PENDING_NOTES_FILE" ]; then
# Read the file, trim leading/trailing whitespace, collapse interior newlines
# into spaces so it fits the one-line release-notes format.
SUGGESTED_NOTES="$(tr '\n' ' ' < "$PENDING_NOTES_FILE" | sed -e 's/[[:space:]]\{1,\}/ /g' -e 's/^ //' -e 's/ $//')"
fi
echo ""
if [ -n "$SUGGESTED_NOTES" ]; then
echo " Suggested release notes (from .release-notes-pending.txt):"
echo " $SUGGESTED_NOTES"
echo ""
read -r -p " Release notes (Enter to accept, or type new): " RELEASE_NOTES
RELEASE_NOTES="${RELEASE_NOTES:-$SUGGESTED_NOTES}"
else
read -r -p " Release notes (one-liner, what changed in $NEW_VERSION?): " RELEASE_NOTES
fi
if [ -z "$RELEASE_NOTES" ]; then
echo "X Release notes are required" >&2
exit 1
fi
# Escape for TypeScript single-quoted string: backslash first, then single quote
ESCAPED_NOTES="$(printf '%s' "$RELEASE_NOTES" | sed -e 's/\\/\\\\/g' -e "s/'/\\\\'/g")"
# Clean up partial state if anything below fails
cleanup_on_error() {
[ -f "$NEW_FILE" ] && rm -f "$NEW_FILE"
[ -f "$INDEX_FILE.tmp" ] && rm -f "$INDEX_FILE.tmp"
[ -f "$INDEX_FILE.bak" ] && rm -f "$INDEX_FILE.bak"
}
trap cleanup_on_error ERR
# --- 1. Create new version file ---
cat > "$NEW_FILE" <<EOF
import { VersionInfo } from '@start9labs/start-sdk'
export const $NEW_VAR = VersionInfo.of({
version: '$NEW_VERSION:0',
releaseNotes: {
en_US: '$ESCAPED_NOTES',
},
migrations: {
up: async ({ effects }) => {},
down: async ({ effects }) => {},
},
})
EOF
# --- 2. Update index.ts ---
# Insert `import { v_NEW } from './vNEW'` right after the last existing version
# import, so the imports stay contiguous.
NEW_IMPORT="import { $NEW_VAR } from './v$NEW_VERSION'"
awk -v new_import="$NEW_IMPORT" '
/^import \{ v_[0-9_]+ \} from/ { last_imp = NR }
{ lines[NR] = $0 }
END {
for (i = 1; i <= NR; i++) {
print lines[i]
if (i == last_imp) print new_import
}
}
' "$INDEX_FILE" > "$INDEX_FILE.tmp"
mv "$INDEX_FILE.tmp" "$INDEX_FILE"
# Point `current:` at the new version, and prepend the old current into `other:`.
# Use -i.bak for macOS/BSD + Linux/GNU sed compatibility.
sed -i.bak \
-e "s/current: $CURRENT_VAR/current: $NEW_VAR/" \
-e "s/other: \[/other: [$CURRENT_VAR, /" \
"$INDEX_FILE"
rm -f "$INDEX_FILE.bak"
trap - ERR
# --- Clean up the pending-notes scratch file now that we've consumed it ---
if [ -f "$PENDING_NOTES_FILE" ]; then
rm -f "$PENDING_NOTES_FILE"
fi
echo ""
echo " ✓ Created startos/versions/v${NEW_VERSION}.ts"
echo " ✓ Wired up in startos/versions/index.ts"
echo " ✓ Version: $CURRENT_DOT$NEW_VERSION"
echo ""
Executable
+109
View File
@@ -0,0 +1,109 @@
#!/usr/bin/env bash
# One-shot deploy: upload the built .s9pk to FileBrowser, register it with the
# Start9 registry, and trigger a re-index so clients see the new version.
#
# Config is loaded from, in order:
# 1. Environment variables
# 2. $PROJECT_ROOT/.deploy.env (gitignored; see .deploy.env.example)
#
# Required config:
# FILEBROWSER_URL — e.g. https://immense-voyage.local:51165
# FILEBROWSER_USER — your FileBrowser login
# FILEBROWSER_PASS — your FileBrowser password
# START9_SERVER — your Start9 server, e.g. https://immense-voyage.local:62185
#
# Optional config (sensible defaults):
# FILEBROWSER_PATH — path on FileBrowser to overwrite. Default: /websites/packages/youtube-summarizer_x86_64.s9pk
# REGISTRY_URL — registry JSON-RPC URL. Default: https://registry.satsflows.com
# REGISTRY_PUBLIC_URL — public .s9pk URL registered with start-cli.
# Default: https://files.satsflows.com/youtube-summarizer_x86_64.s9pk
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
ENV_FILE="$PROJECT_ROOT/.deploy.env"
if [ -f "$ENV_FILE" ]; then
# shellcheck disable=SC1090
set -a; source "$ENV_FILE"; set +a
fi
# --- Validate config ---
: "${FILEBROWSER_URL:?FILEBROWSER_URL is required (see bin/deploy.sh header)}"
: "${FILEBROWSER_USER:?FILEBROWSER_USER is required}"
: "${FILEBROWSER_PASS:?FILEBROWSER_PASS is required}"
: "${START9_SERVER:?START9_SERVER is required (e.g. https://immense-voyage.local:62185)}"
FILEBROWSER_PATH="${FILEBROWSER_PATH:-/websites/packages/youtube-summarizer_x86_64.s9pk}"
REGISTRY_URL="${REGISTRY_URL:-https://registry.satsflows.com}"
REGISTRY_PUBLIC_URL="${REGISTRY_PUBLIC_URL:-https://files.satsflows.com/youtube-summarizer_x86_64.s9pk}"
S9PK_FILE="$PROJECT_ROOT/youtube-summarizer_x86_64.s9pk"
if [ ! -f "$S9PK_FILE" ]; then
echo "X $S9PK_FILE not found. Run 'make x86' first." >&2
exit 1
fi
# --- Discover current version from startos/versions ---
CURRENT_VAR="$(sed -nE "s/.*current:[[:space:]]*(v_[0-9_]+).*/\1/p" "$PROJECT_ROOT/startos/versions/index.ts" | head -1)"
if [ -n "$CURRENT_VAR" ]; then
VERSION_DOT="$(echo "$CURRENT_VAR" | sed 's/^v_//; s/_/./g')"
VERSION_FILE="$PROJECT_ROOT/startos/versions/v${VERSION_DOT}.ts"
CURRENT_VERSION="$(sed -nE "s/.*version:[[:space:]]*'([^']+)'.*/\1/p" "$VERSION_FILE" | head -1)"
else
CURRENT_VERSION="unknown"
fi
echo "==> Deploying youtube-summarizer $CURRENT_VERSION"
echo " source : $S9PK_FILE"
echo " upload : $FILEBROWSER_URL$FILEBROWSER_PATH"
echo " public : $REGISTRY_PUBLIC_URL"
echo " start9 : $START9_SERVER"
echo ""
# FileBrowser is typically on a *.local address with a self-signed cert, so
# curl needs -k (--insecure) to connect. Override with FILEBROWSER_CURL_OPTS if
# you've set up trust for the Start9 root CA.
FB_CURL_OPTS="${FILEBROWSER_CURL_OPTS:--k}"
# --- 1. Authenticate with FileBrowser ---
echo "[1/4] Authenticating with FileBrowser..."
LOGIN_BODY="$(printf '{"username":"%s","password":"%s"}' \
"$(printf '%s' "$FILEBROWSER_USER" | sed 's/[\\"]/\\&/g')" \
"$(printf '%s' "$FILEBROWSER_PASS" | sed 's/[\\"]/\\&/g')")"
TOKEN="$(curl $FB_CURL_OPTS -fsS -X POST "$FILEBROWSER_URL/api/login" \
-H "Content-Type: application/json" \
--data-raw "$LOGIN_BODY")" || {
echo "X FileBrowser login failed (check URL, username, password)" >&2
exit 1
}
if [ -z "$TOKEN" ]; then
echo "X FileBrowser login returned an empty token" >&2
exit 1
fi
# --- 2. Upload .s9pk (override existing) ---
echo "[2/4] Uploading $(basename "$S9PK_FILE") ($(du -h "$S9PK_FILE" | cut -f1))..."
curl $FB_CURL_OPTS -fsS -X POST "$FILEBROWSER_URL/api/resources${FILEBROWSER_PATH}?override=true" \
-H "X-Auth: $TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$S9PK_FILE" \
-o /dev/null
# --- 3. Register with Start9 registry (adds manifest + pointer to public URL) ---
echo "[3/4] Registering package with registry..."
start-cli -r "$START9_SERVER" registry package add "$S9PK_FILE" --url "$REGISTRY_PUBLIC_URL"
# --- 4. Trigger registry re-index so clients see the new version ---
echo "[4/4] Re-indexing registry..."
curl -fsS -X POST "$REGISTRY_URL/rpc/v0" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"index","id":1}' \
-o /dev/null
echo ""
echo "==> Done. youtube-summarizer $CURRENT_VERSION is live."
Executable
BIN
View File
Binary file not shown.