Coding Plugins

Coding

Code analysis, GitHub integration, and development tools to enhance your coding workflow

Table of Contents
  1. Overview
  2. List of Coding Plugins & Agents
  3. Comment
  4. Evaluate
  5. Get Code from GitHub Page
  6. Git Repository Analysis
  7. Search GitHub Repository

Overview


List of Coding Plugins & Agents

Available Plugins

Requires paid subscription
Comment

This plugin lets you comment your source code

Evaluate

This plugin lets you evaluate source code

Get Code from GitHub Page

Get the source code from a GitHub page

Git Repository Analysis

Scan a Git repository for security vulnerabilities, performance issues, and other problems

Search GitHub Repository

Search a GitHub repo for specific text


Comment

Comment Plugin

The Comment plugin is designed to enhance code readability and maintainability. It allows developers to easily add comments to their codebase, making it more understandable. It is particularly useful for those who have inherited a codebase and want to gain a better understanding of the code or for those who want to improve the documentation of their code.

Comment Code Plugin UI
1

Copy Your Code

Copy and paste your code snippet into the plugin.

2

Submit

Select Submit to generate the prompt to comment the code.

Example: Code Without Comments

import pandas as pd

def filter_and_sum_function(file_path, column_filters, delimiter=None, sum_columns=None):

    if file_path.endswith('.xlsx'):
        user_file = pd.read_excel(file_path)
    elif file_path.endswith('.txt') and delimiter:
        user_file = pd.read_csv(file_path, delimiter=delimiter)
    else:
        raise ValueError("Unsupported file type or missing delimiter for text files.")

    print("DataFrame before filtering:")
    display(user_file.head())

    start_count = len(user_file)

    for column, filters in column_filters.items():
        if column not in user_file.columns:
            print(f"Warning: Column '{column}' does not exist in the DataFrame.")
            continue

        filter_condition = pd.Series([False] * len(user_file))

        for filter_value in filters:
            if pd.api.types.is_string_dtype(user_file[column]):
                filter_condition |= user_file[column].str.contains(filter_value, case=False, na=False)
            elif pd.api.types.is_numeric_dtype(user_file[column]):
                try:
                    filter_value_numeric = float(filter_value)
                    filter_condition |= (user_file[column] == filter_value_numeric)
                except ValueError:
                    print(f"Warning: '{filter_value}' is not a valid number for column '{column}'.")
            else:
                print(f"Warning: Column '{column}' has unsupported data type for filtering.")

        user_file = user_file[filter_condition]

    print("Filtered DataFrame:")
    display(user_file)

    count = len(user_file)

    total_sums = {col: user_file[col].sum() for col in sum_columns} if sum_columns else None

    print(f"Total number of rows in the file before filtering: {start_count}")
    print(f'Count of filtered entries: {count}')
    if sum_columns:
        for col, total in total_sums.items():
            print(f'Total sum of {col} in filtered entries: {total}')

Result: Code With Comments

import pandas as pd

def filter_and_sum_function(file_path, column_filters, delimiter=None, sum_columns=None):
    """
    This function reads a file, filters the data based on user-defined column filters,
    and calculates the sum of specified columns in the filtered data.

    Parameters:
    - file_path (str): Path to the file to be processed.
    - column_filters (dict): Dictionary containing column names as keys and a list of filter values as values.
    - delimiter (str, optional): Delimiter used in case of a text file. Default is None.
    - sum_columns (list, optional): List of column names to calculate the sum. Default is None.

    Raises:
    - ValueError: If the file type is not supported or if a delimiter is missing for text files.

    Returns:
    - None
    """

    # Read the file based on the file type
    if file_path.endswith('.xlsx'):
        user_file = pd.read_excel(file_path)
    elif file_path.endswith('.txt') and delimiter:
        user_file = pd.read_csv(file_path, delimiter=delimiter)
    else:
        raise ValueError("Unsupported file type or missing delimiter for text files.")

    # Display the DataFrame before filtering
    print("DataFrame before filtering:")
    display(user_file.head())

    # Get the initial count of rows in the DataFrame
    start_count = len(user_file)

    # Apply column filters
    for column, filters in column_filters.items():
        if column not in user_file.columns:
            print(f"Warning: Column '{column}' does not exist in the DataFrame.")
            continue

        filter_condition = pd.Series([False] * len(user_file))

        for filter_value in filters:
            if pd.api.types.is_string_dtype(user_file[column]):
                filter_condition |= user_file[column].str.contains(filter_value, case=False, na=False)
            elif pd.api.types.is_numeric_dtype(user_file[column]):
                try:
                    filter_value_numeric = float(filter_value)
                    filter_condition |= (user_file[column] == filter_value_numeric)
                except ValueError:
                    print(f"Warning: '{filter_value}' is not a valid number for column '{column}'.")
            else:
                print(f"Warning: Column '{column}' has unsupported data type for filtering.")

        user_file = user_file[filter_condition]

    # Display the filtered DataFrame
    print("Filtered DataFrame:")
    display(user_file)

    # Get the count of rows in the filtered DataFrame
    count = len(user_file)

    # Calculate the sum of specified columns in the filtered DataFrame
    total_sums = {col: user_file[col].sum() for col in sum_columns} if sum_columns else None

    # Output results
    print(f"Total number of rows in the file before filtering: {start_count}")
    print(f'Count of filtered entries: {count}')
    if sum_columns:
        for col, total in total_sums.items():
            print(f'Total sum of {col} in filtered entries: {total}')
Auto-Detection: Users don't need to worry about the formatting of the comments as the plugin will automatically format the comments for you. Additionally, the plugin is able to identify the code language and generate comments accordingly.

Evaluate

Evaluate Plugin

The Evaluate plugin is designed to help developers evaluate code snippets. It is particularly useful for those who want to quickly see what improvements can be made to the code snippet.

Code Evaluate Plugin UI
1

Copy Your Code

Copy and paste your code snippet into the plugin.

2

Submit

Select Submit to generate the prompt to evaluate the code.

Evaluate Results

Ask Sage provides a detailed explanation of the improvements that can be made to the code snippet. This can help developers understand the best practices and coding standards that should be followed.

Improved Code Example

import pandas as pd
import argparse
import logging

logging.basicConfig(level=logging.INFO)

def filter_and_sum_function(file_path: str, column_filters: dict, delimiter: str = None, sum_columns: list = None):
    """
    Filters a DataFrame based on given column filters and calculates the sum of specified columns.

    Parameters:
    file_path (str): Path to the input file.
    column_filters (dict): Dictionary where keys are column names and values are lists of filter values.
    delimiter (str, optional): Delimiter for reading text files. Defaults to None.
    sum_columns (list, optional): List of columns to sum. Defaults to None.
    """
    try:
        if file_path.endswith('.xlsx'):
            user_file = pd.read_excel(file_path)
        elif file_path.endswith('.txt') and delimiter:
            user_file = pd.read_csv(file_path, delimiter=delimiter)
        else:
            raise ValueError("Unsupported file type or missing delimiter for text files.")
    except Exception as e:
        logging.error(f"Error reading file: {e}")
        return

    logging.info("DataFrame before filtering:")
    logging.info(user_file.head())

    # ... rest of improved code with proper logging and error handling

Key Improvements Made:

Added type hints
Proper logging instead of print
Error handling with try/except
Command-line argument parsing
Iterative Improvement: You can re-run the Evaluate plugin to see further improvements that can be made to the code snippet after each iteration. This not only helps with code improvement but also increases the productivity of developers.

Get Code from GitHub Page

Get Code from GitHub Page

The Get Code from GitHub Page plugin is designed to help developers extract code snippets from GitHub pages quickly. There are many instances where developers need to refer to code snippets from GitHub repositories, and this plugin makes it easy to do so.

1

Create a Secret

Create an Ask Sage secret to store your Git repository credentials.

The format of the secret should be:

Full Name, Email, and GitHub Access Token

/add-secret Johnny Doe|||johnny-doe@example.com|||ghp_1234567890
Successful Adding Secret
Security: Ask Sage secrets are encrypted and securely stored. You can use secrets to store sensitive information such as API keys, passwords, and other credentials.
2

Navigate to the Plugin

Navigate to the Ask Sage Plugins tool and select the Coding category. Then select Get Code from GitHub Page plugin.

Get Code Plugin UI
3

Configure and Submit

Select the secret you created and enter the URL of the GitHub file you want to extract code from.

4

View Results

Click submit to run the plugin and extract the code from the GitHub page.

Get Code Results
Code Sandbox: The result will have the code snippet extracted from the GitHub page. The result will render a code sandbox to view the code snippet in a more readable format.

Git Repository Analysis

Git Repository Analysis

The Git Repository Analysis plugin scans a Git repository for security vulnerabilities, performance issues, and other problems. This plugin is useful for developers who want to ensure the quality and security of their codebase.

1

Navigate to the Plugin

Navigate to the Ask Sage Plugins tool and select the Coding category. Then select Git Repository Analysis plugin.

Git Repo Analysis UI
2

Configure Settings

Select the secret you created and enter the URL of the Git repository you want to analyze. Check the box for 'token consumption' to verify the tokens consumption only.

Need a Secret? If you need to create a secret, you can follow the steps outlined in the Get Code from GitHub Page plugin section above.
3

Run Initial Analysis

Click submit to run the plugin.

4

Review Results

Review the results from the plugin.

5

Full Analysis with PR

Re-run the plugin but do not check the box for 'token consumption' to get a full analysis of the repository. This time check the 'Commit (separate branch) and PR (GitHub only) code changes (requires Secret)'.

6

Review Pull Request

Upon completion you will get a separate branch created in the repository with the analysis results that will be PR'd into the main branch. Will require repository owner to approve the PR.

What Gets Analyzed:

Security Vulnerabilities
Performance Issues
Bug Detection
Code Quality

Search GitHub Repository

Search GitHub Repository

The Search GitHub Repository plugin is designed to help developers search a GitHub repository for specific code snippets. This plugin is useful for developers who want to quickly find code snippets in a large codebase or repository.

Code Only: This does not go through documentation or README files, only the codebase.
1

Navigate to the Plugin

Navigate to the Ask Sage Plugins tool and select the Coding category. Then select Search GitHub Repository plugin.

Search Git UI
2

Configure Search

Select the secret you created and enter the URL of the GitHub repository you want to search. Enter the text you want to search for in the repository.

3

Execute Search

Click submit to run the plugin and search the GitHub repository.

4

Review Results

Review the results from the plugin.

Example: Searching for a Field

Searching for the field bank_total_accounts in a repository for a fictitious bank.

# Search term:
bank_total_accounts

# Results found in 3 files:

# File: src/models/account.py (Line 45)
class BankAccount:
    bank_total_accounts = 0  # Class variable to track total accounts

# File: src/services/analytics.py (Line 128)
def get_statistics(self):
    return {"total": bank_total_accounts}

# File: tests/test_accounts.py (Line 23)
assert bank_total_accounts == 100
Search Git Result
Comprehensive Results: The plugin identifies and returns the number of files containing the specified search context, along with the exact lines of code where the term appears. This functionality enables developers to swiftly locate relevant code snippets within a large codebase, providing insights into the frequency and context of the term's usage. This helps in understanding not only the location of the code but also its purpose and significance within the project.

Search Capabilities:

File count with matches
Exact line numbers
Code context
File paths

Back to top

Copyright © 2025 Ask Sage Inc. All Rights Reserved.

This site uses Just the Docs, a documentation theme for Jekyll.