53 lines
1.9 KiB
Bash
53 lines
1.9 KiB
Bash
#!/usr/bin/env sh
|
|
set -eu
|
|
|
|
WORKSPACE="${OPENCODE_WORKSPACE:-/workspace}"
|
|
GROWQR_HOME="${GROWQR_HOME:-/opt/growqr}"
|
|
TEMPLATE="$GROWQR_HOME/workspace-template"
|
|
|
|
mkdir -p "$WORKSPACE" /root/.config/opencode /root/.local/share/opencode
|
|
|
|
# Make sub-agents discoverable from common OpenCode/global locations. We keep
|
|
# the canonical copy in /opt/growqr and symlink/copy to config paths so future
|
|
# OpenCode versions can pick up either convention.
|
|
ln -sfn "$GROWQR_HOME/agents" /root/.config/opencode/agents
|
|
ln -sfn "$GROWQR_HOME/prompts" /root/.config/opencode/prompts
|
|
ln -sfn "$GROWQR_HOME/agents" /root/.local/share/opencode/agents
|
|
ln -sfn "$GROWQR_HOME/prompts" /root/.local/share/opencode/prompts
|
|
|
|
# Seed an empty mounted workspace with the GrowQR Git-backed memory shape. The
|
|
# backend later clones the user's central Gitea repo over this workspace when it
|
|
# provisions the user stack. This only runs for truly empty workspaces.
|
|
if [ -z "$(find "$WORKSPACE" -mindepth 1 -maxdepth 1 2>/dev/null | head -n 1)" ]; then
|
|
cp -a "$TEMPLATE"/. "$WORKSPACE"/
|
|
cat > "$WORKSPACE/README.md" <<EOF
|
|
# GrowQR User Workspace
|
|
|
|
This workspace is controlled by GrowQR's Rivet user actor and backed by the
|
|
user's central Gitea repository. OpenCode runs here with GrowQR sub-agents
|
|
available globally from:
|
|
|
|
- /opt/growqr/agents
|
|
- /opt/growqr/prompts
|
|
- /root/.config/opencode/agents
|
|
|
|
EOF
|
|
git -C "$WORKSPACE" init -b main >/dev/null 2>&1 || true
|
|
git -C "$WORKSPACE" config user.email "growqr@local" || true
|
|
git -C "$WORKSPACE" config user.name "GrowQR" || true
|
|
git -C "$WORKSPACE" add -A >/dev/null 2>&1 || true
|
|
git -C "$WORKSPACE" commit -m "init: growqr workspace template" >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
cat > "$WORKSPACE/.growqr-runtime.json" <<EOF
|
|
{
|
|
"imageVersion": "${GROWQR_IMAGE_VERSION:-dev}",
|
|
"promptVersion": "${GROWQR_PROMPT_VERSION:-dev}",
|
|
"migrationVersion": "${GROWQR_MIGRATION_VERSION:-1}",
|
|
"agentsDir": "$GROWQR_HOME/agents",
|
|
"promptsDir": "$GROWQR_HOME/prompts"
|
|
}
|
|
EOF
|
|
|
|
exec "$@"
|