Skip to content

feat(please-plugins): add monorepo workspace dependency scanning#133

Merged
amondnet merged 6 commits intomainfrom
amondnet/branch-process
Mar 29, 2026
Merged

feat(please-plugins): add monorepo workspace dependency scanning#133
amondnet merged 6 commits intomainfrom
amondnet/branch-process

Conversation

@amondnet
Copy link
Copy Markdown
Contributor

@amondnet amondnet commented Mar 29, 2026

Summary

  • Add workspace resolution for npm/yarn/Bun workspaces field and pnpm-workspace.yaml
  • Aggregate dependencies from all workspace packages before plugin detection
  • Enhance source tracking to show workspace path prefix (e.g., apps/web: @nuxt/ui)
  • Integrate into both scanForSetup() and SessionStart hook

Test plan

  • 62 tests passing (46 existing + 16 new)
  • Workspace resolution tests for npm, pnpm, yarn formats
  • Dependency aggregation with root priority
  • Backward compatibility for non-monorepo projects

Closes #132

Verification Checklist

  • resolveWorkspacePackages resolves npm/yarn/Bun workspaces glob patterns to directory paths
  • resolveWorkspacePackages resolves pnpm-workspace.yaml patterns to directory paths
  • resolveWorkspacePackages returns empty array when no workspaces configured
  • collectAllDependencies merges deps from root + workspace packages
  • collectAllDependencies skips missing/malformed workspace package.json
  • scanForSetup detects plugins from workspace dependencies
  • Source field shows workspace path prefix for workspace-origin deps
  • Non-monorepo projects continue to work unchanged

Add resolveWorkspacePackages() and collectAllDependencies() to scan
workspace package.json files in monorepos. Supports npm/yarn/Bun
workspaces field and pnpm-workspace.yaml. Integrates into both
scanForSetup() and detectForEvent() with workspace-aware source
tracking (e.g., "apps/web: @nuxt/ui").

Closes #132
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
claude-code-plugins Ready Ready Preview, Comment Mar 29, 2026 7:50am

Request Review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements monorepo workspace dependency scanning by aggregating dependencies from all workspace packages defined in package.json or pnpm-workspace.yaml. The changes update the detection logic to attribute dependencies to their specific workspace paths. Feedback highlights several improvement opportunities: the custom glob resolution should be replaced with a standard library like Bun.Glob for better robustness, the manual YAML parsing for pnpm-workspace.yaml should be made more resilient, resolved workspace paths should be deduplicated, and test assertions should be more precise regarding expected directory counts and negation patterns.

Comment thread plugins/please-plugins/hooks/check-dependencies.ts Outdated
Comment thread plugins/please-plugins/hooks/check-dependencies.test.ts Outdated
Comment thread plugins/please-plugins/hooks/check-dependencies.test.ts Outdated
Comment thread plugins/please-plugins/hooks/check-dependencies.ts Outdated
Move resolveWorkspacePackages, collectAllDependencies, and
resolveGlobPatterns to workspace-resolver.ts to keep
check-dependencies.ts under 500 LOC guideline.
@amondnet amondnet marked this pull request as ready for review March 29, 2026 07:20
@amondnet amondnet mentioned this pull request Mar 29, 2026
12 tasks
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 7 files

Confidence score: 3/5

  • There is a concrete regression risk in plugins/please-plugins/hooks/workspace-resolver.ts: glob resolution stops processing after the first *, which can misresolve non-trivial workspace patterns to the wrong directories.
  • Given the issue’s medium severity (6/10) and high confidence (8/10), this introduces user-facing behavior risk in workspace discovery, so this is not fully low-risk to merge yet.
  • Pay close attention to plugins/please-plugins/hooks/workspace-resolver.ts - wildcard parsing may produce incorrect directory matches for complex patterns.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="plugins/please-plugins/hooks/workspace-resolver.ts">

<violation number="1" location="plugins/please-plugins/hooks/workspace-resolver.ts:49">
P2: Glob resolution ignores everything after the first `*`, so non-trivial workspace patterns can match the wrong directories.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant UI as CLI / Hook Trigger
    participant Scanner as check-dependencies.ts
    participant Resolver as NEW: workspace-resolver.ts
    participant FS as File System
    participant Maps as Plugin Mappings

    UI->>Scanner: scanForSetup(cwd) or detectForEvent()
    
    Scanner->>Resolver: NEW: collectAllDependencies(cwd)
    
    Resolver->>FS: loadPackageJson(root)
    FS-->>Resolver: root dependencies
    
    Resolver->>Resolver: NEW: resolveWorkspacePackages()
    
    alt npm / yarn / Bun
        Resolver->>Resolver: Parse "workspaces" glob patterns
    else pnpm
        Resolver->>FS: NEW: Read pnpm-workspace.yaml
        FS-->>Resolver: yaml patterns
    end

    Resolver->>FS: NEW: resolveGlobPatterns (readdirSync)
    
    loop For each resolved workspace directory
        Resolver->>FS: loadPackageJson(workspaceDir)
        alt Valid package.json
            FS-->>Resolver: workspace dependencies
            Resolver->>Resolver: NEW: Aggregate unique dependencies
            Resolver->>Resolver: NEW: Map dep to workspace source path
        else Missing or Malformed
            FS-->>Resolver: null / skip
        end
    end
    
    Resolver-->>Scanner: Return AggregatedDeps (deps + sources map)

    Scanner->>Maps: Load static mappings
    
    Scanner->>Scanner: CHANGED: detectPackages() using aggregated deps
    
    Scanner->>Scanner: NEW: resolvePackageSource()
    Note over Scanner: If dep found in workspace map,<br/>prefix source with path (e.g. "apps/web: @nuxt/ui")
    
    Scanner-->>UI: Return SetupOutput (Detected plugins with attribution)
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread plugins/please-plugins/hooks/workspace-resolver.ts Outdated
@amondnet amondnet self-assigned this Mar 29, 2026
- Replace custom glob resolver with Bun.Glob for accurate multi-segment
  pattern matching (fixes patterns like "apps/*/src" truncation bug)
- Deduplicate resolved workspace paths to avoid duplicate entries when
  npm workspaces and pnpm-workspace.yaml share the same patterns
- Improve pnpm-workspace.yaml parsing to handle inline comments and
  more robust top-level key detection
- Tighten test assertions for deduplication (exact length 1) and
  negation patterns (exact length 2 with both expected dirs)
@amondnet amondnet merged commit 3d824e1 into main Mar 29, 2026
7 checks passed
@amondnet amondnet deleted the amondnet/branch-process branch March 29, 2026 07:53
@pleaeai-bot pleaeai-bot Bot mentioned this pull request Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

track: setup-monorepo-scan-20260329

1 participant