Sign inSign up

maidok/t3-workspace-project:1.1.0

Manifest digest

sha256:2825f1a91f5506597472cfc1fc7246b8e2febd4e753cf233d992d132714d8e60

Last pushed

8 days by maidok

Type

Sandbox Kit

Manifest digest

sha256:2825f1a91f5506597472cfc1fc7246b8e2febd4e753cf233d992d132714d8e60

yaml
schemaVersion: "3"
displayName: T3 Code workspace project
description: Registers the sandbox workspace as a T3 Code project and routes GitHub SSH remotes over HTTPS, so T3 Code can open the project and create worktrees right away. Use with the t3code kit.
kind: mixin
capabilities:
    - type: com.docker.sandbox/lifecycle@1
      config:
        startup:
            - command:
                - sh
                - -c
                - |
                  # The sandbox proxy blocks SSH (port 22), so T3's `git fetch` on a
                  # [email protected]: origin fails. Rewrite to HTTPS and let gh supply
                  # the token. Idempotent: values are reset before being added.
                  command -v gh >/dev/null 2>&1 || { echo "gh not found; skipping"; exit 0; }
                  git config --global --unset-all url.https://github.com/.insteadOf 2>/dev/null || true
                  git config --global --add url.https://github.com/.insteadOf [email protected]:
                  git config --global --add url.https://github.com/.insteadOf ssh://[email protected]/
                  git config --global --unset-all credential.https://github.com.helper 2>/dev/null || true
                  git config --global --add credential.https://github.com.helper ''
                  git config --global --add credential.https://github.com.helper '!gh auth git-credential'
                  echo "GitHub remotes now use HTTPS with gh credentials"
              description: Route GitHub SSH remotes over HTTPS via gh
            - command:
                - sh
                - -c
                - |
                  dir="${WORKSPACE_DIR:-}"
                  [ -n "$dir" ] || { echo "WORKSPACE_DIR is not set; skipping"; exit 0; }
                  # Clone-mode sandboxes may still be populating the workspace.
                  i=0; while [ ! -d "$dir" ] && [ "$i" -lt 60 ]; do sleep 1; i=$((i+1)); done
                  # The t3code kit's `t3` launcher is a node script, and agent images
                  # may not ship node, so call the bundled native binary directly.
                  t3=$(ls /opt/t3/lib/node_modules/t3/node_modules/@t3code/t3-linux-*/t3 2>/dev/null | head -n1)
                  [ -x "$t3" ] || t3=$(command -v t3 || true)
                  [ -n "$t3" ] || { echo "t3 not found; add the t3code kit"; exit 0; }
                  out=$("$t3" project add --title "$(basename "$dir")" "$dir" 2>&1) && { echo "Added T3 project for $dir"; exit 0; }
                  case "$out" in
                    *ProjectAlreadyExistsError*) echo "T3 project for $dir already exists" ;;
                    *) printf '%s\n' "$out" >&2; exit 1 ;;
                  esac
              description: Register the workspace as a T3 Code project
              env:
                - WORKSPACE_DIR