refactor: rename internal files from .internal. to _ prefix#124
refactor: rename internal files from .internal. to _ prefix#124
Conversation
• Move macro.internal.ts to _macro.ts for better file organization • Update imports in _macro.ts and pricing-fetcher.ts • Follow naming convention of underscore prefix for internal files
• Move shared-args.internal.ts to _shared-args.ts for better file organization • Update imports in _shared-args.ts and all command files • Update imports in commands/session.ts, commands/mcp.ts, commands/daily.ts, commands/monthly.ts, commands/blocks.ts
• Move consts.internal.ts to _consts.ts for better file organization • Update imports in commands/mcp.ts, commands/blocks.ts, data-loader.ts • Update imports in session-blocks.internal.ts and debug.ts
• Move session-blocks.internal.ts to _session-blocks.ts for better file organization • Update imports in commands/blocks.ts and data-loader.ts
• Move types.internal.ts to _types.ts for better file organization • Update imports in calculate-cost.ts, data-loader.ts, and mcp.ts
• Move utils.internal.ts to _utils.ts for better file organization • Update imports in all command files (daily, blocks, session, monthly)
• Change exclude pattern from *.internal.ts to _*.ts • Split test and internal file exclusions for clarity
• Add documentation for underscore prefix naming convention • Update CLAUDE.md to reflect the new _*.ts file pattern
• Add explanatory comments for test and internal file exclusions
|
Warning Rate limit exceeded@ryoppippi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 29 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (8)
WalkthroughThis change updates the naming convention for internal files, introducing an underscore prefix (e.g., Changes
Sequence Diagram(s)sequenceDiagram
participant CommandModule
participant _SharedArgs
participant _Utils
participant _Consts
participant _Types
CommandModule->>_SharedArgs: Import sharedCommandConfig
CommandModule->>_Utils: Import utility functions
CommandModule->>_Consts: Import constants
CommandModule->>_Types: Import types
Note right of CommandModule: All imports now use underscore-prefixed filenames
Possibly related PRs
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
commit: |
There was a problem hiding this comment.
Summary of Changes
Hello @ryoppippi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request primarily focuses on a significant refactoring of the project's file naming conventions for internal modules. The change standardizes internal file names with an underscore prefix, enhancing code organization and adhering to common community practices. This refactor involved widespread updates to file paths and import statements, along with necessary adjustments to the build configuration and project documentation.
Highlights
- File Renaming Convention: Refactored the codebase to rename all internal files from using a
.internal.suffix (e.g.,consts.internal.ts) to an underscore_prefix (e.g.,_consts.ts). This change aims to improve file organization by grouping internal files alphabetically and aligns with common Node.js/TypeScript conventions for internal modules. - Import Path Updates: Updated all import statements across the entire codebase to reflect the new
_prefixed file paths, ensuring all modules correctly resolve their dependencies. - Build Configuration Adjustment: The
tsdownconfiguration has been updated to correctly exclude the newly named internal files (_*.ts) from the build process, replacing the previous exclusion pattern for*.internal.tsfiles. - Documentation Update: Added documentation to
CLAUDE.mdto formally describe the new naming convention for internal files, providing clarity for future development and maintenance.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request focuses on refactoring internal files by renaming them with a _ prefix and updating the codebase accordingly. The changes include updating import statements, tsdown configuration, and documentation. Overall, the changes improve file organization and code clarity.
There was a problem hiding this comment.
Actionable comments posted: 8
🔭 Outside diff range comments (1)
src/data-loader.ts (1)
24-28: Fix import order to satisfy ESLint sort-imports
CI is failing due toperfectionist/sort-imports: the_session-blocks.tsimport must come beforepricing-fetcher.ts.Apply this diff to reorder the imports:
- import { PricingFetcher } from './pricing-fetcher.ts'; - import { - identifySessionBlocks, - type LoadedUsageEntry, - type SessionBlock, - } from './_session-blocks.ts'; + import { + identifySessionBlocks, + type LoadedUsageEntry, + type SessionBlock, + } from './_session-blocks.ts'; + import { PricingFetcher } from './pricing-fetcher.ts';
🧹 Nitpick comments (1)
src/data-loader.ts (1)
29-49: Consider consolidating duplicate imports from_types.ts
There are two separate imports from the same module (import typeat the top and value imports here). Merging them into a single statement can reduce duplication and improve readability.Example:
- import type { - ActivityDate, - CostMode, - ModelName, - SortOrder, - Version, - } from './_types.ts'; + import { + type ActivityDate, + type CostMode, + type ModelName, + type SortOrder, + type Version, + activityDateSchema, + createDailyDate, + /* ...other schemas and factories... */ + versionSchema, + } from './_types.ts';
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
CLAUDE.md(1 hunks)src/_macro.ts(1 hunks)src/_session-blocks.ts(1 hunks)src/_shared-args.ts(1 hunks)src/calculate-cost.ts(1 hunks)src/commands/blocks.ts(2 hunks)src/commands/daily.ts(1 hunks)src/commands/mcp.ts(1 hunks)src/commands/monthly.ts(1 hunks)src/commands/session.ts(1 hunks)src/data-loader.ts(4 hunks)src/debug.ts(1 hunks)src/mcp.ts(1 hunks)src/pricing-fetcher.ts(1 hunks)tsdown.config.ts(1 hunks)
🧰 Additional context used
🪛 ESLint
src/mcp.ts
[error] 19-19: Expected "./_types.ts" to come before "./data-loader.ts".
(perfectionist/sort-imports)
src/_macro.ts
[error] 6-6: Prefer using a top-level type-only import instead of inline type specifiers.
(import/consistent-type-specifier-style)
src/commands/daily.ts
[error] 12-12: Expected "../_shared-args.ts" to come before "../logger.ts".
(perfectionist/sort-imports)
src/commands/session.ts
[error] 12-12: Expected "../_shared-args.ts" to come before "../logger.ts".
(perfectionist/sort-imports)
src/commands/mcp.ts
[error] 7-7: Expected "../_shared-args.ts" to come before "../mcp.ts".
(perfectionist/sort-imports)
src/pricing-fetcher.ts
[error] 3-3: Expected "./_macro.ts" to come before "./logger.ts".
(perfectionist/sort-imports)
[error] 4-4: Prefer using a top-level type-only import instead of inline type specifiers.
(import/consistent-type-specifier-style)
src/commands/monthly.ts
[error] 12-12: Expected "../_shared-args.ts" to come before "../logger.ts".
(perfectionist/sort-imports)
src/data-loader.ts
[error] 24-28: Expected "./_session-blocks.ts" to come before "./pricing-fetcher.ts".
(perfectionist/sort-imports)
🪛 GitHub Actions: CI
src/mcp.ts
[error] 19-19: ESLint perfectionist/sort-imports: Expected "./_types.ts" to come before "./data-loader.ts"
src/commands/daily.ts
[error] 12-12: ESLint perfectionist/sort-imports: Expected "../_shared-args.ts" to come before "../logger.ts"
src/commands/session.ts
[error] 12-12: ESLint perfectionist/sort-imports: Expected "../_shared-args.ts" to come before "../logger.ts"
src/commands/mcp.ts
[error] 7-7: ESLint perfectionist/sort-imports: Expected "../_shared-args.ts" to come before "../mcp.ts"
src/pricing-fetcher.ts
[error] 3-3: ESLint perfectionist/sort-imports: Expected "./_macro.ts" to come before "./logger.ts"
src/commands/blocks.ts
[error] 7-7: ESLint perfectionist/sort-imports: Expected "../_session-blocks.ts" to come before "../logger.ts"
src/commands/monthly.ts
[error] 12-12: ESLint perfectionist/sort-imports: Expected "../_shared-args.ts" to come before "../logger.ts"
src/data-loader.ts
[error] 24-24: ESLint perfectionist/sort-imports: Expected "./_session-blocks.ts" to come before "./pricing-fetcher.ts"
🔇 Additional comments (16)
CLAUDE.md (1)
103-103: Good documentation of the new naming convention.The addition clearly documents the underscore prefix convention for internal files, which will help maintain consistency across the codebase.
tsdown.config.ts (1)
8-9: Build configuration correctly updated for new naming convention.The exclusion patterns have been properly updated to exclude underscore-prefixed internal files instead of
.internal.tsfiles, which aligns with the refactoring objectives.src/debug.ts (1)
5-5: Import path correctly updated for new naming convention.The import statement has been properly updated to reference the renamed internal constants file using the underscore prefix.
src/calculate-cost.ts (1)
9-9: Import path correctly updated for new naming convention.The import statement has been properly updated to reference the renamed internal types file using the underscore prefix.
src/_session-blocks.ts (1)
2-2: Import path updated to underscore-prefixed module.The import now correctly references the renamed internal file
_consts.js, aligning with the new naming convention.src/_shared-args.ts (1)
2-3: Updated import paths to new internal file naming convention.Both type-only and value imports now point to
./_types.ts, matching the underscore-prefixed modules.src/_macro.ts (1)
5-5: Import path updated to underscore-prefixed module.The constant
LITELLM_PRICING_URLnow imports from./_consts.tsas intended.src/commands/mcp.ts (2)
3-3: Import path updated to underscore-prefixed module.
MCP_DEFAULT_PORTis now imported from../_consts.js, reflecting the renamed file.
7-7: Import path updated to underscore-prefixed module.
sharedArgsnow correctly comes from../_shared-args.tsunder the new naming convention.src/commands/daily.ts (2)
12-12: Import path updated to underscore-prefixed module.
sharedCommandConfigis now sourced from../_shared-args.ts, consistent with the refactoring.
13-13: Import path updated to underscore-prefixed module.Utilities now import from
../_utils.ts, matching the new file naming convention.src/commands/blocks.ts (3)
4-4: Approve updated path for internal constants
The move fromconsts.internal.jsto_consts.jsis correct and aligns with the new naming convention.
14-14: Approve updated path for shared command config
Importing from_shared-args.tscorrectly reflects the new internal naming scheme.
15-15: Approve updated path for utilities
Switching to_utils.tsaligns with the rename of internal modules and keeps imports clean.src/data-loader.ts (2)
1-7: Import path update is correct
The types import was updated from the old.internalsuffix to the new_types.tsmodule as intended.
19-19: Import path update is correct
The constants import was updated from the old.internalsuffix to the new_consts.jsmodule as intended.
| import { LITELLM_PRICING_URL } from './consts.internal.ts'; | ||
| import { type ModelPricing, modelPricingSchema } from './types.internal.ts'; | ||
| import { LITELLM_PRICING_URL } from './_consts.ts'; | ||
| import { type ModelPricing, modelPricingSchema } from './_types.ts'; |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Use top-level type-only import to satisfy ESLint.
Separate the type import from the value import to conform to the import/consistent-type-specifier-style rule.
-import { type ModelPricing, modelPricingSchema } from './_types.ts';
+import type { ModelPricing } from './_types.ts';
+import { modelPricingSchema } from './_types.ts';📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { type ModelPricing, modelPricingSchema } from './_types.ts'; | |
| -import { type ModelPricing, modelPricingSchema } from './_types.ts'; | |
| +import type { ModelPricing } from './_types.ts'; | |
| +import { modelPricingSchema } from './_types.ts'; |
🧰 Tools
🪛 ESLint
[error] 6-6: Prefer using a top-level type-only import instead of inline type specifiers.
(import/consistent-type-specifier-style)
🤖 Prompt for AI Agents
In src/_macro.ts at line 6, the import statement mixes type and value imports,
violating the ESLint rule import/consistent-type-specifier-style. Separate the
type import by using a top-level type-only import for ModelPricing and keep the
value import for modelPricingSchema in a separate statement.
| import { LITELLM_PRICING_URL } from './_consts.ts'; | ||
| import { logger } from './logger.ts'; | ||
| import { prefetchClaudePricing } from './macro.internal.ts' with { type: 'macro' }; | ||
| import { type ModelPricing, modelPricingSchema } from './types.internal.ts'; | ||
| import { prefetchClaudePricing } from './_macro.ts' with { type: 'macro' }; | ||
| import { type ModelPricing, modelPricingSchema } from './_types.ts'; |
There was a problem hiding this comment.
Reorder and refine imports for style and lint
- Place the
_macroimport beforeloggerto satisfyperfectionist/sort-imports. - Split the inline type specifier into a top-level type‐only import for consistency.
@@
-import { LITELLM_PRICING_URL } from './_consts.ts';
-import { logger } from './logger.ts';
-import { prefetchClaudePricing } from './_macro.ts' with { type: 'macro' };
-import { type ModelPricing, modelPricingSchema } from './_types.ts';
+import { LITELLM_PRICING_URL } from './_consts.ts';
+import { prefetchClaudePricing } from './_macro.ts' with { type: 'macro' };
+import { logger } from './logger.ts';
+
+import type { ModelPricing } from './_types.ts';
+import { modelPricingSchema } from './_types.ts';📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { LITELLM_PRICING_URL } from './_consts.ts'; | |
| import { logger } from './logger.ts'; | |
| import { prefetchClaudePricing } from './macro.internal.ts' with { type: 'macro' }; | |
| import { type ModelPricing, modelPricingSchema } from './types.internal.ts'; | |
| import { prefetchClaudePricing } from './_macro.ts' with { type: 'macro' }; | |
| import { type ModelPricing, modelPricingSchema } from './_types.ts'; | |
| import { LITELLM_PRICING_URL } from './_consts.ts'; | |
| import { prefetchClaudePricing } from './_macro.ts' with { type: 'macro' }; | |
| import { logger } from './logger.ts'; | |
| import type { ModelPricing } from './_types.ts'; | |
| import { modelPricingSchema } from './_types.ts'; |
🧰 Tools
🪛 ESLint
[error] 3-3: Expected "./_macro.ts" to come before "./logger.ts".
(perfectionist/sort-imports)
[error] 4-4: Prefer using a top-level type-only import instead of inline type specifiers.
(import/consistent-type-specifier-style)
🪛 GitHub Actions: CI
[error] 3-3: ESLint perfectionist/sort-imports: Expected "./_macro.ts" to come before "./logger.ts"
🤖 Prompt for AI Agents
In src/pricing-fetcher.ts lines 1 to 4, reorder the imports so that the import
from './_macro.ts' appears before the import from './logger.ts' to comply with
the import sorting rule. Also, separate the inline type import from
'./_types.ts' into a distinct top-level type-only import statement for better
clarity and consistency.
…ernal-files refactor: rename internal files from .internal. to _ prefix
Summary
• Rename all .internal. files to use _ prefix for better file organization
• Update tsdown configuration to exclude _*.ts files instead of *.internal.ts
• Update all import statements throughout the codebase
• Add documentation for the new naming convention
Changes
Benefits
Test plan
Summary by CodeRabbit
Documentation
Chores
No functional changes were made to the application's behavior.