fix: format files to pass lint checks
This commit is contained in:
@@ -1,13 +1,16 @@
|
|||||||
# download-attachment
|
# download-attachment
|
||||||
|
|
||||||
Download files from URLs to attachments folder and organize them with descriptive names.
|
Download files from URLs to attachments folder and organize them with
|
||||||
|
descriptive names.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
/download-attachment <url1> [url2] [url3...]
|
/download-attachment <url1> [url2] [url3...]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
/download-attachment https://example.com/document.pdf
|
/download-attachment https://example.com/document.pdf
|
||||||
/download-attachment https://site.com/image.png https://site.com/report.pdf
|
/download-attachment https://site.com/image.png https://site.com/report.pdf
|
||||||
@@ -15,13 +18,17 @@ Download files from URLs to attachments folder and organize them with descriptiv
|
|||||||
|
|
||||||
## Implementation
|
## Implementation
|
||||||
|
|
||||||
You are tasked with downloading files from URLs and organizing them in the Obsidian vault attachments folder.
|
You are tasked with downloading files from URLs and organizing them in the
|
||||||
|
Obsidian vault attachments folder.
|
||||||
|
|
||||||
### Step 1: Parse and Validate URLs
|
### Step 1: Parse and Validate URLs
|
||||||
|
|
||||||
Extract the URL(s) from the user's input. Handle multiple URLs if provided.
|
Extract the URL(s) from the user's input. Handle multiple URLs if provided.
|
||||||
|
|
||||||
- **Validate URL scheme**: Only allow http:// or https:// URLs
|
- **Validate URL scheme**: Only allow http:// or https:// URLs
|
||||||
- **Reject invalid URLs**: file://, ftp://, or malformed URLs
|
- **Reject invalid URLs**: file://, ftp://, or malformed URLs
|
||||||
- **Example validation**:
|
- **Example validation**:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
if [[ ! "$url" =~ ^https?:// ]]; then
|
if [[ ! "$url" =~ ^https?:// ]]; then
|
||||||
echo "Error: Only HTTP/HTTPS URLs are allowed"
|
echo "Error: Only HTTP/HTTPS URLs are allowed"
|
||||||
@@ -30,7 +37,9 @@ fi
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Download Files
|
### Step 2: Download Files
|
||||||
|
|
||||||
For each URL:
|
For each URL:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Sanitize filename to prevent path traversal
|
# Sanitize filename to prevent path traversal
|
||||||
# Remove ../ and other dangerous characters
|
# Remove ../ and other dangerous characters
|
||||||
@@ -43,29 +52,39 @@ curl --max-time 30 -L "$url" -o "05_Attachments/$filename"
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Step 3: Verify Downloads
|
### Step 3: Verify Downloads
|
||||||
|
|
||||||
Check that files were downloaded successfully:
|
Check that files were downloaded successfully:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ls -la "05_Attachments/"
|
ls -la "05_Attachments/"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 4: Organize Files
|
### Step 4: Organize Files
|
||||||
After downloading, run the organize-attachments command to rename files with descriptive names:
|
|
||||||
|
After downloading, run the organize-attachments command to rename files with
|
||||||
|
descriptive names:
|
||||||
|
|
||||||
For PDFs:
|
For PDFs:
|
||||||
|
|
||||||
- Extract text with `pdftotext`
|
- Extract text with `pdftotext`
|
||||||
- Analyze content for meaningful title
|
- Analyze content for meaningful title
|
||||||
|
|
||||||
For Images:
|
For Images:
|
||||||
- Use `mcp__gemini-vision__analyze_image` or `mcp__gemini-vision__analyze_multiple`
|
|
||||||
|
- Use `mcp__gemini-vision__analyze_image` or
|
||||||
|
`mcp__gemini-vision__analyze_multiple`
|
||||||
- Generate descriptive filename based on content
|
- Generate descriptive filename based on content
|
||||||
|
|
||||||
### Step 5: Move to Organized
|
### Step 5: Move to Organized
|
||||||
|
|
||||||
Move renamed files to `05_Attachments/Organized/` with descriptive names
|
Move renamed files to `05_Attachments/Organized/` with descriptive names
|
||||||
|
|
||||||
### Step 6: Update Index
|
### Step 6: Update Index
|
||||||
|
|
||||||
Add entries to `05_Attachments/00_Index.md`
|
Add entries to `05_Attachments/00_Index.md`
|
||||||
|
|
||||||
### Step 7: Commit Changes
|
### Step 7: Commit Changes
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git add -A
|
git add -A
|
||||||
git commit -m "Download and organize attachments from URLs"
|
git commit -m "Download and organize attachments from URLs"
|
||||||
@@ -74,7 +93,7 @@ git push
|
|||||||
|
|
||||||
## Important Notes
|
## Important Notes
|
||||||
|
|
||||||
1. **File Naming**:
|
1. **File Naming**:
|
||||||
- Initial download: Use URL filename or generate from URL
|
- Initial download: Use URL filename or generate from URL
|
||||||
- After analysis: Rename with descriptive title
|
- After analysis: Rename with descriptive title
|
||||||
|
|
||||||
@@ -109,4 +128,4 @@ git push
|
|||||||
- Use Gemini Vision for batch image analysis (up to 3 at once)
|
- Use Gemini Vision for batch image analysis (up to 3 at once)
|
||||||
- Extract meaningful context from PDFs before renaming
|
- Extract meaningful context from PDFs before renaming
|
||||||
- Preserve original file extensions
|
- Preserve original file extensions
|
||||||
- Keep filenames concise but descriptive (max 60 chars)
|
- Keep filenames concise but descriptive (max 60 chars)
|
||||||
|
|||||||
@@ -1,100 +1,111 @@
|
|||||||
# Pull Request Command
|
# Pull Request Command
|
||||||
|
|
||||||
Creates a new feature branch, commits changes, pushes to GitHub, and opens a pull request - all in one command. Perfect for contributing features or fixes.
|
Creates a new feature branch, commits changes, pushes to GitHub, and opens a
|
||||||
|
pull request - all in one command. Perfect for contributing features or fixes.
|
||||||
|
|
||||||
## Task
|
## Task
|
||||||
|
|
||||||
Automate the entire pull request workflow: create branch, stage changes, commit with descriptive message, push to GitHub, and open PR with proper description.
|
Automate the entire pull request workflow: create branch, stage changes, commit
|
||||||
|
with descriptive message, push to GitHub, and open PR with proper description.
|
||||||
|
|
||||||
## Process
|
## Process
|
||||||
|
|
||||||
### 1. **Check Prerequisites**
|
### 1. **Check Prerequisites**
|
||||||
- Ensure git repository exists
|
|
||||||
- Check for uncommitted changes to include
|
- Ensure git repository exists
|
||||||
- Verify GitHub CLI (`gh`) is available
|
- Check for uncommitted changes to include
|
||||||
- Get current branch as base branch
|
- Verify GitHub CLI (`gh`) is available
|
||||||
- If already on feature branch, ask: "Create PR from current branch?"
|
- Get current branch as base branch
|
||||||
|
- If already on feature branch, ask: "Create PR from current branch?"
|
||||||
|
|
||||||
### 2. **Create Feature Branch**
|
### 2. **Create Feature Branch**
|
||||||
```bash
|
|
||||||
# Generate branch name from PR title or use provided name
|
|
||||||
# Sanitize branch name: lowercase, replace spaces with hyphens, remove special chars
|
|
||||||
branch_name=$(echo "$branch_name" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g')
|
|
||||||
|
|
||||||
# Check if branch already exists
|
```bash
|
||||||
if git show-ref --verify --quiet refs/heads/$branch_name; then
|
# Generate branch name from PR title or use provided name
|
||||||
echo "Branch $branch_name already exists, using alternative name"
|
# Sanitize branch name: lowercase, replace spaces with hyphens, remove special chars
|
||||||
branch_name="${branch_name}-$(date +%s)"
|
branch_name=$(echo "$branch_name" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g')
|
||||||
fi
|
|
||||||
|
|
||||||
# Format: feature/short-description or fix/issue-name
|
# Check if branch already exists
|
||||||
git checkout -b $branch_name
|
if git show-ref --verify --quiet refs/heads/$branch_name; then
|
||||||
```
|
echo "Branch $branch_name already exists, using alternative name"
|
||||||
|
branch_name="${branch_name}-$(date +%s)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Format: feature/short-description or fix/issue-name
|
||||||
|
git checkout -b $branch_name
|
||||||
|
```
|
||||||
|
|
||||||
### 3. **Stage and Review Changes**
|
### 3. **Stage and Review Changes**
|
||||||
- Show `git status` to user
|
|
||||||
- Show `git diff --staged` for review
|
- Show `git status` to user
|
||||||
- If no staged changes, stage all changes: `git add -A`
|
- Show `git diff --staged` for review
|
||||||
- Confirm changes with user before proceeding
|
- If no staged changes, stage all changes: `git add -A`
|
||||||
|
- Confirm changes with user before proceeding
|
||||||
|
|
||||||
### 4. **Commit Changes**
|
### 4. **Commit Changes**
|
||||||
- Analyze changes to create meaningful commit message
|
|
||||||
- Use conventional commits format (feat:, fix:, docs:, etc.)
|
|
||||||
- Include detailed commit body if changes are complex
|
|
||||||
```bash
|
|
||||||
git commit -m "feat: add new feature
|
|
||||||
|
|
||||||
- Detail 1
|
- Analyze changes to create meaningful commit message
|
||||||
- Detail 2
|
- Use conventional commits format (feat:, fix:, docs:, etc.)
|
||||||
|
- Include detailed commit body if changes are complex
|
||||||
|
|
||||||
🤖 Generated with Claude Code"
|
```bash
|
||||||
```
|
git commit -m "feat: add new feature
|
||||||
|
|
||||||
|
- Detail 1
|
||||||
|
- Detail 2
|
||||||
|
|
||||||
|
🤖 Generated with Claude Code"
|
||||||
|
```
|
||||||
|
|
||||||
### 5. **Push to GitHub**
|
### 5. **Push to GitHub**
|
||||||
```bash
|
|
||||||
# Push with upstream tracking
|
```bash
|
||||||
git push -u origin feature/[branch-name]
|
# Push with upstream tracking
|
||||||
```
|
git push -u origin feature/[branch-name]
|
||||||
|
```
|
||||||
|
|
||||||
### 6. **Create Pull Request**
|
### 6. **Create Pull Request**
|
||||||
Use `gh pr create` with:
|
|
||||||
- Descriptive title
|
|
||||||
- Detailed body with:
|
|
||||||
- Summary of changes
|
|
||||||
- Testing checklist
|
|
||||||
- Related issues (if any)
|
|
||||||
- Set base branch (usually main/master)
|
|
||||||
|
|
||||||
```bash
|
Use `gh pr create` with:
|
||||||
gh pr create \
|
|
||||||
--title "Feature: Add awesome new capability" \
|
|
||||||
--body "$(cat <<'EOF'
|
|
||||||
## Summary
|
|
||||||
Brief description of what this PR does
|
|
||||||
|
|
||||||
## Changes
|
- Descriptive title
|
||||||
- Added feature X
|
- Detailed body with:
|
||||||
- Fixed bug Y
|
- Summary of changes
|
||||||
- Improved performance of Z
|
- Testing checklist
|
||||||
|
- Related issues (if any)
|
||||||
|
- Set base branch (usually main/master)
|
||||||
|
|
||||||
## Testing
|
```bash
|
||||||
- [ ] Tested locally
|
gh pr create \
|
||||||
- [ ] All tests pass
|
--title "Feature: Add awesome new capability" \
|
||||||
- [ ] Documentation updated
|
--body "$(cat <<'EOF'
|
||||||
|
## Summary
|
||||||
|
Brief description of what this PR does
|
||||||
|
|
||||||
## Screenshots
|
## Changes
|
||||||
(if applicable)
|
- Added feature X
|
||||||
|
- Fixed bug Y
|
||||||
|
- Improved performance of Z
|
||||||
|
|
||||||
🤖 Generated with [Claude Code](https://claude.ai/code)
|
## Testing
|
||||||
EOF
|
- [ ] Tested locally
|
||||||
)" \
|
- [ ] All tests pass
|
||||||
--base main
|
- [ ] Documentation updated
|
||||||
```
|
|
||||||
|
## Screenshots
|
||||||
|
(if applicable)
|
||||||
|
|
||||||
|
🤖 Generated with [Claude Code](https://claude.ai/code)
|
||||||
|
EOF
|
||||||
|
)" \
|
||||||
|
--base main
|
||||||
|
```
|
||||||
|
|
||||||
### 7. **Provide Next Steps**
|
### 7. **Provide Next Steps**
|
||||||
- Show PR URL
|
|
||||||
- Remind about review process
|
- Show PR URL
|
||||||
- Suggest next actions (request review, add labels, etc.)
|
- Remind about review process
|
||||||
|
- Suggest next actions (request review, add labels, etc.)
|
||||||
|
|
||||||
## Arguments
|
## Arguments
|
||||||
|
|
||||||
@@ -142,6 +153,7 @@ Next steps:
|
|||||||
## Commit Message Format
|
## Commit Message Format
|
||||||
|
|
||||||
Follow conventional commits:
|
Follow conventional commits:
|
||||||
|
|
||||||
- `feat:` New feature
|
- `feat:` New feature
|
||||||
- `fix:` Bug fix
|
- `fix:` Bug fix
|
||||||
- `docs:` Documentation only
|
- `docs:` Documentation only
|
||||||
@@ -164,4 +176,4 @@ Follow conventional commits:
|
|||||||
- If no changes: "No changes to create PR"
|
- If no changes: "No changes to create PR"
|
||||||
- If already on feature branch: Ask if should create PR from current branch
|
- If already on feature branch: Ask if should create PR from current branch
|
||||||
- If PR exists: Show existing PR URL
|
- If PR exists: Show existing PR URL
|
||||||
- If push fails: Check permissions and remote settings
|
- If push fails: Check permissions and remote settings
|
||||||
|
|||||||
+2
-1
@@ -13,7 +13,8 @@ and this project adheres to
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Comprehensive linting and formatting setup with ESLint and Prettier
|
- Comprehensive linting and formatting setup with ESLint and Prettier
|
||||||
- Configuration files organized in `.config/` folder for better project structure
|
- Configuration files organized in `.config/` folder for better project
|
||||||
|
structure
|
||||||
- GitHub Action workflow for automated lint checks on pull requests
|
- GitHub Action workflow for automated lint checks on pull requests
|
||||||
- Package manager specification for consistent dependency management
|
- Package manager specification for consistent dependency management
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user