Skip to content

feat: Nightly news generation script and GitHub Actions workflow#344

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/document-article-enhancement-workflow
Closed

feat: Nightly news generation script and GitHub Actions workflow#344
Copilot wants to merge 2 commits intomainfrom
copilot/document-article-enhancement-workflow

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Automates daily article generation from Swedish Riksdag/Government data: queries MCP for documents published in the last 24 hours, applies a ≥5 document threshold per type to suppress empty articles on low-activity days, generates all 14 language versions, and refreshes indexes/sitemap.

New: scripts/generate-daily-news.js

Four-stage pipeline reusing existing generate-news-enhanced.js generators:

Stage Description
Discovery search_dokument with 24h lookback for prop, mot, bet
Threshold Skip types with < N new docs (default 5, --force to override)
Generation Delegates to existing per-type generators → 14 languages
Post-process Runs index + sitemap scripts as child processes
# Manual dry-run to see what would generate
node scripts/generate-daily-news.js --dry-run --lookback-hours=48 --threshold=3

# Full run, all languages
npm run generate-daily-news -- --languages=all

Key behaviours:

  • Exits 0 even on MCP unavailability (cold starts, outages) — scheduled workflow stays green on quiet days
  • Week-ahead article always queued regardless of threshold
  • Writes news/metadata/daily-generation-status.json for downstream workflow inspection

New: .github/workflows/nightly-news-generation.yml

  • Cron: 0 1 * * * (01:00 UTC = 02:00 CET winter / 03:00 CEST summer)
  • workflow_dispatch exposes all pipeline knobs: languages, threshold, lookback_hours, force_generate, dry_run
  • Creates PR via peter-evans/create-pull-request only when articles are actually written
  • SHA-pinned actions, step-security/harden-runner with egress audit, least-privilege permissions (contents: write, pull-requests: write)
  • Uploads generation artifacts (30-day retention), writes step summary with document counts
Original prompt

This section details on the original issue you should resolve

<issue_title>Document Article Enhancement Workflow and MCP Integration Patterns</issue_title>
<issue_description># 📋 Issue Type
Documentation / Knowledge Management

🎯 Objective

Create comprehensive documentation of the article enhancement workflow, MCP integration patterns, and content generation best practices based on the successful completion of Issues #306-334.

📊 Current State

Gap: While enhancement was successful, there's no consolidated documentation for:

  • Step-by-step workflow for enhancing news articles
  • MCP tool usage patterns and examples
  • Content quality standards and templates
  • Translation workflow for 14 languages
  • Common pitfalls and solutions

Scattered Information: Knowledge exists across:

🚀 Desired State

Create ARTICLE_ENHANCEMENT_GUIDE.md with:

  • 📋 Workflow Overview: Step-by-step process
  • 🔧 MCP Integration: Tool examples and patterns
  • ✍️ Content Standards: Quality checklist, word counts, structure
  • 🌐 Translation Workflow: 14-language process
  • 🎯 Quality Assurance: Validation steps
  • 💡 Best Practices: Lessons learned
  • ⚠️ Common Pitfalls: Issues and solutions

🔧 Documentation Structure

1. Workflow Overview

## Article Enhancement Workflow

### Phase 1: Data Collection (MCP)
1. Identify document IDs from article HTML
2. Fetch full details via riksdag-regering-get_dokument
3. Get supplementary data (committee, author, voting)
4. Validate data completeness

### Phase 2: Content Generation
1. Analyze document content and political context
2. Generate 150-400 word analysis per document
3. Create cross-cutting thematic analysis
4. Write "What to Watch" forward-looking section
5. Generate content-based title and description

### Phase 3: Multi-Language Translation
1. Start with Swedish (source language)
2. Translate to English for global audience
3. Translate to all 14 languages using guides
4. Validate RTL layouts (Arabic, Hebrew)

### Phase 4: Quality Validation
1. HTML validation (HTMLHint)
2. Link checking (all document URLs)
3. Accessibility (WCAG 2.1 AA)
4. SEO validation (unique titles, meta tags)

2. MCP Integration Patterns

## Riksdag-Regering MCP Tools

### Tool: get_dokument
**Purpose**: Fetch full document details
**Example**:
```javascript
riksdag-regering-get_dokument({
  dok_id: "HD01SkU19",
  include_full_text: true
})

Returns: title, summary, proposer, status, committee, full text
Use when: Need complete document information for analysis

Tool: get_utskott

Purpose: Get committee information
Example:

riksdag-regering-get_utskott()

Returns: All committee names, abbreviations, jurisdictions
Use when: Need full committee names and context

[Document all 32 MCP tools with examples]


### 3. Content Quality Standards
- Document analysis: 150-400 words
- Political context: Party positions, coalition dynamics
- Stakeholder impact: Who's affected, how
- Timeline: Chamber debate dates, voting schedule
- Title: 50-60 characters, content-specific
- Description: 150-160 characters, policy areas mentioned

### 4. Translation Best Practices
- Use translation guides for consistency
- Nordic languages first (SV, DA, NO) - similar to source
- RTL support for Arabic and Hebrew
- Validate character limits per language
- Complete UI localization (navigation, buttons)

## ✅ Acceptance Criteria
- [ ] **ARTICLE_ENHANCEMENT_GUIDE.md** created
- [ ] **Workflow section** with step-by-step process
- [ ] **MCP tools documented** with examples for all 32 tools
- [ ] **Quality standards** clearly defined
- [ ] **Translation workflow** documented
- [ ] **Best practices** section with lessons learned
- [ ] **Common pitfalls** section with solutions
- [ ] **Referenced from README.md**

## 📚 References
- **Successful PRs**: Hack23/riksdagsmonitor#307, Hack23/riksdagsmonitor#312, Hack23/riksdagsmonitor#313, Hack23/riksdagsmonitor#314, Hack23/riksdagsmonitor#326, Hack23/riksdagsmonitor#333, Hack23/riksdagsmonitor#334
- **Scripts**: `scripts/enhance-2026-02-19-articles.py`, `scripts/generate-content-based-titles.py`
- **MCP Config**: `.github/copilot-mcp.json`
- **Issue templates**: Hack23/riksdagsmonitor#306-311
- **Repository memories**: Article enhancement patterns

## 🤖 Recommended Agent
**documentation-architect**

## 📝 Notes
**Value**: Enables future article generation to follow proven patterns, reducing errors and improving consistency. Critical for onboarding new contributors or when automating article generation.

**Timeline**: 2-3 days</issue_descriptio...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes Hack23/riksdagsmonitor#339

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

- Add scripts/generate-daily-news.js: queries riksdag-regering MCP for
  new documents (last 24 hours), groups by type, generates articles when
  ≥5 documents exist, creates 14-language versions, updates indexes and sitemap
- Add .github/workflows/nightly-news-generation.yml: runs at 01:00 UTC
  (02:00 CET winter / 03:00 CEST summer) daily, creates automated PR with
  generated articles, supports manual trigger with configurable options
- Add generate-daily-news npm script to package.json

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title [WIP] Document article enhancement workflow and MCP integration patterns feat: Nightly news generation script and GitHub Actions workflow Feb 19, 2026
Copilot AI requested a review from pethers February 19, 2026 17:26
@pethers pethers closed this Feb 19, 2026
@pethers pethers deleted the copilot/document-article-enhancement-workflow branch February 19, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants