chore: initial commit
This commit is contained in:
commit
63f3199076
9 files changed
+567
No files matched your search
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
#ddev-generated
|
||||
## Description: Run Claude Code CLI inside the web container
|
||||
## Usage: claude [--account <n|email|alias>]
|
||||
## Example: "ddev claude --version"
|
||||
set -euo pipefail
|
||||
|
||||
INSTALL_SCRIPT="${DDEV_APPROOT}/.ddev/claude-code/install.sh"
|
||||
SWAP_INSTALL_SCRIPT="${DDEV_APPROOT}/.ddev/claude-code/install-swap.sh"
|
||||
PERSIST_BASE="${DDEV_APPROOT}/.ddev/claude-code"
|
||||
PERSIST_HOME="${PERSIST_BASE}/home"
|
||||
PERSIST_BIN="${PERSIST_HOME}/.local/bin/claude"
|
||||
CSWAP_BIN="${PERSIST_HOME}/.local/bin/cswap"
|
||||
|
||||
# Optional multi-account routing: "ddev claude --account <sel>" starts a session
|
||||
# pinned to a claude-swap account via "cswap run". With no flag, a project
|
||||
# default can come from $DDEV_CLAUDE_SWAP_ACCOUNT or the first line of
|
||||
# .ddev/claude-code/claude-swap-account. When neither is set this behaves
|
||||
# exactly like a plain Claude Code launch.
|
||||
ACCOUNT=""
|
||||
ARGS=()
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--account=*) ACCOUNT="${1#--account=}"; shift ;;
|
||||
--account|-A)
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "ddev claude: --account requires an argument" >&2
|
||||
exit 1
|
||||
fi
|
||||
ACCOUNT="$2"; shift 2 ;;
|
||||
-A*) ACCOUNT="${1#-A}"; shift ;;
|
||||
*) ARGS+=("$1"); shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "${ACCOUNT}" ]; then
|
||||
if [ -n "${DDEV_CLAUDE_SWAP_ACCOUNT:-}" ]; then
|
||||
ACCOUNT="${DDEV_CLAUDE_SWAP_ACCOUNT}"
|
||||
elif [ -f "${PERSIST_BASE}/claude-swap-account" ]; then
|
||||
ACCOUNT="$(head -n1 "${PERSIST_BASE}/claude-swap-account" | tr -d '[:space:]')"
|
||||
fi
|
||||
fi
|
||||
|
||||
"${INSTALL_SCRIPT}"
|
||||
|
||||
export HOME="${PERSIST_HOME}"
|
||||
export XDG_CONFIG_HOME="${PERSIST_BASE}/config"
|
||||
export XDG_DATA_HOME="${PERSIST_BASE}/data"
|
||||
export XDG_STATE_HOME="${PERSIST_BASE}/state"
|
||||
export PATH="${PERSIST_HOME}/.local/bin:${PATH}"
|
||||
unset SSH_AUTH_SOCK
|
||||
|
||||
cd "${DDEV_APPROOT}"
|
||||
|
||||
if [ -n "${ACCOUNT}" ]; then
|
||||
"${SWAP_INSTALL_SCRIPT}"
|
||||
if [ "${#ARGS[@]}" -gt 0 ]; then
|
||||
exec "${CSWAP_BIN}" run "${ACCOUNT}" -- "${ARGS[@]}"
|
||||
fi
|
||||
exec "${CSWAP_BIN}" run "${ACCOUNT}"
|
||||
fi
|
||||
|
||||
exec "${PERSIST_BIN}" ${ARGS[@]+"${ARGS[@]}"}
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
#ddev-generated
|
||||
## Description: Manage multiple Claude accounts (claude-swap / cswap)
|
||||
## Usage: claude-swap [command]
|
||||
## Example: "ddev claude-swap list"
|
||||
set -euo pipefail
|
||||
|
||||
INSTALL_SCRIPT="${DDEV_APPROOT}/.ddev/claude-code/install-swap.sh"
|
||||
PERSIST_BASE="${DDEV_APPROOT}/.ddev/claude-code"
|
||||
PERSIST_HOME="${PERSIST_BASE}/home"
|
||||
CSWAP_BIN="${PERSIST_HOME}/.local/bin/cswap"
|
||||
|
||||
# Lazy install / health check (also handles "ddev claude-swap upgrade").
|
||||
if [ "${1:-}" = "upgrade" ]; then
|
||||
exec "${INSTALL_SCRIPT}" --upgrade
|
||||
fi
|
||||
"${INSTALL_SCRIPT}"
|
||||
|
||||
export HOME="${PERSIST_HOME}"
|
||||
export XDG_CONFIG_HOME="${PERSIST_BASE}/config"
|
||||
export XDG_DATA_HOME="${PERSIST_BASE}/data"
|
||||
export XDG_STATE_HOME="${PERSIST_BASE}/state"
|
||||
export PATH="${PERSIST_HOME}/.local/bin:${PATH}"
|
||||
unset SSH_AUTH_SOCK
|
||||
|
||||
cd "${DDEV_APPROOT}"
|
||||
exec "${CSWAP_BIN}" "$@"
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
#ddev-generated
|
||||
## Description: Run Codex CLI inside the web container
|
||||
## Usage: codex
|
||||
## Example: "ddev codex --version"
|
||||
set -euo pipefail
|
||||
|
||||
INSTALL_SCRIPT="${DDEV_APPROOT}/.ddev/codex-cli/install.sh"
|
||||
PERSIST_BASE="${DDEV_APPROOT}/.ddev/codex-cli"
|
||||
PERSIST_BIN="${PERSIST_BASE}/bin/codex"
|
||||
|
||||
"${INSTALL_SCRIPT}"
|
||||
|
||||
export HOME="${PERSIST_BASE}/home"
|
||||
export CODEX_HOME="${PERSIST_BASE}/home/.codex"
|
||||
export XDG_CONFIG_HOME="${PERSIST_BASE}/config"
|
||||
export XDG_DATA_HOME="${PERSIST_BASE}/data"
|
||||
export XDG_STATE_HOME="${PERSIST_BASE}/state"
|
||||
export PATH="${PERSIST_BASE}/bin:${HOME}/.local/bin:${PATH}"
|
||||
unset SSH_AUTH_SOCK
|
||||
|
||||
cd "${DDEV_APPROOT}"
|
||||
exec "${PERSIST_BIN}" --sandbox danger-full-access --ask-for-approval on-request "$@"
|
||||
Reference in new issue
Block a user