create-qa-architect 5.13.6 → 5.14.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 CHANGED
@@ -1,54 +1,207 @@
1
- VIBE BUILD LAB COMMERCIAL LICENSE
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
2
4
 
3
- Copyright (c) 2025 BuildProven. All rights reserved.
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
6
 
5
- COMMERCIAL SOFTWARE - FREEMIUM MODEL
7
+ 1. Definitions.
6
8
 
7
- This software and associated documentation files (the "Software") are
8
- proprietary commercial products of BuildProven.
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
9
11
 
10
- TERMS OF USE:
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
11
14
 
12
- 1. FREE TIER
13
- The basic CLI tool is available free of charge for personal and commercial use.
14
- Free tier includes:
15
- - Basic quality automation setup
16
- - ESLint, Prettier, Husky configuration
17
- - Standard pre-commit hooks
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
18
22
 
19
- 2. PAID TIERS
20
- - Pro: $49/month or $490/year
21
- - Security scanning (Gitleaks + ESLint security)
22
- - Smart Test Strategy
23
- - Multi-language support
24
- - Unlimited repos
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
25
 
26
- 3. VIBE LAB PRO BUNDLE
27
- Pro tier is included in the Vibe Lab Pro subscription.
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
28
29
 
29
- 4. PERMITTED USES
30
- - Use the free tier without restriction
31
- - Use paid features with active subscription
32
- - Use for personal and commercial projects
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
33
34
 
34
- 5. RESTRICTIONS
35
- - NO redistribution of paid features
36
- - NO resale or sublicensing
37
- - NO circumventing license validation
38
- - NO removal of copyright notices
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
39
 
40
- 6. NO WARRANTY
41
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
44
47
 
45
- 7. LIMITATION OF LIABILITY
46
- IN NO EVENT SHALL VIBE BUILD LAB LLC BE LIABLE FOR ANY CLAIM, DAMAGES OR
47
- OTHER LIABILITY ARISING FROM THE USE OF THE SOFTWARE.
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of tracking or otherwise improving the Work,
59
+ but excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
48
61
 
49
- For licensing inquiries: support@buildproven.ai
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept and charge a
167
+ fee for the acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 BuildProven
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing permissions
201
+ and limitations under the License.
50
202
 
51
203
  ---
52
204
 
53
- BuildProven
54
- https://buildproven.ai
205
+ NOTE: The source code in this repository is licensed under Apache-2.0.
206
+ Use of the Pro tier features at runtime (those gated by a signed license key)
207
+ is additionally governed by the commercial terms in COMMERCIAL.md.
package/README.md CHANGED
@@ -1,8 +1,36 @@
1
1
  # QA Architect
2
2
 
3
- Quality automation CLI for JavaScript/TypeScript, Python, and shell script projects. One command adds ESLint, Prettier, Husky, lint-staged, and GitHub Actions. Pro tiers add security scanning (Gitleaks), Smart Test Strategy, and multi-language support.
3
+ **Security audit and quality automation for AI-generated codebases. One command finds the vulnerabilities your vibe-coded app ships with.**
4
4
 
5
- **This repo = the free CLI.** For the Pro dashboard with repo analytics, CI integration, and automation workflows, see [QA Architect Pro](https://buildproven.ai/qa-architect) (included in BuildProven Starter Kit).
5
+ ```bash
6
+ # Scan your project for security issues (free)
7
+ npx create-qa-architect@latest --audit
8
+ ```
9
+
10
+ ```
11
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
12
+ QA Architect — Vibe-Code Security Audit
13
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
14
+
15
+ 🚨 NOT SAFE TO SHIP
16
+
17
+ Total findings: 7
18
+ 🚨 Critical: 2
19
+ ❌ High: 3
20
+ ⚠️ Medium: 2
21
+
22
+ 🚨 CRITICAL (2)
23
+ ─────────────────────────────────────────────────────
24
+ pages/api/users.js:44
25
+ Prisma query by ID from request params with no user ownership filter.
26
+ → Fix: findUnique({ where: { id: params.id, userId: session.user.id } })
27
+
28
+ lib/auth.js:12
29
+ JWT signed without an expiry option — stolen token = permanent access.
30
+ → Fix: jwt.sign(payload, secret, { expiresIn: '24h' })
31
+ ```
32
+
33
+ > 45% of AI-generated code contains OWASP Top-10 vulnerabilities (Veracode, 100+ LLMs). QA Architect catches them before someone else does.
6
34
 
7
35
  ---
8
36
 
@@ -12,42 +40,54 @@ Quality automation CLI for JavaScript/TypeScript, Python, and shell script proje
12
40
 
13
41
  ---
14
42
 
15
- ## Features
43
+ ## What It Does
44
+
45
+ **Free tier — `--audit`:**
46
+
47
+ Runs [semgrep](https://semgrep.dev/) SAST + npm CVE audit against your codebase and produces a prioritized security report. Covers 5 of the 7 most common vibe-coding vulnerability categories:
48
+
49
+ | Category | Coverage |
50
+ | ----------------------------------------------------------------------------- | ------------------- |
51
+ | Secrets exposure (hardcoded keys, JWT without expiry) | ✅ Free |
52
+ | Auth & authorization gaps (missing checks, IDOR, client-side auth) | ✅ Free |
53
+ | Injection vectors (SQL injection, command injection, prototype pollution) | ✅ Free |
54
+ | Production misconfigs (CORS-all, verbose errors, debug mode, missing headers) | ✅ Free |
55
+ | XSS patterns (unsafe HTML, dynamic hrefs) | ✅ Free |
56
+ | Dependency CVEs | ✅ Free (npm audit) |
57
+ | Hallucinated packages (slopsquatting) | 🔒 Pro |
16
58
 
17
- - **Prettier Code Formatting** - Consistent code style across your project
18
- - **Husky Git Hooks** - Pre-commit (lint + format) and pre-push (type check + tests)
19
- - **lint-staged Processing** - Only process staged files for speed
20
- - **Delta Testing** - Pre-push runs tests on changed files only (fast feedback)
21
- - **GitHub Actions** - Automated quality checks in CI/CD
22
- - **TypeScript Smart** - Auto-detects and configures TypeScript projects
23
- - **Python Support** - Complete Python toolchain with Black, Ruff, isort, mypy, pytest
24
- - **Shell Script Support** - ShellCheck linting, syntax validation, permissions checks, best practices
25
- - **Security Automation** - npm audit (Free), Gitleaks + ESLint security (Pro)
26
- - **Progressive Quality** - Adaptive checks based on project maturity
27
- - **Smart Test Strategy** - Risk-based pre-push validation (Pro feature)
59
+ **Pro tier `--audit --fix`:**
28
60
 
29
- ### Quality Tools
61
+ Generates a ready-to-paste Claude Code prompt for each Critical/High finding. Copy it into Claude Code and it fixes the issue for you. Also adds hallucinated package detection (verifies every package in `package.json` exists on npm).
30
62
 
31
- - **Lighthouse CI** - Performance, accessibility, SEO audits (Free: basic, Pro: thresholds)
32
- - **Bundle Size Limits** - Enforce bundle budgets with size-limit (Pro)
33
- - **axe-core Accessibility** - WCAG compliance testing scaffolding (Free)
34
- - **Conventional Commits** - commitlint with commit-msg hook (Free)
35
- - **Coverage Thresholds** - Enforce code coverage minimums (Pro)
63
+ **Also included:**
36
64
 
37
- ### Pre-Launch Validation
65
+ - **Shipping gates** (`--ship-check`) — SHIP/REVIEW/BLOCK verdict across lint, tests, coverage, bundle, env vars, and CI cost
66
+ - **PR risk classifier** (`--pr-check`) — flags high-risk changes before merge
67
+ - **Full-history secrets scan** (`--history-scan`) — gitleaks across entire git history
68
+ - **Quality bootstrap** — one command adds ESLint, Prettier, Husky, lint-staged, GitHub Actions
38
69
 
39
- - **SEO Validation** - Sitemap, robots.txt, meta tags validation (Free)
40
- - **Link Validation** - Broken link detection with linkinator (Free)
41
- - **Accessibility Audit** - WCAG 2.1 AA compliance with pa11y-ci (Free)
42
- - **Documentation Check** - README completeness, required sections (Free)
43
- - **Env Vars Audit** - Validate .env.example against code usage (Pro)
70
+ ## Quick Start
71
+
72
+ ```bash
73
+ # 1. Install semgrep (required for --audit)
74
+ pip install semgrep # or: brew install semgrep
75
+
76
+ # 2. Run security audit (free)
77
+ npx create-qa-architect@latest --audit
78
+
79
+ # 3. Write report to file (for docs or PR comments)
80
+ npx create-qa-architect@latest --audit --out audit-report.md
81
+
82
+ # 4. Get Claude Code fix prompts for Critical/High findings (Pro)
83
+ npx create-qa-architect@latest --audit --fix
84
+ ```
44
85
 
45
86
  ## Target Users
46
87
 
47
- - **Developers** who want quality automation without manual setup
48
- - **Teams** standardizing code quality across multiple projects
49
- - **Open source maintainers** enforcing contribution standards
50
- - **Agencies** shipping consistent quality across client projects
88
+ - **Vibe coders** about to charge real users get confidence your app won't get hacked on launch day
89
+ - **AI-assisted builders** using Claude Code / Cursor daily — catch regressions before they ship
90
+ - **Inheritors** of AI-generated codebases understand what's fragile before you touch it
51
91
 
52
92
  ## Demo / Live Links
53
93
 
@@ -58,20 +98,31 @@ npx create-qa-architect@latest
58
98
 
59
99
  ## Pricing
60
100
 
61
- | Tier | Price | What You Get |
62
- | -------- | ----------------- | -------------------------------------------------------------------------------------------------- |
63
- | **Free** | $0 | CLI tool, basic linting/formatting, npm audit (capped: 1 private repo, 50 runs/mo) |
64
- | **Pro** | $49/mo or $490/yr | **Security scanning (Gitleaks + ESLint security)**, Smart Test Strategy, multi-language, unlimited |
101
+ | Tier | Price | What You Get |
102
+ | -------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | **Free** | $0 | Security audit (`--audit`), linting/formatting, npm audit (capped: 1 private repo, 50 runs/mo) |
104
+ | **Pro** | $29/mo or $290/yr | **Everything in Free** + `--audit --fix` (Claude Code prompts), hallucination check, Ship Check, PR Risk Check, CI Doctor, full-history secret scan, Smart Test Strategy, multi-language, unlimited |
65
105
 
66
106
  > **Pro included in [BuildProven Starter Kit](https://buildproven.ai/starter-kit)**
67
107
 
68
- ### Security Features by Tier
108
+ ### Security Audit by Tier
109
+
110
+ | Feature | Free | Pro |
111
+ | ------------------------------------------------- | ---- | --- |
112
+ | SAST (semgrep — auth, injection, XSS, misconfigs) | ✅ | ✅ |
113
+ | npm CVE audit | ✅ | ✅ |
114
+ | Gitleaks secrets scanning | ❌ | ✅ |
115
+ | Hallucinated package detection | ❌ | ✅ |
116
+ | `--fix` Claude Code prompts per finding | ❌ | ✅ |
117
+
118
+ ### Release Confidence by Tier
69
119
 
70
- | Feature | Free | Pro+ |
71
- | --------------------------- | ---- | ---- |
72
- | npm audit (basic) | | ✅ |
73
- | Gitleaks (secrets scanning) | ❌ | ✅ |
74
- | ESLint security rules | ❌ | ✅ |
120
+ | Feature | Free | Pro |
121
+ | ------------------------------------ | ---- | --- |
122
+ | Ship Check (release-readiness) | | ✅ |
123
+ | PR Risk Check (diff classifier) | ❌ | ✅ |
124
+ | CI Doctor (workflow waste detection) | ❌ | ✅ |
125
+ | Full-history secrets scan | ❌ | ✅ |
75
126
 
76
127
  ### Quality Tools by Tier
77
128
 
@@ -420,8 +471,9 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
420
471
 
421
472
  ### Purchasing Pro
422
473
 
423
- Pro tier ($49/mo or $490/yr) includes:
474
+ Pro tier ($29/mo or $290/yr) includes:
424
475
 
476
+ - **Release-confidence gates**: Ship Check, PR Risk Check, CI Doctor, full-history secrets scan
425
477
  - Security scanning (Gitleaks + ESLint security rules)
426
478
  - Smart Test Strategy (risk-based pre-push validation)
427
479
  - Multi-language support (Python, Shell scripts)
@@ -431,13 +483,13 @@ Purchase at [buildproven.ai/qa-architect](https://buildproven.ai/qa-architect)
431
483
 
432
484
  ### Server-Side Setup (Maintainers Only)
433
485
 
434
- The billing system uses Stripe webhooks to manage licenses. If you're deploying your own instance:
486
+ The billing system uses Polar.sh webhooks to manage licenses. If you're deploying your own instance:
435
487
 
436
488
  1. Set up webhook handler (see `webhook-handler.js`)
437
- 2. Configure Stripe live mode keys
438
- 3. Deploy to production server
489
+ 2. Configure Polar.sh products and webhook secret
490
+ 3. Deploy to production server (Vercel)
439
491
 
440
- See [docs/STRIPE-LIVE-MODE-DEPLOYMENT.md](docs/STRIPE-LIVE-MODE-DEPLOYMENT.md) for complete setup guide.
492
+ See [docs/POLAR-DEPLOYMENT.md](docs/POLAR-DEPLOYMENT.md) for complete setup guide.
441
493
 
442
494
  ## Support
443
495
 
@@ -446,7 +498,7 @@ See [docs/STRIPE-LIVE-MODE-DEPLOYMENT.md](docs/STRIPE-LIVE-MODE-DEPLOYMENT.md) f
446
498
 
447
499
  ## License
448
500
 
449
- Commercial freemium license the base CLI is free to use; Pro features require a paid subscription. See [LICENSE](LICENSE) for details.
501
+ Source code is licensed under **Apache-2.0** (see [LICENSE](LICENSE)). Use of paid **Pro features** at runtime is additionally governed by the commercial terms in [COMMERCIAL.md](COMMERCIAL.md). The base CLI is free to use; Pro features require a paid subscription.
450
502
 
451
503
  ## Legal
452
504
 
@@ -1,5 +1,5 @@
1
1
  # Code formatting and linting
2
- black~=24.8.0
2
+ black~=26.3.1
3
3
  ruff~=0.6.9
4
4
  isort~=5.13.2
5
5
  mypy~=1.11.2
@@ -8,7 +8,7 @@ mypy~=1.11.2
8
8
  pre-commit~=3.8.0
9
9
 
10
10
  # Testing
11
- pytest~=8.3.3
11
+ pytest~=9.0.3
12
12
  pytest-cov~=5.0.0
13
13
 
14
14
  # Type stubs
@@ -0,0 +1,157 @@
1
+ # Polar.sh Deployment Guide
2
+
3
+ Deploy `webhook-handler.js` to process Polar.sh subscription events and issue signed Pro licenses automatically.
4
+
5
+ ## Overview
6
+
7
+ The payment flow:
8
+
9
+ 1. Customer purchases Pro at your landing page → Polar.sh hosted checkout
10
+ 2. Polar fires a `subscription.created` (and shortly after, `subscription.active`) webhook to your server
11
+ 3. `webhook-handler.js` verifies the signature, generates a signed license key, and saves it to Vercel Blob
12
+ 4. Customer runs `npx create-qa-architect@latest --activate-license` and enters their key
13
+ 5. CLI fetches the public signed registry from Vercel Blob, verifies the signature offline using the bundled `public-key.pem`, and unlocks Pro features
14
+
15
+ ## Prerequisites
16
+
17
+ - A [Polar.sh](https://polar.sh) organization
18
+ - A [Vercel](https://vercel.com) account (for Blob storage and hosting the webhook)
19
+ - Node.js >= 20
20
+ - The Ed25519 private key used to sign licenses (paired with the `public-key.pem` bundled in the npm package)
21
+
22
+ ---
23
+
24
+ ## Step 1: Create Polar products
25
+
26
+ In the [Polar Dashboard](https://polar.sh/dashboard) → your org → Products → New Product:
27
+
28
+ - Name: **QA Architect Pro**
29
+ - Description: _(your marketing copy)_
30
+ - Type: Subscription
31
+ - Prices: add **two** recurring prices under the same product
32
+ - $29.00 USD / month (recurring monthly)
33
+ - $290.00 USD / year (recurring yearly)
34
+
35
+ Save the **product ID** — you'll need it for `POLAR_PRO_PRODUCT_ID` below. Single product, two prices means one tier mapping regardless of billing cadence.
36
+
37
+ ## Step 2: Create the Polar webhook
38
+
39
+ In the Polar Dashboard → Settings → Webhooks → New Webhook:
40
+
41
+ - URL: `https://<your-vercel-domain>/webhook` (we'll deploy this next)
42
+ - Events to subscribe to:
43
+ - `subscription.created`
44
+ - `subscription.active`
45
+ - `subscription.updated`
46
+ - `subscription.canceled`
47
+ - `subscription.revoked`
48
+ - Save the **signing secret** (starts with `whsec_`) — you'll need it for `POLAR_WEBHOOK_SECRET`.
49
+
50
+ ## Step 3: Set up Vercel Blob storage
51
+
52
+ ```bash
53
+ npm install -g vercel
54
+ vercel link
55
+ # Dashboard → Storage → Create → Blob → name it "qa-architect-licenses"
56
+ # Copy the BLOB_READ_WRITE_TOKEN
57
+ ```
58
+
59
+ ## Step 4: Deploy `webhook-handler.js` to Vercel
60
+
61
+ `webhook-handler.js` exports an Express app compatible with Vercel serverless.
62
+
63
+ Create `vercel.json` in the repo root:
64
+
65
+ ```json
66
+ {
67
+ "version": 2,
68
+ "builds": [{ "src": "webhook-handler.js", "use": "@vercel/node" }],
69
+ "routes": [{ "src": "/(.*)", "dest": "/webhook-handler.js" }]
70
+ }
71
+ ```
72
+
73
+ Set environment variables in the Vercel dashboard (Project → Settings → Environment Variables):
74
+
75
+ | Variable | Value |
76
+ | ------------------------------ | -------------------------------------------------------------------- |
77
+ | `POLAR_WEBHOOK_SECRET` | `whsec_...` from Step 2 |
78
+ | `POLAR_PRO_PRODUCT_ID` | Pro product ID from Step 1 |
79
+ | `LICENSE_REGISTRY_PRIVATE_KEY` | Contents of `private-key.pem` (paired with bundled `public-key.pem`) |
80
+ | `LICENSE_REGISTRY_KEY_ID` | An ID for this signing key (e.g., `prod-2026-05`) |
81
+ | `BLOB_READ_WRITE_TOKEN` | From Step 3 |
82
+ | `STATUS_API_TOKEN` | _(optional)_ Bearer token for `/status` debug endpoint |
83
+
84
+ Then deploy:
85
+
86
+ ```bash
87
+ vercel --prod
88
+ ```
89
+
90
+ Update the Polar webhook URL (Step 2) to point at the deployed Vercel URL.
91
+
92
+ ## Step 5: Wire your landing page to Polar checkout
93
+
94
+ On `buildproven.ai/qa-architect`, replace any old Stripe checkout buttons with Polar checkout links:
95
+
96
+ - Monthly: `https://polar.sh/<org-slug>/<product-slug>?price=<price-id-monthly>`
97
+ - Annual: `https://polar.sh/<org-slug>/<product-slug>?price=<price-id-annual>`
98
+
99
+ Or use Polar's embeddable checkout component for an in-page experience.
100
+
101
+ ## Step 6: Smoke test
102
+
103
+ ```bash
104
+ # In the Polar dashboard, send a test webhook event for subscription.created
105
+ # (Settings → Webhooks → [your endpoint] → Send Test Event)
106
+
107
+ # Verify the license appeared:
108
+ curl https://<your-vercel-domain>/health
109
+ # → { "status": "ok", "database": "exists" }
110
+
111
+ curl https://<your-vercel-domain>/api/licenses/qa-architect.json
112
+ # → JSON with one signed license entry
113
+
114
+ # Activate locally:
115
+ npx create-qa-architect@latest --activate-license
116
+ # Enter the test license key. Should report PRO tier.
117
+ ```
118
+
119
+ For a real end-to-end test, use Polar's test mode (every webhook can be replayed from the dashboard) before going live.
120
+
121
+ ## Step 7: Verify revocation works
122
+
123
+ ```bash
124
+ # Cancel a test subscription in Polar (or use "Send Test Event" with subscription.canceled, then subscription.revoked)
125
+
126
+ # Verify license moved out of public registry:
127
+ curl https://<your-vercel-domain>/api/licenses/qa-architect.json
128
+ # → revoked key should be absent
129
+ ```
130
+
131
+ An **already-activated** CLI re-checks the signed registry on a cadence
132
+ (default every 7 days; override with `QAA_LICENSE_REVALIDATE_DAYS`). On the
133
+ next re-check after revocation it downgrades to FREE and prints a reactivation
134
+ message. The re-check **fails open when offline** — a paying user is never
135
+ locked out without a network connection; only a successful, signature-verified
136
+ fetch that finds the key missing or `status: "revoked"` causes a downgrade.
137
+
138
+ ### Optional: nudge users onto the latest CLI
139
+
140
+ Set `minRecommendedVersion` in the signed registry `_metadata` (server-side,
141
+ when you build the registry) to a semver string. On the periodic re-check, any
142
+ Pro CLI older than that prints a loud but **non-fatal** "update available"
143
+ warning. Leave it unset to disable. It never blocks execution.
144
+
145
+ ## Rollback
146
+
147
+ If you need to roll back to Stripe-direct: restore the previous `webhook-handler.js` from git (it's the same Express app + Blob layout, just a different event source). Existing signed licenses in Vercel Blob keep working — they're product-agnostic.
148
+
149
+ ## Common issues
150
+
151
+ **Signature verification fails** — the raw body parser must come _before_ `express.json()` for the `/webhook` route. `webhook-handler.js` does this on line ~125 (`app.use('/webhook', express.raw(...))`).
152
+
153
+ **`POLAR_PRO_PRODUCT_ID` mismatch** — log `event.data.product?.id || event.data.product_id` in the handler to confirm the exact ID Polar sends. Update the env var to match.
154
+
155
+ **License doesn't unlock Pro features** — check that `public-key.pem` bundled in your published npm package matches the private key in `LICENSE_REGISTRY_PRIVATE_KEY` on the server. They must be a pair.
156
+
157
+ **Customer canceled but key still works** — Polar fires `subscription.canceled` immediately, but the key stays valid until `subscription.revoked` fires (typically at `current_period_end`). This is intentional: the customer paid through the end of the period. After `subscription.revoked` removes the key from the registry, an activated CLI drops to FREE on its next periodic re-check (see Step 7) — not necessarily on the customer's very next run.