ca44da71e1
Install gitea-mcp v1.1.0 (Go binary from gitea.com/gitea/gitea-mcp)
using the same multi-arch pattern as gosu/fzf/bat. Provides 50+ MCP
tools for Gitea API — repos, issues, PRs, releases, branches, wiki,
and Actions.
Disabled by default in auto-generated opencode.json (requires
GITEA_ACCESS_TOKEN and GITEA_HOST to be useful). Users enable it by
setting those env vars in .env and flipping enabled to true in their
opencode.json.
Env vars forwarded into the container via docker-compose.yml and
docker-compose.shared.yml environment blocks. Same {env:VAR} pattern
as the GitHub MCP server.
Docs updated: README.md (new Gitea MCP section with setup steps),
DOCKER_HUB.md (tools list), CHANGELOG.md (v1.14.28b entry).
177 lines
5.5 KiB
Bash
177 lines
5.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# ── Shell defaults: copy baked files from /etc/skel-devbox/ if absent
|
|
# Respects host bind-mounts and user customizations — existing files
|
|
# are never overwritten. To restore defaults: rm ~/.bash_aliases (or
|
|
# .inputrc) and recreate the container, or cp from /etc/skel-devbox/
|
|
# directly.
|
|
SKEL_DIR="/etc/skel-devbox"
|
|
if [ -d "$SKEL_DIR" ]; then
|
|
for f in .bash_aliases .inputrc; do
|
|
if [ -f "$SKEL_DIR/$f" ] && [ ! -e "$HOME/$f" ]; then
|
|
cp "$SKEL_DIR/$f" "$HOME/$f"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# ── MemPalace: initialize palace for the workspace if mempalace is installed
|
|
# Creates the palace directory structure on first run. Idempotent — skips
|
|
# if palace already exists. Uses the workspace path to derive the wing name.
|
|
if command -v mempalace &>/dev/null && [ -d /workspace ]; then
|
|
PALACE_DIR="${HOME}/.mempalace"
|
|
if [ ! -d "$PALACE_DIR/palace" ]; then
|
|
echo "Initializing MemPalace for workspace..."
|
|
mempalace init /workspace 2>/dev/null || true
|
|
fi
|
|
fi
|
|
|
|
# ── Git config defaults ──────────────────────────────────────────────
|
|
if [ -n "${GIT_USER_NAME:-}" ] && ! git config --global user.name &>/dev/null; then
|
|
git config --global user.name "$GIT_USER_NAME"
|
|
fi
|
|
if [ -n "${GIT_USER_EMAIL:-}" ] && ! git config --global user.email &>/dev/null; then
|
|
git config --global user.email "$GIT_USER_EMAIL"
|
|
fi
|
|
|
|
# ── Generate opencode config from env vars if no config mounted ──────
|
|
CONFIG_DIR="$HOME/.config/opencode"
|
|
CONFIG_FILE="$CONFIG_DIR/opencode.json"
|
|
|
|
if [ ! -f "$CONFIG_FILE" ] && [ -n "${OPENCODE_PROVIDER:-}" ]; then
|
|
echo "Generating opencode config for provider: $OPENCODE_PROVIDER"
|
|
mkdir -p "$CONFIG_DIR"
|
|
|
|
case "$OPENCODE_PROVIDER" in
|
|
anthropic)
|
|
cat > "$CONFIG_FILE" <<EOF
|
|
{
|
|
"\$schema": "https://opencode.ai/config.json",
|
|
"model": "${OPENCODE_MODEL:-anthropic/claude-sonnet-4-6}",
|
|
"share": "disabled",
|
|
"autoupdate": false
|
|
}
|
|
EOF
|
|
;;
|
|
openai)
|
|
cat > "$CONFIG_FILE" <<EOF
|
|
{
|
|
"\$schema": "https://opencode.ai/config.json",
|
|
"model": "${OPENCODE_MODEL:-openai/gpt-5.4}",
|
|
"share": "disabled",
|
|
"autoupdate": false
|
|
}
|
|
EOF
|
|
;;
|
|
amazon-bedrock)
|
|
cat > "$CONFIG_FILE" <<EOF
|
|
{
|
|
"\$schema": "https://opencode.ai/config.json",
|
|
"model": "${OPENCODE_MODEL:-amazon-bedrock/global.anthropic.claude-sonnet-4-5-20250929-v1:0}",
|
|
"share": "disabled",
|
|
"autoupdate": false,
|
|
"provider": {
|
|
"amazon-bedrock": {
|
|
"options": {
|
|
"region": "${AWS_REGION:-us-east-1}",
|
|
"profile": "${AWS_PROFILE:-default}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
;;
|
|
*)
|
|
cat > "$CONFIG_FILE" <<EOF
|
|
{
|
|
"\$schema": "https://opencode.ai/config.json",
|
|
"model": "${OPENCODE_MODEL:-anthropic/claude-sonnet-4-6}",
|
|
"share": "disabled",
|
|
"autoupdate": false
|
|
}
|
|
EOF
|
|
;;
|
|
esac
|
|
|
|
# Add MCP servers for installed tools
|
|
if command -v python3 &>/dev/null; then
|
|
python3 -c "
|
|
import json, shutil
|
|
with open('$CONFIG_FILE') as f:
|
|
config = json.load(f)
|
|
mcp = config.setdefault('mcp', {})
|
|
|
|
# MemPalace — local AI memory (if installed)
|
|
if shutil.which('mempalace'):
|
|
mcp['mempalace'] = {
|
|
'type': 'local',
|
|
'command': ['python3', '-m', 'mempalace.mcp_server']
|
|
}
|
|
|
|
# Gitea — self-hosted Git forge API (if installed)
|
|
if shutil.which('gitea-mcp'):
|
|
mcp['gitea'] = {
|
|
'type': 'local',
|
|
'command': ['gitea-mcp', '-t', 'stdio'],
|
|
'enabled': False
|
|
}
|
|
|
|
with open('$CONFIG_FILE', 'w') as f:
|
|
json.dump(config, f, indent=2)
|
|
f.write('\n')
|
|
" 2>/dev/null && echo "MCP servers registered in opencode config."
|
|
fi
|
|
fi
|
|
|
|
# ── oh-my-opencode-slim setup (multi-agent orchestration) ────────────
|
|
# Activated by ENABLE_OMOS=true. Requires the image to be built with
|
|
# INSTALL_OMOS=true (which installs bun + the oh-my-opencode-slim package).
|
|
OMOS_CONFIG="$CONFIG_DIR/oh-my-opencode-slim.json"
|
|
|
|
if [ "${ENABLE_OMOS:-false}" = "true" ]; then
|
|
if ! command -v bunx &>/dev/null; then
|
|
echo "WARNING: ENABLE_OMOS=true but bun is not installed."
|
|
echo "Rebuild with: docker compose build --build-arg INSTALL_OMOS=true"
|
|
elif [ ! -f "$OMOS_CONFIG" ]; then
|
|
echo "Setting up oh-my-opencode-slim agents..."
|
|
|
|
# Determine installer flags
|
|
OMOS_TMUX_FLAG="no"
|
|
if [ "${OMOS_TMUX:-false}" = "true" ]; then
|
|
OMOS_TMUX_FLAG="yes"
|
|
fi
|
|
|
|
OMOS_SKILLS_FLAG="yes"
|
|
if [ "${OMOS_SKILLS:-true}" = "false" ]; then
|
|
OMOS_SKILLS_FLAG="no"
|
|
fi
|
|
|
|
bunx oh-my-opencode-slim@latest install \
|
|
--no-tui \
|
|
--tmux="${OMOS_TMUX_FLAG}" \
|
|
--skills="${OMOS_SKILLS_FLAG}"
|
|
|
|
echo "oh-my-opencode-slim configured successfully."
|
|
else
|
|
echo "oh-my-opencode-slim config found at $OMOS_CONFIG (use OMOS_RESET=true to overwrite)."
|
|
|
|
# Allow reset via env var (creates backup automatically)
|
|
if [ "${OMOS_RESET:-false}" = "true" ]; then
|
|
echo "OMOS_RESET=true — regenerating oh-my-opencode-slim config..."
|
|
OMOS_TMUX_FLAG="no"
|
|
[ "${OMOS_TMUX:-false}" = "true" ] && OMOS_TMUX_FLAG="yes"
|
|
OMOS_SKILLS_FLAG="yes"
|
|
[ "${OMOS_SKILLS:-true}" = "false" ] && OMOS_SKILLS_FLAG="no"
|
|
|
|
bunx oh-my-opencode-slim@latest install \
|
|
--no-tui \
|
|
--tmux="${OMOS_TMUX_FLAG}" \
|
|
--skills="${OMOS_SKILLS_FLAG}" \
|
|
--reset
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# ── Execute command ──────────────────────────────────────────────────
|
|
exec "$@"
|