Skip to content

Comments

feat: resolve parent workspace in monorepos workspaces#118

Merged
voxpelli merged 27 commits intomainfrom
copilot/support-local-workspace-monorepo
Feb 9, 2026
Merged

feat: resolve parent workspace in monorepos workspaces#118
voxpelli merged 27 commits intomainfrom
copilot/support-local-workspace-monorepo

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

Implementation Plan for Monorepo Workspace Support

  • Explore repository structure and understand current implementation
  • Research existing npm packages for workspace root detection
  • Identify resolve-workspace-root as the solution
  • Add resolve-workspace-root dependency
  • Implement workspace parent detection in cli.js
  • Test with monorepo scenarios
  • Verify existing functionality still works
  • Run linting and type checking
  • Update documentation
  • Address all code review feedback
  • Run security scan - No issues found
  • Add examples and integration tests with node:test
  • Extract test helpers and improve examples with real errors
  • Address all final code review feedback
  • Ensure all three examples have distinct, non-empty outputs
  • Add test/helpers.js to tsconfig and use explicit test script
  • Fix CI failures on Windows (line endings + helper function)

Summary

Successfully implemented support for running installed-check in a workspace that is part of a larger monorepo, with comprehensive examples demonstrating different validation scenarios and cross-platform test support.

Key Features

  • Automatic parent workspace detection using resolve-workspace-root package
  • Automatic filtering to current workspace to avoid checking entire monorepo
  • Excludes parent workspace root from checks when filtering to specific workspace
  • Works with npm, yarn, pnpm, and bun workspaces
  • Works with both current directory and custom paths
  • --no-parent-workspace flag for explicit opt-out
  • Comprehensive debug logging to stderr
  • 98%+ TypeScript type coverage (all test files included in tsconfig)
  • Modern test infrastructure using node:test
  • Three distinct, realistic examples with different error types
  • Cross-platform tests (Windows + Unix line ending support)

Examples

The examples/ folder contains three distinct demonstrations:

  • basic: Standalone package with meow engine mismatch (requires Node >=20 vs >=18.6.0)
  • monorepo: Monorepo root showing BOTH root's meow issue AND workspace-a's knip issue
  • monorepo/workspace-a: Workspace with knip engine mismatch (requires Node >=18.18.0 vs >=18.6.0), demonstrating that parent's meow issue is correctly excluded

Each example has distinct, non-empty output showcasing different aspects of the tool's functionality.

Tests

Integration tests use:

  • node:test framework with describe/it blocks
  • node:assert/strict for assertions
  • unified/remark for README-driven testing
  • Extracted helpers in test/helpers.js and test/test-readme.js
  • Cross-platform support with normalized line endings

Run with: npm test or npm run test:integration

Security Summary

CodeQL scan completed with no vulnerabilities found.

Original prompt

This section details on the original issue you should resolve

<issue_title>Support running locally in a workspace when part of monorepo</issue_title>
<issue_description>Follow up to #31:

When using eg. git subtree one will have a full test setup with installed-check etc within individual workspaces, which when run currently complains that it can't find the modules hosted to the top level of the monorepo.

We should by default detect if the folder is a workspace in a larger monorepo and if such look into that monorepo's node_modules as well.

This may require extending https://github.com/voxpelli/read-workspaces and/or creating/finding a companion module to it that is something like find-workspace-parent or such</issue_description>

<agent_instructions>If you create the new functionality needed within this module, then prepare for it to be extracted. Use deepwiki, tavily and context7 to find pre-existing modules that we can use, to avoid the not-invented-here syndrome</agent_instructions>

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


💡 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.

Copilot AI and others added 4 commits February 9, 2026 13:28
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
…ix typo

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for running locally in a workspace of a monorepo Support parent workspace node_modules in nested monorepos Feb 9, 2026
Copilot AI requested a review from voxpelli February 9, 2026 13:40
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 9, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/byCedric/resolve-workspace-root/issues
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

…ateWorkspaceRoot

Remove the complex nested workspace detection logic as it's an edge case
that can be added back if requested. This simplifies the code significantly
by removing lib/utils.js and using resolve-workspace-root directly.

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Copilot AI changed the title Support parent workspace node_modules in nested monorepos Support parent workspace node_modules in monorepos Feb 9, 2026
Copilot AI requested a review from voxpelli February 9, 2026 14:01
@voxpelli voxpelli changed the title Support parent workspace node_modules in monorepos feat: resolve parent workspace in monorepos workspaces Feb 9, 2026
… logic

- Add --no-parent-workspace flag to explicitly opt out of parent workspace detection
- Only detect parent workspace when no incompatible flags are set:
  - Skip if user provided explicit workspace filters (--workspace)
  - Skip if user provided custom cwd path as argument
  - Skip if --no-parent-workspace flag is used
- Update README with new flag documentation and conditions for automatic detection

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Copilot AI changed the title feat: resolve parent workspace in monorepos workspaces Support parent workspace node_modules in monorepos Feb 9, 2026
Copilot AI requested a review from voxpelli February 9, 2026 14:15
- Log when attempting to resolve parent workspace root
- Log whether a parent workspace was found and its path
- Log when parent workspace detection is skipped and why
- Fix parentWorkspace flag to work correctly with --no- prefix
  (changed from noParentWorkspace:false to parentWorkspace:true)

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Copy link
Owner

@voxpelli voxpelli left a comment

Choose a reason for hiding this comment

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

@copilot Also mention the example’s in the main readme and link to their readmes

Copilot AI and others added 3 commits February 9, 2026 20:19
- Add Examples section to README.md with links to all example READMEs
- Update basic example to demonstrate engine range validation error
  - Changed meow dependency to ^14.0.0 (requires Node >=20)
  - Package specifies >=18.6.0, creating intentional mismatch
  - Updated README with correct expected output
- Update monorepo example with root-level dependency issue
  - Added meow@^14.0.0 to root package.json
  - Issue appears when running from monorepo root
  - Issue excluded when running from workspace-a (includeWorkspaceRoot: false)
  - Updated both READMEs with correct expected outputs
- Refactor test/integration.js to use Node.js test runner
  - Replace custom assert/test functions with node:assert/strict and node:test
  - Wrap all tests in describe() and it() blocks
  - Extract run() helper to test/helpers.js for reuse
- Update package.json scripts
  - Change test script to: "test": "run-s check test:**"
  - Update test:integration to use --test flag
  - Update test-ci to: "run-s test:**"

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Change test:** to test:* to properly match test scripts like test:integration and test:examples:install
Explicitly list scripts in test-ci instead of using test:* pattern to prevent matching itself
Copy link
Contributor Author

Copilot AI commented Feb 9, 2026

@copilot Also mention the example’s in the main readme and link to their readmes

Added in commit 4c7f990. The main README now has an "Examples" section that links to all example READMEs:

  • examples/basic/README.md
  • examples/monorepo/README.md
  • examples/monorepo/packages/workspace-a/README.md

- Use assert.ok(val !== undefined) instead of assert.notEqual(val, undefined)
- Add .trim() to normalize whitespace in output comparisons
- All integration tests now pass consistently

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Copilot AI requested a review from voxpelli February 9, 2026 20:30
- basic: meow engine mismatch (requires Node >=20, package specifies >=18.6.0)
- monorepo root: shows both root's meow issue AND workspace-a's knip issue
- workspace-a: knip engine mismatch (requires Node >=18.18.0, package specifies >=18.6.0)
  - Demonstrates that parent's meow issue is excluded due to includeWorkspaceRoot: false

All three examples now have non-empty, different outputs that demonstrate
distinct aspects of the tool's functionality.

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Copilot AI requested a review from voxpelli February 9, 2026 21:38
- Add test/helpers.js to tsconfig.json files array for type checking
- Revert test script from wildcard "test:*" to explicit "test:examples:install test:integration"
  This ensures tests run in the correct order and are more explicit

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Copilot AI requested a review from voxpelli February 9, 2026 21:50
@voxpelli voxpelli changed the title Support parent workspace node_modules in monorepos feat: resolve parent workspace in monorepos workspaces Feb 9, 2026
@voxpelli
Copy link
Owner

voxpelli commented Feb 9, 2026

@copilot Figure our why CI is failing :/

Copilot AI and others added 2 commits February 9, 2026 22:20
…ture

- Normalize Windows CRLF line endings to Unix LF in test output comparison
- Fix run() helper function to accept options object instead of string cwd
  This was causing tests to fail because the function signature didn't match usage

These fixes resolve the Windows CI test failures where tests were failing due to:
1. Line ending differences between Windows (CRLF) and Unix (LF)
2. Incorrect function signature causing commands to fail silently

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
…ture

- Normalize Windows CRLF line endings to Unix LF in test output comparison
- Fix run() helper function to accept both string cwd and options object
  This was causing tests to fail because the function signature didn't match usage

These fixes resolve the Windows CI test failures where tests were failing due to:
1. Line ending differences between Windows (CRLF) and Unix (LF)
2. Incorrect function signature causing commands to fail silently

Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 9, 2026

@copilot Figure our why CI is failing :/

Fixed in commit 463880e. The CI was failing on Windows due to:

  1. Line ending differences: Windows uses CRLF (\r\n) while Unix uses LF (\n). Added normalization in normalizeOutput() to convert all CRLF to LF before comparison.

  2. Helper function signature mismatch: The run() helper was expecting an options object but some call sites were passing a string cwd. Updated the function to accept both string | {cwd: string} for flexibility.

All integration tests now pass on both Unix and Windows platforms.

@voxpelli voxpelli merged commit c386a56 into main Feb 9, 2026
14 checks passed
@voxpelli voxpelli deleted the copilot/support-local-workspace-monorepo branch February 9, 2026 22:33
@vp-helper vp-helper bot mentioned this pull request Feb 10, 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.

Support running locally in a workspace when part of monorepo

2 participants