chore: Gate codespace agent session launch on the skills plugin install finishing (#36237)

Co-authored-by: n8n-cat-bot[bot] <n8n-cat-bot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
n8n-cat-bot[bot]
2026-08-13 16:10:55 +00:00
committed by GitHub
parent 077370ff56
commit 4c02c54c61
+12 -1
View File
@@ -73,15 +73,26 @@ const SECRETS = '. /usr/local/lib/codespaces-env.sh 2>/dev/null || true';
// Worktrees share the pnpm store but not the turbo cache; a shared TURBO_CACHE_DIR
// (seeded from the main checkout) keeps new-worktree builds at cache-hit speed.
const CACHE = 'export TURBO_CACHE_DIR=/workspaces/.turbo-cache; [ -d "$TURBO_CACHE_DIR" ] || cp -r /workspaces/n8n/.turbo/cache "$TURBO_CACHE_DIR" 2>/dev/null || mkdir -p "$TURBO_CACHE_DIR"';
// On a freshly created codespace, post-start.mjs installs the skills plugin via a
// network clone that takes tens of seconds. If `claude` boots first it builds its
// skill registry before the plugin exists on disk, and /reload-plugins can't
// recover it in-process — so the first session silently loses every quality skill.
// Run the idempotent install here to block until the plugin is on disk (a fast
// no-op once cached). Mirrors the env vars post-start.mjs sets for the private
// HTTPS clone; failures are tolerated so a plugin hiccup never blocks the session.
const MARKETPLACE = 'n8n-io/n8n-claude-skills';
const PLUGIN = 'quality@n8n-claude-skills';
const ENSURE_PLUGIN = `export CLAUDE_CODE_PLUGIN_PREFER_HTTPS=1 CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE=1; claude plugin marketplace add ${MARKETPLACE} >/dev/null 2>&1 || true; claude plugin install ${PLUGIN} >/dev/null 2>&1 || true`;
function remoteCommand(session, extraArgs) {
const claude = `claude ${extraArgs}`.trim();
if (session === 'agent') return `${SECRETS}; ${CACHE}; cd /workspaces/n8n && ${claude}`;
if (session === 'agent') return `${SECRETS}; ${CACHE}; ${ENSURE_PLUGIN}; cd /workspaces/n8n && ${claude}`;
const wt = `/workspaces/wt-${session}`;
const branch = `session/${session}`;
return [
SECRETS,
CACHE,
ENSURE_PLUGIN,
`if [ ! -d "${wt}" ]; then echo "Setting up worktree ${wt}…"`,
`git -C /workspaces/n8n worktree add "${wt}" -b "${branch}" 2>/dev/null || git -C /workspaces/n8n worktree add "${wt}" "${branch}"`,
`(cd "${wt}" && pnpm install); fi`,