Skip to content

Conversation

@luxass
Copy link
Member

@luxass luxass commented Jan 10, 2026

🔗 Linked issue

📚 Description

This PR implements some general improvements. Mostly around filtering since we have made some changes to paths recently.

Summary by CodeRabbit

  • New Features

    • Added path normalization utilities to improve filtering and matching of file paths.
  • Bug Fixes

    • Removed a noisy CLI lockfile log to reduce output.
    • Made path matching and in-memory filesystem paths consistent (leading/trailing slash handling).
    • Stopped appending a trailing newline and emitting a content-warning header in mock file responses.
  • Tests

    • Added and updated tests to cover normalized path behaviors and tree structures.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 10, 2026

⚠️ No Changeset found

Latest commit: e77d460

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.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 10, 2026

📝 Walkthrough

Walkthrough

Adds path normalization utilities and applies normalized path handling across filtering, shared exports, test utilities, and tests; removes a noisy runtime log and stops appending a trailing newline in a mock file handler.

Changes

Cohort / File(s) Summary
Path normalization utilities & exports
packages/shared/src/files.ts, packages/shared/src/index.ts
Adds normalizePathForFiltering(version, rawPath) and normalizeTreeForFiltering(version, entries) and re-exports them from the shared package index.
Filter logic updates
packages/shared/src/filter.ts
Adds normalization helpers, normalizes include/exclude patterns and input paths before matching, and expands normalized exclude patterns for matching.
Shared tests
packages/shared/test/files.test.ts, packages/shared/test/filter.test.ts
Adds tests for the new normalization utilities and updates filter tests to expect leading-slash path shapes and normalized matching behavior.
Memory FS bridge path formatting
packages/test-utils/src/fs-bridges/memory-fs-bridge.ts, packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
Introduces formatEntryPath() to enforce leading slash and trailing slash for directories; updates implementation and tests to use formatted entry paths.
Mock store file handler
packages/test-utils/src/mock-store/handlers/files.ts
Removes logic that appended a trailing newline to file content and the associated X-Content-Warning header; uses a constant for content extraction.
CLI minor cleanup
packages/cli/src/cmd/lockfile/info.ts
Removes a runtime console.error log that printed the store path when reading lockfile info.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~23 minutes

Possibly related PRs

Poem

🐇
I hop the paths from root to leaf,
I trim each slash and quell the grief,
No noisy logs, no extra line,
The trees stand neat in tidy line,
A rabbit clap — the files align!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'refactor: implement general improvements' is overly vague and generic. It uses non-descriptive terms that don't convey meaningful information about the specific changes made to path filtering, normalization, and test utilities. Revise the title to be more specific about the main changes, such as 'refactor: add path normalization for filtering' or 'refactor: improve path handling and filtering logic' to better describe the changeset's primary purpose.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0051a6 and e77d460.

📒 Files selected for processing (1)
  • packages/shared/test/filter.test.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{test,spec}.?(c|m)[jt]s?(x)

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.?(c|m)[jt]s?(x): Use test file pattern: **/.{test,spec}.?(c|m)[jt]s?(x)
Import test utilities from path aliases (#test-utils/
, #internal/test-utils/conditions) rather than @ucdjs/test-utils to avoid build dependencies and cyclic dependency issues
Use mockStoreApi() utility from #test-utils/mock-store with MSW-based mocking for UCD API
Use testdir() from vitest-testdirs to create temporary test directories for filesystem testing

Files:

  • packages/shared/test/filter.test.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: luxass
Repo: ucdjs/ucd PR: 20
File: packages/ucd-store/test/index.test.ts:1-7
Timestamp: 2025-05-31T07:44:02.123Z
Learning: User luxass prefers to implement functionality in separate PRs rather than including everything in a single large PR, keeping changes focused and manageable.
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-08T03:33:34.184Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Import test utilities from path aliases (#test-utils/*, #internal/test-utils/conditions) rather than ucdjs/test-utils to avoid build dependencies and cyclic dependency issues
📚 Learning: 2025-06-09T05:10:32.105Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 45
File: packages/ucd-store/src/download.ts:24-24
Timestamp: 2025-06-09T05:10:32.105Z
Learning: In the ucd-store package refactor, picomatch was moved from direct usage in download.ts to internal usage within the createPathFilter function in filter.ts. The pattern format is still picomatch-compatible, so JSDoc comments referencing picomatch pattern format remain correct.

Applied to files:

  • packages/shared/test/filter.test.ts
📚 Learning: 2026-01-08T03:33:34.184Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-08T03:33:34.184Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Import test utilities from path aliases (#test-utils/*, #internal/test-utils/conditions) rather than ucdjs/test-utils to avoid build dependencies and cyclic dependency issues

Applied to files:

  • packages/shared/test/filter.test.ts
📚 Learning: 2025-05-04T11:52:22.858Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 6
File: packages/cli/src/cmd/codegen/fields.ts:68-82
Timestamp: 2025-05-04T11:52:22.858Z
Learning: User prefers to address the issue with Node.js API compatibility (`Dirent.parentPath` not being part of Node's API and the `recursive: true` option for `readdir` being only available in Node 21+) in a separate PR rather than the current one.

Applied to files:

  • packages/shared/test/filter.test.ts
📚 Learning: 2026-01-08T03:33:34.184Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-08T03:33:34.184Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Use test file pattern: **/*.{test,spec}.?(c|m)[jt]s?(x)

Applied to files:

  • packages/shared/test/filter.test.ts
📚 Learning: 2025-06-28T08:01:22.596Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 85
File: packages/fetch/package.json:37-38
Timestamp: 2025-06-28T08:01:22.596Z
Learning: In the ucdjs/ucd project, relative paths in npm scripts within packages (like `../../apps/api/.generated/openapi.json` in packages/fetch/package.json) resolve correctly even when run via Turborepo from the repo root, contrary to initial concerns about working directory changes.

Applied to files:

  • packages/shared/test/filter.test.ts
📚 Learning: 2025-06-14T05:20:20.149Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 56
File: packages/utils/src/ucd-files/validate.ts:115-130
Timestamp: 2025-06-14T05:20:20.149Z
Learning: Node.js 22 supports the `recursive` option in `fs.readdir()` (introduced in Node.js 18.17.0), which returns a flattened string array of all descendant files and directories when `recursive: true` is passed.

Applied to files:

  • packages/shared/test/filter.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: lint
  • GitHub Check: test (macos-latest)
  • GitHub Check: test (windows-latest)
🔇 Additional comments (3)
packages/shared/test/filter.test.ts (3)

38-40: LGTM: Excellent test coverage for leading slash path handling.

These new test cases properly verify that relative patterns (e.g., src/**) correctly match paths with leading slashes after normalization. This aligns well with the PR's focus on path normalization improvements.


96-98: LGTM: Insightful test coverage for directory vs file distinction.

Line 97's test case is particularly valuable—it verifies that a directory path (/src/) correctly fails to match a file-extension-only pattern (**/*.{js,ts,jsx,tsx,vue,svelte}). This confirms the filtering logic properly distinguishes directories from files based on trailing slashes.


684-1033: LGTM: Consistent path normalization in expected outputs.

The systematic updates to expected paths (leading slash for files, leading+trailing for directories) correctly reflect the new normalized path representation. Notably, tests with non-normalized input paths (lines 888-898, 901-954, 1044-1115) preserve the original format in outputs, confirming that normalization occurs during matching rather than output transformation—excellent design choice for maintaining input fidelity.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the pkg: test-utils Changes related to the test-utils package. label Jan 10, 2026
@luxass luxass force-pushed the general-improvements branch from e63019c to 84fb905 Compare January 10, 2026 08:12
@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2026

🌏 Preview Deployments

Application Status Preview URL
API ⏳ In Progress N/A
Website ⏳ In Progress N/A

Built from commit: e77d460e2ffc91eff8bc9d95e45f217d2e102c6d


🤖 This comment will be updated automatically when you push new commits to this PR.

Introduces `normalizePathForFiltering` and `normalizeTreeForFiltering` to standardize file paths and maintain directory structure. Enhances test coverage for these new functionalities.
@luxass luxass marked this pull request as ready for review January 10, 2026 12:30
Copilot AI review requested due to automatic review settings January 10, 2026 12:30
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@github-actions github-actions bot added pkg: cli Changes related to the CLI package. pkg: shared Changes related to the Shared package. labels Jan 10, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @packages/shared/test/files.test.ts:
- Around line 162-285: The test file has two new describe blocks for
normalizePathForFiltering and normalizeTreeForFiltering accidentally nested
inside the preceding it("should match directories with trailing slash", ...)
test; fix this by closing that it block (and its parent
describe("findFileByPath", ...) if needed) before starting the new describe
blocks so describe("normalizePathForFiltering", ...) and
describe("normalizeTreeForFiltering", ...) are top-level (or direct children of
the intended describe); locate the trailing-slash test (the it that references
matching directories with trailing slash) and add the missing closing brace(s)
to terminate the it block (and outer describe if unclosed) so the subsequent
describe blocks are moved out of the it scope.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2634dea and 10028ce.

📒 Files selected for processing (9)
  • packages/cli/src/cmd/lockfile/info.ts
  • packages/shared/src/files.ts
  • packages/shared/src/filter.ts
  • packages/shared/src/index.ts
  • packages/shared/test/files.test.ts
  • packages/shared/test/filter.test.ts
  • packages/test-utils/src/fs-bridges/memory-fs-bridge.ts
  • packages/test-utils/src/mock-store/handlers/files.ts
  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
💤 Files with no reviewable changes (1)
  • packages/cli/src/cmd/lockfile/info.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{test,spec}.?(c|m)[jt]s?(x)

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.?(c|m)[jt]s?(x): Use test file pattern: **/.{test,spec}.?(c|m)[jt]s?(x)
Import test utilities from path aliases (#test-utils/
, #internal/test-utils/conditions) rather than @ucdjs/test-utils to avoid build dependencies and cyclic dependency issues
Use mockStoreApi() utility from #test-utils/mock-store with MSW-based mocking for UCD API
Use testdir() from vitest-testdirs to create temporary test directories for filesystem testing

Files:

  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
  • packages/shared/test/filter.test.ts
  • packages/shared/test/files.test.ts
🧠 Learnings (14)
📓 Common learnings
Learnt from: luxass
Repo: ucdjs/ucd PR: 6
File: packages/cli/src/cmd/codegen/fields.ts:68-82
Timestamp: 2025-05-04T11:52:22.858Z
Learning: User prefers to address the issue with Node.js API compatibility (`Dirent.parentPath` not being part of Node's API and the `recursive: true` option for `readdir` being only available in Node 21+) in a separate PR rather than the current one.
Learnt from: luxass
Repo: ucdjs/ucd PR: 20
File: packages/ucd-store/test/index.test.ts:1-7
Timestamp: 2025-05-31T07:44:02.123Z
Learning: User luxass prefers to implement functionality in separate PRs rather than including everything in a single large PR, keeping changes focused and manageable.
Learnt from: luxass
Repo: ucdjs/ucd PR: 85
File: packages/fetch/package.json:37-38
Timestamp: 2025-06-28T08:01:22.596Z
Learning: In the ucdjs/ucd project, relative paths in npm scripts within packages (like `../../apps/api/.generated/openapi.json` in packages/fetch/package.json) resolve correctly even when run via Turborepo from the repo root, contrary to initial concerns about working directory changes.
📚 Learning: 2025-05-04T11:52:22.858Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 6
File: packages/cli/src/cmd/codegen/fields.ts:68-82
Timestamp: 2025-05-04T11:52:22.858Z
Learning: User prefers to address the issue with Node.js API compatibility (`Dirent.parentPath` not being part of Node's API and the `recursive: true` option for `readdir` being only available in Node 21+) in a separate PR rather than the current one.

Applied to files:

  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
  • packages/shared/src/files.ts
  • packages/shared/src/index.ts
  • packages/test-utils/src/fs-bridges/memory-fs-bridge.ts
  • packages/shared/test/filter.test.ts
  • packages/shared/test/files.test.ts
📚 Learning: 2026-01-08T03:33:34.184Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-08T03:33:34.184Z
Learning: Implement File System Bridge pattern using ucdjs/fs-bridge abstraction layer to support different storage backends (Node.js, HTTP, in-memory)

Applied to files:

  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
  • packages/test-utils/src/fs-bridges/memory-fs-bridge.ts
📚 Learning: 2026-01-08T03:33:34.184Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-08T03:33:34.184Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Import test utilities from path aliases (#test-utils/*, #internal/test-utils/conditions) rather than ucdjs/test-utils to avoid build dependencies and cyclic dependency issues

Applied to files:

  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
  • packages/shared/test/filter.test.ts
  • packages/shared/test/files.test.ts
📚 Learning: 2026-01-08T03:33:34.184Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-08T03:33:34.184Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Use testdir() from vitest-testdirs to create temporary test directories for filesystem testing

Applied to files:

  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
📚 Learning: 2025-06-14T05:20:20.149Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 56
File: packages/utils/src/ucd-files/validate.ts:115-130
Timestamp: 2025-06-14T05:20:20.149Z
Learning: Node.js 22 supports the `recursive` option in `fs.readdir()` (introduced in Node.js 18.17.0), which returns a flattened string array of all descendant files and directories when `recursive: true` is passed.

Applied to files:

  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
  • packages/shared/test/filter.test.ts
📚 Learning: 2025-06-14T05:20:24.527Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 56
File: packages/utils/src/ucd-files/fs-adapter.ts:47-51
Timestamp: 2025-06-14T05:20:24.527Z
Learning: The `recursive` option for `fs.readdir()` was introduced in Node.js v20.1.0 and is available in Node.js 22. When `recursive: true` is passed, it will recursively traverse directories and return all file paths as a flat string array.

Applied to files:

  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
📚 Learning: 2025-06-14T05:20:24.527Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 56
File: packages/utils/src/ucd-files/fs-adapter.ts:47-51
Timestamp: 2025-06-14T05:20:24.527Z
Learning: In Node.js 22, the `recursive` option for `fs.readdir()` is supported and will recursively find all files and return them in a string array when set to true.

Applied to files:

  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
📚 Learning: 2025-07-09T15:05:57.763Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 97
File: packages/utils/src/fs-bridge/node.ts:40-50
Timestamp: 2025-07-09T15:05:57.763Z
Learning: The `parentPath` property on `fs.Dirent` was added in Node.js v20.12, contrary to previous assumptions about it not being part of the Node.js API.

Applied to files:

  • packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts
  • packages/test-utils/src/fs-bridges/memory-fs-bridge.ts
📚 Learning: 2025-06-09T05:10:32.105Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 45
File: packages/ucd-store/src/download.ts:24-24
Timestamp: 2025-06-09T05:10:32.105Z
Learning: In the ucd-store package refactor, picomatch was moved from direct usage in download.ts to internal usage within the createPathFilter function in filter.ts. The pattern format is still picomatch-compatible, so JSDoc comments referencing picomatch pattern format remain correct.

Applied to files:

  • packages/shared/src/files.ts
  • packages/shared/src/index.ts
  • packages/shared/src/filter.ts
  • packages/test-utils/src/mock-store/handlers/files.ts
  • packages/test-utils/src/fs-bridges/memory-fs-bridge.ts
  • packages/shared/test/filter.test.ts
  • packages/shared/test/files.test.ts
📚 Learning: 2026-01-08T03:33:34.184Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-08T03:33:34.184Z
Learning: Applies to apps/api/src/routes/**/*.{ts,tsx} : Organize API routes by version and type: /api/v1/files, /api/v1/versions, /api/v1/schemas, /_tasks, /.well-known/

Applied to files:

  • packages/shared/src/files.ts
📚 Learning: 2025-07-13T09:23:43.820Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 107
File: apps/api/src/routes/v1_files.ts:18-32
Timestamp: 2025-07-13T09:23:43.820Z
Learning: UNICODE_STABLE_VERSION from luxass/unicode-utils-new refers to a specific Unicode version string (not a dynamic value), and the validation logic in the files API correctly checks the normalized version (after "latest" substitution) against UNICODE_VERSION_METADATA rather than the mappedVersion from resolveUCDVersion().

Applied to files:

  • packages/shared/src/files.ts
  • packages/shared/test/files.test.ts
📚 Learning: 2026-01-08T03:33:34.184Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-08T03:33:34.184Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Use test file pattern: **/*.{test,spec}.?(c|m)[jt]s?(x)

Applied to files:

  • packages/shared/test/filter.test.ts
📚 Learning: 2025-06-28T08:01:22.596Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 85
File: packages/fetch/package.json:37-38
Timestamp: 2025-06-28T08:01:22.596Z
Learning: In the ucdjs/ucd project, relative paths in npm scripts within packages (like `../../apps/api/.generated/openapi.json` in packages/fetch/package.json) resolve correctly even when run via Turborepo from the repo root, contrary to initial concerns about working directory changes.

Applied to files:

  • packages/shared/test/filter.test.ts
🧬 Code graph analysis (4)
packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts (1)
tooling/moonbeam/src/esm-loader.mjs (1)
  • entries (44-44)
packages/shared/src/files.ts (2)
packages/shared/src/index.ts (2)
  • normalizePathForFiltering (8-8)
  • normalizeTreeForFiltering (8-8)
tooling/moonbeam/src/esm-loader.mjs (1)
  • entries (44-44)
packages/shared/test/filter.test.ts (4)
packages/shared/src/filter.ts (1)
  • filterTreeStructure (229-235)
packages/shared/src/index.ts (1)
  • filterTreeStructure (13-13)
packages/utils/src/index.ts (1)
  • filterTreeStructure (1-1)
packages/ucd-store/src/store.ts (1)
  • tree (165-167)
packages/shared/test/files.test.ts (1)
packages/shared/src/files.ts (2)
  • normalizePathForFiltering (26-42)
  • normalizeTreeForFiltering (63-83)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: typecheck
  • GitHub Check: lint
  • GitHub Check: Agent
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test (windows-latest)
  • GitHub Check: test (macos-latest)
🔇 Additional comments (11)
packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts (1)

136-241: LGTM! Path normalization applied consistently.

The test expectations have been correctly updated to use absolute paths with leading slashes for all entries and trailing slashes for directories. This aligns with the PR's path normalization objectives.

packages/shared/test/filter.test.ts (2)

38-40: Good coverage for leading-slash path handling.

The new test cases verify that filters correctly handle paths with leading slashes, ensuring compatibility with the normalized path format.


684-750: LGTM! Test expectations updated for normalized paths.

All path values in the tree structure assertions now use absolute paths with leading slashes, consistent with the path normalization approach introduced in this PR.

packages/shared/src/index.ts (1)

8-8: LGTM! Public API extended with normalization utilities.

The new exports (normalizePathForFiltering and normalizeTreeForFiltering) appropriately extend the public API surface to expose the path normalization functionality introduced in this PR.

packages/test-utils/src/mock-store/handlers/files.ts (1)

144-159: No evidence found of the described changes.

The review comment references removal of trailing newline appending and an X-Content-Warning header, but neither exist in the codebase. A comprehensive search found no references to X-Content-Warning anywhere in the repository, and the current implementation at lines 144-159 simply returns content without modification. The test suite (files.test.ts) contains no checks for these headers or trailing newline behavior. This appears to be an incorrect or outdated comment that does not reflect the actual code changes.

Likely an incorrect or invalid review comment.

packages/shared/src/filter.ts (2)

144-168: LGTM! Well-designed path normalization helpers.

The normalizeForMatching and normalizePatterns functions provide clean, consistent path normalization for cross-platform glob matching. The logic correctly handles:

  • Platform-specific separators (backslash → forward slash)
  • Relative path prefixes (./)
  • Leading slashes (for relative pattern matching)
  • Trailing slashes (for directory patterns)

Applying the same normalization to both patterns and input paths ensures matching behavior is consistent regardless of path format.


182-196: Consistent application of normalization throughout the filter pipeline.

The normalization is correctly applied at all key points:

  1. Include and exclude patterns are normalized before use
  2. Input paths are normalized before matching
  3. Directory pattern expansion operates on normalized patterns

This ensures the picomatch engine receives consistently formatted inputs.

packages/shared/src/files.ts (2)

44-83: Clean recursive tree normalization implementation.

The normalizeTreeForFiltering function correctly:

  • Recursively processes all nodes in the tree
  • Preserves the structure (including children for directories)
  • Applies path normalization consistently

The implementation handles both files and directories appropriately, and the documentation clearly explains the purpose and usage.


5-42: Clean implementation of path normalization with excellent test coverage.

The normalizePathForFiltering function correctly handles version-relative path normalization across different Unicode versions. Tests confirm that hasUCDFolderPath properly determines which versions include the "ucd/" folder in their structure—verified with versions 1.1.0 (no "ucd/" folder), 16.0.0, and 17.0.0 (both with "ucd/" folders). The function handles all edge cases: leading/trailing slashes, version prefixes, conditional "ucd/" stripping, and already-normalized paths. The recursive normalizeTreeForFiltering implementation preserves tree structure while normalizing all paths, making it suitable for filter pattern matching.

packages/test-utils/src/fs-bridges/memory-fs-bridge.ts (2)

16-24: Simple and effective path formatting helper.

The formatEntryPath function clearly documents and implements FSEntry schema requirements:

  • Leading slash for all paths (parity with node/http bridges)
  • Trailing slash for directories

The implementation is straightforward and uses well-tested utilities from @luxass/utils/path.


209-293: Consistent application of path formatting across all entry points.

The formatEntryPath helper is correctly applied in all locations where FSEntry objects are created:

  • Non-recursive directory entries (lines 209, 261)
  • Recursive nested directories (lines 230, 293)
  • File entries (lines 251, 281)

This ensures all paths returned from the memory FS bridge conform to the FSEntry schema consistently.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements general improvements focused on path normalization consistency across the codebase. The changes standardize path formatting in file system operations to ensure leading slashes for all paths and trailing slashes for directories, bringing the memory-fs-bridge implementation in line with node/http bridges.

Changes:

  • Standardized path formatting in memory-fs-bridge to use leading/trailing slashes consistently
  • Added path normalization utilities for filtering operations to handle version-prefixed paths
  • Enhanced path filter to handle absolute paths (with leading slashes) matching relative glob patterns
  • Removed unnecessary newline addition logic from mock store file handler

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/test-utils/src/fs-bridges/memory-fs-bridge.ts Added formatEntryPath helper to ensure consistent path formatting with leading/trailing slashes
packages/test-utils/test/fs-bridge/memory-fs-bridge.test.ts Updated test expectations to reflect new path format with leading slashes and trailing slashes for directories
packages/test-utils/src/mock-store/handlers/files.ts Removed automatic newline addition logic and related warning header
packages/shared/src/filter.ts Added normalizeForMatching and normalizePatterns to strip leading slashes and normalize paths for pattern matching
packages/shared/src/files.ts Added normalizePathForFiltering and normalizeTreeForFiltering utilities to strip version/UCD prefixes from paths
packages/shared/test/filter.test.ts Added test cases for leading slash path handling
packages/shared/test/files.test.ts Added comprehensive tests for new normalization functions
packages/shared/src/index.ts Exported new normalization utility functions
packages/cli/src/cmd/lockfile/info.ts Removed debug console.error statement

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@luxass luxass merged commit 04f2404 into main Jan 10, 2026
21 of 24 checks passed
@luxass luxass deleted the general-improvements branch January 10, 2026 13:31
@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: cli Changes related to the CLI package. pkg: shared Changes related to the Shared package. pkg: test-utils Changes related to the test-utils package.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants