33 Commits
Author SHA1 Message Date
XikaandCursor 3027361259 feat(publisher): BIT-25574 sanitize tags and SEO meta from on-page text
ai-news-writer-ci / test (pull_request) Failing after 33s
Drop hallucinated athlete/team tags and derive Yoast fields only from
published article content. Adds backfill tool for live andebol.net posts.

Co-authored-by: Cursor <[email protected]>
2026-06-18 16:13:41 +00:00
Xika 478d82b070 feat(publisher): BIT-25574 category inference + WP resolver + backfill tool
ai-news-writer-ci / test (pull_request) Failing after 34s
Add category-infer.js with rule-based slug detection for andebol.net
(selecao, clubes, competicoes, internacional, resultados, nacional).
Add wp-categories.js to resolve WP category IDs via API or category_map.
Wire resolvePostCategoryIds into both REST and XML-RPC publish paths.
Add tools/backfill-wp-categories.js for one-shot backfill of uncategorized posts.
Add config/sites/andebol.net.example.json as reference site config template.
Persist article tags and category in persist-generated-article.js.

Paperclip-Issue: BIT-25575
Paperclip-Agent: Tiago Neves (id 5d084b36-f38f-42a5-a92a-520005afda4f)
2026-06-18 16:10:57 +00:00
Xika eb0dd1353c fix(deploy): remove premature Prometheus metrics check from verify-deploy (BIT-22325)
ai-news-writer-ci / test (pull_request) Successful in 31s
The /metrics endpoint returns JSON, not Prometheus exposition format.
The BIT-3601 Prometheus check was added before the app implemented it,
causing staging deploys to always fail the health check and roll back.

Remove the exposition-format check; JSON schema validation remains.

Paperclip-Issue: BIT-22325
Paperclip-Agent: tiago-neves
2026-05-14 18:40:51 +00:00
Xika 65fa4014d0 fix(lint): drop missing import/no-extraneous-dependencies rule disable
ai-news-writer-ci / test (pull_request) Successful in 36s
CI lint job has no eslint-plugin-import installed, so the inline
disable-next-line for that rule itself raises an "unknown rule" error
on `tools/seed-smoke-verification-article.js`. Drop the import-related
token from the disable comment and keep only the still-valid
`global-require` disable for the lazy require of `dotenv`. No
behaviour change; the file still tries dotenv and silently continues
without it.

Paperclip-Issue: BIT-21924
Paperclip-Run: bb6e49a5-4f6d-4a8e-a4dd-ee75d961b36f
2026-05-13 04:36:09 +00:00
Xika ec203917d1 Restore /api/ui/articles and add staging verification smoke seed
Wire GET /api/ui/articles (documented but missing) so curl/JQ checks work against the article log.
Add idempotent seed helper, npm run seed:smoke-verification, and admin POST /ui/seed/smoke-verification for operators without SSH to the CT.

Paperclip-Issue: BIT-21924
Paperclip-Run: 4105a0ac-e90c-477f-8065-10419988abdf
2026-05-12 13:04:59 +00:00
Paperclip Agent a6965c3321 feat(observability): BIT-21258 — Promtail sidecar config and install script
ai-news-writer-ci / test (pull_request) Successful in 35s
Add tools/observability/promtail-config.yml (Promtail sidecar for CT 223,
tails logs/combined.log + logs/error.log, pushes to Loki on CT 224:3100,
serves Prometheus metrics on :9080) and install-promtail-sidecar.sh for
one-step deployment on the LXC.

Paperclip-Issue: BIT-21258
Paperclip-Run: a5947bea-742f-4322-ba54-ec14c7e83548
Paperclip-Agent: Tiago Neves (urlKey tiago-neves; id 5d084b36-f38f-42a5-a92a-520005afda4f)
2026-05-09 18:58:58 +00:00
Patrícia SantosandPaperclip 38ebc60ad9 feat(security): BIT-5254 implement audit logging for secret access
- Add src/logger/audit.js: dedicated audit logger writing to logs/audit.log
  and logs/combined.log; events: secret.access, secret.missing,
  secrets.loaded, auth.success, auth.failure; never logs secret values
- Integrate audit.logSecretAccess() and audit.logSecretsLoaded() into
  SecretsManager.get() and load() in src/config/secrets.js
- Integrate audit.logAuthAttempt() into adminOk() in src/http/ui-auth.js,
  distinguishing no_token / invalid_token / no_admin_token_configured
- Add audit_log() function to tools/deploy/lxc-secrets-inject.sh writing
  JSON events to syslog (security.info) and stderr for gitea.secret.fetched,
  gitea.secret.fetch_failed, lxc.injection.started, lxc.injection.completed
- Add src/logger/audit.test.js covering all exported functions (11 cases)
- All 341 tests pass

Co-Authored-By: Paperclip <[email protected]>
2026-04-28 00:39:46 +00:00
Patrícia Santos 61fb553aad fix(secrets): map BIT-4619 Gitea secret names in LXC injector
ai-news-writer-ci / test (pull_request) CTO override: tests pass locally (npm test exit 0); CI runner infrastructure issue (pre-existing, all runs failing)
Gitea Actions: default CTO override: tests pass locally (npm test); CI runner infrastructure issue is pre-existing. BIT-14627 merge authorized.
Gitea repository secrets may use WORDPRESS_USER, WORDPRESS_PASSWORD, and
APP_ADMIN_SECRET; the application reads WP_USER, WP_PASSWORD, and ADMIN_TOKEN.
The inject script now writes the canonical keys into secrets.env.

Document the mapping in the LXC deploy runbook, secrets management guide, and
Gitea Actions workflow header.

Paperclip-Issue: BIT-4619
Paperclip-Run: cb503de5-fd4b-4820-b0c5-79a21c605c45
2026-04-25 07:48:51 +00:00
David Santos d3907457c4 Merge remote-tracking branch 'origin/main' into tmp-sync-pr2
ai-news-writer-ci / test (pull_request) Failing after 32s
2026-04-22 22:52:13 +01:00
spark ceb44981d3 Merge pull request 'ops(ai-news-writer): performance monitoring and observability (BIT-3601)' (#6) from task/BIT-3601-observability into main
ai-news-writer-ci / test (push) Failing after 30s
2026-04-22 22:51:02 +01:00
Xika (Agent) a0eb0e15e7 ops(verify-deploy): assert Prometheus /metrics on LXC smoke
Extend tools/verify-deploy.sh so post-deploy checks cover BIT-3601
observability: same base URL as /health must serve exposition with
engagement_collector_runs_total.

Paperclip-Agent: Tiago Neves (urlKey tiago-neves; id 5d084b36-f38f-42a5-a92a-520005afda4f)
Paperclip-Issue: BIT-3601
Paperclip-Run: 78ec1a70-a56f-4ede-af38-7f835dcb84db
2026-04-18 10:14:36 +00:00
Xika (Agent) b8973db6ef ops(ai-news-writer): backup and DR runbooks, article-index backup script, CI fixes
ai-news-writer-ci / test (pull_request) Failing after 27s
- Add BACKUP_STRATEGY, BACKUP_TESTING, DISASTER_RECOVERY runbooks and link them from README and docs/runbooks/README.
- Fix tools/backup-article-index.sh: JSONL line validation, correct staged-diff check before commit, current-branch push, optional Paperclip trailers, commit without hooks that inject forbidden lines.
- Ignore runtime article-index and local .backup/ in .gitignore.
- Circuit breaker: apply OPEN→HALF_OPEN timeout before recordSuccess/recordFailure so half-open probes work without a prior isAvailable call.
- Correlation IDs: generate 15-digit UTC timestamps to match the documented/tested format.
- ESLint: remove unused imports and unused test context parameters so npm run lint passes.

Paperclip-Issue: BIT-3508

Paperclip-Run: 4f18682c-8058-4c73-a14e-44988984e7e9
2026-04-17 20:48:04 +00:00
Xika (Agent)andPaperclip d8d3aa40d0 feat: Add LXC deployment automation (BIT-4603 Phase 3)
- tools/deploy/lxc-secrets-inject.sh: Gitea API secret injection script
  * Fetches secrets from Gitea repository settings
  * Injects into LXC container at /etc/ai-news-writer/secrets.env
  * Handles authentication, permissions, verification
  * Supports dry-run mode (--verify flag)
  * Comprehensive error handling and logging

- docs/runbooks/DEPLOY_LXC.md: Complete deployment runbook
  * Quick start (5-minute deploy)
  * Step-by-step guide with phases
  * Verification procedures
  * Rollback strategies
  * Troubleshooting for common issues
  * Monitoring and maintenance schedules

Enables automated secret injection without:
- Committing .env files to git
- Manual secret copying to containers
- Hard-coded credentials in deployment scripts

Phase 3 subtasks (not yet assigned):
- 3.1: Script creation ✅
- 3.2: Runbook creation ✅
- 3.3: Testing (pending)

Paperclip-Issue: BIT-4603
Co-Authored-By: Paperclip <[email protected]>
2026-04-17 16:47:14 +00:00
Planner 0d2d3c01a4 ci(ai-news-writer): harden Gitea deploy SSH with pinned host keys (BIT-3601)
ai-news-writer-ci / test (pull_request) Failing after 43s
Add tools/ci/gitea-actions-ssh-config.sh and require STAGING_SSH_KNOWN_HOSTS /
PROD_SSH_KNOWN_HOSTS secrets (ssh-keyscan output). Deploy jobs use ssh -F with
StrictHostKeyChecking yes instead of disabling host key verification.
CI parses deploy workflow YAML alongside test.yml.

Paperclip-Issue: BIT-3601
Paperclip-Run: 10d053b5-5cec-45ff-ba5f-29bb21da30d3
2026-04-16 23:54:18 +00:00
Planner 461887840a feat(ai-news-writer): surface metrics in /health and verify /metrics on deploy (BIT-3883)
ai-news-writer-ci / test (pull_request) Failing after 50s
The /health JSON now includes metrics_summary for ops probes without a full scrape.
tools/verify-deploy.sh fetches /metrics and validates the JSON export shape after /health.

Paperclip-Issue: BIT-3883
Paperclip-Run: a918f127-e680-4b48-a3b0-1b2f67e62b39
2026-04-16 23:45:19 +00:00
David Santos 495143690f feat(wp): XML-RPC connectivity probe (system.listMethods)
Node tests / test (push) Has been cancelled
Add xmlrpc-client with serializer/parser (fast-xml-parser), local stub tests,
and npm run wp:probe-xmlrpc for each configured site wp_url. Reuses WP retry
env and exports wpRetryOpts from wordpress.js. Optional OPS_CHECK_XMLRPC=1 in
ops-check.sh after wp:test. Publish path remains REST-only; probe validates
BIT-353 XML-RPC surface for hosts that disable or restrict REST.

Made-with: Cursor
2026-03-25 04:19:15 +00:00
David Santos 2b14db7304 feat(health): expose listen_auto_cron (AUTO_CRON)
Node tests / test (push) Has been cancelled
Same default as src/index.js listen mode (*/30 * * * *). Shown on /health,
ops landing RSS line, and verify-deploy.sh.

Made-with: Cursor
2026-03-25 03:52:52 +00:00
David Santos 953ea7d482 fix(ui): timeout reading POST bodies + /health field
Node tests / test (push) Has been cancelled
- body-read-timeout: parse HTTP_BODY_READ_TIMEOUT_MS (default 120s; 0 = no limit)
- collectBody: destroy socket and reject on timeout; warn log
- /health: http_body_read_timeout_ms (null when unlimited)
- verify-deploy + .env.example; unit tests for parser

Made-with: Cursor
2026-03-25 03:29:11 +00:00
David Santos bd27b446a5 feat(tools): deploy-lxc.sh for git pull + npm ci + PM2 reload
Node tests / test (push) Has been cancelled
- tools/deploy-lxc.sh: ff-only pull, production npm ci, pm2 startOrReload
  ecosystem.config.cjs --update-env; optional --with-ops-check
- package.json: npm run deploy:lxc
- README: commands table + deploy section note

Made-with: Cursor
2026-03-25 03:03:09 +00:00
David Santos 20b94eadf9 feat(http): security headers, deploy_revision on /health
Node tests / test (push) Has been cancelled
- security-headers: mergeResponseHeaders (nosniff + referrer-policy)
- status-server + ui-handlers: all responses use merged headers
- /health: Cache-Control no-store; deploy_revision from DEPLOY_REVISION or GIT_REVISION
- verify-deploy + .env.example: document deploy revision envs
- security-headers.test.js

Made-with: Cursor
2026-03-25 02:37:54 +00:00
David Santos c29b05e6a3 feat(store): bound article JSONL growth + /health size
Node tests / test (push) Has been cancelled
- article-log: trim oldest lines when file exceeds ARTICLE_LOG_TRIM_AT_BYTES
  and line count > ARTICLE_LOG_MAX_LINES (defaults 2MiB / 10000)
- Optional ARTICLE_LOG_PATH (absolute or relative to repo root)
- getArticleLogPath(), getArticleLogHealthFields(); LOG_FILE getter kept
- /health: article_log_bytes; verify-deploy echoes it
- test: trim behaviour with temp log path

Made-with: Cursor
2026-03-25 02:24:37 +00:00
David Santos 5ef4fd9605 feat(listen): CRON_TIMEZONE (IANA) + idle HTTP close on shutdown
Node tests / test (push) Has been cancelled
- util/iana-timezone: shared Intl validation for node-cron + /health
- rss-listener: pass timezone into cron.schedule when valid; warn if invalid
- status-server: rss_cron_timezone on /health (null when unset/invalid)
- HTTP close(): closeIdleConnections() when available (Node 18+)
- verify-deploy + .env.example: document CRON_TIMEZONE
- tests: iana-timezone.test.js

Made-with: Cursor
2026-03-25 01:58:06 +00:00
David Santos ee05af933a feat(ops): process diagnostics, /health pid+node, cron option
Node tests / test (push) Has been cancelled
- runtime/process-diagnostics: log unhandledRejection; uncaughtException + exit 1
- index: install once at startup (all CLI modes)
- status-server /health: pid, node_version
- verify-deploy: print pid and node version
- rss-listener: explicit recoverMissedExecutions: false (default; documented in code)

Made-with: Cursor
2026-03-25 01:38:47 +00:00
David Santos 2b4725424b fix(rss): no-overlap cron ticks + overlap counter in /health
Node tests / test (push) Has been cancelled
Long-running auto mode (detect → write → WP) could overlap the next cron
fire and stack work. Skip overlapping runs with a warn log; expose
rss_listener_overlap_skips in listen-state for /health and verify-deploy.

Made-with: Cursor
2026-03-25 01:25:44 +00:00
David Santos 451853b03e feat(http): inbound timeouts, /health exposure, PM2 kill_timeout
Node tests / test (push) Has been cancelled
- status-server: set requestTimeout/headersTimeout (defaults 120s/125s; env
  HTTP_REQUEST_TIMEOUT_MS / HTTP_HEADERS_TIMEOUT_MS; auto-fix headers ≤ request)
- /health + verify-deploy: echo http_*_timeout_ms for ops
- ecosystem.config.cjs: kill_timeout 15s for graceful SIGTERM path
- .env.example: document timeout vars

Made-with: Cursor
2026-03-25 01:12:44 +00:00
David Santos 82f905d730 test(ops): listen-state unit tests; ops-check runs npm test
Node tests / test (push) Has been cancelled
Add src/runtime/listen-state.test.js (fresh module load per case).
ops-check.sh runs npm test before rss:test. verify-deploy.sh prints RSS
tick fields when present. README ops:check row updated.

Made-with: Cursor
2026-03-25 00:42:49 +00:00
David Santos 2ebab7e2bc docs(tools): clarify ops-check wp:test preconditions
Made-with: Cursor
2026-03-24 21:15:01 +00:00
David Santos d6b819cf28 feat(tools): add ops:check for post-clone smoke tests
Runs rss:test always; wp:test only when WP env or real site JSON exists.
Document in README commands table and LXC deploy steps.

Made-with: Cursor
2026-03-24 21:14:54 +00:00
David Santos f68b5cda7f feat(tools): add verify-deploy.sh for LXC/NPM smoke tests
Validates /health returns ok + mode listen with non-zero exit on failure.
Document npm run verify:deploy in README.

Made-with: Cursor
2026-03-24 20:12:46 +00:00
David Santos cd84efe0b8 chore(deploy): add PM2 ecosystem.config.cjs for listen mode
Single command `pm2 start ecosystem.config.cjs` avoids forgetting `-- listen`.
Document npm script, README deploy path, and Proxmox post-create hints.

Made-with: Cursor
2026-03-24 20:01:22 +00:00
David Santos 297649b5f9 docs(deploy): clarify LXC is manual on Proxmox; fix PM2 echo in script
README explains that CT 223 is not created by the repo alone, adds
verification commands and a PT note for NPM/IP alignment. Proxmox helper
echo now matches the full pm2 listen command. CLI usage text documents
the HTTP surface in listen mode.

Made-with: Cursor
2026-03-24 19:48:16 +00:00
David Santos d6248c3f8b fix(deploy): serve HTTP on PORT in listen mode for NPM proxy
The domain pointed at :3200 had no listener: the app was CLI-only and
default PM2 start ran write mode (exits). Listen mode now starts a small
HTTP server on HOST:PORT (defaults 0.0.0.0:3200) with / and /health.
README and Proxmox script document pm2 "listen" and LXC verification.

Ref: BIT-353 board feedback on ainews.bitreport.pt.
Made-with: Cursor
2026-03-24 19:30:55 +00:00
David SantosandPaperclip d48dc3b87c feat: initial AI News Writer system (BIT-353)
Standalone autonomous news writing system — RSS crawler, journalist AI,
WordPress export, social listening, and LXC provisioning script.

- src/crawler/rss.js: fetch + normalize RSS feeds; keyword filter
- src/crawler/scraper.js: cheerio-based full article scraper
- src/writer/ai.js: OpenAI journalist AI (article generation + topic detection)
- src/publisher/wordpress.js: WP REST API export (tags auto-created)
- src/listener/rss-listener.js: cron-based live RSS monitoring
- src/config/loader.js: sources + site config loader
- src/index.js: manual write + auto listener entry points
- config/sources.json: RSS feeds (Record, A Bola, BBC, ESPN, Reuters...)
- config/sites/example.json: WP site config template
- tools/proxmox/create_ai_news_writer_lxc.sh: LXC provisioning (CT 223, Ubuntu 24, 2C/4GB/20GB)
- .env.example, README.md, package.json

RSS crawler validated: 158 articles from 9 feeds, 18 keyword-matched (live test 2026-03-23).

Paperclip-Issue: BIT-353
Paperclip-Run: 0c1d51c2-8394-475c-bced-e0ae237f4314
Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-23 15:52:38 +00:00