8000 Add SDK exports as library + fix dependencies by rahulkarajgikar · Pull Request #105 · truffle-ai/saiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add SDK exports as library + fix dependencies #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 16, 2025

Conversation

rahulkarajgikar
Copy link
Collaborator
@rahulkarajgikar rahulkarajgikar commented May 16, 2025

This PR exposes core saiki functionality as part of the @truffle-ai/saiki package as a library.

This means that users who install @truffle-ai/saiki now get both the CLI commands and the library for use in programs.

Other changes:

  • Added support for both commonjs (Older js versions) and ESM based imports. This is useful for older projects

  • Added tsup.config.ts which defines the build logic for ESM v/s CJS

  • Added exports field in package.json which defines the actual library exports

  • Moved cli options code from core to app

  • Added path aliases @core and @app for cross functional exports (if files in app need to import from core, they can import x from @core/index.js

  • Updated all files in app directory to import from @core/index.js for better modularity and clear separation of concerns

  • Added new index.ts files in core directory to simplify imports and add better sub-directory separation

  • Added src/TESTING.md which describes how to locally test both code exports and the saiki CLI locally while developing.

  • Tested cjs/esm imports in a separate file (followed TESTING.md)

  • Tested saiki CLI works correctly (followed TESTING.md)

  • Pinned dependencies for 2 libraries via 'overrides' section in package.json because of vulnerabilities with discord and telegram dependencies

  • Added engine section in package.json which warns end users installing saiki that their node version is not supported, if they are below node 20 or below npm 8 - useful for users trying to install saiki on old node versions

SDK exports now include necessary functions/classes/types to use saiki programmatically

next steps:
bump up saiki version and publish the new version post this PR

Summary by CodeRabbit

  • New Features

    • Centralized and streamlined module exports, allowing easier imports from unified entry points.
    • Added detailed documentation for testing package exports and CLI functionality.
    • Enhanced TypeScript configuration with path aliases and declaration file generation.
  • Refactor

    • Updated import paths throughout the codebase to use new centralized module aliases.
    • Improved build process by switching to a new bundler and updating build scripts.
    • Reorganized package entry points and module resolution for better compatibility.
  • Style

    • Minor formatting improvements in configuration files.
  • Chores

    • Updated minimum required Node.js and npm versions.
    • Added dependency version overrides for consistency.

Copy link
coderabbitai bot commented May 16, 2025

Walkthrough

This update introduces a centralized export structure ("barrel" files) throughout the core modules, consolidates logger imports, and updates TypeScript and build configurations for improved module resolution and typing. The build process transitions from tsc to tsup, and package entry points are reorganized for clearer ESM/CJS support. Documentation for testing procedures is also added.

Changes

File(s) Change Summary
package.json, tsconfig.json, tsup.config.ts Updated engines requirements, reorganized entry points, added exports, switched build tool to tsup, added path aliases, enabled declaration file generation, and introduced tsup config for multi-entry builds.
src/app/api/a2a.ts, src/app/api/mcp_handler.ts, src/app/api/server.ts, src/app/cli/cli-subscriber.ts, src/app/cli/cli.ts, src/app/discord/bot.ts, src/app/index.ts, src/app/telegram/bot.ts, src/app/utils/options.ts, src/app/web/server.ts Refactored imports to use centralized @core/index.js alias instead of relative paths.
src/core/ai/agent/SaikiAgent.ts, src/core/ai/llm/messages/factory.ts, src/core/ai/llm/messages/formatters/anthropic.ts, src/core/ai/llm/messages/formatters/factory.ts, src/core/ai/llm/messages/manager.ts, src/core/ai/llm/registry.ts, src/core/ai/llm/services/anthropic.ts, src/core/ai/llm/services/factory.ts, src/core/ai/llm/services/openai.ts, src/core/ai/llm/services/vercel.ts, src/core/ai/llm/tokenizer/openai.ts, src/core/ai/systemPrompt/manager.ts, src/core/client/manager.ts, src/core/client/mcp-client.ts, src/core/client/tool-confirmation/cli-confirmation-provider.ts, src/core/config/loader.ts, src/core/config/manager.ts Updated import paths for logger to use the new centralized logger module location.
src/core/ai/agent/index.ts, src/core/ai/index.ts, src/core/ai/llm/index.ts, src/core/ai/llm/messages/index.ts, src/core/ai/llm/services/index.ts, src/core/client/index.ts, src/core/config/index.ts, src/core/index.ts, src/core/logger/index.ts, src/core/settings/index.ts, src/core/utils/index.ts Added new barrel files to re-export modules for centralized access and simplified imports.
src/core/utils/service-initializer.ts Updated logger import, made cliArgs parameter optional, and conditionally applied CLI overrides in createAgentServices.
src/core/logger/logger.test.ts Updated import path for Logger and logger to match new logger module structure.
src/TESTING.md Added comprehensive documentation for testing library exports and CLI.

Sequence Diagram(s)

sequenceDiagram
    participant Consumer as Consumer Module
    participant CoreIndex as src/core/index.ts
    participant Submodules as {logger, utils, ai, config, client, settings}

    Consumer->>CoreIndex: import {...} from '@core/index.js'
    CoreIndex->>Submodules: re-export all public APIs
    Submodules-->>CoreIndex: expose module exports
    CoreIndex-->>Consumer: provide unified API surface
Loading
sequenceDiagram
    participant Dev as Developer
    participant Build as Build System (tsup)
    participant Output as dist/
    participant Consumer as Consumer Project

    Dev->>Build: Run build script (tsup)
    Build->>Output: Generate CJS/ESM bundles, types, maps
    Consumer->>Output: import from core/app entry points
    Output-->>Consumer: Provide correct module format and typings
Loading

Poem

🐇
A hop and a skip, the barrels align,
Imports now simple, the structure divine!
With tsup in the meadow, and typings that gleam,
The logger now central, our modules a team.
Testing is clearer, the CLI’s in tune—
This rabbit approves, and hums a new tune!
🥕

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rahulkarajgikar rahulkarajgikar changed the title Add SDK exports as library Add SDK exports as library + fix dependencies May 16, 2025
@rahulkarajgikar rahulkarajgikar marked this pull request as ready for review May 16, 2025 01:48
@rahulkarajgikar rahulkarajgikar requested a review from shaunak99 May 16, 2025 01:48
Copy link
@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: 3

🧹 Nitpick comments (13)
src/app/utils/options.ts (1)

2-3: Combine duplicate imports from the same module.

Currently, you have two separate imports from @core/index.js:

import { logger } from '@core/index.js';
import { getSupportedProviders } from '@core/index.js';

For clarity and to reduce duplication, merge them into one:

-import { logger } from '@core/index.js';
-import { getSupportedProviders } from '@core/index.js';
+import { logger, getSupportedProviders } from '@core/index.js';
src/core/ai/llm/messages/manager.ts (1)

7-7: Use the @core alias instead of a relative path for logger.

To keep imports consistent across the project (as seen in src/app), switch the relative import to the alias:

-import { logger } from '../../../logger/index.js';
+import { logger } from '@core/logger';
src/core/ai/llm/services/anthropic.ts (1)

5-5: Use the @core alias instead of a relative path for logger.

Align this import with the centralized barrel exports:

-import { logger } from '../../../logger/index.js';
+import { logger } from '@core/logger';
src/core/ai/llm/tokenizer/openai.ts (1)

3-3: Use the @core alias instead of a relative path for logger.

For uniformity and clarity:

-import { logger } from '../../../logger/index.js';
+import { logger } from '@core/logger';
src/core/ai/systemPrompt/manager.ts (1)

8-8: Use the @core alias instead of a relative path for logger.

To maintain consistency with the rest of the codebase:

-import { logger } from '../../logger/index.js';
+import { logger } from '@core/logger';
src/app/api/a2a.ts (1)

2-3: Nit: Combine type and value imports.
For brevity and clarity, you can merge these into one statement:

import { logger, type AgentCard } from '@core/index.js';
src/app/api/mcp_handler.ts (1)

5-6: Nit: Consolidate type imports.
Consider grouping all type-only imports and separating value imports:

import type { AgentCard, SaikiAgent } from '@core/index.js';
import { logger } from '@core/index.js';

This adheres to TS best practices and enhances readability.

Also applies to: 9-9

src/app/api/server.ts (1)

6-13: Nit: Group and reorder imports from @core.
For better import hygiene, separate type-only imports and consolidate values:

import type { AgentCard } from '@core/index.js';
import { logger, createAgentCard, SaikiAgent } from '@core/index.js';

Also, grouping all @core imports together makes the dependency structure clearer.

src/app/web/server.ts (1)

2-4: Nit: Consolidate @core imports.
You can merge these into grouped statements for clarity:

import { logger, resolvePackagePath, SaikiAgent } from '@core/index.js';
import type { AgentCard } from '@core/index.js';

This streamlines the import section and separates types from values.

Also applies to: 6-7

tsconfig.json (1)

18-20: Evaluate necessity of DOM library and declaration options.
Enabling "declaration" and "declarationMap" is essential for distributing typings. However, including the "DOM" lib may introduce unnecessary browser globals if your core modules run only in Node. Consider removing "DOM" if it isn’t required by your runtime or tests.

src/core/utils/service-initializer.ts (1)

96-100: Conditional application of CLI overrides.

The code now conditionally applies CLI overrides only when they're provided, which is a logical consequence of making the cliArgs parameter optional. This makes the function more robust.

This could be slightly simplified using optional chaining:

- const configManager = new ConfigManager(rawConfig);
- if (cliArgs) {
-     configManager.overrideCLI(cliArgs);
- }
+ const configManager = new ConfigManager(rawConfig);
+ cliArgs && configManager.overrideCLI(cliArgs);
src/TESTING.md (2)

12-12: Add language specifiers to fenced code blocks
Fenced code blocks at these positions have no language hint, which hinders readability and triggers markdownlint MD040. Please update as follows (use text for plain output and bash for shell commands):

-   ```
+   ```text   // for output-only blocks (e.g., the tarball name)
-   ```
+   ```bash  // for shell command snippets

Repeat for lines 82, 88, and 95.

Also applies to: 82-82, 88-88, 95-95

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

12-12: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


77-77: Fix grammatical number agreement
The sentence at line 77 should read “No errors mean that …” instead of “No errors means …”:

- No errors means your `"types"` export is wired up correctly.
+ No errors mean that your `"types"` export is wired up correctly.
🧰 Tools
🪛 LanguageTool

[grammar] ~77-~77: You should probably use “mean”.
Context: ...ash npx tsc ``` No errors means your "types" export is wired up corre...

(AGREEMENT_SENT_START)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 7753496 and faae829.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (44)
  • package.json (2 hunks)
  • src/TESTING.md (1 hunks)
  • src/app/api/a2a.ts (1 hunks)
  • src/app/api/mcp_handler.ts (1 hunks)
  • src/app/api/server.ts (1 hunks)
  • src/app/cli/cli-subscriber.ts (1 hunks)
  • src/app/cli/cli.ts (1 hunks)
  • src/app/discord/bot.ts (1 hunks)
  • src/app/index.ts (1 hunks)
  • src/app/telegram/bot.ts (1 hunks)
  • src/app/utils/options.ts (1 hunks)
  • src/app/web/server.ts (1 hunks)
  • src/core/ai/agent/SaikiAgent.ts (1 hunks)
  • src/core/ai/agent/index.ts (1 hunks)
  • src/core/ai/index.ts (1 hunks)
  • src/core/ai/llm/index.ts (1 hunks)
  • src/core/ai/llm/messages/factory.ts (1 hunks)
  • src/core/ai/llm/messages/formatters/anthropic.ts (1 hunks)
  • src/core/ai/llm/messages/formatters/factory.ts (1 hunks)
  • src/core/ai/llm/messages/index.ts (1 hunks)
  • src/core/ai/llm/messages/manager.ts (1 hunks)
  • src/core/ai/llm/registry.ts (1 hunks)
  • src/core/ai/llm/services/anthropic.ts (1 hunks)
  • src/core/ai/llm/services/factory.ts (1 hunks)
  • src/core/ai/llm/services/index.ts (1 hunks)
  • src/core/ai/llm/services/openai.ts (1 hunks)
  • src/core/ai/llm/services/vercel.ts (1 hunks)
  • src/core/ai/llm/tokenizer/openai.ts (1 hunks)
  • src/core/ai/systemPrompt/manager.ts (1 hunks)
  • src/core/client/index.ts (1 hunks)
  • src/core/client/manager.ts (1 hunks)
  • src/core/client/mcp-client.ts (1 hunks)
  • src/core/client/tool-confirmation/cli-confirmation-provider.ts (1 hunks)
  • src/core/config/index.ts (1 hunks)
  • src/core/config/loader.ts (1 hunks)
  • src/core/config/manager.ts (1 hunks)
  • src/core/index.ts (1 hunks)
  • src/core/logger/index.ts (1 hunks)
  • src/core/logger/logger.test.ts (1 hunks)
  • src/core/settings/index.ts (1 hunks)
  • src/core/utils/index.ts (1 hunks)
  • src/core/utils/service-initializer.ts (2 hunks)
  • tsconfig.json (1 hunks)
  • tsup.config.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/core/utils/service-initializer.ts (3)
src/core/config/types.ts (1)
  • CLIConfigOverrides (17-17)
src/core/config/loader.ts (1)
  • loadConfigFile (36-63)
src/core/config/manager.ts (1)
  • ConfigManager (18-156)
🪛 LanguageTool
src/TESTING.md

[grammar] ~77-~77: You should probably use “mean”.
Context: ...ash npx tsc ``` No errors means your "types" export is wired up corre...

(AGREEMENT_SENT_START)

🪛 markdownlint-cli2 (0.17.2)
src/TESTING.md

12-12: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


82-82: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


88-88: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


95-95: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (43)
src/core/config/loader.ts (1)

6-6: Import path updated for centralized logger module
The import of logger has been refactored to point to the new barrel at ../logger/index.js, aligning with the modular restructuring. Ensure that src/core/logger/index.ts correctly re-exports the logger instance.

src/core/ai/llm/messages/factory.ts (1)

7-7: Aligned logger import to new barrel file
Updated the logger import path to use ../../../logger/index.js, consistent with the centralized logger export. Confirm that no residual imports remain referencing the old path.

src/core/client/tool-confirmation/cli-confirmation-provider.ts (1)

2-2: CLI logger import path updated
The logger import now points to the new ../../logger/index.js barrel file. Verify that other client modules have undergone the same update for consistency.

src/core/ai/llm/registry.ts (1)

1-1: Central logger import applied
Import path for logger has been redirected to ../../logger/index.js. This matches the new structure—ensure the logger barrel exports the same API as before.

src/core/ai/agent/SaikiAgent.ts (1)

9-9: Updated logger import in SaikiAgent
Switched the logger import to ../../logger/index.js to use the centralized barrel module. Confirm that the barrel aggregates the appropriate logging interfaces.

src/core/ai/llm/messages/formatters/factory.ts (1)

5-5: Import path correctly aligned with new barrel.
The logger import now points to the centralized src/core/logger/index.js, matching your refactoring across core modules.

src/app/cli/cli-subscriber.ts (1)

1-1: Switched to alias import for centralized logger.
Using @core/index.js clarifies the origin of the logger utility and leverages the new barrel file. Ensure your tsconfig.json and build config (tsup.config.ts) resolve this alias correctly.

src/core/logger/logger.test.ts (1)

2-2: Updated test to use barrel export.
Importing Logger and logger from ../logger/index.js keeps tests in sync with the reorganized core logger module.

src/core/ai/llm/services/factory.ts (1)

4-4: Centralized logger import updated.
Switching to '../../../logger/index.js' aligns with the new core directory structure and barrel exports. No logic changes here.

src/core/client/manager.ts (1)

3-3: Consistent import for centralized logger.
The import path for logger has been updated to the new barrel file location (src/core/logger/index.ts), aligning with the project-wide refactoring for centralized and cleaner imports.

src/core/ai/llm/messages/formatters/anthropic.ts (1)

3-3: Aligned logger import to new barrel.
The logger import now points to the centralized src/core/logger/index.js barrel, ensuring consistency with other modules and simplifying maintenance.

src/core/client/mcp-client.ts (1)

6-6: Updated logger import path.
This change synchronizes the import of logger with the new barrel at src/core/logger/index.js, matching the updated module layout.

src/core/ai/llm/services/vercel.ts (1)

3-3: Standardized logger import.
The import of logger is redirected to the centralized src/core/logger/index.js barrel, in line with the codebase-wide import restructuring.

src/core/config/manager.ts (1)

2-2: Centralized logger import applied.
Switching to import { logger } from '../logger/index.js' ensures this module uses the new barrel file for logging utilities, fostering uniform import patterns.

src/app/api/a2a.ts (1)

2-3: Refactored imports to use the @core alias.
Switching from relative paths to the centralized barrel file improves maintainability and consistency across the codebase.

src/app/api/mcp_handler.ts (1)

5-6: Centralized core imports via @core alias.
Adopting the barrel export for AgentCard, logger, and SaikiAgent aligns with your modularization goals.

Also applies to: 9-9

src/app/api/server.ts (1)

6-13: Refactored to use @core barrel exports.
All core entities (logger, AgentCard, createAgentCard, SaikiAgent) now pull from the centralized module, which improves modularity.

src/app/web/server.ts (1)

2-4: Updated core imports to use the alias.
Switching to the @core barrel for logger, resolvePackagePath, AgentCard, and SaikiAgent enhances consistency with the new module structure.

Also applies to: 6-7

src/core/ai/agent/index.ts (1)

1-2: Simple, effective barrel file implementation.

This barrel file exports everything from the SaikiAgent module, allowing consumers to import from the directory level rather than specific files. This pattern simplifies imports across the codebase and aligns with the PR objectives.

src/core/ai/llm/services/index.ts (1)

1-2: Clean barrel file implementation.

This barrel file appropriately exports all types from the types.js module, contributing to the centralized export structure being established. This implementation follows the same pattern as other barrel files in the PR.

src/app/cli/cli.ts (1)

3-5: Import paths successfully updated to use the path alias.

The imports have been correctly migrated from relative paths to the @core/index.js path alias. This change aligns with the PR objective to implement path aliases for cleaner imports.

Note that both logger and SaikiAgent are now imported from the same location, which simplifies the import structure.

src/core/logger/index.ts (1)

1-2: Effective barrel file implementation for the logger module.

This barrel file exports all contents from logger.js, creating a centralized entry point for the logger functionality. This change supports the PR's goal of improving module organization and enabling library exports.

src/core/utils/index.ts (1)

1-2: Clean and effective barrel file implementation!

This barrel file properly re-exports from path.js and service-initializer.js, creating a centralized entry point that simplifies imports. This approach aligns with the PR objective of exposing core functionality as a library while maintaining a clean export structure.

src/core/ai/llm/messages/index.ts (1)

1-2: Well-structured barrel file for LLM messages!

This barrel file correctly re-exports from manager.js and types.js, creating a clean entry point for messages functionality. This consolidation makes imports more maintainable for library consumers.

src/core/ai/index.ts (1)

1-2: Solid hierarchical export structure!

This barrel file properly aggregates exports from the agent and llm submodules, creating a clean hierarchical export structure that simplifies library imports. This implementation supports both the ESM and CJS export strategy outlined in the PR objectives.

src/app/discord/bot.ts (2)

4-4: Good addition of HTTP protocol support

Adding the http module import allows the downloadFileAsBase64 function to handle both HTTP and HTTPS protocols, making the file download functionality more robust and versatile.


5-5: Proper implementation of @core path alias

The import for SaikiAgent has been updated to use the new @core path alias instead of relative paths, which aligns with the PR's goal of implementing path aliases for cleaner imports and better separation of concerns.

src/core/settings/index.ts (1)

1-1: Approve barrel export for settings types.
The new barrel file correctly re-exports all types from ./types.js, aligning with the centralized import strategy and simplifying downstream imports.

src/core/config/index.ts (1)

1-3: Approve barrel exports for config submodules.
This index consolidates exports from agentCard.js, schemas.js, and types.js into a single entry point, improving modularity and import clarity.

src/core/ai/llm/index.ts (1)

1-5: Approve barrel exports for LLM module.
Exports for errors.js, registry.js, types.js, messages/index.js, and services/index.js are correctly centralized, making LLM-related APIs easier to consume.

tsconfig.json (1)

7-11: Approve addition of baseUrl and path aliases.
Introducing "baseUrl": "." and path mappings for @app/* and @core/* enables cleaner, alias-based imports across the codebase.

src/core/client/index.ts (1)

1-3: Approve barrel exports for client submodules.
Aggregating exports from manager.js, mcp-client.js, and types.js into a single index improves import ergonomics and aligns with the overall barrel-file strategy.

src/core/index.ts (1)

1-6: Well-structured barrel file for core module exports.

This clean barrel file efficiently re-exports all essential functionality from core submodules, creating a centralized entry point that aligns with the PR objective of exposing Saiki functionality as a library.

src/app/index.ts (2)

5-14: Consolidated imports using centralized core module.

The imports have been effectively consolidated from multiple relative paths into a single import from the centralized @core/index.js. This approach improves maintainability and establishes clear boundaries between app and core modules.


19-19: Updated import path for options utilities.

The import path for option utilities has been correctly moved from core module to app module, aligning with the PR's objective to separate CLI options code from core functionality.

tsup.config.ts (1)

1-21: Well-structured build configuration for dual module formats.

This tsup configuration properly implements the build settings needed for:

  1. Core module (CJS+ESM) with declaration files and proper bundling
  2. App module (ESM only) without bundling

The configuration ensures that chalk and boxen are bundled with the core library, and shims are enabled for both build targets. This setup aligns perfectly with the PR objective of supporting both CommonJS and ECMAScript module imports.

src/core/utils/service-initializer.ts (2)

31-31: Updated logger import to use new barrel file.

The logger import has been correctly updated to use the new barrel file structure, consistent with the overall refactoring.


90-91: Made CLI arguments optional for more flexible service initialization.

Making the CLI arguments optional is a good improvement that enhances flexibility when programmatically creating agent services.

package.json (5)

4-7: Engines field to enforce Node.js and npm versions
The new engines section correctly requires Node.js >=20.0.0 and npm >=8.3.0, matching your build tools (tsup) and ensuring overrides support.


16-23: Validate the exports configuration
The exports field correctly exposes the package for CJS (require), ESM (import), and TypeScript (types), following dual-package best practices.


27-27: Update build script to use tsup
Switching the build script from tsc to npm run clean && tsup && npm run copy-client aligns with your new bundler. Ensure your tsup.config.ts covers both core and app targets.


99-99: Pin tsup in devDependencies
Adding "tsup": "^8.4.0" is required for the updated build process.


106-110: Close lint-staged and add overrides
The lint-staged config is now properly closed, and the overrides section pins tough-cookie and undici to address known vulnerabilities—good catch.

@rahulkarajgikar rahulkarajgikar merged commit a50ae4d into truffle-ai:main May 16, 2025
1 check passed
@rahulkarajgikar rahulkarajgikar mentioned this pull request May 16, 2025
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.

2 participants
0