oh-my-pr 1.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KimY
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,348 @@
1
+ # Code Factory - Get to unsupervised software development
2
+ ## Autonomous PR improvements to release management
3
+
4
+ <p align="center">
5
+ <img width="409" height="409" alt="image__7_-removebg-preview" src="https://github.com/user-attachments/assets/ca339a71-40d9-4619-900f-55825f30a57f" />
6
+ </p>
7
+
8
+
9
+ **Autonomous GitHub PR babysitter — watches your repos, triages review feedback, dispatches AI agents to fix code, and creates releases**
10
+
11
+ [![npm version](https://img.shields.io/npm/v/oh-my-pr.svg)](https://www.npmjs.com/package/oh-my-pr)
12
+ [![CI](https://github.com/yungookim/codefactory/actions/workflows/ci.yml/badge.svg)](https://github.com/yungookim/codefactory/actions/workflows/ci.yml)
13
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
14
+ [![Node.js 22+](https://img.shields.io/badge/Node.js-22%2B-green.svg)](https://nodejs.org/)
15
+ [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](https://www.typescriptlang.org/)
16
+
17
+ ---
18
+
19
+ > Stop babysitting pull requests manually. Code Factory watches your GitHub repos, syncs review comments into a local dashboard, auto-triages feedback, and launches Claude Code CLI or Codex agents to fix everything — all running on your machine.
20
+
21
+ > **Note:** This project is intended for those obsessed with development speed and is still in development.
22
+
23
+ ---
24
+
25
+ <img width="1365" height="686" alt="SCR-20260318-qsva-2" src="https://github.com/user-attachments/assets/66dfa082-c732-4989-8b05-f19aa550acb5" />
26
+
27
+ ## Why Code Factory?
28
+
29
+ This is what Code Factory is good at:
30
+ 1. Watch the PR to check for PR feedback from humans, agents, failing lint/tests, conflicts etc and auto-fix them
31
+ 2. Automatically generate lacking tests for all open PR
32
+ 3. Auto-generate and update user-facing documents
33
+
34
+ Code Factory runs locally and uses the CLI coding agents that are already installed in your machine. No need to add OPEN_API_KEY or any such. Just install & have it running and let it do its thing.
35
+
36
+ <p align="center">
37
+ <img src="docs/architecture-diagram.svg" alt="Code Factory Architecture" width="900" />
38
+ </p>
39
+
40
+ Managing PR feedback across multiple repositories is tedious. Review comments pile up, context-switching kills productivity, and small fixes sit idle for hours. Code Factory automates the entire feedback loop:
41
+
42
+ - **Watch** one or more GitHub repositories for open pull requests
43
+ - **Sync** review comments, reviews, and discussion threads into persistent local storage
44
+ - **Triage** feedback into `accept`, `reject`, or `flag` buckets — automatically or manually
45
+ - **Dispatch** Claude or Codex agents in isolated git worktrees to apply approved changes
46
+ - **Ask** follow-up questions about PR status, feedback, and activity from the dashboard
47
+ - **Resolve** merge conflicts automatically using AI-powered conflict resolution
48
+ - **Push** verified fixes back to the PR branch with full audit logs
49
+
50
+ All of this happens locally on your machine. No hosted service, no data leaving your environment.
51
+
52
+ ## How It Works
53
+
54
+ On startup, Code Factory restores the watcher schedule, resumes interrupted runs, and starts a sync cycle immediately.
55
+
56
+ <img width="969" height="572" alt="image" src="https://github.com/user-attachments/assets/b9dbd102-ae2e-4837-a862-a0282bdfa0b8" />
57
+
58
+
59
+ 1. Add a repository to the watch list or register a PR directly by URL.
60
+ 2. The watcher polls GitHub, auto-registers open PRs, archives PRs that closed upstream, and queues babysitter runs.
61
+ 3. Each run syncs PR metadata and review feedback into SQLite and mirrored logs while preserving prior decisions and run state.
62
+ 4. The babysitter evaluates pending comments and failing CI statuses with the configured agent; accepted items become actionable tasks.
63
+ 5. If work is needed, Code Factory prepares an app-owned repo cache and isolated worktree under `~/.codefactory`, and resolves merge conflicts there when needed.
64
+ 6. The agent works inside that isolated worktree, runs verification, commits, and pushes directly to the PR branch.
65
+ 7. Code Factory re-syncs GitHub, posts follow-up comments, resolves review threads, polls CI on the new commit, and returns the PR to `watching`.
66
+
67
+ ## Features
68
+
69
+ | Feature | Description |
70
+ |---------|-------------|
71
+ | **Multi-repo watching** | Monitor multiple GitHub repos simultaneously |
72
+ | **PR registration** | Add individual PRs by URL for one-off tracking |
73
+ | **Smart triage** | Auto-categorize feedback with manual override support |
74
+ | **Agent flexibility** | Choose between Claude and Codex for code remediation |
75
+ | **PR Q&A** | Ask the configured agent questions about a PR and get context-aware answers from feedback and logs |
76
+ | **Isolated worktrees** | Agent runs happen in detached git worktrees — zero risk to your working copy |
77
+ | **Persistent state** | SQLite-backed storage survives restarts |
78
+ | **Activity logs** | Daily mirrored log files with full run details |
79
+ | **Trusted reviewers** | Configure whose feedback gets auto-accepted |
80
+ | **Conflict resolution** | Automatically resolve merge conflicts using AI agents |
81
+ | **Bot filtering** | Ignore noise from dependabot, codecov, and other bots |
82
+ | **Real-time dashboard** | React-based UI with live status, triage controls, PR Q&A, and config management |
83
+
84
+ ## Tech Stack
85
+
86
+ | Layer | Technology |
87
+ |-------|-----------|
88
+ | **Server** | Node.js 22+, TypeScript (strict), Express 5 |
89
+ | **Client** | React 18, Vite, TanStack Query, Tailwind CSS, shadcn/ui |
90
+ | **Storage** | SQLite via `node:sqlite`, Drizzle ORM |
91
+ | **GitHub** | Octokit + `gh auth token` fallback |
92
+ | **Agents** | Claude CLI or Codex CLI |
93
+ | **Testing** | Node test runner with tsx |
94
+
95
+ ## Quick Start
96
+
97
+ ### Prerequisites
98
+
99
+ - **Node.js 22+** (tested with Node v24.12.0)
100
+ - **npm**
101
+ - **git**
102
+ - A GitHub token (via `GITHUB_TOKEN`, app config, or `gh auth login`)
103
+ - Either `codex` or `claude` CLI installed
104
+
105
+ ### Install & Run
106
+
107
+ ```bash
108
+ # Install globally from npm
109
+ npm install -g oh-my-pr
110
+
111
+ # Start the server
112
+ oh-my-pr
113
+ ```
114
+
115
+ The server starts on port `5001` (configurable via `PORT`) and serves both the API and the dashboard.
116
+
117
+ ### Install from Source
118
+
119
+ ```bash
120
+ # Clone the repository
121
+ git clone https://github.com/yungookim/codefactory.git
122
+ cd codefactory
123
+
124
+ # Install dependencies
125
+ npm install
126
+
127
+ # Start in development mode
128
+ npm run dev
129
+ ```
130
+
131
+ ### Production Build (from source)
132
+
133
+ ```bash
134
+ npm run build # Build the production bundle
135
+ npm run start # Start the production server
136
+ ```
137
+
138
+ ### Other Commands
139
+
140
+ ```bash
141
+ npm run check # TypeScript strict typecheck
142
+ npm run lint # ESLint validation
143
+ npm run test # Run all tests
144
+ npm run db:push # Push Drizzle schema changes
145
+ ```
146
+
147
+ ## Authentication
148
+
149
+ GitHub auth is resolved in order:
150
+
151
+ 1. `GITHUB_TOKEN` environment variable
152
+ 2. Token stored in app config (via the dashboard)
153
+ 3. `gh auth token` (GitHub CLI fallback)
154
+
155
+ ## Configuration
156
+
157
+ All configuration is managed through the dashboard or the API. Persisted settings include:
158
+
159
+ | Setting | Description |
160
+ |---------|-------------|
161
+ | **Agent** | `codex` or `claude` |
162
+ | **Model** | Model name for the selected agent |
163
+ | **Max turns** | Maximum agent conversation turns |
164
+ | **Polling interval** | How often to check GitHub for updates |
165
+ | **Batch window** | Time window for batching feedback |
166
+ | **Max changes per run** | Limit on changes per agent execution |
167
+ | **Watched repositories** | List of repos to monitor |
168
+ | **Trusted reviewers** | Reviewers whose feedback is auto-accepted |
169
+ | **Ignored bots** | Bot accounts to filter out (defaults: dependabot, codecov, github-actions) |
170
+
171
+ ## Local State & Filesystem
172
+
173
+ | Path | Purpose |
174
+ |------|---------|
175
+ | `~/.codefactory/state.sqlite` | Durable app state |
176
+ | `~/.codefactory/log/` | Daily mirrored activity logs |
177
+ | `~/.codefactory/repos/` | App-owned repo caches used to create clean PR worktrees |
178
+ | `~/.codefactory/worktrees/` | Isolated PR worktrees for agent runs |
179
+
180
+ Override the root path with the `CODEFACTORY_HOME` environment variable.
181
+
182
+ ## API Reference
183
+
184
+ The dashboard communicates with the server through a REST API:
185
+
186
+ | Method | Endpoint | Description |
187
+ |--------|----------|-------------|
188
+ | `GET` | `/api/repos` | List watched repositories |
189
+ | `POST` | `/api/repos` | Add a repository to watch |
190
+ | `GET` | `/api/prs` | List tracked pull requests |
191
+ | `GET` | `/api/prs/:id` | Get PR details with feedback |
192
+ | `POST` | `/api/prs` | Register a PR by URL |
193
+ | `DELETE` | `/api/prs/:id` | Remove a tracked PR |
194
+ | `POST` | `/api/prs/:id/fetch` | Force-refresh PR feedback |
195
+ | `POST` | `/api/prs/:id/triage` | Run triage on a PR |
196
+ | `POST` | `/api/prs/:id/apply` | Apply accepted changes via agent |
197
+ | `POST` | `/api/prs/:id/babysit` | Run full babysit cycle |
198
+ | `PATCH` | `/api/prs/:id/feedback/:feedbackId` | Update feedback triage status |
199
+ | `GET` | `/api/prs/:id/questions` | List PR question/answer history |
200
+ | `POST` | `/api/prs/:id/questions` | Ask the configured agent a question about the PR |
201
+ | `GET` | `/api/logs` | Retrieve activity logs |
202
+ | `GET` | `/api/config` | Get current configuration |
203
+ | `PATCH` | `/api/config` | Update configuration |
204
+
205
+ ## Project Structure
206
+
207
+ ```
208
+ client/ React dashboard (Vite + Tailwind + shadcn/ui)
209
+ server/ Express API, babysitter logic, GitHub integration, storage
210
+ shared/ Shared Zod schemas and TypeScript types
211
+ script/ Build tooling
212
+ docs/plans/ Design and implementation planning documents
213
+ tasks/ Project lessons and working notes
214
+ ```
215
+
216
+ ## For OpenClaw agents
217
+
218
+ This section is addressed to you, the OpenClaw agent. Read it in full before interacting with Code Factory.
219
+
220
+ ### What you can do
221
+
222
+ You have access to Code Factory via its MCP server. Code Factory is a local PR babysitter: it watches GitHub repositories, syncs review feedback, triages it, and dispatches AI agents to apply fixes. Every feature is available to you as an MCP tool.
223
+
224
+ ### Step 1 — Check whether Code Factory is already running
225
+
226
+ Before doing anything, verify the server is up:
227
+
228
+ ```
229
+ GET http://localhost:5001/api/runtime
230
+ ```
231
+
232
+ If you get a `200` response, Code Factory is running and you can proceed to Step 3. If the connection is refused, go to Step 2.
233
+
234
+ ### Step 2 — Install and start Code Factory
235
+
236
+ Run these shell commands on the local machine:
237
+
238
+ ```bash
239
+ npm install -g oh-my-pr
240
+ oh-my-pr &
241
+ ```
242
+
243
+ Or from source:
244
+
245
+ ```bash
246
+ git clone https://github.com/yungookim/codefactory.git
247
+ cd codefactory
248
+ npm install
249
+ npm run dev &
250
+ ```
251
+
252
+ Wait until you see `serving on port 5001` in the output, then confirm with `GET http://localhost:5001/api/runtime` before continuing.
253
+
254
+ ### Step 3 — How to use your MCP tools
255
+
256
+ All tools communicate with `http://localhost:5001` over the local network only. External requests are blocked. Call tools in this order for common workflows:
257
+
258
+ **Watch a new repository and process its PRs**
259
+ 1. `add_repo` — add the repo slug (e.g. `"owner/repo"`)
260
+ 2. `sync_repos` — trigger an immediate fetch from GitHub
261
+ 3. `list_prs` — inspect what was found
262
+
263
+ **Handle a specific PR end-to-end**
264
+ 1. `get_pr` — read current state and feedback items
265
+ 2. `triage_pr` — auto-classify all un-triaged feedback
266
+ 3. `apply_pr_fixes` — dispatch the AI agent to apply accepted items
267
+ — or use `babysit_pr` to do all three in one call
268
+
269
+ **Investigate a PR**
270
+ 1. `fetch_pr_feedback` — force a fresh pull from GitHub
271
+ 2. `get_logs` with `pr_id` — read the full activity history
272
+ 3. `ask_pr_question` — ask a natural-language question; poll the returned question `id` via `list_pr_questions` until `status` is `"answered"`
273
+
274
+ **Override a triage decision**
275
+ - `set_feedback_decision` with `decision: "accept" | "reject" | "flag"`
276
+
277
+ **Graceful shutdown before a deploy**
278
+ 1. `set_drain_mode` with `enabled: true, wait_for_idle: true`
279
+ 2. Wait for `activeRuns: 0` in the response
280
+ 3. Perform your deploy, then call `set_drain_mode` with `enabled: false`
281
+
282
+ ### Available tools
283
+
284
+ | Tool | What it does |
285
+ |------|-------------|
286
+ | `list_repos` | List all watched repositories |
287
+ | `add_repo` | Add a repo (`owner/repo` or full URL) to the watch list |
288
+ | `sync_repos` | Force an immediate sync cycle across all repos |
289
+ | `list_prs` | List all actively tracked PRs |
290
+ | `list_archived_prs` | List archived (closed/merged) PRs |
291
+ | `get_pr` | Get full PR details including every feedback item |
292
+ | `add_pr` | Register a PR by its full GitHub URL |
293
+ | `remove_pr` | Remove a PR from tracking |
294
+ | `fetch_pr_feedback` | Force-refresh GitHub comments and reviews for a PR |
295
+ | `triage_pr` | Auto-triage all un-triaged feedback on a PR |
296
+ | `apply_pr_fixes` | Dispatch AI agent to apply accepted feedback |
297
+ | `babysit_pr` | Full cycle: sync → triage → apply in one call |
298
+ | `set_feedback_decision` | Manually set `accept`, `reject`, or `flag` on a feedback item |
299
+ | `retry_feedback_item` | Re-queue a failed or warned feedback item |
300
+ | `list_pr_questions` | List Q&A history for a PR |
301
+ | `ask_pr_question` | Ask the AI agent a question about a PR (async — poll for answer) |
302
+ | `get_logs` | Get activity logs; pass `pr_id` to filter to one PR |
303
+ | `get_config` | Read current configuration (token is redacted) |
304
+ | `update_config` | Partially update configuration |
305
+ | `get_agent_models` | List available AI models for each agent type |
306
+ | `refresh_agent_models` | Re-discover installed agent models |
307
+ | `get_runtime` | Get runtime state: drain mode status and active run count |
308
+ | `set_drain_mode` | Enable or disable drain mode |
309
+ | `list_changelogs` | List generated social-media changelogs |
310
+ | `get_changelog` | Get one changelog by ID |
311
+ | `get_onboarding_status` | Check GitHub Actions workflow status for watched repos |
312
+ | `install_review_workflow` | Install the Code Factory review workflow on a repo |
313
+
314
+ Full parameter schemas are in [LOCAL_API.md](LOCAL_API.md).
315
+
316
+ ### Error conditions you must handle
317
+
318
+ | Error | Meaning | Action |
319
+ |-------|---------|--------|
320
+ | Connection refused on port 5001 | Server is not running | Run `npm run dev` in the codefactory directory |
321
+ | `403 Forbidden` | Request did not come from localhost | Ensure you are calling `127.0.0.1`, not a hostname that resolves externally |
322
+ | `409 Conflict` | Drain mode is active | Call `set_drain_mode` with `enabled: false` first, or wait for the drain to complete |
323
+ | `404 Not Found` | PR or feedback item ID is wrong | Call `list_prs` to get valid IDs before acting on them |
324
+
325
+ ### If something is broken or missing, file a GitHub issue
326
+
327
+ If you encounter a bug, an unexpected error response, a missing tool, or behaviour that does not match this documentation, create a GitHub issue so the maintainers can fix it.
328
+
329
+ **Issue URL:** `https://github.com/yungookim/codefactory/issues/new`
330
+
331
+ Include the following in the issue body:
332
+ - What you were trying to do (the goal)
333
+ - Which tool or endpoint you called and with what parameters
334
+ - The exact error or unexpected response you received
335
+ - The output of `get_logs` filtered to the relevant PR (if applicable)
336
+ - The output of `get_runtime` at the time of the failure
337
+
338
+ Use a clear title such as `[OpenClaw] <tool_name> returns unexpected 500 when X`.
339
+
340
+ ---
341
+
342
+ ## Contributing
343
+
344
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
345
+
346
+ ## License
347
+
348
+ [MIT](LICENSE) — Copyright 2026 KimY
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ process.env.NODE_ENV = process.env.NODE_ENV || "production";
5
+ require("../dist/index.cjs");