@percepta/create 3.1.3 → 3.1.5

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 (39) hide show
  1. package/README.md +8 -8
  2. package/dist/git-ops-C2CIjuce.js +51 -0
  3. package/dist/git-ops-C2CIjuce.js.map +1 -0
  4. package/dist/index.js +1073 -1067
  5. package/dist/index.js.map +1 -0
  6. package/dist/init-OeK4Yk6_.js +52 -0
  7. package/dist/init-OeK4Yk6_.js.map +1 -0
  8. package/dist/status-DC8mvHZj.js +48 -0
  9. package/dist/status-DC8mvHZj.js.map +1 -0
  10. package/dist/sync-C5Pd32VM.js +101 -0
  11. package/dist/sync-C5Pd32VM.js.map +1 -0
  12. package/dist/upstream-F6m8zRBQ.js +85 -0
  13. package/dist/upstream-F6m8zRBQ.js.map +1 -0
  14. package/package.json +23 -24
  15. package/templates/webapp/AGENTS.md +1 -1
  16. package/templates/webapp/README.md +1 -1
  17. package/templates/webapp/agent-skills/database.md +5 -1
  18. package/templates/webapp/agent-skills/deploy.md +5 -3
  19. package/templates/webapp/agent-skills/inngest.md +13 -8
  20. package/templates/webapp/agent-skills/oneshot.md +1 -1
  21. package/templates/webapp/deploy/README.md +2 -2
  22. package/templates/webapp/deploy/ryvn/environments/percepta-test/installations/__APP_NAME__.env.percepta-test.serviceinstallation.yaml +3 -3
  23. package/templates/webapp/package.json.template +2 -2
  24. package/templates/webapp/scripts/deploy-percepta-test.ts +311 -36
  25. package/templates/webapp/scripts/generate-migrations.ts +28 -0
  26. package/templates/webapp/src/drizzle/__tests__/migrationSql.test.ts +24 -0
  27. package/templates/webapp/src/drizzle/migrationSql.ts +8 -0
  28. package/templates/webapp/src/services/inngest/AppWorkflowService.ts +19 -0
  29. package/templates/webapp/src/services/inngest/__tests__/AppWorkflowService.test.ts +19 -0
  30. package/templates/webapp/src/services/inngest/events/AppEvents.ts +7 -13
  31. package/templates/webapp/src/services/inngest/events/payloads/ExampleEventPayload.ts +1 -3
  32. package/dist/chunk-CO3YWUD6.js +0 -139
  33. package/dist/chunk-DCM7JOSC.js +0 -49
  34. package/dist/chunk-V5EJIUBJ.js +0 -60
  35. package/dist/index.d.ts +0 -1
  36. package/dist/init-EQZ2TCSJ.js +0 -96
  37. package/dist/status-QW5TQDYY.js +0 -76
  38. package/dist/sync-RLBZDOFB.js +0 -136
  39. package/dist/upstream-TQFVPMEG.js +0 -144
package/package.json CHANGED
@@ -1,8 +1,17 @@
1
1
  {
2
2
  "name": "@percepta/create",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "Scaffold a new Mosaic package",
5
- "type": "module",
5
+ "keywords": [
6
+ "cli",
7
+ "create",
8
+ "mosaic",
9
+ "nextjs",
10
+ "percepta",
11
+ "scaffold",
12
+ "template"
13
+ ],
14
+ "license": "MIT",
6
15
  "bin": {
7
16
  "create": "./dist/index.js"
8
17
  },
@@ -11,6 +20,10 @@
11
20
  "templates",
12
21
  "template-versions.json"
13
22
  ],
23
+ "type": "module",
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
14
27
  "dependencies": {
15
28
  "chalk": "^5.4.1",
16
29
  "commander": "^13.1.0",
@@ -24,36 +37,22 @@
24
37
  "@types/fs-extra": "^11.0.4",
25
38
  "@types/node": "^24.1.0",
26
39
  "@types/validate-npm-package-name": "^4.0.2",
27
- "tsup": "^8.4.0",
28
- "typescript": "^5.7.3",
29
40
  "vitest": "^4.0.0",
30
- "@percepta/build": "0.4.1"
41
+ "@percepta/build": "0.5.0"
31
42
  },
32
43
  "engines": {
33
44
  "node": ">=18.0.0"
34
45
  },
35
- "publishConfig": {
36
- "access": "public"
37
- },
38
- "keywords": [
39
- "create",
40
- "template",
41
- "nextjs",
42
- "mosaic",
43
- "percepta",
44
- "scaffold",
45
- "cli"
46
- ],
47
- "license": "MIT",
48
46
  "scripts": {
49
- "build": "tsup src/index.ts --format esm --dts --clean",
50
- "create:local": "pnpm build && node dist/index.js",
51
- "dev": "tsup src/index.ts --format esm --watch",
47
+ "build": "tsdown",
48
+ "dev": "tsdown --watch",
49
+ "clean": "rimraf dist",
52
50
  "typecheck": "tsc --noEmit",
53
- "sync-template": "tsx scripts/sync-template.ts",
54
- "template:tag": "tsx scripts/template-tag.ts",
55
51
  "test": "vitest run",
56
52
  "test:watch": "vitest",
57
- "test:template": "bash scripts/test-template.sh"
53
+ "test:template": "bash scripts/test-template.sh",
54
+ "create:local": "pnpm build && node dist/index.js",
55
+ "sync-template": "tsx scripts/sync-template.ts",
56
+ "template:tag": "tsx scripts/template-tag.ts"
58
57
  }
59
58
  }
@@ -8,7 +8,7 @@ Next.js 15 full-stack application scaffolded from the Mosaic webapp template via
8
8
  - `pnpm build` — production build
9
9
  - `pnpm lint` — run ESLint
10
10
  - `pnpm test` — run Vitest tests
11
- - `pnpm docker:up` / `pnpm docker:down` — start/stop PostgreSQL
11
+ - `pnpm docker:up` / `pnpm docker:down` — start PostgreSQL and wait for health / stop PostgreSQL
12
12
  - `pnpm inngest:dev` — start local Inngest dev server when working on background jobs
13
13
  - `pnpm db:generate` — generate Drizzle migrations
14
14
  - `pnpm db:migrate` — apply migrations
@@ -85,7 +85,7 @@ src/
85
85
  | `pnpm build` | Build for production |
86
86
  | `pnpm start` | Start production server |
87
87
  | `pnpm lint` | Run ESLint |
88
- | `pnpm docker:up` | Start PostgreSQL container |
88
+ | `pnpm docker:up` | Start PostgreSQL container and wait until it is healthy |
89
89
  | `pnpm docker:down` | Stop PostgreSQL container |
90
90
  | `pnpm inngest:dev` | Start the local Inngest dev server for this app |
91
91
  | `pnpm db:generate` | Generate Drizzle migrations |
@@ -38,7 +38,11 @@ export * from "./documents";
38
38
  pnpm db:generate
39
39
  ```
40
40
 
41
- This creates a new SQL migration file. **Review the generated SQL** — Drizzle generates it automatically but you should verify it's correct.
41
+ This creates a new SQL migration file and normalizes generated foreign key
42
+ references so they stay schema-relative when `DATABASE_SCHEMA` is set in
43
+ `percepta-test`. **Review the generated SQL** — Drizzle generates it
44
+ automatically but you should verify it's correct, especially for new foreign
45
+ keys and destructive changes.
42
46
 
43
47
  ### 4. Apply the migration
44
48
 
@@ -12,7 +12,7 @@ This is the existing-environment deploy motion: `percepta-test` already owns the
12
12
  - `deploy/ryvn/environments/percepta-test/installations/__APP_NAME__-terraform.env.percepta-test.serviceinstallation.yaml` — schema installation.
13
13
  - `.github/workflows/__APP_NAME__-ryvn-release.yaml` — builds the Docker image and creates the web Ryvn release.
14
14
  - `.github/workflows/__APP_NAME__-terraform-ryvn-release.yaml` — creates the schema Terraform Ryvn release.
15
- - `deploy/ryvn/percepta-test.secrets.env` — generated locally and ignored by git; patched into Ryvn by the deploy helper.
15
+ - `deploy/ryvn/percepta-test.secrets.env` — generated locally and ignored by git; injected into the app installation as Ryvn secrets by the deploy helper.
16
16
 
17
17
  See [`deploy/README.md`](../deploy/README.md) for the file-by-file breakdown.
18
18
 
@@ -42,7 +42,7 @@ The helper:
42
42
  6. Creates or replaces the schema installation and approves the Terraform plan.
43
43
  7. Runs the web release workflow.
44
44
  8. Creates or replaces the web installation.
45
- 9. Patches `BETTER_AUTH_SECRET` and `ENCRYPTION_SECRET_KEY` from `deploy/ryvn/percepta-test.secrets.env`.
45
+ 9. Creates or updates app-scoped Ryvn installation secrets for `BETTER_AUTH_SECRET` and `ENCRYPTION_SECRET_KEY` from `deploy/ryvn/percepta-test.secrets.env`. On first install, the helper injects them into the create manifest so the first pod starts with auth configured.
46
46
  10. Waits for Ryvn health and checks `/api/healthz`, `/api/readyz`, and the protected app route.
47
47
 
48
48
  The app will be available at **https://__APP_NAME__.percepta-test.aitco.dev**.
@@ -74,12 +74,14 @@ curl -s https://__APP_NAME__.percepta-test.aitco.dev/api/readyz
74
74
  curl -I https://__APP_NAME__.percepta-test.aitco.dev/
75
75
  ```
76
76
 
77
+ For apps with tRPC routes, also verify at least one endpoint that initializes Better Auth or app services. `healthz` can be green even when app-specific secrets or workflow wiring are wrong.
78
+
77
79
  ## Troubleshooting
78
80
 
79
81
  - **Image build fails fetching @percepta packages** → check the Percepta-Core org-level `NPM_TOKEN` secret. Do not add a repo-level token unless the org secret is unavailable.
80
82
  - **Ryvn release already exists** → commit a new change or re-run with `--skip-workflows` if the current releases are already present.
81
83
  - **Terraform plan needs approval** → the helper approves it when run with `--yes`; without `--yes`, approve the prompt.
82
- - **Auth/sign-in routes fail after install** → verify the deploy helper patched `BETTER_AUTH_SECRET` and `ENCRYPTION_SECRET_KEY`.
84
+ - **Auth/sign-in or tRPC routes fail after install** → verify the `__APP_NAME__` installation has `BETTER_AUTH_SECRET` and `ENCRYPTION_SECRET_KEY` secrets from `deploy/ryvn/percepta-test.secrets.env`, then redeploy `__APP_NAME__` so the pod reloads them.
83
85
  - **Pod crash-looping** → check `ryvn logs`; migration or database connectivity failures are the most common fresh-deploy causes.
84
86
  - **Database schema missing** → check `ryvn get installation __APP_NAME__-terraform -e percepta-test`.
85
87
  - **Inngest can't reach the app** → `INNGEST_APP_URL` must use the k8s service name `__APP_NAME__-web-server`.
@@ -31,13 +31,13 @@ Add the event to the central `AppEvents` registry:
31
31
  import { DocumentProcessedPayload } from "./payloads/DocumentProcessedPayload";
32
32
 
33
33
  export const AppEvents = {
34
- "app/document.processed": z.object({
35
- data: DocumentProcessedPayload.SCHEMA,
36
- }),
34
+ "app/document.processed": DocumentProcessedPayload.SCHEMA,
37
35
  };
38
36
  ```
39
37
 
40
- Event names follow the convention `"app/<entity>.<action>"`.
38
+ Event names follow the convention `"app/<entity>.<action>"`. `AppEvents`
39
+ schemas validate `event.data`, so do not wrap payload schemas in another
40
+ `{ data: ... }` object.
41
41
 
42
42
  ## Adding a New Function
43
43
 
@@ -93,13 +93,18 @@ const functionCollections: InngestFunctionCollection[] = compact([
93
93
  ## Sending Events
94
94
 
95
95
  ```typescript
96
- const inngest = InngestService.create();
97
- await inngest.client.send({
98
- name: "app/document.processed",
99
- data: { documentId: "abc", userId: "user-1", pageCount: 5 },
96
+ await AppWorkflowService.create().sendDocumentProcessed({
97
+ documentId: "abc",
98
+ userId: "user-1",
99
+ pageCount: 5,
100
100
  });
101
101
  ```
102
102
 
103
+ Prefer adding typed methods to `AppWorkflowService` instead of calling
104
+ `InngestService.create().client.send(...)` directly from routers or route
105
+ handlers. Keep a unit test that asserts the method sends the same payload shape
106
+ that `AppEvents` validates.
107
+
103
108
  ## Running Inngest Locally
104
109
 
105
110
  ### 1. Start the Inngest Dev Server
@@ -193,7 +193,7 @@ git add -A
193
193
  git commit -m "Initial implementation of <app-name>"
194
194
 
195
195
  # Create the repo under the Percepta-Core org
196
- gh repo create Percepta-Core/<app-name> --private --source=. --push
196
+ gh repo create Percepta-Core/<app-name> --internal --source=. --push
197
197
  ```
198
198
 
199
199
  If `gh` is not authenticated, tell the user to run `gh auth login` and then continue.
@@ -18,7 +18,7 @@ These files deploy to `https://__APP_NAME__.percepta-test.aitco.dev`.
18
18
 
19
19
  The default deploy helper performs the existing-environment deploy motion: it assumes the target Ryvn environment already has the shared platform services installed, then wires this app into them. For `percepta-test`, that means shared Postgres, Inngest, the OTEL collector, the LGTM stack, and Langfuse must already exist before app deploy starts. Fresh-environment platform bootstrap is a separate motion and should be handled by a Ryvn blueprint or environment-specific platform rollout.
20
20
 
21
- The helper talks directly to Ryvn: it preflights the existing platform services, creates/updates the services, runs the GitHub Actions release workflows, creates the schema installation, approves the schema Terraform plan, creates the web installation, patches generated secrets, waits for health, and verifies the health and app routes.
21
+ The helper talks directly to Ryvn: it preflights the existing platform services, creates/updates the services, runs the GitHub Actions release workflows, creates the schema installation, approves the schema Terraform plan, creates or updates app-scoped Ryvn secrets, creates the web installation, waits for health, and verifies the health and app routes.
22
22
 
23
23
  ## Deploying
24
24
 
@@ -40,7 +40,7 @@ The helper expects a clean, committed git worktree because GitHub Actions builds
40
40
 
41
41
  **`__APP_NAME__-terraform.env.percepta-test.serviceinstallation.yaml`** — schema installation for `percepta-test`.
42
42
 
43
- **`percepta-test.secrets.env`** — generated locally and ignored by git. The deploy helper patches app-specific auth/encryption secrets into the Ryvn installation; shared Langfuse and LLM demo keys are inherited from a Ryvn variable group.
43
+ **`percepta-test.secrets.env`** — generated locally and ignored by git. The deploy helper injects app-specific auth/encryption secrets into the Ryvn installation create manifest so the first pod starts with auth configured; shared Langfuse and LLM demo keys are inherited from a Ryvn variable group.
44
44
 
45
45
  ## Platform Wiring
46
46
 
@@ -94,9 +94,9 @@ spec:
94
94
  value: https://__APP_NAME__.percepta-test.aitco.dev
95
95
  - key: BETTER_AUTH_URL
96
96
  value: https://__APP_NAME__.percepta-test.aitco.dev
97
- # deploy:percepta-test patches BETTER_AUTH_SECRET and ENCRYPTION_SECRET_KEY
98
- # from deploy/ryvn/percepta-test.secrets.env after the installation exists.
99
- # Secret values are intentionally not declared in GitOps IaC.
97
+ # deploy:percepta-test injects BETTER_AUTH_SECRET and ENCRYPTION_SECRET_KEY
98
+ # from deploy/ryvn/percepta-test.secrets.env into the create request.
99
+ # Secret values are intentionally not declared here.
100
100
 
101
101
  # Inngest (shared percepta-test platform service)
102
102
  - key: INNGEST_BASE_URL
@@ -11,10 +11,10 @@
11
11
  "start": "next start",
12
12
  "lint": "eslint .",
13
13
  "setup": "pnpm docker:up && pnpm db:setup-and-migrate && pnpm db:seed",
14
- "docker:up": "docker compose up -d",
14
+ "docker:up": "docker compose up -d --wait",
15
15
  "docker:down": "docker compose down",
16
16
  "inngest:dev": "pnpm dlx inngest-cli@latest dev -u http://localhost:3000/api/inngest",
17
- "db:generate": "drizzle-kit generate",
17
+ "db:generate": "tsx ./scripts/generate-migrations.ts",
18
18
  "db:migrate": "tsx ./scripts/migrate.ts",
19
19
  "db:setup": "tsx ./scripts/setup-database.ts",
20
20
  "db:setup-and-migrate": "pnpm db:setup && pnpm db:migrate",