## Summary
- Install c8 (coverage), ESLint, and Prettier as devDependencies
- Add .eslintrc.json with Node.js/async-safe rules
- Add .prettierrc.json for code formatting consistency
- Add .nycrc.json with 80% coverage targets for statements/lines/functions, 75% for branches
- Update npm test script to use c8 for coverage reporting (generates HTML + text reports)
- Add lint, lint:fix, and format npm scripts
## Baseline Coverage
Initial run shows 26.4% line coverage, well below 80% target. Modules with 0% coverage:
- src/index.js (main entry point)
- src/crawler/* (RSS, scraper, X/Twitter crawlers)
- src/publisher/wordpress.js (WordPress integration)
- src/listener/* (RSS listener)
- src/writer/ai.js (AI news writing)
These are high-risk modules that need test expansion per BIT-2861.
Implements BIT-2837 Phase 1 per plan.
Paperclip-Run-Id: fb08becb-e019-4cb3-ae50-fb72a4b11745
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
Creates minimal docs/runbooks/README.md with links to deploy, PM2, 502 recovery,
verification commands, and config reference — all pointing back to root README.md
sections. No content duplication.
Paperclip-Issue: BIT-1923
Paperclip-Agent: patricia-santos
Co-Authored-By: Paperclip <[email protected]>
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
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
- Block TRACE, TRACK, CONNECT before any handler (Allow: GET, HEAD, POST)
- /health and / landing: only GET/HEAD; otherwise 405 with correct Allow
- HEAD / and /dashboard supported (same as /health pattern)
- security-headers: writeMethodNotAllowed helper + unit test
- Ops HTML endpoint list updated
Made-with: Cursor
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
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
PM2 and systemd send SIGTERM on stop/restart; only handling SIGINT left
cron and HTTP listening after process exit. Consolidate shutdown: guard
re-entry, stop cron, clear rss_listener_active, close HTTP server.
Made-with: Cursor
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
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
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
- 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
- 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
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
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
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
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
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
- fetchFeed: up to 3 attempts with exponential backoff (500ms base).
- fetchFeedWithResult for structured outcomes; rss:test prints JSON per feed.
Made-with: Cursor
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
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
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