Commit Graph

63 Commits

Author SHA1 Message Date
c9fc834f4e Fix crash log file not found error in spike
Some checks failed
CI / test (pull_request) Has been cancelled
Use getConfig("dataDir") and ensure directory exists before writing crash log, fixing ENOENT error when spike crashes.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-10 09:53:24 -07:00
57fcf9616d Merge origin/main into probablycorey/simple-logging
Some checks failed
CI / test (pull_request) Has been cancelled
Resolve conflicts:
- package.json: keep server/index.tsx paths, adopt new test commands
- discord/index.ts: adopt startDiscord() wrapper, keep log() calls
- server/index.tsx: use startDiscord() import, keep logging structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:27:12 -07:00
96b6a4311b Remove redundant sha from StoredLogEvent type
Some checks failed
CI / test (pull_request) Has been cancelled
The sha is already encoded in the log filename (releaseSha_timestamp.jsonl), so there's no need to include it per-event. This simplifies the type and storage format.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-10 09:23:51 -07:00
6b30715fa1 Add integration tests for Spike PR→Discord bridge
Some checks failed
CI / test (pull_request) Has been cancelled
Move webhook tests to root tests/ dir and restructure to be non-flaky. Setup webhook capture server once via preload, tear down on process exit. Tests now clean up their own PRs in afterEach. Added bridge test to verify Spike PRs create Discord threads. Made Discord client login explicit via startDiscord(). Updated config with new dev Discord channel and Spike username mappings.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-10 09:16:52 -07:00
04aa7c1c91 Add typed event logging system and restructure server
Implement a centralized logging system with typed events (webhook, PR, comment, review, Discord relay, errors, etc.) that feeds a pub/sub pattern. Events are logged to console (with ANSI colors: green=normal, yellow=skipped, red=errors, cyan=PR#) and persisted to JSONL files organized by git commit SHA.

Restructure server code into src/server/ directory with separate route handlers. Add a new /logs endpoint with an HTML viewer that displays events in a searchable table with type/repo filtering and browser timezone conversion. Remove the old /errors endpoint.

Improvements:
- All webhook handlers, Discord events, and errors now use log() instead of console.* calls
- Error objects are properly serialized to JSONL (message + stack extracted)
- Path traversal vulnerability fixed in readLogFile()
- Failed API calls and caught errors are now always logged
- Graceful error handling with fallbacks where appropriate (e.g., missing Discord users)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-10 08:58:47 -07:00
4bcec23c22 Merge branch 'main' into probablycorey/ai-project-structure
Some checks failed
CI / test (pull_request) Has been cancelled
2026-03-09 23:03:25 +00:00
85eea2f4ef Refactor config structure for better readability
Some checks failed
CI / test (pull_request) Has been cancelled
Split nested dev/prod config object into a Config type with separate devConfig and prodConfig objects. This makes it clearer which values apply to which environment and ensures both configs match the type.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-09 15:56:30 -07:00
a71bf2d492 Make webhook tests independent with isolated PRs and retry on merge timing issues
Some checks failed
CI / test (pull_request) Has been cancelled
Each test now creates its own PR and cleans up after itself. Tests no longer depend on shared state or ordering, making them resilient to failures.

Added retry logic to mergePR for Gitea's 404/405 responses while computing mergeability. Used crypto.randomUUID() for unique branch names instead of Date.now() to eliminate collision risk.
2026-03-09 15:56:09 -07:00
238df92888 Untangle Spike architecture with bridge pattern
Split the monolithic gitea/helpers.ts (which had Discord imports and created circular dependencies) into three focused libs:

1. **gitea/** — Pure API client: fetchPR, fetchReviewComments, convertUsername, threadName. No side effects or external deps.

2. **discord/** — Discord client setup: bot login, event listeners, slash commands. Now isolated from Gitea internals.

3. **bridge/** — New integration layer: webhook handler, DB mappings (Gitea PR ↔ Discord thread), Discord helpers, and createPRComment.

Dependencies now flow one direction: bridge → gitea and bridge → discord. No circular imports.

Added:
- Barrel exports (index.ts) for each lib with public API
- README.md for each lib documenting the barrel exports
- Comprehensive spike README.md with setup guide and architecture explanation
- Integration tests for webhooks (callback-based, no race conditions)
- Unit tests for pure API functions
- CLAUDE.md with links to each lib's README

This architecture makes it possible for AI to understand a lib by reading just its README, keeping context focused and small.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-09 15:23:11 -07:00
e46fb0dd7a Discord has a max message length of 2000, keep the PR title below that!
Some checks failed
CI / test (pull_request) Has been cancelled
2025-12-03 10:51:54 -08:00
9e7eb70b4f better
Some checks failed
CI / test (pull_request) Has been cancelled
2025-11-13 14:53:34 -08:00
f156e91bcd this is good enough
Some checks are pending
CI / test (push) Waiting to run
2025-11-13 10:59:49 -08:00
e2feb9cc1a great 2025-11-12 17:13:25 -08:00
34de1f8e40 Much better 2025-11-12 16:38:33 -08:00
fd939af0b7 This is much better
Some checks are pending
CI / test (push) Waiting to run
2025-11-12 11:49:10 -08:00
1bd8ecba7a Update webhook-handler.ts
Some checks are pending
CI / test (push) Waiting to run
2025-11-12 10:03:43 -08:00
726961ca99 let me cook
Some checks are pending
CI / test (push) Waiting to run
2025-11-12 09:55:23 -08:00
c85c61ed95 Update defunkt's name
Some checks failed
CI / test (push) Has been cancelled
2025-11-07 15:43:03 -08:00
f404f7c99b add logs 2025-11-07 15:07:24 -08:00
bff5aa05f5 spike, you are alive
Some checks failed
CI / test (push) Waiting to run
CI / test (pull_request) Has been cancelled
2025-11-07 14:58:20 -08:00
59d51c4be4 cool dude 2025-11-07 14:40:11 -08:00
a41e086d76 yes
Some checks failed
CI / test (pull_request) Has been cancelled
2025-11-07 10:31:37 -08:00
883c69d517 get that subdomain
Some checks are pending
CI / test (push) Waiting to run
2025-11-07 09:52:53 -08:00
bdf6a288b1 try it out!
Some checks are pending
CI / test (push) Waiting to run
2025-11-07 09:39:57 -08:00
3742a016aa Added cron 2025-07-25 14:15:23 -07:00
99645e3993 Add basic ci 2025-07-22 16:24:17 -07:00
c89a1849a7 Improve log fetching and Discord command handling 2025-07-22 12:10:19 -07:00
8fa8f3a2d3 wip 2025-07-22 11:09:26 -07:00
e68bf409f3 wip 2025-07-22 10:35:26 -07:00
97a4c750ad overlay! 2025-07-21 12:03:31 -07:00
258dd43e35 Update events.ts 2025-07-16 10:59:00 -07:00
17b7ab3a9d Update threadKeepAlive.ts 2025-07-16 10:54:25 -07:00
ffd7ad1fa0 Update ai.ts 2025-07-15 16:44:45 -07:00
5134446bf0 Update ai.ts 2025-07-15 16:27:18 -07:00
76a4900863 Give links 2025-07-15 14:59:51 -07:00
80afaef542 tell me about the threads! 2025-07-15 14:54:07 -07:00
c0eb5b6bca Update package.json 2025-07-15 14:17:32 -07:00
a495a5c50c revive threads 2025-07-15 14:14:07 -07:00
6dbbd74c01 wip 2025-07-14 14:47:30 -07:00
d4c725465a I went a little crazy 2025-07-11 13:05:50 -07:00
24c5ac6dc5 wip 2025-06-26 14:03:06 -07:00
429ee209f3 Update ai.ts 2025-06-26 12:20:28 -07:00
07953880af Better personality 2025-06-26 12:08:34 -07:00
21f336f78e Spike gets a facelift. 2025-06-26 11:50:03 -07:00
44eca2fc6c Better 2025-06-25 15:27:14 -07:00
0c8c5c7387 Move KV to separate files! 2025-06-23 15:17:39 -07:00
6750dc45f9 We can now mark good and bad responses from spike! 2025-06-23 14:51:31 -07:00
c2fbeef6e5 Update index.ts 2025-06-19 17:07:27 -07:00
38975981aa Handle emoji better 2025-06-19 17:06:37 -07:00
2292b3fa62 Update index.ts 2025-06-19 17:02:49 -07:00