@ojokesusu/lintasai 1.1.2

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 (86) hide show
  1. package/.github/workflows/publish-npm.yml +40 -0
  2. package/.github/workflows/validate.yml +93 -0
  3. package/AUDIT_POST_SETUP_PROMPT_v1.md +280 -0
  4. package/BOOTSTRAP_PROJECT_DOCS_PROMPT_v1.md +3 -0
  5. package/CHANGELOG.md +313 -0
  6. package/CLAUDE_universal_v1.md +1021 -0
  7. package/CONTRIBUTING.md +101 -0
  8. package/FIRST_SESSION_PROMPT_v1.md +7 -0
  9. package/JALANKAN_KIT.md +188 -0
  10. package/LICENSE +21 -0
  11. package/MULAI_DI_SINI.md +145 -0
  12. package/PROJECT_KICKOFF_PROMPT_v1.md +3 -0
  13. package/PROJECT_LIFECYCLE_PROMPT_v1.md +536 -0
  14. package/PROJECT_MIGRATION_PROMPT_v1.md +3 -0
  15. package/README.md +505 -0
  16. package/SETUP_POLA_B_PROMPT_v1.md +5 -0
  17. package/SPLIT_REPO_MIGRATION_PROMPT_v1.md +485 -0
  18. package/TEAM_ROLLOUT_GUIDE_v1.md +172 -0
  19. package/UPDATE_DOCS_PROMPT_v1.md +3 -0
  20. package/UPDATE_KIT_PROMPT_v1.md +213 -0
  21. package/bin/lintasai.js +81 -0
  22. package/docs/SIGNED_RELEASE.md +162 -0
  23. package/install-windows.ps1 +225 -0
  24. package/kit.ps1 +508 -0
  25. package/lib/agents-md.ps1 +174 -0
  26. package/lib/git-helpers.ps1 +104 -0
  27. package/lib/kit-files.psd1 +133 -0
  28. package/lib/manifest-signing.ps1 +65 -0
  29. package/lib/manifest.ps1 +267 -0
  30. package/lib/rollback.ps1 +241 -0
  31. package/lib/safety.ps1 +193 -0
  32. package/lib/template-deploy.ps1 +242 -0
  33. package/lib/version-detect.ps1 +161 -0
  34. package/package.json +36 -0
  35. package/setup-pola-b.ps1 +687 -0
  36. package/templates/ANALOGI_LIBRARY.md +7 -0
  37. package/templates/CLAUDE_TEAM_GUIDE.md +505 -0
  38. package/templates/CROSS_REPO_TYPES_PIPELINE.md +473 -0
  39. package/templates/DB_SCHEMA_SCAN_PROMPT.md +194 -0
  40. package/templates/DISCORD_BOT_INTEGRATION.md +187 -0
  41. package/templates/GLOSSARY_NON_PROGRAMMER.md +361 -0
  42. package/templates/INDEX.md +157 -0
  43. package/templates/MCP_SETUP.md +1145 -0
  44. package/templates/MIGRATE_TO_SUBFOLDER_PROMPT_v1.md +220 -0
  45. package/templates/ONBOARDING.md +172 -0
  46. package/templates/PROJECT_STARTER_TEMPLATES.md +264 -0
  47. package/templates/PROMPT_LIBRARY.md +790 -0
  48. package/templates/RLS_SETUP_PROMPT.md +167 -0
  49. package/templates/SECURITY_INCIDENT_PLAYBOOK.md +191 -0
  50. package/templates/SPLIT_REPO_AGENTS_TEMPLATES.md +32 -0
  51. package/templates/SPLIT_REPO_NON_PROGRAMMER_PROMPTS.md +604 -0
  52. package/templates/SPLIT_REPO_TOOLS_SETUP.md +388 -0
  53. package/templates/STACK_DETECTION_PATTERN.md +261 -0
  54. package/templates/STACK_GUIDE.md +564 -0
  55. package/templates/STACK_MIGRATION_GUIDE.md +154 -0
  56. package/templates/STACK_VERSIONS.md +31 -0
  57. package/templates/UPDATE_GUIDE.md +246 -0
  58. package/templates/_EXAMPLE.md +110 -0
  59. package/templates/_PATTERNS.md +173 -0
  60. package/templates/architecture.md +180 -0
  61. package/templates/architecture_auto.md +61 -0
  62. package/templates/decisions/README.md +108 -0
  63. package/templates/decisions/_TEMPLATE.md +84 -0
  64. package/templates/feature-flags-advanced.md +171 -0
  65. package/templates/github/CODEOWNERS.template +61 -0
  66. package/templates/github/GENERATE_TYPES_SCRIPT.md +77 -0
  67. package/templates/github/PUBLISH_SHARED_WORKFLOW.yml +52 -0
  68. package/templates/github/RECEIVE_BACKEND_UPDATE.yml +106 -0
  69. package/templates/github/RENOVATE_FRONTEND.json +28 -0
  70. package/templates/github/TRIGGER_FRONTEND_UPDATE.yml +29 -0
  71. package/templates/github/pull_request_template.md +44 -0
  72. package/templates/github/scripts/ai-review.js +153 -0
  73. package/templates/github/workflows/ai-review.yml +61 -0
  74. package/templates/github/workflows/backup-schemas.yml +169 -0
  75. package/templates/glossary.md +110 -0
  76. package/templates/split-agents/BACKEND.md +149 -0
  77. package/templates/split-agents/FRONTEND.md +141 -0
  78. package/templates/split-agents/SHARED.md +82 -0
  79. package/templates/split-agents/TOOLS.md +77 -0
  80. package/tests/Run-Tests.ps1 +19 -0
  81. package/tests/lib-safety.Tests.ps1 +66 -0
  82. package/tests/rollback.Tests.ps1 +66 -0
  83. package/tests/uninstall.Tests.ps1 +265 -0
  84. package/tests/update-kit.Tests.ps1 +78 -0
  85. package/uninstall.ps1 +794 -0
  86. package/update-kit.ps1 +907 -0
@@ -0,0 +1,473 @@
1
+ # Cross-Repo Auto Types Pipeline - lintasAI
2
+
3
+ > Otomatisasi penuh: backend update schema → types auto-generate → @<project>/shared publish → Discord notify → frontend Renovate auto-PR.
4
+ > Audience: Owner setup awal (sekali).
5
+
6
+ ---
7
+
8
+ ## Filosofi: "Backend Owns the Contract"
9
+
10
+ Backend = single source of truth untuk:
11
+ - Database schema (Prisma)
12
+ - API endpoint signatures
13
+ - Business logic types
14
+
15
+ Frontend = consumer of contract via @<project>/shared package.
16
+
17
+ Tidak ada manual sync. Pipeline auto-handle.
18
+
19
+ Kenapa filosofi ini penting:
20
+ - Frontend tidak boleh "tebak-tebakan" bentuk data dari backend
21
+ - Setiap kontrak (type, schema, signature) hanya diubah di backend
22
+ - Frontend cuma konsumsi versi terbaru lewat package manager
23
+ - Conflict resolution jadi mudah karena cuma satu sumber kebenaran
24
+
25
+ ---
26
+
27
+ ## Setup di akses-backend Repo
28
+
29
+ ### Step 1: Install dependencies
30
+
31
+ ```bash
32
+ cd akses-backend
33
+ npm install --save-dev tsup typescript semantic-release @semantic-release/git @semantic-release/exec
34
+ npm install --save zod # untuk shared validation schemas
35
+ ```
36
+
37
+ Penjelasan tiap dependency:
38
+ - `tsup` — bundler super cepat untuk build TypeScript types
39
+ - `typescript` — compiler resmi
40
+ - `semantic-release` — opsional, untuk auto-bump version berdasarkan commit message
41
+ - `zod` — runtime validation schemas yang bisa di-share frontend + backend
42
+
43
+ ### Step 2: Setup tsup config
44
+
45
+ Create akses-backend/tsup.shared.config.ts:
46
+
47
+ ```typescript
48
+ import { defineConfig } from 'tsup'
49
+
50
+ export default defineConfig({
51
+ entry: ['src/shared/index.ts'], // export types yang shared
52
+ format: ['esm', 'cjs'],
53
+ dts: true, // auto-generate .d.ts
54
+ outDir: 'shared-dist',
55
+ clean: true,
56
+ })
57
+ ```
58
+
59
+ Catatan:
60
+ - `format: ['esm', 'cjs']` — support modern bundler (Vite, Next.js) sekaligus legacy (Jest, ts-node)
61
+ - `dts: true` — auto-generate file `.d.ts` (declaration file) untuk type inference di frontend
62
+ - `outDir: 'shared-dist'` — jangan di `dist/` supaya tidak konflik dengan build backend
63
+
64
+ ### Step 3: Define shared types (manual + auto-generated)
65
+
66
+ Create akses-backend/src/shared/index.ts:
67
+
68
+ ```typescript
69
+ // Re-export Prisma types yang aman di-share ke frontend
70
+ export type {
71
+ User,
72
+ Order,
73
+ Platform
74
+ // Don't export: Credentials (sensitive), Sessions (internal)
75
+ } from '@prisma/client'
76
+
77
+ // Export Zod schemas untuk runtime validation
78
+ export { UserSchema, OrderSchema } from './schemas/user'
79
+ export { TrackingSchema, type OrderTracking } from './schemas/tracking'
80
+
81
+ // Manual types untuk API response wrappers
82
+ export type ApiResponse<T> = { data: T, meta?: any } | { error: string }
83
+ ```
84
+
85
+ PENTING: Filter type yang sensitif:
86
+ - `Credentials`, `Sessions`, `ApiKey`, `Token` — JANGAN di-export
87
+ - Field internal seperti `internal_notes`, `cost_price`, `commission` — pakai DTO terpisah
88
+ - Buat type wrapper `PublicUser` (cuma field yang aman ke client) vs `User` (full Prisma model di backend)
89
+
90
+ ### Step 4: Auto-generate script
91
+
92
+ Add to akses-backend/package.json:
93
+
94
+ ```json
95
+ {
96
+ "scripts": {
97
+ "generate:types": "prisma generate && tsup --config tsup.shared.config.ts",
98
+ "publish:shared": "cd shared-dist && npm publish --registry=https://npm.pkg.github.com"
99
+ }
100
+ }
101
+ ```
102
+
103
+ Test lokal:
104
+ ```bash
105
+ npm run generate:types
106
+ ls shared-dist/ # cek output: index.d.ts, index.js, index.mjs, package.json
107
+ ```
108
+
109
+ ### Step 5: GitHub Actions auto-pipeline
110
+
111
+ Create akses-backend/.github/workflows/publish-shared.yml:
112
+
113
+ ```yaml
114
+ name: Publish @<project>/shared on schema change
115
+
116
+ on:
117
+ push:
118
+ branches: [main]
119
+ paths:
120
+ - 'prisma/schema.prisma'
121
+ - 'src/shared/**'
122
+
123
+ jobs:
124
+ publish:
125
+ runs-on: ubuntu-latest
126
+ permissions:
127
+ contents: read
128
+ packages: write
129
+ steps:
130
+ - uses: actions/checkout@v4
131
+ - uses: actions/setup-node@v4
132
+ with:
133
+ node-version: '20'
134
+ registry-url: 'https://npm.pkg.github.com'
135
+ - run: npm ci
136
+ - name: Generate types
137
+ run: npm run generate:types
138
+ - name: Bump version & publish
139
+ env:
140
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141
+ run: |
142
+ cd shared-dist
143
+ npm version patch -m 'chore(shared): bump version [skip ci]'
144
+ npm publish
145
+ - name: Notify Discord
146
+ run: |
147
+ VERSION=$(node -p "require('./shared-dist/package.json').version")
148
+ curl -X POST ${{ secrets.DISCORD_WEBHOOK_DEPS }} \
149
+ -H 'Content-Type: application/json' \
150
+ -d "{\"content\": \"@<project>/shared v$VERSION published. Frontend team: PR dari Renovate akan masuk dalam 24 jam, atau manual npm install untuk segera dapat update.\"}"
151
+ ```
152
+
153
+ Catatan trigger:
154
+ - `paths` filter — workflow hanya jalan kalau yang berubah Prisma schema atau folder shared
155
+ - Kalau cuma update business logic backend (di luar shared/), workflow skip → hemat CI minutes
156
+ - `[skip ci]` di commit version bump — supaya tidak trigger workflow lagi (infinite loop)
157
+
158
+ ---
159
+
160
+ ## Real-Time Trigger Pattern (Recommended for Fast-Moving Teams)
161
+
162
+ > Backend publish → Frontend repo auto-update DALAM 3-5 MENIT (vs Renovate 24 jam).
163
+ > Pakai GitHub Actions repository_dispatch event.
164
+
165
+ ### Filosofi
166
+
167
+ Renovate = polling-based (scan periodic). Untuk team yang kerja CEPAT (AI Claude Code-powered), 24 jam terlalu lama.
168
+
169
+ Solusi: push-based. Backend lapor SEKARANG, frontend respond SEKARANG.
170
+
171
+ ### Setup Backend Side
172
+
173
+ Update .github/workflows/publish-shared.yml di akses-backend, tambah step terakhir:
174
+
175
+ ```yaml
176
+ - name: Trigger frontend repo update
177
+ uses: peter-evans/repository-dispatch@v3
178
+ with:
179
+ token: ${{ secrets.FRONTEND_REPO_DISPATCH_TOKEN }}
180
+ repository: <owner>/<project>-frontend
181
+ event-type: shared-package-published
182
+ client-payload: |
183
+ {
184
+ "version": "${{ env.NEW_VERSION }}",
185
+ "commit": "${{ github.sha }}",
186
+ "changelog_url": "https://github.com/<owner>/<project>-backend/commits/main"
187
+ }
188
+ ```
189
+
190
+ Setup secret:
191
+ 1. Generate Personal Access Token (PAT) di GitHub > Settings > Developer settings > Tokens (classic)
192
+ 2. Scope: `repo` + `workflow` (untuk akses repo frontend)
193
+ 3. Save ke akses-backend > Settings > Secrets > FRONTEND_REPO_DISPATCH_TOKEN
194
+
195
+ ### Setup Frontend Side
196
+
197
+ Create .github/workflows/receive-shared-update.yml di akses-frontend:
198
+
199
+ ```yaml
200
+ name: Receive @<project>/shared update
201
+
202
+ on:
203
+ repository_dispatch:
204
+ types: [shared-package-published]
205
+
206
+ jobs:
207
+ update:
208
+ runs-on: ubuntu-latest
209
+ permissions:
210
+ contents: write
211
+ pull-requests: write
212
+ steps:
213
+ - uses: actions/checkout@v4
214
+ with:
215
+ fetch-depth: 0
216
+ - uses: actions/setup-node@v4
217
+ with:
218
+ node-version: '20'
219
+ registry-url: 'https://npm.pkg.github.com'
220
+ scope: '@<project>'
221
+ - name: Install new shared version
222
+ env:
223
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224
+ run: |
225
+ npm install @<project>/shared@${{ github.event.client_payload.version }}
226
+ - name: Create PR
227
+ uses: peter-evans/create-pull-request@v6
228
+ with:
229
+ token: ${{ secrets.GITHUB_TOKEN }}
230
+ commit-message: "chore(deps): bump @<project>/shared to ${{ github.event.client_payload.version }}"
231
+ title: "Auto-update @<project>/shared to v${{ github.event.client_payload.version }}"
232
+ body: |
233
+ Triggered by backend publish.
234
+
235
+ **Version**: v${{ github.event.client_payload.version }}
236
+ **Backend commit**: [${{ github.event.client_payload.commit }}](${{ github.event.client_payload.changelog_url }})
237
+
238
+ ## Action Required
239
+
240
+ - Review changes di backend (klik commit link di atas)
241
+ - Test di local: `npm run dev` + check halaman yang affected
242
+ - Approve + merge kalau OK
243
+
244
+ ## Auto-Generated
245
+ Workflow: `.github/workflows/receive-shared-update.yml`
246
+ branch: auto/shared-update-${{ github.event.client_payload.version }}
247
+ labels: |
248
+ auto-update
249
+ shared-types
250
+ ```
251
+
252
+ ### Workflow End-to-End (3-5 Menit Total)
253
+
254
+ ```
255
+ 10:00:00 Backend staff prompt AI -> push schema change ke akses-backend main
256
+ 10:00:05 GitHub Actions: publish-shared.yml triggered
257
+ 10:01:30 Types generated + version bumped + publish ke GitHub Packages
258
+ 10:02:00 npm publish complete
259
+ 10:02:05 Discord webhook notif posted
260
+ 10:02:10 repository_dispatch ke akses-frontend
261
+ 10:02:15 Frontend repo: receive-shared-update.yml triggered
262
+ 10:03:00 npm install @<project>/shared@latest
263
+ 10:03:30 Create PR via peter-evans/create-pull-request
264
+ 10:04:00 PR ready di akses-frontend
265
+ 10:04:05 Discord notif update: "PR ready di frontend repo, please review"
266
+
267
+ Total: ~4 menit dari backend push to frontend PR ready.
268
+ ```
269
+
270
+ ### Comparison: Renovate vs Real-Time Trigger
271
+
272
+ | Aspect | Renovate (24 jam) | Real-Time Trigger (4 menit) |
273
+ |---|---|---|
274
+ | Latency | <24 jam | <5 menit |
275
+ | Setup complexity | Low (1 file renovate.json) | Medium (2 workflow files + PAT) |
276
+ | Reliability | High (mature tool) | High (GitHub native event) |
277
+ | Cost | $0 | $0 |
278
+ | Best for | Slow teams, less critical updates | Fast teams, AI Claude Code-powered |
279
+
280
+ ### Recommendation for akses
281
+
282
+ Pakai DUA-DUANYA:
283
+ - Real-time trigger = PRIMARY (handle real-time updates)
284
+ - Renovate = BACKUP (catch missed events, weekly scan)
285
+
286
+ Plus Discord notif at both stages untuk human awareness.
287
+
288
+ ### Optional: Auto-Merge (Aggressive Mode)
289
+
290
+ Kalau super trust + tim kecil (< 5 frontend), bisa auto-merge:
291
+
292
+ ```yaml
293
+ - name: Enable auto-merge
294
+ run: |
295
+ gh pr merge ${{ steps.cpr.outputs.pull-request-number }} --auto --squash
296
+ env:
297
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
298
+ ```
299
+
300
+ Risk: kalau backend publish breaking change, langsung kena frontend.
301
+ Mitigation: backend MUST commit dengan "BREAKING:" prefix -> workflow detect + skip auto-merge.
302
+
303
+ ---
304
+
305
+ ## Setup di akses-frontend Repo
306
+
307
+ ### Renovate Auto-PR (Backup, untuk catch missed real-time events)
308
+
309
+ ### Step 1: Renovate config
310
+
311
+ Create akses-frontend/renovate.json:
312
+
313
+ ```json
314
+ {
315
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
316
+ "extends": ["config:recommended"],
317
+ "schedule": ["after 9am every weekday"],
318
+ "packageRules": [
319
+ {
320
+ "matchPackageNames": ["@<project>/shared"],
321
+ "schedule": ["at any time"],
322
+ "automerge": false,
323
+ "groupName": "shared package",
324
+ "reviewers": ["<owner-username>"],
325
+ "labels": ["auto-update", "shared-types"]
326
+ }
327
+ ],
328
+ "vulnerabilityAlerts": {
329
+ "enabled": true
330
+ }
331
+ }
332
+ ```
333
+
334
+ Enable Renovate bot di GitHub: https://github.com/marketplace/renovate
335
+
336
+ Konfigurasi penting:
337
+ - `schedule: ["at any time"]` untuk @<project>/shared — bypass default schedule supaya update urgent type bisa langsung dibuatkan PR
338
+ - `automerge: false` — owner tetap review sebelum merge (safety)
339
+ - `reviewers` — auto-assign ke owner supaya notif langsung muncul
340
+
341
+ ### Step 2: AI Auto-Check di session start
342
+
343
+ Edit akses-frontend/.claude-kit/AGENTS.md tambah section:
344
+
345
+ ```markdown
346
+ ## Session Start Auto-Check (untuk AI Claude Code)
347
+
348
+ Saat session pertama tiap hari, AI WAJIB:
349
+
350
+ 1. Cek @<project>/shared version:
351
+ - Read package.json: catat version yang dipakai
352
+ - Run: npm view @<project>/shared version --registry=https://npm.pkg.github.com (atau alternatif: curl GitHub Packages API)
353
+ - Compare: kalau outdated, output warning:
354
+ "@<project>/shared outdated (current: <local>, latest: <remote>)
355
+ Lanjut npm install untuk update? Atau lanjut dengan version lama?"
356
+
357
+ 2. Cek Swagger API spec:
358
+ - Fetch: curl -s https://api-staging.<project>.id/docs/openapi.json > /tmp/api-spec.json
359
+ - Cache spec untuk reference saat AI suggest API call
360
+ - Kalau Swagger 404, log warning "Backend offline atau spec belum ready"
361
+
362
+ 3. Cek Discord channel #akses-deps untuk recent updates (manual check, owner periodically share).
363
+
364
+ Tujuan: Frontend AI selalu aware latest API contract + types.
365
+ ```
366
+
367
+ ---
368
+
369
+ ## Setup Discord Webhook
370
+
371
+ 1. Discord server > Settings > Integrations > Webhooks > New Webhook
372
+ 2. Name: "akses-shared-publisher"
373
+ 3. Channel: #akses-deps (bikin channel baru kalau belum ada)
374
+ 4. Copy URL
375
+ 5. Save sebagai GitHub Secret di akses-backend:
376
+ - Settings > Secrets > New: DISCORD_WEBHOOK_DEPS
377
+ - Value: paste URL
378
+
379
+ Tips kanal Discord:
380
+ - Bikin role @deps-watcher dan mention di template message → tim FE dapat notifikasi langsung
381
+ - Aktifkan thread auto-create per release → diskusi breaking change tidak nyampur dengan notif lain
382
+ - Pin pesan pinned dengan link ke dokumen ini supaya tim baru tahu workflow
383
+
384
+ ---
385
+
386
+ ## Workflow End-to-End
387
+
388
+ ```
389
+ Day 1, jam 10:00 — Backend staff
390
+ Prompt: "tambah field estimated_arrival di Order"
391
+
392
+ AI:
393
+ - Update prisma/schema.prisma
394
+ - Run prisma migrate dev (local staging)
395
+ - Update src/shared/schemas/tracking.ts (tambah type)
396
+ - Run npm run generate:types
397
+ - Commit + push
398
+
399
+ Day 1, jam 10:05 — GitHub Actions
400
+ - Detect push to main with schema change
401
+ - Run publish-shared.yml workflow
402
+ - Generate types
403
+ - Bump @<project>/shared dari v1.1.0 → v1.1.1
404
+ - Publish ke GitHub Packages
405
+ - POST Discord webhook
406
+
407
+ Day 1, jam 10:06 — Discord channel #akses-deps
408
+ Bot post: "@<project>/shared v1.1.1 published"
409
+
410
+ Day 1, jam 11:00 — Renovate scan (atau next morning)
411
+ - Detect @<project>/shared v1.1.0 → v1.1.1 available
412
+ - Auto-create PR di akses-frontend
413
+ - Title: "chore(deps): bump @<project>/shared from 1.1.0 to 1.1.1"
414
+
415
+ Day 2, jam 09:00 — Owner morning routine
416
+ - Review PR di GitHub
417
+ - Approve + merge
418
+ - Frontend tim dapat update di next pull
419
+
420
+ Day 2, jam 09:30 — Frontend staff
421
+ Prompt: "bikin halaman tracking"
422
+
423
+ AI session start auto-check:
424
+ - @<project>/shared v1.1.1 sudah pakai
425
+ - Swagger spec fetched, endpoint tracking ada
426
+ - AI proceed dengan up-to-date context
427
+ ```
428
+
429
+ ---
430
+
431
+ ## Versioning & Breaking Changes
432
+
433
+ Pakai semver disiplin:
434
+ - PATCH (1.1.0 → 1.1.1) — tambah field optional, tambah type baru, fix typo
435
+ - MINOR (1.1.0 → 1.2.0) — tambah endpoint baru, tambah enum value
436
+ - MAJOR (1.x → 2.0.0) — hapus field, rename field, ubah signature
437
+
438
+ Untuk MAJOR:
439
+ 1. Backend buat branch `breaking/v2` dulu
440
+ 2. Publish dengan dist-tag `next` (bukan `latest`)
441
+ 3. Frontend bisa coba `npm install @<project>/shared@next`
442
+ 4. Setelah migration di frontend done, baru promote ke `latest`
443
+
444
+ ---
445
+
446
+ ## FAQ
447
+
448
+ **Q: Kalau backend gak mau auto-publish (mau review dulu)?**
449
+ A: Hapus trigger 'on: push: branches: [main]'. Ganti dengan 'on: workflow_dispatch' (manual trigger).
450
+
451
+ **Q: Kalau frontend gak mau auto-PR (mau pilih sendiri kapan update)?**
452
+ A: Disable Renovate, pakai manual npm install routine. Lapis 3 (workflow routine) + Lapis 4 (AI auto-check) tetap aktif.
453
+
454
+ **Q: Cost?**
455
+ A: $0. GitHub Actions free tier, GitHub Packages free (private up to 500MB), Renovate free.
456
+
457
+ **Q: Berapa lama setup?**
458
+ A: 2-3 jam owner one-time. Setelah itu zero ongoing maintenance.
459
+
460
+ **Q: Bagaimana kalau ada conflict antar staff yang ubah shared types bersamaan?**
461
+ A: Karena hanya backend yang punya akses tulis ke `src/shared/`, conflict cuma terjadi di repo backend. Resolusi pakai PR review standar GitHub.
462
+
463
+ **Q: Kalau Renovate tidak detect update dalam 24 jam?**
464
+ A: Buka manual: GitHub > akses-frontend > Insights > Dependency graph > Renovate logs. Atau trigger manual via Dependency Dashboard issue.
465
+
466
+ **Q: Bagaimana audit history apa saja yang berubah di types?**
467
+ A: Lihat commit history di akses-backend `src/shared/` + GitHub Packages versions page. Setiap version punya tag commit yang menghasilkan publish.
468
+
469
+ **Q: Apakah perlu pakai semantic-release?**
470
+ A: Tidak wajib. `npm version patch` di workflow sudah cukup untuk auto-bump. Pakai semantic-release kalau mau analyze commit message untuk decide patch/minor/major otomatis.
471
+
472
+ **Q: Kalau frontend tim banyak (>3), apakah workflow ini cukup?**
473
+ A: Cukup. Setiap dev tarik pakai `git pull` + `npm install` setelah PR Renovate merged. Tidak perlu koordinasi manual.
@@ -0,0 +1,194 @@
1
+ # templates/DB_SCHEMA_SCAN_PROMPT.md — Scan Database Schema → docs/db-schema.md
2
+
3
+ > Versi 1 · 2026-06-01
4
+ > Standalone prompt untuk generate `docs/db-schema.md` dari source code project.
5
+
6
+ ---
7
+
8
+ ## Kapan pakai prompt ini?
9
+
10
+ Paste prompt ini ke Claude Code **kalau**:
11
+ - ✅ Pertama kali setup project + ingin AI paham database struktur project sebelum bantu coding.
12
+ - ✅ Schema baru saja berubah (model ditambah/dihapus, relasi diubah) dan `docs/db-schema.md` belum update.
13
+ - ✅ Audit relasi antar-model untuk planning refactor.
14
+
15
+ **JANGAN paste prompt ini kalau**:
16
+ - ❌ Project belum punya ORM / schema file (mis. project Express tanpa Prisma → schema implicit di code).
17
+ - ❌ Schema confidential dan tidak boleh ke-ekspos ke `.md` (mis. financial data dengan field PII sensitif).
18
+
19
+ ---
20
+
21
+ ## Untuk AI (mulai dari sini)
22
+
23
+ ### Peran
24
+ Kamu adalah **Database Architect + Tech Writer**. Tujuan: generate `docs/db-schema.md` yang akurat berdasarkan source code, BUKAN tebakan generic.
25
+
26
+ ### Aturan kerja
27
+ - **Bahasa Indonesia**, junior-friendly.
28
+ - **Akurasi > kelengkapan**. Lebih baik `[TBD: <alasan>]` daripada karang relasi.
29
+ - **Setiap klaim traceable** ke file/baris source (mis. `prisma/schema.prisma:42`).
30
+ - **JANGAN baca file rahasia** (`.env`, `*.key`, `secrets/`, `credentials*`).
31
+ - **Cek dulu** apakah `docs/db-schema.md` sudah ada — kalau ada, baca dulu untuk anti-overwrite + delta detection.
32
+
33
+ ### Workflow 4 fase
34
+
35
+ #### FASE 1 — Auto-detect schema source
36
+
37
+ Cari file schema dengan prioritas (top down):
38
+
39
+ 1. **Prisma**: `prisma/schema.prisma` (atau `schema.prisma` di root)
40
+ 2. **Drizzle**: `db/schema.ts`, `drizzle/schema.ts`, `src/db/schema.ts`
41
+ 3. **Sequelize**: `models/index.js` + `models/*.js`
42
+ 4. **TypeORM**: file dengan `@Entity()` decorator
43
+ 5. **SQLAlchemy (Python)**: file dengan `class X(Base)` declaration
44
+ 6. **Raw SQL migrations**: `migrations/*.sql`, `db/migrations/*.sql`
45
+ 7. **Hibernate (Java)**: file dengan `@Entity` annotation
46
+ 8. **Active Record (Rails)**: `db/schema.rb`
47
+
48
+ Kalau **tidak ditemukan** → stop, lapor: "Schema source tidak ditemukan. Kalau project pakai database, paste file schema atau output `\d` (psql describe) untuk lanjut."
49
+
50
+ Kalau **multiple sources** (mis. Prisma + raw migrations) → tanya user mana yang authoritative (biasanya schema.prisma).
51
+
52
+ #### FASE 2 — Parse schema
53
+
54
+ Baca file schema source, ekstrak:
55
+
56
+ - **Model list** (nama tabel/entity).
57
+ - **Field per model** (nama, tipe data, constraint: nullable, default, unique, primary key).
58
+ - **Relasi** (1:1, 1:N, N:M) — direction + foreign key field.
59
+ - **Index** (composite, partial, unique).
60
+ - **Enum** (kalau ada).
61
+ - **Trigger / function** (kalau di-export ke schema source).
62
+
63
+ **Skip**:
64
+ - Auto-generated field (mis. `_prisma_migrations` table).
65
+ - Field internal Supabase (`auth.users`, `storage.objects`) kecuali user explicit minta.
66
+
67
+ #### FASE 3 — Generate docs/db-schema.md
68
+
69
+ Format wajib:
70
+
71
+ ```markdown
72
+ # docs/db-schema.md — Schema database <NAMA_PROYEK>
73
+
74
+ > Versi 1 · <YYYY-MM-DD> · auto-generated dari <SCHEMA_SOURCE>
75
+ > Update: tiap schema berubah (lihat aturan AUTO-SYNC 7.1)
76
+
77
+ ## Pengantar
78
+ [1-2 kalimat: stack DB (PostgreSQL via Supabase / MySQL / dll) + ORM (Prisma / Drizzle / raw) + scope (multi-tenant schema / single-tenant)]
79
+
80
+ ## Topology
81
+ [Mermaid ER diagram — kalau total model <= 20. Kalau lebih, group per domain]
82
+
83
+ \`\`\`mermaid
84
+ erDiagram
85
+ USER ||--o{ POST : creates
86
+ USER ||--o{ COMMENT : writes
87
+ POST ||--o{ COMMENT : has
88
+ USER {
89
+ string id PK
90
+ string email UK
91
+ string name
92
+ }
93
+ POST {
94
+ string id PK
95
+ string userId FK
96
+ string title
97
+ datetime createdAt
98
+ }
99
+ \`\`\`
100
+
101
+ ## Daftar Model
102
+
103
+ ### `User` (table: users)
104
+ - **Tujuan**: [1 kalimat berbasis observasi source]
105
+ - **Source**: `prisma/schema.prisma:12-34`
106
+ - **Field**:
107
+ | Nama | Tipe | Constraint | Catatan |
108
+ |---|---|---|---|
109
+ | id | String | PK, @default(cuid()) | unique identifier |
110
+ | email | String | UK, NOT NULL | email login |
111
+ | passwordHash | String | NOT NULL | bcrypt hash |
112
+ | role | Role | enum | SUPERVISOR / PIC / ADMIN |
113
+ | createdAt | DateTime | @default(now()) | timestamp |
114
+ - **Relasi**:
115
+ - 1:N → `Post` via `Post.userId`
116
+ - 1:N → `LoginLog` via `LoginLog.userId`
117
+ - 1:1 → `UserProfile` via `UserProfile.userId`
118
+ - **Index**:
119
+ - UNIQUE(email)
120
+ - INDEX(role, isActive) — untuk filter dashboard cepat
121
+ - **Dipakai di**:
122
+ - [docs/security/auth.md](security/auth.md) — login flow
123
+ - [docs/api/users/index.md](api/users/index.md) — CRUD user
124
+ - [docs/api/security.md](api/security.md) — list active sessions
125
+
126
+ ### `Post` (table: posts)
127
+ [... pattern sama ...]
128
+
129
+ ## Enum
130
+ ### `Role`
131
+ | Value | Deskripsi |
132
+ |---|---|
133
+ | SUPERVISOR | Owner, full akses |
134
+ | PIC | Manager, akses tim |
135
+ | ADMIN | Staff, akses terbatas |
136
+
137
+ ## Index Penting (cross-model)
138
+ - `LoginLog(userId, eventType, createdAt DESC)` — untuk dashboard security
139
+ - `Credential(deletedAt) WHERE deletedAt IS NULL` — partial index untuk soft-delete filter
140
+
141
+ ## Catatan Keputusan
142
+ - **Soft-delete pattern**: model `Credential`, `Post` punya `deletedAt` column → query default `WHERE deletedAt IS NULL`.
143
+ - **Audit trail**: `LoginLog`, `CredentialAuditLog` immutable — tidak ada UPDATE atau DELETE, hanya INSERT.
144
+ - **Encryption-at-rest**: field `password`, `username`, `notes` di `Credential` di-encrypt via [encryption.md](security/encryption.md) sebelum simpan.
145
+ - **Schema isolation**: project ini pakai shared DB Supabase production, schema `<nama>`. Lihat [MCP_SETUP.md](MCP_SETUP.md) untuk role isolation.
146
+
147
+ ## Migrasi history (recent)
148
+ [Optional: kalau ada `prisma migrate` history yang menarik, summarize 3-5 migrasi terakhir]
149
+ - 2026-05-09: tambah `User.activeSessionId` untuk single-session enforcement
150
+ - 2026-05-15: tambah `ImpersonationSession` audit table
151
+ - 2026-05-20: tambah `IpBlacklist` table
152
+
153
+ ## Source files
154
+ - `prisma/schema.prisma` — schema utama
155
+ - `prisma/migrations/` — migration history
156
+ - `src/lib/prisma.ts` — Prisma client singleton ([prisma.md](lib/prisma.md))
157
+ ```
158
+
159
+ #### FASE 4 — Update registry + cross-refs
160
+
161
+ 1. **Update `docs/architecture_auto.md`**: tambah entry `[db-schema.md](db-schema.md) — Schema database (X model, Y relasi)`.
162
+ 2. **Update `docs/architecture.md`** (peta makro proyek) — kalau belum ada section "Database", tambah link ke `db-schema.md`.
163
+ 3. **Cross-link**: untuk tiap model yang di-list di `db-schema.md`, cari `.md` lain yang sebut model tersebut → tambah link bi-directional.
164
+
165
+ ---
166
+
167
+ ## Aturan setelah generate
168
+
169
+ - **AUTO-SYNC (7.1)**: setiap kali schema berubah (file Prisma/Drizzle/dll edited) → AI WAJIB re-generate `docs/db-schema.md` di sesi yang sama. Tidak boleh dibiarkan stale.
170
+ - **Version bump**: kalau ada breaking change (rename model, drop field), bump versi di header `> Versi 2 · ...`.
171
+ - **Cross-check sebelum commit**: pastikan field name di `.md` MATCH dengan source schema persis.
172
+
173
+ ---
174
+
175
+ ## Troubleshooting
176
+
177
+ ### Schema terlalu besar untuk fit di 1 file
178
+ - Kalau total model > 50, split per domain: `docs/db/auth-schema.md`, `docs/db/payment-schema.md`, dst.
179
+ - `docs/db-schema.md` jadi index yang point ke per-domain file.
180
+
181
+ ### Multi-database (mis. PostgreSQL + Redis + MongoDB)
182
+ - Generate 1 file per database: `db-schema-postgres.md`, `db-schema-redis.md`, `db-schema-mongo.md`.
183
+ - Update `architecture.md` section "Data layer" untuk overview cross-DB.
184
+
185
+ ### Mermaid diagram terlalu besar (> 20 model)
186
+ - Skip Mermaid di main file, generate per-domain Mermaid di domain-specific `.md`.
187
+ - Atau pakai PNG embed (generate via mmdc CLI lokal).
188
+
189
+ ---
190
+
191
+ ## Referensi
192
+ - Mermaid ER diagram syntax: https://mermaid.js.org/syntax/entityRelationshipDiagram.html
193
+ - Prisma schema reference: https://www.prisma.io/docs/orm/prisma-schema
194
+ - Drizzle schema docs: https://orm.drizzle.team/docs/sql-schema-declaration