Skip to content

Greenfield detection activates plugin for all empty directories, ignoring Vercel markers #81

@SmartBuild-ai

Description

@SmartBuild-ai

Bug Description

The Vercel plugin's session-start-profiler.mjs and inject-claude-md.mjs hooks activate for any empty directory, even when the directory has no relation to Vercel. The greenfield detection bypasses the Vercel-specific activation marker check.

Root Cause

In session-start-activation.mjs, isGreenfieldDirectory() returns true for any directory without non-dot files:

function isGreenfieldDirectory(projectRoot) {
  const hasNonDotDir = dirents.some(d => !d.name.startsWith("."));
  const hasDotFile = dirents.some(d => d.name.startsWith(".") && d.isFile());
  return !hasNonDotDir && !hasDotFile;
}

Then in session-start-profiler.mjs:413:

const shouldActivate = greenfield !== null || !existsSync(projectRoot) || hasSessionStartActivationMarkers(projectRoot);

The greenfield !== null check comes before hasSessionStartActivationMarkers, so any empty directory activates the plugin regardless of whether it's a Vercel project.

Same in inject-claude-md.mjs:65:

const shouldActivate = isGreenfield || greenfieldOverride || ...

Impact

  • Non-Vercel empty directories get Vercel-specific context injected ("greenfield execution mode", "skip exploration", Vercel CLI install recommendations)
  • This happens even when the plugin is disabled via enabledPlugins: false (separate Claude Code bug)
  • Pollutes the conversation context with irrelevant Vercel guidance
  • Default skills are set to ["nextjs", "ai-sdk", "vercel-cli", "env-vars"] for ANY empty folder

Suggested Fix

The greenfield check should be combined with the activation marker check, not bypass it. If a directory is empty AND there are no Vercel signals, the plugin should not activate.

// Option: only treat as greenfield if there's at least one Vercel signal
const shouldActivate = hasSessionStartActivationMarkers(projectRoot) 
  || (greenfield !== null && hasVercelSignal(projectRoot));

Or at minimum, respect the enabledPlugins setting before running any hook logic.

Environment

  • Platform: Windows 10 Pro
  • Plugin version: 0.40.0
  • Claude Code: latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions