Skip to content

Commit a7ea2e7

Browse files
authored
Merge pull request #25 from GenerationSoftware/GEN-1996-dev-agent
GEN-1996 Restructure Factorize as npm workspaces monorepo
2 parents 916a010 + d20be1e commit a7ea2e7

70 files changed

Lines changed: 127 additions & 1704 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ permissions:
1818

1919
jobs:
2020
check:
21-
name: Test and validate Worker
21+
name: Test and validate Workers
2222
runs-on: ubuntu-latest
2323
timeout-minutes: 10
2424
steps:

‎.github/workflows/deploy.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515

1616
jobs:
1717
deploy:
18-
name: Deploy Worker
18+
name: Deploy app Worker
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 15
2121
environment: production
@@ -27,8 +27,8 @@ jobs:
2727
cache: npm
2828
- run: npm ci
2929
- run: npm run build:css
30-
- name: Deploy Worker
31-
run: npm run deploy
30+
- name: Deploy app Worker
31+
run: npm run deploy:app
3232
env:
3333
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
3434
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

‎README.md‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Factorize
22

33
[![CI](https://github.com/asselstine/factorize/actions/workflows/ci.yml/badge.svg)](https://github.com/asselstine/factorize/actions/workflows/ci.yml)
4-
[![Deploy to Cloudflare](https://img.shields.io/badge/Deploy_to-Cloudflare-F38020?style=flat&logo=cloudflare&logoColor=white)](https://deploy.workers.cloudflare.com/?url=https://github.com/asselstine/factorize)
4+
[![Deploy to Cloudflare](https://img.shields.io/badge/Deploy_to-Cloudflare-F38020?style=flat&logo=cloudflare&logoColor=white)](https://deploy.workers.cloudflare.com/?url=https://github.com/asselstine/factorize&path=packages/app)
55

66
**A no-code software factory for Linear teams.** Factorize turns selected Linear issue changes into coding-agent jobs on your own exe.dev VM, using Herdr to run the agent you choose.
77

@@ -21,29 +21,29 @@ Linear webhook → Cloudflare Worker → Durable Object → exe.dev /exec → He
2121

2222
## Deploy to Cloudflare
2323

24-
Click the **Deploy to Cloudflare** button above to create a copy of this Worker in your own Cloudflare account. Cloudflare provisions the Durable Object binding and configures Workers Builds for the copied repository.
24+
Click the **Deploy to Cloudflare** button above to create a copy of the app Worker in your own Cloudflare account. The button selects `packages/app` as the Worker root; Cloudflare provisions the Durable Object binding and configures Workers Builds for the copied repository.
2525

2626
> The Deploy to Cloudflare button works for public GitHub or GitLab repositories. If you are using a private fork, deploy with Wrangler instead.
2727
2828
### Deploy with Wrangler
2929

3030
1. Clone the repository and install dependencies.
31-
2. Set `APP_ORIGIN` in `wrangler.jsonc` to your final HTTPS Worker URL or custom domain.
32-
3. Create a dedicated OAuth KV namespace with `npx wrangler kv namespace create OAUTH_KV`, then replace `REPLACE_WITH_OAUTH_KV_ID` in `wrangler.jsonc` with its ID.
31+
2. Set `APP_ORIGIN` in `packages/app/wrangler.jsonc` to your final HTTPS Worker URL or custom domain.
32+
3. Create a dedicated OAuth KV namespace with `npm exec --workspace=factorize -- wrangler kv namespace create OAUTH_KV`, then set its ID in `packages/app/wrangler.jsonc`.
3333
4. Configure the Linear OAuth callback as `https://your-domain.example/auth/linear/callback`.
3434
5. Build assets, add secrets, and deploy:
3535

3636
```bash
3737
npm ci
3838
npm run build:css
3939

40-
npx wrangler secret put LINEAR_CLIENT_ID
41-
npx wrangler secret put LINEAR_CLIENT_SECRET
42-
npx wrangler secret put LINEAR_WEBHOOK_SIGNING_SECRET
43-
npx wrangler secret put CREDENTIAL_ENCRYPTION_KEY
44-
npx wrangler secret put SESSION_SIGNING_SECRET
40+
npm exec --workspace=factorize -- wrangler secret put LINEAR_CLIENT_ID
41+
npm exec --workspace=factorize -- wrangler secret put LINEAR_CLIENT_SECRET
42+
npm exec --workspace=factorize -- wrangler secret put LINEAR_WEBHOOK_SIGNING_SECRET
43+
npm exec --workspace=factorize -- wrangler secret put CREDENTIAL_ENCRYPTION_KEY
44+
npm exec --workspace=factorize -- wrangler secret put SESSION_SIGNING_SECRET
4545

46-
npm run deploy
46+
npm run deploy:app
4747
```
4848

4949
For a headless machine, authenticate first with `npx wrangler login --device --browser=false`, then open the displayed URL and approve the device code from your browser.
@@ -61,7 +61,7 @@ For a headless machine, authenticate first with `npx wrangler login --device --b
6161

6262
```bash
6363
npm install
64-
cp .dev.vars.example .dev.vars
64+
cp packages/app/.dev.vars.example packages/app/.dev.vars
6565
npm run dev
6666
```
6767

@@ -109,7 +109,7 @@ Cloudflare Worker failures can also start flows through the separately deployabl
109109
| `LINEAR_WEBHOOK_SIGNING_SECRET` | Verifies Linear webhook signatures |
110110
| `CREDENTIAL_ENCRYPTION_KEY` | Base64-encoded 32-byte key for encrypted credentials |
111111
| `SESSION_SIGNING_SECRET` | Independent secret for signed browser sessions |
112-
| `APP_ORIGIN` | Public Worker origin, configured in `wrangler.jsonc` |
112+
| `APP_ORIGIN` | Public Worker origin, configured in `packages/app/wrangler.jsonc` |
113113
| `OAUTH_KV` | KV binding containing OAuth clients, grants, refresh tokens, and revocation state |
114114

115115
Never commit `.dev.vars` or production secret values. The included `.dev.vars.example` is a safe template.
@@ -119,12 +119,14 @@ Never commit `.dev.vars` or production secret values. The included `.dev.vars.ex
119119
| Command | What it does |
120120
| --- | --- |
121121
| `npm run dev` | Build CSS and start local Wrangler development |
122-
| `npm run build:css` | Compile Tailwind into `public/styles.css` |
122+
| `npm run build:css` | Compile Tailwind into `packages/app/public/styles.css` |
123123
| `npm test` | Run the unit test suite |
124-
| `npm run check` | Type-check, test, and validate a Wrangler dry-run deploy |
125-
| `npm run deploy` | Deploy the Worker with Wrangler |
124+
| `npm run check` | Type-check/test the app and dry-run both Worker deployments |
125+
| `npm run deploy:app` | Deploy only the `factorize` app Worker |
126+
| `npm run deploy:tail-relay` | Deploy only the `factorize-tail-relay` Worker |
127+
| `npm run deploy` | Deploy the app, then the Tail relay; stop on the first failure |
126128

127-
GitHub Actions runs `npm run check` on every push and pull request.
129+
GitHub Actions installs the single root lockfile and runs `npm run check` on every push and pull request. The two packages are independently deployable Cloudflare Workers; the root scripts only provide a unified developer workflow.
128130

129131
## REST API and OAuth
130132

‎docs/cloudflare-tail.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Cloudflare Tail flow source
22

3-
Cloudflare Tail is a Factorize flow source for native uncaught Worker exceptions and structured `console.error` failures. Tail Workers require a Workers Paid or Enterprise plan. The relay stays in the same Cloudflare account as the producer Workers; the Factorize flow may be in any account.
3+
Cloudflare Tail is a Factorize flow source for native uncaught Worker exceptions and structured `console.error` failures. Tail Workers require a Workers Paid or Enterprise plan. The relay is a separate Cloudflare Worker and must be deployed in the same Cloudflare account as the producer Workers; the Factorize app Worker may be in any account.
44

55
## Configure the flow and relay
66

77
1. Create a flow, choose **Cloudflare Tail**, and save it. Copy the one-time relay destination and signing secret from the response/flow setup view.
8-
2. In `factorize-tail-relay`, run `npm install`, set `FACTORIZE_TAIL_DESTINATION` as a Wrangler variable, and run `npx wrangler secret put FACTORIZE_TAIL_SECRET`.
9-
3. Run `npm run deploy`. Keep the relay name `factorize-tail-relay`; Factorize excludes its own relay traces to prevent loops.
8+
2. From the repository root, run `npm ci` and set `FACTORIZE_TAIL_DESTINATION` as a Wrangler variable in `packages/tail-relay/wrangler.jsonc`.
9+
3. Authenticate Wrangler to the producer Workers' Cloudflare account, then run `npm exec --workspace=factorize-tail-relay -- wrangler secret put FACTORIZE_TAIL_SECRET` and `npm run deploy:tail-relay`. Keep the relay name `factorize-tail-relay`; Factorize excludes its own relay traces to prevent loops.
1010
4. Add the relay to every producer Worker. One relay can consume multiple producers and forwards each event with its `scriptName`:
1111

1212
```jsonc

0 commit comments

Comments
 (0)