
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
Transform your development workflow with intelligent command translation, code analysis, and seamless Jira/GitHub integration. N2B provides a suite of tools to enhance productivity.
IMPORTANT: Command Restructuring in v2.0
The
n2b
andn2b-diff
commands have been restructured in version 2.0.
n2b
is now solely for natural language to shell command translation.n2b-diff
handles both AI-powered merge conflict resolution AND AI-powered code diff analysis (previouslyn2b --diff
).Please see our MIGRATION.md for details on adapting your commands and workflows.
Transform your development workflow with intelligent code analysis and seamless Jira integration. N2B is an AI-powered development tool that revolutionizes code review, requirements compliance, and project management through automated diff analysis, smart merge conflict resolution, and intelligent ticket integration.
n2b-diff --analyze
)n2b-diff --analyze
.n2b-diff --analyze
)git
/hg
changes.-m/--message
option.n2b
)n2b-diff
): Interactive merge conflict resolver with HTML audit logs.n2b-diff
.n2b-diff --analyze
โก Beta FeatureGet instant, intelligent code review for every change you make. The n2b-diff --analyze
command provides comprehensive insights into your code changes, helping you catch issues early and maintain high code quality.
# Analyze your current changes
n2b-diff --analyze
# Compare against main branch with requirements checking and a custom message
n2b-diff --analyze --branch main --requirements requirements.md -m "Focus on security aspects"
# Full workflow with Jira integration
n2b-diff --analyze --jira PROJ-123 --update
This is a beta feature and we're actively improving it based on real-world usage. Your feedback is invaluable! Please share your experience:
n2b-diff --analyze
Transform your development workflow with intelligent Jira and GitHub issue integration:
# Install and configure
gem install n2b
n2b --advanced-config # Set up Jira credentials
# Test your connection
n2b-test-jira # (This command might need review if its scope changes)
# Analyze code against ticket requirements
n2b-diff --analyze --jira PROJ-123 --update
# Analyze code against GitHub issue requirements
n2b-diff --analyze --github your-org/your-repo/issues/42 --update
# Working on ticket PROJ-123
git add .
n2b-diff --analyze --jira PROJ-123 --update
Result: Your Jira ticket (or GitHub issue) gets updated with a professional analysis comment showing implementation progress, technical insights, and compliance status.
N2B now generates beautiful HTML merge logs that provide complete audit trails of your merge conflict resolutions:
# Enable merge logging in config (if not already enabled)
n2b -c
# Resolve conflicts - HTML log automatically generated
n2b-diff conflicted_file.rb
# Find your logs
open .n2b_merge_log/2025-01-08-143022.html
N2B offers two primary commands for different aspects of your workflow:
1. n2b
(Natural Language to Shell Commands)
Use n2b
for translating your plain English (or other language) descriptions into shell commands.
n2b "list all ruby files modified in the last 2 days"
n2b -x "create a backup of my_app.log"
2. n2b-diff
(Merge Conflict Resolution & Diff Analysis)
Use n2b-diff
for AI-assisted merge conflict resolution and for detailed AI-powered analysis of your code changes (diffs).
Diff Analysis Examples:
# Analyze uncommitted changes
n2b-diff --analyze
# Compare against specific branch with requirements and custom message
n2b-diff --analyze --branch main --requirements requirements.md -m "Ensure all new functions are documented."
# Full workflow with Jira integration
n2b-diff --analyze --jira PROJ-123 --requirements specs.md --update
N2B_DEBUG=true
for detailed troubleshooting when neededn2b
for command translation, n2b-diff
for merge conflicts and all-new AI diff analysis. See MIGRATION.md.-m/--message
option with n2b-diff --analyze
.n2b-diff
: Now the central hub for code analysis, supporting branches, requirements files, Jira/GitHub integration, and custom analysis instructions.gem install n2b
For users with rbenv (Ruby version manager), install globally to make n2b available across all Ruby versions:
# Option 1: Install in system Ruby (Recommended)
rbenv global system
gem install n2b
rbenv rehash
# Option 2: Install in a dedicated Ruby version
rbenv install 3.3.0
rbenv global 3.3.0
gem install n2b
rbenv rehash
# Verify installation works across Ruby versions
rbenv shell 3.1.0 && n2b --version
rbenv shell 3.2.0 && n2b --version
If n2b-diff
command is not found after installation:
# Remove corrupted shim and regenerate
rm ~/.rbenv/shims/.rbenv-shim
rm -rf ~/.rbenv/shims/*
rbenv rehash
# Verify both commands are available
which n2b
which n2b-diff
Add to your ~/.gitconfig
:
[merge]
tool = n2b-diff
[mergetool "n2b-diff"]
cmd = n2b-diff "$MERGED"
trustExitCode = true
keepBackup = false
Usage:
git merge feature-branch
# CONFLICT (content): Merge conflict in file.rb
git mergetool # Uses n2b-diff automatically
Add to your ~/.hgrc
:
[ui]
merge = n2b-diff
[merge-tools]
n2b-diff.executable = n2b-diff
n2b-diff.args = $output
n2b-diff.premerge = keep
n2b-diff.priority = 100
Usage:
hg merge
# conflict in file.rb
# n2b-diff launches automatically
n2b-diff --analyze
) (โก Beta - Try It Now!)# Get instant AI analysis of your changes
n2b-diff --analyze
# Compare against main branch with requirements checking and custom message
n2b-diff --analyze --branch main --requirements specs.md -m "Check for API compatibility."
# Full workflow with Jira integration
n2b-diff --analyze --jira PROJ-123 --update
# Set up Jira/GitHub integration (done once via n2b's config)
n2b --advanced-config
# Analyze code changes against a Jira ticket
n2b-diff --analyze --jira PROJ-123 --update
# Analyze code changes against a GitHub issue
n2b-diff --analyze --github your-org/your-repo/issues/42 --update
n2b
)# Generate bash commands
n2b "create a new git repo and push to github"
# Execute commands directly
n2b -x "backup all .rb files to backup folder"
First, require and extend the N2B module:
require 'n2b'
extend N2B::IRB
For automatic loading in every IRB session, add these lines to your ~/.irbrc
:
require 'n2b'
extend N2B::IRB
After loading, you can use the following commands:
n2r
- For general Ruby assistancen2rrbit
- For Errbit error analysisn2rscrum
- For generating Scrum tickets# Get help with a Ruby question
n2r "How do I parse JSON in Ruby?"
# Analyze an Errbit error
n2rrbit(url: "your_errbit_url", cookie: "your_cookie")
# Generate a Scrum ticket
n2rscrum "Create a user authentication system"
N2B now features a flexible model configuration system that supports both suggested models and custom model names across all providers.
Run the configuration command to get started:
n2b -c
This will guide you through:
haiku
โ claude-3-haiku-20240307sonnet
โ claude-3-sonnet-20240229sonnet35
โ claude-3-5-sonnet-20240620sonnet37
โ claude-3-7-sonnet-20250219sonnet40
โ claude-sonnet-4-20250514gpt-4o
โ gpt-4ogpt-4o-mini
โ gpt-4o-minio3
โ o3 (Latest reasoning model)o3-mini
โ o3-minio3-mini-high
โ o3-mini-higho4
โ o4o4-mini
โ o4-minio4-mini-high
โ o4-mini-highgemini-2.5-flash
โ gemini-2.5-flash-preview-05-20gemini-2.5-pro
โ gemini-2.5-pro-preview-05-06deepseek-v3
โ deepseek-v3-0324deepseek-r1-llama-8b
โ deepseek-r1-distill-llama-8bllama-3.3-70b
โ llama-3.3-70b-instructllama-3.3-8b
โ llama-3.3-8b-instructwayfinder-large
โ wayfinder-large-70b-llama-3.3llama3
โ llama3mistral
โ mistralcodellama
โ codellamaqwen
โ qwen2.5You can use a custom config file by setting the N2B_CONFIG_FILE
environment variable:
export N2B_CONFIG_FILE=/path/to/your/config.yml
You can also set the history file location using the N2B_HISTORY_FILE
environment variable:
export N2B_HISTORY_FILE=/path/to/your/history
For troubleshooting Jira integration or other issues, enable debug mode:
export N2B_DEBUG=true
n2b-diff --analyze --jira PROJ-123 --update
This will show detailed information about:
N2B uses text templates for AI prompts. To override them, specify paths in your configuration:
templates:
diff_system_prompt: /path/to/my_system_prompt.txt
diff_json_instruction: /path/to/my_json_instruction.txt
merge_conflict_prompt: /path/to/my_merge_prompt.txt
When these paths are not provided, the built-in templates located in lib/n2b/templates/
are used.
Available Templates:
diff_system_prompt.txt
- Main diff analysis promptdiff_json_instruction.txt
- JSON formatting instructions for diff analysismerge_conflict_prompt.txt
- Merge conflict resolution promptN2B allows you to configure your preferred text editor or visual diff tool for use with the [e]
(Edit) option during merge conflict resolution. This can be set up during the advanced configuration flow (run n2b --advanced-config
or n2b -c
and choose to configure advanced settings).
You will be prompted to choose from a list of auto-detected editors (like nano
, vim
, code
- VS Code) and diff tools (like meld
, kdiff3
, vimdiff
). You can also provide a custom command.
The chosen editor is stored in your ~/.n2b/config.yml
file under the editor
key:
editor:
command: "meld"
type: "diff_tool" # Can be "text_editor" or "diff_tool"
configured: true
[e]
option will open the conflicted file directly for manual editing using the specified editor command.n2b init a new github repo called abc, add local files, transmit
results in
Translated /bin/zsh Commands:
------------------------
git init
git remote add origin https://github.com/yourusername/abc.git
git add .
git commit -m 'Initial commit'
git push -u origin main
------------------------
Explanation:
These commands initialize a new Git repository, add a remote GitHub repository named 'abc', stage all local files, create an initial commit, and push the changes to GitHub. Replace 'yourusername' with your actual GitHub username. Note that you'll need to create the repository on GitHub first before running these commands. Also, ensure you have Git installed and configured with your GitHub credentials.
irb
require 'n2b'
n2r 4544 # results in exception
n2r "what is the bug",exception:_
result
input_string.to_s.scan(/[\/\w.-]+\.rb(?=\s|:|$)/)
Explanation
The error undefined method 'scan' for 7767:Integer
occurs because the method scan
is being called on an integer instead of a string. To fix the issue, we need to ensure that input_string
is a string before calling the scan
method on it. Here's the corrected part of the code that converts input_string
to a string before using scan
:
input_string.to_s.scan(/[\/\w.-]+\.rb(?=\s|:|$)/)
Install the gem by running: gem install n2b
N2B v0.4.0 introduces a flexible model configuration system:
When you run n2b -c
, you'll see an enhanced interface:
Choose a model for openai:
1. gpt-4o (gpt-4o)
2. gpt-4o-mini (gpt-4o-mini) [default]
3. o3 (o3)
4. o3-mini (o3-mini)
5. o3-mini-high (o3-mini-high)
6. o4 (o4)
7. o4-mini (o4-mini)
8. o4-mini-high (o4-mini-high)
9. custom (enter your own model name)
Enter choice (1-9) or model name [gpt-4o-mini]: 9
Enter custom model name: gpt-5-preview
โ Using custom model: gpt-5-preview
Configuration is stored in ~/.n2b/config.yml
.
Basic usage:
n2b [options] "your natural language instruction"
n2b
Options:
-x
, --execute
: Execute the translated commands after confirmation.-c
, --config
: Configure N2B (API key, model, privacy settings, etc.).--advanced-config
: Access advanced configuration options.-v
, --version
: Show version information.-h
, --help
: Display help information for n2b
.n2b-diff
Command Usage:
n2b-diff [FILE] [options]
(for merge conflicts)
n2b-diff --analyze [options]
(for code diff analysis)
n2b-diff
Options:
Merge Conflict Mode (when FILE is provided and not --analyze):
- --context N
: Number of context lines to display around a merge conflict.
Diff Analysis Mode (--analyze
):
- -a
, --analyze
: Activate AI-powered diff analysis.
- --branch [BRANCH_NAME]
: Specify branch to compare against (e.g., 'main', 'develop'). Defaults to auto-detected primary branch.
- -j
, --jira JIRA_ID_OR_URL
: Link a Jira ticket for context or updates.
- --github GITHUB_ISSUE_URL
: Link a GitHub issue for context or updates (e.g., 'owner/repo/issues/123').
- -r
, --requirements FILE_PATH
: Provide a requirements file for the AI.
- -m
, --message "TEXT"
: Add custom instructions for the AI analysis.
- --update
: If -j or --github is used, attempt to update the ticket/issue with the analysis (prompts for confirmation by default unless this flag is used for auto-yes).
- --no-update
: Prevent updating the ticket/issue.
Common for n2b-diff
:
- -h
, --help
: Display help information for n2b-diff
.
- -v
, --version
: Show version information.
Other Commands:
n2b-test-jira
: Test Jira API connection and permissions (functionality might be reviewed/updated).Examples:
n2b list all PDF files in the current directory
n2b -x create a new directory named 'project' and initialize a git repository in it
n2b -c
n2b-diff --analyze
)n2b-diff --analyze
provides comprehensive AI-powered code review for your Git and Mercurial repositories.
# Analyze uncommitted changes (against HEAD or default compare target)
n2b-diff --analyze
# Analyze changes against a specific branch
n2b-diff --analyze --branch main
n2b-diff --analyze --branch feature/auth
# Auto-detect default branch (main/master/default) if --branch is provided without a value
n2b-diff --analyze --branch
# Check if changes meet requirements from a file
n2b-diff --analyze --requirements requirements.md
# Combine with branch comparison and add a custom message for the AI
n2b-diff --analyze --branch main --requirements requirements.md -m "Pay special attention to the new UserProfile class."
The AI analysis provides:
Code Diff Analysis:
-------------------
Summary:
Added user authentication with JWT tokens and password validation.
Potential Errors:
- lib/auth.rb line 42: Password validation allows weak passwords
- controllers/auth_controller.rb lines 15-20: Missing rate limiting for login attempts
Suggested Improvements:
- lib/auth.rb line 30: Consider using bcrypt for password hashing
- spec/auth_spec.rb: Add tests for edge cases and security scenarios
Test Coverage Assessment:
Good: Basic authentication flow is tested. Missing: No tests for password validation edge cases, JWT expiration handling, or security attack scenarios.
Requirements Evaluation:
โ
IMPLEMENTED: User login/logout functionality fully working
โ ๏ธ PARTIALLY IMPLEMENTED: Password strength requirements present but not comprehensive
โ NOT IMPLEMENTED: Two-factor authentication not addressed in this diff
-------------------
n2b-diff --analyze
)n2b-diff --analyze
provides seamless integration with Jira and GitHub for automated ticket/issue analysis and updates.
Configure Jira integration using the advanced configuration:
n2b --advanced-config
You'll need:
company.atlassian.net
)Your API token needs these specific scopes:
Essential Scopes:
read:project:jira
- View projects (access project list)read:issue:jira
- View issues (fetch ticket details)read:comment:jira
- View comments (fetch ticket comments for context)write:comment:jira
- Create and update comments (post analysis results)Optional but Recommended:
read:issue-details:jira
- View detailed issue informationread:issue.property:jira
- View issue properties (comprehensive ticket data)Legacy Permission Names (for older Jira versions):
# Analyze code changes against Jira ticket requirements
n2b-diff --analyze --jira PROJ-123
# Use full Jira URL
n2b-diff --analyze --jira https://company.atlassian.net/browse/PROJ-123
# Auto-update Jira ticket without prompt (if configured and supported by client)
n2b-diff --analyze --jira PROJ-123 --update
# Analyze only, do not offer to update Jira ticket
n2b-diff --analyze --jira PROJ-123 --no-update
# Analyze code changes against GitHub issue, with custom message and update
n2b-diff --analyze --github your-org/your-repo/issues/42 -m "Focus on UI changes" --update
*N2B Code Analysis Report*
=========================
*Implementation Summary:*
Implemented user authentication with JWT tokens, password validation,
and session management as specified in the ticket requirements.
---
*Automated Analysis Findings:*
*Technical Changes:*
Added authentication middleware, JWT token generation, and password
hashing with bcrypt. Updated user model with authentication methods.
*Potential Issues/Risks:*
โข No rate limiting on login attempts
โข Password validation could be stronger
*Suggested Improvements:*
โข Add rate limiting middleware
โข Implement password strength requirements
โข Add two-factor authentication support
*Test Coverage Assessment:*
Good: Basic authentication flow tested. Missing: Edge cases, security
scenarios, and JWT expiration handling tests.
*Requirements Evaluation:*
โ
IMPLEMENTED: User login/logout functionality
โ
IMPLEMENTED: Password hashing and validation
โ ๏ธ PARTIALLY IMPLEMENTED: Session management (basic implementation)
โ NOT IMPLEMENTED: Two-factor authentication
Test your Jira API connection and permissions:
# Test basic connection
n2b-test-jira
# Test specific ticket access
n2b-test-jira PROJ-123
This will verify:
Resolve Git and Mercurial merge conflicts with intelligent AI assistance.
# Resolve conflicts in a file
n2b-diff conflicted_file.rb
# With more context lines
n2b-diff conflicted_file.rb --context 20
# Get help
n2b-diff --help
<<<<<<<
, =======
, >>>>>>>
markersFor each conflict, you can:
When resolving merge conflicts with n2b-diff
, N2B now automatically generates a 3-way HTML preview of the conflict.
file:///
link to the preview is also displayed in your terminal.
๐ Opening conflict preview in browser...
๐ Preview: file:///Users/user/.n2b_merge_log/conflict_preview_your_file.rb_20231027_103045.html
Actions: [y] Accept, [n] Skip, [c] Comment, [e] Edit, [s] Refresh Preview, [a] Abort
(Preview link above can be cmd/ctrl+clicked if your terminal supports it)
Your choice:
[e]
edit option and a new suggestion is fetched) or if you use the [s]
(Refresh Preview) option..n2b_merge_log/
directory and are automatically cleaned up after the conflict is resolved or skipped for that particular block.<<<<<<< HEAD
)>>>>>>> feature
)=======
)--context N
(default: 10).n2b_merge_log/
$ n2b-diff user_service.rb
<<<<<<< HEAD
def create_user(name, email)
# Basic validation
raise "Invalid" if name.empty?
User.create(name: name, email: email)
end
=======
def create_user(name, email, age = nil)
# Enhanced validation
validate_name(name)
validate_email(email)
User.create(name: name.titleize, email: email.downcase, age: age)
end
>>>>>>> feature/enhanced-validation
--- Suggestion ---
def create_user(name, email, age = nil)
# Enhanced validation with fallback
validate_name(name) if respond_to?(:validate_name)
validate_email(email) if respond_to?(:validate_email)
User.create(name: name.titleize, email: email.downcase, age: age)
end
Reason: Combined enhanced validation from feature branch with safety checks
for method existence, maintaining backward compatibility while adding new features.
Accept [y], Skip [n], Comment [c], Abort [a]: y
Customize merge prompts by adding to your config:
templates:
merge_conflict_prompt: /path/to/my_merge_prompt.txt
Template variables available:
{full_file_content}
- Complete file content for full context understanding{context_before}
- Code before the conflict{context_after}
- Code after the conflict{base_label}
- Base branch label (e.g., "HEAD"){base_content}
- Base branch content{incoming_label}
- Incoming branch label (e.g., "feature/auth"){incoming_content}
- Incoming branch content{user_comment}
- User-provided comment (if any)# During merge conflicts
git merge feature-branch
# CONFLICT (content): Merge conflict in file.rb
# Use configured merge tool
git mergetool
# Or call directly
n2b-diff file.rb
# Continue merge
git add file.rb
git commit -m "Resolve merge conflicts"
# During hg merge conflicts
hg merge
# conflict in file.rb
# Resolve with n2b-diff (auto-launches if configured)
n2b-diff file.rb
# Mark as resolved and commit
hg resolve --mark file.rb
hg commit -m "Resolve merge conflicts"
# Git rebase conflicts
git rebase -i main
# CONFLICT: Merge conflict in user_service.rb
n2b-diff user_service.rb
git add user_service.rb
git rebase --continue
# Find and resolve all conflicts
find . -name "*.rb" -exec grep -l "<<<<<<< HEAD" {} \; | while read file; do
echo "Resolving conflicts in $file"
n2b-diff "$file"
done
Add to your .zshrc
or .bashrc
:
# Quick aliases for n2b tools
alias resolve-conflicts='n2b-diff' # For merge conflicts
alias test-jira='n2b-test-jira' # For testing Jira connection
alias ai-diff='n2b-diff --analyze' # For AI diff analysis
# Function to resolve all conflict files
resolve-all-conflicts() {
find . -name "*.rb" -exec grep -l "<<<<<<< HEAD" {} \; | while read file; do
echo "Resolving conflicts in $file"
n2b-diff "$file"
done
}
n2r in ruby or rails console n2r "your question", files:['file1.rb', 'file2.rb'], exception: AnError only question is mandatory
N2B::IRB.n2r if no shortcut defined
create an initializer
# config/initializers/n2r.rb
require 'n2b/irb'
Rails.application.config.after_initialize do
Object.include(Module.new do
def n2r(input_string = '', files: [], exception: nil, log: false)
N2B::IRB.n2r(input_string, files: files, exception: exception, log: log)
end
end)
end
N2B allows you to configure what information is sent to the Claude API:
You can adjust these settings during configuration.
Always sent to llm
-x
option.Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
n2b
is now for natural language to shell command translation only. n2b-diff
handles merge conflicts and all AI-powered diff/code analysis. See MIGRATION.md.n2b-diff --analyze
:
--github
option for GitHub Issue integration (fetching details, updating issues).-m, --message, --msg
option for providing custom instructions to the AI during diff analysis.--jira
, --update
, --no-update
).n2b-diff --analyze
.MIGRATION.md
.n2b
and significantly enhanced tests for n2b-diff
.N2B::MessageUtils
for message handling.n2b --diff
) (Pre-Restructure)n2b-diff
)n2b --diff
)n2b-test-jira
utility.n2b --diff
)If you encounter any issues or have questions, please file an issue on the GitHub repository.
Create well-formatted Scrum tickets from Errbit errors:
require 'n2b'
# Generate a Scrum ticket from an Errbit error
n2rscrum(
url: "https://your-errbit-instance/apps/12345/problems/67890",
cookie: "your_errbit_session_cookie",
source_dir: "/path/to/your/app" # Optional: source code directory
)
The generated tickets include:
FAQs
Unknown package
We found that n2b demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.ย It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.