praisonaiwp 1.0.0__tar.gz

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 (51) hide show
  1. praisonaiwp-1.0.0/.gitignore +59 -0
  2. praisonaiwp-1.0.0/.python-version +1 -0
  3. praisonaiwp-1.0.0/ARCHITECTURE.md +390 -0
  4. praisonaiwp-1.0.0/COMPLETE.md +451 -0
  5. praisonaiwp-1.0.0/LICENSE +21 -0
  6. praisonaiwp-1.0.0/PKG-INFO +282 -0
  7. praisonaiwp-1.0.0/PROJECT_SUMMARY.md +264 -0
  8. praisonaiwp-1.0.0/QUICKSTART.md +211 -0
  9. praisonaiwp-1.0.0/README.md +241 -0
  10. praisonaiwp-1.0.0/TESTING.md +340 -0
  11. praisonaiwp-1.0.0/UV_GUIDE.md +357 -0
  12. praisonaiwp-1.0.0/UV_MIGRATION.md +340 -0
  13. praisonaiwp-1.0.0/examples/bulk_update_9_pages.py +87 -0
  14. praisonaiwp-1.0.0/examples/create_single_post.py +56 -0
  15. praisonaiwp-1.0.0/examples/posts.json +20 -0
  16. praisonaiwp-1.0.0/examples/update_specific_line.py +96 -0
  17. praisonaiwp-1.0.0/examples/updates.json +20 -0
  18. praisonaiwp-1.0.0/praisonaiwp/__init__.py +16 -0
  19. praisonaiwp-1.0.0/praisonaiwp/__main__.py +8 -0
  20. praisonaiwp-1.0.0/praisonaiwp/__version__.py +1 -0
  21. praisonaiwp-1.0.0/praisonaiwp/cli/__init__.py +5 -0
  22. praisonaiwp-1.0.0/praisonaiwp/cli/commands/__init__.py +1 -0
  23. praisonaiwp-1.0.0/praisonaiwp/cli/commands/create.py +206 -0
  24. praisonaiwp-1.0.0/praisonaiwp/cli/commands/find.py +135 -0
  25. praisonaiwp-1.0.0/praisonaiwp/cli/commands/init.py +137 -0
  26. praisonaiwp-1.0.0/praisonaiwp/cli/commands/list.py +96 -0
  27. praisonaiwp-1.0.0/praisonaiwp/cli/commands/update.py +141 -0
  28. praisonaiwp-1.0.0/praisonaiwp/cli/main.py +49 -0
  29. praisonaiwp-1.0.0/praisonaiwp/core/__init__.py +7 -0
  30. praisonaiwp-1.0.0/praisonaiwp/core/config.py +163 -0
  31. praisonaiwp-1.0.0/praisonaiwp/core/ssh_manager.py +133 -0
  32. praisonaiwp-1.0.0/praisonaiwp/core/wp_client.py +200 -0
  33. praisonaiwp-1.0.0/praisonaiwp/editors/__init__.py +5 -0
  34. praisonaiwp-1.0.0/praisonaiwp/editors/content_editor.py +190 -0
  35. praisonaiwp-1.0.0/praisonaiwp/parallel/__init__.py +5 -0
  36. praisonaiwp-1.0.0/praisonaiwp/parallel/executor.py +121 -0
  37. praisonaiwp-1.0.0/praisonaiwp/parallel/nodejs/README.md +73 -0
  38. praisonaiwp-1.0.0/praisonaiwp/parallel/nodejs/index.js +180 -0
  39. praisonaiwp-1.0.0/praisonaiwp/parallel/nodejs/package.json +21 -0
  40. praisonaiwp-1.0.0/praisonaiwp/utils/__init__.py +17 -0
  41. praisonaiwp-1.0.0/praisonaiwp/utils/exceptions.py +31 -0
  42. praisonaiwp-1.0.0/praisonaiwp/utils/logger.py +51 -0
  43. praisonaiwp-1.0.0/pyproject.toml +125 -0
  44. praisonaiwp-1.0.0/requirements-dev.txt +7 -0
  45. praisonaiwp-1.0.0/requirements.txt +8 -0
  46. praisonaiwp-1.0.0/setup.py +56 -0
  47. praisonaiwp-1.0.0/tests/__init__.py +1 -0
  48. praisonaiwp-1.0.0/tests/conftest.py +78 -0
  49. praisonaiwp-1.0.0/tests/test_config.py +112 -0
  50. praisonaiwp-1.0.0/tests/test_content_editor.py +137 -0
  51. praisonaiwp-1.0.0/tests/test_wp_client.py +138 -0
@@ -0,0 +1,59 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual Environment
24
+ venv/
25
+ ENV/
26
+ env/
27
+ .venv/
28
+
29
+ # uv
30
+ uv.lock
31
+
32
+ # IDE
33
+ .vscode/
34
+ .idea/
35
+ *.swp
36
+ *.swo
37
+ *~
38
+
39
+ # Testing
40
+ .pytest_cache/
41
+ .coverage
42
+ htmlcov/
43
+ .tox/
44
+
45
+ # Config
46
+ .env
47
+ config.yaml
48
+ servers.yaml
49
+
50
+ # Logs
51
+ *.log
52
+ logs/
53
+
54
+ # Backups
55
+ backups/
56
+
57
+ # OS
58
+ .DS_Store
59
+ Thumbs.db
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,390 @@
1
+ # PraisonAIWP - Architecture Documentation
2
+
3
+ ## Overview
4
+
5
+ **PraisonAIWP** is a Python-based WordPress content management framework designed to simplify and automate WordPress content operations via WP-CLI over SSH.
6
+
7
+ ### Key Features
8
+
9
+ - **Simple CLI**: Only 5 core commands (`init`, `create`, `update`, `find`, `list`)
10
+ - **Smart Defaults**: Auto-detects file formats, execution modes, and optimal settings
11
+ - **Dual Execution Modes**: Sequential (Python) for reliability, Parallel (Node.js) for speed
12
+ - **Precision Editing**: Line-specific and occurrence-specific text replacements
13
+ - **Safe Operations**: Auto-backup, preview mode, dry-run capabilities
14
+
15
+ ### Design Philosophy
16
+
17
+ 1. **Convention Over Configuration** - Sensible defaults, minimal setup
18
+ 2. **Safety First** - Preview, backup, confirm before destructive operations
19
+ 3. **Performance When Needed** - Auto-parallel for bulk operations
20
+ 4. **Developer Experience** - Clear commands, helpful errors, progress indicators
21
+
22
+ ## System Architecture
23
+
24
+ ```
25
+ User (CLI)
26
+
27
+ CLI Layer (Click) → 5 Commands: init, create, update, find, list
28
+
29
+ Operations Layer → Create, Update, Search Operations
30
+
31
+ Core Layer → SSH Manager, WP Client, Content Editor
32
+
33
+ Execution Modes → Sequential (Python) | Parallel (Node.js)
34
+
35
+ Remote WordPress Server → WP-CLI, Database, WordPress Core
36
+ ```
37
+
38
+ ## Project Structure
39
+
40
+ ```
41
+ praisonaiwp/
42
+ ├── setup.py
43
+ ├── requirements.txt
44
+ ├── praisonaiwp/
45
+ │ ├── __init__.py
46
+ │ ├── core/ # SSH, WP-CLI, DB, REST API
47
+ │ ├── editors/ # Content editing logic
48
+ │ ├── operations/ # High-level operations
49
+ │ ├── cli/ # CLI commands
50
+ │ ├── parallel/ # Node.js bridge for parallel ops
51
+ │ └── utils/ # Logger, validator, backup, progress
52
+ ├── templates/ # Content templates
53
+ ├── tests/ # Unit & integration tests
54
+ └── examples/ # Usage examples
55
+ ```
56
+
57
+ ## Core Components
58
+
59
+ ### 1. SSH Manager (`core/ssh_manager.py`)
60
+ - Manages SSH connections using Paramiko
61
+ - Context manager support for auto-cleanup
62
+ - Connection pooling and retry logic
63
+
64
+ ### 2. WP Client (`core/wp_client.py`)
65
+ - Wrapper around WP-CLI
66
+ - Handles different PHP binaries (Plesk support)
67
+ - Returns Python objects (not raw strings)
68
+
69
+ ### 3. Content Editor (`editors/content_editor.py`)
70
+ - `replace_at_line()` - Replace at specific line number
71
+ - `replace_nth_occurrence()` - Replace 1st, 2nd, nth occurrence
72
+ - `replace_in_range()` - Replace in line range
73
+ - `find_occurrences()` - Find all matches with line numbers
74
+ - `preview_changes()` - Preview before applying
75
+
76
+ ### 4. Operations Layer (`operations/`)
77
+ - **Create**: Single post, from file, from template, bulk
78
+ - **Update**: Content, with replacement (line/nth), bulk
79
+ - **Search**: Find in post, find in all posts, list posts
80
+
81
+ ### 5. CLI Layer (`cli/`)
82
+ - Built with Click framework
83
+ - 5 commands: init, create, update, find, list
84
+ - Smart defaults and auto-detection
85
+
86
+ ### 6. Parallel Executor (`parallel/`)
87
+ - Python-Node.js bridge for parallel operations
88
+ - Automatically used when >10 posts
89
+ - 10x faster for bulk operations
90
+
91
+ ## CLI Commands
92
+
93
+ ### 1. `praisonaiwp init`
94
+ Initialize configuration (one-time setup)
95
+
96
+ ### 2. `praisonaiwp create [file|title]`
97
+ Create posts (auto-detects format, auto-parallel for bulk)
98
+
99
+ ### 3. `praisonaiwp update <id> [find] [replace]`
100
+ Update posts with optional `--line` or `--nth` flags
101
+
102
+ ### 4. `praisonaiwp find <pattern>`
103
+ Search for text in posts
104
+
105
+ ### 5. `praisonaiwp list`
106
+ List WordPress posts with filters
107
+
108
+ ## Configuration
109
+
110
+ **Location**: `~/.praisonaiwp/config.yaml`
111
+
112
+ ```yaml
113
+ default_server: production
114
+
115
+ servers:
116
+ production:
117
+ hostname: example.com
118
+ username: user
119
+ key_file: ~/.ssh/id_ed25519
120
+ wp_path: /var/www/html
121
+ php_bin: /opt/plesk/php/8.3/bin/php
122
+
123
+ settings:
124
+ auto_backup: true
125
+ parallel_threshold: 10
126
+ parallel_workers: 10
127
+ log_level: INFO
128
+ ```
129
+
130
+ ## Data Flow Examples
131
+
132
+ ### Create 100 Posts (Auto-Parallel)
133
+ ```
134
+ User: praisonaiwp create posts.json
135
+
136
+ Detect: 100 posts in file
137
+
138
+ Auto-select: Parallel mode
139
+
140
+ Spawn Node.js process
141
+
142
+ Create 10 batches of 10 posts
143
+
144
+ Execute batches in parallel
145
+
146
+ Complete in ~8 seconds (vs 50s sequential)
147
+ ```
148
+
149
+ ### Update Specific Line
150
+ ```
151
+ User: praisonaiwp update 123 "old" "new" --line 10
152
+
153
+ Get post content
154
+
155
+ Apply: ContentEditor.replace_at_line(content, 10, "old", "new")
156
+
157
+ Preview changes (show diff)
158
+
159
+ Backup original
160
+
161
+ Confirm with user
162
+
163
+ Update post
164
+ ```
165
+
166
+ ## Security
167
+
168
+ - SSH key-based authentication only
169
+ - No password storage
170
+ - Config file permissions: 600
171
+ - Automatic backup before destructive operations
172
+ - Preview mode for all changes
173
+
174
+ ## Performance
175
+
176
+ - **Sequential**: ~0.5s per post (network limited)
177
+ - **Parallel (10 workers)**: ~5-8s for 100 posts
178
+ - **Speedup**: 10x faster for bulk operations
179
+
180
+ ## Testing Strategy
181
+
182
+ - **Unit Tests**: Core components (SSH, WP Client, Content Editor)
183
+ - **Integration Tests**: CLI commands, end-to-end workflows
184
+ - **Fixtures**: Sample posts, config files
185
+ - **Mocking**: SSH connections for offline testing
186
+
187
+ ## Future Enhancements
188
+
189
+ 1. AI-powered content generation
190
+ 2. WordPress REST API support (alternative to WP-CLI)
191
+ 3. Plugin system for custom operations
192
+ 4. Web dashboard for visual management
193
+ 5. Multi-site support
194
+ 6. Content migration tools
195
+ 7. SEO optimization features
196
+
197
+ ---
198
+
199
+ **Version**: 1.0.0
200
+ **Last Updated**: October 2025
201
+
202
+
203
+ ✅ SIMPLIFIED CLI STRUCTURE
204
+ 1️⃣ Setup (One-time)
205
+ bash
206
+ # Initialize with interactive prompts
207
+ praisonaiwp init
208
+
209
+ # Asks:
210
+ # - Server hostname?
211
+ # - SSH username?
212
+ # - SSH key path? (default: ~/.ssh/id_ed25519)
213
+ # - WordPress path? (auto-detects)
214
+ # - PHP binary? (auto-detects)
215
+
216
+ # That's it! Saved to ~/.praisonaiwp/config.yaml
217
+ 2️⃣ Create Posts
218
+ bash
219
+ # Single post (interactive)
220
+ praisonaiwp create
221
+ # Prompts for: title, content, status
222
+
223
+ # Single post (direct)
224
+ praisonaiwp create "My Post Title" --content "Post content"
225
+
226
+ # From file (auto-detects format: JSON, YAML, CSV)
227
+ praisonaiwp create posts.json
228
+
229
+ # 100 posts? Same command! Auto-parallel if >10 posts
230
+ praisonaiwp create 100_posts.json
231
+ # Automatically uses parallel mode for speed ⚡
232
+ 3️⃣ Update Posts
233
+ bash
234
+ # Interactive mode
235
+ praisonaiwp update 123
236
+ # Shows current content, asks what to change
237
+
238
+ # Direct replacement
239
+ praisonaiwp update 123 "old text" "new text"
240
+
241
+ # Specific line
242
+ praisonaiwp update 123 "old text" "new text" --line 10
243
+
244
+ # Nth occurrence
245
+ praisonaiwp update 123 "old text" "new text" --nth 2
246
+
247
+ # Preview first (always safe)
248
+ praisonaiwp update 123 "old text" "new text" --preview
249
+ 4️⃣ Find
250
+ bash
251
+ # Find in post
252
+ praisonaiwp find 123 "search text"
253
+
254
+ # Find across all posts
255
+ praisonaiwp find "search text"
256
+ 5️⃣ List
257
+ bash
258
+ # List all posts
259
+ praisonaiwp list
260
+
261
+ # List pages
262
+ praisonaiwp list --type page
263
+
264
+ # List with search
265
+ praisonaiwp list --search "church"
266
+ 🎯 EVEN SIMPLER: Natural Language Style
267
+ bash
268
+ # Create
269
+ praisonaiwp "create a post titled 'Hello World'"
270
+ praisonaiwp "create 100 posts from posts.json"
271
+
272
+ # Update
273
+ praisonaiwp "update post 123 replace 'old' with 'new' on line 10"
274
+ praisonaiwp "update post 123 change the 2nd occurrence of 'old' to 'new'"
275
+
276
+ # Find
277
+ praisonaiwp "find 'church' in post 123"
278
+ praisonaiwp "show me all posts with 'church'"
279
+
280
+ # List
281
+ praisonaiwp "list all pages"
282
+ praisonaiwp "show me published posts"
283
+ 🏆 RECOMMENDED: Hybrid Approach
284
+ Simple commands + Smart defaults + Natural language fallback
285
+
286
+ Core Commands (5 only):
287
+ bash
288
+ praisonaiwp init # Setup (one-time)
289
+ praisonaiwp create [file] # Create posts
290
+ praisonaiwp update <id> # Update posts
291
+ praisonaiwp find <pattern> # Search
292
+ praisonaiwp list # List posts
293
+ Smart Defaults:
294
+ Auto-detects file format (JSON/YAML/CSV)
295
+ Auto-uses parallel mode for bulk (>10 posts)
296
+ Auto-backups before updates
297
+ Auto-preview for destructive operations
298
+ Auto-connects to default server
299
+ Example Usage:
300
+ bash
301
+ # Setup once
302
+ praisonaiwp init
303
+
304
+ # Create single post
305
+ praisonaiwp create "My Post" --content "Hello World"
306
+
307
+ # Create 100 posts (auto-parallel!)
308
+ praisonaiwp create posts.json
309
+ # Output: Creating 100 posts in parallel... Done in 8s ⚡
310
+
311
+ # Update specific line
312
+ praisonaiwp update 123 "old" "new" --line 10
313
+ # Output: Preview changes? [Y/n]
314
+ # Line 10: "old heading" → "new heading"
315
+ # Apply? [Y/n]
316
+
317
+ # Find text
318
+ praisonaiwp find "church"
319
+ # Output: Found in 9 posts:
320
+ # - Post 116 (line 10, 55)
321
+ # - Post 117 (line 10)
322
+ # ...
323
+ Comparison: Before vs After
324
+ ❌ BEFORE (Too Complex):
325
+ bash
326
+ praisonaiwp bulk create \
327
+ --server production \
328
+ --file posts.json \
329
+ --mode parallel \
330
+ --workers 10 \
331
+ --backup \
332
+ --dry-run
333
+ ✅ AFTER (Simple):
334
+ bash
335
+ praisonaiwp create posts.json
336
+ # Auto-detects: bulk, auto-parallel, auto-backup, auto-preview
337
+ File Format (Super Simple)
338
+ posts.json
339
+ json
340
+ [
341
+ {
342
+ "title": "Tamil Church in Peterborough",
343
+ "content": "<p>Welcome...</p>"
344
+ },
345
+ {
346
+ "title": "Hindi Church in Peterborough",
347
+ "content": "<p>Welcome...</p>"
348
+ }
349
+ ]
350
+ updates.json
351
+ json
352
+ [
353
+ {
354
+ "id": 116,
355
+ "line": 10,
356
+ "find": "Old Heading",
357
+ "replace": "New Heading"
358
+ },
359
+ {
360
+ "id": 117,
361
+ "line": 10,
362
+ "find": "Old Heading",
363
+ "replace": "Different Heading"
364
+ }
365
+ ]
366
+ 🎯 Final Recommendation
367
+ Use this simplified structure:
368
+
369
+ bash
370
+ # 5 core commands only
371
+ praisonaiwp init
372
+ praisonaiwp create [file|title]
373
+ praisonaiwp update <id> [find] [replace]
374
+ praisonaiwp find <pattern>
375
+ praisonaiwp list
376
+
377
+ # Smart flags (optional)
378
+ --line <num> # Update specific line
379
+ --nth <num> # Update nth occurrence
380
+ --preview # Preview changes
381
+ --no-backup # Skip backup
382
+ --server <name> # Use different server
383
+ Benefits:
384
+
385
+ ✅ Only 5 commands to remember
386
+ ✅ Smart defaults (no need to specify mode, workers, etc.)
387
+ ✅ Auto-detects everything
388
+ ✅ Interactive when needed
389
+ ✅ Safe by default (preview, backup)
390
+ ✅ Fast automatically (parallel for bulk)