Chrome Extension Capture Client #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Daily Planner | ||
| on: | ||
| schedule: | ||
| # Run daily at 6 AM UTC (10 PM PST, 1 AM EST) | ||
| - cron: '0 6 * * *' | ||
| workflow_dispatch: # Allow manual triggering | ||
| inputs: | ||
| test_mode: | ||
| description: 'Run in test mode with verbose logging' | ||
| required: false | ||
| default: 'true' | ||
| type: boolean | ||
| generate_weekly: | ||
| description: 'Generate weekly plan as well' | ||
| required: false | ||
| default: 'false' | ||
| type: boolean | ||
| jobs: | ||
| generate-daily-plan: | ||
| name: Generate Daily Plan | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Verify prerequisites | ||
| run: | | ||
| echo "π Verifying daily planner prerequisites..." | ||
| # Check master prompt | ||
| if [ -f "prompts/origin-master-prompt.md" ]; then | ||
| echo "β Master prompt exists" | ||
| echo "π Size: $(wc -l < prompts/origin-master-prompt.md) lines" | ||
| else | ||
| echo "β Master prompt not found" | ||
| exit 1 | ||
| fi | ||
| # Check reading queue | ||
| if [ -f "data/reading-queue.json" ]; then | ||
| if command -v jq >/dev/null 2>&1; then | ||
| local queue_size=$(jq '.meta.total_items // 0' data/reading-queue.json 2>/dev/null || echo "0") | ||
| echo "β Reading queue exists with $queue_size items" | ||
| else | ||
| echo "β Reading queue exists (jq not available for count)" | ||
| fi | ||
| else | ||
| echo "β οΈ Reading queue not found, running normalizer first..." | ||
| node automation/normalize.js | ||
| echo "β Reading queue generated" | ||
| fi | ||
| # Check configurations | ||
| local missing_configs="" | ||
| for config in schedule.yaml priorities.yaml areas.yaml; do | ||
| if [ -f "configs/$config" ]; then | ||
| echo "β Config found: $config" | ||
| else | ||
| echo "β οΈ Config missing: $config" | ||
| missing_configs="$missing_configs $config" | ||
| fi | ||
| done | ||
| if [ -n "$missing_configs" ]; then | ||
| echo "β οΈ Some configuration files are missing, using defaults" | ||
| fi | ||
| - name: Generate timestamp for artifacts | ||
| id: timestamp | ||
| run: | | ||
| echo "timestamp=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT | ||
| echo "date_human=$(date -u +"%Y-%m-%d")" >> $GITHUB_OUTPUT | ||
| - name: Run Agent Harness (Local Mode) | ||
| run: | | ||
| echo "π€ Running agent harness in local mode..." | ||
| # Set environment variables for test mode | ||
| if [ "${{ github.event.inputs.test_mode }}" = "true" ]; then | ||
| export DEBUG=1 | ||
| echo "π Debug mode enabled" | ||
| fi | ||
| # Run the harness | ||
| if node agent/harness.js --mode local; then | ||
| echo "β Agent harness executed successfully" | ||
| # Verify outputs | ||
| local outputs_generated=true | ||
| if [ -f "agent/out/daily-plan.json" ]; then | ||
| echo "β Daily plan JSON generated" | ||
| local file_size=$(du -h agent/out/daily-plan.json | cut -f1) | ||
| echo "π File size: $file_size" | ||
| if command -v jq >/dev/null 2>&1; then | ||
| local task_count=$(jq '.schedule.total_tasks // 0' agent/out/daily-plan.json 2>/dev/null || echo "0") | ||
| local focus_time=$(jq '.schedule.total_focus_time // 0' agent/out/daily-plan.json 2>/dev/null || echo "0") | ||
| echo "π Tasks: $task_count, Focus time: $focus_time minutes" | ||
| fi | ||
| else | ||
| echo "β Daily plan JSON not generated" | ||
| outputs_generated=false | ||
| fi | ||
| if [ -f "agent/out/weekly-plan.json" ]; then | ||
| echo "β Weekly plan JSON generated" | ||
| local file_size=$(du -h agent/out/weekly-plan.json | cut -f1) | ||
| echo "π File size: $file_size" | ||
| if command -v jq >/dev/null 2>&1; then | ||
| local weekly_tasks=$(jq '.tasks_summary.total_selected // 0' agent/out/weekly-plan.json 2>/dev/null || echo "0") | ||
| echo "π Weekly tasks selected: $weekly_tasks" | ||
| fi | ||
| else | ||
| echo "β Weekly plan JSON not generated" | ||
| outputs_generated=false | ||
| fi | ||
| if [ -f "daily/daily.md" ]; then | ||
| echo "β Daily markdown generated" | ||
| local file_size=$(du -h daily/daily.md | cut -f1) | ||
| echo "π File size: $file_size" | ||
| else | ||
| echo "β Daily markdown not generated" | ||
| outputs_generated=false | ||
| fi | ||
| if [ -f "weekly/weekly.md" ]; then | ||
| echo "β Weekly markdown generated" | ||
| local file_size=$(du -h weekly/weekly.md | cut -f1) | ||
| echo "π File size: $file_size" | ||
| else | ||
| echo "β οΈ Weekly markdown not generated (may be expected)" | ||
| fi | ||
| if [ "$outputs_generated" = "false" ]; then | ||
| echo "β Some expected outputs were not generated" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "β Agent harness execution failed" | ||
| exit 1 | ||
| fi | ||
| - name: Run Agent Tests (if available) | ||
| run: | | ||
| echo "π§ͺ Running agent test suite..." | ||
| if [ -x "./tests/agent.test.sh" ]; then | ||
| if ./tests/agent.test.sh; then | ||
| echo "β All agent tests passed" | ||
| else | ||
| echo "β οΈ Some agent tests may have failed, but continuing..." | ||
| fi | ||
| else | ||
| echo "β οΈ Agent test script not found" | ||
| fi | ||
| - name: Generate Plan Summary | ||
| run: | | ||
| echo "π Generating plan summary..." | ||
| cat > daily-plan-summary.md << EOF | ||
| # Daily Plan Summary - ${{ steps.timestamp.outputs.date_human }} | ||
| **Generated:** $(date -u +"%Y-%m-%d %H:%M:%S UTC") | ||
| **Workflow Run:** [#${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | ||
| **Mode:** Local Mock Planning | ||
| ## Generated Plans | ||
| 1. β **Daily Plan** - JSON and Markdown formats | ||
| 2. β **Weekly Plan** - JSON and Markdown formats | ||
| 3. β **Time Blocks** - Energy-aware scheduling | ||
| 4. β **Task Selection** - Priority-based from reading queue | ||
| EOF | ||
| # Add statistics if available | ||
| if [ -f "agent/out/daily-plan.json" ] && command -v jq >/dev/null 2>&1; then | ||
| cat >> daily-plan-summary.md << EOF | ||
| ## Daily Plan Statistics | ||
| - **Total Tasks:** $(jq '.schedule.total_tasks // 0' agent/out/daily-plan.json) | ||
| - **Focus Time:** $(jq '.schedule.total_focus_time // 0' agent/out/daily-plan.json) minutes | ||
| - **Breaks Included:** $(jq '.schedule.breaks_included // 0' agent/out/daily-plan.json) | ||
| - **Daily Focus:** $(jq -r '.focus_theme // "Not specified"' agent/out/daily-plan.json) | ||
| EOF | ||
| fi | ||
| # Add weekly statistics if available | ||
| if [ -f "agent/out/weekly-plan.json" ] && command -v jq >/dev/null 2>&1; then | ||
| cat >> daily-plan-summary.md << EOF | ||
| ## Weekly Plan Statistics | ||
| - **Tasks Selected:** $(jq '.tasks_summary.total_selected // 0' agent/out/weekly-plan.json) | ||
| - **Work Tasks:** $(jq '.tasks_summary.work_tasks // 0' agent/out/weekly-plan.json) | ||
| - **Learning Tasks:** $(jq '.tasks_summary.learning_tasks // 0' agent/out/weekly-plan.json) | ||
| - **Creative Tasks:** $(jq '.tasks_summary.creative_tasks // 0' agent/out/weekly-plan.json) | ||
| - **High Priority:** $(jq '.tasks_summary.high_priority // 0' agent/out/weekly-plan.json) | ||
| - **Focus Areas:** $(jq -r '.focus_areas | join(", ")' agent/out/weekly-plan.json) | ||
| EOF | ||
| fi | ||
| echo "" | ||
| echo "## π Daily Plan Summary" | ||
| echo "" | ||
| cat daily-plan-summary.md | ||
| - name: Check for changes | ||
| id: changes | ||
| run: | | ||
| # Add all generated files | ||
| git add agent/out/ daily/ weekly/ daily-plan-summary.md 2>/dev/null || true | ||
| if git diff --cached --quiet; then | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| echo "π No changes to commit" | ||
| else | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| echo "π Changes detected, preparing commit..." | ||
| git diff --cached --stat | ||
| fi | ||
| - name: Commit and push changes | ||
| if: steps.changes.outputs.changed == 'true' | ||
| run: | | ||
| git config --local user.email "action@github.com" | ||
| git config --local user.name "GitHub Action" | ||
| git commit -m "chore: generate daily plan ${{ steps.timestamp.outputs.date_human }} | ||
| π€ Generated with [GitHub Actions](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | ||
| - Daily plan created with local agent | ||
| - Time blocks scheduled based on reading queue | ||
| - Energy-aware task prioritization | ||
| - Markdown and JSON outputs generated | ||
| - Timestamp: $(date -u +"%Y-%m-%d %H:%M:%S UTC") | ||
| Plan Details: | ||
| $(cat daily-plan-summary.md | grep -E "^-|\*\*" | head -8) | ||
| Co-Authored-By: GitHub Action <action@users.noreply.github.com>" | ||
| git push | ||
| - name: Upload daily plan artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: daily-plan-${{ steps.timestamp.outputs.timestamp }} | ||
| path: | | ||
| agent/out/ | ||
| daily/daily.md | ||
| weekly/weekly.md | ||
| daily-plan-summary.md | ||
| retention-days: 30 | ||
| - name: Archive old daily plans | ||
| run: | | ||
| echo "ποΈ Archiving old plans..." | ||
| # Archive yesterday's daily plan if it exists | ||
| yesterday=$(date -d "yesterday" +%Y-%m-%d 2>/dev/null || date -v-1d +%Y-%m-%d 2>/dev/null || echo "2025-01-01") | ||
| if [ -f "daily/daily.md" ] && [ "$yesterday" != "$(date +%Y-%m-%d)" ]; then | ||
| # Create archive directory if it doesn't exist | ||
| mkdir -p archive/daily archive/weekly archive/json | ||
| # Archive previous files (if they exist and are different from today) | ||
| if [ -f "daily/daily.md" ]; then | ||
| cp daily/daily.md "archive/daily/daily-$yesterday.md" 2>/dev/null || true | ||
| fi | ||
| if [ -f "weekly/weekly.md" ]; then | ||
| cp weekly/weekly.md "archive/weekly/weekly-$yesterday.md" 2>/dev/null || true | ||
| fi | ||
| if [ -f "agent/out/daily-plan.json" ]; then | ||
| cp agent/out/daily-plan.json "archive/json/daily-plan-$yesterday.json" 2>/dev/null || true | ||
| fi | ||
| if [ -f "agent/out/weekly-plan.json" ]; then | ||
| cp agent/out/weekly-plan.json "archive/json/weekly-plan-$yesterday.json" 2>/dev/null || true | ||
| fi | ||
| echo "π¦ Archived previous plans to archive/ directories" | ||
| fi | ||
| - name: Summary | ||
| run: | | ||
| echo "## π Daily Planner Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Status:** ${{ steps.changes.outputs.changed == 'true' && 'β Generated & Committed' || 'β Generated' }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Date:** ${{ steps.timestamp.outputs.date_human }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Timestamp:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Mode:** Local Mock Planning" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| if [ -f "agent/out/daily-plan.json" ]; then | ||
| if command -v jq >/dev/null 2>&1; then | ||
| echo "**Daily Plan Statistics:**" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Tasks: $(jq '.schedule.total_tasks // 0' agent/out/daily-plan.json)" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Focus Time: $(jq '.schedule.total_focus_time // 0' agent/out/daily-plan.json) minutes" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Theme: $(jq -r '.focus_theme // "Not specified"' agent/out/daily-plan.json)" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
| fi | ||
| if [ -f "agent/out/weekly-plan.json" ]; then | ||
| if command -v jq >/dev/null 2>&1; then | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Weekly Plan Overview:**" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Total Tasks: $(jq '.tasks_summary.total_selected // 0' agent/out/weekly-plan.json)" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Work: $(jq '.tasks_summary.work_tasks // 0' agent/out/weekly-plan.json), Learning: $(jq '.tasks_summary.learning_tasks // 0' agent/out/weekly-plan.json), Creative: $(jq '.tasks_summary.creative_tasks // 0' agent/out/weekly-plan.json)" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
| fi | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Generated Files:**" >> $GITHUB_STEP_SUMMARY | ||
| echo "- \`agent/out/daily-plan.json\` - Structured daily plan" >> $GITHUB_STEP_SUMMARY | ||
| echo "- \`agent/out/weekly-plan.json\` - Structured weekly plan" >> $GITHUB_STEP_SUMMARY | ||
| echo "- \`daily/daily.md\` - Human-readable daily schedule" >> $GITHUB_STEP_SUMMARY | ||
| echo "- \`weekly/weekly.md\` - Weekly overview" >> $GITHUB_STEP_SUMMARY | ||
| if [ "${{ steps.changes.outputs.changed }}" == "true" ]; then | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### π Changes Committed" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Daily and weekly plans committed to repository" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Previous plans archived for reference" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Ready for daily workflow execution" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**π¦ Artifacts:**" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Download all generated files from the artifacts section" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Files retained for 30 days" >> $GITHUB_STEP_SUMMARY | ||
| plan-validation: | ||
| name: Plan Validation | ||
| runs-on: ubuntu-latest | ||
| needs: generate-daily-plan | ||
| if: always() && needs.generate-daily-plan.result == 'success' | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Validate generated plans | ||
| run: | | ||
| echo "π Validating generated plans..." | ||
| # Validate daily plan JSON | ||
| if [ -f "agent/out/daily-plan.json" ]; then | ||
| if jq empty agent/out/daily-plan.json 2>/dev/null; then | ||
| echo "β Daily plan JSON is valid" | ||
| # Check required fields | ||
| if jq -e '.date' agent/out/daily-plan.json >/dev/null 2>&1; then | ||
| echo "β Daily plan has date field" | ||
| else | ||
| echo "β Daily plan missing date field" | ||
| exit 1 | ||
| fi | ||
| if jq -e '.time_blocks' agent/out/daily-plan.json >/dev/null 2>&1; then | ||
| local block_count=$(jq '.time_blocks | length' agent/out/daily-plan.json 2>/dev/null || echo "0") | ||
| echo "β Daily plan has $block_count time blocks" | ||
| else | ||
| echo "β Daily plan missing time_blocks field" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "β Daily plan JSON is invalid" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "β Daily plan JSON not found" | ||
| exit 1 | ||
| fi | ||
| # Validate weekly plan JSON | ||
| if [ -f "agent/out/weekly-plan.json" ]; then | ||
| if jq empty agent/out/weekly-plan.json 2>/dev/null; then | ||
| echo "β Weekly plan JSON is valid" | ||
| else | ||
| echo "β Weekly plan JSON is invalid" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "β οΈ Weekly plan JSON not found" | ||
| fi | ||
| # Validate markdown files | ||
| if [ -f "daily/daily.md" ]; then | ||
| if grep -q "^# " daily/daily.md; then | ||
| echo "β Daily markdown has title" | ||
| else | ||
| echo "β οΈ Daily markdown may not have proper title" | ||
| fi | ||
| fi | ||
| if [ -f "weekly/weekly.md" ]; then | ||
| if grep -q "^# " weekly/weekly.md; then | ||
| echo "β Weekly markdown has title" | ||
| else | ||
| echo "β οΈ Weekly markdown may not have proper title" | ||
| fi | ||
| fi | ||
| - name: Validation Summary | ||
| run: | | ||
| echo "## β Plan Validation Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**JSON Validation:** β Passed" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Schema Validation:** β Passed" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Markdown Files:** β Passed" >> $GITHUB_STEP_SUMMARY | ||
| echo "**File Structure:** β Passed" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "All generated plans passed validation checks!" >> $GITHUB_STEP_SUMMARY | ||