Skip to content

feat(ai-agents): Twitter auto-responder with AI summaries#59

Open
madidnyc wants to merge 64 commits intosteipete:mainfrom
madidnyc:ai-agents-implementation
Open

feat(ai-agents): Twitter auto-responder with AI summaries#59
madidnyc wants to merge 64 commits intosteipete:mainfrom
madidnyc:ai-agents-implementation

Conversation

@madidnyc
Copy link

Summary

  • Standalone application monitoring Twitter for AI agent posts by 50K+ influencers
  • Automated PDF summary generation via Manus API
  • PNG conversion and reply posting within 5-minute window
  • Conservative rate limits prevent spam detection (10-15/day, 10min gaps)
  • SQLite state management for deduplication and rate limiting
  • Comprehensive test coverage (unit, integration, E2E)

Test Plan

  • Unit tests pass (config, filters, templates, database)
  • Integration tests pass (filter+DB, Manus API)
  • E2E tests pass (full pipeline, real Twitter search)
  • Lint and type check pass
  • Dry-run mode tested locally
  • Production mode tested with real credentials (manual)

🤖 Generated with Claude Code

madidnyc and others added 30 commits January 19, 2026 13:49
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Responder class that orchestrates Bird reply flow
- Upload PNG via client.uploadMedia()
- Select random template and build reply text via ReplyTemplateManager
- Post reply with media attachment via client.reply()
- Full dry-run mode support: skip Bird calls, log payload, return fake ID
- Log media upload size and reply success metadata

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix TypeScript type errors in responder.ts:
- Use cookieSource instead of source in resolveCredentials options
- Fix TweetResult discriminated union handling (no error on success branch)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Removed rootDir constraint from tsconfig.json to allow scripts directory
to be included in type checking alongside src directory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
madidnyc and others added 30 commits January 19, 2026 16:01
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Verified: bun run tsc --noEmit - no type errors
Task 2.6 [VERIFY] Quality checkpoint passed without fixes needed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Wrap poller.search() with retry using birdSearch config
- Wrap generator.generate() with circuit breaker protection
- Handle circuit breaker open state: log warning and skip cycle
- Circuit breaker tracks state in DB via recordManusSuccess/recordManusFailure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create src/utils/errors.ts with error detection utilities:
  - isAuthError() for 401/403 detection
  - isDatabaseError() for SQLite errors
  - isCriticalError() for process-exit conditions
  - classifyError() for full error categorization
- Update index.ts runCycle() with proper error handling:
  - Auth errors in search/reply stages exit immediately
  - Critical database errors exit to prevent corruption
  - Non-critical errors logged and skipped
- All components use result pattern consistently

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Verified: bun run tsc --noEmit - no type errors
Task 2.9 [VERIFY] Quality checkpoint passed without fixes needed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Note: Graceful shutdown was already implemented in the POC phase.
This commit marks task 2.10 as complete after verification.

Implementation matches design.md exactly:
- SIGTERM/SIGINT handlers registered at startup
- shutdown(signal) logs shutdown_initiated with signal name
- Sets running = false to stop new cycles
- Waits for currentCyclePromise with Promise.race() and 5min timeout
- Closes DB via db.close()
- Logs shutdown_complete
- Exits with process.exit(0)

Verified: Process exits cleanly on SIGTERM after completing current cycle.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Verified: bun run tsc --noEmit - no type errors
Task 2.12 [VERIFY] Quality checkpoint passed. Phase 2 complete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Filter pipeline unit tests added (33 tests passing).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix TypeScript strict mode errors in test files:
- config.test.ts: Add proper type casting through unknown for deepMerge
- filter.test.ts: Apply same fix for Config type conversion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Verified: bun run test - 76 tests passed
Verified: bun run tsc --noEmit - no type errors (after fixes)
Fixed TypeScript type conversion errors in test files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reply template unit tests added (34 tests, 460 assertions).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Exclude database.test.ts from vitest (uses bun:sqlite, Bun-specific)
- Update test script to run both vitest and bun tests
- Add test:vitest and test:bun scripts for individual runners

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Verified: bun run test - 167 tests passed (vitest: 110, bun: 57)
Fixed test configuration to run vitest + bun tests sequentially.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Verified: bun test src/__tests__/integration/ - 36 tests passed
Integration tests working: filter-db (26), manus (10).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Verified: bun run test - 235 tests passed
Complete test suite: unit (110), integration (36), E2E (32), database (57).
Phase 3 Testing complete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add biome.json from bird root with code style rules
- Add lint scripts to package.json:
  - lint: Run both Biome and Oxlint
  - lint:biome: biome check src/
  - lint:oxlint: oxlint src/
  - lint:fix: biome check --write src/
- Fix all Biome lint errors across codebase:
  - Replace non-null assertions with proper guards
  - Move regex literals to top-level constants
  - Add explicit types for implicit any
  - Use block statements consistently
  - Use template literals over concatenation
- All 235 tests passing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Verified: lint (0 issues), check-types (pass), test (235 passing)
Full local CI suite passes successfully.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant