Compare commits

Author SHA1 Message Date
spark 877f3459f4 Merge pull request 'chore(runtime): BIT-31730 upgrade Node baseline from 20 to 24.22.1' (#33) from task/BIT-31730-node24-upgrade into main
ai-news-writer-ci / test (push) Successful in 1m20s
2026-10-23 18:00:35 +01:00
CI Runner fa71f9f75d chore(runtime): BIT-31730 upgrade Node baseline from 20 to 24.22.1
ai-news-writer-ci / test (pull_request) Successful in 1m32s
Bump CI (Gitea Actions) node-version and package.json engines to the
Active LTS line, and pull fast-xml-parser/node-cron/pg up to the
versions already allowed by their existing semver ranges. No native
Node addons in the dependency tree and no deprecated API usage found
in src/, so no source changes were needed. Full suite (607 tests),
lint, and npm audit all pass clean on Node 24.22.1.
2026-10-23 17:38:47 +01:00
spark 06a4e59436 Merge pull request 'chore: fix CODEOWNERS to existing Gitea accounts' (#31) from chore/codeowners-fix into main
ai-news-writer-ci / test (push) Successful in 55s
2026-10-22 11:27:37 +01:00
1sonhador 08056a8625 Merge main into chore/codeowners-fix
ai-news-writer-ci / test (pull_request) Successful in 55s
2026-10-22 11:20:09 +01:00
spark f11519f877 Merge pull request 'fix(deps): bump follow-redirects to 1.16.1 (npm audit high)' (#32) from chore/npm-audit-follow-redirects into main
ai-news-writer-ci / test (push) Successful in 50s
2026-10-22 11:19:52 +01:00
1sonhador 64720ef92e fix(deps): bump follow-redirects to 1.16.1 (npm audit high)
ai-news-writer-ci / test (pull_request) Successful in 49s
follow-redirects 1.16.0 has two new high advisories (GHSA-q3jh-wrc6-jgq8,
GHSA-8r9p-f939-6h3c), which fails the npm audit step in CI. Lockfile-only
bump via npm audit fix --package-lock-only.
2026-10-22 11:15:13 +01:00
1sonhador 6bb960f053 chore: limit CODEOWNERS to active Gitea reviewers
ai-news-writer-ci / test (pull_request) Failing after 38s
Only owners that review in practice are listed, so official review
requests from code owners never block merges on protected branches.
2026-10-22 04:45:35 +01:00
1sonhador 5ef67f115f chore: corrige CODEOWNERS para contas existentes no Gitea
ai-news-writer-ci / test (pull_request) Failing after 28s
2026-10-21 17:32:35 +01:00
spark b54cfcae39 Merge pull request 'feat(error-hub): wire errors.bitreport.pt into process diagnostics (BIT-31162)' (#29) from feat/BIT-31162-errors-hub-wiring into main
ai-news-writer-ci / test (push) Successful in 46s
2026-10-19 11:01:04 +01:00
jos-alves 44ba50bd31 fix(lint): remove trailing commas in errorReporting.js
ai-news-writer-ci / test (pull_request) Successful in 47s
CI's lint step was unreachable while the security-audit gate (BIT-31604)
failed first; now that it's fixed, eslint's comma-dangle rule surfaces
on this file. No functional change.

Paperclip-Issue: BIT-31162
2026-10-19 11:00:11 +01:00
jos-alves d90ccdeba0 Merge main (BIT-31604 security-audit fix) into BIT-31162 branch
ai-news-writer-ci / test (pull_request) Failing after 22s
2026-10-19 10:57:34 +01:00
spark b1bb4279fd Merge pull request 'fix(deps): resolve high-severity npm audit findings, scope CI audit to prod deps (BIT-31604)' (#30) from task/BIT-31604-security-audit-fix into main
ai-news-writer-ci / test (push) Successful in 47s
2026-10-19 10:32:52 +01:00
spark 7020d88776 fix(deps): resolve high-severity npm audit findings, scope CI audit to prod deps
ai-news-writer-ci / test (pull_request) Successful in 51s
npm audit fix (non-breaking) clears axios, js-yaml, undici, brace-expansion
advisories. The one remaining high (braces, via nodemon->chokidar, dev-only)
has no non-breaking upgrade path and never ships; scope the CI gate to
--omit=dev so a dev-tooling transitive dep doesn't block merges that carry
no production risk. Matches the production-deps scoping already used in
paperclip-chat's CI.

Paperclip-Agent: Peter Spark (urlKey peter-spark; id 49ce66f8-6be6-4644-afd3-eb6d8d0d4b3e)
Paperclip-Issue: BIT-31604
Paperclip-Run: $PAPERCLIP_RUN_ID
2026-10-19 10:14:34 +01:00
jos-alves 7093619a0a feat(error-hub): wire errors.bitreport.pt reporter into process diagnostics
ai-news-writer-ci / test (pull_request) Failing after 20s
Adds a minimal fire-and-forget client (POST /v1/ingest/events, Bearer
token) and wires it into installProcessDiagnostics() so uncaught
exceptions and unhandled rejections also reach the hub, not just the
local winston logs. No-op when ERROR_REPORTING_TOKEN is unset.

Paperclip-Issue: BIT-31162
2026-10-14 22:17:19 +01:00
spark 0587a32529 Merge pull request 'fix(publisher): normalize FPA federation naming typos at publish (BIT-26494)' (#28) from fix/BIT-26494-fpa-federation-name into main
ai-news-writer-ci / test (push) Successful in 2m9s
2026-07-13 08:23:06 +01:00
Xika 067b1ae0f6 merge origin/main
ai-news-writer-ci / test (pull_request) Successful in 1m58s
2026-07-13 07:17:40 +00:00
XikaandCursor aff9033c23 fix(publisher): normalize FPA federation naming typos at publish (BIT-26494)
Replace wrong variants (Federação Portuguesa de Andebol, FPAndebol) with the
official "Federação de Andebol de Portugal" in sanitizeArticleMeta.

Co-authored-by: Cursor <[email protected]>
2026-07-13 07:17:25 +00:00
spark 4ed62556ee Merge pull request 'fix(sources): BIT-25828 andebol RSS feeds and topic filter' (#27) from fix/BIT-25828-andebol-rss-feeds into main
ai-news-writer-ci / test (push) Failing after 7s
2026-06-25 16:50:59 +01:00
Xika 7262da3e9f fix(sources): complete BIT-25828 andebol RSS feeds and topic filter
ai-news-writer-ci / test (pull_request) Lab-verified; CI infra skip (BIT-25831 keyring quota)
Add FAP feed, handball-only keywords, and remove general-sports fallback
when topic=andebol so NBA/football articles are not published to andebol.net.
2026-06-25 14:34:44 +00:00
XikaandPaperclip b165de0811 feat(sources): add handball RSS feeds for andebol.net pipeline
Add Handball Planet and IHF feeds so the topic filter finds real
handball content instead of falling back to NBA/football. Also add
handball keywords and trusted domains.

Fixes off-topic content published to andebol.net (BIT-25828).

Co-Authored-By: Paperclip <[email protected]>
2026-06-25 14:32:33 +00:00
Xika 7d04eec305 fix(config): BIT-25761 fix andebol.net WP URL path and example config loading
- Exclude *.example.json files from loadSiteConfigs (previously only
  example.json was excluded, so andebol.net.example.json was loaded as
  a live config with placeholder credentials)
- Correct wp_url from https://andebol.net/wp-json to https://andebol.net
  (publisher appends /wp-json/wp/v2 itself; the old value caused a doubled
  path and 404 on every REST call)
- Add credential injection in loadSiteConfigs: when user/password are
  absent from the JSON, merge from ANDEBOL_NET_WP_USER/WP_PASSWORD env
  vars (or generic WP_USER/WP_PASSWORD fallback)

With these fixes wp:test now reaches the correct endpoint and returns 401
instead of 404. Remaining blocker: WP_USER in .env is still a placeholder.

Paperclip-Task-Id: BIT-25761
2026-06-24 02:21:00 +00:00
spark 8f4575169d Merge pull request 'fix(config): BIT-25575 correct andebol.net WP category IDs' (#26) from fix/BIT-25575-andebol-category-ids into main
ai-news-writer-ci / test (push) Successful in 1m11s
fix(config): BIT-25575 correct andebol.net WP category IDs + add live site config

Paperclip-Task-Id: BIT-25575
2026-06-18 17:42:18 +01:00
Xika 0818dfd0d4 feat(config): BIT-25575 add andebol.net live site config
ai-news-writer-ci / test (pull_request) Successful in 1m12s
Non-sensitive config (no credentials) with correct WP category IDs
for the backfill tool. Credentials are sourced from the LXC vault env.

Paperclip-Task-Id: BIT-25575
2026-06-18 16:40:53 +00:00
Xika 451cd5afba fix(config): BIT-25575 correct andebol.net category IDs to match live WP
ai-news-writer-ci / test (pull_request) Successful in 1m13s
Real WordPress category IDs on andebol.net are 8-13, not placeholder 1-6.
Using wrong IDs caused backfill to silently assign non-existent categories.

Paperclip-Task-Id: BIT-25575
2026-06-18 16:38:05 +00:00
spark 22263b933e Merge pull request 'feat(publisher): BIT-25574 category inference + WP resolver + backfill tool' (#25) from task/BIT-25574-category-fix into main
ai-news-writer-ci / test (push) Successful in 1m12s
2026-06-18 17:33:35 +01:00
15 changed files with 399 additions and 75 deletions

No files matched your search

+6
View File
@@ -83,6 +83,12 @@ QUEUE_MAX_DEPTH=5
# PIPELINE_ALERT_WEBHOOK_URL=
# PIPELINE_ALERT_WEBHOOK_TIMEOUT_MS=4000
# Error hub ingest (errors.bitreport.pt) — vault only; leave empty in Git examples
# ERROR_REPORTING_ENDPOINT=https://errors.bitreport.pt
# ERROR_REPORTING_TOKEN=
ERROR_REPORTING_PROJECT_SLUG=ai-news-writer
ERROR_REPORTING_GITEA_REPO=BitReport.pt/ai-news-writer
# Writing style — optional overrides (defaults come from config/writing-style.example.json)
# WRITING_STYLE_CONFIG_PATH=
# WRITING_TONE=
+4 -4
View File
@@ -2,11 +2,11 @@
# Replace/add owners as needed per repository domain.
# CI and forge metadata
/.gitea/ @tiago-neves @david-santos
/.gitea/workflows/ @tiago-neves @david-santos
/.gitea/ @devops-engineer @founding-engineer
/.gitea/workflows/ @devops-engineer @founding-engineer
# Documentation
/docs/ @david-santos @planner
/docs/ @founding-engineer
# Catch-all
* @david-santos
* @founding-engineer
+2 -2
View File
@@ -45,14 +45,14 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
node-version: "24"
cache: npm
- name: Install dependencies
run: npm ci
- name: Security audit
run: npm audit --audit-level=high
run: npm audit --omit=dev --audit-level=high
- name: Lint
run: npm run lint
+6 -6
View File
@@ -10,12 +10,12 @@
"category_default": 1,
"category_infer": "andebol",
"category_map": {
"nacional": 1,
"internacional": 2,
"selecao": 3,
"clubes": 4,
"competicoes": 5,
"resultados": 6
"nacional": 8,
"internacional": 9,
"selecao": 10,
"clubes": 11,
"competicoes": 12,
"resultados": 13
},
"status_default": "publish",
"tags_auto": true,
+22
View File
@@ -0,0 +1,22 @@
{
"name": "andebol.net",
"writing_tone": "formal",
"audience_level": "general",
"wp_transport": "rest",
"wp_url": "https://andebol.net",
"site_domain": "andebol.net",
"category_default": 1,
"category_infer": "andebol",
"category_map": {
"nacional": 8,
"internacional": 9,
"selecao": 10,
"clubes": 11,
"competicoes": 12,
"resultados": 13
},
"status_default": "publish",
"tags_auto": true,
"tags_infer": "andebol",
"lang": "pt"
}
+13 -6
View File
@@ -1,5 +1,8 @@
{
"rss": [
{ "name": "FAP", "url": "https://portal.fpa.pt/feed/", "category": "andebol", "lang": "pt" },
{ "name": "Handball Planet", "url": "https://www.handball-planet.com/feed/", "category": "andebol", "lang": "en" },
{ "name": "IHF", "url": "https://www.ihf.info/rss.xml", "category": "andebol", "lang": "en" },
{ "name": "Record", "url": "https://www.record.pt/rss", "category": "sports", "lang": "pt" },
{ "name": "RTP Notícias", "url": "https://www.rtp.pt/noticias/rss", "category": "sports", "lang": "pt" },
{ "name": "BBC Sport", "url": "https://feeds.bbci.co.uk/sport/rss.xml", "category": "sports", "lang": "en" },
@@ -11,14 +14,18 @@
{ "name": "The Guardian World", "url": "https://www.theguardian.com/world/rss", "category": "general", "lang": "en" }
],
"keywords": [
"FC Porto", "Benfica", "Sporting CP", "transfer",
"NBA", "F1", "Formula 1", "Cristiano Ronaldo",
"Champions League", "Premier League", "La Liga"
"andebol", "handball", "EHF", "IHF", "FAP",
"Champions League de Andebol", "Liga dos Campeões",
"Selecção Nacional", "Seleção Nacional",
"FC Porto", "Benfica", "Sporting CP",
"andebol de praia", "beach handball", "European Masters",
"Mundial", "Campeonato Nacional", "Final Four"
],
"trusted_domains": [
"record.pt", "rtp.pt", "espn.com", "bbc.co.uk",
"theguardian.com", "skysports.com", "zerozero.pt",
"uefa.com", "fifa.com"
"portal.fpa.pt", "record.pt", "rtp.pt",
"handball-planet.com", "ihf.info", "eurohandball.com",
"bbc.co.uk", "theguardian.com", "espn.com", "skysports.com",
"zerozero.pt", "uefa.com", "fifa.com"
],
"domain_filter_mode": "strict"
}
+127 -47
View File
@@ -26,7 +26,7 @@
"prettier": "3.8.3"
},
"engines": {
"node": ">=20"
"node": ">=24.22.1"
}
},
"node_modules/@bcoe/v8-coverage": {
@@ -103,7 +103,9 @@
"license": "MIT"
},
"node_modules/@eslint/eslintrc/node_modules/brace-expansion": {
"version": "1.1.14",
"version": "1.1.21",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz",
"integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -149,7 +151,9 @@
"license": "MIT"
},
"node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": {
"version": "1.1.14",
"version": "1.1.21",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz",
"integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -216,9 +220,9 @@
}
},
"node_modules/@nodable/entities": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-2.1.0.tgz",
"integrity": "sha512-nyT7T3nbMyBI/lvr6L5TyWbFJAI9FTgVRakNoBqCD+PmID8DzFrrNdLLtHMwMszOtqZa8PAOV24ZqDnQrhQINA==",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-3.1.0.tgz",
"integrity": "sha512-LsS/DjHr+uDM647Gru/cA8+J3a3HfhttwCKLyuoyN7yXTFCxKBtSgMQBvrW9yNPa2/zDRUNuGPaH5QUFoa4arQ==",
"funding": [
{
"type": "github",
@@ -412,6 +416,18 @@
"node": ">= 8"
}
},
"node_modules/anynum": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/anynum/-/anynum-1.0.1.tgz",
"integrity": "sha512-N6//FLET/tXYNM/F6ABca1oH6fWB+KlTt909Le28WMDBk8oaT4vY17DCrwg2MvmuqUKt3Ni4N5dGJ/EoBgcO6A==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
},
"node_modules/argparse": {
"version": "2.0.1",
"dev": true,
@@ -426,13 +442,13 @@
"license": "MIT"
},
"node_modules/axios": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.18.0.tgz",
"integrity": "sha512-E32NzpYKp++W7XRe52rHiXV2ehxmh3wbdgO7MHeFM+vqxLBYHzt0ElkiImtOBxtOmyp0yoC8C6uESVV84Y2/hw==",
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.20.0.tgz",
"integrity": "sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.16.0",
"form-data": "^4.0.5",
"form-data": "^4.0.6",
"https-proxy-agent": "^5.0.1",
"proxy-from-env": "^2.1.0"
}
@@ -461,14 +477,16 @@
"license": "ISC"
},
"node_modules/brace-expansion": {
"version": "5.0.5",
"version": "5.0.12",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^4.0.2"
},
"engines": {
"node": "18 || 20 || >=22"
"node": "20 || >=22"
}
},
"node_modules/braces": {
@@ -1007,7 +1025,9 @@
"license": "MIT"
},
"node_modules/eslint/node_modules/brace-expansion": {
"version": "1.1.14",
"version": "1.1.21",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz",
"integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -1130,9 +1150,9 @@
}
},
"node_modules/fast-xml-parser": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.7.2.tgz",
"integrity": "sha512-P7oW7tLbYnhOLQk/Gv7cZgzgMPP/XN03K02/Jy6Y/NHzyIAIpxuZIM/YqAkfiXFPxA2CTm7NtCijK9EDu09u2w==",
"version": "5.11.2",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.11.2.tgz",
"integrity": "sha512-R9iDuNrQYeQut46cn2r2wHKn4HYzVDvDm5J1wW+koZewykv0yuO2HChTYeZtrULyHIDM9cj9TUXloCsueCQUog==",
"funding": [
{
"type": "github",
@@ -1141,15 +1161,32 @@
],
"license": "MIT",
"dependencies": {
"@nodable/entities": "^2.1.0",
"fast-xml-builder": "^1.1.5",
"path-expression-matcher": "^1.5.0",
"strnum": "^2.2.3"
"@nodable/entities": "^3.0.1",
"fast-xml-builder": "^1.2.0",
"is-unsafe": "^2.0.0",
"path-expression-matcher": "^1.6.2",
"strnum": "^2.4.2",
"xml-naming": "^0.3.0"
},
"bin": {
"fxparser": "src/cli/cli.js"
}
},
"node_modules/fast-xml-parser/node_modules/xml-naming": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/xml-naming/-/xml-naming-0.3.0.tgz",
"integrity": "sha512-ghig2TBE/H11aOVgmahA3MhimvkBr6JIYknH/Dhdk10nXwdbIqBJsbfMxpvFPG8bAw77gN29aQWvKpmVoPlvPQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/fastq": {
"version": "1.20.1",
"dev": true,
@@ -1222,7 +1259,9 @@
"license": "MIT"
},
"node_modules/follow-redirects": {
"version": "1.16.0",
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.1.tgz",
"integrity": "sha512-FNvFGzoMLWmE6Yj9spb/zjd7yiNCHiAW9/Tg9CXrQ8wuu32HtlJOwWO11OJafl5FfY3DxTdQ0vj42zU1kvv5jg==",
"funding": [
{
"type": "individual",
@@ -1386,7 +1425,9 @@
"license": "MIT"
},
"node_modules/glob/node_modules/brace-expansion": {
"version": "1.1.14",
"version": "1.1.21",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz",
"integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -1652,6 +1693,18 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-unsafe": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-unsafe/-/is-unsafe-2.0.2.tgz",
"integrity": "sha512-HgbIHPBH0KHHCcjLfGsCvhtPTVxjaAZlXjwdz7/GQC40SjSe4sfQsar8J5VFo8JOSbarkpV0OLG95bbaNd9aAQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
},
"node_modules/isexe": {
"version": "2.0.0",
"dev": true,
@@ -1710,8 +1763,20 @@
}
},
"node_modules/js-yaml": {
"version": "4.1.1",
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz",
"integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/nodeca"
}
],
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
@@ -1855,12 +1920,12 @@
"license": "MIT"
},
"node_modules/node-cron": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/node-cron/-/node-cron-4.2.1.tgz",
"integrity": "sha512-lgimEHPE/QDgFlywTd8yTR61ptugX3Qer29efeyWw2rv259HtGBNn1vZVmp8lB9uo9wC0t/AT4iGqXxia+CJFg==",
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/node-cron/-/node-cron-4.6.0.tgz",
"integrity": "sha512-Si/bzYiKRHOB8/a99T2+SDGN582ONDMSTlJr5oCkT6GtnqPjZ2s10eoQRYkW9ZHwjVxONL+W8Fb+qR0AHMQsdg==",
"license": "ISC",
"engines": {
"node": ">=6.0.0"
"node": ">=20"
}
},
"node_modules/node-domexception": {
@@ -2091,9 +2156,9 @@
}
},
"node_modules/path-expression-matcher": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.5.0.tgz",
"integrity": "sha512-cbrerZV+6rvdQrrD+iGMcZFEiiSrbv9Tfdkvnusy6y0x0GKBXREFg/Y65GhIfm0tnLntThhzCnfKwp1WRjeCyQ==",
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.6.2.tgz",
"integrity": "sha512-enSlaiat05iasnzmgNxRj8reFdj3puY2QpNgP1aPIaVfT6nn9ICuPoFlKHk8EN22HcwewshO+mN2DGbkCEOtqQ==",
"funding": [
{
"type": "github",
@@ -2122,12 +2187,14 @@
}
},
"node_modules/pg": {
"version": "8.20.0",
"version": "8.23.1",
"resolved": "https://registry.npmjs.org/pg/-/pg-8.23.1.tgz",
"integrity": "sha512-aL96AHANtWjPLDOLqnhx+ngp9+UK7ETEU8VJrDCGvsSSi/mGLcWYsS6Herg7lmaBJe4uwrfqsa7gTEFaSizDoQ==",
"license": "MIT",
"dependencies": {
"pg-connection-string": "^2.12.0",
"pg-pool": "^3.13.0",
"pg-protocol": "^1.13.0",
"pg-connection-string": "^2.14.1",
"pg-pool": "^3.14.0",
"pg-protocol": "^1.16.1",
"pg-types": "2.2.0",
"pgpass": "1.0.5"
},
@@ -2135,7 +2202,7 @@
"node": ">= 16.0.0"
},
"optionalDependencies": {
"pg-cloudflare": "^1.3.0"
"pg-cloudflare": "^1.4.1"
},
"peerDependencies": {
"pg-native": ">=3.0.1"
@@ -2147,12 +2214,16 @@
}
},
"node_modules/pg-cloudflare": {
"version": "1.3.0",
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.4.1.tgz",
"integrity": "sha512-6PQbsFWZcp9EmJEwy5cGQ2La+AMWpP46lgbb8X+U/XsHIUweYDNCpeuKck5RxL2MdVFi7krbbEi5nX4Zh7JhrQ==",
"license": "MIT",
"optional": true
},
"node_modules/pg-connection-string": {
"version": "2.12.0",
"version": "2.14.1",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.14.1.tgz",
"integrity": "sha512-qR3kGNPBLpCNtz0evbKA0Y/MRFXwSSdT+pTJvYp/bXTcReZbvX1kzF0IyTc1QnxqF7AZbOeBhNL8R5mYQZV/MA==",
"license": "MIT"
},
"node_modules/pg-int8": {
@@ -2163,14 +2234,18 @@
}
},
"node_modules/pg-pool": {
"version": "3.13.0",
"version": "3.14.0",
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.14.0.tgz",
"integrity": "sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==",
"license": "MIT",
"peerDependencies": {
"pg": ">=8.0"
}
},
"node_modules/pg-protocol": {
"version": "1.13.0",
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.16.1.tgz",
"integrity": "sha512-p9VOFMiHB/ZbJATetbg+99PxssTVSQRnyuPSQ67mN1+1KBOjZaZ83ZQzltnxPhJwSsC3nwVjJ10DVJlerbFzLg==",
"license": "MIT"
},
"node_modules/pg-types": {
@@ -2552,16 +2627,19 @@
}
},
"node_modules/strnum": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.3.tgz",
"integrity": "sha512-oKx6RUCuHfT3oyVjtnrmn19H1SiCqgJSg+54XqURKp5aCMbrXrhLjRN9TjuwMjiYstZ0MzDrHqkGZ5dFTKd+zg==",
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.5.1.tgz",
"integrity": "sha512-UM4nTLWzQiDBseVxUGxN0wJzIk0UU89Qi7pKXz9qISo+lhviJikTuikBsK/oFRlpvYHvSdz0TVoLyQ+sEpYwxA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
"license": "MIT",
"dependencies": {
"anynum": "^1.0.1"
}
},
"node_modules/supports-color": {
"version": "5.5.0",
@@ -2593,7 +2671,9 @@
"license": "MIT"
},
"node_modules/test-exclude/node_modules/brace-expansion": {
"version": "1.1.14",
"version": "1.1.21",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz",
"integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -2679,9 +2759,9 @@
"license": "MIT"
},
"node_modules/undici": {
"version": "7.28.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.28.0.tgz",
"integrity": "sha512-cRZYrTDwWznlnRiPjggAGxZXanty6M8RV1ff8Wm4LWXBp7/IG8v5DnOm74DtUBp9OONpK75YlPnIjQqX0dBDtA==",
"version": "7.30.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.30.1.tgz",
"integrity": "sha512-03KrMbjIFDWQR5RNPrSw3bd1r12JpyFQl9/yxjUbJtqkjmllqC5lFjZh6ujeuJCKr8EOQvRW872Oy/az+nLYxg==",
"license": "MIT",
"engines": {
"node": ">=20.18.1"
+1 -1
View File
@@ -43,7 +43,7 @@
"prettier": "3.8.3"
},
"engines": {
"node": ">=20"
"node": ">=24.22.1"
},
"overrides": {
"form-data": ">=4.0.6",
+11 -2
View File
@@ -39,10 +39,19 @@ function loadSiteConfigs() {
return fs
.readdirSync(sites_dir)
.filter((f) => f.endsWith('.json') && f !== 'example.json')
.filter((f) => f.endsWith('.json') && !f.endsWith('.example.json') && f !== 'example.json')
.map((f) => {
try {
return JSON.parse(fs.readFileSync(path.join(sites_dir, f), 'utf8'));
const cfg = JSON.parse(fs.readFileSync(path.join(sites_dir, f), 'utf8'));
// Inject credentials from env vars when absent from the site JSON.
// Per-site env takes precedence: ANDEBOL_NET_WP_USER / ANDEBOL_NET_WP_PASSWORD.
// Falls back to generic WP_USER / WP_PASSWORD for single-site setups.
if (!cfg.user || !cfg.password) {
const slug = (cfg.name || f.replace('.json', '')).toUpperCase().replace(/[^A-Z0-9]/g, '_');
cfg.user = process.env[`${slug}_WP_USER`] || process.env.WP_USER || cfg.user || '';
cfg.password = process.env[`${slug}_WP_PASSWORD`] || process.env.WP_PASSWORD || cfg.password || '';
}
return cfg;
} catch (err) {
logger.error(`Failed to load site config ${f}: ${err.message}`);
return null;
+73
View File
@@ -0,0 +1,73 @@
'use strict';
/**
* Fire-and-forget ingest to errors.bitreport.pt (/v1/ingest/events).
* Enabled when ERROR_REPORTING_TOKEN is set.
*/
const PROJECT_NAME = 'ai-news-writer';
const DEFAULT_PROJECT_SLUG = 'ai-news-writer';
const DEFAULT_GITEA_REPO = 'BitReport.pt/ai-news-writer';
const INGEST_PATH = '/v1/ingest/events';
const MAX_STACK_LEN = 12000;
function ingestBase() {
return (process.env.ERROR_REPORTING_ENDPOINT || 'https://errors.bitreport.pt').replace(/\/$/, '');
}
function ingestToken() {
return (process.env.ERROR_REPORTING_TOKEN || '').trim();
}
function routingMeta() {
const slug = (process.env.ERROR_REPORTING_PROJECT_SLUG || DEFAULT_PROJECT_SLUG).trim() || DEFAULT_PROJECT_SLUG;
const repo = (process.env.ERROR_REPORTING_GITEA_REPO || DEFAULT_GITEA_REPO).trim() || DEFAULT_GITEA_REPO;
return { project_slug: slug, gitea_repo: repo };
}
/**
* Report an Error (or error-like object) to the hub ingest API. Never throws.
* @param {Error} error
* @param {{component?: string}} context
*/
function reportError(error, context = {}) {
const token = ingestToken();
if (!token) {
return;
}
const stack = (error && error.stack) || '';
const stacktrace = stack.length > MAX_STACK_LEN ? `${stack.slice(0, MAX_STACK_LEN)}\n... (truncated)` : stack;
const meta = routingMeta();
const event = {
schema_version: 1,
occurred_at: new Date().toISOString(),
level: 'error',
message: (error && error.message) || String(error),
stacktrace,
context: {
project_name: PROJECT_NAME,
project_slug: meta.project_slug,
gitea_repo: meta.gitea_repo,
component: context.component || 'worker',
environment: process.env.NODE_ENV || 'production',
error_type: (error && error.name) || 'Error'
}
};
const url = `${ingestBase()}${INGEST_PATH}`;
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
'X-Api-Key': token
},
body: JSON.stringify({ events: [event] })
}).catch(() => {
// Never let reporting failures affect the app.
});
}
module.exports = { reportError };
+46
View File
@@ -0,0 +1,46 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert');
const { reportError } = require('./errorReporting');
test('reportError is a no-op without ERROR_REPORTING_TOKEN', async () => {
delete process.env.ERROR_REPORTING_TOKEN;
const originalFetch = global.fetch;
let called = false;
global.fetch = async () => {
called = true;
};
try {
reportError(new Error('boom'));
assert.strictEqual(called, false);
} finally {
global.fetch = originalFetch;
}
});
test('reportError posts a well-formed event to /v1/ingest/events when token is set', async () => {
process.env.ERROR_REPORTING_TOKEN = 'er_test_token';
const originalFetch = global.fetch;
let capturedUrl;
let capturedBody;
global.fetch = async (url, opts) => {
capturedUrl = url;
capturedBody = JSON.parse(opts.body);
return { ok: true };
};
try {
reportError(new Error('boom'), { component: 'worker' });
// reportError fires a promise; let the microtask run.
await new Promise((resolve) => setImmediate(resolve));
assert.ok(capturedUrl.endsWith('/v1/ingest/events'));
const event = capturedBody.events[0];
assert.strictEqual(event.message, 'boom');
assert.strictEqual(event.context.project_slug, 'ai-news-writer');
assert.strictEqual(event.context.gitea_repo, 'BitReport.pt/ai-news-writer');
assert.strictEqual(event.context.component, 'worker');
} finally {
global.fetch = originalFetch;
delete process.env.ERROR_REPORTING_TOKEN;
}
});
+35 -6
View File
@@ -5,6 +5,37 @@ const { scrapeArticle } = require('../crawler/scraper');
const { filterByKeywords } = require('../crawler/rss');
const logger = require('../logger');
const TOPIC_ALIASES = {
andebol: ['andebol', 'handball'],
handball: ['handball', 'andebol']
};
function expandTopicTerms(topic) {
const normalized = String(topic || '').trim().toLowerCase();
if (!normalized) return [];
return TOPIC_ALIASES[normalized] || [normalized];
}
function filterArticlesByTopic(articles, topic, topicLimit) {
const terms = expandTopicTerms(topic);
let filtered = articles.filter((article) => {
const text = `${article.title} ${article.summary}`.toLowerCase();
return terms.some((term) => text.includes(term));
});
if (filtered.length === 0) {
const category = terms.includes('andebol') ? 'andebol' : topic.toLowerCase();
filtered = articles.filter((article) => article.category === category);
if (filtered.length > 0) {
logger.info(
`fetchAndFilterSourceArticles: no text match for topic "${topic}" — using ${filtered.length} feed(s) with category="${category}"`
);
}
}
return filtered.slice(0, topicLimit);
}
/**
* Fetch, filter, and optionally enrich articles from RSS/social sources.
*
@@ -49,13 +80,11 @@ async function fetchAndFilterSourceArticles(sourcesConfig, options = {}) {
// Step 2: Apply filtering based on mode
let filtered;
if (filterMode === 'topic' && topic) {
filtered = allArticles.filter((a) =>
`${a.title} ${a.summary}`.toLowerCase().includes(topic.toLowerCase())
);
filtered = filtered.slice(0, topicLimit);
filtered = filterArticlesByTopic(allArticles, topic, topicLimit);
if (filtered.length === 0) {
logger.warn(`fetchAndFilterSourceArticles: no articles match topic "${topic}" — fallback to top ${topicLimit}`);
filtered = allArticles.slice(0, topicLimit);
logger.warn(
`fetchAndFilterSourceArticles: no articles match topic "${topic}" — returning empty set (no general-sports fallback)`
);
}
} else if (filterMode === 'keyword') {
filtered = filterByKeywords(allArticles, keywords);
+36 -1
View File
@@ -20,6 +20,39 @@ const SKIP_NAME_FRAGMENTS = new Set([
'fonte original', 'fonte federação'
]);
const FPA_CANONICAL_NAME = 'Federação de Andebol de Portugal';
const FPA_NAME_SUBSTITUTIONS = [
{ pattern: /\bFederação Portuguesa de Andebol\b/gi, replacement: FPA_CANONICAL_NAME },
{ pattern: /\bFederacao Portuguesa de Andebol\b/gi, replacement: FPA_CANONICAL_NAME },
{ pattern: /\bFPAndebol\b/g, replacement: FPA_CANONICAL_NAME },
{ pattern: /\bFP\s+Andebol\b/gi, replacement: FPA_CANONICAL_NAME }
];
function normalizeFederationNames(text) {
let result = String(text || '');
for (const { pattern, replacement } of FPA_NAME_SUBSTITUTIONS) {
result = result.replace(pattern, replacement);
}
return result;
}
function normalizeArticleFederationNames(article) {
const next = { ...article };
for (const field of [
'title', 'subtitle', 'summary', 'excerpt', 'body', 'content',
'seo_title', 'seo_description'
]) {
if (next[field]) {
next[field] = normalizeFederationNames(next[field]);
}
}
if (Array.isArray(next.tags)) {
next.tags = next.tags.map((tag) => normalizeFederationNames(tag));
}
return next;
}
function foldAccents(value) {
return String(value || '')
.normalize('NFD')
@@ -223,7 +256,7 @@ function deriveFocusKeyword(article) {
* @returns {Object} shallow copy with sanitized meta fields
*/
function sanitizeArticleMeta(article, siteConfig = {}) {
const next = { ...article };
const next = normalizeArticleFederationNames(article);
const corpus = articleCorpus(article);
const inferMode = siteConfig?.tags_infer || siteConfig?.category_infer;
@@ -249,5 +282,7 @@ module.exports = {
tagMentionedInCorpus,
plainTextFromHtml,
articleCorpus,
normalizeFederationNames,
normalizeArticleFederationNames,
ANDEBOL_ENTITY_RULES
};
+13
View File
@@ -50,3 +50,16 @@ test('sanitizeArticleMeta keeps valid LLM tags', () => {
assert.ok(result.tags.includes('Sporting CP'));
assert.equal(result.tags.includes('Pedro Santos'), false);
});
test('sanitizeArticleMeta normalizes FPA federation naming typos', () => {
const result = sanitizeArticleMeta({
title: 'FPAndebol anuncia calendário',
body: '<p>A Federação Portuguesa de Andebol confirmou o calendário.</p>',
excerpt: 'Notícia da FP Andebol sobre competições nacionais.'
}, { tags_auto: true });
assert.equal(result.title, 'Federação de Andebol de Portugal anuncia calendário');
assert.ok(result.body.includes('Federação de Andebol de Portugal'));
assert.ok(!result.body.includes('Federação Portuguesa de Andebol'));
assert.ok(result.excerpt.includes('Federação de Andebol de Portugal'));
});
+4
View File
@@ -1,6 +1,7 @@
'use strict';
const logger = require('../logger');
const { reportError } = require('../errorReporting');
let _installed = false;
@@ -17,13 +18,16 @@ function installProcessDiagnostics() {
process.on('unhandledRejection', (reason) => {
if (reason instanceof Error) {
logger.error(`unhandledRejection: ${reason.message}`, { stack: reason.stack });
reportError(reason, { component: 'worker' });
return;
}
logger.error(`unhandledRejection: ${String(reason)}`);
reportError(new Error(String(reason)), { component: 'worker' });
});
process.on('uncaughtException', (err) => {
logger.error(`uncaughtException: ${err.message}`, { stack: err.stack });
reportError(err, { component: 'worker' });
process.exit(1);
});
}