Skip to content

Convert to esm package#4

Open
neryams wants to merge 3 commits into
obra:mainfrom
neryams:main
Open

Convert to esm package#4
neryams wants to merge 3 commits into
obra:mainfrom
neryams:main

Conversation

@neryams

@neryams neryams commented Jun 2, 2025

Copy link
Copy Markdown

Motivation and Context

The package is broken on later versions of dependencies as @xenova/transformers is now an esm-only package

How Has This Been Tested?

Tested on my local as an MCP server

Breaking Changes

Just make sure to npm i

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Summary by CodeRabbit

  • Documentation

    • Expanded README with comprehensive feature details for journaling, search & discovery, and privacy capabilities.
    • Revised installation and usage guidance with updated configuration examples.
    • Enhanced MCP tools documentation with expanded options and detailed descriptions.
    • Added extensive examples for file structure, journal entry formats, and development workflows.
  • Chores

    • Updated dependencies and improved build configuration.

@coderabbitai

coderabbitai Bot commented Nov 14, 2025

Copy link
Copy Markdown

Walkthrough

The project migrates from CommonJS to ES modules (ESM) by updating TypeScript and Jest configurations, adding explicit .js file extensions to import statements across all source and test files, and updating dependencies including MCP SDK. README documentation is expanded with feature details and updated usage guidance.

Changes

Cohort / File(s) Summary
ESM Configuration & Dependencies
package.json, tsconfig.json, jest.config.cjs
Updated to ESM: added "type": "module", changed TypeScript module to ESNext with allowSyntheticDefaultImports, configured Jest with ts-jest ESM preset and moduleNameMapper. Updated MCP SDK dependency to ^1.12.1 and added tsx ^4.19.4.
Source Module Imports
src/index.ts, src/journal.ts, src/search.ts, src/server.ts
Added explicit .js extensions to all local module imports for ESM compatibility. Modified server.ts to add empty capabilities object to Server constructor.
Test Module Imports & Setup
tests/embeddings.test.ts, tests/journal.test.ts, tests/paths.test.ts, tests/setup.ts
Updated import paths with .js extensions. Enhanced journal.test.ts to locate and use .md files dynamically, handling presence of .embedding files. Modified setup.ts embedding mock to return text-dependent embeddings and added console.error mock.
Documentation
README.md
Expanded feature descriptions under Journaling, Search & Discovery, and Privacy & Performance. Updated Installation, Usage, and MCP configuration examples to reference local package setup. Enhanced File Structure and Entry Format sections with updated examples and YAML formatting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • jest.config.cjs & tsconfig.json: Review ESM preset paths and moduleResolution settings for correctness.
  • tests/journal.test.ts: Verify dynamic .md file discovery logic handles edge cases (file ordering, missing files) correctly.
  • tests/setup.ts: Confirm deterministic hash-based embedding generation doesn't break test reproducibility.

Poem

🐰 From CommonJS we hop away,

ESM modules lead the way!

Extensions explicit, configs aligned,

Embedding hashes, tests refined—

A swift migration, clean and bright! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective of the changeset: converting the package from CommonJS to ESM, as evidenced by changes to package.json (adding "type": "module"), tsconfig.json (switching to ESNext), jest.config.cjs (adding ESM support), and .js file extensions throughout source and test files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
README.md (1)

29-33: Clarify the installation approach.

The installation instructions recommend using npm link for local development, but the MCP configuration examples later use npx private-journal-mcp, which assumes the package is published to npm. This could be confusing for users.

Consider one of these approaches:

  1. For published package: Update installation to use npm install -g private-journal-mcp instead of npm link.

  2. For local development: Update the MCP configuration examples to reference the linked local package:

    {
      "command": "node",
      "args": ["/path/to/private-journal-mcp/dist/index.js"]
    }
  3. For both: Add separate sections clearly distinguishing between "Development Setup" and "Using the Published Package."

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e816a33 and f75824a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • README.md (5 hunks)
  • jest.config.cjs (1 hunks)
  • package.json (2 hunks)
  • src/index.ts (1 hunks)
  • src/journal.ts (1 hunks)
  • src/search.ts (1 hunks)
  • src/server.ts (2 hunks)
  • tests/embeddings.test.ts (1 hunks)
  • tests/journal.test.ts (9 hunks)
  • tests/paths.test.ts (1 hunks)
  • tests/setup.ts (1 hunks)
  • tsconfig.json (1 hunks)
🔇 Additional comments (27)
src/server.ts (2)

10-12: ESM-local imports with .js extensions look correct

Using ./journal.js, ./types.js, and ./search.js aligns with the ESNext module config and should compile to matching specifiers in dist. No issues here.


26-32: Server capabilities object is wired as expected

Passing a second argument with capabilities: { tools: {}, resources: {} } matches the MCP Server constructor shape and advertises tool support without changing behavior. This looks consistent with the rest of the server setup.

src/index.ts (1)

7-8: Entrypoint imports updated for ESM correctly

Switching to ./server.js and ./paths.js keeps runtime resolution aligned with the built dist files under ES modules; the rest of the file remains unchanged and should behave identically.

tsconfig.json (1)

4-5: TypeScript ESM settings are consistent with the migration

Using module: "ESNext" plus moduleResolution: "node" and allowSyntheticDefaultImports: true is a reasonable configuration for this ESM shift and matches the updated .js specifiers across the codebase. If you later run into resolution quirks with packages that rely heavily on conditional exports, you might consider switching moduleResolution to node16/nodenext or bundler, but there’s no immediate need to change anything given tests are passing.

Also applies to: 11-11

src/search.ts (2)

1-2: ABOUTME comments accurately describe the search behavior

The new header comments match the existing embedding-based semantic search implementation and improve discoverability without affecting behavior.


6-7: SearchService ESM imports are aligned with the new module setup

Importing EmbeddingService and path resolvers via ./embeddings.js and ./paths.js is consistent with the ESNext config and other updated modules; this should keep type-checking and runtime resolution in sync.

tests/paths.test.ts (1)

5-5: Test import updated to match ESM build output

Pointing the tests to ../src/paths.js keeps them consistent with the new ESM module specifiers; the rest of the test file is unchanged and should continue to validate the same behavior.

tests/embeddings.test.ts (1)

8-10: LGTM!

The import paths are correctly updated to use explicit .js extensions, which is required for ES modules. The changes are consistent with the ESM migration across the codebase.

src/journal.ts (1)

6-8: LGTM!

The import paths are correctly updated to use explicit .js extensions as required for ES modules.

tests/setup.ts (2)

4-13: LGTM!

The updated mock implementation generates deterministic but text-dependent embeddings, which is more realistic for testing semantic search functionality. The hash-based approach ensures test consistency while maintaining text differentiation.


15-16: LGTM!

Mocking console.error reduces noise in test output, which improves test readability.

package.json (3)

5-5: LGTM!

Adding "type": "module" correctly enables ES module support for the package, which is necessary for compatibility with the ESM-only @xenova/transformers.


42-43: Verify if tsx dependency is actually needed; update to latest if retained.

Security verification passed: both @xenova/transformers v2.17.2 and tsx v4.19.4 have zero known vulnerabilities. However, tsx v4.19.4 is behind the latest v4.20.6, and critically, tsx is not used anywhere—it's absent from npm scripts and source code imports. Confirm whether tsx is needed; if so, update to v4.20.6 (allowed by caret constraint).


41-41: I need more specific information about breaking changes between versions 0.4.0 and 1.12.1. Let me search for migration details.

Based on my web search findings, the SSE transport is now deprecated in favor of Streamable HTTP, and new implementations should use Streamable HTTP while existing SSE implementations should plan to migrate. This represents a known breaking change within the v1.x series.

From the earlier search, v1.0.0 itself didn't introduce API-breaking changes beyond establishing the baseline/stable API, and the project policy aims to avoid breaking changes where possible. However, some later 1.x releases did contain or revert breaking changes (for example a breaking change introduced in v1.13.3 was reverted in v1.15.0). Since the codebase targets v1.12.1 (which is before the v1.13.3 change), it should avoid that particular issue.

Verify that the codebase does not use the deprecated SSE transport.

If your server implementation uses SseServerTransport, it must be migrated to StreamableHTTPServerTransport to remain compatible with v1.12.1 and forward. If you're using modern patterns (e.g., StdioServerTransport or StreamableHTTPServerTransport), the upgrade should proceed without issues.

jest.config.cjs (1)

2-12: LGTM!

The Jest configuration is correctly updated to support ES modules with the standard ts-jest ESM preset, proper module transformation, and name mapping to resolve .js imports to their .ts source files during testing.

tests/journal.test.ts (9)

8-8: LGTM!

The import path is correctly updated to use the explicit .js extension as required for ES modules.


136-142: LGTM!

The test correctly expects only the .md file for empty content since embedding generation is skipped when content is empty. The updated file discovery using find() is more robust than relying on fixed array positions.


161-165: LGTM!

The dynamic file discovery approach using find() is more robust than assuming a specific array index, especially when file ordering may vary.


181-187: LGTM!

The test is correctly updated to expect 2 files (.md and .embedding) and uses dynamic file discovery for robustness.


207-213: LGTM!

The test correctly accounts for both the .md and .embedding files being created for non-empty content.


239-258: LGTM!

The test is properly updated to dynamically discover .md files in both project and user directories, making the tests more resilient to file ordering variations.


278-283: LGTM!

The test correctly uses dynamic file discovery and expects both .md and .embedding files for non-empty user content.


305-310: LGTM!

The test is properly updated to use dynamic file discovery for the project directory scenario.


332-337: LGTM!

The test correctly uses dynamic file discovery for the custom user path scenario, ensuring robustness across different file orderings.

README.md (3)

9-25: LGTM!

The expanded feature documentation provides clear, granular details about the journaling capabilities, search functionality, and privacy features, improving user understanding of the tool's capabilities.


80-111: LGTM!

The enhanced MCP tools documentation with detailed parameter descriptions and default values significantly improves usability and clarity.


136-153: LGTM!

The entry format example clearly demonstrates the YAML frontmatter structure and section organization, which helps users understand how their journal entries are stored.

AmadeusDelfino added a commit to AmadeusDelfino/private-journal-mcp that referenced this pull request Jul 13, 2026
Design for review-batch item #1 (dimension-mismatch crash). Covers both
the noisy dimension-crash and the silent same-dimension-different-model
mode via a shared model-identity compatibility predicate, a read-only
skip-and-defer search guard, a dimension floor as corruption backstop,
and a hardened startup migration (observable throwing regen, truthful
count, generous init timeout).

Hardened through two adversarial read-only review rounds; residual holes
(quantized/prefix in the key = item obra#4, large-journal startup latency,
concurrent writers) recorded as out-of-scope.
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.

1 participant