Conversation
There was a problem hiding this comment.
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!
Summary of Changes
Hello team, Gemini here with a summary of this pull request. This PR, authored by @ryoppippi, addresses issue #2 by undertaking a significant refactoring of the project's structure. The core change involves moving the main source files into a dedicated src directory. This required updating various import paths throughout the codebase, modifying the package.json file to reflect the new file locations and entry points, and adjusting the build configuration (tsdown.config.ts) to correctly process files within the new src structure. Additionally, the main execution script name in package.json and documentation has been changed from report to start to better reflect its purpose.
Highlights
- Project Structure Reorganization: The primary change is the migration of source files (like
index.ts,logger.ts, and command files) into a newsrc/directory for better organization. - Import Path Updates: All internal import paths have been updated to correctly reference files within the new
src/directory structure. - Package Configuration Updates: The
package.jsonfile has been updated to include newexportsentries pointing to modules within thedist/directory (compiled fromsrc/) and the main script name has been changed fromreporttostart. - Build Configuration Adjustment: The
tsdown.config.tsbuild configuration has been updated to use a glob pattern (./src/*.ts) to include all source files in thesrcdirectory for compilation, while explicitly excluding test files. - Documentation Updates: The
CLAUDE.mdfile has been updated to reflect the change in the main script name fromreporttostart.
Changelog
Click here to see the changelog
- CLAUDE.md
- Updated development usage commands to use
bun run startinstead ofbun run report. - Updated the direct execution command from
bun run index.tstobun run ./src/index.ts.
- Updated development usage commands to use
- package.json
- Added new entries to the
exportsfield for modules now located undersrc(debug, logger, pricing-fetcher, shared-args, types, utils). - Renamed the
reportscript tostartand updated the command tobun run ./src/index.ts.
- Added new entries to the
- src/commands/index.ts
- Removed the shebang line, as it is now in the new
src/index.ts. - Updated import paths for
package.json(relative path changed). - Updated import paths for
dailyCommandandsessionCommand(relative path changed from./commands/...to./...).
- Removed the shebang line, as it is now in the new
- src/index.ts
- Added a new file
src/index.ts. - Added the shebang line (
#!/usr/bin/env node). - Imports
src/commands/index.tsto serve as the new main entry point.
- Added a new file
- src/logger.ts
- Updated the import path for
package.json(relative path changed).
- Updated the import path for
- tsdown.config.ts
- Updated the
entryconfiguration to use a glob pattern./src/*.tsand exclude test files!./src/**/*.test.ts.
- Updated the
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.
Files find a new home,
Insrcthey now roam,
Imports change their way,
Builds know where to play,
Order helps code grow.
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. ↩
commit: |
There was a problem hiding this comment.
Pull Request Overview
This PR reorganizes the project under a new src directory, updates import paths and package scripts, and adjusts build/configuration settings to match the new structure.
- Moved source files (
index.ts,commands/,logger.ts, etc.) intosrc/ - Updated import paths in
logger.tsandcommands/index.ts - Adjusted
package.jsonexports and scripts; updatedtsdown.config.tsentry globs
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tsdown.config.ts | Changed entry points to use ./src/*.ts and exclude test files |
| src/logger.ts | Updated JSON import path to reach package root |
| src/index.ts | Added CLI shebang and bootstrapped commands entry |
| src/commands/index.ts | Fixed import paths for commands and package metadata |
| package.json | Added new exports entries and replaced report script with start |
| CLAUDE.md | Updated usage instructions to reflect new start script |
|
|
||
| export default defineConfig({ | ||
| entry: ["./index.ts", "./data-loader.ts", "./calculate-cost.ts"], | ||
| entry: ["./src/*.ts", "!./src/**/*.test.ts"], |
There was a problem hiding this comment.
The tsdown entry glob only includes top‐level files under src/ and omits subdirectories like src/commands. Consider using "./src/**/*.ts" to include all source modules.
| entry: ["./src/*.ts", "!./src/**/*.test.ts"], | |
| entry: ["./src/**/*.ts", "!./src/**/*.test.ts"], |
| @@ -0,0 +1,3 @@ | |||
| #!/usr/bin/env node | |||
|
|
|||
| import "./commands/index.ts"; | |||
There was a problem hiding this comment.
[nitpick] You can simplify this to import "./commands"; and rely on the index.ts fallback, which is more idiomatic and avoids hardcoding the file extension.
| import "./commands/index.ts"; | |
| import "./commands"; |
| import { dailyCommand } from "./commands/daily.ts"; | ||
| import { sessionCommand } from "./commands/session.ts"; | ||
| import { description, name, version } from "./package.json"; | ||
| import { description, name, version } from "../../package.json"; |
There was a problem hiding this comment.
[nitpick] Deep relative imports (../../package.json) can be brittle. Consider configuring a path alias (e.g., @root/package.json) or moving metadata access into a shared module to improve maintainability.
There was a problem hiding this comment.
Code Review
This pull request effectively reorganizes the project by moving source files into an src directory. The changes are well-documented in the PR description and appear consistent across configuration files, package scripts, and documentation. This is a positive step for project structure and maintainability.
My review considers general TypeScript best practices and information from CLAUDE.md, as no formal style guide was provided. For instance, CLAUDE.md provides guidance on console.log usage.
Two points for consideration outside the direct diff review but relevant to the codebase:
- The
CLAUDE.mdfile's "Architecture Overview" (line 39) still refers toindex.tsas the CLI entry point. This might need updating to reflect the newsrc/index.tsandsrc/commands/index.tsstructure in a follow-up. - I also noticed an existing line
export const log = console.log;insrc/logger.ts(line 7 of the full file). This seems to conflict with the guidance inCLAUDE.md(lines 59, 89) about avoidingconsole.logand using the logger instead. While this line wasn't changed in this PR, it might be worth addressing in a follow-up to align with project guidelines.
Summary of Findings
- Potential conflict/redundancy in
package.json#exportsandtsdownconfiguration: Manual additions topackage.json#exportsmight be redundant or conflict withtsdown'sexports: truefeature, which aims to auto-generate these. This could impact maintainability and the correctness of the published package's API. (Commented) - Documentation updates in
CLAUDE.md: TheCLAUDE.mdfile's development usage commands were correctly updated. (Low severity, not commented due to settings) - Build configuration update in
tsdown.config.ts: The change to use a glob pattern"./src/*.ts"for entry points intsdown.config.tsis a good improvement for maintainability and aligns with the newexportsstructure. (Low severity, not commented due to settings) - Path adjustments: Import paths in moved files (
src/commands/index.ts,src/logger.ts) have been correctly updated. (Low severity, not commented due to settings)
Merge Readiness
The pull request makes sensible structural improvements. However, before merging, I recommend clarifying the interaction between the manual package.json#exports additions and tsdown's exports: true feature to ensure the build process is robust and maintainable. Addressing this point will help guarantee the package's API is correctly defined upon publishing. I am unable to approve the pull request myself; please ensure further review and approval as per your team's policy after addressing the feedback.
| "./debug": "./dist/debug.js", | ||
| "./logger": "./dist/logger.js", | ||
| "./pricing-fetcher": "./dist/pricing-fetcher.js", | ||
| "./shared-args": "./dist/shared-args.js", | ||
| "./types": "./dist/types.js", | ||
| "./utils": "./dist/utils.js", |
There was a problem hiding this comment.
These new export entries correctly map to the expected JavaScript files in the dist/ directory, corresponding to the newly organized TypeScript source files in src/.
However, I notice that tsdown.config.ts includes the exports: true option (line 15 in the full tsdown.config.ts file). According to tsdown documentation, this option should automatically generate the exports field in package.json based on the entry points defined (now "./src/*.ts").
Could you clarify if these manual additions to package.json#exports are necessary?
- If
tsdowncan auto-generate these, relying on that might simplifypackage.jsonmaintenance and ensure consistency between defined entry points and exported paths. - If
tsdown's auto-generation overwrites these manual entries, there's a risk of the finalpackage.jsonnot matching what's committed if the generation logic differs slightly.
Understanding how exports: true interacts with these manual entries, especially during the prepack script which involves tsdown and other package.json manipulation tools, is important for ensuring the package's public API is correctly and reliably defined.
chore: move files under src directory
fixes: #2
This pull request introduces several updates to the project structure, including changes to file paths, package scripts, and configuration settings. The most significant updates involve reorganizing the codebase to use a
srcdirectory for source files, modifying import paths, and adjusting package scripts to reflect the new structure.Updates to project structure:
index.tstosrc/commands/index.tsand adjusted imports to reflect the new directory structure. ([src/commands/index.tsL1-R5](https://github.com/ryoppippi/ccusage/pull/7/files#diff-a6a1db61476382a80351bf0b40126b3cfca87878293a3fca70dfe04367f4a11fL1-R5))src/index.tsfile as the entry point, including a shebang for CLI execution and importingsrc/commands/index.ts. ([src/index.tsR1-R3](https://github.com/ryoppippi/ccusage/pull/7/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R1-R3))logger.tstosrc/logger.tsand updated the import path forpackage.json. ([src/logger.tsL3-R3](https://github.com/ryoppippi/ccusage/pull/7/files#diff-7bc1140e724e284ae22084e1172568baa8d151063d02c75ed1d8805fa7796acaL3-R3))Updates to
package.json:./debug,./logger,./pricing-fetcher,./shared-args,./types, and./utilsin theexportsfield. ([package.jsonR21-R26](https://github.com/ryoppippi/ccusage/pull/7/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R21-R26))reportscript with astartscript that runs./src/index.ts. ([package.jsonL35-R41](https://github.com/ryoppippi/ccusage/pull/7/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L35-R41))Updates to configuration:
tsdown.config.tsfile to use./src/*.tsas entry points, excluding test files (!./src/**/*.test.ts). ([tsdown.config.tsL5-R5](https://github.com/ryoppippi/ccusage/pull/7/files#diff-c105f99c241d6d60e41561e663ee096629894e9b2a773c82283655b323f59485L5-R5))