Skip to content

[ccusage]feat: enhance Node.js path resolution and CLI execution flexibility, preventing ccusage execution failures - #21280

Closed
zzyfisher wants to merge 1 commit into
raycast:mainfrom
zzyfisher:ext/ccusage
Closed

zzyfisher wants to merge 1 commit into
raycast:mainfrom
zzyfisher:ext/ccusage

Conversation

@zzyfisher

@zzyfisher zzyfisher commented Sep 1, 2025 •

Copy link
Copy Markdown
Contributor

feat: enhance Node.js path resolution and CLI execution flexibility

This PR enhances the ccusage extension with two major improvements:

  1. 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.

  2. 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

  • useDirectCcusageCommand preference in package.json
  • Version parsing and sorting functionality in node-path-resolver.ts
  • Enhanced PATH resolution for multiple Node.js version managers

Changed

  • Updated all CLI hooks to support direct command execution
  • Simplified dependencies by removing usehooks-ts
  • Improved .gitignore rules

Fixed

  • Enhanced compatibility with various Node.js installations (nvm, fnm, volta)
  • Better npx binary discovery across different environments

Screencast

image

Checklist

- 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
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: ccusage Issues related to the ccusage extension AI Extension labels Sep 1, 2025
@raycastbot

raycastbot commented Sep 1, 2025 •

Copy link
Copy Markdown
Collaborator

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.

@zzyfisher zzyfisher changed the title Update ccusage extension []feat: enhance Node.js path resolution and CLI execution flexibility Sep 1, 2025
@zzyfisher zzyfisher changed the title []feat: enhance Node.js path resolution and CLI execution flexibility [ccusage]feat: enhance Node.js path resolution and CLI execution flexibility, preventing ccusage execution failures Sep 1, 2025
@zzyfisher
zzyfisher marked this pull request as ready for review September 1, 2025 12:50
@pernielsentikaer

Copy link
Copy Markdown
Contributor

Hi @zzyfisher👋

Thanks for your contribution 🔥

@nyatinte do you want to check this?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Edit Code Review Bot Settings | Greptile

Comment on lines +20 to +21
const [, major, minor, patch] = versionMatch;
return parseInt(major) * 1000000 + parseInt(minor) * 1000 + parseInt(patch);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style: Consider using parseInt(major, 10) to explicitly specify base 10 and avoid potential issues with leading zeros

@nyatinte

nyatinte commented Sep 2, 2025 •

Copy link
Copy Markdown
Contributor

Hello @zzyfisher!
Thanks for the PR! 🎉 The Node.js version sorting and direct command execution features look great - exactly what we needed to fix those execution failures.
I’m diving into the review now. Hang tight while I check everything out and test it properly. Will get back to you with feedback shortly!
Appreciate your contribution!

@nyatinte nyatinte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've made a few comments! Please make the necessary corrections. Overall, the revisions were excellent!


.claude
.claude
.history

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nits-badge

Is this change directly related to the main topic of this PR? If it concerns personal local settings that are not relevant, it would be helpful if you could exclude it to minimize the impact of the PR.

"contributors": [
"bohdan_zhuravel"
"bohdan_zhuravel",
"zzyfisher"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

congrats!!

Comment on lines +15 to +21
// 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

must-badge

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!

Comment on lines +11 to +15
const useDirectCommand = preferences.useDirectCcusageCommand;

const command = useDirectCommand ? "ccusage" : "npx";
const args = useDirectCommand ? ["daily", "--json"] : ["ccusage@latest", "daily", "--json"];
const result = useExec(command, args, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@pernielsentikaer

Copy link
Copy Markdown
Contributor

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 Ready for review when it's ready and we'll have a look 😊

@pernielsentikaer
pernielsentikaer marked this pull request as draft September 3, 2025 11:20
@nyatinte

Copy link
Copy Markdown
Contributor

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!

@nyatinte

nyatinte commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

@raycastbot close this pr
this pr has been moved #22740

@raycastbot

Copy link
Copy Markdown
Collaborator

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 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label Jan 27, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

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.

@raycastbot raycastbot closed this Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Extension extension: ccusage Issues related to the ccusage extension extension fix / improvement Label for PRs with extension's fix improvements status: stalled Stalled due inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants