40 Commits
Author SHA1 Message Date
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
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
Planner d8fc8c4d98 ci: Gitea Actions pipeline for ai-news-writer (BIT-3394)
ai-news-writer-ci / test (pull_request) Failing after 32s
Align workflow with BIT-2731: lint, npm test under c8 with lcov, upload
coverage artifact, optional Codecov via repository secret. Document
branch protection and forge URLs in README; ignore coverage output.

Fix ESLint (auto-fix plus strict equality) so the lint job is green.
Disable c8 global check-coverage until overall line coverage catches up;
reports and artifacts remain for Codecov and local review.

Made-with: Cursor
2026-04-15 02:28:56 +00:00
Paperclip 3727e11129 feat(ui): editorial status and approve/reject actions on /ui
Node tests / test (push) Has been cancelled
- Persist editorial_status on new article log rows; add updateArticleStatus() with atomic rewrite
- Dashboard: badges, flash from ?flash=, POST /ui/articles/:id/approve|reject (ADMIN_TOKEN)
- Tests for article log; README documents endpoints and proxy note

Paperclip-Run: 5aeedb07-8f14-40bb-b737-79354c25d4c1
Paperclip-Task: ca360b61-1e05-47bc-ad3c-b1d78ce7d104
2026-04-09 21:55:32 +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 628fbd4533 feat(health): wp_publish_by_transport counts on /health and ops page
Node tests / test (push) Has been cancelled
2026-03-25 04:47:15 +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 0780e68279 fix(ui): 415 for non-form Content-Type on POST /ui/*
Node tests / test (push) Has been cancelled
Admin saves parse the body as URLSearchParams (x-www-form-urlencoded).
Reject application/json, multipart, etc. before collectBody; log WARN.
Add ui-form-post helper + tests; README note.

Made-with: Cursor
2026-03-25 03:41:14 +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 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 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 d13a1706c7 feat(health): expose RSS listener last cron tick on /health
Node tests / test (push) Has been cancelled
Record each listener iteration in listen-state; JSON adds
rss_listener_last_tick_at, rss_listener_last_tick_ok,
rss_listener_last_tick_error. Ops HTML shows tick summary when listener
is active.

Made-with: Cursor
2026-03-25 00:29:01 +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 77024a71d4 feat(http): expose OpenAI config flags on /health and ops page
Add openai_api_key_configured and ai_model to JSON; show on landing HTML.

Made-with: Cursor
2026-03-24 23:10:01 +00:00
David Santos 8e239cbe3d fix(listen): keep HTTP up if RSS listener fails; document NPM 502
- loadSources/loadSocial: tolerate invalid JSON (log + safe fallback)
- runAutoMode: catch listener startup errors so the status server stays
  bound for probes and NPM debugging
- /health + ops page: rss_listener_active flag for degraded state
- README: 502 checklist (PM2, port, NPM upstream, firewall, curl from NPM)

Made-with: Cursor
2026-03-24 23:06:05 +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 fa0818ff7c feat(http): ops landing page at / and /dashboard for listen mode
Adds a read-only HTML page (PT) explaining where to open the service,
which endpoints exist, and that the editorial dashboard is still
out of scope. Reuses existing config probes for RSS/X/WP flags.
Documents HTTP surface in README.

Made-with: Cursor
2026-03-24 22:53:22 +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 ee330c8319 fix(wp): retry REST post create on transient failures
Up to 3 attempts with exponential backoff for 429, 502-504, and common
network errors before surfacing publish failure.

Made-with: Cursor
2026-03-24 22:29:30 +00:00
David Santos 63dbe77249 refactor(crawler): centralize RSS+X merge in merge-sources.js
fetchMergedSourceArticles used by manual write and rss-listener; single
log line on X aggregate failure.

Made-with: Cursor
2026-03-24 22:17:26 +00:00
David Santos c5e197d707 feat(write): merge optional X tweets into manual write sources
Align manual mode with listen: RSS + social.json recent search, sorted by
time. Skip HTTP scrape for source=x (tweet text stays in summary).

Made-with: Cursor
2026-03-24 22:05:16 +00:00
David Santos 86421a202a feat(http): extend /health with listen feature flags
Expose rss_feed_count, x_queries_configured, x_listening, and
wp_credentials_configured (no secrets, no network) for NPM/ops probes.

Made-with: Cursor
2026-03-24 21:53:42 +00:00
David Santos 560ad9716f feat(x): optional X API v2 recent search in listen mode
- config/social.example.json + loadSocialConfig; social.json gitignored.
- fetchXAsArticles merges tweets with RSS before keyword filter.
- x:test / npm run x:test probes queries + bearer token.

Made-with: Cursor
2026-03-24 21:41:35 +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 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 3b35420053 fix(config): replace dead RSS feeds in default sources
Reuters (deprecated host), A Bola 404, and malformed UEFA XML broke
rss:test and reduced crawler yield. Use Guardian + RTP Notícias feeds
verified with rss-parser; refresh trusted_domains.

Made-with: Cursor
2026-03-24 21:02:35 +00:00
David Santos 8b71437c8d feat(rss): retries + rss:test feed probe
- fetchFeed: up to 3 attempts with exponential backoff (500ms base).
- fetchFeedWithResult for structured outcomes; rss:test prints JSON per feed.

Made-with: Cursor
2026-03-24 20:48:26 +00:00
David Santos c80d44dfda feat(cli): wp:test validates all site configs
When multiple config/sites/*.json exist, probe each via REST users/me;
aggregate { ok, sites } on stdout. Incomplete site files fail fast.

Made-with: Cursor
2026-03-24 20:35:31 +00:00
David Santos bd23f10250 feat(cli): add wp:test for WordPress REST credential check
Uses existing testConnection (users/me). Exits non-zero on failure;
prints one-line JSON on success for scripting.

Made-with: Cursor
2026-03-24 20:23:58 +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 6e70fbe1b3 feat(http): enrich /health with version, mode, and HEAD support
Helps ops verify NPM/LXC deployments are running listen mode and the
expected package version, not a one-shot write process.

Made-with: Cursor
2026-03-24 19:59:45 +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
spark 2ffbfdc3dd Initial commit 2026-03-23 15:48:46 +00:00