Repository navigation
Conversation
- add .history to gitignore - formatting - v2.0.3 - feat: enhance Node.js PATH resolution with version sorting - feat: add direct ccusage command execution option. - Add useDirectCcusageCommand preference for network environments - Support direct \'ccusage\' command as alternative to npx - Initial commit
|
Thank you for your first contribution! 🎉 🔔 @nyatinte @zhuravel you might want to have a look. You can use this guide to learn how to check out the Pull Request locally in order to test it. You can expect an initial review within five business days. |
|
Hi @zzyfisher👋 Thanks for your contribution 🔥 @nyatinte do you want to check this? |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the ccusage extension with two key improvements: adding a preference option to use the ccusage command directly instead of npx (solving network connectivity issues), and implementing Node.js version-based sorting to prioritize the latest versions when multiple Node.js installations are present.
- Added direct command execution preference to bypass npx network issues
- Implemented version parsing and sorting for Node.js installations
- Updated all CLI hooks to support configurable command execution
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/ccusage/src/utils/node-path-resolver.ts | Added version parsing and sorting logic to prioritize latest Node.js versions |
| extensions/ccusage/src/hooks/useCCUsageTotalCli.ts | Added support for direct ccusage command execution based on preference |
| extensions/ccusage/src/hooks/useCCUsageSessionCli.ts | Added support for direct ccusage command execution based on preference |
| extensions/ccusage/src/hooks/useCCUsageMonthlyCli.ts | Added support for direct ccusage command execution based on preference |
| extensions/ccusage/src/hooks/useCCUsageDailyCli.ts | Added support for direct ccusage command execution based on preference |
| extensions/ccusage/package.json | Added new preference for direct ccusage command execution and contributor |
| extensions/ccusage/CHANGELOG.md | Added changelog entry for v2.0.3 with proper template format |
| extensions/ccusage/.gitignore | Added .history to gitignore |
Files not reviewed (1)
- extensions/ccusage/package-lock.json: Language not supported
There was a problem hiding this comment.
Greptile Summary
This PR enhances the ccusage extension with two significant improvements to address a critical issue where users experienced "No output received from ccusage daily command" errors (issue #21272). The first improvement adds a new preference option useDirectCcusageCommand that allows users to bypass npx ccusage@latest and execute ccusage directly, resolving network connectivity issues with npx. The second improvement implements sophisticated Node.js path resolution with version-based sorting to prioritize the latest Node.js installations when multiple versions are present (common with version managers like nvm, fnm, volta).
The changes are implemented consistently across all CLI hooks (useCCUsageDailyCli, useCCUsageMonthlyCli, useCCUsageSessionCli, useCCUsageTotalCli) with conditional command execution logic. The Node.js path resolver now parses version strings, converts them to comparable numbers, and sorts paths to ensure newer versions take precedence. This prevents execution failures that occur when the system locates older Node.js versions that may lack required packages or have compatibility issues.
The implementation maintains backward compatibility by defaulting to the existing npx ccusage@latest behavior while providing users with a preference-based workaround for network-related issues. The CHANGELOG.md properly documents these enhancements under version 2.0.3 with appropriate categorization of Added, Changed, and Fixed sections.
Important Files Changed
Changed Files
| Filename | Score | Overview |
|---|---|---|
| extensions/ccusage/CHANGELOG.md | 5/5 | Adds version 2.0.3 entry documenting CLI execution flexibility and Node.js path resolution improvements |
| extensions/ccusage/package.json | 5/5 | Adds new preference useDirectCcusageCommand to enable direct ccusage command execution |
| extensions/ccusage/src/utils/node-path-resolver.ts | 4/5 | Implements version parsing and sorting to prioritize latest Node.js installations |
| extensions/ccusage/src/hooks/useCCUsageDailyCli.ts | 5/5 | Updates to support conditional command execution based on user preference |
| extensions/ccusage/src/hooks/useCCUsageMonthlyCli.ts | 5/5 | Updates to support conditional command execution based on user preference |
| extensions/ccusage/src/hooks/useCCUsageSessionCli.ts | 5/5 | Updates to support conditional command execution based on user preference |
| extensions/ccusage/src/hooks/useCCUsageTotalCli.ts | 5/5 | Updates to support conditional command execution based on user preference |
| extensions/ccusage/.gitignore | 5/5 | Minor addition of development-related files (.claude, .history) to ignore list |
Confidence score: 4/5
- This PR is safe to merge with low risk as it addresses a genuine user issue with a well-implemented solution
- Score reflects solid implementation with consistent patterns across all CLI hooks and proper preference handling
- Pay close attention to extensions/ccusage/src/utils/node-path-resolver.ts for the version sorting logic complexity
8 files reviewed, 1 comment
| const [, major, minor, patch] = versionMatch; | ||
| return parseInt(major) * 1000000 + parseInt(minor) * 1000 + parseInt(patch); |
There was a problem hiding this comment.
style: Consider using parseInt(major, 10) to explicitly specify base 10 and avoid potential issues with leading zeros
|
Hello @zzyfisher! |
nyatinte
left a comment
There was a problem hiding this comment.
I've made a few comments! Please make the necessary corrections. Overall, the revisions were excellent!
|
|
||
| .claude | ||
| .claude | ||
| .history |
| "contributors": [ | ||
| "bohdan_zhuravel" | ||
| "bohdan_zhuravel", | ||
| "zzyfisher" |
| // Parse Node.js version string to comparable number (e.g., "18.17.1" -> 18017001) | ||
| const parseVersion = (version: string): number => { | ||
| const versionMatch = version.match(/^v?(\d+)\.(\d+)\.(\d+)/); | ||
| if (!versionMatch) return 0; | ||
|
|
||
| const [, major, minor, patch] = versionMatch; | ||
| return parseInt(major) * 1000000 + parseInt(minor) * 1000 + parseInt(patch); |
There was a problem hiding this comment.
The implementation looks good, but let's use a library here to handle edge cases and ensure we're parsing versions correctly. I'd suggest using semver - it's battle-tested and will save us from potential headaches down the road. Open to other solid alternatives if you have any in mind though!
| const useDirectCommand = preferences.useDirectCcusageCommand; | ||
|
|
||
| const command = useDirectCommand ? "ccusage" : "npx"; | ||
| const args = useDirectCommand ? ["daily", "--json"] : ["ccusage@latest", "daily", "--json"]; | ||
| const result = useExec(command, args, { |
|
Thanks for the review @nyatinte, @zzyfisher can you look into this? I converted this PR into a draft until it's ready for the review, please press the button |
|
Hi @zzyfisher, Are you still planning to work on this? If you're busy or no longer able to continue, I'd be happy to take over and help get this merged. Let me know! |
|
@raycastbot close this pr |
|
This pull request has been automatically marked as stale because it did not have any recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊 |
|
This pull request has been automatically closed due to inactivity. Feel free to comment in the thread when you're ready to continue working on it 🙂 You can also catch us in Slack if you want to discuss this. |
feat: enhance Node.js path resolution and CLI execution flexibility
This PR enhances the ccusage extension with two major improvements:
Direct Command Execution Execution: Adds a preference option to use the ccusage command directly instead of npx ccusage@latest, resolving network connectivity issues as described in [Claude Code Usage (ccusage)] No output received from ccusage daily command #21272.
Node.js Path Optimization: Implements version-based sorting of Node.js installations to prioritize the latest versions, preventing ccuage execution failures caused by locating older Node.js versions when multiple versions are installed (e.g., via nvm).
Changes
Added
useDirectCcusageCommandpreference in package.jsonnode-path-resolver.tsChanged
usehooks-ts.gitignorerulesFixed
Screencast
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare placed outside of themetadatafolder