22 Commits
Author SHA1 Message Date
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
Nelson Baptista 0ab7e7ef1d feat(config): align sources example, env docs, and secrets precedence notes
ai-news-writer-ci / test (pull_request) Successful in 1m27s
- Add config/sources.example.json for new installs; document in ops README
- Extend .env.example with WP_CATEGORY, QUEUE_MAX_DEPTH, and optional analytics/pipeline/writing-style vars
- Fix secrets.js merge-order comment to match implementation
- Validate sources.domain_filter_mode (strict|warn|log) at startup
- Fix status-server test cleanup var HTTP_BODY_READ_TIMEOUT_MS
- Replace nonexistent OPENAI_TIMEOUT_MS hint in incident runbook

Paperclip-Agent: David Santos (id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376)
Paperclip-Issue: BIT-4294
Paperclip-Run: bc46f5b4-65d4-462a-8b56-e991c4aca0c1
2026-05-08 12:58:49 +00:00
Xika (Agent)andPaperclip d3f5a94ace docs(http-retry): phases 5-7 complete — docs, deprecation warnings, observability
**Phase 5: Documentation Updates**
- Update .env.example with unified HTTP_* vars and deprecation notice
- Update README.md environment vars table (mark legacy vars deprecated)
- Update textual references in README to new unified configuration

**Phase 6: Deprecation Warnings**
- Add deprecationWarningFor() helper in HttpRetryConfig
- Log warnings when legacy component-specific env vars are used
- Provide migration path in warning messages

**Phase 7: Observability**
- Add toObservability() method to expose config state for metrics
- Enable debugging of which env vars took precedence
- Add 3 new unit tests for observability functionality

All 35 HttpRetryConfig tests passing, 213 total tests passing.

Paperclip-Issue: BIT-4296
Co-Authored-By: Paperclip <[email protected]>
2026-04-18 00:22:43 +00:00
PlannerandClaude Haiku 4.5 c902994fcb feat: Implement enhanced article metadata editing (BIT-3884)
Core Features:
- Article metadata editing: title, subtitle, slug, tags, category
  - Edit modal UI with form validation
  - POST /ui/articles/{id}/edit endpoint
  - Slug uniqueness validation with proper error messages

- Bulk tag assignment for multiple articles
  - Select/deselect all checkboxes
  - POST /ui/articles/bulk/assign-tags endpoint
  - Batch metadata updates

- Quality scoring integration:
  - Flesch-Kincaid readability grade calculation
  - Article word count validation
  - Keyword density analysis
  - Quality score (0-100) with detailed issue breakdown
  - Integration with article logging and metrics

- Article metadata storage enhancements:
  - Support for tags (max 20 per article)
  - Support for category field
  - Quality metrics storage (score, status, issues)
  - Atomic file operations for data persistence

Configuration:
- Added QUALITY_MIN_SCORE (default 60)
- Added QUALITY_MIN_WORD_COUNT (default 300)
- Added QUALITY_MAX_READABILITY_GRADE (default 8)

The feature provides:
- Web UI for editorial control of article metadata
- Automatic quality assessment of generated articles
- Bulk operations for efficient content management
- Comprehensive validation and error handling
- Persistent storage of all metadata changes

All changes are backward compatible and properly logged.

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
2026-04-17 05:06:08 +00:00
Paperclip 492918d861 feat: add PUBLISH_HOURS editorial window for WordPress status
Node tests / test (push) Has been cancelled
Parse PUBLISH_HOURS in the config loader, resolve post status against
CRON_TIMEZONE and the half-open hour window, and thread the result through
REST and XML-RPC publish paths. Expose publish_hours fields on GET /health,
document env vars, and add unit tests.

Paperclip-Agent: Miguel Teixeira (urlKey miguel-teixeira; id 0f722e1a-bc3e-4381-8d98-76fa3c7aea10)
Paperclip-Issue: BIT-1940
Paperclip-Run: 04613601-88af-4aaf-8a81-770dd9ff3c91
Made-with: Cursor
2026-04-09 21:51:06 +00:00
David Santos 5010e34a5f feat(wp): optional XML-RPC publish (wp.newPost) and credential test
Node tests / test (push) Has been cancelled
- Add wp-http-options.js (shared retries) and wp-transport.js (rest vs xmlrpc).
- publishToWordPress / testConnection branch on wp_transport site field or WP_TRANSPORT.
- xmlrpc-client: publishArticleXmlRpc, testConnectionXmlRpc, extractScalarParam.
- UI publishers table shows transport; wp:test JSON includes wp_transport.
- Tests: wp-transport + XML-RPC publish stub.

REST remains default; link fallback uses ?p=<id> for XML-RPC posts.

Made-with: Cursor
2026-03-25 04:34: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 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 7f941e3cf7 chore(pm2): auto DEPLOY_REVISION from git in ecosystem
Node tests / test (push) Has been cancelled
When DEPLOY_REVISION/GIT_REVISION are unset, ecosystem.config.cjs runs
git rev-parse --short HEAD at pm2 start so /health deploy_revision matches
the checkout. Documented in README and .env.example.

Made-with: Cursor
2026-03-25 02:50:38 +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 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 c87d221995 feat(x): retry recent-search via http-retry; add Gitea Actions test job
Node tests / test (push) Has been cancelled
X API v2 search uses axiosGetWithRetry (429, 502–504, transient network).
New env: X_HTTP_MAX_ATTEMPTS (default 3), X_RETRY_BASE_MS (default 1000ms).

Add .gitea/workflows/test.yml to run npm ci && npm test on push/PR.

Made-with: Cursor
2026-03-25 00:14:50 +00:00
David Santos 11350b2f3e feat(rss): use shared http-retry for feed GET; add unit tests
RSS fetch uses axiosGetWithRetry + parseString so transient policy matches
WP/scraper. New env: RSS_HTTP_MAX_ATTEMPTS, RSS_RETRY_BASE_MS.

Add http-retry policy tests; fix npm test to discover *.test.js via find.

Made-with: Cursor
2026-03-25 00:01:37 +00:00
David Santos 07880405d3 feat(scraper): retry article GET on transient HTTP/network errors
Align with WP/OpenAI: 429 and 5xx gateway, common socket errors, timeout
message. Env SCRAPER_HTTP_MAX_ATTEMPTS and SCRAPER_RETRY_BASE_MS.

Made-with: Cursor
2026-03-24 23:30:03 +00:00
David Santos 8f2ad454e9 feat(ui): simple admin pages /ui for titles, sources, social, theme
- Append generated article metadata to data/article-index.jsonl for listing
- HTML UI: /ui, /ui/sources, /ui/social, /ui/publishers, /ui/theme
- Saves require ADMIN_TOKEN; optional Bearer for future API use
- GET /api/ui/articles JSON; config/ui-theme.example.json for accents
- README and .env.example document access control expectations

Made-with: Cursor
2026-03-24 23:17:53 +00:00
David Santos 574e6a5ddd feat(ai): retry OpenAI chat completions on transient errors
chatCompletionWithRetry for generateArticle and detectTopics; env
OPENAI_MAX_ATTEMPTS and OPENAI_RETRY_BASE_MS.

Made-with: Cursor
2026-03-24 22:55:45 +00:00
David Santos 34faf38911 feat(wp): configurable retries for all REST calls
Add axiosGetWithRetry; use for tag search, tag create, and users/me.
WP_HTTP_MAX_ATTEMPTS and WP_RETRY_BASE_MS env vars (documented).
Guard tag search when response body is not an array.

Made-with: Cursor
2026-03-24 22:41:42 +00:00
David Santos d31e158b84 feat(crawler): bounded RSS concurrency + env HTTP tuning
fetchAllFeeds processes feeds in chunks (RSS_FETCH_CONCURRENCY, default 3).
RSS timeout and User-Agent from env; scraper shares HTTP_USER_AGENT and
SCRAPER_TIMEOUT_MS. Document in .env.example and README.

Made-with: Cursor
2026-03-24 21:27:28 +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