Skip to content

fix: purge deprecated code/scripts, clarify agentic workflow prompts, and update SHARED_PROMPT_PATTERNS.md#1699

Merged
pethers merged 5 commits intomainfrom
copilot/purge-deprecated-code-and-test
Apr 12, 2026
Merged

fix: purge deprecated code/scripts, clarify agentic workflow prompts, and update SHARED_PROMPT_PATTERNS.md#1699
pethers merged 5 commits intomainfrom
copilot/purge-deprecated-code-and-test

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

Purges unused scripts and orphaned production code, updates agentic workflow prompts to remove misleading function-call-style instructions, and clarifies SHARED_PROMPT_PATTERNS.md to accurately document the current analysis/rendering pipeline.

Deleted Files (14 scripts/types + 11 tests)

Standalone scripts with no workflow/import references

  • scripts/generate-news-backport.ts — only in package.json, never invoked
  • scripts/fix-old-articles-branding.ts — one-time migration, completed
  • scripts/fix-keywords-localization.ts — one-time fix, completed
  • scripts/extract-vocabulary.ts — standalone utility, unreferenced

Production code only consumed by its own tests

  • scripts/pipeline/ (4 files) — orchestrator/validation/types never imported by production code
  • scripts/deep-inspection/index.ts — never imported by production code
  • scripts/workflow-state-coordinator.ts — never imported by production code
  • scripts/party-variants.ts — never imported by production code
  • scripts/government-role-validator.ts — never imported by production code

Orphaned type files

  • scripts/types/party.ts — only consumer was deleted party-variants.ts
  • scripts/types/workflow.ts — only consumer was deleted workflow-state-coordinator.ts

Agentic Workflow Prompt Fixes

SHARED_PROMPT_PATTERNS.md

  • Corrected deprecated functions table: fixed file paths, clarified AIAnalysisPipeline runtime role, scoped scoreNewsworthiness() description
  • HTML Renderer table: scoped SWOT as the only currently implemented extraction flow; dashboard/mindmap/multi-panel/economic renderers labeled as utilities requiring explicit structured data input
  • Added script-corrections policy section

9 Workflow .md files updated

Replaced "provide chart data / define mindmap structure — the script renders" language with accurate descriptions that do not imply an implemented render pipeline for non-SWOT renderers:

  • news-weekly-review.md, news-week-ahead.md, news-realtime-monitor.md, news-propositions.md, news-motions.md, news-month-ahead.md, news-monthly-review.md, news-interpellations.md, news-evening-analysis.md

v2 Prompt Reference Docs

  • swot-generation.md and political-analysis.md: marked buildSwotFromDocs code snippets as pseudocode

Cleanup

  • Removed generate-news-backport from package.json scripts
  • Cleaned stale patterns from knip.json and .github/labeler.yml
  • Moved template-sections.test.ts to tests/ root

Verification

  • TypeScript build: ✅ clean
  • All tests: ✅ 91 files, 3871 tests pass
  • Code review: ✅
  • CodeQL: ✅

… workflow prompts with AI-driven analysis instructions

- Updated SHARED_PROMPT_PATTERNS.md: clarified distinction between deprecated analysis generators and active HTML renderer functions, added HTML Renderer Functions table, added Minor TypeScript/Script Corrections Policy section, extended Shared Skill Block with per-file-intelligence-analysis.md, ai-driven-analysis-guide.md, and templates
- Updated 8 news workflow .md files: replaced all 'Generate generateSwotSection()/generateDashboardSection()/generateMindmapSection()' call-style patterns with clear AI-driven analysis instructions
- Updated scripts/prompts/v2 references: added clarifying notes that HTML renderers are script-side, not AI-callable

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/9e0dc1aa-65fc-4722-a2a4-b19bb162fb37

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions github-actions bot added documentation Documentation updates workflow GitHub Actions workflows ci-cd CI/CD pipeline changes refactor Code refactoring news News articles and content generation agentic-workflow Agentic workflow changes size-m Medium change (50-250 lines) labels Apr 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🏷️ Automatic Labeling Summary

This PR has been automatically labeled based on the files changed and PR metadata.

Applied Labels: documentation,workflow,ci-cd,refactor,size-m,news,agentic-workflow

Label Categories

  • 🗳️ Content: news, dashboard, visualization, intelligence
  • 💻 Technology: html-css, javascript, workflow, security
  • 📊 Data: cia-data, riksdag-data, data-pipeline, schema
  • 🌍 I18n: i18n, translation, rtl
  • 🔒 ISMS: isms, iso-27001, nist-csf, cis-controls
  • 🏗️ Infrastructure: ci-cd, deployment, performance, monitoring
  • 🔄 Quality: testing, accessibility, documentation, refactor
  • 🤖 AI: agent, skill, agentic-workflow

For more information, see .github/labeler.yml.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copilot AI requested a review from pethers April 12, 2026 21:31
@pethers pethers marked this pull request as ready for review April 12, 2026 21:34
Copilot AI review requested due to automatic review settings April 12, 2026 21:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR cleans up agentic workflow prompt text and shared workflow guidance to remove misleading “function-call-like” instructions, clarifying that AI agents write analysis in markdown while scripts perform HTML rendering.

Changes:

  • Replaced prompt language like “Generate generateSwotSection()/generateDashboardSection()/generateMindmapSection()” with instructions to write analysis + provide structured inputs that scripts render.
  • Updated SHARED_PROMPT_PATTERNS.md to distinguish deprecated analysis generators vs active HTML renderer utilities and to add a script-corrections policy.
  • Added clarifying notes in v2 prompt reference docs describing script-side rendering flow.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/prompts/v2/swot-generation.md Adds an explicit note that generateSwotSection() is script-side and not AI-invoked.
scripts/prompts/v2/political-analysis.md Clarifies that generateSwotSection() is an HTML renderer called by scripts, not AI agents.
.github/workflows/SHARED_PROMPT_PATTERNS.md Refines deprecated-function guidance; adds an HTML renderer table and a minor script-corrections policy; extends referenced skills/templates.
.github/workflows/news-weekly-review.md Replaces deprecated function-call phrasing with “write/provide/define” instructions for SWOT/dashboard/mindmap.
.github/workflows/news-week-ahead.md Updates dashboard instruction to request chart data for script rendering.
.github/workflows/news-realtime-monitor.md Updates activity chart instruction to request chart data for script rendering.
.github/workflows/news-propositions.md Replaces function-call phrasing with explicit AI outputs + script rendering notes.
.github/workflows/news-motions.md Updates dashboard instruction to request chart data for script rendering.
.github/workflows/news-monthly-review.md Replaces SWOT/dashboard/mindmap function-call phrasing; updates stakeholder SWOT instruction to be AI-written.
.github/workflows/news-month-ahead.md Updates dashboard/mindmap instructions to request structured inputs for script rendering.
.github/workflows/news-interpellations.md Updates dashboard instruction to request chart data for script rendering.
.github/workflows/news-evening-analysis.md Replaces scoreNewsworthiness() mention with AI-based scoring; updates dashboard instruction to request chart data for script rendering.

Comment on lines 380 to 381
| `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 |
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.

The table references scripts/data-transformers/content-generators/ai-swot-analyzer.ts, but that file does not exist in the repo. Update this entry to point to the actual module (e.g. scripts/generate-news-enhanced/swot-analyzer.ts) or remove the row to avoid broken guidance.

Suggested change
| `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/swot-analyzer.ts` | ⚠️ DEPRECATED | AI agent generates SWOT per political-swot-framework.md |

Copilot uses AI. Check for mistakes.
| `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 |
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 row references scripts/data-transformers/content-generators/stakeholder-swot-section.ts, but the module is not present under scripts/data-transformers/content-generators/. If the intent is to document the current stubbed generateStakeholderSwotSection, point to its actual location (currently implemented as a stub in scripts/data-transformers/content-generators/index.ts).

Suggested change
| `scripts/data-transformers/content-generators/stakeholder-swot-section.ts` | ⚠️ DEPRECATED | AI agent generates stakeholder analysis per stakeholder-impact.md |
| `scripts/data-transformers/content-generators/index.ts``generateStakeholderSwotSection()` | ⚠️ DEPRECATED | AI agent generates stakeholder analysis per stakeholder-impact.md |

Copilot uses AI. Check for mistakes.
| `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/ai-analysis-pipeline.ts` → `AIAnalysisPipeline` class | ⚠️ DEPRECATED | AI agent performs all analysis; class retained only for type definitions |
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.

The AIAnalysisPipeline entry says the class is “retained only for type definitions”, but it is still instantiated and executed in scripts/generate-news-enhanced/generators.ts (pipeline.analyze). Please adjust the wording to reflect its current runtime role (even if its analysis output is considered deprecated/stub).

Suggested change
| `scripts/generate-news-enhanced/ai-analysis-pipeline.ts``AIAnalysisPipeline` class | ⚠️ DEPRECATED | AI agent performs all analysis; class retained only for type definitions |
| `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 |

Copilot uses AI. Check for mistakes.
| `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 still used by scripts; AI SHOULD also independently assess newsworthiness |
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 row claims scoreNewsworthiness() is “still used by scripts”, but there are no in-repo runtime call sites (only the function definition/exports and unit tests). Consider rewording to accurately describe current usage (e.g., retained for routing/experimentation/tests) and keep the note that it’s deprecated for editorial significance assessment.

Suggested change
| `scripts/data-transformers/content-generators/newsworthiness.ts``scoreNewsworthiness()` | ✅ ACTIVE (data utility) | Heuristic scoring still used by scripts; AI SHOULD also independently assess newsworthiness |
| `scripts/data-transformers/content-generators/newsworthiness.ts``scoreNewsworthiness()` | ✅ ACTIVE (data utility) | Heuristic scoring retained for routing/experimentation/tests; AI MUST independently assess editorial significance |

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 12, 2026

@copilot apply changes based on the comments in this thread

…eprecated functions table

- Fix ai-swot-analyzer.ts path to scripts/generate-news-enhanced/swot-analyzer.ts
- Fix stakeholder-swot-section.ts to actual location in index.ts
- Fix AIAnalysisPipeline description: still runs as deprecated/stub runtime pipeline
- Fix scoreNewsworthiness description: retained for routing/experimentation/tests

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/fb6a6cc1-6af8-43fc-add9-798d2b873756

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 12, 2026

@copilot apply changes based on the comments in this thread

Applied all 4 review comments in 85fb18d:

  1. Fixed ai-swot-analyzer.ts path → scripts/generate-news-enhanced/swot-analyzer.ts (verified file exists)
  2. Fixed stakeholder-swot-section.tsscripts/data-transformers/content-generators/index.tsgenerateStakeholderSwotSection() (actual stub location)
  3. Fixed AIAnalysisPipeline description: "class still runs as a deprecated/stub runtime pipeline" (confirmed it's instantiated in generators.ts:2045)
  4. Fixed scoreNewsworthiness() description: "retained for routing/experimentation/tests; AI MUST independently assess editorial significance" (confirmed no runtime call sites beyond exports/tests)

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment on lines +401 to +407
| `generateSwotSection({ data, lang })` | `swot-section.ts` | Renders SWOT quadrant HTML from `SwotData` | AI writes SWOT analysis in markdown → script reads it → calls this function to render HTML |
| `generateDashboardSection({ data, lang })` | `dashboard-section.ts` | Renders Chart.js canvas HTML from chart config | AI provides chart data in analysis → script calls this to render chart containers |
| `generateMindmapSection({ topic, branches, lang })` | `mindmap-section.ts` | Renders CSS mindmap HTML from branch data | AI defines mindmap structure in analysis → script renders it as interactive HTML |
| `generateMultiPanelDashboardSection(...)` | `dashboard-section.ts` | Renders multi-panel CSS dashboards | AI provides panel data → script renders the full dashboard |
| `generateEconomicDashboardSection(...)` | `economic-dashboard-section.ts` | Renders economic indicator dashboard | AI provides economic data → script renders comparative charts |

> **How AI agents interact with these**: AI agents do NOT call these TypeScript functions directly. Instead, AI agents write rich analysis content (SWOT entries, chart data, mindmap structures) in their analysis markdown files. The `generate-news-enhanced` script reads the analysis, extracts the structured data, and calls these renderer functions to produce the final HTML article sections.
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 section says AI supplies chart data and the script “reads the analysis, extracts the structured data” for dashboards/mindmaps. In the current code, scripts/analysis-reader.ts parses classification/risk/SWOT/etc. but not dashboard/mindmap structures, and scripts/generate-news-enhanced/generators.ts uses stubbed analyzeDashboardData() (returns empty charts/tables). Please either (1) scope this guidance to SWOT-only, (2) document the actual extraction mechanism/location for dashboard+mindmap data, or (3) rephrase as a future/aspirational capability.

Suggested change
| `generateSwotSection({ data, lang })` | `swot-section.ts` | Renders SWOT quadrant HTML from `SwotData` | AI writes SWOT analysis in markdown → script reads it → calls this function to render HTML |
| `generateDashboardSection({ data, lang })` | `dashboard-section.ts` | Renders Chart.js canvas HTML from chart config | AI provides chart data in analysis → script calls this to render chart containers |
| `generateMindmapSection({ topic, branches, lang })` | `mindmap-section.ts` | Renders CSS mindmap HTML from branch data | AI defines mindmap structure in analysis → script renders it as interactive HTML |
| `generateMultiPanelDashboardSection(...)` | `dashboard-section.ts` | Renders multi-panel CSS dashboards | AI provides panel data → script renders the full dashboard |
| `generateEconomicDashboardSection(...)` | `economic-dashboard-section.ts` | Renders economic indicator dashboard | AI provides economic data → script renders comparative charts |
> **How AI agents interact with these**: AI agents do NOT call these TypeScript functions directly. Instead, AI agents write rich analysis content (SWOT entries, chart data, mindmap structures) in their analysis markdown files. The `generate-news-enhanced` script reads the analysis, extracts the structured data, and calls these renderer functions to produce the final HTML article sections.
| `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 documented here as a standard implemented 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. In the current documented flow, AI agents write rich analysis content and the pipeline extracts **SWOT-style structured data** before calling the relevant renderer. Other renderer functions in this table remain available HTML utilities, but dashboard, mindmap, multi-panel, and economic dashboard extraction from analysis markdown should be treated as requiring explicit pipeline support rather than assumed as a universally implemented capability.

Copilot uses AI. Check for mistakes.
Comment on lines +401 to +407
| `generateSwotSection({ data, lang })` | `swot-section.ts` | Renders SWOT quadrant HTML from `SwotData` | AI writes SWOT analysis in markdown → script reads it → calls this function to render HTML |
| `generateDashboardSection({ data, lang })` | `dashboard-section.ts` | Renders Chart.js canvas HTML from chart config | AI provides chart data in analysis → script calls this to render chart containers |
| `generateMindmapSection({ topic, branches, lang })` | `mindmap-section.ts` | Renders CSS mindmap HTML from branch data | AI defines mindmap structure in analysis → script renders it as interactive HTML |
| `generateMultiPanelDashboardSection(...)` | `dashboard-section.ts` | Renders multi-panel CSS dashboards | AI provides panel data → script renders the full dashboard |
| `generateEconomicDashboardSection(...)` | `economic-dashboard-section.ts` | Renders economic indicator dashboard | AI provides economic data → script renders comparative charts |

> **How AI agents interact with these**: AI agents do NOT call these TypeScript functions directly. Instead, AI agents write rich analysis content (SWOT entries, chart data, mindmap structures) in their analysis markdown files. The `generate-news-enhanced` script reads the analysis, extracts the structured data, and calls these renderer functions to produce the final HTML article sections.
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.

The statement that agents “write rich analysis content (… mindmap structures) in their analysis markdown files” and generate-news-enhanced then renders it implies the pipeline consumes those markdown structures. If the intended flow is “AI writes final HTML/sections in the article content” (instead of structured extraction), clarify that here to prevent workflow authors from assuming a supported structured-parse step that doesn’t exist yet.

Suggested change
| `generateSwotSection({ data, lang })` | `swot-section.ts` | Renders SWOT quadrant HTML from `SwotData` | AI writes SWOT analysis in markdown → script reads it → calls this function to render HTML |
| `generateDashboardSection({ data, lang })` | `dashboard-section.ts` | Renders Chart.js canvas HTML from chart config | AI provides chart data in analysis → script calls this to render chart containers |
| `generateMindmapSection({ topic, branches, lang })` | `mindmap-section.ts` | Renders CSS mindmap HTML from branch data | AI defines mindmap structure in analysis → script renders it as interactive HTML |
| `generateMultiPanelDashboardSection(...)` | `dashboard-section.ts` | Renders multi-panel CSS dashboards | AI provides panel data → script renders the full dashboard |
| `generateEconomicDashboardSection(...)` | `economic-dashboard-section.ts` | Renders economic indicator dashboard | AI provides economic data → script renders comparative charts |
> **How AI agents interact with these**: AI agents do NOT call these TypeScript functions directly. Instead, AI agents write rich analysis content (SWOT entries, chart data, mindmap structures) in their analysis markdown files. The `generate-news-enhanced` script reads the analysis, extracts the structured data, and calls these renderer functions to produce the final HTML article sections.
| `generateSwotSection({ data, lang })` | `swot-section.ts` | Renders SWOT quadrant HTML from `SwotData` | Use only when a workflow already supplies validated `SwotData`; do not assume free-form markdown SWOT notes are auto-parsed |
| `generateDashboardSection({ data, lang })` | `dashboard-section.ts` | Renders Chart.js canvas HTML from chart config | Use only when chart config is explicitly produced in a supported machine-readable format; analysis prose alone is not a chart input contract |
| `generateMindmapSection({ topic, branches, lang })` | `mindmap-section.ts` | Renders CSS mindmap HTML from branch data | Use only when a workflow explicitly provides `topic` and `branches`; markdown bullet trees or “mindmap” prose are not automatically extracted by default |
| `generateMultiPanelDashboardSection(...)` | `dashboard-section.ts` | Renders multi-panel CSS dashboards | Use only with explicitly prepared panel data; this does not imply a generic markdown-to-dashboard parser |
| `generateEconomicDashboardSection(...)` | `economic-dashboard-section.ts` | Renders economic indicator dashboard | Use only with explicitly prepared economic data; renderer availability does not mean narrative analysis is auto-converted into comparative charts |
> **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. Workflow authors MUST NOT assume a supported structured-parse step exists for arbitrary markdown; if a renderer is used, the workflow must explicitly define how its input data is produced and validated.

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 12, 2026

@copilot apply changes based on the comments in this thread

…rent extraction capabilities

- SWOT renderer: clarified as current implemented extraction flow
- Dashboard/Mindmap/MultiPanel/Economic renderers: clarified as utilities requiring explicit structured data, not automatic markdown extraction
- Updated guidance note: only SWOT extraction is standard; other renderers need explicit pipeline support

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/a5646b0e-f78a-45f1-bfd9-2cc5a5678cd1

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 12, 2026

@copilot apply changes based on the comments in this thread

Applied both review comments in d06c70f:

  • SWOT renderer row now explicitly states "Current implementation" with the full extraction flow
  • Dashboard, Mindmap, MultiPanel, and Economic renderers clarified as utilities requiring explicit structured data — no assumption of automatic markdown extraction
  • Guidance note rewritten: only SWOT extraction is a standard implemented flow; workflow authors must not assume structured-parse steps exist for other renderers

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 12, 2026

Both review comments from that thread were already applied in d06c70f:

  1. HTML Renderer table now scopes SWOT as the only currently implemented extraction flow; dashboard/mindmap/multi-panel/economic renderers are labeled as utilities requiring explicit structured data input
  2. Guidance note rewritten to state "Workflow authors MUST NOT assume a supported structured-parse step exists" for non-SWOT renderers — no implied generic markdown extraction

All 93 workflow architecture tests pass.

Deleted 15 unused script/type files:
- scripts/generate-news-backport.ts (standalone, no workflow usage)
- scripts/fix-old-articles-branding.ts (one-time migration, unused)
- scripts/fix-keywords-localization.ts (one-time fix, unused)
- scripts/extract-vocabulary.ts (standalone utility, unused)
- scripts/check-banned-patterns.ts (CLI only, no workflow usage)
- scripts/pipeline/ (index, orchestrator, types, validation — only used by own tests)
- scripts/deep-inspection/index.ts (only used by own tests)
- scripts/workflow-state-coordinator.ts (only used by own tests)
- scripts/party-variants.ts (only used by test files)
- scripts/government-role-validator.ts (only used by test file)
- scripts/types/party.ts (orphaned after party-variants deletion)
- scripts/types/workflow.ts (orphaned after workflow-state-coordinator deletion)

Deleted 12 test files for deleted code.
Moved template-sections.test.ts to tests/ root (tests article template, not pipeline).
Cleaned package.json, knip.json, labeler.yml references.

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/af8d54c4-a19d-4873-a480-48028eb2f521

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions github-actions bot added dependencies Dependency updates testing Test coverage size-xl Extra large change (> 1000 lines) labels Apr 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 44 out of 44 changed files in this pull request and generated 12 comments.

Comment on lines 76 to 80
"generate-sitemap-html": "npx tsx scripts/generate-sitemap-html.ts",
"generate-rss": "npx tsx scripts/generate-rss.ts",
"generate-news-backport": "node scripts/generate-news-backport.ts",

"htmlhint": "sh -c 'htmlhint *.html; set -- news/*.html; if [ -e \"$1\" ]; then htmlhint \"$@\"; else echo \"No news/*.html files to lint\"; fi'",
"lint": "eslint .",
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 PR deletes scripts/check-banned-patterns.ts, but scripts/validate-news-generation.sh still executes npx tsx scripts/check-banned-patterns.ts … (Check 15). That will make the validation step fail in content workflows. Either keep/replace that CLI, or update the shell validator to call the new implementation (or inline detectBannedPatterns + AI_MUST_REPLACE detection) so validate-news-generation.sh continues to work.

Copilot uses AI. Check for mistakes.
Comment on lines 9 to +12
**Always prefer pre-computed SWOT data** from `analysis/daily/YYYY-MM-DD/swot-analysis.md` over inline generation.

> **Note**: The code below shows the **script-side** flow. AI agents do NOT call `generateSwotSection()` directly. Instead, AI agents write SWOT analysis content in markdown — the script reads the analysis and calls this HTML renderer function to produce the article section.

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 new note claims the script reads SWOT markdown and calls generateSwotSection(), but the example snippet later in this document uses a fallback buildSwotFromDocs(docs, lang) which does not exist in the codebase. Consider either (1) updating the note/snippet to match the actual implemented pipeline, or (2) explicitly marking the snippet as pseudocode so workflow authors don’t rely on non-existent APIs.

Copilot uses AI. Check for mistakes.
Comment on lines 97 to +101
### Step 3: Use Pre-Computed SWOT

When `analysis.swot` is available, pass it directly to `generateSwotSection()`:
> **Note**: The `generateSwotSection()` function is an HTML renderer used by the article generation script. AI agents do NOT call this function directly. Instead, AI agents write SWOT analysis in markdown files — the script reads the analysis and calls this function to render HTML.

When `analysis.swot` is available, the script passes it directly to `generateSwotSection()`:
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 note says the script reads SWOT markdown and renders via generateSwotSection(), but the example immediately below falls back to buildSwotFromDocs(docs, lang), which does not exist anywhere in the repo. Please align the documentation with an actual implementation (or clearly mark the fallback as pseudocode) to avoid sending workflow authors toward a non-existent API.

Copilot uses AI. Check for mistakes.
Comment on lines +210 to +212
1. **Condensed SWOT**: Write SWOT analysis with ≥3 stakeholder perspectives on the week's balance of power — the script renders this as an interactive SWOT section
2. **Week-in-Review Dashboard**: Provide chart data for ≥2 visualizations (activity by day, document type breakdown — the script renders these as interactive dashboard sections)
3. **Policy Mindmap**: Define mindmap structure showing how the week's stories interconnect (central topic + branches — the script renders this as a CSS mindmap)
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.

These updated instructions say the agent should “provide chart data” / “define mindmap structure” and that “the script renders” dashboards/mindmaps. However, SHARED_PROMPT_PATTERNS.md’s new HTML renderer guidance explicitly says dashboards/mindmaps require a workflow-specific, validated machine-readable input format (and that only SWOT markdown extraction is a standard flow). Please either add the exact schema + integration steps (where this chart/mindmap data is parsed and passed to renderers), or soften the wording so it doesn’t imply an implemented render pipeline.

Suggested change
1. **Condensed SWOT**: Write SWOT analysis with ≥3 stakeholder perspectives on the week's balance of power — the script renders this as an interactive SWOT section
2. **Week-in-Review Dashboard**: Provide chart data for ≥2 visualizations (activity by day, document type breakdown — the script renders these as interactive dashboard sections)
3. **Policy Mindmap**: Define mindmap structure showing how the week's stories interconnect (central topic + branches — the script renders this as a CSS mindmap)
1. **Condensed SWOT**: Write SWOT analysis with ≥3 stakeholder perspectives on the week's balance of power, using clear markdown headings and bullets suitable for the standard SWOT extraction flow
2. **Week-in-Review Dashboard**: Provide ≥2 visualization-ready summaries (for example: activity by day and document type breakdown) with explicit labels, values, and short interpretation text; do not assume an interactive dashboard renderer unless a workflow-specific validated input format is defined
3. **Policy Mindmap**: Provide a structured outline showing how the week's stories interconnect (central topic + branches + sub-branches) in nested markdown bullets; do not assume a mindmap render pipeline unless a workflow-specific validated input format is defined

Copilot uses AI. Check for mistakes.
Comment on lines 206 to 209
### Phase 2 — Depth Enhancement (for `deep`/`comprehensive` depth only)
1. **Quick SWOT**: 1-paragraph SWOT overview of the week's political balance
2. **Event Dashboard**: Generate `generateDashboardSection()` with ≥2 charts (committee meeting density, event type breakdown)
2. **Event Dashboard**: Provide chart data for ≥2 visualizations (committee meeting density, event type breakdown — the script renders these as interactive dashboard sections)
3. **Quality Gate**:
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 step now asks the agent to “provide chart data … the script renders these as interactive dashboard sections”, but the workflow text doesn’t define a machine-readable chart schema or where that data is parsed and passed into the dashboard renderer. To avoid ambiguous outputs, either document the exact JSON/schema + consumption step, or reword this as a narrative requirement (e.g., describe what the charts should show) rather than implying an existing render pipeline.

Copilot uses AI. Check for mistakes.
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**: Provide chart data for ≥1 visualization (party motion count — the script renders this as an interactive dashboard section)
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 “provide chart data” and says the script will render it, but the workflow doesn’t specify the chart data schema or where it’s parsed and passed to the dashboard renderer. Please add an explicit machine-readable format + integration step, or reword to avoid implying an implemented render pipeline.

Suggested change
2. **Coalition Dashboard**: Provide chart data for ≥1 visualization (party motion count — the script renders this as an interactive dashboard section)
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.

Copilot uses AI. Check for mistakes.
Comment on lines +225 to +226
2. **Strategic Dashboard**: Provide chart data for ≥2 visualizations (documents by week, policy domain distribution — the script renders these as interactive dashboard sections)
3. **Policy Mindmap**: Define mindmap structure showing inter-connected policy areas (central topic + branches with sub-items — the script renders this as a CSS mindmap)
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.

These steps now require the agent to output “chart data” and “mindmap structure” and assume the script will render them, but there’s no defined machine-readable schema here (nor a documented parsing/integration step). Please either specify the exact JSON/schema + how it’s consumed, or reword to avoid implying a supported render pipeline.

Suggested change
2. **Strategic Dashboard**: Provide chart data for ≥2 visualizations (documents by week, policy domain distributionthe script renders these as interactive dashboard sections)
3. **Policy Mindmap**: Define mindmap structure showing inter-connected policy areas (central topic + branches with sub-itemsthe script renders this as a CSS mindmap)
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.

Copilot uses AI. Check for mistakes.
Comment on lines +211 to +214
1. **Full SWOT**: Write 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) — the script renders this as an interactive SWOT section
2. **Monthly Dashboard**: Provide chart data for ≥4 visualizations (monthly trends, party activity ranking, policy domain heatmap, legislative pipeline — the script renders these as interactive dashboard sections)
3. **Policy Mindmap**: Define mindmap structure showing the month's cross-cutting policy themes (central topic + color-coded branches — the script renders this as a CSS mindmap)
4. **Stakeholder SWOT**: Write stakeholder-focused SWOT with ≥7 perspectives for comprehensive depth (each entry must cite specific dok_id evidence)
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.

These steps imply the agent will emit structured “chart data” / “mindmap structure” that the script will render, but the workflow doesn’t define the required schema or the parsing/integration step that turns agent output into generateDashboardSection() / generateMindmapSection() inputs. Please document the exact machine-readable format + consumption/validation, or reword to avoid implying an implemented render pipeline.

Suggested change
1. **Full SWOT**: Write 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) — the script renders this as an interactive SWOT section
2. **Monthly Dashboard**: Provide chart data for ≥4 visualizations (monthly trends, party activity ranking, policy domain heatmap, legislative pipeline the script renders these as interactive dashboard sections)
3. **Policy Mindmap**: Define mindmap structure showing the month's cross-cutting policy themes (central topic + color-coded branches — the script renders this as a CSS mindmap)
4. **Stakeholder SWOT**: Write stakeholder-focused SWOT with ≥7 perspectives for comprehensive depth (each entry must cite specific dok_id evidence)
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.

Copilot uses AI. Check for mistakes.
Comment on lines 257 to 259
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**: Provide chart data for ≥1 visualization (interpellations by minister or party — the script renders this as an interactive dashboard section)
3. **Quality Gate** (check before next iteration):
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.
### 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**: Provide chart data for ≥1 visualization (today's activity breakdown by type/party — the script renders this as an interactive dashboard section)
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 requirement says the agent should “provide chart data” and that the script will render it, but the workflow doesn’t define what chart schema/format the agent should output or where it’s parsed into a generateDashboardSection() input. Please document the exact machine-readable format + integration step, or reword to avoid implying an implemented render pipeline.

Suggested change
2. **Activity Dashboard**: Provide chart data for ≥1 visualization (today's activity breakdown by type/party — the script renders this as an interactive dashboard section)
2. **Activity Dashboard**: Provide machine-readable chart data for ≥1 visualization in a fenced `json` block using this exact shape: `{ "title": "Today's activity by type", "chartType": "bar|line|pie", "labels": ["label1", "label2"], "series": [{ "name": "series name", "data": [1, 2] }] }`. Use this to document dashboard-ready data for downstream/manual rendering; do not assume an implemented `generateDashboardSection()` integration unless a later workflow step explicitly parses this JSON.

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 12, 2026

@copilot apply changes based on the comments in this thread

…eudocode refs, clarify dashboard/mindmap wording

- Restored scripts/check-banned-patterns.ts (validate-news-generation.sh Check 15 depends on it)
- Restored tests/detect-banned-patterns.test.ts
- Fixed swot-generation.md: marked buildSwotFromDocs as pseudocode
- Fixed political-analysis.md: marked buildSwotFromDocs as pseudocode
- Fixed 9 workflow .md files: removed implied dashboard/mindmap render pipeline wording
  - news-weekly-review.md: SWOT/dashboard/mindmap steps reworded
  - news-week-ahead.md: dashboard step reworded
  - news-realtime-monitor.md: activity chart → activity summary
  - news-propositions.md: policy dashboard/mindmap → comparison summary/impact map
  - news-motions.md: coalition dashboard reworded
  - news-month-ahead.md: strategic dashboard/mindmap reworded
  - news-monthly-review.md: full SWOT/dashboard/mindmap reworded
  - news-interpellations.md: accountability dashboard reworded
  - news-evening-analysis.md: activity dashboard reworded

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/d935f5e1-ccff-41eb-9710-71f7c5afc1de

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 12, 2026

@copilot apply changes based on the comments in this thread

Applied all 12 review comments in 25a7de1:

  1. Restored scripts/check-banned-patterns.ts and its test — validate-news-generation.sh Check 15 depends on it
  2. Fixed pseudocode in swot-generation.md and political-analysis.mdbuildSwotFromDocs now clearly marked as pseudocode with the actual fallback shown
  3. Reworded 9 workflow .md files — dashboard/mindmap/chart steps no longer imply an implemented render pipeline; only SWOT extraction is described as a standard flow

All 91 test files pass (3871 tests), TypeScript build clean, CodeQL clean.

Both review comments from that thread were already applied in d06c70f:

  1. HTML Renderer table now scopes SWOT as the only currently implemented extraction flow; dashboard/mindmap/multi-panel/ec...

Confirmed — those changes were already applied in d06c70f. The latest commit 25a7de1 addresses the subsequent review thread (4095817779) with 12 additional fixes.

Copilot AI changed the title fix: purge deprecated function-call patterns from agentic workflows and update SHARED_PROMPT_PATTERNS.md fix: purge deprecated code/scripts, clarify agentic workflow prompts, and update SHARED_PROMPT_PATTERNS.md Apr 12, 2026
@pethers pethers requested a review from Copilot April 12, 2026 23:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated no new comments.

@pethers pethers merged commit b08db7f into main Apr 12, 2026
21 checks passed
@pethers pethers deleted the copilot/purge-deprecated-code-and-test branch April 12, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentic-workflow Agentic workflow changes ci-cd CI/CD pipeline changes dependencies Dependency updates documentation Documentation updates news News articles and content generation refactor Code refactoring size-m Medium change (50-250 lines) size-xl Extra large change (> 1000 lines) testing Test coverage workflow GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants