CLI/TUI for drafting, repeating, and publishing daily standup updates as GitHub issues
github go cli golang management project tui daily
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: add project license, readme, and go module setup

Daniel Vieites 2c2d0ed6

+4130
+79
.github/ISSUE_TEMPLATE/async-daily.yml
··· 1 + name: Async Daily 2 + about: Daily async standup update 3 + title: "[Async Daily] [YYYY/MM/DD]" 4 + labels: [] 5 + body: 6 + - type: markdown 7 + attributes: 8 + value: | 9 + ## Daily Standup Update 10 + 11 + - type: textarea 12 + id: yesterday 13 + attributes: 14 + label: "✅ What did you do yesterday?" 15 + description: Describe what you accomplished yesterday 16 + placeholder: | 17 + - Completed feature X 18 + - Reviewed PR #123 19 + - Fixed bug in Y 20 + validations: 21 + required: true 22 + 23 + - type: textarea 24 + id: today 25 + attributes: 26 + label: "🎯 What will you do today?" 27 + description: Outline your plans for today 28 + placeholder: | 29 + - Start work on feature Z 30 + - Attend team meeting 31 + - Update documentation 32 + validations: 33 + required: true 34 + 35 + - type: textarea 36 + id: blockers 37 + attributes: 38 + label: "🚧 Any blockers?" 39 + description: Mention any obstacles you're facing (optional) 40 + placeholder: | 41 + - Waiting for code review 42 + - Need access to X resource 43 + - Blocked by external dependency 44 + validations: 45 + required: false 46 + 47 + - type: checkboxes 48 + id: parking_lot 49 + attributes: 50 + label: "🚨 Do you request a Parking Lot or escalation?" 51 + description: Check if you need team discussion or escalation 52 + options: 53 + - label: "✅ Yes, I need a Parking Lot or escalation" 54 + validations: 55 + required: false 56 + 57 + - type: textarea 58 + id: parking_details 59 + attributes: 60 + label: "📝 Parking Lot Details" 61 + description: Describe what you need to discuss (only used if escalation requested) 62 + placeholder: | 63 + - Need decision on architecture approach 64 + - Clarification on requirements 65 + - Resource constraints 66 + validations: 67 + required: false 68 + 69 + - type: textarea 70 + id: comments 71 + attributes: 72 + label: "💬 Additional Comments" 73 + description: Any other notes or context for the team (optional) 74 + placeholder: | 75 + - Working remotely today 76 + - Will be offline after 3pm 77 + - Taking Friday off 78 + validations: 79 + required: false
+48
.github/scripts/close-individual-issues.js
··· 1 + /** 2 + * Close individual async daily issues after the report is generated 3 + * 4 + * @param {object} github - GitHub API client 5 + * @param {object} context - GitHub Actions context 6 + * @param {Array} issues - Array of issues to close 7 + * @param {string} reportIssueUrl - URL to the generated report issue 8 + * @returns {Promise<void>} 9 + */ 10 + async function closeIndividualIssues(github, context, issues, reportIssueUrl) { 11 + console.log(`Closing ${issues.length} individual async daily issues...`); 12 + 13 + const closeComment = `✅ This async daily report has been processed and included in the [Daily Report](${reportIssueUrl}).\n\nClosing this individual issue.`; 14 + 15 + let successCount = 0; 16 + let errorCount = 0; 17 + 18 + for (const issue of issues) { 19 + try { 20 + // Add a comment with the link to the report 21 + await github.rest.issues.createComment({ 22 + owner: context.repo.owner, 23 + repo: context.repo.repo, 24 + issue_number: issue.number, 25 + body: closeComment 26 + }); 27 + 28 + // Close the issue 29 + await github.rest.issues.update({ 30 + owner: context.repo.owner, 31 + repo: context.repo.repo, 32 + issue_number: issue.number, 33 + state: 'closed', 34 + state_reason: 'completed' 35 + }); 36 + 37 + console.log(`✓ Closed issue #${issue.number} by @${issue.user.login}`); 38 + successCount++; 39 + } catch (error) { 40 + console.error(`✗ Failed to close issue #${issue.number}:`, error.message); 41 + errorCount++; 42 + } 43 + } 44 + 45 + console.log(`\nSummary: ${successCount} issues closed successfully, ${errorCount} errors`); 46 + } 47 + 48 + module.exports = { closeIndividualIssues };
+55
.github/scripts/collect-asyncdaily-issues.js
··· 1 + /** 2 + * Collects async daily issues for a given date and returns the data 3 + * 4 + * @param {object} github - GitHub API client 5 + * @param {object} context - GitHub Actions context 6 + * @param {string} reportDate - Date string in YYYY-MM-DD format (optional) 7 + * @param {string} label - Label to filter issues (default: 'async-daily') 8 + * @returns {Promise<object>} Object containing asyncDailyIssues array and date information 9 + */ 10 + async function collectAsyncDailyIssues(github, context, reportDate, label = 'async-daily') { 11 + // Determine the date for the report 12 + let date; 13 + if (reportDate) { 14 + date = new Date(reportDate); 15 + } else { 16 + date = new Date(); 17 + } 18 + 19 + // Format date as YYYY-MM-DD 20 + const dateStr = date.toISOString().split('T')[0]; 21 + 22 + // Format date as YYYY/MM/DD for issue title matching 23 + const [year, month, day] = dateStr.split('-'); 24 + const titleDateStr = `${year}/${month}/${day}`; 25 + 26 + console.log(`Collecting async daily issues for: ${dateStr} (${titleDateStr})`); 27 + console.log(`Using label: ${label}`); 28 + 29 + // Get all issues with the specified label 30 + const issues = await github.rest.issues.listForRepo({ 31 + owner: context.repo.owner, 32 + repo: context.repo.repo, 33 + labels: label, 34 + state: 'all', 35 + sort: 'created', 36 + direction: 'desc', 37 + per_page: 100 38 + }); 39 + 40 + // Filter issues by title pattern only (allows creating issues in advance) 41 + const asyncDailyIssues = issues.data.filter(issue => { 42 + const titleMatch = issue.title.includes(titleDateStr); 43 + return titleMatch; 44 + }); 45 + 46 + console.log(`Found ${asyncDailyIssues.length} async daily issues`); 47 + 48 + return { 49 + asyncDailyIssues, 50 + dateStr, 51 + titleDateStr 52 + }; 53 + } 54 + 55 + module.exports = { collectAsyncDailyIssues };
+27
.github/scripts/create-report-issue.js
··· 1 + /** 2 + * Create a GitHub issue with the daily report 3 + * 4 + * @param {object} github - GitHub API client 5 + * @param {object} context - GitHub Actions context 6 + * @param {string} titleDateStr - Date string in YYYY/MM/DD format 7 + * @param {string} markdownBody - Report content in markdown format 8 + * @param {string} reportLabel - Label for report issues (default: 'async-daily/report') 9 + * @returns {Promise<object>} Created issue data 10 + */ 11 + async function createReportIssue(github, context, titleDateStr, markdownBody, reportLabel = 'async-daily/report') { 12 + console.log('Creating GitHub issue with the report...'); 13 + 14 + const reportIssue = await github.rest.issues.create({ 15 + owner: context.repo.owner, 16 + repo: context.repo.repo, 17 + title: `[Daily Report] ${titleDateStr}`, 18 + body: markdownBody, 19 + labels: [reportLabel] 20 + }); 21 + 22 + console.log(`Report issue created: #${reportIssue.data.number} - ${reportIssue.data.html_url}`); 23 + 24 + return reportIssue.data; 25 + } 26 + 27 + module.exports = { createReportIssue };
+44
.github/scripts/enrich-user-info.js
··· 1 + /** 2 + * Enrich issues with user display names from GitHub API 3 + * 4 + * @param {object} github - GitHub API client 5 + * @param {Array} issues - Array of GitHub issues 6 + * @returns {Promise<Array>} Array of issues with enriched user information 7 + */ 8 + async function enrichUserInfo(github, issues) { 9 + const enrichedIssues = []; 10 + 11 + for (const issue of issues) { 12 + try { 13 + // Get user details from GitHub API 14 + const { data: user } = await github.rest.users.getByUsername({ 15 + username: issue.user.login 16 + }); 17 + 18 + // Add display name to the issue 19 + enrichedIssues.push({ 20 + ...issue, 21 + user: { 22 + ...issue.user, 23 + displayName: user.name || issue.user.login, 24 + avatarUrl: user.avatar_url 25 + } 26 + }); 27 + } catch (error) { 28 + console.warn(`Failed to fetch user info for ${issue.user.login}:`, error.message); 29 + // Fallback: use login as display name 30 + enrichedIssues.push({ 31 + ...issue, 32 + user: { 33 + ...issue.user, 34 + displayName: issue.user.login, 35 + avatarUrl: issue.user.avatar_url 36 + } 37 + }); 38 + } 39 + } 40 + 41 + return enrichedIssues; 42 + } 43 + 44 + module.exports = { enrichUserInfo };
+143
.github/scripts/generate-reports.js
··· 1 + const fs = require('fs'); 2 + const path = require('path'); 3 + const { parseIssueBody } = require('./parse-issue'); 4 + 5 + /** 6 + * Convert basic markdown to HTML 7 + * 8 + * @param {string} text - Markdown text 9 + * @returns {string} HTML text 10 + */ 11 + function markdownToHtml(text) { 12 + if (!text) return text; 13 + 14 + // Convert lists with nested support 15 + const lines = text.split('\n'); 16 + let html = ''; 17 + let listStack = []; 18 + 19 + for (let i = 0; i < lines.length; i++) { 20 + const line = lines[i]; 21 + const trimmedLine = line.trim(); 22 + 23 + const listMatch = line.match(/^(\s*)[-*]\s+(.+)$/); 24 + 25 + if (listMatch) { 26 + const indent = listMatch[1].length; 27 + const listContent = listMatch[2]; 28 + const level = Math.floor(indent / 2); 29 + 30 + while (listStack.length > level + 1) { 31 + html += '</ul>\n'; 32 + listStack.pop(); 33 + } 34 + 35 + if (listStack.length === level) { 36 + html += '<ul>\n'; 37 + listStack.push(level); 38 + } 39 + 40 + html += `<li>${escapeHtml(listContent)}</li>\n`; 41 + } else { 42 + while (listStack.length > 0) { 43 + html += '</ul>\n'; 44 + listStack.pop(); 45 + } 46 + 47 + if (trimmedLine) { 48 + html += escapeHtml(line) + '\n'; 49 + } else { 50 + html += '\n'; 51 + } 52 + } 53 + } 54 + 55 + while (listStack.length > 0) { 56 + html += '</ul>\n'; 57 + listStack.pop(); 58 + } 59 + 60 + return html; 61 + } 62 + 63 + function escapeHtml(text) { 64 + return text 65 + .replace(/&/g, '&amp;') 66 + .replace(/</g, '&lt;') 67 + .replace(/>/g, '&gt;') 68 + .replace(/"/g, '&quot;') 69 + .replace(/'/g, '&#039;'); 70 + } 71 + 72 + function generateReports(dailyIssues, titleDateStr, context, reportIssueUrl = null) { 73 + const parkingLotItems = []; 74 + const markdownBody = generateMarkdownReport(dailyIssues, titleDateStr, context, parkingLotItems); 75 + 76 + return { 77 + markdownBody, 78 + parkingLotItems 79 + }; 80 + } 81 + 82 + function generateMarkdownReport(dailyIssues, titleDateStr, context, parkingLotItems) { 83 + let markdownBody = `# 📅 Async Daily Summary - ${titleDateStr}\n\n`; 84 + markdownBody += `**Team Updates:** ${dailyIssues.length} member(s) reported today\n\n`; 85 + markdownBody += `---\n\n`; 86 + 87 + for (const issue of dailyIssues) { 88 + const author = issue.user.login; 89 + const displayName = issue.user.displayName || author; 90 + const avatarUrl = issue.user.avatarUrl || issue.user.avatar_url; 91 + const issueNumber = issue.number; 92 + const issueUrl = issue.html_url; 93 + const sections = parseIssueBody(issue.body); 94 + 95 + markdownBody += `## <img src="${avatarUrl}" width="24" height="24" style="border-radius: 50%; vertical-align: middle;"> ${displayName} (@${author}) ${sections.parkingLot ? '🚨 **PARKING LOT**' : ''} | #${issueNumber}\n\n`; 96 + 97 + markdownBody += `### ✅ What did you do yesterday?\n\n`; 98 + markdownBody += sections.yesterday ? sections.yesterday + '\n\n' : '_No information provided_\n\n'; 99 + 100 + markdownBody += `### 🎯 What will you do today?\n\n`; 101 + markdownBody += sections.today ? sections.today + '\n\n' : '_No information provided_\n\n'; 102 + 103 + if (sections.blockers) { 104 + markdownBody += `### 🚧 Any blockers?\n\n`; 105 + markdownBody += sections.blockers + '\n\n'; 106 + } 107 + 108 + if (sections.parkingLotDetails) { 109 + markdownBody += `### 📝 Parking Lot Details\n\n`; 110 + markdownBody += sections.parkingLotDetails + '\n\n'; 111 + } 112 + 113 + if (sections.additionalComments) { 114 + markdownBody += `### 💬 Additional Comments\n\n`; 115 + markdownBody += sections.additionalComments + '\n\n'; 116 + } 117 + 118 + markdownBody += `---\n\n`; 119 + 120 + if (sections.parkingLot) { 121 + parkingLotItems.push({ author, displayName, avatarUrl, issueUrl, issueNumber }); 122 + } 123 + } 124 + 125 + if (parkingLotItems.length > 0) { 126 + markdownBody += `## 🚨 Parking Lot Items (${parkingLotItems.length})\n\n`; 127 + markdownBody += `The following team members have requested a parking lot discussion or escalation:\n\n`; 128 + 129 + for (const item of parkingLotItems) { 130 + markdownBody += `- <img src="${item.avatarUrl}" width="20" height="20" style="border-radius: 50%; vertical-align: middle;"> **${item.displayName} (@${item.author})** - [Issue #${item.issueNumber}](${item.issueUrl})\n`; 131 + } 132 + 133 + markdownBody += `\n`; 134 + } 135 + 136 + markdownBody += `---\n\n`; 137 + markdownBody += `_This is an automated async daily report generated from GitHub issues._\n`; 138 + markdownBody += `_Repository: ${context.repo.owner}/${context.repo.repo}_\n`; 139 + 140 + return markdownBody; 141 + } 142 + 143 + module.exports = { generateReports };
+54
.github/scripts/parse-issue.js
··· 1 + /** 2 + * Parse issue body to extract async daily information 3 + * 4 + * @param {string} body - The issue body text 5 + * @returns {object} Object containing yesterday, today, blockers, parkingLotDetails, additionalComments sections and parkingLot flag 6 + */ 7 + function parseIssueBody(body) { 8 + const sections = { 9 + yesterday: '', 10 + today: '', 11 + blockers: '', 12 + parkingLot: false, 13 + parkingLotDetails: '', 14 + additionalComments: '' 15 + }; 16 + 17 + if (!body) return sections; 18 + 19 + // Helper function to clean empty responses 20 + const cleanEmptyResponse = (text) => { 21 + if (!text) return ''; 22 + const trimmed = text.trim(); 23 + if (trimmed === '_No response_' || trimmed.toLowerCase() === 'none' || trimmed === '_None._') { 24 + return ''; 25 + } 26 + return trimmed; 27 + }; 28 + 29 + // Handle both GitHub form format (###) and rendered markdown (##) 30 + const yesterdayMatch = body.match(/### ✅ What did you do yesterday\?\s*([\s\S]*?)(?=###|##|$)/) || 31 + body.match(/## ✅ What did you do yesterday\?\s*([\s\S]*?)(?=##|$)/); 32 + const todayMatch = body.match(/### 🎯 What will you do today\?\s*([\s\S]*?)(?=###|##|$)/) || 33 + body.match(/## 🎯 What will you do today\?\s*([\s\S]*?)(?=##|$)/); 34 + const blockersMatch = body.match(/### 🚧 Any blockers\?\s*([\s\S]*?)(?=###|##|$)/) || 35 + body.match(/## 🚧 Any blockers\?\s*([\s\S]*?)(?=##|$)/); 36 + const parkingLotMatch = body.match(/- \[x\].*Parking Lot/i) || 37 + body.match(/- ✅ Yes, I need a Parking Lot/i); 38 + const parkingLotDetailsMatch = body.match(/### 📝 Parking Lot Details\s*([\s\S]*?)(?=###|##|$)/) || 39 + body.match(/## 📝 Parking Lot Details\s*([\s\S]*?)(?=##|$)/); 40 + const additionalCommentsMatch = body.match(/### 💬 Additional Comments\s*([\s\S]*?)(?=###|##|$)/) || 41 + body.match(/## 💬 Additional Comments\s*([\s\S]*?)(?=##|$)/); 42 + 43 + if (yesterdayMatch) sections.yesterday = yesterdayMatch[1].trim(); 44 + if (todayMatch) sections.today = todayMatch[1].trim(); 45 + if (blockersMatch) sections.blockers = cleanEmptyResponse(blockersMatch[1]); 46 + if (parkingLotDetailsMatch) sections.parkingLotDetails = cleanEmptyResponse(parkingLotDetailsMatch[1]); 47 + if (additionalCommentsMatch) sections.additionalComments = cleanEmptyResponse(additionalCommentsMatch[1]); 48 + 49 + sections.parkingLot = !!parkingLotMatch; 50 + 51 + return sections; 52 + } 53 + 54 + module.exports = { parseIssueBody };
+111
.github/workflows/asyncdaily-reporter.yml
··· 1 + name: Async Daily Reporter 2 + 3 + on: 4 + # Run every weekday at 10:00 AM UTC (adjust timezone as needed) 5 + schedule: 6 + - cron: '45 10 * * 1-5' 7 + 8 + # Allow manual execution with date parameter 9 + workflow_dispatch: 10 + inputs: 11 + report_date: 12 + description: 'Date for the report (YYYY-MM-DD). Leave empty for today.' 13 + required: false 14 + type: string 15 + 16 + jobs: 17 + generate-asyncdaily-report: 18 + runs-on: ubuntu-24.04 19 + steps: 20 + - name: Checkout repository 21 + uses: actions/checkout@v4 22 + 23 + - name: Collect async daily issues and send report 24 + id: generate_report 25 + uses: actions/github-script@v7 26 + with: 27 + github-token: ${{ secrets.GITHUB_TOKEN }} 28 + script: | 29 + const { collectAsyncDailyIssues } = require('./.github/scripts/collect-asyncdaily-issues.js'); 30 + const { enrichUserInfo } = require('./.github/scripts/enrich-user-info.js'); 31 + const { generateReports } = require('./.github/scripts/generate-reports.js'); 32 + const { createReportIssue } = require('./.github/scripts/create-report-issue.js'); 33 + const { closeIndividualIssues } = require('./.github/scripts/close-individual-issues.js'); 34 + 35 + // Collect async daily issues 36 + const reportDate = context.payload.inputs?.report_date; 37 + const { asyncDailyIssues, dateStr, titleDateStr } = await collectAsyncDailyIssues(github, context, reportDate, '${{ vars.ASYNC_DAILY_LABEL || ''async-daily'' }}'); 38 + 39 + if (asyncDailyIssues.length === 0) { 40 + console.log('No async daily issues found for this date. Skipping report.'); 41 + core.setOutput('has_issues', 'false'); 42 + return; 43 + } 44 + 45 + core.setOutput('has_issues', 'true'); 46 + 47 + // Enrich issues with user display names 48 + let enrichedIssues = await enrichUserInfo(github, asyncDailyIssues); 49 + 50 + // Sort issues alphabetically by user handle to ensure predictable order 51 + enrichedIssues = enrichedIssues.sort((a, b) => { 52 + return a.user.login.localeCompare(b.user.login); 53 + }); 54 + 55 + // Create report issue first to get its URL 56 + const reportIssue = await createReportIssue(github, context, titleDateStr, 'Generating report...', '${{ vars.ASYNC_DAILY_REPORT_LABEL || ''async-daily/report'' }}'); 57 + 58 + // Generate reports with the report issue URL 59 + const { markdownBody, parkingLotItems } = generateReports(enrichedIssues, titleDateStr, context, reportIssue.html_url); 60 + 61 + // Update the report issue with the actual markdown content 62 + await github.rest.issues.update({ 63 + owner: context.repo.owner, 64 + repo: context.repo.repo, 65 + issue_number: reportIssue.number, 66 + body: markdownBody 67 + }); 68 + 69 + console.log('Report issue updated with final content'); 70 + 71 + // Close individual issues after the report is generated 72 + await closeIndividualIssues(github, context, enrichedIssues, reportIssue.html_url); 73 + 74 + core.setOutput('report_issue_number', reportIssue.number); 75 + core.setOutput('report_issue_url', reportIssue.html_url); 76 + 77 + // Generate summary content 78 + let summaryContent = `👉 [**Full Daily Report**](${reportIssue.html_url}) 👈\n\n`; 79 + 80 + if (parkingLotItems.length > 0) { 81 + summaryContent += `🚨 **Parking lot requests:** ${parkingLotItems.length}\n\n`; 82 + } 83 + 84 + summaryContent += `---\n\n`; 85 + summaryContent += `## Team Members\n\n`; 86 + 87 + for (const issue of enrichedIssues) { 88 + const displayName = issue.user.displayName || issue.user.login; 89 + summaryContent += `- ${displayName} (@${issue.user.login}) - [#${issue.number}](${issue.html_url})\n`; 90 + } 91 + 92 + // Write summary to file 93 + const fs = require('fs'); 94 + const summaryPath = `${process.env.GITHUB_WORKSPACE}/asyncdaily-summary.md`; 95 + fs.writeFileSync(summaryPath, summaryContent); 96 + console.log(`Summary written to: ${summaryPath}`); 97 + 98 + - name: Publish summary 99 + if: steps.generate_report.outputs.has_issues == 'true' 100 + run: | 101 + cat asyncdaily-summary.md >> "$GITHUB_STEP_SUMMARY" 102 + 103 + - name: Set report today date 104 + if: steps.generate_report.outputs.has_issues == 'true' && github.event.inputs.report_date == '' 105 + id: set_date 106 + run: | 107 + if [ -z "${{ github.event.inputs.report_date }}" ]; then 108 + echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT 109 + else 110 + echo "date=${{ github.event.inputs.report_date }}" >> $GITHUB_OUTPUT 111 + fi
+61
.github/workflows/asyncdaily-updater.yml
··· 1 + name: Async Daily Template Updater 2 + 3 + on: 4 + # Run every day at 12:00 PM UTC 5 + schedule: 6 + - cron: '0 12 * * *' 7 + 8 + # Allow manual execution for testing 9 + workflow_dispatch: 10 + 11 + permissions: 12 + contents: write 13 + 14 + jobs: 15 + update-template-date: 16 + runs-on: ubuntu-24.04 17 + steps: 18 + - name: Checkout repository 19 + uses: actions/checkout@v4 20 + 21 + - name: Update template date 22 + run: | 23 + # Get tomorrow's date in YYYY/MM/DD format 24 + TOMORROW=$(date -d '+1 day' +"%Y/%m/%d") 25 + echo "TOMORROW=$TOMORROW" >> $GITHUB_ENV 26 + 27 + echo "Updating template date to: $TOMORROW" 28 + 29 + # Path to the template file 30 + TEMPLATE_FILE=".github/ISSUE_TEMPLATE/async-daily.yml" 31 + 32 + # Check if template exists 33 + if [ ! -f "$TEMPLATE_FILE" ]; then 34 + echo "Template file not found: $TEMPLATE_FILE" 35 + exit 0 36 + fi 37 + 38 + # Update the title line with tomorrow's date 39 + # Using sed to replace the date in the title line 40 + sed -i "s|title: '\[Async Daily\] \[.*\]'|title: '[Async Daily] [$TOMORROW]'|g" "$TEMPLATE_FILE" 41 + 42 + echo "Template updated successfully" 43 + cat "$TEMPLATE_FILE" | grep "title:" || echo "No title line found" 44 + 45 + - name: Commit and push changes 46 + run: | 47 + # Check if there are changes 48 + if git diff --quiet; then 49 + echo "No changes to commit" 50 + exit 0 51 + fi 52 + 53 + git config user.name "GitHub Action" 54 + git config user.email "actions@github.com" 55 + 56 + # Stage, commit and push 57 + git add .github/ISSUE_TEMPLATE/async-daily.yml 58 + git commit -m "chore: update async daily template date to $TOMORROW" 59 + git push origin ${{ github.ref_name }} 60 + 61 + echo "Changes pushed successfully"
+60
.github/workflows/release.yml
··· 1 + name: Release 2 + 3 + on: 4 + push: 5 + tags: 6 + - 'v*' 7 + workflow_dispatch: 8 + 9 + permissions: 10 + contents: write 11 + 12 + jobs: 13 + goreleaser: 14 + runs-on: ubuntu-24.04 15 + steps: 16 + - name: Checkout 17 + uses: actions/checkout@v6 18 + with: 19 + fetch-depth: 0 20 + 21 + - name: Check if tag is on main branch 22 + id: check_branch 23 + run: | 24 + git fetch origin main 25 + if git branch -r --contains ${{ github.ref }} | grep -q 'origin/main'; then 26 + echo "on_main=true" >> "$GITHUB_OUTPUT" 27 + echo "Tag is on main branch - will create release" 28 + else 29 + echo "on_main=false" >> "$GITHUB_OUTPUT" 30 + echo "Tag is NOT on main branch - will create snapshot only" 31 + fi 32 + 33 + - name: Set up Go 34 + uses: actions/setup-go@v6 35 + with: 36 + go-version: '1.25.4' 37 + 38 + - name: Run GoReleaser (Release) 39 + if: steps.check_branch.outputs.on_main == 'true' 40 + uses: goreleaser/goreleaser-action@v7 41 + with: 42 + distribution: goreleaser 43 + version: latest 44 + args: release --clean 45 + env: 46 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 47 + 48 + - name: Build snapshot (macOS ARM only) 49 + if: steps.check_branch.outputs.on_main == 'false' 50 + run: | 51 + mkdir -p dist 52 + GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}-snapshot" -o dist/pad . 53 + 54 + - name: Upload snapshot artifacts 55 + if: steps.check_branch.outputs.on_main == 'false' 56 + uses: actions/upload-artifact@v6 57 + with: 58 + name: snapshot-binaries 59 + path: dist/* 60 + retention-days: 7
+4
.gitignore
··· 1 + dist/ 2 + coverage.out 3 + .DS_Store 4 + pad
+45
.goreleaser.yaml
··· 1 + version: 2 2 + 3 + project_name: pad 4 + 5 + before: 6 + hooks: 7 + - go test ./... 8 + 9 + builds: 10 + - id: pad 11 + main: . 12 + binary: pad 13 + env: 14 + - CGO_ENABLED=0 15 + ldflags: 16 + - -s -w -X main.version={{.Version}} 17 + goos: 18 + - darwin 19 + - linux 20 + - windows 21 + goarch: 22 + - amd64 23 + - arm64 24 + 25 + archives: 26 + - id: pad 27 + builds: 28 + - pad 29 + formats: 30 + - tar.gz 31 + format_overrides: 32 + - goos: windows 33 + formats: 34 + - zip 35 + 36 + checksum: 37 + name_template: checksums.txt 38 + 39 + changelog: 40 + sort: asc 41 + filters: 42 + exclude: 43 + - '^docs:' 44 + - '^test:' 45 + - '^chore:'
+31
AGENTS.md
··· 1 + This repo contains `pad`, a Go CLI/TUI that helps teams draft, repeat, review, and publish async daily standup updates as GitHub issues with less manual copy/paste. 2 + 3 + ## Stack 4 + 5 + - Go 1.25.x 6 + - CLI: `github.com/spf13/cobra` 7 + - Simple terminal UI: `github.com/charmbracelet/bubbletea` 8 + - GitHub integration for the first iterations: `gh` CLI, so the app can reuse the user's existing GitHub auth 9 + - Local storage: config only in the user's config directory; async daily history is read from GitHub 10 + - Database: none for now; only introduce SQLite if plain files become a real limitation 11 + 12 + ## Release Versioning 13 + 14 + - Use semver tags in the form `vMAJOR.MINOR.PATCH`. 15 + - Derive the next version from conventional commits since the previous tag. 16 + - Bump `MAJOR` when a commit has `BREAKING CHANGE` or uses the `type!:` form. 17 + - Bump `MINOR` when at least one commit is a `feat:` and there is no major bump. 18 + - Bump `PATCH` for `fix:`, `refactor:`, `perf:`, `docs:`, `test:`, `build:`, or `chore:` changes when there is no major or minor bump. 19 + - For the first public release, default to `v0.1.0` unless the repo history clearly justifies something else. 20 + 21 + ## Scope Of This Iteration 22 + 23 + This first iteration does not yet auto-suggest URLs or fetch each individual worker issue directly as a grouped team view. It can already show the repository's merged daily report issue generated by the existing workflow. 24 + 25 + ## Things To Keep In Mind 26 + 27 + - Add short dated notes here whenever a workflow trap, bug, auth issue, release caveat, or repository-specific decision is worth remembering. 28 + - 2026-04-16: Initial GitHub issue creation goes through `gh` instead of direct API calls so setup stays simple and users can rely on existing GitHub authentication. 29 + - 2026-04-16: Go's `os.UserConfigDir()` does not honor `XDG_CONFIG_HOME` on macOS. Keep `pad` on explicit env-aware path helpers so tests and local overrides can isolate config/data cleanly. 30 + - 2026-04-16: `gh` authentication depends on its normal config home. If tests or wrappers override `XDG_CONFIG_HOME`, remote commands like `pad list` and remote `pad show` will not see existing `gh auth login` state unless that config is also made available. 31 + - 2026-04-16: `pad repeat` now pre-fills from the latest GitHub async-daily issue by the authenticated user instead of reading local JSON entries.
+674
LICENSE
··· 1 + GNU GENERAL PUBLIC LICENSE 2 + Version 3, 29 June 2007 3 + 4 + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> 5 + Everyone is permitted to copy and distribute verbatim copies 6 + of this license document, but changing it is not allowed. 7 + 8 + Preamble 9 + 10 + The GNU General Public License is a free, copyleft license for 11 + software and other kinds of works. 12 + 13 + The licenses for most software and other practical works are designed 14 + to take away your freedom to share and change the works. By contrast, 15 + the GNU General Public License is intended to guarantee your freedom to 16 + share and change all versions of a program--to make sure it remains free 17 + software for all its users. We, the Free Software Foundation, use the GNU 18 + General Public License for most of our software; it applies also to any 19 + other work released this way by its authors. You can apply it to your 20 + programs, too. 21 + 22 + When we speak of free software, we are referring to freedom, not 23 + price. Our General Public Licenses are designed to make sure that you 24 + have the freedom to distribute copies of free software (and charge for 25 + them if you wish), that you receive source code or can get it if you 26 + want it, that you can change the software or use pieces of it in new 27 + free programs, and that you know you can do these things. 28 + 29 + To protect your rights, we need to prevent others from denying you 30 + these rights or asking you to surrender the rights. Therefore, you have 31 + certain responsibilities if you distribute copies of the software, or if 32 + you modify it: responsibilities to respect the freedom of others. 33 + 34 + For example, if you distribute copies of such a program, whether 35 + gratis or for a fee, you must pass on to the recipients the same 36 + freedoms that you received. You must make sure that they, too, receive 37 + or can get the source code. And you must show them these terms so they 38 + know their rights. 39 + 40 + Developers that use the GNU GPL protect your rights with two steps: 41 + (1) assert copyright on the software, and (2) offer you this License 42 + giving you legal permission to copy, distribute and/or modify it. 43 + 44 + For the developers' and authors' protection, the GPL clearly explains 45 + that there is no warranty for this free software. For both users' and 46 + authors' sake, the GPL requires that modified versions be marked as 47 + changed, so that their problems will not be attributed erroneously to 48 + authors of previous versions. 49 + 50 + Some devices are designed to deny users access to install or run 51 + modified versions of the software inside them, although the manufacturer 52 + can do so. This is fundamentally incompatible with the aim of 53 + protecting users' freedom to change the software. The systematic 54 + pattern of such abuse occurs in the area of products for individuals to 55 + use, which is precisely where it is most unacceptable. Therefore, we 56 + have designed this version of the GPL to prohibit the practice for those 57 + products. If such problems arise substantially in other domains, we 58 + stand ready to extend this provision to those domains in future versions 59 + of the GPL, as needed to protect the freedom of users. 60 + 61 + Finally, every program is threatened constantly by software patents. 62 + States should not allow patents to restrict development and use of 63 + software on general-purpose computers, but in those that do, we wish to 64 + avoid the special danger that patents applied to a free program could 65 + make it effectively proprietary. To prevent this, the GPL assures that 66 + patents cannot be used to render the program non-free. 67 + 68 + The precise terms and conditions for copying, distribution and 69 + modification follow. 70 + 71 + TERMS AND CONDITIONS 72 + 73 + 0. Definitions. 74 + 75 + "This License" refers to version 3 of the GNU General Public License. 76 + 77 + "Copyright" also means copyright-like laws that apply to other kinds of 78 + works, such as semiconductor masks. 79 + 80 + "The Program" refers to any copyrightable work licensed under this 81 + License. Each licensee is addressed as "you". "Licensees" and 82 + "recipients" may be individuals or organizations. 83 + 84 + To "modify" a work means to copy from or adapt all or part of the work 85 + in a fashion requiring copyright permission, other than the making of an 86 + exact copy. The resulting work is called a "modified version" of the 87 + earlier work or a work "based on" the earlier work. 88 + 89 + A "covered work" means either the unmodified Program or a work based 90 + on the Program. 91 + 92 + To "propagate" a work means to do anything with it that, without 93 + permission, would make you directly or secondarily liable for 94 + infringement under applicable copyright law, except executing it on a 95 + computer or modifying a private copy. Propagation includes copying, 96 + distribution (with or without modification), making available to the 97 + public, and in some countries other activities as well. 98 + 99 + To "convey" a work means any kind of propagation that enables other 100 + parties to make or receive copies. Mere interaction with a user through 101 + a computer network, with no transfer of a copy, is not conveying. 102 + 103 + An interactive user interface displays "Appropriate Legal Notices" 104 + to the extent that it includes a convenient and prominently visible 105 + feature that (1) displays an appropriate copyright notice, and (2) 106 + tells the user that there is no warranty for the work (except to the 107 + extent that warranties are provided), that licensees may convey the 108 + work under this License, and how to view a copy of this License. If 109 + the interface presents a list of user commands or options, such as a 110 + menu, a prominent item in the list meets this criterion. 111 + 112 + 1. Source Code. 113 + 114 + The "source code" for a work means the preferred form of the work 115 + for making modifications to it. "Object code" means any non-source 116 + form of a work. 117 + 118 + A "Standard Interface" means an interface that either is an official 119 + standard defined by a recognized standards body, or, in the case of 120 + interfaces specified for a particular programming language, one that 121 + is widely used among developers working in that language. 122 + 123 + The "System Libraries" of an executable work include anything, other 124 + than the work as a whole, that (a) is included in the normal form of 125 + packaging a Major Component, but which is not part of that Major 126 + Component, and (b) serves only to enable use of the work with that 127 + Major Component, or to implement a Standard Interface for which an 128 + implementation is available to the public in source code form. A 129 + "Major Component", in this context, means a major essential component 130 + (kernel, window system, and so on) of the specific operating system 131 + (if any) on which the executable work runs, or a compiler used to 132 + produce the work, or an object code interpreter used to run it. 133 + 134 + The "Corresponding Source" for a work in object code form means all 135 + the source code needed to generate, install, and (for an executable 136 + work) run the object code and to modify the work, including scripts to 137 + control those activities. However, it does not include the work's 138 + System Libraries, or general-purpose tools or generally available free 139 + programs which are used unmodified in performing those activities but 140 + which are not part of the work. For example, Corresponding Source 141 + includes interface definition files associated with source files for 142 + the work, and the source code for shared libraries and dynamically 143 + linked subprograms that the work is specifically designed to require, 144 + such as by intimate data communication or control flow between those 145 + subprograms and other parts of the work. 146 + 147 + The Corresponding Source need not include anything that users 148 + can regenerate automatically from other parts of the Corresponding 149 + Source. 150 + 151 + The Corresponding Source for a work in source code form is that 152 + same work. 153 + 154 + 2. Basic Permissions. 155 + 156 + All rights granted under this License are granted for the term of 157 + copyright on the Program, and are irrevocable provided the stated 158 + conditions are met. This License explicitly affirms your unlimited 159 + permission to run the unmodified Program. The output from running a 160 + covered work is covered by this License only if the output, given its 161 + content, constitutes a covered work. This License acknowledges your 162 + rights of fair use or other equivalent, as provided by copyright law. 163 + 164 + You may make, run and propagate covered works that you do not 165 + convey, without conditions so long as your license otherwise remains 166 + in force. You may convey covered works to others for the sole purpose 167 + of having them make modifications exclusively for you, or provide you 168 + with facilities for running those works, provided that you comply with 169 + the terms of this License in conveying all material for which you do 170 + not control copyright. Those thus making or running the covered works 171 + for you must do so exclusively on your behalf, under your direction 172 + and control, on terms that prohibit them from making any copies of 173 + your copyrighted material outside their relationship with you. 174 + 175 + Conveying under any other circumstances is permitted solely under 176 + the conditions stated below. Sublicensing is not allowed; section 10 177 + makes it unnecessary. 178 + 179 + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 + 181 + No covered work shall be deemed part of an effective technological 182 + measure under any applicable law fulfilling obligations under article 183 + 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 + similar laws prohibiting or restricting circumvention of such 185 + measures. 186 + 187 + When you convey a covered work, you waive any legal power to forbid 188 + circumvention of technological measures to the extent such circumvention 189 + is effected by exercising rights under this License with respect to 190 + the covered work, and you disclaim any intention to limit operation or 191 + modification of the work as a means of enforcing, against the work's 192 + users, your or third parties' legal rights to forbid circumvention of 193 + technological measures. 194 + 195 + 4. Conveying Verbatim Copies. 196 + 197 + You may convey verbatim copies of the Program's source code as you 198 + receive it, in any medium, provided that you conspicuously and 199 + appropriately publish on each copy an appropriate copyright notice; 200 + keep intact all notices stating that this License and any 201 + non-permissive terms added in accord with section 7 apply to the code; 202 + keep intact all notices of the absence of any warranty; and give all 203 + recipients a copy of this License along with the Program. 204 + 205 + You may charge any price or no price for each copy that you convey, 206 + and you may offer support or warranty protection for a fee. 207 + 208 + 5. Conveying Modified Source Versions. 209 + 210 + You may convey a work based on the Program, or the modifications to 211 + produce it from the Program, in the form of source code under the 212 + terms of section 4, provided that you also meet all of these conditions: 213 + 214 + a) The work must carry prominent notices stating that you modified 215 + it, and giving a relevant date. 216 + 217 + b) The work must carry prominent notices stating that it is 218 + released under this License and any conditions added under section 219 + 7. This requirement modifies the requirement in section 4 to 220 + "keep intact all notices". 221 + 222 + c) You must license the entire work, as a whole, under this 223 + License to anyone who comes into possession of a copy. This 224 + License will therefore apply, along with any applicable section 7 225 + additional terms, to the whole of the work, and all its parts, 226 + regardless of how they are packaged. This License gives no 227 + permission to license the work in any other way, but it does not 228 + invalidate such permission if you have separately received it. 229 + 230 + d) If the work has interactive user interfaces, each must display 231 + Appropriate Legal Notices; however, if the Program has interactive 232 + interfaces that do not display Appropriate Legal Notices, your 233 + work need not make them do so. 234 + 235 + A compilation of a covered work with other separate and independent 236 + works, which are not by their nature extensions of the covered work, 237 + and which are not combined with it such as to form a larger program, 238 + in or on a volume of a storage or distribution medium, is called an 239 + "aggregate" if the compilation and its resulting copyright are not 240 + used to limit the access or legal rights of the compilation's users 241 + beyond what the individual works permit. Inclusion of a covered work 242 + in an aggregate does not cause this License to apply to the other 243 + parts of the aggregate. 244 + 245 + 6. Conveying Non-Source Forms. 246 + 247 + You may convey a covered work in object code form under the terms 248 + of sections 4 and 5, provided that you also convey the 249 + machine-readable Corresponding Source under the terms of this License, 250 + in one of these ways: 251 + 252 + a) Convey the object code in, or embodied in, a physical product 253 + (including a physical distribution medium), accompanied by the 254 + Corresponding Source fixed on a durable physical medium 255 + customarily used for software interchange. 256 + 257 + b) Convey the object code in, or embodied in, a physical product 258 + (including a physical distribution medium), accompanied by a 259 + written offer, valid for at least three years and valid for as 260 + long as you offer spare parts or customer support for that product 261 + model, to give anyone who possesses the object code either (1) a 262 + copy of the Corresponding Source for all the software in the 263 + product that is covered by this License, on a durable physical 264 + medium customarily used for software interchange, for a price no 265 + more than your reasonable cost of physically performing this 266 + conveying of source, or (2) access to copy the 267 + Corresponding Source from a network server at no charge. 268 + 269 + c) Convey individual copies of the object code with a copy of the 270 + written offer to provide the Corresponding Source. This 271 + alternative is allowed only occasionally and noncommercially, and 272 + only if you received the object code with such an offer, in accord 273 + with subsection 6b. 274 + 275 + d) Convey the object code by offering access from a designated 276 + place (gratis or for a charge), and offer equivalent access to the 277 + Corresponding Source in the same way through the same place at no 278 + further charge. You need not require recipients to copy the 279 + Corresponding Source along with the object code. If the place to 280 + copy the object code is a network server, the Corresponding Source 281 + may be on a different server (operated by you or a third party) 282 + that supports equivalent copying facilities, provided you maintain 283 + clear directions next to the object code saying where to find the 284 + Corresponding Source. Regardless of what server hosts the 285 + Corresponding Source, you remain obligated to ensure that it is 286 + available for as long as needed to satisfy these requirements. 287 + 288 + e) Convey the object code using peer-to-peer transmission, provided 289 + you inform other peers where the object code and Corresponding 290 + Source of the work are being offered to the general public at no 291 + charge under subsection 6d. 292 + 293 + A separable portion of the object code, whose source code is excluded 294 + from the Corresponding Source as a System Library, need not be 295 + included in conveying the object code work. 296 + 297 + A "User Product" is either (1) a "consumer product", which means any 298 + tangible personal property which is normally used for personal, family, 299 + or household purposes, or (2) anything designed or sold for incorporation 300 + into a dwelling. In determining whether a product is a consumer product, 301 + doubtful cases shall be resolved in favor of coverage. For a particular 302 + product received by a particular user, "normally used" refers to a 303 + typical or common use of that class of product, regardless of the status 304 + of the particular user or of the way in which the particular user 305 + actually uses, or expects or is expected to use, the product. A product 306 + is a consumer product regardless of whether the product has substantial 307 + commercial, industrial or non-consumer uses, unless such uses represent 308 + the only significant mode of use of the product. 309 + 310 + "Installation Information" for a User Product means any methods, 311 + procedures, authorization keys, or other information required to install 312 + and execute modified versions of a covered work in that User Product from 313 + a modified version of its Corresponding Source. The information must 314 + suffice to ensure that the continued functioning of the modified object 315 + code is in no case prevented or interfered with solely because 316 + modification has been made. 317 + 318 + If you convey an object code work under this section in, or with, or 319 + specifically for use in, a User Product, and the conveying occurs as 320 + part of a transaction in which the right of possession and use of the 321 + User Product is transferred to the recipient in perpetuity or for a 322 + fixed term (regardless of how the transaction is characterized), the 323 + Corresponding Source conveyed under this section must be accompanied 324 + by the Installation Information. But this requirement does not apply 325 + if neither you nor any third party retains the ability to install 326 + modified object code on the User Product (for example, the work has 327 + been installed in ROM). 328 + 329 + The requirement to provide Installation Information does not include a 330 + requirement to continue to provide support service, warranty, or updates 331 + for a work that has been modified or installed by the recipient, or for 332 + the User Product in which it has been modified or installed. Access to a 333 + network may be denied when the modification itself materially and 334 + adversely affects the operation of the network or violates the rules and 335 + protocols for communication across the network. 336 + 337 + Corresponding Source conveyed, and Installation Information provided, 338 + in accord with this section must be in a format that is publicly 339 + documented (and with an implementation available to the public in 340 + source code form), and must require no special password or key for 341 + unpacking, reading or copying. 342 + 343 + 7. Additional Terms. 344 + 345 + "Additional permissions" are terms that supplement the terms of this 346 + License by making exceptions from one or more of its conditions. 347 + Additional permissions that are applicable to the entire Program shall 348 + be treated as though they were included in this License, to the extent 349 + that they are valid under applicable law. If additional permissions 350 + apply only to part of the Program, that part may be used separately 351 + under those permissions, but the entire Program remains governed by 352 + this License without regard to the additional permissions. 353 + 354 + When you convey a copy of a covered work, you may at your option 355 + remove any additional permissions from that copy, or from any part of 356 + it. (Additional permissions may be written to require their own 357 + removal in certain cases when you modify the work.) You may place 358 + additional permissions on material, added by you to a covered work, 359 + for which you have or can give appropriate copyright permission. 360 + 361 + Notwithstanding any other provision of this License, for material you 362 + add to a covered work, you may (if authorized by the copyright holders of 363 + that material) supplement the terms of this License with terms: 364 + 365 + a) Disclaiming warranty or limiting liability differently from the 366 + terms of sections 15 and 16 of this License; or 367 + 368 + b) Requiring preservation of specified reasonable legal notices or 369 + author attributions in that material or in the Appropriate Legal 370 + Notices displayed by works containing it; or 371 + 372 + c) Prohibiting misrepresentation of the origin of that material, or 373 + requiring that modified versions of such material be marked in 374 + reasonable ways as different from the original version; or 375 + 376 + d) Limiting the use for publicity purposes of names of licensors or 377 + authors of the material; or 378 + 379 + e) Declining to grant rights under trademark law for use of some 380 + trade names, trademarks, or service marks; or 381 + 382 + f) Requiring indemnification of licensors and authors of that 383 + material by anyone who conveys the material (or modified versions of 384 + it) with contractual assumptions of liability to the recipient, for 385 + any liability that these contractual assumptions directly impose on 386 + those licensors and authors. 387 + 388 + All other non-permissive additional terms are considered "further 389 + restrictions" within the meaning of section 10. If the Program as you 390 + received it, or any part of it, contains a notice stating that it is 391 + governed by this License along with a term that is a further 392 + restriction, you may remove that term. If a license document contains 393 + a further restriction but permits relicensing or conveying under this 394 + License, you may add to a covered work material governed by the terms 395 + of that license document, provided that the further restriction does 396 + not survive such relicensing or conveying. 397 + 398 + If you add terms to a covered work in accord with this section, you 399 + must place, in the relevant source files, a statement of the 400 + additional terms that apply to those files, or a notice indicating 401 + where to find the applicable terms. 402 + 403 + Additional terms, permissive or non-permissive, may be stated in the 404 + form of a separately written license, or stated as exceptions; 405 + the above requirements apply either way. 406 + 407 + 8. Termination. 408 + 409 + You may not propagate or modify a covered work except as expressly 410 + provided under this License. Any attempt otherwise to propagate or 411 + modify it is void, and will automatically terminate your rights under 412 + this License (including any patent licenses granted under the third 413 + paragraph of section 11). 414 + 415 + However, if you cease all violation of this License, then your 416 + license from a particular copyright holder is reinstated (a) 417 + provisionally, unless and until the copyright holder explicitly and 418 + finally terminates your license, and (b) permanently, if the copyright 419 + holder fails to notify you of the violation by some reasonable means 420 + prior to 60 days after the cessation. 421 + 422 + Moreover, your license from a particular copyright holder is 423 + reinstated permanently if the copyright holder notifies you of the 424 + violation by some reasonable means, this is the first time you have 425 + received notice of violation of this License (for any work) from that 426 + copyright holder, and you cure the violation prior to 30 days after 427 + your receipt of the notice. 428 + 429 + Termination of your rights under this section does not terminate the 430 + licenses of parties who have received copies or rights from you under 431 + this License. If your rights have been terminated and not permanently 432 + reinstated, you do not qualify to receive new licenses for the same 433 + material under section 10. 434 + 435 + 9. Acceptance Not Required for Having Copies. 436 + 437 + You are not required to accept this License in order to receive or 438 + run a copy of the Program. Ancillary propagation of a covered work 439 + occurring solely as a consequence of using peer-to-peer transmission 440 + to receive a copy likewise does not require acceptance. However, 441 + nothing other than this License grants you permission to propagate or 442 + modify any covered work. These actions infringe copyright if you do 443 + not accept this License. Therefore, by modifying or propagating a 444 + covered work, you indicate your acceptance of this License to do so. 445 + 446 + 10. Automatic Licensing of Downstream Recipients. 447 + 448 + Each time you convey a covered work, the recipient automatically 449 + receives a license from the original licensors, to run, modify and 450 + propagate that work, subject to this License. You are not responsible 451 + for enforcing compliance by third parties with this License. 452 + 453 + An "entity transaction" is a transaction transferring control of an 454 + organization, or substantially all assets of one, or subdividing an 455 + organization, or merging organizations. If propagation of a covered 456 + work results from an entity transaction, each party to that 457 + transaction who receives a copy of the work also receives whatever 458 + licenses to the work the party's predecessor in interest had or could 459 + give under the previous paragraph, plus a right to possession of the 460 + Corresponding Source of the work from the predecessor in interest, if 461 + the predecessor has it or can get it with reasonable efforts. 462 + 463 + You may not impose any further restrictions on the exercise of the 464 + rights granted or affirmed under this License. For example, you may 465 + not impose a license fee, royalty, or other charge for exercise of 466 + rights granted under this License, and you may not initiate litigation 467 + (including a cross-claim or counterclaim in a lawsuit) alleging that 468 + any patent claim is infringed by making, using, selling, offering for 469 + sale, or importing the Program or any portion of it. 470 + 471 + 11. Patents. 472 + 473 + A "contributor" is a copyright holder who authorizes use under this 474 + License of the Program or a work on which the Program is based. The 475 + work thus licensed is called the contributor's "contributor version". 476 + 477 + A contributor's "essential patent claims" are all patent claims 478 + owned or controlled by the contributor, whether already acquired or 479 + hereafter acquired, that would be infringed by some manner, permitted 480 + by this License, of making, using, or selling its contributor version, 481 + but do not include claims that would be infringed only as a 482 + consequence of further modification of the contributor version. For 483 + purposes of this definition, "control" includes the right to grant 484 + patent sublicenses in a manner consistent with the requirements of 485 + this License. 486 + 487 + Each contributor grants you a non-exclusive, worldwide, royalty-free 488 + patent license under the contributor's essential patent claims, to 489 + make, use, sell, offer for sale, import and otherwise run, modify and 490 + propagate the contents of its contributor version. 491 + 492 + In the following three paragraphs, a "patent license" is any express 493 + agreement or commitment, however denominated, not to enforce a patent 494 + (such as an express permission to practice a patent or covenant not to 495 + sue for patent infringement). To "grant" such a patent license to a 496 + party means to make such an agreement or commitment not to enforce a 497 + patent against the party. 498 + 499 + If you convey a covered work, knowingly relying on a patent license, 500 + and the Corresponding Source of the work is not available for anyone 501 + to copy, free of charge and under the terms of this License, through a 502 + publicly available network server or other readily accessible means, 503 + then you must either (1) cause the Corresponding Source to be so 504 + available, or (2) arrange to deprive yourself of the benefit of the 505 + patent license for this particular work, or (3) arrange, in a manner 506 + consistent with the requirements of this License, to extend the patent 507 + license to downstream recipients. "Knowingly relying" means you have 508 + actual knowledge that, but for the patent license, your conveying the 509 + covered work in a country, or your recipient's use of the covered work 510 + in a country, would infringe one or more identifiable patents in that 511 + country that you have reason to believe are valid. 512 + 513 + If, pursuant to or in connection with a single transaction or 514 + arrangement, you convey, or propagate by procuring conveyance of, a 515 + covered work, and grant a patent license to some of the parties 516 + receiving the covered work authorizing them to use, propagate, modify 517 + or convey a specific copy of the covered work, then the patent license 518 + you grant is automatically extended to all recipients of the covered 519 + work and works based on it. 520 + 521 + A patent license is "discriminatory" if it does not include within 522 + the scope of its coverage, prohibits the exercise of, or is 523 + conditioned on the non-exercise of one or more of the rights that are 524 + specifically granted under this License. You may not convey a covered 525 + work if you are a party to an arrangement with a third party that is 526 + in the business of distributing software, under which you make payment 527 + to the third party based on the extent of your activity of conveying 528 + the work, and under which the third party grants, to any of the 529 + parties who would receive the covered work from you, a discriminatory 530 + patent license (a) in connection with copies of the covered work 531 + conveyed by you (or copies made from those copies), or (b) primarily 532 + for and in connection with specific products or compilations that 533 + contain the covered work, unless you entered into that arrangement, 534 + or that patent license was granted, prior to 28 March 2007. 535 + 536 + Nothing in this License shall be construed as excluding or limiting 537 + any implied license or other defenses to infringement that may 538 + otherwise be available to you under applicable patent law. 539 + 540 + 12. No Surrender of Others' Freedom. 541 + 542 + If conditions are imposed on you (whether by court order, agreement or 543 + otherwise) that contradict the conditions of this License, they do not 544 + excuse you from the conditions of this License. If you cannot convey a 545 + covered work so as to satisfy simultaneously your obligations under this 546 + License and any other pertinent obligations, then as a consequence you may 547 + not convey it at all. For example, if you agree to terms that obligate you 548 + to collect a royalty for further conveying from those to whom you convey 549 + the Program, the only way you could satisfy both those terms and this 550 + License would be to refrain entirely from conveying the Program. 551 + 552 + 13. Use with the GNU Affero General Public License. 553 + 554 + Notwithstanding any other provision of this License, you have 555 + permission to link or combine any covered work with a work licensed 556 + under version 3 of the GNU Affero General Public License into a single 557 + combined work, and to convey the resulting work. The terms of this 558 + License will continue to apply to the part which is the covered work, 559 + but the special requirements of the GNU Affero General Public License, 560 + section 13, concerning interaction through a network will apply to the 561 + combination as such. 562 + 563 + 14. Revised Versions of this License. 564 + 565 + The Free Software Foundation may publish revised and/or new versions of 566 + the GNU General Public License from time to time. Such new versions will 567 + be similar in spirit to the present version, but may differ in detail to 568 + address new problems or concerns. 569 + 570 + Each version is given a distinguishing version number. If the 571 + Program specifies that a certain numbered version of the GNU General 572 + Public License "or any later version" applies to it, you have the 573 + option of following the terms and conditions either of that numbered 574 + version or of any later version published by the Free Software 575 + Foundation. If the Program does not specify a version number of the 576 + GNU General Public License, you may choose any version ever published 577 + by the Free Software Foundation. 578 + 579 + If the Program specifies that a proxy can decide which future 580 + versions of the GNU General Public License can be used, that proxy's 581 + public statement of acceptance of a version permanently authorizes you 582 + to choose that version for the Program. 583 + 584 + Later license versions may give you additional or different 585 + permissions. However, no additional obligations are imposed on any 586 + author or copyright holder as a result of your choosing to follow a 587 + later version. 588 + 589 + 15. Disclaimer of Warranty. 590 + 591 + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 + APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 + HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 + OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 + THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 + PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 + IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 + ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 + 600 + 16. Limitation of Liability. 601 + 602 + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 + WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 + THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 + GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 + USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 + DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 + PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 + EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 + SUCH DAMAGES. 611 + 612 + 17. Interpretation of Sections 15 and 16. 613 + 614 + If the disclaimer of warranty and limitation of liability provided 615 + above cannot be given local legal effect according to their terms, 616 + reviewing courts shall apply local law that most closely approximates 617 + an absolute waiver of all civil liability in connection with the 618 + Program, unless a warranty or assumption of liability accompanies a 619 + copy of the Program in return for a fee. 620 + 621 + END OF TERMS AND CONDITIONS 622 + 623 + How to Apply These Terms to Your New Programs 624 + 625 + If you develop a new program, and you want it to be of the greatest 626 + possible use to the public, the best way to achieve this is to make it 627 + free software which everyone can redistribute and change under these terms. 628 + 629 + To do so, attach the following notices to the program. It is safest 630 + to attach them to the start of each source file to most effectively 631 + state the exclusion of warranty; and each file should have at least 632 + the "copyright" line and a pointer to where the full notice is found. 633 + 634 + <one line to give the program's name and a brief idea of what it does.> 635 + Copyright (C) <year> <name of author> 636 + 637 + This program is free software: you can redistribute it and/or modify 638 + it under the terms of the GNU General Public License as published by 639 + the Free Software Foundation, either version 3 of the License, or 640 + (at your option) any later version. 641 + 642 + This program is distributed in the hope that it will be useful, 643 + but WITHOUT ANY WARRANTY; without even the implied warranty of 644 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 + GNU General Public License for more details. 646 + 647 + You should have received a copy of the GNU General Public License 648 + along with this program. If not, see <https://www.gnu.org/licenses/>. 649 + 650 + Also add information on how to contact you by electronic and paper mail. 651 + 652 + If the program does terminal interaction, make it output a short 653 + notice like this when it starts in an interactive mode: 654 + 655 + <program> Copyright (C) <year> <name of author> 656 + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 + This is free software, and you are welcome to redistribute it 658 + under certain conditions; type `show c' for details. 659 + 660 + The hypothetical commands `show w' and `show c' should show the appropriate 661 + parts of the General Public License. Of course, your program's commands 662 + might be different; for a GUI interface, you would use an "about box". 663 + 664 + You should also get your employer (if you work as a programmer) or school, 665 + if any, to sign a "copyright disclaimer" for the program, if necessary. 666 + For more information on this, and how to apply and follow the GNU GPL, see 667 + <https://www.gnu.org/licenses/>. 668 + 669 + The GNU General Public License does not permit incorporating your program 670 + into proprietary programs. If your program is a subroutine library, you 671 + may consider it more useful to permit linking proprietary applications with 672 + the library. If this is what you want to do, use the GNU Lesser General 673 + Public License instead of this License. But first, please read 674 + <https://www.gnu.org/licenses/why-not-lgpl.html>.
+231
README.md
··· 1 + <p align="center"> 2 + <img src="assets/icon.png" alt="pad icon" width="220"> 3 + </p> 4 + 5 + # pad 6 + 7 + `pad` is a small CLI with a simple terminal UI that helps teams draft and publish async daily standup updates without repeating the same manual steps every day. 8 + 9 + Current first iteration focuses on the fastest useful workflow: 10 + 11 + - open a split editor with live preview directly from `pad create` 12 + - prefill from your latest GitHub async daily issue with `pad repeat` 13 + - list your already-published async dailies directly from GitHub with `pad list` 14 + - read the merged team report issue with `pad report` 15 + - preview the rendered GitHub issue body with `pad show` or `pad create --dry-run` 16 + - create the GitHub issue in your configured repository with `pad create` 17 + 18 + ## Setup 19 + 20 + Requirements: 21 + 22 + - Go 1.25+ 23 + - `gh` installed and authenticated with `gh auth login` 24 + 25 + Build from source: 26 + 27 + ```bash 28 + go build -o pad . 29 + ``` 30 + 31 + Create the default config: 32 + 33 + ```bash 34 + ./pad init 35 + ``` 36 + 37 + This creates a TOML config file at the platform-appropriate location: 38 + 39 + - Linux/macOS: `~/.config/pad/pad.toml` (or `$XDG_CONFIG_HOME/pad/pad.toml`) 40 + - Windows: `%APPDATA%\pad\pad.toml` 41 + 42 + Example config: 43 + 44 + ```toml 45 + github_repo = "owner/repo" 46 + labels = ["daily-update"] 47 + ``` 48 + 49 + Configure your repository: 50 + 51 + ```bash 52 + ./pad init --repo owner/repo --labels daily-update 53 + ``` 54 + 55 + ## Repository Setup 56 + 57 + To use `pad` with your team, you need a GitHub repository with an issue template. 58 + 59 + ### 1. Create a Repository 60 + 61 + Create a repository (e.g., `your-org/dailies` or `your-org/standups`). 62 + 63 + ### 2. Add the Issue Template 64 + 65 + Copy the issue template from this repository: 66 + 67 + - [`.github/ISSUE_TEMPLATE/async-daily.yml`](.github/ISSUE_TEMPLATE/async-daily.yml) 68 + 69 + Place it in your repository at the same path. This template defines the structure that `pad` expects when parsing and creating issues. 70 + 71 + ### 3. (Optional) Set Up Automated Workflows 72 + 73 + This repository includes ready-to-use GitHub Actions workflows: 74 + 75 + **Async Daily Reporter** (`.github/workflows/asyncdaily-reporter.yml`) 76 + - Collects all daily issues from team members 77 + - Generates a merged report with parking lot items highlighted 78 + - Closes individual issues after including them in the report 79 + - Runs weekdays at 10:45 AM UTC (customize the cron schedule as needed) 80 + 81 + **Async Daily Template Updater** (`.github/workflows/asyncdaily-updater.yml`) 82 + - Automatically updates the issue template date to tomorrow 83 + - Runs daily at 12:00 PM UTC 84 + 85 + To use these workflows: 86 + 87 + 1. Copy the workflow files from `.github/workflows/` to your repository 88 + 2. Copy the scripts from `.github/scripts/` to your repository 89 + 3. Set up repository variables (optional): 90 + - `ASYNC_DAILY_LABEL`: Label for individual daily issues (default: `async-daily`) 91 + - `ASYNC_DAILY_REPORT_LABEL`: Label for report issues (default: `async-daily/report`) 92 + 4. The reporter workflow uses `GITHUB_TOKEN` which is automatically available 93 + 94 + The report issue title follows this format: `[Daily Report] YYYY/MM/DD` 95 + 96 + ### 4. Configure `pad` 97 + 98 + Each team member runs: 99 + 100 + ```bash 101 + pad init --repo your-org/dailies --labels daily-update 102 + ``` 103 + 104 + ## Shell Completion 105 + 106 + `pad` exposes shell completions through Cobra's built-in `completion` command. 107 + 108 + If `pad` is installed in your `PATH`, use `pad completion <shell>`. 109 + If you are still running it from a checkout, use the absolute path to the built binary instead of `pad` in the examples below. 110 + 111 + Bash: 112 + 113 + Add this line to `~/.bashrc`: 114 + 115 + ```bash 116 + source <(pad completion bash) 117 + ``` 118 + 119 + Then open a new shell or run: 120 + 121 + ```bash 122 + source ~/.bashrc 123 + ``` 124 + 125 + Zsh: 126 + 127 + Make sure completion is enabled in `~/.zshrc`: 128 + 129 + ```bash 130 + autoload -U compinit 131 + compinit 132 + source <(pad completion zsh) 133 + ``` 134 + 135 + Then open a new shell or run: 136 + 137 + ```bash 138 + source ~/.zshrc 139 + ``` 140 + 141 + Fish: 142 + 143 + Write the completion file once: 144 + 145 + ```bash 146 + mkdir -p ~/.config/fish/completions 147 + pad completion fish > ~/.config/fish/completions/pad.fish 148 + ``` 149 + 150 + Then start a new Fish shell. 151 + 152 + PowerShell: 153 + 154 + Load it for the current session: 155 + 156 + ```powershell 157 + pad completion powershell | Out-String | Invoke-Expression 158 + ``` 159 + 160 + Persist it in your PowerShell profile: 161 + 162 + ```powershell 163 + if (!(Test-Path $PROFILE)) { New-Item -ItemType File -Force $PROFILE | Out-Null } 164 + 'pad completion powershell | Out-String | Invoke-Expression' | Add-Content $PROFILE 165 + ``` 166 + 167 + Then restart PowerShell. 168 + 169 + ## Main Usage 170 + 171 + Open the async daily editor for today. The left pane shows the template fields, the right pane shows a live preview, and `pad` asks for confirmation before publishing: 172 + 173 + ```bash 174 + ./pad create 175 + ``` 176 + 177 + Repeat from your latest GitHub async daily issue into today's editor and create a new issue: 178 + 179 + ```bash 180 + ./pad repeat 181 + ``` 182 + 183 + Repeat into a different date: 184 + 185 + ```bash 186 + ./pad repeat --date 2026-04-17 187 + ``` 188 + 189 + Preview today's rendered issue body: 190 + 191 + ```bash 192 + ./pad show 193 + ``` 194 + 195 + `pad show --date YYYY-MM-DD` reads the issue already published in GitHub. 196 + 197 + Open the editor for a specific date and create that issue: 198 + 199 + ```bash 200 + ./pad create --date 2026-04-16 201 + ``` 202 + 203 + Open the editor and print the exact title and body without publishing: 204 + 205 + ```bash 206 + ./pad create --dry-run 207 + ``` 208 + 209 + List your async daily issues from GitHub: 210 + 211 + ```bash 212 + ./pad list 213 + ``` 214 + 215 + Show today's merged team report issue: 216 + 217 + ```bash 218 + ./pad report 219 + ``` 220 + 221 + Show the merged report for a specific date: 222 + 223 + ```bash 224 + ./pad report --date 2026-04-16 225 + ``` 226 + 227 + List recent merged report issues: 228 + 229 + ```bash 230 + ./pad report --list 231 + ```
assets/icon.png

This is a binary file and will not be displayed.

+82
cmd/create.go
··· 1 + package cmd 2 + 3 + import ( 4 + "context" 5 + "errors" 6 + "fmt" 7 + 8 + "github.com/prefapp/pad/internal/daily" 9 + "github.com/prefapp/pad/internal/tui" 10 + "github.com/spf13/cobra" 11 + ) 12 + 13 + func newCreateCmd() *cobra.Command { 14 + var date string 15 + var dryRun bool 16 + 17 + cmd := &cobra.Command{ 18 + Use: "create", 19 + Short: "Open the async daily editor and create the GitHub issue", 20 + RunE: func(cmd *cobra.Command, _ []string) error { 21 + env, err := loadEnv() 22 + if err != nil { 23 + return err 24 + } 25 + 26 + resolvedDate, err := resolveDate(date) 27 + if err != nil { 28 + return err 29 + } 30 + 31 + ctx := context.Background() 32 + if !dryRun { 33 + if err := ensureCanCreateForDate(ctx, env, resolvedDate); err != nil { 34 + return err 35 + } 36 + } 37 + 38 + entry := daily.New(resolvedDate) 39 + 40 + if dryRun { 41 + entry, err = tui.Edit(entry) 42 + } else { 43 + entry, err = tui.EditForCreate(entry) 44 + } 45 + if err != nil { 46 + if errors.Is(err, tui.ErrCanceled) { 47 + fmt.Fprintln(cmd.OutOrStdout(), "edit canceled") 48 + return nil 49 + } 50 + 51 + return err 52 + } 53 + 54 + if dryRun { 55 + title, err := entry.Title() 56 + if err != nil { 57 + return err 58 + } 59 + 60 + fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n%s\n", title, entry.Body()) 61 + return nil 62 + } 63 + 64 + if err := entry.ValidateForCreate(); err != nil { 65 + return err 66 + } 67 + 68 + issue, err := createIssueFromEntry(ctx, env, entry) 69 + if err != nil { 70 + return err 71 + } 72 + 73 + fmt.Fprintln(cmd.OutOrStdout(), issue.URL) 74 + return nil 75 + }, 76 + } 77 + 78 + cmd.Flags().StringVar(&date, "date", "", "Entry date in YYYY-MM-DD format") 79 + cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Open the editor and print the title/body without creating a GitHub issue") 80 + 81 + return cmd 82 + }
+47
cmd/init.go
··· 1 + package cmd 2 + 3 + import ( 4 + "fmt" 5 + 6 + "github.com/prefapp/pad/internal/appfs" 7 + "github.com/prefapp/pad/internal/config" 8 + "github.com/spf13/cobra" 9 + ) 10 + 11 + func newInitCmd() *cobra.Command { 12 + var repo string 13 + var labels []string 14 + 15 + cmd := &cobra.Command{ 16 + Use: "init", 17 + Short: "Create or update local pad config", 18 + RunE: func(cmd *cobra.Command, _ []string) error { 19 + paths, err := appfs.Discover() 20 + if err != nil { 21 + return err 22 + } 23 + 24 + cfg, err := config.Load(paths.ConfigFile) 25 + if err != nil { 26 + return err 27 + } 28 + 29 + cfg.GitHubRepo = repo 30 + cfg.Labels = labels 31 + 32 + if err := config.Save(paths.ConfigFile, cfg); err != nil { 33 + return err 34 + } 35 + 36 + fmt.Fprintf(cmd.OutOrStdout(), "saved config: %s\n", paths.ConfigFile) 37 + fmt.Fprintf(cmd.OutOrStdout(), "repo: %s\n", cfg.GitHubRepo) 38 + fmt.Fprintf(cmd.OutOrStdout(), "labels: %v\n", cfg.Labels) 39 + return nil 40 + }, 41 + } 42 + 43 + cmd.Flags().StringVar(&repo, "repo", "", "GitHub repository for async daily issues (required)") 44 + cmd.Flags().StringSliceVar(&labels, "labels", nil, "Labels to apply when creating issues (can be specified multiple times)") 45 + 46 + return cmd 47 + }
+51
cmd/list.go
··· 1 + package cmd 2 + 3 + import ( 4 + "context" 5 + "fmt" 6 + "text/tabwriter" 7 + 8 + "github.com/spf13/cobra" 9 + ) 10 + 11 + func newListCmd() *cobra.Command { 12 + var limit int 13 + 14 + cmd := &cobra.Command{ 15 + Use: "list", 16 + Short: "List async daily issues created by you", 17 + RunE: func(cmd *cobra.Command, _ []string) error { 18 + env, err := loadEnv() 19 + if err != nil { 20 + return err 21 + } 22 + 23 + ctx := context.Background() 24 + if err := env.gh.EnsureReady(ctx); err != nil { 25 + return err 26 + } 27 + 28 + issues, err := env.gh.ListAsyncDailyIssues(ctx, env.cfg.GitHubRepo, env.cfg.Labels, limit) 29 + if err != nil { 30 + return err 31 + } 32 + 33 + if len(issues) == 0 { 34 + fmt.Fprintln(cmd.OutOrStdout(), "no remote async daily issues found for the authenticated user") 35 + return nil 36 + } 37 + 38 + writer := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 4, 2, ' ', 0) 39 + fmt.Fprintln(writer, "DATE\tNUMBER\tSTATE\tURL") 40 + for _, issue := range issues { 41 + fmt.Fprintf(writer, "%s\t#%d\t%s\t%s\n", issue.Date, issue.Number, issue.State, issue.URL) 42 + } 43 + 44 + return writer.Flush() 45 + }, 46 + } 47 + 48 + cmd.Flags().IntVar(&limit, "limit", 10, "Maximum number of entries to show") 49 + 50 + return cmd 51 + }
+93
cmd/repeat.go
··· 1 + package cmd 2 + 3 + import ( 4 + "context" 5 + "errors" 6 + "fmt" 7 + 8 + "github.com/prefapp/pad/internal/daily" 9 + "github.com/prefapp/pad/internal/ghcli" 10 + "github.com/prefapp/pad/internal/tui" 11 + "github.com/spf13/cobra" 12 + ) 13 + 14 + func newRepeatCmd() *cobra.Command { 15 + var date string 16 + var dryRun bool 17 + 18 + cmd := &cobra.Command{ 19 + Use: "repeat", 20 + Short: "Prefill from your latest GitHub async daily issue and create a new one", 21 + RunE: func(cmd *cobra.Command, _ []string) error { 22 + env, err := loadEnv() 23 + if err != nil { 24 + return err 25 + } 26 + 27 + resolvedDate, err := resolveDate(date) 28 + if err != nil { 29 + return err 30 + } 31 + 32 + ctx := context.Background() 33 + if err := env.gh.EnsureReady(ctx); err != nil { 34 + return err 35 + } 36 + 37 + if !dryRun { 38 + if err := ensureCanCreateForDate(ctx, env, resolvedDate); err != nil { 39 + return err 40 + } 41 + } 42 + 43 + latestIssue, err := env.gh.LatestAsyncDailyIssue(ctx, env.cfg.GitHubRepo, env.cfg.Labels) 44 + if err != nil { 45 + if errors.Is(err, ghcli.ErrIssueNotFound) { 46 + return fmt.Errorf("no previous async daily issues found for the authenticated user") 47 + } 48 + 49 + return err 50 + } 51 + 52 + entry := daily.EntryFromIssueBody(resolvedDate, latestIssue.Body) 53 + entry.Source = fmt.Sprintf("repeat:%s", latestIssue.Date) 54 + 55 + if dryRun { 56 + entry, err = tui.Edit(entry) 57 + } else { 58 + entry, err = tui.EditForCreate(entry) 59 + } 60 + if err != nil { 61 + if errors.Is(err, tui.ErrCanceled) { 62 + fmt.Fprintln(cmd.OutOrStdout(), "edit canceled") 63 + return nil 64 + } 65 + 66 + return err 67 + } 68 + 69 + if dryRun { 70 + title, err := entry.Title() 71 + if err != nil { 72 + return err 73 + } 74 + 75 + fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n%s\n", title, entry.Body()) 76 + return nil 77 + } 78 + 79 + issue, err := createIssueFromEntry(ctx, env, entry) 80 + if err != nil { 81 + return err 82 + } 83 + 84 + fmt.Fprintln(cmd.OutOrStdout(), issue.URL) 85 + return nil 86 + }, 87 + } 88 + 89 + cmd.Flags().StringVar(&date, "date", "", "Entry date in YYYY-MM-DD format") 90 + cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Open the editor with the repeated content and print the title/body without creating a GitHub issue") 91 + 92 + return cmd 93 + }
+76
cmd/report.go
··· 1 + package cmd 2 + 3 + import ( 4 + "context" 5 + "errors" 6 + "fmt" 7 + "text/tabwriter" 8 + 9 + "github.com/prefapp/pad/internal/ghcli" 10 + "github.com/spf13/cobra" 11 + ) 12 + 13 + func newReportCmd() *cobra.Command { 14 + var date string 15 + var list bool 16 + var limit int 17 + 18 + cmd := &cobra.Command{ 19 + Use: "report", 20 + Short: "Show the merged async daily team report issue", 21 + RunE: func(cmd *cobra.Command, _ []string) error { 22 + env, err := loadEnv() 23 + if err != nil { 24 + return err 25 + } 26 + 27 + ctx := context.Background() 28 + if err := env.gh.EnsureReady(ctx); err != nil { 29 + return err 30 + } 31 + 32 + if list { 33 + issues, err := env.gh.ListReportIssues(ctx, env.cfg.GitHubRepo, limit) 34 + if err != nil { 35 + return err 36 + } 37 + 38 + if len(issues) == 0 { 39 + fmt.Fprintln(cmd.OutOrStdout(), "no async daily report issues found") 40 + return nil 41 + } 42 + 43 + writer := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 4, 2, ' ', 0) 44 + fmt.Fprintln(writer, "DATE\tNUMBER\tSTATE\tURL") 45 + for _, issue := range issues { 46 + fmt.Fprintf(writer, "%s\t#%d\t%s\t%s\n", issue.Date, issue.Number, issue.State, issue.URL) 47 + } 48 + 49 + return writer.Flush() 50 + } 51 + 52 + resolvedDate, err := resolveDate(date) 53 + if err != nil { 54 + return err 55 + } 56 + 57 + issue, err := env.gh.FindReportIssueByDate(ctx, env.cfg.GitHubRepo, resolvedDate) 58 + if err != nil { 59 + if errors.Is(err, ghcli.ErrIssueNotFound) { 60 + return fmt.Errorf("no async daily report issue found for %s", resolvedDate) 61 + } 62 + 63 + return err 64 + } 65 + 66 + fmt.Fprintf(cmd.OutOrStdout(), "%s\n%s\n\n%s\n", issue.Title, issue.URL, issue.Body) 67 + return nil 68 + }, 69 + } 70 + 71 + cmd.Flags().StringVar(&date, "date", "", "Report date in YYYY-MM-DD format") 72 + cmd.Flags().BoolVar(&list, "list", false, "List recent report issues instead of showing one") 73 + cmd.Flags().IntVar(&limit, "limit", 10, "Maximum number of report issues to show with --list") 74 + 75 + return cmd 76 + }
+24
cmd/root.go
··· 1 + package cmd 2 + 3 + import "github.com/spf13/cobra" 4 + 5 + func NewRootCmd(version string) *cobra.Command { 6 + rootCmd := &cobra.Command{ 7 + Use: "pad", 8 + Short: "Async daily standup helper", 9 + SilenceUsage: true, 10 + SilenceErrors: true, 11 + Version: version, 12 + } 13 + 14 + rootCmd.SetVersionTemplate("{{.Version}}\n") 15 + 16 + rootCmd.AddCommand(newInitCmd()) 17 + rootCmd.AddCommand(newRepeatCmd()) 18 + rootCmd.AddCommand(newShowCmd()) 19 + rootCmd.AddCommand(newCreateCmd()) 20 + rootCmd.AddCommand(newListCmd()) 21 + rootCmd.AddCommand(newReportCmd()) 22 + 23 + return rootCmd 24 + }
+51
cmd/show.go
··· 1 + package cmd 2 + 3 + import ( 4 + "context" 5 + "errors" 6 + "fmt" 7 + 8 + "github.com/prefapp/pad/internal/ghcli" 9 + "github.com/spf13/cobra" 10 + ) 11 + 12 + func newShowCmd() *cobra.Command { 13 + var date string 14 + 15 + cmd := &cobra.Command{ 16 + Use: "show", 17 + Short: "Print your async daily issue body from GitHub for a date", 18 + RunE: func(cmd *cobra.Command, _ []string) error { 19 + env, err := loadEnv() 20 + if err != nil { 21 + return err 22 + } 23 + 24 + resolvedDate, err := resolveDate(date) 25 + if err != nil { 26 + return err 27 + } 28 + 29 + ctx := context.Background() 30 + if err := env.gh.EnsureReady(ctx); err != nil { 31 + return err 32 + } 33 + 34 + issue, err := env.gh.FindAsyncDailyIssueByDate(ctx, env.cfg.GitHubRepo, env.cfg.Labels, resolvedDate) 35 + if err != nil { 36 + if errors.Is(err, ghcli.ErrIssueNotFound) { 37 + return fmt.Errorf("no remote async daily issue found for %s", resolvedDate) 38 + } 39 + 40 + return err 41 + } 42 + 43 + fmt.Fprintf(cmd.OutOrStdout(), "%s\n%s\n\n%s\n", issue.Title, issue.URL, issue.Body) 44 + return nil 45 + }, 46 + } 47 + 48 + cmd.Flags().StringVar(&date, "date", "", "Entry date in YYYY-MM-DD format") 49 + 50 + return cmd 51 + }
+77
cmd/support.go
··· 1 + package cmd 2 + 3 + import ( 4 + "context" 5 + "errors" 6 + "fmt" 7 + "time" 8 + 9 + "github.com/prefapp/pad/internal/appfs" 10 + "github.com/prefapp/pad/internal/config" 11 + "github.com/prefapp/pad/internal/daily" 12 + "github.com/prefapp/pad/internal/ghcli" 13 + ) 14 + 15 + type commandEnv struct { 16 + cfg config.Config 17 + gh *ghcli.Client 18 + } 19 + 20 + func loadEnv() (*commandEnv, error) { 21 + paths, err := appfs.Discover() 22 + if err != nil { 23 + return nil, err 24 + } 25 + 26 + cfg, err := config.Load(paths.ConfigFile) 27 + if err != nil { 28 + return nil, err 29 + } 30 + 31 + if cfg.GitHubRepo == "" { 32 + return nil, fmt.Errorf("no repository configured; run `pad init --repo owner/repo`") 33 + } 34 + 35 + return &commandEnv{ 36 + cfg: cfg, 37 + gh: ghcli.New(), 38 + }, nil 39 + } 40 + 41 + func resolveDate(raw string) (string, error) { 42 + if raw == "" { 43 + return time.Now().Format(daily.DateLayout), nil 44 + } 45 + 46 + if _, err := time.Parse(daily.DateLayout, raw); err != nil { 47 + return "", fmt.Errorf("invalid date %q: use YYYY-MM-DD", raw) 48 + } 49 + 50 + return raw, nil 51 + } 52 + 53 + func ensureCanCreateForDate(ctx context.Context, env *commandEnv, date string) error { 54 + if err := env.gh.EnsureReady(ctx); err != nil { 55 + return err 56 + } 57 + 58 + existingIssue, err := env.gh.FindAsyncDailyIssueByDate(ctx, env.cfg.GitHubRepo, env.cfg.Labels, date) 59 + if err == nil { 60 + return fmt.Errorf("async daily issue already exists for %s: %s", date, existingIssue.URL) 61 + } 62 + 63 + if errors.Is(err, ghcli.ErrIssueNotFound) { 64 + return nil 65 + } 66 + 67 + return fmt.Errorf("check existing GitHub issues: %w", err) 68 + } 69 + 70 + func createIssueFromEntry(ctx context.Context, env *commandEnv, entry daily.Entry) (daily.IssueRef, error) { 71 + title, err := entry.Title() 72 + if err != nil { 73 + return daily.IssueRef{}, err 74 + } 75 + 76 + return env.gh.CreateIssue(ctx, env.cfg.GitHubRepo, title, entry.Body(), env.cfg.Labels) 77 + }
+37
go.mod
··· 1 + module github.com/prefapp/pad 2 + 3 + go 1.25.0 4 + 5 + require ( 6 + github.com/BurntSushi/toml v1.6.0 7 + github.com/charmbracelet/bubbles v1.0.0 8 + github.com/charmbracelet/bubbletea v1.3.10 9 + github.com/charmbracelet/lipgloss v1.1.0 10 + github.com/spf13/cobra v1.10.2 11 + ) 12 + 13 + require ( 14 + github.com/atotto/clipboard v0.1.4 // indirect 15 + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect 16 + github.com/charmbracelet/colorprofile v0.4.1 // indirect 17 + github.com/charmbracelet/x/ansi v0.11.6 // indirect 18 + github.com/charmbracelet/x/cellbuf v0.0.15 // indirect 19 + github.com/charmbracelet/x/term v0.2.2 // indirect 20 + github.com/clipperhouse/displaywidth v0.9.0 // indirect 21 + github.com/clipperhouse/stringish v0.1.1 // indirect 22 + github.com/clipperhouse/uax29/v2 v2.5.0 // indirect 23 + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect 24 + github.com/inconshreveable/mousetrap v1.1.0 // indirect 25 + github.com/lucasb-eyer/go-colorful v1.3.0 // indirect 26 + github.com/mattn/go-isatty v0.0.20 // indirect 27 + github.com/mattn/go-localereader v0.0.1 // indirect 28 + github.com/mattn/go-runewidth v0.0.19 // indirect 29 + github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect 30 + github.com/muesli/cancelreader v0.2.2 // indirect 31 + github.com/muesli/termenv v0.16.0 // indirect 32 + github.com/rivo/uniseg v0.4.7 // indirect 33 + github.com/spf13/pflag v1.0.9 // indirect 34 + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect 35 + golang.org/x/sys v0.38.0 // indirect 36 + golang.org/x/text v0.4.0 // indirect 37 + )
+68
go.sum
··· 1 + github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= 2 + github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= 3 + github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= 4 + github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= 5 + github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= 6 + github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= 7 + github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= 8 + github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= 9 + github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY= 10 + github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E= 11 + github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc= 12 + github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E= 13 + github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= 14 + github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= 15 + github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk= 16 + github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk= 17 + github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= 18 + github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= 19 + github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8= 20 + github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= 21 + github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI= 22 + github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q= 23 + github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= 24 + github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI= 25 + github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA= 26 + github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA= 27 + github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= 28 + github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= 29 + github.com/clipperhouse/uax29/v2 v2.5.0 h1:x7T0T4eTHDONxFJsL94uKNKPHrclyFI0lm7+w94cO8U= 30 + github.com/clipperhouse/uax29/v2 v2.5.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= 31 + github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= 32 + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= 33 + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= 34 + github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= 35 + github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= 36 + github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag= 37 + github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= 38 + github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 39 + github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 40 + github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= 41 + github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= 42 + github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= 43 + github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= 44 + github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= 45 + github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= 46 + github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= 47 + github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= 48 + github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= 49 + github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= 50 + github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= 51 + github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= 52 + github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 53 + github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= 54 + github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= 55 + github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= 56 + github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 57 + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= 58 + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= 59 + go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= 60 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= 61 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= 62 + golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 63 + golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 64 + golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= 65 + golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= 66 + golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= 67 + golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 68 + gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+20
internal/appfs/paths.go
··· 1 + package appfs 2 + 3 + import ( 4 + "github.com/prefapp/pad/internal/config" 5 + ) 6 + 7 + type Paths struct { 8 + ConfigFile string 9 + } 10 + 11 + func Discover() (Paths, error) { 12 + configFile, err := config.ConfigFile() 13 + if err != nil { 14 + return Paths{}, err 15 + } 16 + 17 + return Paths{ 18 + ConfigFile: configFile, 19 + }, nil 20 + }
+18
internal/appfs/paths_test.go
··· 1 + package appfs 2 + 3 + import ( 4 + "testing" 5 + ) 6 + 7 + func TestDiscoverHonorsXDGOverrides(t *testing.T) { 8 + t.Setenv("XDG_CONFIG_HOME", "/tmp/pad-config") 9 + 10 + paths, err := Discover() 11 + if err != nil { 12 + t.Fatalf("discover paths: %v", err) 13 + } 14 + 15 + if paths.ConfigFile != "/tmp/pad-config/pad/pad.toml" { 16 + t.Fatalf("expected config path /tmp/pad-config/pad/pad.toml, got %q", paths.ConfigFile) 17 + } 18 + }
+95
internal/config/config.go
··· 1 + package config 2 + 3 + import ( 4 + "errors" 5 + "fmt" 6 + "os" 7 + "path/filepath" 8 + "runtime" 9 + 10 + "github.com/BurntSushi/toml" 11 + ) 12 + 13 + type Config struct { 14 + GitHubRepo string `toml:"github_repo"` 15 + Labels []string `toml:"labels"` 16 + } 17 + 18 + func Default() Config { 19 + return Config{ 20 + GitHubRepo: "", 21 + Labels: []string{}, 22 + } 23 + } 24 + 25 + func Load(path string) (Config, error) { 26 + cfg := Default() 27 + 28 + data, err := os.ReadFile(path) 29 + if err != nil { 30 + if errors.Is(err, os.ErrNotExist) { 31 + return cfg, nil 32 + } 33 + 34 + return Config{}, fmt.Errorf("read config: %w", err) 35 + } 36 + 37 + if err := toml.Unmarshal(data, &cfg); err != nil { 38 + return Config{}, fmt.Errorf("decode config: %w", err) 39 + } 40 + 41 + return cfg, nil 42 + } 43 + 44 + func Save(path string, cfg Config) error { 45 + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { 46 + return fmt.Errorf("create config dir: %w", err) 47 + } 48 + 49 + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) 50 + if err != nil { 51 + return fmt.Errorf("open config file: %w", err) 52 + } 53 + defer f.Close() 54 + 55 + enc := toml.NewEncoder(f) 56 + if err := enc.Encode(cfg); err != nil { 57 + return fmt.Errorf("encode config: %w", err) 58 + } 59 + 60 + return nil 61 + } 62 + 63 + func ConfigDir() (string, error) { 64 + if xdg := os.Getenv("XDG_CONFIG_HOME"); xdg != "" { 65 + return filepath.Join(xdg, "pad"), nil 66 + } 67 + 68 + if runtime.GOOS == "windows" { 69 + if appData := os.Getenv("APPDATA"); appData != "" { 70 + return filepath.Join(appData, "pad"), nil 71 + } 72 + } 73 + 74 + home, err := os.UserHomeDir() 75 + if err != nil { 76 + return "", fmt.Errorf("resolve user home dir: %w", err) 77 + } 78 + 79 + switch runtime.GOOS { 80 + case "darwin": 81 + return filepath.Join(home, "Library", "Application Support", "pad"), nil 82 + case "windows": 83 + return filepath.Join(home, "AppData", "Roaming", "pad"), nil 84 + default: 85 + return filepath.Join(home, ".config", "pad"), nil 86 + } 87 + } 88 + 89 + func ConfigFile() (string, error) { 90 + dir, err := ConfigDir() 91 + if err != nil { 92 + return "", err 93 + } 94 + return filepath.Join(dir, "pad.toml"), nil 95 + }
+294
internal/daily/entry.go
··· 1 + package daily 2 + 3 + import ( 4 + "fmt" 5 + "strings" 6 + "time" 7 + ) 8 + 9 + const DateLayout = "2006-01-02" 10 + 11 + const issueTitlePrefix = "[Async Daily] [" 12 + const reportTitlePrefix = "[Daily Report] " 13 + 14 + type IssueRef struct { 15 + Number int `json:"number"` 16 + URL string `json:"url"` 17 + } 18 + 19 + type Entry struct { 20 + Date string `json:"date"` 21 + Yesterday string `json:"yesterday"` 22 + Today string `json:"today"` 23 + Blockers string `json:"blockers,omitempty"` 24 + ParkingLot bool `json:"parking_lot,omitempty"` 25 + ParkingLotDetails string `json:"parking_lot_details,omitempty"` 26 + AdditionalComments string `json:"additional_comments,omitempty"` 27 + Source string `json:"source,omitempty"` 28 + Issue *IssueRef `json:"issue,omitempty"` 29 + CreatedAt time.Time `json:"created_at"` 30 + UpdatedAt time.Time `json:"updated_at"` 31 + } 32 + 33 + func New(date string) Entry { 34 + return Entry{ 35 + Date: date, 36 + Source: "manual", 37 + } 38 + } 39 + 40 + func EntryFromIssueBody(date, body string) Entry { 41 + sections := parseSections(body) 42 + parkingLot, parkingLotDetails := parseParkingLotSections(sections) 43 + 44 + return Entry{ 45 + Date: date, 46 + Yesterday: normalizeParsedSection(sections["yesterday"]), 47 + Today: normalizeParsedSection(sections["today"]), 48 + Blockers: normalizeParsedSection(sections["blockers"]), 49 + ParkingLot: parkingLot, 50 + ParkingLotDetails: parkingLotDetails, 51 + AdditionalComments: normalizeParsedSection(sections["comments"]), 52 + } 53 + } 54 + 55 + func (e Entry) Title() (string, error) { 56 + return TitleForDate(e.Date) 57 + } 58 + 59 + func TitleForDate(date string) (string, error) { 60 + return titleForDate(date, issueTitlePrefix, "2006/01/02", "]") 61 + } 62 + 63 + func ReportTitleForDate(date string) (string, error) { 64 + return titleForDate(date, reportTitlePrefix, "2006/01/02", "") 65 + } 66 + 67 + func DateFromIssueTitle(title string) (string, bool) { 68 + return dateFromTitle(title, issueTitlePrefix, "]") 69 + } 70 + 71 + func DateFromReportTitle(title string) (string, bool) { 72 + return dateFromTitle(title, reportTitlePrefix, "") 73 + } 74 + 75 + func titleForDate(date, prefix, format, suffix string) (string, error) { 76 + t, err := time.Parse(DateLayout, date) 77 + if err != nil { 78 + return "", fmt.Errorf("parse entry date: %w", err) 79 + } 80 + 81 + return fmt.Sprintf("%s%s%s", prefix, t.Format(format), suffix), nil 82 + } 83 + 84 + func dateFromTitle(title, prefix, suffix string) (string, bool) { 85 + if !strings.HasPrefix(title, prefix) || !strings.HasSuffix(title, suffix) { 86 + return "", false 87 + } 88 + 89 + raw := strings.TrimSuffix(strings.TrimPrefix(title, prefix), suffix) 90 + t, err := time.Parse("2006/01/02", raw) 91 + if err != nil { 92 + return "", false 93 + } 94 + 95 + return t.Format(DateLayout), true 96 + } 97 + 98 + func (e Entry) Body() string { 99 + sections := []section{ 100 + {Title: "✅ What did you do yesterday?", Body: e.Yesterday}, 101 + {Title: "🎯 What will you do today?", Body: e.Today}, 102 + {Title: "🚧 Any blockers?", Body: e.Blockers}, 103 + } 104 + 105 + parkingLotBody := buildParkingLotBody(e) 106 + if parkingLotBody != "" { 107 + sections = append(sections, section{Title: "🚨 Parking Lot / Escalation", Body: parkingLotBody}) 108 + } 109 + 110 + if strings.TrimSpace(e.AdditionalComments) != "" { 111 + sections = append(sections, section{Title: "💬 Additional Comments", Body: e.AdditionalComments}) 112 + } 113 + 114 + var body strings.Builder 115 + for index, section := range sections { 116 + if index > 0 { 117 + body.WriteString("\n\n") 118 + } 119 + 120 + body.WriteString("## ") 121 + body.WriteString(section.Title) 122 + body.WriteString("\n") 123 + body.WriteString(normalizeSectionBody(section.Body)) 124 + } 125 + 126 + return body.String() 127 + } 128 + 129 + func (e Entry) ValidateForCreate() error { 130 + if strings.TrimSpace(e.Yesterday) == "" { 131 + return fmt.Errorf("yesterday section is required; fill it in with `pad create` or `pad repeat --edit`") 132 + } 133 + 134 + if strings.TrimSpace(e.Today) == "" { 135 + return fmt.Errorf("today section is required; fill it in with `pad create` or `pad repeat --edit`") 136 + } 137 + 138 + return nil 139 + } 140 + 141 + func (e Entry) Normalize() Entry { 142 + e.Yesterday = strings.TrimSpace(e.Yesterday) 143 + e.Today = strings.TrimSpace(e.Today) 144 + e.Blockers = strings.TrimSpace(e.Blockers) 145 + e.ParkingLotDetails = strings.TrimSpace(e.ParkingLotDetails) 146 + e.AdditionalComments = strings.TrimSpace(e.AdditionalComments) 147 + e.Source = strings.TrimSpace(e.Source) 148 + return e 149 + } 150 + 151 + type section struct { 152 + Title string 153 + Body string 154 + } 155 + 156 + func normalizeSectionBody(body string) string { 157 + trimmed := strings.TrimSpace(body) 158 + if trimmed == "" { 159 + return "_None._" 160 + } 161 + 162 + return trimmed 163 + } 164 + 165 + func buildParkingLotBody(e Entry) string { 166 + var parts []string 167 + 168 + if e.ParkingLot { 169 + parts = append(parts, "- ✅ Yes, I need a Parking Lot or escalation") 170 + } 171 + 172 + if details := strings.TrimSpace(e.ParkingLotDetails); details != "" { 173 + parts = append(parts, details) 174 + } 175 + 176 + return strings.Join(parts, "\n\n") 177 + } 178 + 179 + func parseSections(body string) map[string]string { 180 + sections := make(map[string][]string) 181 + current := "" 182 + 183 + for _, line := range strings.Split(strings.ReplaceAll(body, "\r\n", "\n"), "\n") { 184 + if key, ok := sectionKey(strings.TrimSpace(line)); ok { 185 + current = key 186 + continue 187 + } 188 + 189 + if current == "" { 190 + continue 191 + } 192 + 193 + sections[current] = append(sections[current], line) 194 + } 195 + 196 + parsed := make(map[string]string, len(sections)) 197 + for key, lines := range sections { 198 + parsed[key] = strings.TrimSpace(strings.Join(lines, "\n")) 199 + } 200 + 201 + return parsed 202 + } 203 + 204 + func sectionKey(line string) (string, bool) { 205 + if !strings.HasPrefix(line, "##") { 206 + return "", false 207 + } 208 + 209 + heading := strings.TrimSpace(strings.TrimLeft(line, "# ")) 210 + switch heading { 211 + case "✅ What did you do yesterday?": 212 + return "yesterday", true 213 + case "🎯 What will you do today?": 214 + return "today", true 215 + case "🚧 Any blockers?": 216 + return "blockers", true 217 + case "🚨 Do you request a Parking Lot or escalation?": 218 + return "parking_checkbox", true 219 + case "🚨 Parking Lot / Escalation": 220 + return "parking_combined", true 221 + case "📝 Parking Lot Details": 222 + return "parking_details", true 223 + case "💬 Additional Comments": 224 + return "comments", true 225 + default: 226 + return "", false 227 + } 228 + } 229 + 230 + func parseParkingLotSections(sections map[string]string) (bool, string) { 231 + parkingLot := false 232 + details := normalizeParsedSection(sections["parking_details"]) 233 + 234 + checkbox := normalizeParsedSection(sections["parking_checkbox"]) 235 + if strings.Contains(strings.ToLower(checkbox), "[x]") { 236 + parkingLot = true 237 + } 238 + 239 + combined := normalizeParsedSection(sections["parking_combined"]) 240 + if combined != "" { 241 + combinedParkingLot, combinedDetails := parseCombinedParkingLot(combined) 242 + if combinedParkingLot { 243 + parkingLot = true 244 + } 245 + if details == "" { 246 + details = combinedDetails 247 + } 248 + } 249 + 250 + if details != "" { 251 + parkingLot = true 252 + } 253 + 254 + return parkingLot, details 255 + } 256 + 257 + func parseCombinedParkingLot(body string) (bool, string) { 258 + parkingLot := false 259 + detailLines := make([]string, 0) 260 + 261 + for _, line := range strings.Split(body, "\n") { 262 + trimmed := strings.TrimSpace(line) 263 + if trimmed == "" { 264 + if len(detailLines) > 0 { 265 + detailLines = append(detailLines, line) 266 + } 267 + continue 268 + } 269 + 270 + if strings.Contains(trimmed, "Yes, I need a Parking Lot or escalation") { 271 + parkingLot = true 272 + continue 273 + } 274 + 275 + detailLines = append(detailLines, line) 276 + } 277 + 278 + details := normalizeParsedSection(strings.TrimSpace(strings.Join(detailLines, "\n"))) 279 + if details != "" { 280 + parkingLot = true 281 + } 282 + 283 + return parkingLot, details 284 + } 285 + 286 + func normalizeParsedSection(body string) string { 287 + trimmed := strings.TrimSpace(body) 288 + switch trimmed { 289 + case "", "_No response_", "_None._": 290 + return "" 291 + default: 292 + return trimmed 293 + } 294 + }
+162
internal/daily/entry_test.go
··· 1 + package daily 2 + 3 + import ( 4 + "strings" 5 + "testing" 6 + ) 7 + 8 + func TestEntryFromIssueBodyParsesIssueFormMarkdown(t *testing.T) { 9 + body := `### ✅ What did you do yesterday? 10 + 11 + - https://github.com/prefapp/features/issues/918 12 + 13 + ### 🎯 What will you do today? 14 + 15 + - https://github.com/prefapp/gitops-k8s/pull/1755 16 + 17 + ### 🚧 Any blockers? 18 + 19 + _No response_ 20 + 21 + ### 🚨 Do you request a Parking Lot or escalation? 22 + 23 + - [x] ✅ Yes, I need a Parking Lot or escalation 24 + 25 + ### 📝 Parking Lot Details 26 + 27 + - Need help with deployment scope 28 + 29 + ### 💬 Additional Comments 30 + 31 + - Offline after 17:00` 32 + 33 + got := EntryFromIssueBody("2026-04-17", body) 34 + 35 + if got.Date != "2026-04-17" { 36 + t.Fatalf("expected date 2026-04-17, got %q", got.Date) 37 + } 38 + 39 + if got.Yesterday != "- https://github.com/prefapp/features/issues/918" { 40 + t.Fatalf("unexpected yesterday %q", got.Yesterday) 41 + } 42 + 43 + if got.Today != "- https://github.com/prefapp/gitops-k8s/pull/1755" { 44 + t.Fatalf("unexpected today %q", got.Today) 45 + } 46 + 47 + if got.Blockers != "" { 48 + t.Fatalf("expected empty blockers, got %q", got.Blockers) 49 + } 50 + 51 + if !got.ParkingLot { 52 + t.Fatalf("expected parking lot to be true") 53 + } 54 + 55 + if got.ParkingLotDetails != "- Need help with deployment scope" { 56 + t.Fatalf("unexpected parking lot details %q", got.ParkingLotDetails) 57 + } 58 + 59 + if got.AdditionalComments != "- Offline after 17:00" { 60 + t.Fatalf("unexpected additional comments %q", got.AdditionalComments) 61 + } 62 + } 63 + 64 + func TestEntryFromIssueBodyParsesPadMarkdown(t *testing.T) { 65 + body := `## ✅ What did you do yesterday? 66 + - Reviewed PR #42 67 + 68 + ## 🎯 What will you do today? 69 + - Continue feature work 70 + 71 + ## 🚧 Any blockers? 72 + _None._ 73 + 74 + ## 🚨 Parking Lot / Escalation 75 + - ✅ Yes, I need a Parking Lot or escalation 76 + 77 + - Need product input 78 + 79 + ## 💬 Additional Comments 80 + - Waiting for design confirmation` 81 + 82 + got := EntryFromIssueBody("2026-04-17", body) 83 + 84 + if got.Yesterday != "- Reviewed PR #42" { 85 + t.Fatalf("unexpected yesterday %q", got.Yesterday) 86 + } 87 + 88 + if got.Today != "- Continue feature work" { 89 + t.Fatalf("unexpected today %q", got.Today) 90 + } 91 + 92 + if got.Blockers != "" { 93 + t.Fatalf("expected empty blockers, got %q", got.Blockers) 94 + } 95 + 96 + if !got.ParkingLot { 97 + t.Fatalf("expected parking lot to be true") 98 + } 99 + 100 + if got.ParkingLotDetails != "- Need product input" { 101 + t.Fatalf("unexpected parking lot details %q", got.ParkingLotDetails) 102 + } 103 + 104 + if got.AdditionalComments != "- Waiting for design confirmation" { 105 + t.Fatalf("unexpected additional comments %q", got.AdditionalComments) 106 + } 107 + } 108 + 109 + func TestBodyRendersTemplateSections(t *testing.T) { 110 + entry := Entry{ 111 + Date: "2026-04-16", 112 + Yesterday: "- Reviewed PR #42", 113 + Today: "- Continue feature work", 114 + } 115 + 116 + body := entry.Body() 117 + 118 + checks := []string{ 119 + "## ✅ What did you do yesterday?", 120 + "## 🎯 What will you do today?", 121 + "## 🚧 Any blockers?", 122 + "_None._", 123 + } 124 + 125 + for _, check := range checks { 126 + if !strings.Contains(body, check) { 127 + t.Fatalf("expected body to contain %q, got %q", check, body) 128 + } 129 + } 130 + 131 + if strings.Contains(body, "Parking Lot / Escalation") { 132 + t.Fatalf("expected empty parking lot section to be omitted") 133 + } 134 + } 135 + 136 + func TestDateFromIssueTitle(t *testing.T) { 137 + date, ok := DateFromIssueTitle("[Async Daily] [2026/04/16]") 138 + if !ok { 139 + t.Fatalf("expected title to parse") 140 + } 141 + 142 + if date != "2026-04-16" { 143 + t.Fatalf("expected parsed date 2026-04-16, got %q", date) 144 + } 145 + } 146 + 147 + func TestDateFromIssueTitleRejectsNonTemplateTitles(t *testing.T) { 148 + if _, ok := DateFromIssueTitle("other title"); ok { 149 + t.Fatalf("expected non-template title to be rejected") 150 + } 151 + } 152 + 153 + func TestDateFromReportTitle(t *testing.T) { 154 + date, ok := DateFromReportTitle("[Daily Report] 2026/04/16") 155 + if !ok { 156 + t.Fatalf("expected report title to parse") 157 + } 158 + 159 + if date != "2026-04-16" { 160 + t.Fatalf("expected parsed date 2026-04-16, got %q", date) 161 + } 162 + }
+307
internal/ghcli/issues.go
··· 1 + package ghcli 2 + 3 + import ( 4 + "context" 5 + "encoding/json" 6 + "errors" 7 + "fmt" 8 + "net/url" 9 + "os/exec" 10 + "path" 11 + "strconv" 12 + "strings" 13 + "time" 14 + 15 + "github.com/prefapp/pad/internal/daily" 16 + ) 17 + 18 + var ErrIssueNotFound = errors.New("issue not found") 19 + 20 + type runner func(ctx context.Context, args ...string) ([]byte, error) 21 + 22 + type Client struct { 23 + run runner 24 + } 25 + 26 + type AsyncDailyIssue struct { 27 + Number int 28 + Title string 29 + Body string 30 + URL string 31 + State string 32 + Date string 33 + CreatedAt time.Time 34 + UpdatedAt time.Time 35 + } 36 + 37 + type ReportIssue = AsyncDailyIssue 38 + 39 + type issueListItem struct { 40 + Number int `json:"number"` 41 + Title string `json:"title"` 42 + URL string `json:"url"` 43 + State string `json:"state"` 44 + CreatedAt string `json:"createdAt"` 45 + UpdatedAt string `json:"updatedAt"` 46 + } 47 + 48 + type issueViewItem struct { 49 + Number int `json:"number"` 50 + Title string `json:"title"` 51 + Body string `json:"body"` 52 + URL string `json:"url"` 53 + State string `json:"state"` 54 + CreatedAt string `json:"createdAt"` 55 + UpdatedAt string `json:"updatedAt"` 56 + } 57 + 58 + func New() *Client { 59 + return &Client{run: runGH} 60 + } 61 + 62 + func newForTests(run runner) *Client { 63 + return &Client{run: run} 64 + } 65 + 66 + func (c *Client) EnsureReady(ctx context.Context) error { 67 + if _, err := exec.LookPath("gh"); err != nil { 68 + return fmt.Errorf("`gh` not found in PATH") 69 + } 70 + 71 + output, err := c.run(ctx, "auth", "status") 72 + if err != nil { 73 + return fmt.Errorf("GitHub auth is not ready: %s", strings.TrimSpace(string(output))) 74 + } 75 + 76 + return nil 77 + } 78 + 79 + func (c *Client) CreateIssue(ctx context.Context, repo, title, body string, labels []string) (daily.IssueRef, error) { 80 + args := []string{"issue", "create", "--repo", repo, "--title", title, "--body", body} 81 + for _, label := range labels { 82 + label = strings.TrimSpace(label) 83 + if label == "" { 84 + continue 85 + } 86 + 87 + args = append(args, "--label", label) 88 + } 89 + 90 + output, err := c.run(ctx, args...) 91 + if err != nil { 92 + return daily.IssueRef{}, fmt.Errorf("create GitHub issue: %s", strings.TrimSpace(string(output))) 93 + } 94 + 95 + issueURL := strings.TrimSpace(string(output)) 96 + issueNumber, err := issueNumberFromURL(issueURL) 97 + if err != nil { 98 + return daily.IssueRef{}, err 99 + } 100 + 101 + return daily.IssueRef{Number: issueNumber, URL: issueURL}, nil 102 + } 103 + 104 + func (c *Client) ListAsyncDailyIssues(ctx context.Context, repo string, labels []string, limit int) ([]AsyncDailyIssue, error) { 105 + return c.searchIssues(ctx, repo, "@me", labels, limit, "") 106 + } 107 + 108 + func (c *Client) FindAsyncDailyIssueByDate(ctx context.Context, repo string, labels []string, date string) (AsyncDailyIssue, error) { 109 + title, err := daily.TitleForDate(date) 110 + if err != nil { 111 + return AsyncDailyIssue{}, err 112 + } 113 + 114 + issues, err := c.searchIssues(ctx, repo, "@me", labels, 5, fmt.Sprintf("%q in:title", title)) 115 + if err != nil { 116 + return AsyncDailyIssue{}, err 117 + } 118 + 119 + if len(issues) == 0 { 120 + issues, err = c.searchIssues(ctx, repo, "@me", labels, 10, fmt.Sprintf("created:%s", date)) 121 + if err != nil { 122 + return AsyncDailyIssue{}, err 123 + } 124 + } 125 + 126 + for _, issue := range issues { 127 + if issue.Date != date { 128 + continue 129 + } 130 + 131 + return c.ViewIssue(ctx, repo, issue.Number) 132 + } 133 + 134 + return AsyncDailyIssue{}, ErrIssueNotFound 135 + } 136 + 137 + func (c *Client) LatestAsyncDailyIssue(ctx context.Context, repo string, labels []string) (AsyncDailyIssue, error) { 138 + issues, err := c.ListAsyncDailyIssues(ctx, repo, labels, 1) 139 + if err != nil { 140 + return AsyncDailyIssue{}, err 141 + } 142 + 143 + if len(issues) == 0 { 144 + return AsyncDailyIssue{}, ErrIssueNotFound 145 + } 146 + 147 + return c.ViewIssue(ctx, repo, issues[0].Number) 148 + } 149 + 150 + func (c *Client) ListReportIssues(ctx context.Context, repo string, limit int) ([]ReportIssue, error) { 151 + return c.searchIssues(ctx, repo, "", []string{"async-daily/report"}, limit, "") 152 + } 153 + 154 + func (c *Client) FindReportIssueByDate(ctx context.Context, repo string, date string) (ReportIssue, error) { 155 + title, err := daily.ReportTitleForDate(date) 156 + if err != nil { 157 + return ReportIssue{}, err 158 + } 159 + 160 + issues, err := c.searchIssues(ctx, repo, "", []string{"async-daily/report"}, 5, fmt.Sprintf("%q in:title", title)) 161 + if err != nil { 162 + return ReportIssue{}, err 163 + } 164 + 165 + if len(issues) == 0 { 166 + issues, err = c.searchIssues(ctx, repo, "", []string{"async-daily/report"}, 10, fmt.Sprintf("created:%s", date)) 167 + if err != nil { 168 + return ReportIssue{}, err 169 + } 170 + } 171 + 172 + for _, issue := range issues { 173 + if issue.Date != date { 174 + continue 175 + } 176 + 177 + return c.ViewIssue(ctx, repo, issue.Number) 178 + } 179 + 180 + return ReportIssue{}, ErrIssueNotFound 181 + } 182 + 183 + func (c *Client) searchIssues(ctx context.Context, repo, author string, labels []string, limit int, search string) ([]AsyncDailyIssue, error) { 184 + if limit <= 0 { 185 + limit = 100 186 + } 187 + 188 + args := []string{"issue", "list", "--repo", repo, "--state", "all", "--limit", strconv.Itoa(limit)} 189 + if strings.TrimSpace(author) != "" { 190 + args = append(args, "--author", author) 191 + } 192 + 193 + for _, label := range labels { 194 + label = strings.TrimSpace(label) 195 + if label == "" { 196 + continue 197 + } 198 + 199 + args = append(args, "--label", label) 200 + } 201 + 202 + if strings.TrimSpace(search) != "" { 203 + args = append(args, "--search", search) 204 + } 205 + 206 + args = append(args, "--json", "number,title,url,createdAt,updatedAt,state") 207 + 208 + output, err := c.run(ctx, args...) 209 + if err != nil { 210 + return nil, fmt.Errorf("list GitHub issues: %s", strings.TrimSpace(string(output))) 211 + } 212 + 213 + var raw []issueListItem 214 + if err := json.Unmarshal(output, &raw); err != nil { 215 + return nil, fmt.Errorf("decode GitHub issues: %w", err) 216 + } 217 + 218 + issues := make([]AsyncDailyIssue, 0, len(raw)) 219 + for _, item := range raw { 220 + createdAt, err := time.Parse(time.RFC3339, item.CreatedAt) 221 + if err != nil { 222 + return nil, fmt.Errorf("parse issue createdAt %q: %w", item.CreatedAt, err) 223 + } 224 + 225 + updatedAt, err := time.Parse(time.RFC3339, item.UpdatedAt) 226 + if err != nil { 227 + return nil, fmt.Errorf("parse issue updatedAt %q: %w", item.UpdatedAt, err) 228 + } 229 + 230 + issues = append(issues, AsyncDailyIssue{ 231 + Number: item.Number, 232 + Title: item.Title, 233 + URL: item.URL, 234 + State: item.State, 235 + Date: issueDate(item.Title, createdAt), 236 + CreatedAt: createdAt, 237 + UpdatedAt: updatedAt, 238 + }) 239 + } 240 + 241 + return issues, nil 242 + } 243 + 244 + func (c *Client) ViewIssue(ctx context.Context, repo string, number int) (AsyncDailyIssue, error) { 245 + output, err := c.run(ctx, "issue", "view", strconv.Itoa(number), "--repo", repo, "--json", "number,title,body,url,state,createdAt,updatedAt") 246 + if err != nil { 247 + return AsyncDailyIssue{}, fmt.Errorf("view GitHub issue: %s", strings.TrimSpace(string(output))) 248 + } 249 + 250 + var item issueViewItem 251 + if err := json.Unmarshal(output, &item); err != nil { 252 + return AsyncDailyIssue{}, fmt.Errorf("decode GitHub issue: %w", err) 253 + } 254 + 255 + createdAt, err := time.Parse(time.RFC3339, item.CreatedAt) 256 + if err != nil { 257 + return AsyncDailyIssue{}, fmt.Errorf("parse issue createdAt %q: %w", item.CreatedAt, err) 258 + } 259 + 260 + updatedAt, err := time.Parse(time.RFC3339, item.UpdatedAt) 261 + if err != nil { 262 + return AsyncDailyIssue{}, fmt.Errorf("parse issue updatedAt %q: %w", item.UpdatedAt, err) 263 + } 264 + 265 + return AsyncDailyIssue{ 266 + Number: item.Number, 267 + Title: item.Title, 268 + Body: item.Body, 269 + URL: item.URL, 270 + State: item.State, 271 + Date: issueDate(item.Title, createdAt), 272 + CreatedAt: createdAt, 273 + UpdatedAt: updatedAt, 274 + }, nil 275 + } 276 + 277 + func issueDate(title string, createdAt time.Time) string { 278 + trimmedTitle := strings.TrimSpace(title) 279 + if date, ok := daily.DateFromIssueTitle(trimmedTitle); ok { 280 + return date 281 + } 282 + 283 + if date, ok := daily.DateFromReportTitle(trimmedTitle); ok { 284 + return date 285 + } 286 + 287 + return createdAt.Format(daily.DateLayout) 288 + } 289 + 290 + func issueNumberFromURL(rawURL string) (int, error) { 291 + parsed, err := url.Parse(strings.TrimSpace(rawURL)) 292 + if err != nil { 293 + return 0, fmt.Errorf("parse issue URL: %w", err) 294 + } 295 + 296 + number, err := strconv.Atoi(path.Base(parsed.Path)) 297 + if err != nil { 298 + return 0, fmt.Errorf("parse issue number from %q: %w", rawURL, err) 299 + } 300 + 301 + return number, nil 302 + } 303 + 304 + func runGH(ctx context.Context, args ...string) ([]byte, error) { 305 + cmd := exec.CommandContext(ctx, "gh", args...) 306 + return cmd.CombinedOutput() 307 + }
+127
internal/ghcli/issues_test.go
··· 1 + package ghcli 2 + 3 + import ( 4 + "context" 5 + "strings" 6 + "testing" 7 + ) 8 + 9 + func TestListAsyncDailyIssuesKeepsLabeledIssuesAndFallsBackToCreatedDate(t *testing.T) { 10 + client := newForTests(func(_ context.Context, args ...string) ([]byte, error) { 11 + joined := strings.Join(args, " ") 12 + if !strings.Contains(joined, "issue list") { 13 + t.Fatalf("expected issue list command, got %q", joined) 14 + } 15 + 16 + if !strings.Contains(joined, "--author @me") { 17 + t.Fatalf("expected author filter, got %q", joined) 18 + } 19 + 20 + return []byte(`[ 21 + {"number":470,"title":"[Async Daily] [2026/04/16]","url":"https://example.com/470","state":"CLOSED","createdAt":"2026-04-16T08:54:39Z","updatedAt":"2026-04-16T11:08:57Z"}, 22 + {"number":9,"title":"Unrelated issue","url":"https://example.com/9","state":"OPEN","createdAt":"2026-04-16T08:54:39Z","updatedAt":"2026-04-16T11:08:57Z"} 23 + ]`), nil 24 + }) 25 + 26 + issues, err := client.ListAsyncDailyIssues(context.Background(), "prefapp/doc-asyncdaily", []string{"async-daily/member"}, 10) 27 + if err != nil { 28 + t.Fatalf("list async daily issues: %v", err) 29 + } 30 + 31 + if len(issues) != 2 { 32 + t.Fatalf("expected 2 labeled issues, got %d", len(issues)) 33 + } 34 + 35 + if issues[0].Date != "2026-04-16" { 36 + t.Fatalf("expected parsed date 2026-04-16, got %q", issues[0].Date) 37 + } 38 + 39 + if issues[1].Date != "2026-04-16" { 40 + t.Fatalf("expected createdAt fallback date 2026-04-16, got %q", issues[1].Date) 41 + } 42 + } 43 + 44 + func TestFindAsyncDailyIssueByDateLoadsIssueBody(t *testing.T) { 45 + client := newForTests(func(_ context.Context, args ...string) ([]byte, error) { 46 + joined := strings.Join(args, " ") 47 + switch { 48 + case strings.Contains(joined, "issue list"): 49 + return []byte(`[ 50 + {"number":470,"title":"[Async Daily] [2026/04/16]","url":"https://example.com/470","state":"CLOSED","createdAt":"2026-04-16T08:54:39Z","updatedAt":"2026-04-16T11:08:57Z"} 51 + ]`), nil 52 + case strings.Contains(joined, "issue view 470"): 53 + return []byte(`{"number":470,"title":"[Async Daily] [2026/04/16]","body":"remote body","url":"https://example.com/470","state":"CLOSED","createdAt":"2026-04-16T08:54:39Z","updatedAt":"2026-04-16T11:08:57Z"}`), nil 54 + default: 55 + t.Fatalf("unexpected gh command %q", joined) 56 + return nil, nil 57 + } 58 + }) 59 + 60 + issue, err := client.FindAsyncDailyIssueByDate(context.Background(), "prefapp/doc-asyncdaily", []string{"async-daily/member"}, "2026-04-16") 61 + if err != nil { 62 + t.Fatalf("find async daily issue: %v", err) 63 + } 64 + 65 + if issue.Body != "remote body" { 66 + t.Fatalf("expected remote body, got %q", issue.Body) 67 + } 68 + } 69 + 70 + func TestListReportIssuesDoesNotUseAuthorFilter(t *testing.T) { 71 + client := newForTests(func(_ context.Context, args ...string) ([]byte, error) { 72 + joined := strings.Join(args, " ") 73 + if strings.Contains(joined, "--author") { 74 + t.Fatalf("did not expect author filter, got %q", joined) 75 + } 76 + 77 + if !strings.Contains(joined, "--label async-daily/report") { 78 + t.Fatalf("expected report label filter, got %q", joined) 79 + } 80 + 81 + return []byte(`[ 82 + {"number":473,"title":"[Daily Report] 2026/04/16","url":"https://example.com/473","state":"OPEN","createdAt":"2026-04-16T11:08:51Z","updatedAt":"2026-04-16T11:08:52Z"} 83 + ]`), nil 84 + }) 85 + 86 + issues, err := client.ListReportIssues(context.Background(), "prefapp/doc-asyncdaily", 10) 87 + if err != nil { 88 + t.Fatalf("list report issues: %v", err) 89 + } 90 + 91 + if len(issues) != 1 { 92 + t.Fatalf("expected 1 report issue, got %d", len(issues)) 93 + } 94 + 95 + if issues[0].Date != "2026-04-16" { 96 + t.Fatalf("expected parsed report date 2026-04-16, got %q", issues[0].Date) 97 + } 98 + } 99 + 100 + func TestFindReportIssueByDateLoadsIssueBody(t *testing.T) { 101 + client := newForTests(func(_ context.Context, args ...string) ([]byte, error) { 102 + joined := strings.Join(args, " ") 103 + switch { 104 + case strings.Contains(joined, "issue list"): 105 + if !strings.Contains(joined, "\"[Daily Report] 2026/04/16\" in:title") { 106 + t.Fatalf("expected exact report title search, got %q", joined) 107 + } 108 + return []byte(`[ 109 + {"number":473,"title":"[Daily Report] 2026/04/16","url":"https://example.com/473","state":"OPEN","createdAt":"2026-04-16T11:08:51Z","updatedAt":"2026-04-16T11:08:52Z"} 110 + ]`), nil 111 + case strings.Contains(joined, "issue view 473"): 112 + return []byte(`{"number":473,"title":"[Daily Report] 2026/04/16","body":"team report body","url":"https://example.com/473","state":"OPEN","createdAt":"2026-04-16T11:08:51Z","updatedAt":"2026-04-16T11:08:52Z"}`), nil 113 + default: 114 + t.Fatalf("unexpected gh command %q", joined) 115 + return nil, nil 116 + } 117 + }) 118 + 119 + issue, err := client.FindReportIssueByDate(context.Background(), "prefapp/doc-asyncdaily", "2026-04-16") 120 + if err != nil { 121 + t.Fatalf("find report issue: %v", err) 122 + } 123 + 124 + if issue.Body != "team report body" { 125 + t.Fatalf("expected team report body, got %q", issue.Body) 126 + } 127 + }
+687
internal/tui/editor.go
··· 1 + package tui 2 + 3 + import ( 4 + "errors" 5 + "fmt" 6 + "strings" 7 + 8 + "github.com/charmbracelet/bubbles/textarea" 9 + "github.com/charmbracelet/bubbles/viewport" 10 + tea "github.com/charmbracelet/bubbletea" 11 + "github.com/charmbracelet/lipgloss" 12 + "github.com/prefapp/pad/internal/daily" 13 + ) 14 + 15 + var ErrCanceled = errors.New("edit canceled") 16 + 17 + const ( 18 + yesterdayField = iota 19 + todayField 20 + blockersField 21 + parkingLotField 22 + parkingLotDetailsField 23 + additionalCommentsField 24 + ) 25 + 26 + type fieldKind int 27 + 28 + const ( 29 + textField fieldKind = iota 30 + boolField 31 + ) 32 + 33 + type editorMode int 34 + 35 + const ( 36 + modeSave editorMode = iota 37 + modeCreate 38 + ) 39 + 40 + type fieldDef struct { 41 + Title string 42 + Description string 43 + Kind fieldKind 44 + Placeholder string 45 + } 46 + 47 + var fieldDefs = []fieldDef{ 48 + { 49 + Title: "✅ What did you do yesterday?", 50 + Description: "Describe what you accomplished yesterday.", 51 + Kind: textField, 52 + Placeholder: "- Reviewed PR #123\n- Finished API changes", 53 + }, 54 + { 55 + Title: "🎯 What will you do today?", 56 + Description: "Outline your plans for today.", 57 + Kind: textField, 58 + Placeholder: "- Continue feature work\n- Write documentation", 59 + }, 60 + { 61 + Title: "🚧 Any blockers?", 62 + Description: "Optional. Mention obstacles you are facing.", 63 + Kind: textField, 64 + Placeholder: "- Waiting for code review\n- Need clarification on scope", 65 + }, 66 + { 67 + Title: "🚨 Request a Parking Lot or escalation?", 68 + Description: "Toggle this on when you need escalation or want to add a topic to the Parking Lot.", 69 + Kind: boolField, 70 + }, 71 + { 72 + Title: "📝 Parking Lot Details", 73 + Description: "Only used when escalation is enabled.", 74 + Kind: textField, 75 + Placeholder: "- Need clarification on API contract changes", 76 + }, 77 + { 78 + Title: "💬 Additional Comments", 79 + Description: "Optional extra notes or context for the team.", 80 + Kind: textField, 81 + Placeholder: "- Offline after 17:00\n- Waiting for design confirmation", 82 + }, 83 + } 84 + 85 + var ( 86 + headerStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("86")) 87 + paneStyle = lipgloss.NewStyle().Border(lipgloss.NormalBorder()).BorderForeground(lipgloss.Color("240")).Padding(1) 88 + paneTitleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("212")) 89 + currentFieldStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("81")) 90 + mutedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("244")) 91 + errorStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("203")) 92 + confirmStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("214")) 93 + helpTextStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("252")) 94 + navKeyStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("81")) 95 + actionKeyStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("42")) 96 + previewKeyStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("214")) 97 + cancelKeyStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("203")) 98 + secondaryKeyStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("141")) 99 + helpDividerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240")) 100 + statusFilledStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("42")) 101 + statusEmptyStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("244")) 102 + statusDisabledStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240")) 103 + ) 104 + 105 + type model struct { 106 + mode editorMode 107 + entry daily.Entry 108 + index int 109 + editor textarea.Model 110 + preview viewport.Model 111 + width int 112 + height int 113 + message string 114 + messageIsError bool 115 + confirm bool 116 + submitted bool 117 + canceled bool 118 + result daily.Entry 119 + } 120 + 121 + func Edit(entry daily.Entry) (daily.Entry, error) { 122 + return run(entry, modeSave) 123 + } 124 + 125 + func EditForCreate(entry daily.Entry) (daily.Entry, error) { 126 + return run(entry, modeCreate) 127 + } 128 + 129 + func run(entry daily.Entry, mode editorMode) (daily.Entry, error) { 130 + program := tea.NewProgram(newModel(entry, mode), tea.WithAltScreen()) 131 + 132 + finalModel, err := program.Run() 133 + if err != nil { 134 + return daily.Entry{}, err 135 + } 136 + 137 + final, ok := finalModel.(model) 138 + if !ok { 139 + return daily.Entry{}, fmt.Errorf("unexpected tea model type %T", finalModel) 140 + } 141 + 142 + if final.canceled { 143 + return daily.Entry{}, ErrCanceled 144 + } 145 + 146 + if !final.submitted { 147 + return daily.Entry{}, fmt.Errorf("editor exited without completing the action") 148 + } 149 + 150 + return final.result, nil 151 + } 152 + 153 + func newModel(entry daily.Entry, mode editorMode) model { 154 + editor := textarea.New() 155 + editor.ShowLineNumbers = false 156 + editor.Prompt = "" 157 + editor.CharLimit = 0 158 + editor.SetWidth(40) 159 + editor.SetHeight(8) 160 + 161 + preview := viewport.New(40, 8) 162 + 163 + m := model{ 164 + mode: mode, 165 + entry: entry.Normalize(), 166 + index: yesterdayField, 167 + editor: editor, 168 + preview: preview, 169 + width: 120, 170 + height: 32, 171 + } 172 + m.syncEditor() 173 + m.resizePanes() 174 + m.refreshPreview() 175 + return m 176 + } 177 + 178 + func (m model) Init() tea.Cmd { 179 + return textarea.Blink 180 + } 181 + 182 + func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { 183 + switch msg := msg.(type) { 184 + case tea.WindowSizeMsg: 185 + m.width = msg.Width 186 + m.height = msg.Height 187 + m.resizePanes() 188 + m.refreshPreview() 189 + return m, nil 190 + 191 + case tea.KeyMsg: 192 + if m.confirm { 193 + return m.updateConfirmation(msg) 194 + } 195 + 196 + switch msg.String() { 197 + case "ctrl+c", "esc": 198 + m.canceled = true 199 + return m, tea.Quit 200 + case "ctrl+s": 201 + return m.handlePrimaryAction() 202 + case "tab": 203 + m.move(1) 204 + return m, textarea.Blink 205 + case "shift+tab": 206 + m.move(-1) 207 + return m, textarea.Blink 208 + case "pgup", "pgdown": 209 + var cmd tea.Cmd 210 + m.preview, cmd = m.preview.Update(msg) 211 + return m, cmd 212 + } 213 + 214 + if m.currentField().Kind == boolField { 215 + switch msg.String() { 216 + case " ", "enter": 217 + m.entry.ParkingLot = !m.entry.ParkingLot 218 + m.refreshPreview() 219 + return m, nil 220 + } 221 + 222 + return m, nil 223 + } 224 + } 225 + 226 + if m.currentField().Kind != textField { 227 + return m, nil 228 + } 229 + 230 + var cmd tea.Cmd 231 + m.editor, cmd = m.editor.Update(msg) 232 + m.persistCurrentField() 233 + m.refreshPreview() 234 + return m, cmd 235 + } 236 + 237 + func (m model) updateConfirmation(msg tea.KeyMsg) (tea.Model, tea.Cmd) { 238 + switch strings.ToLower(msg.String()) { 239 + case "ctrl+c": 240 + m.canceled = true 241 + return m, tea.Quit 242 + case "esc", "n": 243 + m.confirm = false 244 + return m, nil 245 + case "y", "enter": 246 + entry := m.finalEntry() 247 + if err := entry.ValidateForCreate(); err != nil { 248 + m.message = err.Error() 249 + m.messageIsError = true 250 + m.confirm = false 251 + m.refreshPreview() 252 + return m, nil 253 + } 254 + 255 + m.result = entry 256 + m.submitted = true 257 + return m, tea.Quit 258 + default: 259 + return m, nil 260 + } 261 + } 262 + 263 + func (m model) handlePrimaryAction() (tea.Model, tea.Cmd) { 264 + entry := m.finalEntry() 265 + if m.mode == modeSave { 266 + m.result = entry 267 + m.submitted = true 268 + return m, tea.Quit 269 + } 270 + 271 + if err := entry.ValidateForCreate(); err != nil { 272 + m.message = err.Error() 273 + m.messageIsError = true 274 + m.refreshPreview() 275 + return m, nil 276 + } 277 + 278 + m.message = "" 279 + m.messageIsError = false 280 + m.confirm = true 281 + m.refreshPreview() 282 + return m, nil 283 + } 284 + 285 + func (m model) View() string { 286 + left := paneStyle.Width(m.leftPaneWidth()).Height(m.leftPaneHeight()).Render(m.leftPaneView()) 287 + right := paneStyle.Width(m.rightPaneWidth()).Height(m.rightPaneHeight()).Render(m.rightPaneView()) 288 + 289 + headerLines := []string{ 290 + headerStyle.Render(fmt.Sprintf("pad %s %s", m.actionTitle(), m.entry.Date)), 291 + } 292 + if m.entry.Source != "" { 293 + headerLines = append(headerLines, mutedStyle.Render("Source: "+m.entry.Source)) 294 + } 295 + 296 + content := []string{ 297 + lipgloss.JoinVertical(lipgloss.Left, headerLines...), 298 + m.bodyView(left, right), 299 + m.footerView(), 300 + } 301 + 302 + return lipgloss.JoinVertical(lipgloss.Left, content...) 303 + } 304 + 305 + func (m model) bodyView(left, right string) string { 306 + if m.splitLayout() { 307 + return lipgloss.JoinHorizontal(lipgloss.Top, left, right) 308 + } 309 + 310 + return lipgloss.JoinVertical(lipgloss.Left, left, right) 311 + } 312 + 313 + func (m model) leftPaneView() string { 314 + fieldLines := make([]string, 0, len(fieldDefs)) 315 + for index, def := range fieldDefs { 316 + prefix := " " 317 + titleStyle := mutedStyle 318 + if index == m.index { 319 + prefix = "> " 320 + titleStyle = currentFieldStyle 321 + } 322 + 323 + fieldLines = append(fieldLines, fmt.Sprintf("%s%s %s", prefix, titleStyle.Render(def.Title), m.fieldStatus(index))) 324 + } 325 + 326 + current := m.currentField() 327 + editingBlock := []string{ 328 + paneTitleStyle.Render("Template"), 329 + mutedStyle.Render("Fill the async-daily template on the left. The right pane updates live."), 330 + "", 331 + strings.Join(fieldLines, "\n"), 332 + "", 333 + paneTitleStyle.Render("Editing"), 334 + currentFieldStyle.Render(current.Title), 335 + mutedStyle.Render(current.Description), 336 + "", 337 + } 338 + 339 + if current.Kind == boolField { 340 + value := "No" 341 + if m.entry.ParkingLot { 342 + value = "Yes" 343 + } 344 + editingBlock = append(editingBlock, 345 + fmt.Sprintf("Current value: %s", currentFieldStyle.Render(value)), 346 + mutedStyle.Render("Press space or enter to toggle this field."), 347 + ) 348 + } else { 349 + editingBlock = append(editingBlock, m.editor.View()) 350 + } 351 + 352 + return lipgloss.JoinVertical(lipgloss.Left, editingBlock...) 353 + } 354 + 355 + func (m model) rightPaneView() string { 356 + return lipgloss.JoinVertical( 357 + lipgloss.Left, 358 + paneTitleStyle.Render("Live Preview"), 359 + mutedStyle.Render("Use pgup/pgdown when the preview is longer than the screen."), 360 + "", 361 + m.preview.View(), 362 + ) 363 + } 364 + 365 + func (m model) footerView() string { 366 + lines := make([]string, 0, 2) 367 + if m.message != "" { 368 + style := mutedStyle 369 + if m.messageIsError { 370 + style = errorStyle 371 + } 372 + lines = append(lines, style.Render(m.message)) 373 + } 374 + 375 + if m.confirm { 376 + lines = append(lines, lipgloss.JoinHorizontal( 377 + lipgloss.Top, 378 + confirmStyle.Render(fmt.Sprintf("Create GitHub issue for %s? ", m.entry.Date)), 379 + helpItem(actionKeyStyle, "enter/y", "confirm"), 380 + helpDividerStyle.Render(" • "), 381 + helpItem(secondaryKeyStyle, "n", "go back"), 382 + helpDividerStyle.Render(" • "), 383 + helpItem(cancelKeyStyle, "esc", "go back"), 384 + )) 385 + return lipgloss.JoinVertical(lipgloss.Left, lines...) 386 + } 387 + 388 + primaryKeyStyle := actionKeyStyle 389 + primaryDescription := "save" 390 + if m.mode == modeCreate { 391 + primaryDescription = "create" 392 + } 393 + 394 + lines = append(lines, lipgloss.JoinHorizontal( 395 + lipgloss.Top, 396 + helpItem(navKeyStyle, "tab", "next field"), 397 + helpDividerStyle.Render(" • "), 398 + helpItem(navKeyStyle, "shift+tab", "previous field"), 399 + helpDividerStyle.Render(" • "), 400 + helpItem(primaryKeyStyle, "ctrl+s", primaryDescription), 401 + helpDividerStyle.Render(" • "), 402 + helpItem(previewKeyStyle, "pgup/pgdn", "scroll preview"), 403 + helpDividerStyle.Render(" • "), 404 + helpItem(cancelKeyStyle, "esc", "cancel"), 405 + )) 406 + 407 + return lipgloss.JoinVertical(lipgloss.Left, lines...) 408 + } 409 + 410 + func helpItem(keyStyle lipgloss.Style, key, description string) string { 411 + return keyStyle.Render(key) + helpTextStyle.Render(" "+description) 412 + } 413 + 414 + func (m model) actionTitle() string { 415 + if m.mode == modeCreate { 416 + return "Create Async Daily" 417 + } 418 + 419 + return "Edit Draft" 420 + } 421 + 422 + func (m *model) move(step int) { 423 + m.persistCurrentField() 424 + m.index = nextVisibleIndex(m.index, step, m.entry.ParkingLot) 425 + m.syncEditor() 426 + m.refreshPreview() 427 + } 428 + 429 + func (m *model) syncEditor() { 430 + if m.currentField().Kind != textField { 431 + m.editor.Blur() 432 + return 433 + } 434 + 435 + m.editor.Focus() 436 + m.editor.Placeholder = m.currentField().Placeholder 437 + m.editor.SetValue(m.storedTextValue(m.index)) 438 + m.resizeEditor() 439 + } 440 + 441 + func (m *model) resizePanes() { 442 + m.resizeEditor() 443 + m.preview.Width = m.previewWidth() 444 + m.preview.Height = m.previewHeight() 445 + } 446 + 447 + func (m *model) resizeEditor() { 448 + width := m.leftPaneWidth() - 6 449 + if width < 20 { 450 + width = 20 451 + } 452 + 453 + height := m.leftPaneHeight() - 16 454 + if height < 6 { 455 + height = 6 456 + } 457 + 458 + m.editor.SetWidth(width) 459 + m.editor.SetHeight(height) 460 + } 461 + 462 + func (m *model) refreshPreview() { 463 + content := previewContent(m.finalEntry()) 464 + if m.preview.Width > 0 { 465 + content = lipgloss.NewStyle().Width(m.preview.Width).Render(content) 466 + } 467 + m.preview.SetContent(content) 468 + } 469 + 470 + func previewContent(entry daily.Entry) string { 471 + title, err := entry.Title() 472 + if err != nil { 473 + title = entry.Date 474 + } 475 + 476 + return fmt.Sprintf("%s\n\n%s", title, entry.Body()) 477 + } 478 + 479 + func (m *model) persistCurrentField() { 480 + if m.currentField().Kind != textField { 481 + return 482 + } 483 + 484 + m.setTextValue(m.index, m.editor.Value()) 485 + } 486 + 487 + func (m model) finalEntry() daily.Entry { 488 + entry := m.entry 489 + if m.currentField().Kind == textField { 490 + switch m.index { 491 + case yesterdayField: 492 + entry.Yesterday = m.editor.Value() 493 + case todayField: 494 + entry.Today = m.editor.Value() 495 + case blockersField: 496 + entry.Blockers = m.editor.Value() 497 + case parkingLotDetailsField: 498 + entry.ParkingLotDetails = m.editor.Value() 499 + case additionalCommentsField: 500 + entry.AdditionalComments = m.editor.Value() 501 + } 502 + } 503 + 504 + if !entry.ParkingLot { 505 + entry.ParkingLotDetails = "" 506 + } 507 + 508 + return entry.Normalize() 509 + } 510 + 511 + func (m model) currentField() fieldDef { 512 + return fieldDefs[m.index] 513 + } 514 + 515 + func (m model) fieldStatus(index int) string { 516 + var status string 517 + var style lipgloss.Style 518 + 519 + switch index { 520 + case parkingLotField: 521 + if m.entry.ParkingLot { 522 + status = "[yes]" 523 + style = statusFilledStyle 524 + } else { 525 + status = "[no]" 526 + style = statusEmptyStyle 527 + } 528 + return style.Render(status) 529 + case parkingLotDetailsField: 530 + if !m.entry.ParkingLot { 531 + return statusDisabledStyle.Render("[disabled]") 532 + } 533 + } 534 + 535 + if strings.TrimSpace(m.textValue(index)) == "" { 536 + return statusEmptyStyle.Render("[empty]") 537 + } 538 + 539 + return statusFilledStyle.Render("[filled]") 540 + } 541 + 542 + func (m model) textValue(index int) string { 543 + if index == m.index && m.currentField().Kind == textField { 544 + return m.editor.Value() 545 + } 546 + 547 + return m.storedTextValue(index) 548 + } 549 + 550 + func (m model) storedTextValue(index int) string { 551 + 552 + switch index { 553 + case yesterdayField: 554 + return m.entry.Yesterday 555 + case todayField: 556 + return m.entry.Today 557 + case blockersField: 558 + return m.entry.Blockers 559 + case parkingLotDetailsField: 560 + return m.entry.ParkingLotDetails 561 + case additionalCommentsField: 562 + return m.entry.AdditionalComments 563 + default: 564 + return "" 565 + } 566 + } 567 + 568 + func (m *model) setTextValue(index int, value string) { 569 + switch index { 570 + case yesterdayField: 571 + m.entry.Yesterday = value 572 + case todayField: 573 + m.entry.Today = value 574 + case blockersField: 575 + m.entry.Blockers = value 576 + case parkingLotDetailsField: 577 + m.entry.ParkingLotDetails = value 578 + case additionalCommentsField: 579 + m.entry.AdditionalComments = value 580 + } 581 + } 582 + 583 + func (m model) splitLayout() bool { 584 + return m.width >= 80 585 + } 586 + 587 + func (m model) leftPaneWidth() int { 588 + if !m.splitLayout() { 589 + width := m.width - 4 590 + if width < 30 { 591 + width = 30 592 + } 593 + return width 594 + } 595 + 596 + width := (m.width - 1) / 2 597 + if width < 30 { 598 + width = 30 599 + } 600 + return width 601 + } 602 + 603 + func (m model) rightPaneWidth() int { 604 + if !m.splitLayout() { 605 + width := m.width - 4 606 + if width < 30 { 607 + width = 30 608 + } 609 + return width 610 + } 611 + 612 + width := m.width - m.leftPaneWidth() - 1 613 + if width < 30 { 614 + width = 30 615 + } 616 + return width 617 + } 618 + 619 + func (m model) previewWidth() int { 620 + width := m.rightPaneWidth() - 4 621 + if width < 16 { 622 + width = 16 623 + } 624 + return width 625 + } 626 + 627 + func (m model) previewHeight() int { 628 + height := m.rightPaneHeight() - 5 629 + if height < 8 { 630 + height = 8 631 + } 632 + return height 633 + } 634 + 635 + func (m model) leftPaneHeight() int { 636 + if !m.splitLayout() { 637 + height := (m.height - 6) / 2 638 + if height < 14 { 639 + height = 14 640 + } 641 + return height 642 + } 643 + 644 + height := m.height - 5 645 + if height < 14 { 646 + height = 14 647 + } 648 + return height 649 + } 650 + 651 + func (m model) rightPaneHeight() int { 652 + if !m.splitLayout() { 653 + height := m.height - m.leftPaneHeight() - 6 654 + if height < 14 { 655 + height = 14 656 + } 657 + return height 658 + } 659 + 660 + height := m.height - 5 661 + if height < 14 { 662 + height = 14 663 + } 664 + return height 665 + } 666 + 667 + func nextVisibleIndex(current, step int, parkingLot bool) int { 668 + candidate := current + step 669 + 670 + // Wrap around boundaries 671 + if candidate < 0 { 672 + candidate = len(fieldDefs) - 1 673 + } else if candidate >= len(fieldDefs) { 674 + candidate = 0 675 + } 676 + 677 + // Skip parking lot details if disabled 678 + if candidate == parkingLotDetailsField && !parkingLot { 679 + // Continue in same direction, but prevent infinite loop 680 + if step == 0 { 681 + step = 1 682 + } 683 + return nextVisibleIndex(candidate, step, parkingLot) 684 + } 685 + 686 + return candidate 687 + }
+110
internal/tui/editor_test.go
··· 1 + package tui 2 + 3 + import ( 4 + "strings" 5 + "testing" 6 + 7 + "github.com/prefapp/pad/internal/daily" 8 + ) 9 + 10 + func TestNextVisibleIndexWrapsForwardFromLastField(t *testing.T) { 11 + lastField := len(fieldDefs) - 1 12 + next := nextVisibleIndex(lastField, 1, false) 13 + if next != 0 { 14 + t.Fatalf("expected wrap to field 0 from last field, got %d", next) 15 + } 16 + } 17 + 18 + func TestNextVisibleIndexWrapsBackwardFromFirstField(t *testing.T) { 19 + next := nextVisibleIndex(0, -1, false) 20 + lastField := len(fieldDefs) - 1 21 + if next != lastField { 22 + t.Fatalf("expected wrap to field %d from first field, got %d", lastField, next) 23 + } 24 + } 25 + 26 + func TestNextVisibleIndexSkipsParkingLotDetailsWhenDisabledForward(t *testing.T) { 27 + next := nextVisibleIndex(parkingLotField, 1, false) 28 + if next != additionalCommentsField { 29 + t.Fatalf("expected skip to field %d, got %d", additionalCommentsField, next) 30 + } 31 + } 32 + 33 + func TestNextVisibleIndexSkipsParkingLotDetailsWhenDisabledBackward(t *testing.T) { 34 + next := nextVisibleIndex(additionalCommentsField, -1, false) 35 + if next != parkingLotField { 36 + t.Fatalf("expected skip back to field %d, got %d", parkingLotField, next) 37 + } 38 + } 39 + 40 + func TestNextVisibleIndexIncludesParkingLotDetailsWhenEnabled(t *testing.T) { 41 + next := nextVisibleIndex(parkingLotField, 1, true) 42 + if next != parkingLotDetailsField { 43 + t.Fatalf("expected next field %d, got %d", parkingLotDetailsField, next) 44 + } 45 + } 46 + 47 + func TestFinalEntryClearsParkingLotDetailsWhenDisabled(t *testing.T) { 48 + m := newModel(daily.Entry{ 49 + Date: "2026-04-16", 50 + ParkingLot: false, 51 + ParkingLotDetails: "should be cleared", 52 + }, modeSave) 53 + 54 + entry := m.finalEntry() 55 + if entry.ParkingLotDetails != "" { 56 + t.Fatalf("expected parking lot details to be cleared, got %q", entry.ParkingLotDetails) 57 + } 58 + } 59 + 60 + func TestFinalEntryDoesNotMutateParkingLotDetailsInModel(t *testing.T) { 61 + m := newModel(daily.Entry{ 62 + Date: "2026-04-16", 63 + ParkingLot: false, 64 + ParkingLotDetails: "keep me during editing", 65 + }, modeCreate) 66 + 67 + _ = m.finalEntry() 68 + if m.entry.ParkingLotDetails != "keep me during editing" { 69 + t.Fatalf("expected editor state to keep parking lot details, got %q", m.entry.ParkingLotDetails) 70 + } 71 + } 72 + 73 + func TestPreviewContentContainsRenderedTemplate(t *testing.T) { 74 + content := previewContent(daily.Entry{ 75 + Date: "2026-04-16", 76 + Yesterday: "- Reviewed PR #42", 77 + Today: "- Continue feature work", 78 + }) 79 + 80 + checks := []string{ 81 + "[Async Daily] [2026/04/16]", 82 + "## ✅ What did you do yesterday?", 83 + "## 🎯 What will you do today?", 84 + } 85 + 86 + for _, check := range checks { 87 + if !strings.Contains(content, check) { 88 + t.Fatalf("expected preview content to contain %q, got %q", check, content) 89 + } 90 + } 91 + } 92 + 93 + func TestMoveLoadsStoredTextForEachField(t *testing.T) { 94 + m := newModel(daily.Entry{Date: "2026-04-16"}, modeCreate) 95 + m.editor.SetValue("- first field text") 96 + m.persistCurrentField() 97 + 98 + m.move(1) 99 + if got := m.editor.Value(); got != "" { 100 + t.Fatalf("expected next field editor to start empty, got %q", got) 101 + } 102 + 103 + m.editor.SetValue("- second field text") 104 + m.persistCurrentField() 105 + 106 + m.move(-1) 107 + if got := m.editor.Value(); got != "- first field text" { 108 + t.Fatalf("expected previous field text to be restored, got %q", got) 109 + } 110 + }
+20
justfile
··· 1 + set shell := ["bash", "-euo", "pipefail", "-c"] 2 + 3 + _default: 4 + just --list 5 + 6 + build: 7 + go build ./... 8 + 9 + test: 10 + go test ./... 11 + 12 + release-tag version: 13 + version="{{version}}"; \ 14 + if [[ ! "$version" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then \ 15 + echo "version must look like 0.1.0 or v0.1.0" >&2; \ 16 + exit 1; \ 17 + fi; \ 18 + version="${version#v}"; \ 19 + git tag "v${version}"; \ 20 + git push origin "v${version}"
+17
main.go
··· 1 + package main 2 + 3 + import ( 4 + "fmt" 5 + "os" 6 + 7 + "github.com/prefapp/pad/cmd" 8 + ) 9 + 10 + var version = "dev" 11 + 12 + func main() { 13 + if err := cmd.NewRootCmd(version).Execute(); err != nil { 14 + fmt.Fprintln(os.Stderr, err) 15 + os.Exit(1) 16 + } 17 + }