comfy-pr 0.2.27 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +258 -157
  2. package/bot/IdleWaiter.ts +31 -0
  3. package/bot/RestartManager.spec.ts +163 -0
  4. package/bot/RestartManager.ts +190 -0
  5. package/bot/WorkingTasksManager.spec.ts +154 -0
  6. package/bot/cli.ts +1171 -0
  7. package/bot/codesearch-ai-wip.ts +351 -0
  8. package/bot/error-collector.ts +133 -0
  9. package/bot/index.ts +14 -0
  10. package/bot/restart-example.ts +99 -0
  11. package/bot/slack-bolt.ts +688 -0
  12. package/bot/slack-bot.ts +1575 -0
  13. package/bot/state.ts +19 -0
  14. package/bot/templateLoader.test.ts +84 -0
  15. package/bot/templateLoader.ts +92 -0
  16. package/next.config.ts +26 -0
  17. package/package.json +161 -41
  18. package/post-summary.ts +44 -0
  19. package/src/Authors.ts +2 -2
  20. package/src/CMNodes.ts +3 -3
  21. package/src/CNRepos.ts +30 -7
  22. package/src/CRNodes.ts +11 -9
  23. package/src/CRPulls.ts +3 -0
  24. package/src/EmailTasks.ts +27 -9
  25. package/src/FORK_OWNER.ts +3 -1
  26. package/src/FollowRules.ts +3 -3
  27. package/src/GithubIssueComments.ts +1 -1
  28. package/src/Totals.ts +9 -8
  29. package/src/WorkerInstances.ts +31 -8
  30. package/src/addCommentAction.ts +19 -11
  31. package/src/analyzePullsStatus.ts +39 -17
  32. package/src/analyzeTotals.ts +19 -11
  33. package/src/bypassRepos.ts +6 -5
  34. package/src/checkPRsFailures.ts +13 -8
  35. package/src/cli.test.ts +2 -0
  36. package/src/cli.ts +1 -1
  37. package/src/constants.ts +2 -0
  38. package/src/createComfyRegistryPRsFromCandidates.ts +20 -12
  39. package/src/createComfyRegistryPullRequests.ts +35 -10
  40. package/src/createGithubForkForRepo.ts +36 -11
  41. package/src/createGithubPullRequest.ts +83 -33
  42. package/src/createIssueComment.ts +4 -4
  43. package/src/fetchComfyRegistryNodes.ts +34 -4
  44. package/src/fetchCurrentGeoInfo.ts +3 -1
  45. package/src/fetchRelatedPullWithComments.ts +1 -1
  46. package/src/fetchRepoDescriptionMap.ts +1 -4
  47. package/src/followRuleSchema.ts +10 -4
  48. package/src/getBranchWorkingDir.ts +3 -7
  49. package/src/getRepoWorkingDir.ts +2 -3
  50. package/src/gh.spec.ts +571 -0
  51. package/src/ghData.ts +13 -0
  52. package/src/ghPageFlow.ts +33 -0
  53. package/src/ghSubscriber.ts +76 -0
  54. package/src/ghUser.ts +28 -4
  55. package/src/index.ts +13 -4
  56. package/src/initializeFollowRules.ts +11 -4
  57. package/src/logger.spec.ts +95 -0
  58. package/src/logger.ts +46 -0
  59. package/src/makeGpl3LicenseBranch.ts +66 -0
  60. package/src/makePublishBranch.ts +21 -15
  61. package/src/makeTomlBranch.ts +48 -14
  62. package/src/makeUpdateTomlLicenseBranch.ts +40 -44
  63. package/src/matchRelatedPulls.ts +9 -4
  64. package/src/normalizeGithubUrl.spec.ts +131 -0
  65. package/src/normalizeGithubUrl.ts +64 -0
  66. package/src/parseIssueUrl.spec.ts +95 -0
  67. package/src/parseIssueUrl.ts +17 -3
  68. package/src/parseOwnerRepo.spec.ts +147 -0
  69. package/src/parseOwnerRepo.ts +8 -5
  70. package/src/parsePullsState.ts +2 -2
  71. package/src/parseTitleBodyOfMarkdown.ts +1 -1
  72. package/src/pickRepoInfo.ts +37 -0
  73. package/src/postSlackMessage.ts +5 -1
  74. package/src/preload.ts +30 -27
  75. package/src/readTemplateTitle.ts +1 -3
  76. package/src/sendEmailAction.ts +14 -10
  77. package/src/sendGmail.ts +3 -3
  78. package/src/updateAuthorsForGithub.ts +53 -35
  79. package/src/updateAuthorsFromCNRepo.ts +12 -5
  80. package/src/updateCMNodesDuplicationWarnings.ts +14 -9
  81. package/src/updateCMRepos.ts +1 -1
  82. package/src/updateCNRepos.ts +14 -14
  83. package/src/updateCNReposCRPullsComments.ts +7 -5
  84. package/src/updateCNReposInfo.ts +49 -40
  85. package/src/updateCNReposPRCandidate.ts +3 -3
  86. package/src/updateCNReposPulls.ts +9 -5
  87. package/src/updateCNReposPullsDashboard.ts +11 -9
  88. package/src/updateCNReposRelatedPulls.ts +3 -3
  89. package/src/updateCRNodes.ts +24 -5
  90. package/src/updateCRRepos.ts +1 -1
  91. package/src/updateComfyTotals.ts +7 -5
  92. package/src/updateFollowRuleSet.ts +17 -9
  93. package/src/updateOutdatedPullsTemplates.ts +61 -48
  94. package/src/updateSlackMessages.ts +8 -4
  95. package/tailwind.config.ts +7 -1
  96. package/next-env.d.ts +0 -5
  97. package/src/GIT_USEREMAIL.ts +0 -5
  98. package/src/GIT_USERNAME.ts +0 -9
  99. package/src/clone_modify_push_Branches.ts +0 -21
  100. package/src/tomlFillDescription.ts +0 -17
package/README.md CHANGED
@@ -1,247 +1,348 @@
1
1
  # Comfy-PR
2
2
 
3
- Make PRs that helps comfy community grow with [Comfy.org](https://comfy.org/).
3
+ A comprehensive automation platform for [ComfyUI Custom Node](https://registry.comfy.org/) development and publishing. Comfy-PR helps Custom Node authors streamline their publishing workflow by automating repository setup, pull request creation, and ongoing maintenance.
4
4
 
5
- ## Project Goals: (aka roadmap)
5
+ ## Features
6
6
 
7
- ### Cli usage:
7
+ - 🔄 **Automated PR Creation**: Clone repos, update `pyproject.toml`, initialize GitHub Actions, and create PRs
8
+ - 📊 **Analytics Dashboard**: Web-based dashboard with statistics, CSV/YAML exports, and repository insights
9
+ - 🔗 **GitHub Webhook Integration**: Real-time monitoring of issues, PRs, and comments
10
+ - ⚡ **Performance Optimized**: Cached GitHub API client with SQLite storage (5min TTL)
11
+ - 📋 **Task Management**: Automated task execution with progress tracking
12
+ - 🎯 **Rule-Based Follow-ups**: Configurable automation rules for different PR states
8
13
 
9
- - [x] fork repo
10
- - [x] clone repo locally
11
- - [x] create pyproject branch, run comfy node init . Push branch.
12
- - [x] create publish branch, create in a Github workflow file. Push branch.
13
- - [x] create PR to original repository with template PR description.
14
- - [x] Submit PR
15
- - [x] Clean local debris before clone
16
- - [x] DOING: Export PR status into csv for @haohao
14
+ ## Comfy-PR Project Goals
17
15
 
18
- ### Github Actions Workerds
16
+ The Comfy-PR project aims to support and streamline the process for Custom Node Authors to publish their work in the Comfy Registry. Here's why this initiative is essential:
19
17
 
20
- - [x] Fetch repos from CM & CR list
21
- - [x] Make diff
22
- - [x] Notify to slack channel
23
- - [x] Fetch repo status (private or archived or ...)
24
- - [x] Fetch pr status (open / merged / closed) + comments
25
- - [x] Fetch pr comments
26
- - [x] Automaticaly find candidates, and do the cli does
27
- - [x] Mention related prs in dashboard https://github.com/drip-art/Comfy-Registry-PR/issues/1
28
- - [x] Analyze Totals
29
- - [x] license schema updator
30
- - [x] bypass repo
31
- - [ ] Follow-up prs by state
32
- - [ ] Issues Comment
33
- - [ ] Slack
34
- - [ ] Email
35
- - [ ] Delete the forked repo which is Merged
18
+ 1. **Simplify Node Publishing**: Provide tools and assistance to make publishing Custom Nodes straightforward, allowing authors to concentrate on development rather than the complexities of the publishing process.
19
+ 2. **Expand Node Availability**: Streamlined publishing will increase the number of Custom Nodes in the Comfy Registry, enriching the ecosystem and offering more options to users.
20
+ 3. **Encourage Collaboration**: Scanning GitHub repositories and providing follow-up support fosters collaboration, knowledge-sharing, and a stronger sense of community among Custom Node Authors and users.
21
+ 4. **Ensure Quality and Compliance**: Automate checks and provide guidance to maintain high-quality standards and compliance within the Comfy Registry.
22
+ 5. **Resolve Publishing Issues Promptly**: Address Custom Node Authors' issues during the publishing process quickly, reducing frustration and improving the overall user experience.
23
+ 6. **Strengthen the Comfy Community**: Help solve users' problems with Custom Node uploading and publishing, contributing to a more vibrant, supportive, and engaged community.
24
+ 7. **Promote Innovation**: Lower barriers to publishing Custom Nodes to encourage innovation and creativity within the community, leading to the development of novel and exciting nodes.
36
25
 
37
- ### Web Site https://comfy-pr.vercel.app
26
+ Through these efforts, Comfy-PR seeks to create an environment where Custom Node Authors can thrive and users can access a diverse and high-quality array of Custom Nodes.
38
27
 
39
- - [x] A dashboard csv/yaml exporter site for @haohao
40
- - [x] pr dashboard
28
+ ## Architecture Overview
41
29
 
42
- ## Admin
30
+ ### Core Components
43
31
 
44
- ### Changing PR Owner
32
+ 1. **CLI Tool** (`src/cli.ts`): Command-line interface for processing individual repositories
33
+ 2. **Main Service** (`src/index.ts`): Orchestrates batch processing of repositories
34
+ 3. **Web Dashboard** (`app/`): Next.js application with analytics and management UI
35
+ 4. **Webhook Service** (`run/index.ts`): Real-time GitHub event monitoring
36
+ 5. **Task System** (`app/tasks/`): Automated background tasks for various operations
45
37
 
46
- If you wish to change which Github account the Pull Requests come from, then you need to place a Github token into the **[Actions Secrets](https://github.com/drip-art/Comfy-Registry-PR/settings/secrets/actions )**
38
+ ### Key Features
47
39
 
48
- `GH_TOKEN_COMFY_PR = ************`
40
+ #### CLI Operations
49
41
 
50
- ## Usages
42
+ - ✅ Repository forking and local cloning
43
+ - ✅ Automated `pyproject.toml` setup via `comfy node init`
44
+ - ✅ GitHub Actions workflow creation and publishing
45
+ - ✅ Template-based PR creation with descriptions
46
+ - ✅ Clean workspace management
51
47
 
52
- ### CLI Usage: Get Started by
48
+ #### Analytics & Monitoring
53
49
 
54
- ```
55
- bunx comfy-pr [...GITHUB_REPO_URLS]
56
- ```
50
+ - ✅ Repository status tracking (private/archived/active)
51
+ - ✅ PR status monitoring (open/merged/closed) with comments
52
+ - ✅ Statistical analysis and reporting
53
+ - ✅ CSV/YAML data exports
54
+ - ✅ Related PR cross-referencing
55
+
56
+ #### Automation Engine
57
+
58
+ - ✅ Rule-based follow-up actions
59
+ - ✅ Slack notifications
60
+ - ✅ Email task management
61
+ - ✅ License schema updates
62
+ - ✅ Repository bypass logic
63
+ - 🔄 Auto-cleanup of merged forks (in progress)
64
+
65
+ ### Web Dashboard
57
66
 
58
- ### 1. Setup Envs
67
+ Access the dashboard at https://comfy-pr.vercel.app
59
68
 
60
- A demo .env should be sth like:
69
+ - 📊 Repository statistics and analytics
70
+ - 📈 Interactive charts and visualizations
71
+ - 📋 Task management interface
72
+ - 📤 Data export tools (CSV/YAML)
73
+ - 🔍 PR status monitoring and filtering
61
74
 
62
- ```sh
63
- # your github token
64
- GH_TOKEN=ghp_WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
75
+ ## Configuration
65
76
 
66
- # the pr source organization/ leave it blank to use yourself's account.
77
+ ### Environment Variables
78
+
79
+ #### Core Settings
80
+
81
+ ```bash
82
+ # GitHub API token (required)
83
+ GH_TOKEN=ghp_your_github_token_here
84
+
85
+ # PR source organization (optional - defaults to your account)
67
86
  FORK_OWNER="ComfyNodePRs"
68
87
 
69
- # PR prefix
88
+ # PR branch prefix (optional)
70
89
  FORK_PREFIX="PR-"
90
+
91
+ # MongoDB connection (for dashboard/analytics)
92
+ MONGODB_URI=mongodb://localhost:27017
71
93
  ```
72
94
 
73
- #### Github API Token (GH_TOKEN)
95
+ #### Webhook Service (Optional)
74
96
 
75
- GO https://github.com/settings/tokens?type=beta to get an Github Access key
97
+ ```bash
98
+ # Enable real-time webhook monitoring
99
+ USE_WEBHOOKS=true
100
+ GITHUB_WEBHOOK_SECRET=your_secure_webhook_secret
101
+ WEBHOOK_BASE_URL=https://your-domain.com
102
+ PORT=8080
103
+ ```
76
104
 
77
- Check 3 permissions for all of your repositories
105
+ ### GitHub Token Setup
78
106
 
79
- - Pull requests Access: Read and write
80
- - Workflows Access: Read and write
81
- - Metadata Access: Read-only
107
+ 1. Go to [GitHub Personal Access Tokens](https://github.com/settings/tokens?type=beta)
108
+ 2. Create a fine-grained token with these permissions:
109
+ - **Pull requests**: Read and write
110
+ - **Workflows**: Read and write
111
+ - **Metadata**: Read-only
112
+ - **Repository hooks**: Read and write (for webhooks)
82
113
 
83
- And save your GH_TOKEN into .env file
114
+ ### SSH Key Setup
84
115
 
85
- #### Github SSH Key (.ssh/id_rsa, .ssh/id_rsa.pub)
116
+ Required for automated git operations:
86
117
 
87
- Must provide to push code automaticaly, btw prob. you've already setup.
118
+ ```bash
119
+ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
120
+ cat ~/.ssh/id_rsa.pub
121
+ # Add the public key to https://github.com/settings/keys
122
+ ```
88
123
 
89
- Run `ssh-keygen`, got `id_rsa.pub`, Then add into here https://github.com/settings/keys
124
+ ## Quick Start
90
125
 
91
- ### 2. Run!
126
+ ### CLI Usage
92
127
 
93
- Ways to run this script
128
+ ```bash
129
+ # Install and run for specific repositories
130
+ bunx comfy-pr [GITHUB_REPO_URLS...]
94
131
 
95
- 1. Local run
96
- 2. Docker run (also local)
97
- 3. Docker run at cloud (TODO)
132
+ # Process from a file list
133
+ bunx comfy-pr --repolist repos.txt
98
134
 
99
- #### 1. Launch by Docker Compose
135
+ # Use environment variable
136
+ REPO=https://github.com/owner/repo bunx comfy-pr
137
+ ```
100
138
 
101
- After configured your .env file, run docker compose build and up.
139
+ ### Examples
102
140
 
103
- ```sh
104
- git clone https://github.com/drip-art/Comfy-Registry-PR
105
- cd Comfy-Registry-PR
106
- docker compose build
107
- docker compose up
108
- ```
141
+ ```bash
142
+ # Process a single repository
143
+ bunx comfy-pr https://github.com/example/my-comfy-node
109
144
 
110
- #### 2. Docker usage (not stable)
145
+ # Process multiple repositories
146
+ bunx comfy-pr \
147
+ https://github.com/user1/node-a \
148
+ https://github.com/user2/node-b
111
149
 
112
- ```sh
113
- docker run --rm -it \
114
- -v $HOME/.ssh:/root/.ssh:ro \
115
- -e GH_TOKEN=ghp_WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW \
116
- -e REPO=https://github.com/snomiao/ComfyNode-Registry-test \
117
- snomiao/comfy-registry-pr
150
+ # Use a repository list file
151
+ echo "https://github.com/example/repo1" > repos.txt
152
+ echo "https://github.com/example/repo2" >> repos.txt
153
+ bunx comfy-pr --repolist repos.txt
118
154
  ```
119
155
 
120
- #### 3. Run native in Unix/Linux/MacOS/WSL
156
+ ## Installation & Setup
121
157
 
122
- ```sh
123
- git clone https://github.com/drip-art/Comfy-Registry-PR
158
+ ### Prerequisites
124
159
 
125
- # setup comfy-cli environment
126
- cd Comfy-Registry-PR
127
- python3 -m venv .venv
128
- chmod +x ./.venv/bin/*
129
- source ./.venv/bin/activate
130
- pip3 install comfy-cli
160
+ - [Bun](https://bun.sh) runtime
161
+ - Python 3.x with `comfy-cli` installed
162
+ - Git with SSH key configured
163
+ - GitHub Personal Access Token
164
+
165
+ ### Local Development
166
+
167
+ ```bash
168
+ # Clone the repository
169
+ git clone https://github.com/Comfy-Org/Comfy-PR
170
+ cd Comfy-PR
131
171
 
172
+ # Install dependencies
173
+ bun install
174
+
175
+ # Setup Python environment for comfy-cli
176
+ python3 -m venv .venv
177
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
178
+ pip install comfy-cli
132
179
 
180
+ # Configure environment
181
+ cp .env.example .env
182
+ # Edit .env with your settings
133
183
 
134
- # setup bun for js-script
135
- curl -fsSL https://bun.sh/install | bash
136
- bun i
184
+ # Run CLI tool
185
+ bun src/cli.ts https://github.com/example/my-comfy-node
137
186
 
138
- # and
139
- bun src/cli.ts [REPO_PATH_NEED_TO_PR]
140
- # for example
141
- bun src/cli.ts https://github.com/snomiao/ComfyNode-Registry-test
187
+ # Run main service (batch processing)
188
+ bun src/index.ts
142
189
 
190
+ # Start web dashboard
191
+ bun run dev # Available at http://localhost:3000
143
192
  ```
144
193
 
145
- #### 4. Run natively in Windows
194
+ ### Production Deployment
146
195
 
147
- ```bat
196
+ #### Docker Compose (Recommended)
148
197
 
149
- git clone https://github.com/drip-art/Comfy-Registry-PR
198
+ ```bash
199
+ # Configure environment
200
+ cp .env.example .env
201
+ # Edit .env with production settings
150
202
 
151
- @REM setup comfy-cli environment
152
- cd Comfy-Registry-PR
153
- python3 -m venv .venv
154
- .\.venv\Scripts\activate
155
- pip3 install comfy-cli
203
+ # Deploy with Docker Compose
204
+ docker compose up -d
205
+ ```
156
206
 
157
- @REM run with tsx
158
- npx -y cross-env REPO=https://github.com/snomiao/ComfyNode-Registry-test npx -y tsx src/cli.ts
207
+ #### Manual Docker
159
208
 
209
+ ```bash
210
+ docker run --rm -it \
211
+ -v $HOME/.ssh:/root/.ssh:ro \
212
+ -e GH_TOKEN=your_github_token \
213
+ -e MONGODB_URI=mongodb://localhost:27017 \
214
+ comfy-org/comfy-pr
160
215
  ```
161
216
 
162
- #### Other Configurations in dockerfile
217
+ #### Cloud Deployment
218
+
219
+ The webhook service can be deployed to:
163
220
 
164
- Don't change it unless you know what you are doing.
221
+ - **Vercel**: `vercel --prod`
222
+ - **Google Cloud Run**: `cd run && ./deploy.sh`
223
+ - **Railway**: `railway deploy`
224
+ - **Heroku**: Standard Node.js deployment
165
225
 
166
- ```dockerfile
226
+ ## Development
167
227
 
168
- ENV FORK_OWNER=drip-art
169
- ENV FORK_PREFIX=PR-
228
+ ### Project Structure
170
229
 
171
- # Unset it into current authorized user's name and email (from your github api token).
172
- ENV GIT_USEREMAIL=comfy-ci@drip.art
173
- ENV GIT_USERNAME=comfy-ci
230
+ ```
231
+ Comfy-PR/
232
+ ├── src/ # Core utilities and business logic
233
+ │ ├── cli.ts # Command-line interface
234
+ │ ├── index.ts # Main service orchestrator
235
+ │ ├── ghc.ts # Cached GitHub API client
236
+ │ ├── db/ # Database models and utilities
237
+ │ ├── gh/ # GitHub API wrappers
238
+ │ └── utils/ # Shared utilities
239
+ ├── app/ # Next.js web dashboard
240
+ │ ├── (dashboard)/ # Dashboard pages and components
241
+ │ ├── api/ # API routes and tRPC
242
+ │ └── tasks/ # Background task implementations
243
+ ├── run/ # Production services
244
+ │ ├── index.ts # GitHub webhook service
245
+ │ └── deploy.sh # Cloud deployment scripts
246
+ ├── gh-service/ # Legacy webhook service
247
+ ├── templates/ # PR and workflow templates
248
+ └── packages/ # Internal packages
249
+ └── mongodb-pipeline-ts/ # MongoDB aggregation utilities
174
250
  ```
175
251
 
176
- ## Development
252
+ ### Development Workflow
177
253
 
178
- ### Cli
254
+ ```bash
255
+ # Install dependencies
256
+ bun install
179
257
 
180
- ```sh
181
- # Create comfy pr dir and go into it
182
- mkdir comfy-pr
183
- cd comfy-pr
258
+ # Start MongoDB (required for dashboard)
259
+ docker compose up mongodb -d
184
260
 
185
- # Prepare code and environments
186
- git clone https://github.com/drip-art/Comfy-Registry-PR .
261
+ # Initialize database
262
+ bun src/index.ts
187
263
 
188
- # Prepare bun
189
- # go here - [Installation \| Bun Docs]( https://bun.sh/docs/installation )
264
+ # Development modes:
265
+ bun run dev # Web dashboard (http://localhost:3000)
266
+ bun run dev:tsc # TypeScript compiler watch mode
267
+ bun run gh-service # Webhook service
190
268
 
191
- # Install project
192
- bun i
269
+ # Testing
270
+ bun test # Run test suite
271
+ bun test --watch # Watch mode
193
272
 
194
- # Prepare bun
195
- bun i
273
+ # Linting and building
274
+ bun run lint # ESLint
275
+ bun run build # Next.js build
196
276
  ```
197
277
 
198
- ### Github Action Worker & server
278
+ ### Running Individual Components
199
279
 
200
- 1. Setup envs in the usages section above (plz check bun src/cli.ts runnable first)
280
+ ```bash
281
+ # Process specific repositories
282
+ bun src/cli.ts https://github.com/example/repo
201
283
 
202
- 2. Run mongodb with docker compose
284
+ # Run specific tasks
285
+ bun app/tasks/coreping/coreping.ts
286
+ bun app/tasks/gh-bounty/gh-bounty.ts
203
287
 
204
- ```sh
205
- docker compose -f docker-compose.mongodb.yml up
288
+ # Update repository data
289
+ bun src/updateCNRepos.ts
290
+ bun src/updateAuthors.ts
206
291
  ```
207
292
 
208
- ```yaml
209
- services:
210
- mongdb:
211
- restart: always
212
- image: mongo
213
- ports: ["27017:27017"]
214
- volumes: [./data/mongodb:/data/db]
215
- ```
293
+ ## Advanced Usage
216
294
 
217
- And fill URI into env
295
+ ### Webhook Integration
218
296
 
219
- ```env
220
- MONGODB_URI=mongodb://localhost:27017
297
+ For real-time GitHub event monitoring:
298
+
299
+ ```bash
300
+ # Generate secure webhook secret
301
+ export GITHUB_WEBHOOK_SECRET=$(openssl rand -hex 32)
302
+
303
+ # Enable webhook mode
304
+ export USE_WEBHOOKS=true
305
+ export WEBHOOK_BASE_URL=https://your-domain.com
306
+
307
+ # Start webhook service
308
+ bun run gh-service
221
309
  ```
222
310
 
223
- 3. Play with codes...
311
+ See [WEBHOOK_SETUP.md](./WEBHOOK_SETUP.md) for detailed webhook configuration.
224
312
 
225
- ```sh
226
- # To initialize your database, run:
227
- bun src/index.ts
313
+ ### Task System
228
314
 
229
- # To start develop in any of other scripts:
230
- # Feel free to run any scripts in src/, they are safe to re-run and stop in any time.
231
- bun src/THAT_FILE_YOU_WANT_TO_RUN.ts
315
+ The platform includes several automated tasks:
232
316
 
233
- # To check if you didn't break anything?
234
- bun test --watch
317
+ - **CorePing** (`app/tasks/coreping/`): Repository health monitoring
318
+ - **GitHub Bounty** (`app/tasks/gh-bounty/`): Bounty management
319
+ - **Design Tasks** (`app/tasks/gh-design/`): Design-related automation
320
+ - **Contributor Analysis** (`app/tasks/github-contributor-analyze/`): Contribution statistics
321
+ - **Action Updates** (`app/tasks/github-action-update/`): GitHub Actions maintenance
322
+
323
+ ### Database Inspection
324
+
325
+ ```bash
326
+ # Inspect production database (read-only)
327
+ echo 'MONGODB_URI_INSPECT=mongodb://prod-readonly-uri' > .env.development.local
328
+ echo 'MONGODB_URI=$MONGODB_URI_INSPECT' >> .env.development.local
329
+
330
+ # Run inspection scripts
331
+ bun src/checkPRsFailures.ts
332
+ bun src/analyzeTotals.ts
235
333
  ```
236
334
 
335
+ ### Performance Optimization
237
336
 
238
- ## DB Inspecting
337
+ The project uses a cached GitHub API client (`src/ghc.ts`) that:
239
338
 
240
- Make .env.development.local as
339
+ - Stores responses in SQLite for 5 minutes
340
+ - Reduces API rate limiting
341
+ - Improves response times for repeated requests
241
342
 
242
- ```sh
243
- MONGODB_URI_INSPECT_HAOHAO={{that readonly db link sno gave you}}
244
- MONGODB_URI=$MONGODB_URI_INSPECT_HAOHAO
245
- ```
343
+ ```typescript
344
+ import { ghc } from "./src/ghc";
246
345
 
247
- And inspect db with script, e.g. `src/checkPRsFailures.ts`
346
+ // Use ghc instead of gh for automatic caching
347
+ const repo = await ghc.repos.get({ owner, repo });
348
+ ```
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A utility class to wait for idle periods based on activity pings.
3
+ *
4
+ * @example
5
+ * const idleWaiter = new IdleWaiter();
6
+ *
7
+ * // Somewhere in your code, when activity occurs:
8
+ * idleWaiter.ping();
9
+ *
10
+ * // To wait for an idle period of 5 seconds:
11
+ * await idleWaiter.wait(5000);
12
+ * console.log('System has been idle for 5 seconds');
13
+ */
14
+ export class IdleWaiter {
15
+ lastActivityTime = Date.now();
16
+ checkInterval = 100; // Default check interval in milliseconds
17
+
18
+ constructor() {
19
+ this.ping();
20
+ }
21
+
22
+ ping() {
23
+ this.lastActivityTime = Date.now();
24
+ return this;
25
+ }
26
+
27
+ async wait(ms: number) {
28
+ while (this.lastActivityTime >= Date.now() - ms)
29
+ await new Promise((resolve) => setTimeout(resolve, this.checkInterval));
30
+ }
31
+ }