appydave-tools 0.15.0 → 0.16.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/CLAUDE.md +113 -29
  4. data/README.md +262 -86
  5. data/bin/subtitle_manager.rb +18 -12
  6. data/bin/subtitle_processor.rb +158 -0
  7. data/docs/archive/codebase-audit-2025-01.md +424 -0
  8. data/docs/archive/documentation-framework-proposal.md +808 -0
  9. data/docs/archive/purpose-and-philosophy.md +110 -0
  10. data/docs/archive/test-coverage-quick-wins.md +342 -0
  11. data/docs/archive/tool-discovery.md +199 -0
  12. data/docs/archive/tool-documentation-analysis.md +592 -0
  13. data/docs/tools/bank-reconciliation.md +269 -0
  14. data/docs/tools/cli-actions.md +444 -0
  15. data/docs/tools/configuration.md +329 -0
  16. data/docs/{usage → tools}/gpt-context.md +118 -7
  17. data/docs/tools/index.md +324 -0
  18. data/docs/tools/move-images.md +295 -0
  19. data/docs/tools/name-manager.md +322 -0
  20. data/docs/tools/prompt-tools.md +209 -0
  21. data/docs/tools/subtitle-processor.md +242 -0
  22. data/docs/tools/youtube-automation.md +258 -0
  23. data/docs/tools/youtube-manager.md +248 -0
  24. data/lib/appydave/tools/{subtitle_manager → subtitle_processor}/clean.rb +1 -1
  25. data/lib/appydave/tools/{subtitle_manager → subtitle_processor}/join.rb +5 -2
  26. data/lib/appydave/tools/version.rb +1 -1
  27. data/lib/appydave/tools.rb +2 -4
  28. data/package.json +1 -1
  29. metadata +29 -12
  30. data/lib/mj-paste-test/main.rb +0 -35
  31. data/lib/mj-paste-test/prompts.txt +0 -18
  32. data/lib/mj-paste-test/readme-leonardo.md +0 -0
  33. /data/lib/appydave/tools/{subtitle_manager → subtitle_processor}/_doc-clean.md +0 -0
  34. /data/lib/appydave/tools/{subtitle_manager → subtitle_processor}/_doc-join.md +0 -0
  35. /data/lib/appydave/tools/{subtitle_manager → subtitle_processor}/_doc-todo.md +0 -0
@@ -0,0 +1,242 @@
1
+ # Subtitle Processor
2
+
3
+ Clean, normalize, and merge SRT subtitle files with configurable formatting and timeline adjustments.
4
+
5
+ ## What It Does
6
+
7
+ **Subtitle Processor** handles video subtitle (SRT) file operations:
8
+
9
+ - Cleans and normalizes SRT formatting (removes HTML tags, fixes encoding)
10
+ - Joins multiple SRT files into one with timeline offset
11
+ - Handles timing synchronization across segments
12
+ - Supports various sort orders (ascending, descending, inferred)
13
+ - Flexible buffer/gap control between segments
14
+ - UTF-8 encoding handling
15
+
16
+ ## How to Use
17
+
18
+ ### Clean Subtitles
19
+
20
+ Remove formatting issues, HTML tags, and normalize SRT structure:
21
+
22
+ ```bash
23
+ # Clean a subtitle file
24
+ subtitle_processor clean -f input.srt -o output.srt
25
+
26
+ # Clean and review
27
+ subtitle_processor clean -f subtitles.srt -o cleaned.srt
28
+ ```
29
+
30
+ **What it fixes**:
31
+ - Removes HTML tags (`<u>`, `<b>`, `<i>`, etc.)
32
+ - Fixes character encoding issues
33
+ - Normalizes line breaks and spacing
34
+ - Ensures proper SRT format (number, timestamp, text, blank line)
35
+
36
+ ### Join Subtitles
37
+
38
+ Merge multiple SRT files with proper timeline management:
39
+
40
+ ```bash
41
+ # Join all SRT files in a directory
42
+ subtitle_processor join -d ./ -f "*.srt" -o merged.srt
43
+
44
+ # Join specific files with custom buffer
45
+ subtitle_processor join -d ./subtitles -f "part1.srt,part2.srt,part3.srt" -b 500 -o final.srt
46
+
47
+ # Join with specific sort order
48
+ subtitle_processor join -d ./ -f "*.srt" -s "asc" -o merged.srt
49
+ ```
50
+
51
+ **Key options**:
52
+ - `-d` / `--directory`: Folder containing SRT files (default: current)
53
+ - `-f` / `--files`: Pattern (`*.srt`) or comma-separated list
54
+ - `-s` / `--sort`: Order (`asc`, `desc`, `inferred`) - inferred uses numeric filename order
55
+ - `-b` / `--buffer`: Gap between segments in milliseconds (default: 100ms)
56
+ - `-o` / `--output`: Output filename (default: `merged.srt`)
57
+
58
+ ## Use Cases for AI Agents
59
+
60
+ ### 1. Subtitle Quality Assurance
61
+ ```bash
62
+ # Clean subtitles before publishing
63
+ subtitle_processor clean -f extracted-subs.srt -o published.srt
64
+ ```
65
+ **AI discovers**: Formatting issues, encoding problems, HTML artifacts. Can identify and fix subtitle quality problems systematically.
66
+
67
+ ### 2. Multi-Part Video Subtitle Handling
68
+ ```bash
69
+ # Combine subtitles from video segments
70
+ subtitle_processor join -d ./segments -f "*.srt" -s "inferred" -o complete.srt
71
+ ```
72
+ **AI discovers**: How multiple video segments need proper timing. Can orchestrate subtitle merging for multi-part content.
73
+
74
+ ### 3. Subtitle Synchronization
75
+ ```bash
76
+ # Adjust timing between merged segments
77
+ subtitle_processor join -d ./ -f "part1.srt,part2.srt" -b 200 -o sync.srt
78
+ ```
79
+ **AI discovers**: Timing requirements between segments. Can calculate and apply correct timing offsets.
80
+
81
+ ### 4. Batch Subtitle Processing
82
+ ```bash
83
+ # Process all subtitles in project
84
+ # AI orchestrates:
85
+ # 1. Find all .srt files
86
+ # 2. Clean each one
87
+ # 3. Verify cleaned files are valid
88
+ ```
89
+ **AI discovers**: How to systematically process multiple subtitle files. Can batch process and verify quality.
90
+
91
+ ### 5. Subtitle Format Migration
92
+ ```bash
93
+ # Convert between subtitle standards via cleanup
94
+ subtitle_processor clean -f old-format.srt -o new-format.srt
95
+ ```
96
+ **AI discovers**: Original SRT issues and formatting. Can prepare for format conversion.
97
+
98
+ ### 6. Damage Repair
99
+ ```bash
100
+ # Fix corrupted or poorly extracted subtitles
101
+ subtitle_processor clean -f corrupted.srt -o repaired.srt
102
+ ```
103
+ **AI discovers**: Encoding issues, formatting damage. Can restore usable subtitles from corrupted sources.
104
+
105
+ ### 7. Merged Video Preparation
106
+ ```bash
107
+ # Prepare subtitles when merging video files
108
+ subtitle_processor join -d ./ -f "intro.srt,main.srt,outro.srt" -b 100 -o merged.srt
109
+ ```
110
+ **AI discovers**: How many segments, their order, timing requirements. Can prepare complete subtitle for merged video.
111
+
112
+ ### 8. Archive Subtitle Cleanup
113
+ ```bash
114
+ # Clean up subtitle library
115
+ # AI processes all subtitles, removes HTML, normalizes encoding
116
+ for file in *.srt; do
117
+ subtitle_processor clean -f "$file" -o "cleaned/$file"
118
+ done
119
+ ```
120
+ **AI discovers**: Quality issues across library. Can systematically improve archive.
121
+
122
+ ### 9. Subtitle Editing Preparation
123
+ ```bash
124
+ # Clean before human editing
125
+ subtitle_processor clean -f raw.srt -o edit-ready.srt
126
+ ```
127
+ **AI discovers**: What needs fixing before human review. Can prepare clean files for editing.
128
+
129
+ ### 10. Workflow Automation
130
+ ```bash
131
+ # Full subtitle workflow in script
132
+ # Extract subtitles from video
133
+ # Clean extracted subtitles
134
+ # Join with other segments if needed
135
+ # Verify output is valid SRT
136
+ ```
137
+ **AI discovers**: Complete workflow from extraction to publishing. Can automate multi-step subtitle processes.
138
+
139
+ ## Command Reference
140
+
141
+ ### Clean Command
142
+ ```bash
143
+ subtitle_processor clean [options]
144
+ ```
145
+
146
+ | Option | Short | Long | Description |
147
+ |--------|-------|------|-------------|
148
+ | File | `-f` | `--file FILE` | SRT file to process (required) |
149
+ | Output | `-o` | `--output FILE` | Output file (required) |
150
+ | Help | `-h` | `--help` | Show help |
151
+
152
+ **Input**: Any SRT file (even malformed)
153
+ **Output**: Cleaned, valid SRT format
154
+
155
+ ### Join Command
156
+ ```bash
157
+ subtitle_processor join [options]
158
+ ```
159
+
160
+ | Option | Short | Long | Description |
161
+ |--------|-------|------|-------------|
162
+ | Directory | `-d` | `--directory DIR` | Folder with SRT files (default: current) |
163
+ | Files | `-f` | `--files PATTERN` | Pattern `*.srt` or list `part1.srt,part2.srt` |
164
+ | Sort | `-s` | `--sort ORDER` | `asc`, `desc`, or `inferred` (default: inferred) |
165
+ | Buffer | `-b` | `--buffer MS` | Gap between segments in ms (default: 100) |
166
+ | Output | `-o` | `--output FILE` | Output filename (default: merged.srt) |
167
+ | Log Level | `-L` | `--log-level LEVEL` | `none`, `info`, `detail` |
168
+ | Help | `-h` | `--help` | Show help |
169
+
170
+ ## SRT Format Reference
171
+
172
+ Valid SRT file structure:
173
+
174
+ ```
175
+ 1
176
+ 00:00:00,000 --> 00:00:03,000
177
+ First subtitle
178
+
179
+ 2
180
+ 00:00:03,500 --> 00:00:07,000
181
+ Second subtitle
182
+
183
+ 3
184
+ 00:00:07,500 --> 00:00:10,000
185
+ Third subtitle
186
+ ```
187
+
188
+ **Important**:
189
+ - Sequence numbers must be sequential (1, 2, 3...)
190
+ - Timestamps use comma for milliseconds (00:00:00,000)
191
+ - Blank line required between entries
192
+ - Text can be multiple lines
193
+ - No HTML tags (Processor removes these)
194
+
195
+ ## Troubleshooting
196
+
197
+ | Issue | Solution |
198
+ |-------|----------|
199
+ | "Missing required options" | Provide both `-f` (file) and `-o` (output) for clean command |
200
+ | "File not found" | Check file path and permissions |
201
+ | "Encoding error" | Try cleaning first to fix encoding: `clean -f file.srt -o temp.srt` |
202
+ | "Invalid sort order" | Use `asc`, `desc`, or `inferred` |
203
+ | "Timestamp overlap" | Reduce or remove buffer with `-b 0` |
204
+
205
+ ## Tips & Tricks
206
+
207
+ 1. **Always clean extracted subtitles**: Video tools often create messy SRT with HTML tags
208
+ 2. **Test join first**: Review timing with small file set before processing 100+ files
209
+ 3. **Use inferred sort**: Helps when files are numbered (part1.srt, part2.srt)
210
+ 4. **Buffer for safety**: Small buffer (100-200ms) prevents timing overlaps between segments
211
+ 5. **Backup originals**: Always keep original .srt files before processing
212
+
213
+ ## Examples
214
+
215
+ ### Clean Subtitles from YouTube
216
+ ```bash
217
+ # YouTube captions often have encoding issues
218
+ subtitle_processor clean -f youtube-captions.srt -o youtube-clean.srt
219
+ ```
220
+
221
+ ### Merge Multi-Part Educational Video
222
+ ```bash
223
+ # Join chapter subtitles with 500ms gap
224
+ subtitle_processor join -d chapters/ -f "*.srt" -s "inferred" -b 500 -o course-complete.srt
225
+ ```
226
+
227
+ ### Fix Corrupted Archive
228
+ ```bash
229
+ # Repair entire subtitle library
230
+ for file in archive/*.srt; do
231
+ subtitle_processor clean -f "$file" -o "archive-clean/$(basename $file)"
232
+ done
233
+ ```
234
+
235
+ ---
236
+
237
+ **Related Tools**:
238
+ - `youtube_manager` - Manage video metadata alongside subtitles
239
+ - `gpt_context` - Gather subtitle data for analysis
240
+ - `move_images` - Part of video processing pipeline
241
+
242
+ **File Format**: [SRT Format Specification](https://en.wikipedia.org/wiki/SubRip)
@@ -0,0 +1,258 @@
1
+ # YouTube Automation
2
+
3
+ Internal orchestration tool for coordinating YouTube workflows and content generation tasks.
4
+
5
+ ## What It Does
6
+
7
+ **YouTube Automation** is an internal tool that coordinates complex YouTube workflows:
8
+
9
+ - Orchestrates multi-step video publishing processes
10
+ - Coordinates with GPT agents for content generation
11
+ - Manages workflow state and dependencies
12
+ - Integrates with other tools (YouTube Manager, Subtitle Processor, etc.)
13
+ - Supports parameterized workflow definitions
14
+ - Handles error recovery and retries
15
+
16
+ ## How to Use
17
+
18
+ ### Workflow Structure
19
+
20
+ This tool uses a configuration-based workflow system:
21
+
22
+ ```bash
23
+ # List available workflows
24
+ youtube_automation workflows
25
+
26
+ # Execute a workflow
27
+ youtube_automation execute workflow_name [options]
28
+
29
+ # Check workflow status
30
+ youtube_automation status workflow_name
31
+ ```
32
+
33
+ ### Configuration Location
34
+
35
+ Workflows are defined in:
36
+ - `~/.config/appydave/youtube_automation.json` - Workflow definitions
37
+ - `~/.config/appydave/channels.json` - Channel configuration
38
+
39
+ ## Workflow Concepts
40
+
41
+ Each workflow consists of:
42
+
43
+ 1. **Trigger**: What starts the workflow (manual, scheduled, event)
44
+ 2. **Steps**: Sequential or parallel operations (fetch, transform, publish)
45
+ 3. **Integrations**: Which tools are involved (YouTube Manager, Subtitle Processor, etc.)
46
+ 4. **Handlers**: Error handling and retry logic
47
+ 5. **State**: What data flows between steps
48
+
49
+ ## Use Cases for AI Agents
50
+
51
+ ### 1. Orchestrated Video Publishing
52
+ ```bash
53
+ # AI-managed workflow:
54
+ # 1. Fetch video details (youtube_manager get)
55
+ # 2. Generate optimized description (GPT agent)
56
+ # 3. Extract and clean subtitles (subtitle_processor clean)
57
+ # 4. Upload updated metadata (youtube_manager update)
58
+ youtube_automation execute publish_with_optimization -v dQw4w9WgXcQ
59
+ ```
60
+ **AI discovers**: Complete publishing workflow, what each step does, dependencies. Can orchestrate complex multi-step processes.
61
+
62
+ ### 2. Batch Content Optimization
63
+ ```bash
64
+ # Process multiple videos:
65
+ # For each video:
66
+ # 1. Get current metadata
67
+ # 2. Analyze with AI for improvements
68
+ # 3. Generate optimized version
69
+ # 4. Stage changes for review
70
+ youtube_automation execute batch_optimize -c "channel-id"
71
+ ```
72
+ **AI discovers**: How to handle batch operations at scale. Can orchestrate 50+ videos with proper state management.
73
+
74
+ ### 3. Content Generation Pipeline
75
+ ```bash
76
+ # Workflow: Script → Video → Captions → Metadata → Publish
77
+ # AI coordinates between:
78
+ # - LLM for script generation
79
+ # - Video tools for processing
80
+ # - Subtitle processor for captions
81
+ # - YouTube manager for publishing
82
+ youtube_automation execute full_content_pipeline -s "script-file.md"
83
+ ```
84
+ **AI discovers**: End-to-end content workflow dependencies. Can manage complex multi-tool pipelines.
85
+
86
+ ### 4. Error Recovery & Resumption
87
+ ```bash
88
+ # Workflow with fault tolerance
89
+ # If step 2 fails:
90
+ # - Log error with context
91
+ # - Offer resume option
92
+ # - Continue from where it failed
93
+ youtube_automation resume job_id
94
+ ```
95
+ **AI discovers**: How to handle failures gracefully in complex workflows. Can implement robust error recovery.
96
+
97
+ ### 5. Parallel Workflow Processing
98
+ ```bash
99
+ # Process multiple channels simultaneously
100
+ # Workflow handles concurrent operations:
101
+ # - Video 1: fetch, optimize, update
102
+ # - Video 2: fetch, optimize, update
103
+ # - Video 3: fetch, optimize, update
104
+ youtube_automation execute parallel_optimization -c "multiple-channels"
105
+ ```
106
+ **AI discovers**: Concurrency patterns, state isolation. Can coordinate parallel tasks safely.
107
+
108
+ ### 6. Conditional Workflow Branching
109
+ ```bash
110
+ # Workflow with conditional logic:
111
+ # If video has < 1000 views:
112
+ # - Regenerate thumbnail
113
+ # - Reoptimize description
114
+ # - Add to promotion list
115
+ # Else:
116
+ # - Mark as successful
117
+ # - Archive metadata
118
+ youtube_automation execute conditional_optimization -v "video-id"
119
+ ```
120
+ **AI discovers**: How to implement conditional workflows. Can build intelligent decision logic into processes.
121
+
122
+ ### 7. Workflow State Inspection
123
+ ```bash
124
+ # Debug workflow execution
125
+ # See what data is flowing between steps
126
+ # Identify bottlenecks or failures
127
+ youtube_automation debug job_id --verbose
128
+ ```
129
+ **AI discovers**: Workflow state, what's happening at each step. Can diagnose issues in complex workflows.
130
+
131
+ ### 8. Integration Testing
132
+ ```bash
133
+ # Test workflow with dry-run mode
134
+ # Execute steps without making changes
135
+ youtube_automation execute workflow_name --dry-run
136
+ ```
137
+ **AI discovers**: What workflow would do without side effects. Can safely test complex workflows.
138
+
139
+ ### 9. Workflow Composition
140
+ ```bash
141
+ # Combine multiple workflows
142
+ # Master workflow orchestrates sub-workflows:
143
+ # - run: fetch_workflow
144
+ # - run: process_workflow
145
+ # - run: publish_workflow
146
+ youtube_automation execute master_workflow
147
+ ```
148
+ **AI discovers**: How to compose complex workflows from simpler components. Can build modular workflow systems.
149
+
150
+ ### 10. Historical Analysis & Metrics
151
+ ```bash
152
+ # Analyze workflow execution history
153
+ # What videos took longest to process?
154
+ # Where do failures happen most?
155
+ # Which steps have highest latency?
156
+ youtube_automation analyze metrics --period "30d"
157
+ ```
158
+ **AI discovers**: Workflow performance patterns. Can identify optimization opportunities based on historical data.
159
+
160
+ ## Workflow Definition Example
161
+
162
+ ```json
163
+ {
164
+ "workflows": {
165
+ "publish_with_optimization": {
166
+ "trigger": "manual",
167
+ "steps": [
168
+ {
169
+ "name": "fetch",
170
+ "tool": "youtube_manager",
171
+ "command": "get",
172
+ "params": {"video_id": "${VIDEO_ID}"}
173
+ },
174
+ {
175
+ "name": "optimize",
176
+ "tool": "gpt_agent",
177
+ "command": "optimize_metadata",
178
+ "params": {"metadata": "${fetch.output}"}
179
+ },
180
+ {
181
+ "name": "update",
182
+ "tool": "youtube_manager",
183
+ "command": "update",
184
+ "params": {
185
+ "video_id": "${VIDEO_ID}",
186
+ "title": "${optimize.title}",
187
+ "description": "${optimize.description}"
188
+ }
189
+ }
190
+ ],
191
+ "on_error": "retry_step"
192
+ }
193
+ }
194
+ }
195
+ ```
196
+
197
+ ## Command Reference
198
+
199
+ ### Execute Workflow
200
+ ```bash
201
+ youtube_automation execute WORKFLOW_NAME [options]
202
+ ```
203
+
204
+ | Option | Short | Long | Description |
205
+ |--------|-------|------|-------------|
206
+ | Dry Run | `-d` | `--dry-run` | Simulate without making changes |
207
+ | Verbose | `-v` | `--verbose` | Detailed output |
208
+ | Config | `-c` | `--config FILE` | Custom config file |
209
+
210
+ ### Status & Monitoring
211
+ ```bash
212
+ youtube_automation status [job_id]
213
+ youtube_automation resume [job_id]
214
+ youtube_automation cancel [job_id]
215
+ youtube_automation logs [job_id]
216
+ ```
217
+
218
+ ## Configuration
219
+
220
+ Edit workflow definitions:
221
+
222
+ ```bash
223
+ # Edit in default editor
224
+ youtube_automation config edit workflows
225
+
226
+ # View current config
227
+ youtube_automation config show
228
+
229
+ # Validate config
230
+ youtube_automation config validate
231
+ ```
232
+
233
+ ## Troubleshooting
234
+
235
+ | Issue | Solution |
236
+ |-------|----------|
237
+ | "Workflow not found" | Check `~/.config/appydave/youtube_automation.json` |
238
+ | "Step failed, stopped" | Use `--verbose` to see error, then `resume` |
239
+ | "Configuration invalid" | Run `youtube_automation config validate` |
240
+ | "API rate limited" | Workflows implement backoff; check quotas in Google Cloud Console |
241
+
242
+ ## Tips & Tricks
243
+
244
+ 1. **Use dry-run first**: Test workflows without side effects
245
+ 2. **Check logs**: See detailed execution history with `youtube_automation logs job_id`
246
+ 3. **Parallel is safer**: Use parallel steps carefully; sequential is easier to debug
247
+ 4. **Error handling**: All workflows should have `on_error` strategy defined
248
+ 5. **State visibility**: Use `--verbose` to see data flowing between steps
249
+
250
+ ---
251
+
252
+ **Related Tools**:
253
+ - `youtube_manager` - For individual video operations
254
+ - `gpt_context` - For gathering context for workflow decisions
255
+ - `subtitle_processor` - For caption handling in workflows
256
+ - `configuration` - For workflow and channel setup
257
+
258
+ **Architecture**: Internal tool designed for orchestration. Not intended for direct end-user use in most cases.