smart_ide/scripts/open-carbonyl-preview-test.sh
4NK 3f1894e21f Remove AnythingLLM VS Code extension; add Carbonyl service (upstream submodule)
- Delete extensions/anythingllm-workspaces; document migration to anythingllm-devtools
- Add services/carbonyl: shallow submodule fathyb/carbonyl, run-carbonyl.sh (Docker/native)
- Add scripts/open-carbonyl-preview-test.sh and smart_ide.preview_urls.test in example conf
- Docs: service-carbonyl, carbonyl-terminal-browser, architecture index updates
2026-04-03 22:13:34 +02:00

76 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Open smart_ide.preview_urls.test for the active project in Carbonyl (terminal browser).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PROJECT_ID=""
while [[ $# -gt 0 ]]; do
case "$1" in
--project)
PROJECT_ID="${2:?}"
shift 2
;;
-h | --help)
echo "usage: $(basename "$0") [--project <id>]" >&2
echo " Resolves project id: --project, SMART_IDE_PROJECT_ID, or projects/active-project.json" >&2
exit 0
;;
*)
echo "unknown arg: $1" >&2
exit 1
;;
esac
done
if [[ -z "${PROJECT_ID}" ]]; then
if [[ -n "${SMART_IDE_PROJECT_ID:-}" ]]; then
PROJECT_ID="${SMART_IDE_PROJECT_ID}"
fi
fi
ACTIVE="${ROOT}/projects/active-project.json"
if [[ -z "${PROJECT_ID}" && -f "${ACTIVE}" ]]; then
PROJECT_ID="$(python3 -c "
import json
with open('${ACTIVE}', encoding='utf-8') as f:
d = json.load(f)
print(d.get('id') or '')
" 2>/dev/null || true)"
fi
if [[ -z "${PROJECT_ID}" ]]; then
echo "Set SMART_IDE_PROJECT_ID, copy projects/active-project.json.example to projects/active-project.json, or pass --project <id>" >&2
exit 1
fi
CONF="${ROOT}/projects/${PROJECT_ID}/conf.json"
if [[ ! -f "${CONF}" ]]; then
echo "Missing ${CONF}" >&2
exit 1
fi
URL="$(python3 -c "
import json
import sys
with open('${CONF}', encoding='utf-8') as f:
d = json.load(f)
si = d.get('smart_ide') or {}
pu = si.get('preview_urls') or {}
url = (pu.get('test') or '').strip()
if url:
print(url)
sys.exit(0)
sys.exit(1)
" 2>/dev/null || true)"
if [[ -z "${URL}" ]]; then
if [[ -n "${PREVIEW_TEST_URL:-}" ]]; then
URL="${PREVIEW_TEST_URL}"
else
echo "No preview URL: set smart_ide.preview_urls.test in ${CONF} or export PREVIEW_TEST_URL" >&2
exit 1
fi
fi
exec "${ROOT}/services/carbonyl/run-carbonyl.sh" "${URL}"