Skip to content
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

upload files to generate a context for new questions #211

Open
henry-hz opened this issue Sep 13, 2024 · 0 comments
Open

upload files to generate a context for new questions #211

henry-hz opened this issue Sep 13, 2024 · 0 comments

Comments

@henry-hz
Copy link

henry-hz commented Sep 13, 2024

First of all, thanks for the plugin, amazing design and implementation!

I would like to ask if there is a way to have the repo files uploaded to the AI agent, so we can ask questions about the repo and even more, have the code generation follow the actual repo code style. In the same way we already have a context that is uploaded every request, we could follow the pattern and have an agent context, will all the repository data (see the script below), so questions about the repo could be answered.

I found this idea on the phind plugin on vscode.

#!/bin/bash

# Set the path to your Solidity project
PROJECT_DIR="."

# Set the output file name for the repository context
OUTPUT_FILE="repo_context.txt"

# Function to append content to the output file
append_to_file() {
    echo "$1" >> "$OUTPUT_FILE"
}

# Create an empty output file
echo "" > "$OUTPUT_FILE"

# Append project directory structure
append_to_file "Project Directory Structure:"
tree -d "$PROJECT_DIR" | grep -v "node_modules" | grep -v "artifacts" | sed 's/^/  /' >> "$OUTPUT_FILE"

# Append list of Solidity contracts
append_to_file "\nSolidity Contracts:"
find "$PROJECT_DIR" -name "*.sol" | sed 's|^./||' | while read -r contract; do
    append_to_file "  - $contract"
done

# Append list of test files
append_to_file "\nTest Files:"
find "$PROJECT_DIR/test" -name "*.t.sol" | sed 's|^./||' | while read -r test_file; do
    append_to_file "  - $test_file"
done

# Append list of script files
append_to_file "\nScript Files:"
find "$PROJECT_DIR/script" -name "*.s.sol" | sed 's|^./||' | while read -r script_file; do
    append_to_file "  - $script_file"
done

# Append contents of key project files
append_to_file "\nKey Project Files:"

# Foundry configuration file
if [ -f "$PROJECT_DIR/foundry.toml" ]; then
    append_to_file "\n  foundry.toml:"
    cat "$PROJECT_DIR/foundry.toml" | sed 's/^/    /' >> "$OUTPUT_FILE"
fi

# Readme file
if [ -f "$PROJECT_DIR/README.md" ]; then
    append_to_file "\n  README.md:"
    cat "$PROJECT_DIR/README.md" | sed 's/^/    /' >> "$OUTPUT_FILE"
fi

# Deployment scripts
deployment_scripts=$(find "$PROJECT_DIR/script" -name "deploy*.s.sol")
if [ -n "$deployment_scripts" ]; then
    append_to_file "\nDeployment Scripts:"
    echo "$deployment_scripts" | while read -r script; do
        append_to_file "\n  $script:"
        cat "$script" | sed 's/^/    /' >> "$OUTPUT_FILE"
    done
fi

append_to_file "\nConcatenated Files:"

append_to_file "\n  src files:"
find "$PROJECT_DIR/src" -type f -print0 | while IFS= read -r -d '' file; do
    append_to_file "\n    $file:"
    cat "$file" | sed 's/^/      /' >> "$OUTPUT_FILE"
done

append_to_file "\n  test files:"
find "$PROJECT_DIR/test" -type f -print0 | while IFS= read -r -d '' file; do
    append_to_file "\n    $file:"
    cat "$file" | sed 's/^/      /' >> "$OUTPUT_FILE"
done

echo "Repository context created in $OUTPUT_FILE"
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

No branches or pull requests

1 participant