Skip to content

Fixes/initial fixes #29

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fixes/initial fixes #29

wants to merge 2 commits into from

Conversation

tonyboylehub
Copy link
Contributor

No description provided.

Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

Summary by CodeRabbit

  • Documentation

    • Added a changelog file to document notable project updates, including initial public beta release and improvements to wallet path handling and error messages.
  • Bug Fixes

    • Improved wallet path handling by normalizing and validating absolute paths, ensuring consistent storage and preventing errors from directory changes.
    • Enhanced error messages for wallet configuration commands.
  • New Features

    • Expanded help descriptions, usage examples, and help text formatting for command-line tools, improving clarity and user guidance across asset, collection, plugin, and toolbox commands.

Walkthrough

The changes introduce a new changelog file and enhance wallet path handling in configuration commands by normalizing and validating file paths, improving error messages, and ensuring consistent storage of absolute paths. Additionally, command index pages for core and toolbox modules are updated with detailed descriptions, usage examples, help flag definitions, and improved help output behavior.

Changes

Files/Groups Change Summary
CHANGELOG.md Added new changelog documenting unreleased changes and initial public beta release.
src/commands/config/wallets/add.ts, set.ts, new.ts Normalized wallet file paths to absolute paths, improved file existence checks, path storage, and error handling.
src/commands/core/index.ts, asset/index.ts, collection/index.ts, plugins/index.ts Expanded descriptions, added concrete usage examples, defined help flags, and improved help output in run methods.
src/commands/toolbox/index.ts, sol/index.ts, token/index.ts Renamed class (index.ts), added detailed descriptions, usage examples, help flags, and improved help output.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI_Command
    participant FileSystem
    participant Config

    User->>CLI_Command: Run wallet add/set/new command with file path
    CLI_Command->>FileSystem: Normalize path to absolute
    CLI_Command->>FileSystem: Check if wallet file exists
    alt File exists
        CLI_Command->>Config: Store absolute path in config
        CLI_Command-->>User: Success message
    else File does not exist
        CLI_Command-->>User: Error message (file not found)
    end
Loading

Suggested reviewers

  • nhanphan
  • blockiosaurus
✨ 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.

Copy link
Contributor

@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: 16

🔭 Outside diff range comments (2)
src/commands/config/wallets/new.ts (1)

94-108: ⚠️ Potential issue

Avoid manual backslash escaping – leads to double-escaped paths & duplicate-detection bugs

filePath.replace(/\\/g, '\\\\') stores a different string than the one you just compared against in existingPath.
At runtime the parsed JSON already contains single back-slashes (they’re escaped only in the file), so the extra .replace():

  1. Produces a double-escaped value in memory → JSON ends up with quadruple back-slashes on every save.
  2. Breaks the existingPath check, letting the same wallet be added twice on Windows.
-            const newWallet = {
-                name: flags.name,
-                path: filePath.replace(/\\/g, '\\\\'), // Escape backslashes for JSON
+            const newWallet = {
+                name: flags.name,
+                path: filePath,                       // JSON.stringify will escape as needed
src/commands/config/wallets/add.ts (1)

39-46: 🧹 Nitpick (assertive)

Path validation is case-sensitive – .JSON files fail unexpectedly

endsWith('.json') rejects valid keypair files with an upper-case extension on Windows/macOS.

-if (!args.path.endsWith('.json')) {
+if (!args.path.toLowerCase().endsWith('.json')) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52686a8 and 87d0a39.

📒 Files selected for processing (11)
  • CHANGELOG.md (1 hunks)
  • src/commands/config/wallets/add.ts (4 hunks)
  • src/commands/config/wallets/new.ts (3 hunks)
  • src/commands/config/wallets/set.ts (2 hunks)
  • src/commands/core/asset/index.ts (1 hunks)
  • src/commands/core/collection/index.ts (1 hunks)
  • src/commands/core/index.ts (1 hunks)
  • src/commands/core/plugins/index.ts (1 hunks)
  • src/commands/toolbox/index.ts (1 hunks)
  • src/commands/toolbox/sol/index.ts (1 hunks)
  • src/commands/toolbox/token/index.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/commands/config/wallets/add.ts

[error] 3-3: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)

src/commands/config/wallets/set.ts

[error] 6-6: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)


[error] 8-8: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)

🪛 markdownlint-cli2 (0.17.2)
CHANGELOG.md

7-7: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


8-8: Lists should be surrounded by blank lines
null

(MD032, blanks-around-lists)


14-14: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


15-15: Lists should be surrounded by blank lines
null

(MD032, blanks-around-lists)


25-25: Files should end with a single newline character
null

(MD047, single-trailing-newline)

Comment on lines +24 to 33
public async run(): Promise<void> {
const {args, flags} = await this.parse(ToolboxSol)

// Show help by default
this.log(ToolboxSol.description)
this.log('\nExamples:')
ToolboxSol.examples.forEach(example => {
this.log(` ${example}`)
})
}
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 13, 2025

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Leverage Oclif’s built-in help instead of manual logging

Re-implementing help text risks divergence from actual flags/examples.
Consider delegating to Oclif to keep maintenance low:

-    // Show help by default
-    this.log(ToolboxSol.description)
-    this.log('\nExamples:')
-    ToolboxSol.examples.forEach(example => {
-      this.log(`  ${example}`)
-    })
+    // Show generated help output
+    await this.showHelp(['--help'])
🤖 Prompt for AI Agents
In src/commands/toolbox/sol/index.ts around lines 24 to 33, the run method
manually logs the help description and examples, which risks becoming outdated.
Replace this manual logging by invoking Oclif's built-in help command or method
to automatically display the current help text, ensuring consistency and
reducing maintenance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

await this.showHelp(['--help']) doesn't exist.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tonyboylehub You’re right—showHelp isn’t part of @oclif/core’s Command API.
The usual ways to display help programmatically are:

  1. Call the command’s own help generator:

    // inside run()
    await this.parse(ToolboxSol);        // keep your current parse
    await this.config.runCommand(this.id, ['--help']);

    config.runCommand() re-invokes the command with --help, so the standard help system handles description, flags and examples.

  2. Or use the generic Help class:

    import {Help} from '@oclif/core';
    
    // …
    const help = new Help(this.config);
    await help.showHelp(['toolbox','sol']);

    This instantiates the built-in Help renderer directly.

If you prefer to stay lightweight, keeping the custom this.log(...) block is perfectly valid—just be aware it may drift from the actual flag/description strings over time.

Let me know which route you’d like to take and I can adjust the suggestion accordingly.

@@ -1,18 +1,33 @@
import {Args, Command, Flags} from '@oclif/core'
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Remove unused Args import.

-import {Args, Command, Flags} from '@oclif/core'
+import {Command, Flags} from '@oclif/core'
📝 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.

Suggested change
import {Args, Command, Flags} from '@oclif/core'
import {Command, Flags} from '@oclif/core'
🤖 Prompt for AI Agents
In src/commands/core/index.ts at line 1, the imported `Args` from '@oclif/core'
is not used anywhere in the file. Remove `Args` from the import statement to
clean up unused imports and improve code clarity.

Comment on lines 49 to 57
const {args, flags} = await this.parse(CorePlugins)


// Show help by default
this.log(CorePlugins.description)
this.log('\nExamples:')
CorePlugins.examples.forEach(example => {
this.log(` ${example}`)
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Drop unused destructuring from parse call

The command neither reads args nor flags, so the destructured variables are unused (and may trigger lint warnings).
You can keep the call—it validates input—while avoiding the unused bindings:

-    const {args, flags} = await this.parse(CorePlugins)
+    await this.parse(CorePlugins) // validate CLI input

Optional: you can replace the custom logging with this._help(), letting oclif format the description & examples consistently across commands.

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

Suggested change
const {args, flags} = await this.parse(CorePlugins)
// Show help by default
this.log(CorePlugins.description)
this.log('\nExamples:')
CorePlugins.examples.forEach(example => {
this.log(` ${example}`)
})
}
await this.parse(CorePlugins) // validate CLI input
// Show help by default
this.log(CorePlugins.description)
this.log('\nExamples:')
CorePlugins.examples.forEach(example => {
this.log(` ${example}`)
})
}
🤖 Prompt for AI Agents
In src/commands/core/plugins/index.ts around lines 49 to 57, the destructured
variables 'args' and 'flags' from the parse call are unused and may cause lint
warnings. To fix this, remove the destructuring and just await the parse call
without assigning its result. Optionally, replace the manual logging of
description and examples with a call to this._help() to leverage oclif's
consistent help formatting.

Comment on lines +5 to +34
static override description = `MPL Core Plugin Management - Add and manage plugins for assets and collections

The plugin commands provide functionality for managing plugins that extend the capabilities of assets and collections on the Solana blockchain.

Available subcommands:
add - Add plugins to assets or collections (with wizard or JSON config)
remove - Remove plugins from assets or collections
generate - Generate reusable plugin configuration files for scripting

Available Plugin Types:
Common Plugins (Asset & Collection):
- Attributes
- Royalties
- Update Delegate
- Permanent Freeze
- Permanent Transfer
- Permanent Burn
- Add Blocker
- Immutable Metadata
- Autograph
- Verified Creators

Collection-specific Plugins:
- Master Edition

Asset-specific Plugins:
- Edition
- Freeze Delegate
- Burn Delegate
- Transfer Delegate`
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Trim leading indentation in the multi-line description string

The template literal captures all the leading spaces that appear in the source file, so the CLI prints each line indented by two spaces. This makes the help text look slightly “shifted” compared with oclif’s built-in help for other commands.

A low-impact tweak is to strip the indentation at build time so the output is perfectly left-aligned:

-  static override description = `MPL Core Plugin Management - Add and manage plugins for assets and collections
-  ...
-    - Transfer Delegate`
+  static override description = [
+    'MPL Core Plugin Management - Add and manage plugins for assets and collections',
+    '',
+    'The plugin commands provide functionality for managing plugins that extend the capabilities of assets and collections on the Solana blockchain.',
+    '',
+    'Available subcommands:',
+    '  add      - Add plugins to assets or collections (with wizard or JSON config)',
+    '  remove   - Remove plugins from assets or collections',
+    '  generate - Generate reusable plugin configuration files for scripting',
+    '',
+    'Available Plugin Types:',
+    '  Common Plugins (Asset & Collection):',
+    '    - Attributes',
+    '    - Royalties',
+    '    - Update Delegate',
+    '    - Permanent Freeze',
+    '    - Permanent Transfer',
+    '    - Permanent Burn',
+    '    - Add Blocker',
+    '    - Immutable Metadata',
+    '    - Autograph',
+    '    - Verified Creators',
+    '',
+    '  Collection-specific Plugins:',
+    '    - Master Edition',
+    '',
+    '  Asset-specific Plugins:',
+    '    - Edition',
+    '    - Freeze Delegate',
+    '    - Burn Delegate',
+    '    - Transfer Delegate',
+  ].join('\n')

Any string-dedent helper (e.g. common-tagsstripIndent) would achieve the same effect with less boilerplate.

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

Suggested change
static override description = `MPL Core Plugin Management - Add and manage plugins for assets and collections
The plugin commands provide functionality for managing plugins that extend the capabilities of assets and collections on the Solana blockchain.
Available subcommands:
add - Add plugins to assets or collections (with wizard or JSON config)
remove - Remove plugins from assets or collections
generate - Generate reusable plugin configuration files for scripting
Available Plugin Types:
Common Plugins (Asset & Collection):
- Attributes
- Royalties
- Update Delegate
- Permanent Freeze
- Permanent Transfer
- Permanent Burn
- Add Blocker
- Immutable Metadata
- Autograph
- Verified Creators
Collection-specific Plugins:
- Master Edition
Asset-specific Plugins:
- Edition
- Freeze Delegate
- Burn Delegate
- Transfer Delegate`
static override description = [
'MPL Core Plugin Management - Add and manage plugins for assets and collections',
'',
'The plugin commands provide functionality for managing plugins that extend the capabilities of assets and collections on the Solana blockchain.',
'',
'Available subcommands:',
' add - Add plugins to assets or collections (with wizard or JSON config)',
' remove - Remove plugins from assets or collections',
' generate - Generate reusable plugin configuration files for scripting',
'',
'Available Plugin Types:',
' Common Plugins (Asset & Collection):',
' - Attributes',
' - Royalties',
' - Update Delegate',
' - Permanent Freeze',
' - Permanent Transfer',
' - Permanent Burn',
' - Add Blocker',
' - Immutable Metadata',
' - Autograph',
' - Verified Creators',
'',
' Collection-specific Plugins:',
' - Master Edition',
'',
' Asset-specific Plugins:',
' - Edition',
' - Freeze Delegate',
' - Burn Delegate',
' - Transfer Delegate',
].join('\n')
🤖 Prompt for AI Agents
In src/commands/core/plugins/index.ts between lines 5 and 34, the multi-line
description string includes leading spaces causing the CLI help text to be
indented and misaligned. To fix this, remove the leading indentation from each
line of the template literal so the output is left-aligned. You can do this by
using a string dedent helper like common-tags' stripIndent or manually trimming
the indentation in the string definition.

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.

1 participant