Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 12, 2025

Problem

When running pnpm exec @db-ux/agent-cli, the tool would not detect or process @db-ux packages, leaving the .github/copilot-instructions.md file empty or unchanged. This was because pnpm uses a unique node_modules structure with symlinks to manage dependencies efficiently, and the CLI was not following these symlinks.

Root Cause

The issue stemmed from using Node.js's Dirent.isDirectory() method, which returns false for symlinks even when they point to directories. In pnpm's structure, packages in node_modules/@db-ux/ are symlinks to the actual package locations in .pnpm/, so they were being skipped:

node_modules/@db-ux/
├── core-components -> ../../.pnpm/@[email protected]/node_modules/@db-ux/core-components
└── foundations -> ../../.pnpm/@[email protected]/node_modules/@db-ux/foundations

Solution

Modified the code to use fs.statSync() instead of Dirent.isDirectory(). The statSync() method follows symlinks by default, correctly identifying symlinked directories:

  1. Updated findAllNodeModulesDirectories() - Now uses fs.statSync() to detect directories while following symlinks
  2. Updated package detection in generateCopilot() - Now uses fs.statSync() for package directory detection
  3. Added error handling - Wrapped in try-catch blocks to gracefully skip inaccessible paths or broken symlinks

Testing

  • Added comprehensive test case with realistic pnpm symlink structure
  • All existing tests continue to pass
  • Verified with manual end-to-end tests using actual pnpm installations
  • Tested graceful handling of broken symlinks

Compatibility

This fix maintains full backward compatibility with npm and yarn while adding pnpm support. The tool now works seamlessly with all major Node.js package managers.

Documentation

Updated README.md with pnpm usage example and added a note about package manager compatibility.

Fixes #[issue-number]

Original prompt

This section details on the original issue you should resolve

<issue_title>@db-ux/agent-cli doesn't work with pnpm</issue_title>
<issue_description>### Which generators are affected?

  • All
  • HTML
  • React
  • Angular
  • Vue
  • Web components
  • Power Apps

Reproduction case

When running pnpm exec @db-ux/agent-cli with pnpm there wouldn't be an update to my .github/instructions.md file, as pnpm doesn't seem to be able to resolve the symlinks within node_modules folder provided.

Expected Behaviour

I would get an update to my projects .github/instructions.md after running pnpm exec @db-ux/agent-cli with pnpm.

Screenshots

No response

Browser version

None

Add any other context about the problem here.

No response

Which DB business unit do you work for?

DB Systel GmbH (please name your customer below)

”DB Systel” please enter your customer / ”other” please enter your area or business unit.

DB UX Design System

What project are you working on?

DB UX Design System</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #5202


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot
Copy link

changeset-bot bot commented Oct 12, 2025

⚠️ No Changeset found

Latest commit: 402ec19

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI changed the title [WIP] Fix @db-ux/agent-cli for pnpm compatibility fix(agent-cli): add pnpm compatibility by following symlinks in node_modules Oct 12, 2025
Copilot AI requested a review from mfranzke October 12, 2025 09:28
Copilot finished work on behalf of mfranzke October 12, 2025 09:28
@nmerget nmerget moved this from 🏗 In progress to 🎁 Ready for review in UX Engineering Team Backlog Oct 24, 2025
@nmerget nmerget removed the request for review from mfranzke October 24, 2025 10:13
@mfranzke mfranzke moved this from 🎁 Ready for review to 🏗 In progress in UX Engineering Team Backlog Oct 25, 2025
@mfranzke mfranzke moved this from 🏗 In progress to 🎁 Ready for review in UX Engineering Team Backlog Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎁 Ready for review

Development

Successfully merging this pull request may close these issues.

@db-ux/agent-cli doesn't work with pnpm

2 participants