Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- run: npm ci
- name: Verify generated API contract
run: |
npm run generate:openapi
git diff --exit-code -- packages/docs/openapi.yaml
npm run generate
git diff --exit-code -- packages/docs/openapi.yaml packages/api-client/src/schema.d.ts
- run: npm run build:css
- run: npm run check
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
- name: Configure authentication email Worker secret
working-directory: packages/app
working-directory: packages/api
run: |
node -e 'process.stdout.write(JSON.stringify({ POSTMARK_SERVER_TOKEN: process.env.POSTMARK_SERVER_TOKEN }))' | npx wrangler secret bulk
env:
Expand Down
10 changes: 9 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ This project in Linear is "Factorize"

- Every JSON application endpoint must live under `/api/v1` and be documented in `packages/docs/openapi.yaml`.
- Frontend code must call the same `/api/v1` endpoints as external clients. Never add a frontend-only `/api/*` route.
- Register API operations only in `packages/app/src/protected-api.ts`; page, auth callback, webhook, health, and internal routes belong in their existing non-API namespaces.
- Register API operations only in `packages/api/src/protected-api.ts`; page, auth callback, webhook, health, and internal routes belong in their existing non-API namespaces.
- A new API operation must include authorization, validation, OpenAPI documentation, and contract or boundary tests in the same change.
- `/auth`, `/oauth`, `/webhooks`, `/internal`, `/mcp`, and `/healthz` are explicit non-API namespaces and must not be used to hide frontend application endpoints.

## Package boundaries

- `packages/api` owns the Worker. Its npm name remains `factorize` during the staged migration; this does not change production infrastructure identity.
- `packages/app` is the static frontend (`factorize-app`). It may only import the generated public contract through `factorize-api-client`; never import backend implementations.
- `packages/api-client` is generated from the published OpenAPI document. It must have no backend or frontend implementation dependencies. Run `npm run generate` after contract changes.
- Run `npm run check:boundaries` to validate imports, including dynamic imports and type imports. Do not add aliases or build configuration that bypasses these boundaries.
- Keep the legacy UI and production routing working until each replacement screen has parity and the rollout checks in `docs/package-migration.md` pass.
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Factorize

[![CI](https://github.com/GenerationSoftware/factorize/actions/workflows/ci.yml/badge.svg)](https://github.com/GenerationSoftware/factorize/actions/workflows/ci.yml)
[![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/GenerationSoftware/factorize&path=packages/app)
[![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/GenerationSoftware/factorize&path=packages/api)

**A no-code software factory for Linear teams.** Factorize turns selected Linear issue changes into coding-agent jobs on isolated, ephemeral exe.dev VMs.

Expand All @@ -21,15 +21,15 @@ Linear webhook → Cloudflare Worker → Durable Object → exe.dev /exec → is

## Deploy to Cloudflare

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.
Click the **Deploy to Cloudflare** button above to create a copy of the app Worker in your own Cloudflare account. The button selects `packages/api` as the Worker root; Cloudflare provisions the Durable Object binding and configures Workers Builds for the copied repository.

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

### Deploy with Wrangler

1. Clone the repository and install dependencies.
2. Set `APP_ORIGIN` in `packages/app/wrangler.jsonc` to your final HTTPS Worker URL or custom domain.
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`.
2. Set `APP_ORIGIN` in `packages/api/wrangler.jsonc` to your final HTTPS Worker URL or custom domain.
3. Create a dedicated OAuth KV namespace with `npm exec --workspace=factorize -- wrangler kv namespace create OAUTH_KV`, then set its ID in `packages/api/wrangler.jsonc`.
4. Configure the Linear OAuth callback as `https://your-domain.example/auth/linear/callback`.
5. Build assets, add secrets, and deploy:

Expand Down Expand Up @@ -62,7 +62,7 @@ For a headless machine, authenticate first with `npx wrangler login --device --b

```bash
npm install
cp packages/app/.dev.vars.example packages/app/.dev.vars
cp packages/api/.dev.vars.example packages/api/.dev.vars
npm run dev
```

Expand All @@ -84,7 +84,7 @@ Factorize owns authentication in PostgreSQL. Create a native account at `/auth/s

Postmark sends one-hour, single-use verification and password-reset links. `/auth/verify/request` resends verification; `/auth/password-reset` handles recovery. Links never appear in application responses or logs. Passwords use salted PBKDF2-SHA-256. **Change password** in the account menu requires the current password. Password reset, password change and sign-out invalidate existing sessions via membership session versions, including delegated API credentials.

Before deploying, configure `POSTMARK_SERVER_TOKEN` as a **production GitHub environment secret**. The deployment copies it to a Worker secret; the verified sender and transactional message stream are non-secret Worker vars in `packages/app/wrangler.jsonc`. For a manual Postmark preflight, set the following environment variables along with `APP_ORIGIN`:
Before deploying, configure `POSTMARK_SERVER_TOKEN` as a **production GitHub environment secret**. The deployment copies it to a Worker secret; the verified sender and transactional message stream are non-secret Worker vars in `packages/api/wrangler.jsonc`. For a manual Postmark preflight, set the following environment variables along with `APP_ORIGIN`:

| Setting | Required value |
| --- | --- |
Expand Down Expand Up @@ -142,7 +142,7 @@ Cloudflare Worker failures can also start Jobs through the separately deployable
| `CLICKUP_CLIENT_SECRET` | ClickUp OAuth client secret; ClickUp also uses a per-installation webhook secret stored encrypted by Factorize |
| `CREDENTIAL_ENCRYPTION_KEY` | Base64-encoded 32-byte key for encrypted credentials |
| `SESSION_SIGNING_SECRET` | Independent secret for signed browser sessions |
| `APP_ORIGIN` | Public Worker origin, configured in `packages/app/wrangler.jsonc` |
| `APP_ORIGIN` | Public Worker origin, configured in `packages/api/wrangler.jsonc` |
| `OAUTH_KV` | KV binding containing OAuth clients, grants, refresh tokens, and revocation state |

Never commit `.dev.vars` or production secret values. The included `.dev.vars.example` is a safe template.
Expand All @@ -152,7 +152,7 @@ Never commit `.dev.vars` or production secret values. The included `.dev.vars.ex
| Command | What it does |
| --- | --- |
| `npm run dev` | Build CSS and start local Wrangler development |
| `npm run build:css` | Compile Tailwind into `packages/app/public/styles.css` |
| `npm run build:css` | Compile Tailwind into `packages/api/public/styles.css` |
| `npm test` | Run the unit test suite |
| `npm run check` | Type-check/test the app and dry-run both Worker deployments |
| `npm run deploy:app` | Deploy only the `factorize` app Worker |
Expand Down Expand Up @@ -224,3 +224,18 @@ Factorize also supports the OAuth 2.0 Device Authorization Grant (RFC 8628) for

[Apache License 2.0](LICENSE)
Test line for the Factorize PR-check and merge-queue flow.

### Static application migration

The existing Worker now lives in `packages/api`. `packages/app` contains the Vite/React frontend foundation and `packages/api-client` contains the generated public API client. Production still serves the existing dashboard while feature routes migrate. See [the staged rollout and route inventory](docs/package-migration.md).

| Command | Purpose |
| --- | --- |
| `npm run dev:api` | Run the existing API/legacy dashboard Worker |
| `npm run dev:app` | Run the static frontend development server |
| `npm run generate` | Generate OpenAPI and browser client types |
| `npm run build:app` | Build static frontend assets |
| `npm run check:boundaries` | Reject frontend/backend implementation imports |
| `npm run check` | Validate packages, generated client, tests and builds |

Use Node 24. Keep local secrets in `packages/api/.dev.vars`; the static frontend does not expose environment variables.
4 changes: 2 additions & 2 deletions docs/execution-trace-stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Normalized execution streams contain UTF-8, newline-terminated JSON objects in a

Required fields: `version` (1), `id`, `type`, `title`, `preview`. Optional fields:
`parentId`, `role`, `occurredAt` (ISO timestamp), `display` (object). Event types
match `TraceEventType` in `packages/app/src/trace.ts`. Sequence is assigned by the
match `TraceEventType` in `packages/api/src/trace.ts`. Sequence is assigned by the
projection, never trusted from the producer. Producers must append whole records
and finish each with LF. They must write human stdout/stderr to their separate
supervisor logs, never to the stream. The supervisor creates the stream directory
Expand Down Expand Up @@ -96,7 +96,7 @@ persisted source declaration continue to use native discovery. Native fallback
parsing retains tool IDs, result names and error flags, including across artifact
read chunks.

`packages/app/test/fixtures/claude-2.1.293/` contains synthetic, version-pinned
`packages/api/test/fixtures/claude-2.1.293/` contains synthetic, version-pinned
schema fixtures for Claude Code 2.1.293 (the installed CLI version used during
implementation). They model default root/subagent-tool behavior, not forwarded
child text. Boundary tests execute the exact guest supervisor with a fake CLI,
Expand Down
2 changes: 1 addition & 1 deletion docs/marketing-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Factorize is deployed as a Cloudflare Pages site and an app Worker:

- `packages/marketing` owns the public landing page at `https://factorize.sh`. It is a static Cloudflare Pages project named `factorize-marketing`; its production branch is `main` and its output directory is `packages/marketing/public`. It contains no authenticated APIs or tenant data. Login and Create a Job links cross to `https://app.factorize.sh`.
- `packages/app` owns the authenticated dashboard, OAuth callbacks, API/MCP endpoints, provider webhooks, and job deep links at `https://app.factorize.sh`. Its `/` route is the signed-out login entry point and redirects signed-in users to `/jobs`.
- `packages/api` owns the authenticated dashboard, OAuth callbacks, API/MCP endpoints, provider webhooks, and job deep links at `https://app.factorize.sh`. Its `/` route is the signed-out login entry point and redirects signed-in users to `/jobs`.

The Pages project is connected to `GenerationSoftware/factorize` for pull request previews, but Cloudflare's automatic production deployments are disabled. Production deploys from `main` run through `.github/workflows/deploy.yml`, where failures are visible in GitHub Actions. For a manual deployment, authenticate Wrangler and run `npm run deploy:marketing`; this uploads `packages/marketing/public` to the `factorize-marketing` project.

Expand Down
Loading
Loading