Skip to content

fix(please-plugins): setup command fails to find root package.json#130

Merged
amondnet merged 7 commits intomainfrom
amondnet/guttural-catboat
Mar 29, 2026
Merged

fix(please-plugins): setup command fails to find root package.json#130
amondnet merged 7 commits intomainfrom
amondnet/guttural-catboat

Conversation

@amondnet
Copy link
Copy Markdown
Contributor

@amondnet amondnet commented Mar 29, 2026

Summary

  • Add --setup CLI mode to check-dependencies.ts with scanForSetup() function that outputs structured JSON
  • Rewrite setup.md command to delegate dependency scanning to the script instead of ambiguous LLM prose instructions
  • Eliminates Glob truncation bug where node_modules/ entries buried root package.json

Test plan

  • 46 unit tests pass (7 new for scanForSetup)
  • Manual verification: --setup correctly detects plugins in project with node_modules/
  • End-to-end: invoke /please-plugins:setup in a real project

Closes #129


Summary by cubic

Fixes the setup command not finding the root package.json by delegating dependency scanning to a new --setup mode in check-dependencies.ts. Also refactors scanForSetup() to reuse detection helpers and annotate sources cleanly. Fixes #129.

  • New Features

    • Added scanForSetup() and a --setup CLI mode in check-dependencies.ts that outputs JSON { detected, installed } with source info.
    • setup.md now invokes bun run "${CLAUDE_PLUGIN_ROOT}/hooks/check-dependencies.ts" --setup and parses the JSON for selection.
  • Refactors

    • scanForSetup() now reuses detectPackages() and detectTooling() with resolvePackageSource() and resolveToolingSource() helpers to deduplicate and label sources.

Written for commit 1f1573e. Summary will update on new commits.

Add bugfix track for setup command failing to find root package.json
due to Glob result truncation by node_modules entries. Plan: delegate
dependency scanning to check-dependencies.ts via --setup CLI mode.

Refs: #129
Add scanForSetup() function that outputs structured JSON with detected
plugins and their source packages/files, separated by install status.
Update main() to handle --setup flag bypassing stdin hook protocol.

Refs: #129
Replace ambiguous LLM prose instructions with direct script invocation
of check-dependencies.ts --setup. Eliminates Glob truncation bug where
node_modules entries buried the root package.json.

Refs: #129
All 9 tasks completed. Tests pass (46/46). Manual verification confirms
setup --setup mode correctly finds root package.json in project with
node_modules/.

Refs: #129
@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:00am

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 addresses a bug where the setup command failed to find the root package.json in projects with large node_modules directories. The fix involves delegating dependency scanning to a new --setup CLI mode in the check-dependencies.ts script, which uses direct path construction instead of ambiguous glob patterns. The setup.md command was rewritten to utilize this script and parse its JSON output. A review comment suggests refactoring scanForSetup to reduce logic duplication with existing detection functions and improve maintainability.

Comment thread plugins/please-plugins/hooks/check-dependencies.ts Outdated
- Use ESM import for mkdirSync instead of require() in test
- Remove redundant truthiness check on loadEnabledPlugins result

Refs: #129
@amondnet amondnet marked this pull request as ready for review March 29, 2026 06:56
@amondnet amondnet added the type:bug Something isn't working label Mar 29, 2026
@amondnet amondnet self-assigned this Mar 29, 2026
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.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant User as End User
    participant Claude as Claude Code (Runtime)
    participant Script as check-dependencies.ts
    participant FS as Local Filesystem

    Note over Claude, FS: NEW: Script-Delegated Setup Flow

    User->>Claude: /please-plugins:setup
    Claude->>Script: NEW: bun run check-dependencies.ts --setup
    
    activate Script
    Script->>FS: CHANGED: Load root package.json (Direct Path)
    FS-->>Script: JSON content
    
    Script->>FS: Scan for tooling indicators (lockfiles, configs)
    Note right of Script: Avoids Glob truncation bugs
    
    Script->>FS: Read .claude/settings.json
    FS-->>Script: Enabled plugins list
    
    Script->>Script: NEW: Map dependencies to plugin-mappings.json
    
    alt Scan Successful
        Script-->>Claude: NEW: Return JSON {detected, installed}
    else Scan Failed (e.g. no package.json)
        Script-->>Claude: Exit code 1 + Error message
        Claude->>User: Inform error and stop
    end
    deactivate Script

    alt No matching plugins
        Claude->>User: "No matching plugins found"
    else Plugins found
        Claude->>User: NEW: AskUserQuestion (Multi-select)
        User-->>Claude: Selected plugins to install
        
        loop for each selected plugin
            Claude->>Claude: claude plugin install {pluginName}@pleaseai
        end
        
        Claude->>User: Final summary of installations
    end
Loading

…ng detectPackages/detectTooling

Extract resolvePackageSource and resolveToolingSource helpers to annotate
detection results with source info, so scanForSetup can delegate all
detection logic to the existing functions rather than duplicating it.
@amondnet amondnet merged commit ff798ee into main Mar 29, 2026
7 checks passed
@amondnet amondnet deleted the amondnet/guttural-catboat branch March 29, 2026 07:02
@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

type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: setup command fails to find root package.json due to Glob truncation

1 participant