xuanzhu 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +424 -0
  3. package/bin/xzh.js +3 -0
  4. package/dist/cli.js +5602 -0
  5. package/dist/cli.js.map +7 -0
  6. package/dist/skills/aws/SKILL.md +70 -0
  7. package/dist/skills/datadog/SKILL.md +261 -0
  8. package/dist/skills/elasticsearch/SKILL.md +88 -0
  9. package/dist/skills/elasticsearch/install.sh +91 -0
  10. package/dist/skills/email/SKILL.md +63 -0
  11. package/dist/skills/github/SKILL.md +69 -0
  12. package/dist/skills/gitlab/SKILL.md +68 -0
  13. package/dist/skills/gitlab/install.sh +74 -0
  14. package/dist/skills/gmail/README.md +139 -0
  15. package/dist/skills/gmail/SECURITY.md +552 -0
  16. package/dist/skills/gmail/SETUP.md +258 -0
  17. package/dist/skills/gmail/activate-gmail-cli.sh +15 -0
  18. package/dist/skills/gmail/generate-hashes.sh +82 -0
  19. package/dist/skills/gmail/gmail-cli-secure.py +599 -0
  20. package/dist/skills/gmail/install.sh +313 -0
  21. package/dist/skills/gmail/requirements.txt +38 -0
  22. package/dist/skills/gmail/skill.md +225 -0
  23. package/dist/skills/jira/SKILL.md +68 -0
  24. package/dist/skills/kubernetes/SKILL.md +70 -0
  25. package/dist/skills/linear/SKILL.md +48 -0
  26. package/dist/skills/mongodb/SKILL.md +53 -0
  27. package/dist/skills/mysql/SKILL.md +71 -0
  28. package/dist/skills/mysql/install.sh +74 -0
  29. package/dist/skills/officecli/SKILL.md +429 -0
  30. package/dist/skills/playwright/SKILL.md +171 -0
  31. package/dist/skills/postgres/SKILL.md +44 -0
  32. package/dist/skills/postgres/install.sh +73 -0
  33. package/dist/skills/redis/SKILL.md +58 -0
  34. package/dist/skills/redis/install.sh +39 -0
  35. package/dist/skills/sentry/SKILL.md +59 -0
  36. package/dist/skills/telegram/SKILL.md +151 -0
  37. package/package.json +46 -0
@@ -0,0 +1,258 @@
1
+ # Gmail CLI Setup Instructions
2
+
3
+ This guide will help you set up the Gmail CLI tool.
4
+
5
+ ## Prerequisites
6
+
7
+ - Python 3.7 or higher
8
+ - pip (Python package manager)
9
+ - A Google account with Gmail enabled
10
+
11
+ ## Installation Steps
12
+
13
+ ### 1. Install Required Python Packages
14
+
15
+ ```bash
16
+ pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
17
+ ```
18
+
19
+ ### 2. Copy the Gmail CLI Script
20
+
21
+ The gmail-cli script should be located at `.codebuddy/bin/gmail-cli`. If it's not there or not executable, run:
22
+
23
+ ```bash
24
+ chmod +x .codebuddy/bin/gmail-cli
25
+ ```
26
+
27
+ ### 3. Set Up Google Cloud Project & OAuth2 Credentials
28
+
29
+ To use the Gmail API, you need to create OAuth2 credentials:
30
+
31
+ #### Step 3.1: Create a Google Cloud Project
32
+
33
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
34
+ 2. Click "Select a project" → "New Project"
35
+ 3. Enter a project name (e.g., "Gmail CLI")
36
+ 4. Click "Create"
37
+
38
+ #### Step 3.2: Enable Gmail API
39
+
40
+ 1. In your project, go to "APIs & Services" → "Library"
41
+ 2. Search for "Gmail API"
42
+ 3. Click on "Gmail API" and then click "Enable"
43
+
44
+ #### Step 3.3: Create OAuth2 Credentials
45
+
46
+ 1. Go to "APIs & Services" → "Credentials"
47
+ 2. Click "Create Credentials" → "OAuth client ID"
48
+ 3. If prompted, configure the OAuth consent screen:
49
+ - Choose "External" user type
50
+ - Fill in required fields (App name, User support email, Developer contact)
51
+ - Add your email as a test user
52
+ - Save and continue through the scopes and summary
53
+ 4. Back to "Create OAuth client ID":
54
+ - Choose "Desktop app" as the application type
55
+ - Give it a name (e.g., "Gmail CLI")
56
+ - Click "Create"
57
+ 5. Download the credentials JSON file
58
+
59
+ #### Step 3.4: Save Credentials (SECURE)
60
+
61
+ ⚠️ **CRITICAL SECURITY STEP** - Follow these instructions carefully!
62
+
63
+ 1. Create the configuration directory with **restrictive permissions**:
64
+ ```bash
65
+ # Create directory with owner-only access
66
+ mkdir -p ~/.gmail-cli
67
+ chmod 700 ~/.gmail-cli
68
+ ```
69
+
70
+ **Why?** Default permissions (755) allow other users on shared systems to read your credentials!
71
+
72
+ 2. Save the downloaded JSON file with **secure permissions**:
73
+ ```bash
74
+ # Move the downloaded credentials file
75
+ mv ~/Downloads/client_secret_*.json ~/.gmail-cli/credentials.json
76
+
77
+ # Set owner-only read/write permissions
78
+ chmod 600 ~/.gmail-cli/credentials.json
79
+ ```
80
+
81
+ **Why?** This prevents other users from reading your OAuth2 client secret!
82
+
83
+ 3. **Verify permissions** (IMPORTANT):
84
+ ```bash
85
+ # Check directory permissions (should show: drwx------)
86
+ ls -ld ~/.gmail-cli/
87
+
88
+ # Check file permissions (should show: -rw-------)
89
+ ls -l ~/.gmail-cli/credentials.json
90
+ ```
91
+
92
+ **Expected output:**
93
+ ```
94
+ drwx------ 2 youruser yourgroup 64 Jan 15 10:30 /home/youruser/.gmail-cli/
95
+ -rw------- 1 youruser yourgroup 450 Jan 15 10:31 /home/youruser/.gmail-cli/credentials.json
96
+ ```
97
+
98
+ 4. **Security verification script** (optional but recommended):
99
+ ```bash
100
+ # Run this to check all permissions
101
+ bash << 'EOF'
102
+ GMAIL_DIR="$HOME/.gmail-cli"
103
+
104
+ echo "🔍 Checking security permissions..."
105
+
106
+ # Check directory
107
+ DIR_PERMS=$(stat -c %a "$GMAIL_DIR" 2>/dev/null || stat -f %A "$GMAIL_DIR" 2>/dev/null)
108
+ if [ "$DIR_PERMS" = "700" ]; then
109
+ echo "✓ Directory permissions secure: $DIR_PERMS"
110
+ else
111
+ echo "⚠️ WARNING: Directory has insecure permissions: $DIR_PERMS (should be 700)"
112
+ echo " Fix with: chmod 700 $GMAIL_DIR"
113
+ fi
114
+
115
+ # Check credentials file if it exists
116
+ if [ -f "$GMAIL_DIR/credentials.json" ]; then
117
+ CRED_PERMS=$(stat -c %a "$GMAIL_DIR/credentials.json" 2>/dev/null || stat -f %A "$GMAIL_DIR/credentials.json" 2>/dev/null)
118
+ if [ "$CRED_PERMS" = "600" ]; then
119
+ echo "✓ Credentials file secure: $CRED_PERMS"
120
+ else
121
+ echo "⚠️ WARNING: Credentials has insecure permissions: $CRED_PERMS (should be 600)"
122
+ echo " Fix with: chmod 600 $GMAIL_DIR/credentials.json"
123
+ fi
124
+ fi
125
+ EOF
126
+ ```
127
+
128
+ ### 4. Authenticate
129
+
130
+ Run the authentication command:
131
+
132
+ ```bash
133
+ ./.codebuddy/bin/gmail-cli auth
134
+ ```
135
+
136
+ This will:
137
+ - Open a browser window
138
+ - Ask you to log in to your Google account
139
+ - Request permission to access Gmail
140
+ - Save an authentication token locally
141
+
142
+ ## Verification
143
+
144
+ Test that everything works:
145
+
146
+ ```bash
147
+ # List recent emails
148
+ ./.codebuddy/bin/gmail-cli list --max 5
149
+
150
+ # List unread emails
151
+ ./.codebuddy/bin/gmail-cli list --unread
152
+ ```
153
+
154
+ ## Troubleshooting
155
+
156
+ ### "Required packages not installed" Error
157
+
158
+ Install the required packages:
159
+ ```bash
160
+ pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
161
+ ```
162
+
163
+ ### "Credentials file not found" Error
164
+
165
+ Make sure you've:
166
+ 1. Downloaded the OAuth2 credentials from Google Cloud Console
167
+ 2. Saved them to `~/.gmail-cli/credentials.json`
168
+
169
+ ### "Permission denied" Error
170
+
171
+ Make the script executable:
172
+ ```bash
173
+ chmod +x ./.codebuddy/bin/gmail-cli
174
+ ```
175
+
176
+ ### Authentication Issues
177
+
178
+ Reset authentication and try again:
179
+ ```bash
180
+ ./.codebuddy/bin/gmail-cli auth --reset
181
+ ```
182
+
183
+ ## Security Notes
184
+
185
+ ### 🔒 Critical Security Requirements
186
+
187
+ 1. **File Permissions** (MANDATORY):
188
+ - Directory: `chmod 700 ~/.gmail-cli/` (owner-only access)
189
+ - Credentials: `chmod 600 ~/.gmail-cli/credentials.json` (owner read/write only)
190
+ - Tokens: `chmod 600 ~/.gmail-cli/token.pickle` (owner read/write only)
191
+
192
+ 2. **Never Commit Secrets to Git**:
193
+ - Add `.gmail-cli/` to your `~/.gitignore` or global gitignore
194
+ - Never commit `credentials.json`, `token.pickle`, or any `.enc` files
195
+ - Use `.gitignore` file provided in `.codebuddy/skills/gmail/.gitignore`
196
+
197
+ 3. **OAuth2 Scopes** (Updated for Security):
198
+ - **Recommended**: Use minimal scopes: `gmail.readonly` + `gmail.send`
199
+ - **Avoid**: `gmail.modify` (allows deletion and modification of emails)
200
+ - Edit the Python binary to change requested scopes
201
+
202
+ 4. **Token Management**:
203
+ - Tokens stored in: `~/.gmail-cli/token.pickle`
204
+ - Tokens auto-refresh but should be rotated every 30-90 days
205
+ - Revoke tokens after device loss: https://myaccount.google.com/permissions
206
+ - Use `gmail-cli token --revoke` command (if implemented)
207
+
208
+ 5. **Shared Systems**:
209
+ - ⚠️ **Extra caution on shared computers/servers**
210
+ - Other users can read your files if permissions are wrong
211
+ - Consider using encrypted home directories
212
+ - Use `ps aux | grep gmail-cli` to check for running processes
213
+
214
+ 6. **Backup Security**:
215
+ - Never backup credentials to cloud storage unencrypted
216
+ - Use encrypted password managers for credential backup
217
+ - Exclude `~/.gmail-cli/` from unencrypted backups
218
+
219
+ 7. **OAuth Consent Screen**:
220
+ - Your app may show as "unverified" - this is normal for personal projects
221
+ - Google requires verification for apps with >100 users
222
+ - You're the only user, so verification not needed
223
+
224
+ 8. **Full-Disk Encryption** (Recommended):
225
+ - Enable FileVault (macOS), BitLocker (Windows), or LUKS (Linux)
226
+ - This protects credentials if device is stolen
227
+ - Does not protect against online attacks or malware
228
+
229
+ ### 🛡️ Security Checklist
230
+
231
+ Before using Gmail CLI, verify:
232
+
233
+ - [ ] Python packages installed in virtual environment (not globally)
234
+ - [ ] `~/.gmail-cli/` has 700 permissions
235
+ - [ ] `credentials.json` has 600 permissions
236
+ - [ ] `.gitignore` configured to exclude sensitive files
237
+ - [ ] Using minimal OAuth2 scopes (not `gmail.modify`)
238
+ - [ ] Full-disk encryption enabled on device
239
+ - [ ] Understand how to revoke tokens if compromised
240
+ - [ ] Regular security audits: `pip-audit` in virtual environment
241
+
242
+ ## Alternative: Using App Passwords (Less Recommended)
243
+
244
+ If you prefer not to use OAuth2, you can use Gmail's App Password feature:
245
+
246
+ 1. Enable 2-Step Verification on your Google account
247
+ 2. Go to [App Passwords](https://myaccount.google.com/apppasswords)
248
+ 3. Generate a new app password for "Mail"
249
+ 4. Use the existing email skill with SMTP instead (see `email/skill.md`)
250
+
251
+ Note: This method provides less security and functionality than the OAuth2 approach.
252
+
253
+ ## File Locations
254
+
255
+ - Script: `.codebuddy/bin/gmail-cli`
256
+ - Config directory: `~/.gmail-cli/`
257
+ - Credentials: `~/.gmail-cli/credentials.json`
258
+ - Token: `~/.gmail-cli/token.pickle`
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+ # Activate Gmail CLI virtual environment
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
6
+ VENV_DIR="$PROJECT_ROOT/.venv-gmail-cli"
7
+
8
+ if [ -f "$VENV_DIR/bin/activate" ]; then
9
+ source "$VENV_DIR/bin/activate"
10
+ echo "✓ Gmail CLI virtual environment activated"
11
+ echo "Deactivate with: deactivate"
12
+ else
13
+ echo "❌ Virtual environment not found. Run install.sh first."
14
+ exit 1
15
+ fi
@@ -0,0 +1,82 @@
1
+ #!/bin/bash
2
+ # Generate Package Hashes for Requirements
3
+ # This script downloads packages and generates SHA256 hashes for pip's --require-hashes option
4
+ # Usage: ./generate-hashes.sh [output-file]
5
+
6
+ set -euo pipefail
7
+
8
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
+ OUTPUT_FILE="${1:-$SCRIPT_DIR/requirements-locked.txt}"
10
+ TEMP_DIR=$(mktemp -d)
11
+
12
+ # Cleanup temp directory on exit
13
+ trap 'rm -rf "$TEMP_DIR"' EXIT
14
+
15
+ # Colors
16
+ GREEN='\033[0;32m'
17
+ YELLOW='\033[1;33m'
18
+ NC='\033[0m'
19
+
20
+ echo "🔐 Generating Package Hashes"
21
+ echo "============================"
22
+ echo ""
23
+
24
+ # Core packages to hash (pinned versions for reproducibility)
25
+ PACKAGES=(
26
+ "google-api-python-client==2.108.0"
27
+ "google-auth-httplib2==0.1.1"
28
+ "google-auth-oauthlib==1.1.0"
29
+ "google-auth==2.23.4"
30
+ "cryptography==41.0.7"
31
+ )
32
+
33
+ # Header for output file
34
+ cat > "$OUTPUT_FILE" << 'EOF'
35
+ # Gmail CLI Python Dependencies - LOCKED with hashes
36
+ # Generated with generate-hashes.sh
37
+ # Install with: pip install --require-hashes -r requirements-locked.txt
38
+ #
39
+ # WARNING: These hashes are tied to specific package versions.
40
+ # Regenerate after updating package versions.
41
+
42
+ EOF
43
+
44
+ echo -e "${YELLOW}⚠️ Note: This requires network access to download packages${NC}"
45
+ echo ""
46
+
47
+ for package in "${PACKAGES[@]}"; do
48
+ pkg_name=$(echo "$package" | cut -d'=' -f1)
49
+ echo "📦 Processing: $package"
50
+
51
+ # Download package
52
+ pip download --no-deps --dest "$TEMP_DIR" "$package" 2>/dev/null
53
+
54
+ # Find the downloaded file
55
+ pkg_file=$(ls -1 "$TEMP_DIR"/*.whl 2>/dev/null | head -1 || ls -1 "$TEMP_DIR"/*.tar.gz 2>/dev/null | head -1)
56
+
57
+ if [ -z "$pkg_file" ]; then
58
+ echo " ❌ Failed to download $package"
59
+ continue
60
+ fi
61
+
62
+ # Generate hash
63
+ hash=$(pip hash "$pkg_file" 2>/dev/null | grep "sha256:" | head -1)
64
+
65
+ if [ -n "$hash" ]; then
66
+ echo "$package \\" >> "$OUTPUT_FILE"
67
+ echo " $hash" >> "$OUTPUT_FILE"
68
+ echo "" >> "$OUTPUT_FILE"
69
+ echo -e " ${GREEN}✓${NC} Hash generated"
70
+ else
71
+ echo " ❌ Failed to generate hash"
72
+ fi
73
+
74
+ # Clean up for next package
75
+ rm -f "$TEMP_DIR"/*
76
+ done
77
+
78
+ echo ""
79
+ echo -e "${GREEN}✓${NC} Hashes written to: $OUTPUT_FILE"
80
+ echo ""
81
+ echo "To use hash verification:"
82
+ echo " pip install --require-hashes -r $OUTPUT_FILE"