Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ data-pipeline:
- changed-files:
- any-glob-to-any-file:
- ".github/workflows/data-pipeline.yml"
- "scripts/pipeline-*.js"
- "scripts/fetch-*.js"
- "scripts/validate-*.js"
- title: "pipeline:*"
Expand Down Expand Up @@ -176,7 +175,6 @@ i18n:
- "sitemap_*.xml"
- "news/**/*_*.html"
- "TRANSLATION_GUIDE.md"
- "scripts/extract-vocabulary.js"
- title: "i18n:*"
- title: "localization:*"
- title: "l10n:*"
Expand Down
60 changes: 46 additions & 14 deletions .github/workflows/SHARED_PROMPT_PATTERNS.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,29 +371,56 @@ Scripts MUST NEVER generate any of these — this is the AI agent's exclusive re

The following script directories and functions previously generated analysis content and are now **DEPRECATED** — their analysis functions are replaced by AI agent analysis in workflow prompts:

> ⚠️ **IMPORTANT DISTINCTION**: The table below lists **analysis-generating** functions that are deprecated. The **HTML rendering** functions (`generateSwotSection()`, `generateDashboardSection()`, `generateMindmapSection()`) are **NOT deprecated** — they are active HTML renderers that take structured data and produce formatted HTML sections. AI agents produce analysis content in markdown files; scripts then render that content into HTML using these renderer functions. See §HTML RENDERER FUNCTIONS below.

| Directory/Function | Status | Replacement |
|-----------|--------|-------------|
| `scripts/ai-analysis/` | ⚠️ DEPRECATED for analysis generation | AI agent performs analysis per workflow prompts |
| `scripts/analysis-framework/` | ⚠️ DEPRECATED for analysis generation | AI agent uses methodology guides directly |
| `scripts/data-transformers/content-generators/ai-swot-analyzer.ts` | ⚠️ DEPRECATED | AI agent generates SWOT per political-swot-framework.md |
| `scripts/data-transformers/content-generators/stakeholder-swot-section.ts` | ⚠️ DEPRECATED | AI agent generates stakeholder analysis per stakeholder-impact.md |
| `scripts/generate-news-enhanced/ai-analysis-pipeline.ts` → `buildDynamicSwot()` | ⚠️ DEPRECATED | AI prompt: "Generate SWOT for all 8 stakeholder groups with dok_id evidence" |
| `scripts/generate-news-enhanced/ai-analysis-pipeline.ts` → `buildStrategicImplications()` | ⚠️ DEPRECATED | AI prompt: "Write strategic implications citing specific policy signals" |
| `scripts/generate-news-enhanced/ai-analysis-pipeline.ts` → `buildKeyTakeaways()` | ⚠️ DEPRECATED | AI prompt: "Extract 5 key takeaways with confidence levels" |
| `scripts/generate-news-enhanced/ai-analysis-pipeline.ts` → `buildLegislativeImpact()` | ⚠️ DEPRECATED | AI prompt: "Assess legislative impact using committee + vote data" |
| `scripts/generate-news-enhanced/ai-analysis-pipeline.ts` → `buildCrossPartyImplications()` | ⚠️ DEPRECATED | AI prompt: "Analyze cross-party dynamics from voting records" |
| `scripts/generate-news-enhanced/swot-analyzer.ts` | ⚠️ DEPRECATED | AI agent generates SWOT per political-swot-framework.md |
| `scripts/data-transformers/content-generators/index.ts` → `generateStakeholderSwotSection()` | ⚠️ DEPRECATED | AI agent generates stakeholder analysis per stakeholder-impact.md |
| `scripts/generate-news-enhanced/ai-analysis-pipeline.ts` → `AIAnalysisPipeline` class | ⚠️ DEPRECATED | AI agent performs the primary analysis; class still runs as a deprecated/stub runtime pipeline |
| `scripts/data-transformers/content-generators/shared.ts` → `generateDeepAnalysisSection()` | ⚠️ DEPRECATED | AI prompt: "Write 5W deep analysis (Who/What/When/Why/Winners)" |
| `scripts/data-transformers/content-generators/shared.ts` → `generateTimelineContext()` | 🔴 REMOVED | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific timeline analysis |
| `scripts/data-transformers/content-generators/shared.ts` → `broadAgendaText()`, `focusedAgendaText()`, `defaultWhyText()` | 🔴 REMOVED | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific "Why This Matters" analysis |
| `scripts/data-transformers/content-generators/shared.ts` → `genericImpactText()`, `propImpactText()`, `betImpactText()`, `motImpactText()` | 🔴 REMOVED | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific political impact analysis |
| `scripts/data-transformers/content-generators/shared.ts` → `genericConsequencesText()`, `propConsequencesText()`, `motConsequencesText()` | 🔴 REMOVED | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific consequences analysis |
| `scripts/data-transformers/content-generators/shared.ts` → `defaultCriticalText()` | 🔴 REMOVED | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific critical assessment |
| `scripts/editorial-pillars.ts` → `INTER_PILLAR_TRANSITIONS` | 🔴 REMOVED | Transitions now empty — AI MUST write article-specific connective prose or omit |
| `scripts/data-transformers/content-generators/newsworthiness.ts` → `scoreNewsworthiness()` | ⚠️ DEPRECATED | AI prompt: "Score newsworthiness 0-100 with dimension breakdown" |
| `scripts/data-transformers/content-generators/shared.ts` → `generateTimelineContext()` | 🔴 STUB | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific timeline analysis |
| `scripts/data-transformers/content-generators/shared.ts` → `broadAgendaText()`, `focusedAgendaText()`, `defaultWhyText()` | 🔴 STUB | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific "Why This Matters" analysis |
| `scripts/data-transformers/content-generators/shared.ts` → `genericImpactText()`, `propImpactText()`, `betImpactText()`, `motImpactText()` | 🔴 STUB | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific political impact analysis |
| `scripts/data-transformers/content-generators/shared.ts` → `genericConsequencesText()`, `propConsequencesText()`, `motConsequencesText()` | 🔴 STUB | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific consequences analysis |
| `scripts/data-transformers/content-generators/shared.ts` → `defaultCriticalText()` | 🔴 STUB | Now outputs `AI_MUST_REPLACE` marker — AI MUST write specific critical assessment |
| `scripts/editorial-pillars.ts` → `INTER_PILLAR_TRANSITIONS` | 🔴 EMPTY | Transitions now return empty strings — AI MUST write article-specific connective prose or omit |
| `scripts/data-transformers/content-generators/newsworthiness.ts` → `scoreNewsworthiness()` | ✅ ACTIVE (data utility) | Heuristic scoring retained for routing/experimentation/tests; AI MUST independently assess editorial significance |
| `scripts/data-transformers/content-generators/shared.ts` → all `*Text()` templates | ⚠️ DEPRECATED | AI prompt: "Write editorial analysis from actual document data" |

**These scripts may still be called for data downloading and HTML formatting functions**, but their analysis output (SWOT entries, risk scores, classifications, titles, descriptions, editorial judgments) MUST be treated as stubs that the AI agent MUST overwrite with real template-compliant analysis.

#### HTML Renderer Functions (NOT Deprecated — Active Utilities)

The following functions are **HTML renderers**, not analysis generators. They take structured data and produce formatted HTML. They are used by `generate-news-enhanced` to build article sections and are **actively maintained**:

| Function | Module | Purpose | AI Agent Relationship |
|----------|--------|---------|----------------------|
| `generateSwotSection({ data, lang })` | `swot-section.ts` | Renders SWOT quadrant HTML from `SwotData` | **Current implementation:** AI writes SWOT analysis in markdown → script reads it → extracts SWOT data → calls this function to render HTML |
| `generateDashboardSection({ data, lang })` | `dashboard-section.ts` | Renders Chart.js canvas HTML from chart config | Renderer utility: used when structured chart data is provided by the pipeline; automatic extraction from AI analysis markdown is not currently implemented as a standard flow |
| `generateMindmapSection({ topic, branches, lang })` | `mindmap-section.ts` | Renders CSS mindmap HTML from branch data | Renderer utility: used when structured mindmap branch data is provided by the pipeline; analysis-to-mindmap extraction is workflow-specific or future-facing |
| `generateMultiPanelDashboardSection(...)` | `dashboard-section.ts` | Renders multi-panel CSS dashboards | Renderer utility for pre-structured panel data; not a guaranteed current markdown-extraction path |
| `generateEconomicDashboardSection(...)` | `economic-dashboard-section.ts` | Renders economic indicator dashboard | Renderer utility for structured economic dashboard data when available; automated extraction from agent analysis should be treated as planned or workflow-specific unless separately implemented |

> **How AI agents interact with these**: AI agents do NOT call these TypeScript functions directly. These utilities are renderers only. Unless a specific workflow explicitly implements and validates a machine-readable input format, `generate-news-enhanced` should be treated as consuming final article HTML/section-ready content rather than generically extracting SWOT entries, chart data, or mindmap structures from markdown analysis files. Currently, only SWOT data extraction from analysis markdown is implemented as a standard flow. Workflow authors MUST NOT assume a supported structured-parse step exists for dashboard, mindmap, or other renderer inputs; if a renderer is used, the workflow must explicitly define how its input data is produced and validated.

#### Minor TypeScript/Script Corrections Policy

> **Agentic workflows MAY make minor corrections** to TypeScript code and scripts when necessary to complete their mission, but MUST use AI prompts for all important analysis and content creation.

| Allowed Minor Corrections | Prohibited Changes |
|--------------------------|-------------------|
| Fix broken file paths or import statements | Rewrite analysis-generating logic |
| Correct typos in template strings | Add new analysis functions |
| Fix date format bugs in scripts | Change article quality thresholds |
| Update stale configuration values | Modify editorial framework scoring |
| Fix syntax errors blocking article generation | Change MCP tool invocation patterns |
| Adjust HTML template structure for validation | Remove or bypass quality gates |

**Rule**: If a correction affects analysis content quality, it MUST be done via AI prompt analysis — not by editing TypeScript code.

---

## 🏆 AI ANALYSIS QUALITY HIERARCHY — AI Always Wins
Expand Down Expand Up @@ -1321,6 +1348,9 @@ Before generating articles, consult these skills:
7. **`scripts/prompts/v2/political-analysis.md`** — Core political analysis framework (6 analytical lenses)
8. **`scripts/prompts/v2/stakeholder-perspectives.md`** — Multi-perspective analysis instructions
9. **`scripts/prompts/v2/quality-criteria.md`** — Quality self-assessment rubric (minimum 7/10)
10. **`scripts/prompts/v2/per-file-intelligence-analysis.md`** — Per-file AI analysis protocol
11. **`analysis/methodologies/ai-driven-analysis-guide.md`** — Master methodology guide (v5.0): analysis-driven article decisions, policy domain inference, empty analysis fallback, Election 2026 lens
12. **`analysis/templates/per-file-political-intelligence.md`** — Per-file analysis output template (SWOT, risk matrix, threat taxonomy, Mermaid diagrams)
```

## 🧠 Repo Memory — Persistent Cross-Workflow Context (copy into every workflow)
Expand Down Expand Up @@ -2124,6 +2154,8 @@ Read these methodology documents to guide your analysis:
- **`analysis/templates/stakeholder-impact.md`** — Stakeholder impact template
- **`analysis/templates/significance-scoring.md`** — Significance scoring template
- **`scripts/prompts/v2/per-file-intelligence-analysis.md`** — Detailed analysis prompt
- **`analysis/templates/per-file-political-intelligence.md`** — Per-file analysis output template (SWOT, risk, threat, Mermaid)
- **`analysis/methodologies/ai-driven-analysis-guide.md`** — Master methodology guide (v5.0)

#### Protocol
1. **Catalog:** Run `npx tsx scripts/catalog-downloaded-data.ts --pending-only` to list files needing analysis
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/news-evening-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ Every analysis MUST include an **Election 2026 Implications** section assessing:

### Phase 1 — Data Collection & Initial Analysis
1. Fetch today's activity from MCP (`search_anforanden` — filter by `datum`, `get_betankanden` — filter by `publicerad`, `search_voteringar` — filter by `datum`, `get_sync_status`)
2. Score newsworthiness of each item using `scoreNewsworthiness()` logic
2. Assess newsworthiness of each item using AI analysis (score 0-100 with dimension breakdown: political significance, public impact, timeliness, unexpectedness)
3. Build initial outline: day-in-review lede, top stories, votes summary, tonight's context

### Phase 2 — Depth Enhancement (for `deep`/`comprehensive` depth)
1. **Quick SWOT**: 1-paragraph SWOT overview of the day's political balance
2. **Activity Dashboard**: Generate `generateDashboardSection()` with ≥1 chart (today's activity breakdown)
2. **Activity Dashboard**: Include a concise activity breakdown by type/party as a Markdown table or bullet list; do not assume an automatic dashboard rendering step unless a workflow-specific validated input format is defined.
3. **Quality Gate**:
- Verify article covers events from today's date (not yesterday or tomorrow)
- Verify all Swedish API text is translated
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/news-interpellations.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Every analysis MUST include an **Election 2026 Implications** section assessing:
### Phase 2 — Iterative Depth Enhancement (repeat per `analysis_depth`)
For each AI iteration:
1. **SWOT Analysis**: Generate multi-stakeholder SWOT with ALL 8 groups (Citizens, Government Coalition, Opposition Bloc, Business/Industry, Civil Society, International/EU, Judiciary/Constitutional, Media/Public Opinion). Use structured evidence tables with columns: `#`, `Statement`, `Evidence (frs ID/dok_id)`, `Confidence`, `Impact`, `Entry Date`. Every entry MUST cite specific interpellation frs ID, minister name, and policy area.
2. **Accountability Dashboard**: Generate `generateDashboardSection()` with ≥1 chart (interpellations by minister or party)
2. **Accountability Dashboard**: Include at least one chart-ready summary (interpellations by minister or party), formatted as a clear Markdown table or bullet list; do not assume automatic dashboard rendering unless a separate workflow step explicitly parses and renders it.
3. **Quality Gate** (check before next iteration):
Comment on lines 257 to 259
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dashboard step asks the agent to emit “chart data” and asserts the script will render it, but the workflow doesn’t define the chart data schema or the integration step that converts agent output into a dashboard section. Please add an explicit machine-readable format + parsing/validation step, or reword to avoid implying an implemented render pipeline.

Copilot uses AI. Check for mistakes.
- Verify ministerial accountability section names specific ministers and their policy areas
- Verify no identical "Why It Matters" text across entries — each must reference the specific minister and policy context
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/news-month-ahead.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ Every analysis MUST include an **Election 2026 Implications** section assessing:
### Phase 2 — Iterative Depth Enhancement (repeat per `analysis_depth`)
For each AI iteration:
1. **Full SWOT Analysis**: Generate multi-stakeholder SWOT with ALL 8 groups (Citizens, Government Coalition, Opposition Bloc, Business/Industry, Civil Society, International/EU, Judiciary/Constitutional, Media/Public Opinion) focusing on upcoming legislative priorities. Use structured evidence tables with columns: `#`, `Statement`, `Evidence (dok_id)`, `Confidence`, `Impact`, `Entry Date`. Every entry MUST cite specific scheduled debate, committee meeting, or expected vote.
2. **Strategic Dashboard**: Generate `generateDashboardSection()` with ≥2 charts (documents by week, policy domain distribution)
3. **Policy Mindmap**: Generate `generateMindmapSection()` showing inter-connected policy areas
2. **Strategic Dashboard Summary**: Provide concise comparative summaries for at least 2 analytical views (for example, documents by week and policy domain distribution) using prose and/or markdown tables that can be included directly in the article without requiring any undocumented rendering pipeline.
3. **Policy Relationship Outline**: Describe inter-connected policy areas as a clear hierarchical outline (central topic, major branches, and sub-items) in standard markdown so the relationships are explicit without assuming automated mindmap rendering.
4. **Quality Gate** (check before next iteration):
- Verify forward-looking watch-points reference specific scheduled events
- Verify all Swedish API text is translated
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/news-monthly-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ Every analysis MUST include an **Election 2026 Implications** section assessing:

### Phase 2 — Iterative Depth Enhancement (3 iterations for `deep`/`comprehensive`)
For each AI iteration:
1. **Full SWOT**: Generate `generateSwotSection()` with ≥5 stakeholder perspectives per quadrant (government coalition, opposition parties, affected citizens, EU/Nordic context, media/civil society, business sector, academic/think-tanks)
2. **Monthly Dashboard**: Generate `generateEconomicDashboardSection()` with ≥4 charts (monthly trends, party activity ranking, policy domain heatmap, legislative pipeline)
3. **Policy Mindmap**: Generate `generateMindmapSection()` showing the month's cross-cutting policy themes
4. **Stakeholder SWOT**: Generate `generateStakeholderSwotSection()` with ≥7 perspectives for comprehensive depth
1. **Full SWOT**: Write a clearly structured SWOT analysis with ≥5 stakeholder perspectives per quadrant (government coalition, opposition parties, affected citizens, EU/Nordic context, media/civil society, business sector, academic/think-tanks). Format it as publication-ready markdown with explicit `Strengths`, `Weaknesses`, `Opportunities`, and `Threats` headings.
2. **Monthly Dashboard Summary**: Provide a dashboard-style analytical summary covering at least 4 evidence-based views: monthly trends, party activity ranking, policy domain heatmap summary, and legislative pipeline status. Present the underlying figures and comparisons directly in markdown text and bullet lists or tables; do not assume any machine-readable chart schema or automatic rendering step.
3. **Policy Theme Map**: Describe the month's cross-cutting policy themes as a hierarchical outline with one central theme and clearly labelled subthemes. Use readable markdown headings or nested bullet lists rather than implying a structured mindmap payload or CSS-rendered component.
4. **Stakeholder SWOT**: Write a stakeholder-focused SWOT with ≥7 perspectives for comprehensive depth, and cite specific `dok_id` evidence for each entry.
5. **Quality Gate** (check before next iteration):
- Verify trend comparison uses actual previous-month data from MCP
- Verify party rankings section covers all 8 Riksdag parties
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/news-motions.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Every analysis MUST include an **Election 2026 Implications** section assessing:
### Phase 2 — Iterative Depth Enhancement (repeat per `analysis_depth`)
For each AI iteration:
1. **SWOT Analysis**: Generate multi-stakeholder SWOT with ALL 8 groups (Citizens, Government Coalition, Opposition Bloc, Business/Industry, Civil Society, International/EU, Judiciary/Constitutional, Media/Public Opinion). Use structured evidence tables with columns: `#`, `Statement`, `Evidence (mot. ID/dok_id)`, `Confidence`, `Impact`, `Entry Date`. Every entry MUST cite specific motion number, party origin, and policy area.
2. **Coalition Dashboard**: Generate `generateDashboardSection()` with ≥1 chart (party motion count)
2. **Coalition Dashboard**: Include at least one chart-ready summary in the article output (for example, party motion counts or thematic distribution), formatted as a clear Markdown table or bullet list; do not assume automatic dashboard rendering unless a separate workflow step explicitly parses and renders it.
3. **Quality Gate** (check before next iteration):
- Verify opposition strategy section is substantive (not just party counts)
- Verify no identical "Why It Matters" text across entries
Expand Down
Loading
Loading