ui-syncup 0.3.13 → 0.4.0-beta.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 (1047) hide show
  1. package/.agents/skills/ai-spec-workflow/SKILL.md +58 -0
  2. package/.agents/skills/ai-spec-workflow/references/AI_SPECIFICATION_WORKFLOW.md +1434 -0
  3. package/.agents/skills/ai-spec-workflow/references/templates/design-template.md +729 -0
  4. package/.agents/skills/ai-spec-workflow/references/templates/requirements-template.md +179 -0
  5. package/.agents/skills/ai-spec-workflow/references/templates/tasks-template.md +501 -0
  6. package/.agents/skills/animation-designer/SKILL.md +688 -0
  7. package/.agents/skills/animation-designer/manifest.yaml +44 -0
  8. package/.agents/skills/brainstorming/SKILL.md +54 -0
  9. package/.agents/skills/contract-driven-ui/SKILL.md +270 -0
  10. package/.agents/skills/dispatching-parallel-agents/SKILL.md +180 -0
  11. package/.agents/skills/executing-plans/SKILL.md +76 -0
  12. package/.agents/skills/executing-specs/SKILL.md +53 -0
  13. package/.agents/skills/finishing-a-development-branch/SKILL.md +200 -0
  14. package/.agents/skills/github-workflow-automation/SKILL.md +846 -0
  15. package/.agents/skills/react-best-practices/AGENTS.md +2249 -0
  16. package/.agents/skills/react-best-practices/README.md +123 -0
  17. package/.agents/skills/react-best-practices/SKILL.md +121 -0
  18. package/.agents/skills/react-best-practices/metadata.json +15 -0
  19. package/.agents/skills/react-best-practices/rules/_sections.md +46 -0
  20. package/.agents/skills/react-best-practices/rules/_template.md +28 -0
  21. package/.agents/skills/react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  22. package/.agents/skills/react-best-practices/rules/advanced-use-latest.md +49 -0
  23. package/.agents/skills/react-best-practices/rules/async-api-routes.md +38 -0
  24. package/.agents/skills/react-best-practices/rules/async-defer-await.md +80 -0
  25. package/.agents/skills/react-best-practices/rules/async-dependencies.md +36 -0
  26. package/.agents/skills/react-best-practices/rules/async-parallel.md +28 -0
  27. package/.agents/skills/react-best-practices/rules/async-suspense-boundaries.md +99 -0
  28. package/.agents/skills/react-best-practices/rules/bundle-barrel-imports.md +59 -0
  29. package/.agents/skills/react-best-practices/rules/bundle-conditional.md +31 -0
  30. package/.agents/skills/react-best-practices/rules/bundle-defer-third-party.md +49 -0
  31. package/.agents/skills/react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  32. package/.agents/skills/react-best-practices/rules/bundle-preload.md +50 -0
  33. package/.agents/skills/react-best-practices/rules/client-event-listeners.md +74 -0
  34. package/.agents/skills/react-best-practices/rules/client-swr-dedup.md +56 -0
  35. package/.agents/skills/react-best-practices/rules/js-batch-dom-css.md +82 -0
  36. package/.agents/skills/react-best-practices/rules/js-cache-function-results.md +80 -0
  37. package/.agents/skills/react-best-practices/rules/js-cache-property-access.md +28 -0
  38. package/.agents/skills/react-best-practices/rules/js-cache-storage.md +70 -0
  39. package/.agents/skills/react-best-practices/rules/js-combine-iterations.md +32 -0
  40. package/.agents/skills/react-best-practices/rules/js-early-exit.md +50 -0
  41. package/.agents/skills/react-best-practices/rules/js-hoist-regexp.md +45 -0
  42. package/.agents/skills/react-best-practices/rules/js-index-maps.md +37 -0
  43. package/.agents/skills/react-best-practices/rules/js-length-check-first.md +49 -0
  44. package/.agents/skills/react-best-practices/rules/js-min-max-loop.md +82 -0
  45. package/.agents/skills/react-best-practices/rules/js-set-map-lookups.md +24 -0
  46. package/.agents/skills/react-best-practices/rules/js-tosorted-immutable.md +57 -0
  47. package/.agents/skills/react-best-practices/rules/rendering-activity.md +26 -0
  48. package/.agents/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  49. package/.agents/skills/react-best-practices/rules/rendering-conditional-render.md +40 -0
  50. package/.agents/skills/react-best-practices/rules/rendering-content-visibility.md +38 -0
  51. package/.agents/skills/react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  52. package/.agents/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  53. package/.agents/skills/react-best-practices/rules/rendering-svg-precision.md +28 -0
  54. package/.agents/skills/react-best-practices/rules/rerender-defer-reads.md +39 -0
  55. package/.agents/skills/react-best-practices/rules/rerender-dependencies.md +45 -0
  56. package/.agents/skills/react-best-practices/rules/rerender-derived-state.md +29 -0
  57. package/.agents/skills/react-best-practices/rules/rerender-functional-setstate.md +74 -0
  58. package/.agents/skills/react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  59. package/.agents/skills/react-best-practices/rules/rerender-memo.md +44 -0
  60. package/.agents/skills/react-best-practices/rules/rerender-transitions.md +40 -0
  61. package/.agents/skills/react-best-practices/rules/server-after-nonblocking.md +73 -0
  62. package/.agents/skills/react-best-practices/rules/server-cache-lru.md +41 -0
  63. package/.agents/skills/react-best-practices/rules/server-cache-react.md +26 -0
  64. package/.agents/skills/react-best-practices/rules/server-parallel-fetching.md +79 -0
  65. package/.agents/skills/react-best-practices/rules/server-serialization.md +38 -0
  66. package/.agents/skills/react-ui-patterns/SKILL.md +289 -0
  67. package/.agents/skills/receiving-code-review/SKILL.md +213 -0
  68. package/.agents/skills/requesting-code-review/SKILL.md +105 -0
  69. package/.agents/skills/requesting-code-review/code-reviewer.md +146 -0
  70. package/.agents/skills/reviewing-code/SKILL.md +28 -0
  71. package/.agents/skills/shadcn/SKILL.md +240 -0
  72. package/.agents/skills/shadcn/agents/openai.yml +5 -0
  73. package/.agents/skills/shadcn/assets/shadcn-small.png +0 -0
  74. package/.agents/skills/shadcn/assets/shadcn.png +0 -0
  75. package/.agents/skills/shadcn/cli.md +255 -0
  76. package/.agents/skills/shadcn/customization.md +202 -0
  77. package/.agents/skills/shadcn/evals/evals.json +47 -0
  78. package/.agents/skills/shadcn/mcp.md +94 -0
  79. package/.agents/skills/shadcn/rules/base-vs-radix.md +306 -0
  80. package/.agents/skills/shadcn/rules/composition.md +195 -0
  81. package/.agents/skills/shadcn/rules/forms.md +192 -0
  82. package/.agents/skills/shadcn/rules/icons.md +101 -0
  83. package/.agents/skills/shadcn/rules/styling.md +162 -0
  84. package/.agents/skills/steering-creation/SKILL.md +221 -0
  85. package/.agents/skills/steering-creation/references/STEERING_CREATION_INSTRUCTION.md +850 -0
  86. package/.agents/skills/subagent-driven-development/SKILL.md +240 -0
  87. package/.agents/skills/subagent-driven-development/code-quality-reviewer-prompt.md +20 -0
  88. package/.agents/skills/subagent-driven-development/implementer-prompt.md +78 -0
  89. package/.agents/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  90. package/.agents/skills/systematic-debugging/CREATION-LOG.md +119 -0
  91. package/.agents/skills/systematic-debugging/SKILL.md +296 -0
  92. package/.agents/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  93. package/.agents/skills/systematic-debugging/condition-based-waiting.md +115 -0
  94. package/.agents/skills/systematic-debugging/defense-in-depth.md +122 -0
  95. package/.agents/skills/systematic-debugging/find-polluter.sh +63 -0
  96. package/.agents/skills/systematic-debugging/root-cause-tracing.md +169 -0
  97. package/.agents/skills/systematic-debugging/test-academic.md +14 -0
  98. package/.agents/skills/systematic-debugging/test-pressure-1.md +58 -0
  99. package/.agents/skills/systematic-debugging/test-pressure-2.md +68 -0
  100. package/.agents/skills/systematic-debugging/test-pressure-3.md +69 -0
  101. package/.agents/skills/test-driven-development/SKILL.md +371 -0
  102. package/.agents/skills/test-driven-development/testing-anti-patterns.md +299 -0
  103. package/.agents/skills/using-git-worktrees/SKILL.md +217 -0
  104. package/.agents/skills/using-superpowers/SKILL.md +87 -0
  105. package/.agents/skills/verification-before-completion/SKILL.md +139 -0
  106. package/.agents/skills/web-design-guidelines/SKILL.md +36 -0
  107. package/.agents/skills/writing-plans/SKILL.md +116 -0
  108. package/.agents/skills/writing-skills/SKILL.md +655 -0
  109. package/.agents/skills/writing-skills/anthropic-best-practices.md +1150 -0
  110. package/.agents/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  111. package/.agents/skills/writing-skills/graphviz-conventions.dot +172 -0
  112. package/.agents/skills/writing-skills/persuasion-principles.md +187 -0
  113. package/.agents/skills/writing-skills/render-graphs.js +168 -0
  114. package/.agents/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  115. package/.ai/steering/product.md +51 -0
  116. package/.ai/steering/structure.md +275 -0
  117. package/.ai/steering/tech.md +188 -0
  118. package/.claude/agents/database-architect.md +96 -0
  119. package/.claude/agents/deployment-pipeline-architect.md +122 -0
  120. package/.claude/agents/nextjs-expert.md +69 -0
  121. package/.claude/agents/ui-design-expert.md +106 -0
  122. package/.claudeignore +69 -0
  123. package/.dockerignore +8 -0
  124. package/.env.development +86 -0
  125. package/.env.example +171 -0
  126. package/.env.production +139 -0
  127. package/.env.test +58 -0
  128. package/.gitattributes +2 -0
  129. package/.github/ISSUE_TEMPLATE/bug_report.yml +33 -0
  130. package/.github/ISSUE_TEMPLATE/feature_request.yml +20 -0
  131. package/.github/PULL_REQUEST_TEMPLATE.md +23 -0
  132. package/.github/workflows/ci.yml +64 -0
  133. package/.github/workflows/release.yml +174 -0
  134. package/.nvmrc +1 -0
  135. package/.releaserc.json +18 -0
  136. package/.vercelignore +73 -0
  137. package/AGENTS.md +544 -0
  138. package/CHANGELOG.md +69 -0
  139. package/CODE_OF_CONDUCT.md +21 -0
  140. package/CONTRIBUTING.md +32 -0
  141. package/Dockerfile +84 -0
  142. package/LICENSE +21 -0
  143. package/README.md +328 -59
  144. package/SECURITY.md +16 -0
  145. package/bun.lock +3853 -0
  146. package/cli/README.md +94 -0
  147. package/cli/bun.lock +306 -0
  148. package/cli/index.ts +96 -0
  149. package/cli/package-lock.json +2157 -0
  150. package/cli/package.json +30 -0
  151. package/cli/src/commands/backup.ts +78 -0
  152. package/cli/src/commands/doctor.ts +82 -0
  153. package/cli/src/commands/init.ts +234 -0
  154. package/cli/src/commands/logs.ts +26 -0
  155. package/cli/src/commands/open.ts +23 -0
  156. package/cli/src/commands/remove.ts +44 -0
  157. package/cli/src/commands/restart.ts +21 -0
  158. package/cli/src/commands/restore.ts +90 -0
  159. package/cli/src/commands/start.ts +26 -0
  160. package/cli/src/commands/status.ts +25 -0
  161. package/cli/src/commands/stop.ts +20 -0
  162. package/cli/src/commands/upgrade.ts +28 -0
  163. package/cli/src/lib/docker.ts +40 -0
  164. package/cli/src/lib/env.ts +42 -0
  165. package/cli/src/lib/ui.ts +43 -0
  166. package/cli/tsconfig.json +13 -0
  167. package/cli/tsup.config.ts +12 -0
  168. package/components.json +24 -0
  169. package/docker/README.md +430 -0
  170. package/docker/compose.dev-minio.yml +30 -0
  171. package/docker/compose.dev.yml +39 -0
  172. package/docker/compose.local.yml +84 -0
  173. package/docker/compose.yml +153 -0
  174. package/docs/VERSIONING.md +101 -0
  175. package/docs/database/DRIZZLE_COMMANDS_EXPLAINED.md +1779 -0
  176. package/docs/database/DRIZZLE_ZOD_POSTGRESQL_INSTRUCTION.md +646 -0
  177. package/docs/database/MIGRATION_BEST_PRACTICES.md +601 -0
  178. package/docs/database/MIGRATION_ROLLBACK.md +1080 -0
  179. package/docs/database/MIGRATION_SYSTEM.md +165 -0
  180. package/docs/database/MIGRATION_TROUBLESHOOTING.md +881 -0
  181. package/docs/development/ENVIRONMENT_CONFIG.md +896 -0
  182. package/docs/development/LOCAL_DEVELOPMENT.md +456 -0
  183. package/docs/development/REMOTE_DATABASE_SETUP.md +786 -0
  184. package/docs/development/STORAGE_SETUP.md +207 -0
  185. package/docs/development/SUPABASE_LOCAL_SETUP.md +178 -0
  186. package/docs/development/TESTING.md +714 -0
  187. package/docs/feature-architectures/LOADING_ARCHITECTURE.md +343 -0
  188. package/docs/feature-architectures/NOTIFICATION_ARCHITECTURE.md +858 -0
  189. package/docs/feature-architectures/RATE_LIMIT_RESET.md +147 -0
  190. package/docs/feature-architectures/RBAC.md +1132 -0
  191. package/docs/feature-architectures/RESOURCE_LIMITS.md +69 -0
  192. package/docs/feature-architectures/SECURITY.md +284 -0
  193. package/docs/feature-architectures/WORKSPACES.md +278 -0
  194. package/docs/plans/admin-setup-wizard-routing-plan.md +623 -0
  195. package/drizzle/0000_purple_wilson_fisk.sql +360 -0
  196. package/drizzle/0001_drop_instance_public_url.sql +1 -0
  197. package/drizzle/meta/0000_snapshot.json +3118 -0
  198. package/drizzle/meta/_journal.json +20 -0
  199. package/drizzle.config.ts +13 -0
  200. package/eslint.config.mjs +44 -0
  201. package/install.sh +180 -0
  202. package/next.config.ts +91 -0
  203. package/package.json +128 -22
  204. package/playwright.config.ts +70 -0
  205. package/postcss.config.mjs +7 -0
  206. package/public/file.svg +1 -0
  207. package/public/globe.svg +1 -0
  208. package/public/logo.svg +11 -0
  209. package/public/next.svg +1 -0
  210. package/public/playground/CPM-101/as-is-image.jpg +0 -0
  211. package/public/playground/CPM-101/to-be-image.jpg +0 -0
  212. package/public/playground/TEST-1/LinkedIn-skeleton-screen.png +0 -0
  213. package/public/playground/TEST-1/https___dev-to-uploads.s3.amazonaws.com_uploads_articles_vuahe90ka1mkx9aepmea.webp +0 -0
  214. package/public/playground/TEST-1/linkedin_skeletonscreen.jpg +0 -0
  215. package/public/vercel.svg +1 -0
  216. package/public/window.svg +1 -0
  217. package/scripts/__tests__/migrate.integration.test.ts +642 -0
  218. package/scripts/__tests__/migrate.property.test.ts +1714 -0
  219. package/scripts/__tests__/migrate.test.ts +536 -0
  220. package/scripts/admin-reset-password.ts +114 -0
  221. package/scripts/check-email-queue.ts +99 -0
  222. package/scripts/check-sessions.ts +50 -0
  223. package/scripts/db-pull-data.sh +73 -0
  224. package/scripts/force-verify-email.sh +13 -0
  225. package/scripts/migrate.ts +693 -0
  226. package/scripts/process-email-queue.ts +26 -0
  227. package/scripts/reset-db.ts +47 -0
  228. package/scripts/reset-rate-limit.sh +26 -0
  229. package/scripts/reset-remote-db.sql +31 -0
  230. package/scripts/retry-failed-emails.ts +67 -0
  231. package/scripts/seed.ts +605 -0
  232. package/scripts/setup-monitoring.sh +440 -0
  233. package/scripts/sync-migration-tracking.ts +113 -0
  234. package/scripts/test-ci-error-handling.sh +237 -0
  235. package/scripts/test-ci-workflow.sh +200 -0
  236. package/scripts/test-migration.sh +151 -0
  237. package/scripts/validate-env.ts +25 -0
  238. package/scripts/validate-migration-system.ts +566 -0
  239. package/scripts/verify-ci-status-reporting.sh +206 -0
  240. package/scripts/verify-user-email.sql +22 -0
  241. package/scripts/verify-vercel-integration.ts +292 -0
  242. package/seed_data.md +54 -0
  243. package/src/app/(protected)/(team)/(routes)/[projectSlug]/error.tsx +89 -0
  244. package/src/app/(protected)/(team)/(routes)/[projectSlug]/loading.tsx +101 -0
  245. package/src/app/(protected)/(team)/(routes)/[projectSlug]/page.tsx +91 -0
  246. package/src/app/(protected)/(team)/(routes)/issue/[issueKey]/README.md +192 -0
  247. package/src/app/(protected)/(team)/(routes)/issue/[issueKey]/error.tsx +58 -0
  248. package/src/app/(protected)/(team)/(routes)/issue/[issueKey]/loading.tsx +14 -0
  249. package/src/app/(protected)/(team)/(routes)/issue/[issueKey]/not-found.tsx +47 -0
  250. package/src/app/(protected)/(team)/(routes)/issue/[issueKey]/page.tsx +91 -0
  251. package/src/app/(protected)/(team)/projects/page.tsx +16 -0
  252. package/src/app/(protected)/(team)/team/settings/(section)/instance/page.tsx +52 -0
  253. package/src/app/(protected)/(team)/team/settings/(section)/integrations/loading.tsx +5 -0
  254. package/src/app/(protected)/(team)/team/settings/(section)/integrations/page.tsx +23 -0
  255. package/src/app/(protected)/(team)/team/settings/(section)/members/loading.tsx +5 -0
  256. package/src/app/(protected)/(team)/team/settings/(section)/members/page.tsx +35 -0
  257. package/src/app/(protected)/(team)/team/settings/layout.tsx +72 -0
  258. package/src/app/(protected)/(team)/team/settings/loading.tsx +5 -0
  259. package/src/app/(protected)/(team)/team/settings/page.tsx +71 -0
  260. package/src/app/(protected)/dev/auth/README.md +151 -0
  261. package/src/app/(protected)/dev/auth/page.tsx +590 -0
  262. package/src/app/(protected)/layout.test.tsx +209 -0
  263. package/src/app/(protected)/layout.tsx +28 -0
  264. package/src/app/(protected)/onboarding/page.tsx +27 -0
  265. package/src/app/(protected)/settings/integrations/page.tsx +23 -0
  266. package/src/app/(protected)/settings/layout.tsx +26 -0
  267. package/src/app/(protected)/settings/notifications/page.tsx +26 -0
  268. package/src/app/(protected)/settings/other/page.tsx +23 -0
  269. package/src/app/(protected)/settings/page.tsx +23 -0
  270. package/src/app/(protected)/settings/preferences/page.tsx +23 -0
  271. package/src/app/(protected)/settings/security/page.tsx +37 -0
  272. package/src/app/(public)/forgot-password/page.tsx +20 -0
  273. package/src/app/(public)/invite/project/[token]/error.tsx +50 -0
  274. package/src/app/(public)/invite/project/[token]/loading.tsx +39 -0
  275. package/src/app/(public)/invite/project/[token]/page.tsx +156 -0
  276. package/src/app/(public)/layout.tsx +9 -0
  277. package/src/app/(public)/privacy-policy/page.tsx +12 -0
  278. package/src/app/(public)/reset-password/page.tsx +37 -0
  279. package/src/app/(public)/setup/__tests__/page.test.tsx +30 -0
  280. package/src/app/(public)/setup/page.tsx +17 -0
  281. package/src/app/(public)/share/issue/[token]/page.tsx +51 -0
  282. package/src/app/(public)/sign-in/page.tsx +55 -0
  283. package/src/app/(public)/sign-up/page.tsx +23 -0
  284. package/src/app/(public)/verify-email/page.tsx +22 -0
  285. package/src/app/(public)/verify-email-confirm/page.tsx +40 -0
  286. package/src/app/api/auth/[...all]/route.ts +6 -0
  287. package/src/app/api/auth/delete-account/route.ts +134 -0
  288. package/src/app/api/auth/dev/force-verify/route.ts +180 -0
  289. package/src/app/api/auth/dev/reset-rate-limit/route.ts +144 -0
  290. package/src/app/api/auth/dev/sessions/route.ts +172 -0
  291. package/src/app/api/auth/forgot-password/__tests__/forgot-password.property.test.ts +397 -0
  292. package/src/app/api/auth/forgot-password/route.ts +277 -0
  293. package/src/app/api/auth/logout/route.ts +115 -0
  294. package/src/app/api/auth/me/route.ts +123 -0
  295. package/src/app/api/auth/providers/__tests__/route.test.ts +236 -0
  296. package/src/app/api/auth/providers/route.ts +119 -0
  297. package/src/app/api/auth/resend-verification/route.ts +262 -0
  298. package/src/app/api/auth/reset-password/__tests__/reset-password.property.test.ts +493 -0
  299. package/src/app/api/auth/reset-password/__tests__/route.test.ts +284 -0
  300. package/src/app/api/auth/reset-password/route.ts +251 -0
  301. package/src/app/api/auth/verify-email/route.ts +232 -0
  302. package/src/app/api/example-cors/route.ts +61 -0
  303. package/src/app/api/health/route.ts +14 -0
  304. package/src/app/api/invite/project/[token]/__tests__/accept-invitation.integration.test.ts +348 -0
  305. package/src/app/api/invite/project/[token]/decline/route.ts +99 -0
  306. package/src/app/api/invite/project/[token]/route.ts +269 -0
  307. package/src/app/api/issues/[issueId]/activities/route.ts +213 -0
  308. package/src/app/api/issues/[issueId]/attachments/[attachmentId]/annotations/[annotationId]/comments/[commentId]/route.ts +486 -0
  309. package/src/app/api/issues/[issueId]/attachments/[attachmentId]/annotations/[annotationId]/comments/route.ts +283 -0
  310. package/src/app/api/issues/[issueId]/attachments/[attachmentId]/annotations/[annotationId]/read/route.ts +242 -0
  311. package/src/app/api/issues/[issueId]/attachments/[attachmentId]/annotations/[annotationId]/route.ts +534 -0
  312. package/src/app/api/issues/[issueId]/attachments/[attachmentId]/annotations/route.ts +514 -0
  313. package/src/app/api/issues/[issueId]/attachments/[attachmentId]/route.ts +161 -0
  314. package/src/app/api/issues/[issueId]/attachments/route.ts +376 -0
  315. package/src/app/api/issues/[issueId]/route.ts +516 -0
  316. package/src/app/api/notifications/[id]/read/route.ts +131 -0
  317. package/src/app/api/notifications/__tests__/notifications.integration.test.ts +350 -0
  318. package/src/app/api/notifications/read-all/route.ts +72 -0
  319. package/src/app/api/notifications/route.ts +148 -0
  320. package/src/app/api/notifications/unread-count/route.ts +77 -0
  321. package/src/app/api/projects/[id]/activities/route.ts +174 -0
  322. package/src/app/api/projects/[id]/invitations/[invitationId]/resend/route.ts +99 -0
  323. package/src/app/api/projects/[id]/invitations/[invitationId]/route.ts +96 -0
  324. package/src/app/api/projects/[id]/invitations/route.ts +254 -0
  325. package/src/app/api/projects/[id]/issues/route.ts +452 -0
  326. package/src/app/api/projects/[id]/join/route.ts +207 -0
  327. package/src/app/api/projects/[id]/members/[memberId]/route.ts +364 -0
  328. package/src/app/api/projects/[id]/members/me/route.ts +121 -0
  329. package/src/app/api/projects/[id]/members/route.ts +129 -0
  330. package/src/app/api/projects/[id]/route.ts +476 -0
  331. package/src/app/api/projects/route.ts +394 -0
  332. package/src/app/api/setup/admin/route.ts +255 -0
  333. package/src/app/api/setup/complete/__tests__/route.test.ts +60 -0
  334. package/src/app/api/setup/complete/route.ts +244 -0
  335. package/src/app/api/setup/config/route.ts +195 -0
  336. package/src/app/api/setup/export/route.ts +111 -0
  337. package/src/app/api/setup/health/route.ts +74 -0
  338. package/src/app/api/setup/import/route.ts +154 -0
  339. package/src/app/api/setup/status/route.ts +82 -0
  340. package/src/app/api/setup/workspace/route.ts +252 -0
  341. package/src/app/api/teams/[teamId]/export/route.ts +115 -0
  342. package/src/app/api/teams/[teamId]/invitations/[invitationId]/resend/route.ts +132 -0
  343. package/src/app/api/teams/[teamId]/invitations/[invitationId]/route.ts +117 -0
  344. package/src/app/api/teams/[teamId]/invitations/route.ts +363 -0
  345. package/src/app/api/teams/[teamId]/members/[userId]/route.ts +335 -0
  346. package/src/app/api/teams/[teamId]/members/route.ts +184 -0
  347. package/src/app/api/teams/[teamId]/members/search/route.ts +202 -0
  348. package/src/app/api/teams/[teamId]/route.ts +423 -0
  349. package/src/app/api/teams/[teamId]/switch/route.ts +140 -0
  350. package/src/app/api/teams/[teamId]/transfer-ownership/route.ts +212 -0
  351. package/src/app/api/teams/invitations/[token]/accept/route.ts +140 -0
  352. package/src/app/api/teams/invitations/by-id/[id]/accept/route.ts +98 -0
  353. package/src/app/api/teams/invitations/by-id/[id]/decline/route.ts +90 -0
  354. package/src/app/api/teams/route.ts +278 -0
  355. package/src/app/api/uploads/media/route.ts +118 -0
  356. package/src/app/api/uploads/presigned/route.ts +49 -0
  357. package/src/app/api/user/linked-accounts/route.ts +35 -0
  358. package/src/app/email-preview/page.tsx +11 -0
  359. package/src/app/favicon.ico +0 -0
  360. package/src/app/global-error.tsx +21 -0
  361. package/src/app/layout.tsx +50 -0
  362. package/src/app/page.tsx +5 -0
  363. package/src/components/icons/atlassian-icon.tsx +22 -0
  364. package/src/components/icons/index.ts +1 -0
  365. package/src/components/layout/SIDEBAR_LAYOUT_BEST_PRACTICES.md +240 -0
  366. package/src/components/layout/app-shell-header-store.tsx +20 -0
  367. package/src/components/layout/app-shell-skeleton.tsx +89 -0
  368. package/src/components/layout/app-shell-wrapper.tsx +32 -0
  369. package/src/components/layout/app-shell.test.tsx +155 -0
  370. package/src/components/layout/app-shell.tsx +100 -0
  371. package/src/components/shared/headers/app-header-configurator.tsx +42 -0
  372. package/src/components/shared/headers/app-header.tsx +103 -0
  373. package/src/components/shared/headers/header-user-menu.tsx +247 -0
  374. package/src/components/shared/headers/index.ts +44 -0
  375. package/src/components/shared/headers/page-header.tsx +25 -0
  376. package/src/components/shared/notifications/__tests__/notification-bell.test.tsx +159 -0
  377. package/src/components/shared/notifications/__tests__/notification-dropdown.test.tsx +296 -0
  378. package/src/components/shared/notifications/__tests__/notification-item.test.tsx +328 -0
  379. package/src/components/shared/notifications/index.ts +45 -0
  380. package/src/components/shared/notifications/notification-actions.tsx +295 -0
  381. package/src/components/shared/notifications/notification-bell-button.tsx +77 -0
  382. package/src/components/shared/notifications/notification-dropdown.tsx +160 -0
  383. package/src/components/shared/notifications/notification-group-item.tsx +268 -0
  384. package/src/components/shared/notifications/notification-item.tsx +193 -0
  385. package/src/components/shared/notifications/notification-load-more.tsx +50 -0
  386. package/src/components/shared/notifications/notification-panel.tsx +49 -0
  387. package/src/components/shared/notifications/utils.tsx +127 -0
  388. package/src/components/shared/permission-guard/index.ts +1 -0
  389. package/src/components/shared/permission-guard/permission-tooltip.tsx +45 -0
  390. package/src/components/shared/relative-time.tsx +53 -0
  391. package/src/components/shared/section-container.tsx +32 -0
  392. package/src/components/shared/service-status-banner.tsx +121 -0
  393. package/src/components/shared/settings-sidebar/index.ts +2 -0
  394. package/src/components/shared/settings-sidebar/team-setting-aside.tsx +97 -0
  395. package/src/components/shared/settings-sidebar/user-settings-aside.tsx +66 -0
  396. package/src/components/shared/sidebar/app-sidebar.tsx +146 -0
  397. package/src/components/shared/sidebar/index.ts +36 -0
  398. package/src/components/shared/sidebar/sidebar-main.tsx +81 -0
  399. package/src/components/shared/sidebar/sidebar-project.tsx +61 -0
  400. package/src/components/shared/sidebar/sidebar-team-avatar.tsx +126 -0
  401. package/src/components/shared/sidebar/sidebar-team-switcher.tsx +185 -0
  402. package/src/components/shared/sidebar/type.ts +97 -0
  403. package/src/components/ui/alert-dialog.tsx +157 -0
  404. package/src/components/ui/alert.tsx +66 -0
  405. package/src/components/ui/avatar-upload.tsx +147 -0
  406. package/src/components/ui/avatar.tsx +53 -0
  407. package/src/components/ui/badge.tsx +46 -0
  408. package/src/components/ui/breadcrumb.tsx +109 -0
  409. package/src/components/ui/button.tsx +60 -0
  410. package/src/components/ui/card.tsx +92 -0
  411. package/src/components/ui/checkbox.tsx +32 -0
  412. package/src/components/ui/collapsible.tsx +33 -0
  413. package/src/components/ui/command.tsx +184 -0
  414. package/src/components/ui/dialog.tsx +143 -0
  415. package/src/components/ui/dropdown-menu.tsx +257 -0
  416. package/src/components/ui/empty.tsx +104 -0
  417. package/src/components/ui/field.tsx +244 -0
  418. package/src/components/ui/image-cropper-dialog.tsx +167 -0
  419. package/src/components/ui/input.tsx +21 -0
  420. package/src/components/ui/label.tsx +24 -0
  421. package/src/components/ui/optimized-image.tsx +220 -0
  422. package/src/components/ui/pagination.tsx +127 -0
  423. package/src/components/ui/popover.tsx +48 -0
  424. package/src/components/ui/progress.tsx +31 -0
  425. package/src/components/ui/radio-group.tsx +45 -0
  426. package/src/components/ui/scroll-area.tsx +58 -0
  427. package/src/components/ui/select.tsx +187 -0
  428. package/src/components/ui/separator.tsx +28 -0
  429. package/src/components/ui/sheet.tsx +139 -0
  430. package/src/components/ui/sidebar.tsx +733 -0
  431. package/src/components/ui/skeleton.tsx +13 -0
  432. package/src/components/ui/sonner.tsx +40 -0
  433. package/src/components/ui/spinner.tsx +16 -0
  434. package/src/components/ui/switch.tsx +31 -0
  435. package/src/components/ui/table.tsx +116 -0
  436. package/src/components/ui/tabs.tsx +66 -0
  437. package/src/components/ui/textarea.tsx +23 -0
  438. package/src/components/ui/tooltip.tsx +61 -0
  439. package/src/config/__tests__/workspace.property.test.ts +40 -0
  440. package/src/config/auth.ts +62 -0
  441. package/src/config/integrations.ts +126 -0
  442. package/src/config/quotas.ts +20 -0
  443. package/src/config/roles.ts +463 -0
  444. package/src/config/settings-nav.ts +39 -0
  445. package/src/config/team-settings-nav.ts +37 -0
  446. package/src/config/user-settings-nav.ts +42 -0
  447. package/src/config/version.ts +1 -0
  448. package/src/config/workspace.ts +64 -0
  449. package/src/features/annotations/README.md +283 -0
  450. package/src/features/annotations/api/annotations-api.ts +194 -0
  451. package/src/features/annotations/api/comments-api.ts +147 -0
  452. package/src/features/annotations/api/index.ts +71 -0
  453. package/src/features/annotations/api/save-annotation.ts +150 -0
  454. package/src/features/annotations/api/schemas.ts +142 -0
  455. package/src/features/annotations/components/annotated-attachment-view.tsx +576 -0
  456. package/src/features/annotations/components/annotation-action-sheet.tsx +140 -0
  457. package/src/features/annotations/components/annotation-annotations-panel.tsx +213 -0
  458. package/src/features/annotations/components/annotation-box.tsx +539 -0
  459. package/src/features/annotations/components/annotation-canvas.tsx +534 -0
  460. package/src/features/annotations/components/annotation-comment-input.tsx +145 -0
  461. package/src/features/annotations/components/annotation-context-menu.tsx +164 -0
  462. package/src/features/annotations/components/annotation-drawer.tsx +231 -0
  463. package/src/features/annotations/components/annotation-layer.tsx +271 -0
  464. package/src/features/annotations/components/annotation-pin.tsx +318 -0
  465. package/src/features/annotations/components/annotation-popover.tsx +562 -0
  466. package/src/features/annotations/components/annotation-thread-panel.tsx +485 -0
  467. package/src/features/annotations/components/annotation-thread-preview.tsx +195 -0
  468. package/src/features/annotations/components/annotation-toolbar.tsx +244 -0
  469. package/src/features/annotations/components/keyboard-shortcuts-modal.tsx +79 -0
  470. package/src/features/annotations/docs/ANNOTATIONS_ARCHITECTURE.md +67 -0
  471. package/src/features/annotations/docs/ANNOTATION_SAVE_ARCHITECTURE.md +422 -0
  472. package/src/features/annotations/docs/ANNOTATION_SAVE_FEATURE.md +408 -0
  473. package/src/features/annotations/docs/BOX_ANNOTATION_GUIDE.md +542 -0
  474. package/src/features/annotations/docs/NEXTSTEP.md +28 -0
  475. package/src/features/annotations/docs/STALE_CLOSURE_FIX.md +344 -0
  476. package/src/features/annotations/docs/UNDO_REDO_QUICK_START.md +545 -0
  477. package/src/features/annotations/docs/local_first_canvas_autosave_architecture.md +674 -0
  478. package/src/features/annotations/examples/complete-example.tsx +266 -0
  479. package/src/features/annotations/examples/save-annotation-example.tsx +309 -0
  480. package/src/features/annotations/hooks/__tests__/use-annotation-permissions.property.test.tsx +493 -0
  481. package/src/features/annotations/hooks/index.ts +36 -0
  482. package/src/features/annotations/hooks/use-annotation-batch-save.ts +109 -0
  483. package/src/features/annotations/hooks/use-annotation-comments.ts +353 -0
  484. package/src/features/annotations/hooks/use-annotation-drafts.ts +137 -0
  485. package/src/features/annotations/hooks/use-annotation-edit-state.ts +99 -0
  486. package/src/features/annotations/hooks/use-annotation-history-tracker.ts +159 -0
  487. package/src/features/annotations/hooks/use-annotation-integration.ts +916 -0
  488. package/src/features/annotations/hooks/use-annotation-permissions.ts +210 -0
  489. package/src/features/annotations/hooks/use-annotation-popover.ts +175 -0
  490. package/src/features/annotations/hooks/use-annotation-save.ts +208 -0
  491. package/src/features/annotations/hooks/use-annotation-tools.ts +237 -0
  492. package/src/features/annotations/hooks/use-annotations-with-history.ts +332 -0
  493. package/src/features/annotations/hooks/use-auto-save.ts +94 -0
  494. package/src/features/annotations/index.ts +111 -0
  495. package/src/features/annotations/types/annotation.ts +201 -0
  496. package/src/features/annotations/types/index.ts +28 -0
  497. package/src/features/annotations/utils/history-manager.ts +73 -0
  498. package/src/features/annotations/utils/index.ts +2 -0
  499. package/src/features/annotations/utils/map-attachments-to-threads.ts +28 -0
  500. package/src/features/annotations/utils/position-comment-input.ts +136 -0
  501. package/src/features/annotations/utils/re-sequence-labels.ts +92 -0
  502. package/src/features/annotations/utils/validate-annotation-label.ts +120 -0
  503. package/src/features/auth/api/types.ts +101 -0
  504. package/src/features/auth/components/__tests__/role-gate.test.tsx +448 -0
  505. package/src/features/auth/components/__tests__/social-login-buttons.test.tsx +313 -0
  506. package/src/features/auth/components/auth-card.tsx +36 -0
  507. package/src/features/auth/components/forgot-password-form.tsx +115 -0
  508. package/src/features/auth/components/index.ts +14 -0
  509. package/src/features/auth/components/invite-code-input.tsx +155 -0
  510. package/src/features/auth/components/invited-user-form.tsx +309 -0
  511. package/src/features/auth/components/onboarding-form.tsx +195 -0
  512. package/src/features/auth/components/password-strength-indicator.tsx +113 -0
  513. package/src/features/auth/components/reset-password-form.tsx +138 -0
  514. package/src/features/auth/components/role-gate.tsx +124 -0
  515. package/src/features/auth/components/self-registration-choice.tsx +153 -0
  516. package/src/features/auth/components/sign-in-form.tsx +159 -0
  517. package/src/features/auth/components/sign-up-form.tsx +158 -0
  518. package/src/features/auth/components/social-login-buttons.tsx +219 -0
  519. package/src/features/auth/hooks/__tests__/use-onboarding.test.tsx +109 -0
  520. package/src/features/auth/hooks/__tests__/use-session.test.tsx +160 -0
  521. package/src/features/auth/hooks/index.ts +15 -0
  522. package/src/features/auth/hooks/use-accept-invitation.ts +194 -0
  523. package/src/features/auth/hooks/use-delete-account.ts +86 -0
  524. package/src/features/auth/hooks/use-force-verify.ts +89 -0
  525. package/src/features/auth/hooks/use-forgot-password.ts +144 -0
  526. package/src/features/auth/hooks/use-link-account.ts +78 -0
  527. package/src/features/auth/hooks/use-linked-accounts.ts +88 -0
  528. package/src/features/auth/hooks/use-onboarding.ts +159 -0
  529. package/src/features/auth/hooks/use-resend-verification.ts +139 -0
  530. package/src/features/auth/hooks/use-reset-password.ts +151 -0
  531. package/src/features/auth/hooks/use-reset-rate-limit.ts +56 -0
  532. package/src/features/auth/hooks/use-self-registration.ts +202 -0
  533. package/src/features/auth/hooks/use-session.ts +81 -0
  534. package/src/features/auth/hooks/use-sessions.ts +59 -0
  535. package/src/features/auth/hooks/use-sign-in.ts +234 -0
  536. package/src/features/auth/hooks/use-sign-out.ts +88 -0
  537. package/src/features/auth/hooks/use-sign-up.ts +194 -0
  538. package/src/features/auth/hooks/use-unlink-account.ts +100 -0
  539. package/src/features/auth/hooks/use-verify-email-token.ts +125 -0
  540. package/src/features/auth/index.ts +75 -0
  541. package/src/features/auth/screens/forgot-password-screen.tsx +33 -0
  542. package/src/features/auth/screens/index.ts +7 -0
  543. package/src/features/auth/screens/onboarding-screen.tsx +49 -0
  544. package/src/features/auth/screens/reset-password-screen.tsx +33 -0
  545. package/src/features/auth/screens/sign-in-screen.tsx +61 -0
  546. package/src/features/auth/screens/sign-up-screen.tsx +37 -0
  547. package/src/features/auth/screens/verify-email-confirm-screen.tsx +286 -0
  548. package/src/features/auth/screens/verify-email-screen.tsx +146 -0
  549. package/src/features/auth/types/index.ts +14 -0
  550. package/src/features/auth/utils/__tests__/validators.test.ts +331 -0
  551. package/src/features/auth/utils/password-strength.ts +129 -0
  552. package/src/features/auth/utils/validators.ts +124 -0
  553. package/src/features/email-preview/actions/render-email.ts +21 -0
  554. package/src/features/email-preview/screens/email-preview-screen.tsx +81 -0
  555. package/src/features/folder-scaffold-template/index.ts +0 -0
  556. package/src/features/instance-settings/components/index.ts +6 -0
  557. package/src/features/instance-settings/components/instance-settings-form.tsx +180 -0
  558. package/src/features/instance-settings/components/instance-status-display.tsx +158 -0
  559. package/src/features/instance-settings/index.ts +7 -0
  560. package/src/features/instance-settings/screens/index.ts +5 -0
  561. package/src/features/instance-settings/screens/instance-settings-screen.tsx +59 -0
  562. package/src/features/issues/README.md +330 -0
  563. package/src/features/issues/api/create-issue.ts +19 -0
  564. package/src/features/issues/api/delete-issue.ts +27 -0
  565. package/src/features/issues/api/get-issue-activities.ts +58 -0
  566. package/src/features/issues/api/get-issue-details.ts +25 -0
  567. package/src/features/issues/api/get-project-issues-server.ts +44 -0
  568. package/src/features/issues/api/get-project-issues.ts +21 -0
  569. package/src/features/issues/api/index.ts +44 -0
  570. package/src/features/issues/api/update-issue.ts +31 -0
  571. package/src/features/issues/api/upload-attachment.ts +81 -0
  572. package/src/features/issues/components/activity-timeline.tsx +440 -0
  573. package/src/features/issues/components/canvas-state-indicator.tsx +90 -0
  574. package/src/features/issues/components/centered-canvas-view.tsx +739 -0
  575. package/src/features/issues/components/image-selector.tsx +123 -0
  576. package/src/features/issues/components/image-upload-zone.tsx +262 -0
  577. package/src/features/issues/components/infinite-canvas-background.tsx +163 -0
  578. package/src/features/issues/components/inline-editable-select.tsx +173 -0
  579. package/src/features/issues/components/inline-editable-text.tsx +225 -0
  580. package/src/features/issues/components/inline-editable-textarea.tsx +219 -0
  581. package/src/features/issues/components/inline-editable-user-select.tsx +202 -0
  582. package/src/features/issues/components/issue-deletion-dialog.tsx +142 -0
  583. package/src/features/issues/components/issue-details-panel.tsx +101 -0
  584. package/src/features/issues/components/issues-create-dialog.tsx +578 -0
  585. package/src/features/issues/components/issues-list-filter.tsx +312 -0
  586. package/src/features/issues/components/issues-list.tsx +151 -0
  587. package/src/features/issues/components/issues-priority-badge.tsx +77 -0
  588. package/src/features/issues/components/issues-status-badge.tsx +100 -0
  589. package/src/features/issues/components/metadata-section.tsx +389 -0
  590. package/src/features/issues/components/optimized-attachment-view.tsx +528 -0
  591. package/src/features/issues/components/optimized-image.tsx +257 -0
  592. package/src/features/issues/components/panel-header.tsx +186 -0
  593. package/src/features/issues/components/preload.ts +31 -0
  594. package/src/features/issues/components/priority-selector.tsx +101 -0
  595. package/src/features/issues/components/responsive-issue-layout-skeleton.tsx +139 -0
  596. package/src/features/issues/components/responsive-issue-layout.tsx +617 -0
  597. package/src/features/issues/components/status-selector.tsx +320 -0
  598. package/src/features/issues/components/type-selector.tsx +102 -0
  599. package/src/features/issues/components/upload-progress-overlay.tsx +35 -0
  600. package/src/features/issues/components/uploaded-image-preview.tsx +173 -0
  601. package/src/features/issues/components/workflow-control.tsx +318 -0
  602. package/src/features/issues/components/zoom-controls.tsx +150 -0
  603. package/src/features/issues/config/index.ts +47 -0
  604. package/src/features/issues/config/options.ts +323 -0
  605. package/src/features/issues/config/workflow.ts +102 -0
  606. package/src/features/issues/docs/ARCHITECTURE_DIAGRAM.md +321 -0
  607. package/src/features/issues/docs/BACKEND_ARCHITECTURE.md +194 -0
  608. package/src/features/issues/docs/IMAGE_COMPONENTS_ARCHITECTURE.md +363 -0
  609. package/src/features/issues/docs/IMAGE_COMPONENTS_IMPORTS.md +412 -0
  610. package/src/features/issues/docs/IMPLEMENTATION_CHECKLIST.md +210 -0
  611. package/src/features/issues/docs/ROUTE_SETUP_COMPLETE.md +242 -0
  612. package/src/features/issues/hooks/index.ts +78 -0
  613. package/src/features/issues/hooks/use-canvas-transform.ts +255 -0
  614. package/src/features/issues/hooks/use-create-issue.ts +28 -0
  615. package/src/features/issues/hooks/use-elastic-scroll.ts +296 -0
  616. package/src/features/issues/hooks/use-issue-activities.ts +71 -0
  617. package/src/features/issues/hooks/use-issue-delete.ts +84 -0
  618. package/src/features/issues/hooks/use-issue-details.ts +70 -0
  619. package/src/features/issues/hooks/use-issue-filters.ts +50 -0
  620. package/src/features/issues/hooks/use-issue-update.ts +93 -0
  621. package/src/features/issues/hooks/use-keyboard-shortcuts.ts +104 -0
  622. package/src/features/issues/hooks/use-optimized-image.ts +228 -0
  623. package/src/features/issues/hooks/use-project-issues.ts +14 -0
  624. package/src/features/issues/index.ts +65 -0
  625. package/src/features/issues/screens/issue-details-screen.tsx +207 -0
  626. package/src/features/issues/screens/issue-details-skeletons.tsx +295 -0
  627. package/src/features/issues/screens/issue-share-screen.tsx +56 -0
  628. package/src/features/issues/types/index.ts +48 -0
  629. package/src/features/issues/types/issue.ts +291 -0
  630. package/src/features/issues/utils/filter-issues.ts +141 -0
  631. package/src/features/issues/utils/index.ts +14 -0
  632. package/src/features/legal/index.ts +1 -0
  633. package/src/features/legal/screens/privacy-policy-screen.tsx +307 -0
  634. package/src/features/notifications/api/get-notifications.ts +58 -0
  635. package/src/features/notifications/api/get-unread-count.ts +37 -0
  636. package/src/features/notifications/api/index.ts +35 -0
  637. package/src/features/notifications/api/mark-all-as-read.ts +37 -0
  638. package/src/features/notifications/api/mark-as-read.ts +41 -0
  639. package/src/features/notifications/api/types.ts +109 -0
  640. package/src/features/notifications/hooks/__tests__/use-notification-subscription.test.ts +206 -0
  641. package/src/features/notifications/hooks/index.ts +28 -0
  642. package/src/features/notifications/hooks/use-mark-all-as-read.ts +106 -0
  643. package/src/features/notifications/hooks/use-mark-as-read.ts +106 -0
  644. package/src/features/notifications/hooks/use-notification-subscription.ts +244 -0
  645. package/src/features/notifications/hooks/use-notification-toast.ts +161 -0
  646. package/src/features/notifications/hooks/use-notifications.ts +80 -0
  647. package/src/features/notifications/hooks/use-unread-count.ts +60 -0
  648. package/src/features/notifications/index.ts +48 -0
  649. package/src/features/notifications/utils/group-notifications.ts +152 -0
  650. package/src/features/notifications/utils/index.ts +9 -0
  651. package/src/features/projects/api/create-invitation.ts +45 -0
  652. package/src/features/projects/api/create-project.ts +64 -0
  653. package/src/features/projects/api/delete-project.ts +50 -0
  654. package/src/features/projects/api/get-project-activities.ts +43 -0
  655. package/src/features/projects/api/get-project-members.ts +53 -0
  656. package/src/features/projects/api/get-project.ts +49 -0
  657. package/src/features/projects/api/get-projects.ts +61 -0
  658. package/src/features/projects/api/index.ts +27 -0
  659. package/src/features/projects/api/join-project.ts +52 -0
  660. package/src/features/projects/api/leave-project.ts +51 -0
  661. package/src/features/projects/api/list-invitations.ts +36 -0
  662. package/src/features/projects/api/remove-member.ts +60 -0
  663. package/src/features/projects/api/resend-invitation.ts +36 -0
  664. package/src/features/projects/api/revoke-invitation.ts +36 -0
  665. package/src/features/projects/api/types.ts +286 -0
  666. package/src/features/projects/api/update-member-role.ts +70 -0
  667. package/src/features/projects/api/update-project.ts +69 -0
  668. package/src/features/projects/components/__tests__/project-detail-activity-feed.test.tsx +106 -0
  669. package/src/features/projects/components/__tests__/project-invitation-dialog.test.tsx +211 -0
  670. package/src/features/projects/components/__tests__/project-member-manager-dialog.test.tsx +254 -0
  671. package/src/features/projects/components/index.ts +21 -0
  672. package/src/features/projects/components/project-actions.tsx +248 -0
  673. package/src/features/projects/components/project-create-dialog.tsx +410 -0
  674. package/src/features/projects/components/project-detail-activity-feed.tsx +206 -0
  675. package/src/features/projects/components/project-detail-header.tsx +103 -0
  676. package/src/features/projects/components/project-detail-overview.tsx +128 -0
  677. package/src/features/projects/components/project-icon-selector.test.tsx +49 -0
  678. package/src/features/projects/components/project-icon-selector.tsx +76 -0
  679. package/src/features/projects/components/project-invitation-dialog.tsx +368 -0
  680. package/src/features/projects/components/project-issues.tsx +128 -0
  681. package/src/features/projects/components/project-leave-button.tsx +69 -0
  682. package/src/features/projects/components/project-list-card.tsx +246 -0
  683. package/src/features/projects/components/project-list-filters.tsx +320 -0
  684. package/src/features/projects/components/project-member-manager-dialog.tsx +419 -0
  685. package/src/features/projects/components/project-settings-dialog.tsx +204 -0
  686. package/src/features/projects/components/project-stats.tsx +46 -0
  687. package/src/features/projects/components/project-title-section.tsx +78 -0
  688. package/src/features/projects/config/icons.ts +91 -0
  689. package/src/features/projects/hooks/index.ts +28 -0
  690. package/src/features/projects/hooks/use-create-invitation.ts +83 -0
  691. package/src/features/projects/hooks/use-create-project.ts +77 -0
  692. package/src/features/projects/hooks/use-delete-project.ts +84 -0
  693. package/src/features/projects/hooks/use-join-project.ts +43 -0
  694. package/src/features/projects/hooks/use-leave-project.ts +84 -0
  695. package/src/features/projects/hooks/use-project-activities.ts +39 -0
  696. package/src/features/projects/hooks/use-project-filters.ts +86 -0
  697. package/src/features/projects/hooks/use-project-invitations.ts +66 -0
  698. package/src/features/projects/hooks/use-project-members.ts +57 -0
  699. package/src/features/projects/hooks/use-project.ts +67 -0
  700. package/src/features/projects/hooks/use-projects.ts +49 -0
  701. package/src/features/projects/hooks/use-recent-projects.ts +58 -0
  702. package/src/features/projects/hooks/use-remove-member.ts +89 -0
  703. package/src/features/projects/hooks/use-resend-invitation.ts +68 -0
  704. package/src/features/projects/hooks/use-revoke-invitation.ts +71 -0
  705. package/src/features/projects/hooks/use-team-member-suggestions.ts +133 -0
  706. package/src/features/projects/hooks/use-update-member-role.ts +92 -0
  707. package/src/features/projects/hooks/use-update-project.ts +88 -0
  708. package/src/features/projects/index.ts +91 -0
  709. package/src/features/projects/screens/index.ts +3 -0
  710. package/src/features/projects/screens/invitation-acceptance-screen.tsx +320 -0
  711. package/src/features/projects/screens/project-detail-screen-wrapper.tsx +47 -0
  712. package/src/features/projects/screens/project-detail-screen.tsx +661 -0
  713. package/src/features/projects/screens/projects-list-screen.tsx +161 -0
  714. package/src/features/projects/types/index.ts +59 -0
  715. package/src/features/projects/utils/format-helpers.ts +16 -0
  716. package/src/features/projects/utils/index.ts +2 -0
  717. package/src/features/projects/utils/role-helpers.ts +25 -0
  718. package/src/features/setup/api/complete-setup.ts +21 -0
  719. package/src/features/setup/api/create-admin.ts +21 -0
  720. package/src/features/setup/api/create-first-workspace.ts +21 -0
  721. package/src/features/setup/api/get-instance-status.ts +12 -0
  722. package/src/features/setup/api/get-service-health.ts +12 -0
  723. package/src/features/setup/api/index.ts +44 -0
  724. package/src/features/setup/api/save-instance-config.ts +21 -0
  725. package/src/features/setup/api/types.ts +122 -0
  726. package/src/features/setup/components/__tests__/setup-wizard-ui.test.tsx +362 -0
  727. package/src/features/setup/components/admin-account-step.tsx +205 -0
  728. package/src/features/setup/components/first-workspace-step.tsx +120 -0
  729. package/src/features/setup/components/index.ts +9 -0
  730. package/src/features/setup/components/instance-config-step.tsx +107 -0
  731. package/src/features/setup/components/mail-config-step.tsx +205 -0
  732. package/src/features/setup/components/sample-data-step.tsx +131 -0
  733. package/src/features/setup/components/service-health-step.tsx +180 -0
  734. package/src/features/setup/components/service-status-badge.tsx +50 -0
  735. package/src/features/setup/components/setup-progress.tsx +103 -0
  736. package/src/features/setup/components/setup-wizard.tsx +169 -0
  737. package/src/features/setup/hooks/index.ts +12 -0
  738. package/src/features/setup/hooks/use-complete-setup.ts +23 -0
  739. package/src/features/setup/hooks/use-create-admin.ts +25 -0
  740. package/src/features/setup/hooks/use-create-first-workspace.ts +24 -0
  741. package/src/features/setup/hooks/use-instance-status.ts +21 -0
  742. package/src/features/setup/hooks/use-save-instance-config.ts +23 -0
  743. package/src/features/setup/hooks/use-service-health.ts +21 -0
  744. package/src/features/setup/hooks/use-setup-wizard.ts +152 -0
  745. package/src/features/setup/hooks/use-workspace-mode.ts +19 -0
  746. package/src/features/setup/index.ts +30 -0
  747. package/src/features/setup/screens/index.ts +1 -0
  748. package/src/features/setup/screens/setup-screen.tsx +40 -0
  749. package/src/features/setup/types/index.ts +69 -0
  750. package/src/features/setup/utils/index.ts +78 -0
  751. package/src/features/team-settings/components/index.ts +39 -0
  752. package/src/features/team-settings/components/loading-states.tsx +296 -0
  753. package/src/features/team-settings/components/permission-guard.tsx +23 -0
  754. package/src/features/team-settings/components/settings-card.tsx +22 -0
  755. package/src/features/team-settings/components/settings-context-provider.tsx +51 -0
  756. package/src/features/team-settings/components/settings-error-boundary.tsx +366 -0
  757. package/src/features/team-settings/components/settings-navigation.tsx +87 -0
  758. package/src/features/team-settings/components/settings-section.tsx +23 -0
  759. package/src/features/team-settings/components/team-danger-zone.tsx +275 -0
  760. package/src/features/team-settings/components/team-information-form.tsx +116 -0
  761. package/src/features/team-settings/components/team-invitations-list.tsx +463 -0
  762. package/src/features/team-settings/components/team-members-list.tsx +342 -0
  763. package/src/features/team-settings/components/team-permission-guard.tsx +56 -0
  764. package/src/features/team-settings/components/team-setting-integrations.tsx +27 -0
  765. package/src/features/team-settings/components/team-setting-member.tsx +28 -0
  766. package/src/features/team-settings/components/team-settings-general.tsx +131 -0
  767. package/src/features/team-settings/components/transfer-ownership-modal.tsx +164 -0
  768. package/src/features/team-settings/components/unauthorized-access.tsx +52 -0
  769. package/src/features/team-settings/hooks/__tests__/use-team-settings.test.tsx +139 -0
  770. package/src/features/team-settings/hooks/index.ts +1 -0
  771. package/src/features/team-settings/hooks/use-team-settings.ts +148 -0
  772. package/src/features/team-settings/hooks/use-transfer-ownership.ts +45 -0
  773. package/src/features/team-settings/index.ts +25 -0
  774. package/src/features/team-settings/screens/index.ts +1 -0
  775. package/src/features/team-settings/screens/team-settings-screen.tsx +33 -0
  776. package/src/features/team-settings/types/index.ts +78 -0
  777. package/src/features/team-settings/utils/index.ts +6 -0
  778. package/src/features/team-settings/utils/mock-data.ts +40 -0
  779. package/src/features/teams/api/cancel-invitation.ts +25 -0
  780. package/src/features/teams/api/create-invitation.ts +28 -0
  781. package/src/features/teams/api/create-team.ts +14 -0
  782. package/src/features/teams/api/delete-team.ts +19 -0
  783. package/src/features/teams/api/get-invitations.ts +25 -0
  784. package/src/features/teams/api/get-team-members.ts +25 -0
  785. package/src/features/teams/api/get-team.ts +13 -0
  786. package/src/features/teams/api/get-teams.ts +19 -0
  787. package/src/features/teams/api/index.ts +49 -0
  788. package/src/features/teams/api/leave-team.ts +22 -0
  789. package/src/features/teams/api/remove-member.ts +25 -0
  790. package/src/features/teams/api/resend-invitation.ts +26 -0
  791. package/src/features/teams/api/switch-team.ts +13 -0
  792. package/src/features/teams/api/types.ts +122 -0
  793. package/src/features/teams/api/update-member-roles.ts +28 -0
  794. package/src/features/teams/api/update-team.ts +17 -0
  795. package/src/features/teams/components/create-team-dialog.tsx +105 -0
  796. package/src/features/teams/hooks/__tests__/cache-invalidation.property.test.tsx +268 -0
  797. package/src/features/teams/hooks/index.ts +35 -0
  798. package/src/features/teams/hooks/use-can-manage-members.ts +21 -0
  799. package/src/features/teams/hooks/use-can-manage-team.ts +21 -0
  800. package/src/features/teams/hooks/use-cancel-invitation.ts +52 -0
  801. package/src/features/teams/hooks/use-create-invitation.ts +59 -0
  802. package/src/features/teams/hooks/use-create-team.ts +38 -0
  803. package/src/features/teams/hooks/use-delete-team.ts +43 -0
  804. package/src/features/teams/hooks/use-invitations.ts +31 -0
  805. package/src/features/teams/hooks/use-leave-team.ts +43 -0
  806. package/src/features/teams/hooks/use-remove-member.ts +58 -0
  807. package/src/features/teams/hooks/use-resend-invitation.ts +52 -0
  808. package/src/features/teams/hooks/use-switch-team.ts +41 -0
  809. package/src/features/teams/hooks/use-team-members.ts +31 -0
  810. package/src/features/teams/hooks/use-team-permissions.ts +102 -0
  811. package/src/features/teams/hooks/use-team.ts +30 -0
  812. package/src/features/teams/hooks/use-teams.ts +26 -0
  813. package/src/features/teams/hooks/use-update-member-roles.ts +64 -0
  814. package/src/features/teams/hooks/use-update-team.ts +47 -0
  815. package/src/features/teams/index.ts +111 -0
  816. package/src/features/user-settings/actions/set-password.ts +63 -0
  817. package/src/features/user-settings/api/index.ts +16 -0
  818. package/src/features/user-settings/components/__tests__/security-settings.test.tsx +125 -0
  819. package/src/features/user-settings/components/delete-account-dialog.tsx +185 -0
  820. package/src/features/user-settings/components/index.ts +13 -0
  821. package/src/features/user-settings/components/integrations-list.tsx +152 -0
  822. package/src/features/user-settings/components/notification-preferences.tsx +112 -0
  823. package/src/features/user-settings/components/other-settings.tsx +126 -0
  824. package/src/features/user-settings/components/password-section.tsx +297 -0
  825. package/src/features/user-settings/components/security-settings.tsx +184 -0
  826. package/src/features/user-settings/components/user-preferences.tsx +146 -0
  827. package/src/features/user-settings/hooks/index.ts +8 -0
  828. package/src/features/user-settings/hooks/use-notification-preferences.ts +65 -0
  829. package/src/features/user-settings/hooks/use-user-preferences.ts +52 -0
  830. package/src/features/user-settings/index.ts +22 -0
  831. package/src/features/user-settings/screens/index.ts +11 -0
  832. package/src/features/user-settings/screens/integrations-screen.tsx +24 -0
  833. package/src/features/user-settings/screens/notifications-screen.tsx +29 -0
  834. package/src/features/user-settings/screens/other-settings-screen.tsx +24 -0
  835. package/src/features/user-settings/screens/setting-preferences-screen.tsx +24 -0
  836. package/src/features/user-settings/screens/user-settings-screen.tsx +23 -0
  837. package/src/features/user-settings/types/index.ts +42 -0
  838. package/src/features/user-settings/utils/index.ts +8 -0
  839. package/src/hooks/use-long-press.ts +196 -0
  840. package/src/hooks/use-media-upload.ts +95 -0
  841. package/src/hooks/use-mobile.ts +19 -0
  842. package/src/hooks/use-team.ts +32 -0
  843. package/src/instrumentation.ts +14 -0
  844. package/src/lib/__tests__/auth-config.test.ts +166 -0
  845. package/src/lib/__tests__/config.test.ts +42 -0
  846. package/src/lib/__tests__/db.test.ts +101 -0
  847. package/src/lib/__tests__/env.property.test.ts +197 -0
  848. package/src/lib/__tests__/env.test.ts +177 -0
  849. package/src/lib/__tests__/health-check.test.ts +87 -0
  850. package/src/lib/__tests__/oauth-errors.test.ts +184 -0
  851. package/src/lib/__tests__/oauth-redirect.test.ts +224 -0
  852. package/src/lib/__tests__/oauth-scopes.test.ts +268 -0
  853. package/src/lib/__tests__/storage.test.ts +58 -0
  854. package/src/lib/__tests__/url-validator.test.ts +232 -0
  855. package/src/lib/api-client.ts +93 -0
  856. package/src/lib/auth-client.ts +5 -0
  857. package/src/lib/auth-config.ts +146 -0
  858. package/src/lib/auth.ts +209 -0
  859. package/src/lib/config.ts +228 -0
  860. package/src/lib/cors.ts +96 -0
  861. package/src/lib/date.ts +16 -0
  862. package/src/lib/db.ts +88 -0
  863. package/src/lib/env.ts +489 -0
  864. package/src/lib/feedback.ts +29 -0
  865. package/src/lib/health-check.ts +229 -0
  866. package/src/lib/logger.ts +204 -0
  867. package/src/lib/oauth-errors.ts +138 -0
  868. package/src/lib/performance.ts +367 -0
  869. package/src/lib/query-server.ts +35 -0
  870. package/src/lib/query.tsx +43 -0
  871. package/src/lib/resend.ts +36 -0
  872. package/src/lib/security-headers.ts +165 -0
  873. package/src/lib/setup-status.ts +34 -0
  874. package/src/lib/storage.ts +150 -0
  875. package/src/lib/supabase-client.ts +58 -0
  876. package/src/lib/testing/test-db.ts +75 -0
  877. package/src/lib/url-validator.ts +168 -0
  878. package/src/lib/utils.ts +6 -0
  879. package/src/mocks/README.md +42 -0
  880. package/src/mocks/activity.fixtures.ts +281 -0
  881. package/src/mocks/annotation.fixtures.ts +325 -0
  882. package/src/mocks/attachment.fixtures.ts +80 -0
  883. package/src/mocks/email.fixtures.ts +61 -0
  884. package/src/mocks/index.ts +33 -0
  885. package/src/mocks/issue.fixtures.ts +364 -0
  886. package/src/mocks/landing.fixtures.ts +118 -0
  887. package/src/mocks/notification.fixtures.ts +111 -0
  888. package/src/mocks/project-activity.fixtures.ts +69 -0
  889. package/src/mocks/project-invitation.fixtures.ts +95 -0
  890. package/src/mocks/project-member.fixtures.ts +93 -0
  891. package/src/mocks/project.fixtures.ts +249 -0
  892. package/src/mocks/settings.fixtures.ts +56 -0
  893. package/src/mocks/share.fixtures.ts +48 -0
  894. package/src/mocks/team-member.fixtures.ts +147 -0
  895. package/src/mocks/team.fixtures.ts +35 -0
  896. package/src/mocks/user-settings.fixtures.ts +77 -0
  897. package/src/mocks/user.fixtures.ts +21 -0
  898. package/src/providers/theme-provider.tsx +11 -0
  899. package/src/proxy/__tests__/proxy-setup-gate.test.ts +43 -0
  900. package/src/proxy.ts +169 -0
  901. package/src/server/annotations/__tests__/annotation-limit.property.test.ts +291 -0
  902. package/src/server/annotations/__tests__/attachment-deletion-cascade.property.test.ts +385 -0
  903. package/src/server/annotations/__tests__/comment-delete-authorization.property.test.ts +419 -0
  904. package/src/server/annotations/__tests__/sanitize.property.test.ts +302 -0
  905. package/src/server/annotations/annotation-service.ts +305 -0
  906. package/src/server/annotations/comment-service.ts +288 -0
  907. package/src/server/annotations/index.ts +61 -0
  908. package/src/server/annotations/permission-utils.ts +125 -0
  909. package/src/server/annotations/sanitize.ts +134 -0
  910. package/src/server/annotations/types.ts +161 -0
  911. package/src/server/audit/audit-service.ts +85 -0
  912. package/src/server/audit/index.ts +11 -0
  913. package/src/server/audit/types.ts +75 -0
  914. package/src/server/auth/__tests__/README.md +368 -0
  915. package/src/server/auth/__tests__/account-linking.integration.test.ts +410 -0
  916. package/src/server/auth/__tests__/auth-integration.test.ts +811 -0
  917. package/src/server/auth/__tests__/cookies.test.ts +337 -0
  918. package/src/server/auth/__tests__/login.property.test.ts +428 -0
  919. package/src/server/auth/__tests__/oauth-integration.test.ts +555 -0
  920. package/src/server/auth/__tests__/password.test.ts +194 -0
  921. package/src/server/auth/__tests__/rate-limiter.test.ts +450 -0
  922. package/src/server/auth/__tests__/rbac.test.ts +474 -0
  923. package/src/server/auth/__tests__/session.test.ts +599 -0
  924. package/src/server/auth/__tests__/signup.property.test.ts +224 -0
  925. package/src/server/auth/__tests__/token-encryption.test.ts +171 -0
  926. package/src/server/auth/__tests__/tokens.test.ts +476 -0
  927. package/src/server/auth/__tests__/verify-email.property.test.ts +372 -0
  928. package/src/server/auth/cookies.ts +184 -0
  929. package/src/server/auth/password.ts +94 -0
  930. package/src/server/auth/rate-limiter.ts +257 -0
  931. package/src/server/auth/rbac.ts +1168 -0
  932. package/src/server/auth/session.ts +392 -0
  933. package/src/server/auth/token-encryption.ts +201 -0
  934. package/src/server/auth/tokens.ts +397 -0
  935. package/src/server/db/schema/account.ts +21 -0
  936. package/src/server/db/schema/annotation-read-status.ts +57 -0
  937. package/src/server/db/schema/better-auth-verifications.ts +27 -0
  938. package/src/server/db/schema/email-jobs.ts +24 -0
  939. package/src/server/db/schema/index.ts +20 -0
  940. package/src/server/db/schema/instance-settings.ts +42 -0
  941. package/src/server/db/schema/issue-activities.ts +97 -0
  942. package/src/server/db/schema/issue-attachments.ts +101 -0
  943. package/src/server/db/schema/issues.ts +139 -0
  944. package/src/server/db/schema/notifications.ts +119 -0
  945. package/src/server/db/schema/project-activities.ts +116 -0
  946. package/src/server/db/schema/project-invitations.ts +34 -0
  947. package/src/server/db/schema/project-members.ts +29 -0
  948. package/src/server/db/schema/projects.ts +46 -0
  949. package/src/server/db/schema/sessions.ts +17 -0
  950. package/src/server/db/schema/team-invitations.ts +22 -0
  951. package/src/server/db/schema/team-members.ts +18 -0
  952. package/src/server/db/schema/teams.ts +15 -0
  953. package/src/server/db/schema/user-roles.ts +14 -0
  954. package/src/server/db/schema/users.ts +17 -0
  955. package/src/server/db/schema/verification-tokens.ts +15 -0
  956. package/src/server/email/README.md +258 -0
  957. package/src/server/email/__tests__/client.property.test.ts +218 -0
  958. package/src/server/email/__tests__/payload.property.test.ts +205 -0
  959. package/src/server/email/__tests__/queue.test.ts +407 -0
  960. package/src/server/email/__tests__/render-template.test.tsx +172 -0
  961. package/src/server/email/client.ts +70 -0
  962. package/src/server/email/index.ts +20 -0
  963. package/src/server/email/providers/console-provider.ts +43 -0
  964. package/src/server/email/providers/index.ts +5 -0
  965. package/src/server/email/providers/resend-provider.ts +59 -0
  966. package/src/server/email/providers/smtp-provider.ts +65 -0
  967. package/src/server/email/queue.ts +365 -0
  968. package/src/server/email/render-template.tsx +117 -0
  969. package/src/server/email/templates/layout.tsx +66 -0
  970. package/src/server/email/templates/ownership-transfer-email.tsx +75 -0
  971. package/src/server/email/templates/password-reset-email.tsx +72 -0
  972. package/src/server/email/templates/project-invitation-email.tsx +70 -0
  973. package/src/server/email/templates/security-alert-email.tsx +161 -0
  974. package/src/server/email/templates/team-invitation-email.tsx +68 -0
  975. package/src/server/email/templates/verification-email.tsx +61 -0
  976. package/src/server/email/templates/welcome-email.tsx +60 -0
  977. package/src/server/email/worker.ts +182 -0
  978. package/src/server/issues/activity-service.ts +422 -0
  979. package/src/server/issues/attachment-service.ts +379 -0
  980. package/src/server/issues/index.ts +68 -0
  981. package/src/server/issues/issue-service.ts +569 -0
  982. package/src/server/issues/types.ts +233 -0
  983. package/src/server/notifications/__tests__/notification-service.integration.test.ts +405 -0
  984. package/src/server/notifications/index.ts +13 -0
  985. package/src/server/notifications/notification-service.ts +526 -0
  986. package/src/server/notifications/types.ts +234 -0
  987. package/src/server/projects/__tests__/activity-logging.integration.test.ts +319 -0
  988. package/src/server/projects/__tests__/invitation-email.integration.test.ts +258 -0
  989. package/src/server/projects/__tests__/invitation-service.integration.test.ts +651 -0
  990. package/src/server/projects/__tests__/member-service.property.test.ts +397 -0
  991. package/src/server/projects/__tests__/project-service.property.test.ts +116 -0
  992. package/src/server/projects/activity-service.ts +548 -0
  993. package/src/server/projects/index.ts +11 -0
  994. package/src/server/projects/invitation-service.ts +773 -0
  995. package/src/server/projects/member-service.ts +458 -0
  996. package/src/server/projects/project-service.ts +491 -0
  997. package/src/server/projects/schemas.ts +310 -0
  998. package/src/server/projects/types.ts +166 -0
  999. package/src/server/projects/utils.ts +128 -0
  1000. package/src/server/setup/__tests__/health-check.property.test.ts +70 -0
  1001. package/src/server/setup/__tests__/sample-data.property.test.ts +82 -0
  1002. package/src/server/setup/__tests__/setup.property.test.ts +95 -0
  1003. package/src/server/setup/health-check-service.ts +294 -0
  1004. package/src/server/setup/index.ts +35 -0
  1005. package/src/server/setup/sample-data-service.ts +233 -0
  1006. package/src/server/setup/setup-service.ts +229 -0
  1007. package/src/server/setup/types.ts +96 -0
  1008. package/src/server/teams/__tests__/export.property.test.ts +542 -0
  1009. package/src/server/teams/__tests__/get-members.integration.test.ts +105 -0
  1010. package/src/server/teams/__tests__/invitation-flow.integration.test.ts +402 -0
  1011. package/src/server/teams/__tests__/invitations.property.test.ts +235 -0
  1012. package/src/server/teams/__tests__/member-management-flow.integration.test.ts +306 -0
  1013. package/src/server/teams/__tests__/members.property.test.ts +180 -0
  1014. package/src/server/teams/__tests__/ownership-transfer.property.test.ts +173 -0
  1015. package/src/server/teams/__tests__/resource-limits.property.test.ts +382 -0
  1016. package/src/server/teams/__tests__/team-context-management.integration.test.ts +396 -0
  1017. package/src/server/teams/__tests__/team-context.property.test.ts +854 -0
  1018. package/src/server/teams/__tests__/team-creation-flow.integration.test.ts +310 -0
  1019. package/src/server/teams/__tests__/team-creation.property.test.ts +280 -0
  1020. package/src/server/teams/errors.ts +396 -0
  1021. package/src/server/teams/export-service.ts +383 -0
  1022. package/src/server/teams/index.ts +10 -0
  1023. package/src/server/teams/invitation-service.ts +708 -0
  1024. package/src/server/teams/member-service.ts +334 -0
  1025. package/src/server/teams/resource-limits.ts +211 -0
  1026. package/src/server/teams/slug.ts +58 -0
  1027. package/src/server/teams/team-context.ts +648 -0
  1028. package/src/server/teams/team-service.ts +660 -0
  1029. package/src/server/teams/types.ts +81 -0
  1030. package/src/server/teams/validation.ts +209 -0
  1031. package/src/styles/globals.css +160 -0
  1032. package/src/types/deployment.ts +39 -0
  1033. package/supabase/config.toml +357 -0
  1034. package/supabase/seed.sql +480 -0
  1035. package/tests/e2e/.gitkeep +0 -0
  1036. package/tests/e2e/QUICK_START.md +98 -0
  1037. package/tests/e2e/README.md +301 -0
  1038. package/tests/e2e/auth.spec.ts +583 -0
  1039. package/tests/e2e/global-setup.ts +23 -0
  1040. package/tests/e2e/global-teardown.ts +23 -0
  1041. package/tests/e2e/helpers/auth-helpers.ts +310 -0
  1042. package/tests/e2e/helpers/test-fixtures.ts +286 -0
  1043. package/tests/e2e/smoke-test.spec.ts +330 -0
  1044. package/tsconfig.json +48 -0
  1045. package/vitest.config.ts +50 -0
  1046. package/vitest.setup.ts +56 -0
  1047. package/dist/index.js +0 -778
@@ -0,0 +1,1434 @@
1
+ # AI Specification Workflow
2
+
3
+ > Complete guide to the AI-driven specification creation workflow for UI SyncUp features.
4
+
5
+ # Goal
6
+
7
+ You are an agent that specializes in working with Specification-Driven Development (SDD). Specification-Driven Development are a way to develop complex features by creating requirements, design and an implementation plan.
8
+
9
+ Specification-Driven Development have an iterative workflow: you help transform an idea into requirements first, then design, then tasks. The workflow defined below describes each phase in detail.
10
+
11
+ # Workflow to execute
12
+
13
+ Here is the workflow you need to follow:
14
+
15
+ ## Table of Contents
16
+
17
+ 1. [Overview](#overview)
18
+ 2. [Workflow Principles](#workflow-principles)
19
+ 3. [Phase 1: Requirements Gathering](#phase-1-requirements-gathering)
20
+ 4. [Phase 2: Design Creation](#phase-2-design-creation)
21
+ 5. [Phase 3: Task Breakdown](#phase-3-task-breakdown)
22
+ 6. [EARS Patterns Reference](#ears-patterns-reference)
23
+ 7. [INCOSE Quality Rules](#incose-quality-rules)
24
+ 8. [Correctness Properties Guide](#correctness-properties-guide)
25
+ 9. [Property-Based Testing](#property-based-testing)
26
+ 10. [Common Property Patterns](#common-property-patterns)
27
+ 11. [Workflow Commands](#workflow-commands)
28
+ 12. [Troubleshooting](#troubleshooting)
29
+
30
+ ---
31
+
32
+ ## Overview
33
+
34
+ The AI Specification Workflow is an interactive, iterative process that transforms a rough feature idea into complete, testable specifications. It follows a strict three-phase approach with explicit approval gates.
35
+
36
+ ### What You Get
37
+
38
+ - **requirements.md** - EARS-compliant requirements with INCOSE quality validation
39
+ - **design.md** - Technical design with formal correctness properties
40
+ - **tasks.md** - Implementation checklist with requirement traceability
41
+
42
+ ### Key Features
43
+
44
+ ✅ **Explicit approval gates** - You control progression between phases
45
+ ✅ **Iterative refinement** - Feedback loops until you're satisfied
46
+ ✅ **Property-based testing** - Formal correctness guarantees
47
+ ✅ **Requirement traceability** - Clear mapping from requirements to properties to tasks
48
+ ✅ **EARS + INCOSE compliance** - Industry-standard requirement patterns
49
+
50
+ ---
51
+
52
+ ## Workflow Principles
53
+
54
+ ### Core Principles
55
+
56
+ 1. **User establishes ground truth** - AI generates, user approves
57
+ 2. **No silent progression** - Explicit approval required at each phase
58
+ 3. **Iterative refinement** - Feedback loops until satisfaction
59
+ 4. **Property-based correctness** - Formal properties for all testable requirements
60
+ 5. **Complete traceability** - Every property and task links to requirements
61
+
62
+ ### Approval Gates
63
+
64
+ The workflow has three mandatory approval gates:
65
+
66
+
67
+ | Gate | Question | Required Response |
68
+ |------|----------|-------------------|
69
+ | **Gate 1** | "Do the requirements look good? If so, we can move on to the design." | Explicit "yes", "approved", or equivalent |
70
+ | **Gate 2** | "Does the design look good? If so, we can move on to the implementation plan." | Explicit "yes", "approved", or equivalent |
71
+ | **Gate 3** | "The current task list marks some tasks as optional. Keep optional tasks (faster MVP) or make all tasks required?" | Choose option or approve |
72
+
73
+ **Critical Rule:** AI MUST NOT proceed to the next phase without explicit user approval.
74
+
75
+ ### Workflow States
76
+
77
+ ```mermaid
78
+ stateDiagram-v2
79
+ [*] --> Requirements: User provides feature idea
80
+
81
+ Requirements --> ReviewReq: AI generates requirements.md
82
+ ReviewReq --> Requirements: User requests changes
83
+ ReviewReq --> Design: User approves
84
+
85
+ Design --> ReviewDesign: AI generates design.md
86
+ ReviewDesign --> Design: User requests changes
87
+ ReviewDesign --> Tasks: User approves
88
+
89
+ Tasks --> ReviewTasks: AI generates tasks.md
90
+ ReviewTasks --> Tasks: User requests changes
91
+ ReviewTasks --> [*]: User approves
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Phase 1: Requirements Gathering
97
+
98
+ ### Objective
99
+
100
+ Generate EARS-compliant requirements with INCOSE quality validation. Iterate until user explicitly approves.
101
+
102
+ ### Process
103
+
104
+ 1. **AI generates initial requirements.md** based on feature idea
105
+ 2. **AI applies EARS patterns** to all acceptance criteria
106
+ 3. **AI validates against INCOSE rules**
107
+ 4. **AI presents for review** using userInput tool
108
+ 5. **User reviews and provides feedback**
109
+ 6. **AI iterates** based on feedback
110
+ 7. **Repeat 5-6** until user explicitly approves
111
+
112
+ ### AI Constraints
113
+
114
+ - MUST create `.ai/specs/{feature-name}/requirements.md`
115
+ - MUST generate initial version WITHOUT asking clarifying questions first
116
+ - MUST use userInput tool with reason 'spec-requirements-review'
117
+ - MUST ask: "Do the requirements look good? If so, we can move on to the design."
118
+ - MUST iterate until explicit approval received
119
+ - MUST correct non-compliant requirements and explain corrections
120
+
121
+
122
+ ### Requirements Document Structure
123
+
124
+ ```markdown
125
+ # Requirements Document: [Feature Name]
126
+
127
+ ## Introduction
128
+ [Business value and problem statement]
129
+
130
+ ## Glossary
131
+ - **System**: The UI SyncUp application
132
+ - **User**: An authenticated person using the system
133
+ - **[Domain_Term]**: [Definition]
134
+
135
+ ## Requirements
136
+
137
+ ### Requirement 1: [Title]
138
+ **User Story:** As a [role], I want [goal], so that [benefit].
139
+
140
+ #### Acceptance Criteria
141
+ 1. WHEN [trigger] THEN the System SHALL [action]
142
+ 2. WHILE [state] the System SHALL [behavior]
143
+ 3. IF [error condition] THEN the System SHALL [error handling]
144
+ 4. THE System SHALL [invariant]
145
+ 5. WHERE [optional feature] the System SHALL [conditional behavior]
146
+ ```
147
+
148
+ ### Quality Standards
149
+
150
+ Every requirement MUST:
151
+ - Follow exactly one EARS pattern
152
+ - Pass all INCOSE quality checks
153
+ - Be testable and unambiguous
154
+ - Use "SHALL" for mandatory, "MAY" for optional
155
+ - Avoid vague terms (quickly, user-friendly, reasonable)
156
+
157
+ ### Special Requirements Guidance
158
+
159
+ **Parser and Serializer Requirements:**
160
+ - Call out ALL parsers and serializers as explicit requirements
161
+ - Reference the grammar being parsed
162
+ - ALWAYS include a pretty printer requirement when a parser is needed
163
+ - ALWAYS include a round-trip requirement (parse → print → parse)
164
+ - This is ESSENTIAL - parsers are tricky and round-trip testing catches bugs
165
+
166
+ **Example:**
167
+ ```markdown
168
+ ### Requirement 3: Parse Configuration Files
169
+
170
+ **User Story:** As a developer, I want to parse configuration files, so that I can load application settings.
171
+
172
+ #### Acceptance Criteria
173
+ 1. WHEN a valid configuration file is provided THEN the Parser SHALL parse it into a Configuration object
174
+ 2. WHEN an invalid configuration file is provided THEN the Parser SHALL return a descriptive error
175
+ 3. THE Pretty_Printer SHALL format Configuration objects back into valid configuration files
176
+ 4. FOR ALL valid Configuration objects, parsing then printing then parsing SHALL produce an equivalent object (round-trip property)
177
+ ```
178
+
179
+
180
+ ---
181
+
182
+ ## Phase 2: Design Creation
183
+
184
+ ### Objective
185
+
186
+ Develop comprehensive technical design with formal correctness properties. Iterate until user explicitly approves.
187
+
188
+ ### Process
189
+
190
+ 1. **AI identifies research needs** and conducts research
191
+ 2. **AI writes design sections** (Overview → Architecture → Components → Data Models)
192
+ 3. **AI STOPS before Correctness Properties section**
193
+ 4. **AI uses prework tool** to analyze acceptance criteria for testability
194
+ 5. **AI performs property reflection** to eliminate redundancy
195
+ 6. **AI writes Correctness Properties** based on prework analysis
196
+ 7. **AI completes remaining sections** (Error Handling, Testing Strategy)
197
+ 8. **AI presents for review** using userInput tool
198
+ 9. **User reviews and provides feedback**
199
+ 10. **AI iterates** based on feedback
200
+ 11. **Repeat 9-10** until user explicitly approves
201
+
202
+ ### AI Constraints
203
+
204
+ - MUST create `.ai/specs/{feature-name}/design.md`
205
+ - MUST identify areas where research is needed
206
+ - MUST conduct research and build up context in conversation
207
+ - SHOULD NOT create separate research files
208
+ - MUST summarize key findings that inform the design
209
+ - SHOULD cite sources and include relevant links
210
+ - MUST use prework tool BEFORE writing Correctness Properties
211
+ - MUST perform property reflection to eliminate redundancy
212
+ - MUST use userInput tool with reason 'spec-design-review'
213
+ - MUST ask: "Does the design look good? If so, we can move on to the implementation plan."
214
+
215
+ ### Design Document Structure
216
+
217
+ Required sections:
218
+ 1. Overview
219
+ 2. Architecture (with Mermaid diagrams)
220
+ 3. Components and Interfaces
221
+ 4. Data Models
222
+ 5. **Correctness Properties** (with requirement traceability)
223
+ 6. Error Handling
224
+ 7. Testing Strategy
225
+
226
+
227
+ ### Critical: Prework Analysis
228
+
229
+ **BEFORE writing Correctness Properties, AI MUST:**
230
+
231
+ 1. Use the `prework` tool to analyze each acceptance criterion
232
+ 2. Determine testability: property, example, edge-case, or not testable
233
+ 3. Store analysis in context for property generation
234
+
235
+ **Prework Format:**
236
+
237
+ ```
238
+ Acceptance Criteria Testing Prework:
239
+
240
+ X.Y Criteria Name
241
+ Thoughts: [Step-by-step analysis of testability]
242
+ Testable: yes - property | yes - example | edge-case | no
243
+ ```
244
+
245
+ **Example Prework:**
246
+
247
+ ```
248
+ 1.1 WHEN a user types a task description and presses Enter THEN the system SHALL create a new task
249
+ Thoughts: This is testing a UI interaction. It requires that we start with a valid
250
+ task description (non-empty), trigger the UI elements that add it to the list, then
251
+ confirm that the list is now longer. This applies to all valid task descriptions.
252
+ Testable: yes - property
253
+
254
+ 1.2 WHEN a user attempts to add an empty task THEN the system SHALL prevent the addition
255
+ Thoughts: This seems at first like an example, but "empty" might mean more than just
256
+ the empty string. We should think about empty as meaning all whitespace strings. This
257
+ is testing that our input validation correctly rejects invalid inputs.
258
+ Testable: yes - property
259
+
260
+ 1.5 WHEN the input field receives focus THEN the system SHALL provide subtle visual feedback
261
+ Thoughts: This is testing a UI interaction. It's a requirement for how the UI feels
262
+ for a user, which isn't a computable property.
263
+ Testable: no
264
+ ```
265
+
266
+ ### Property Reflection
267
+
268
+ **After prework, AI MUST perform property reflection:**
269
+
270
+ 1. Review ALL properties identified as testable
271
+ 2. Identify logically redundant properties where one implies another
272
+ 3. Identify properties that can be combined into a single, more comprehensive property
273
+ 4. Mark redundant properties for removal or consolidation
274
+ 5. Ensure each remaining property provides unique validation value
275
+
276
+ **Examples of Redundancy:**
277
+
278
+ - Property 1: "adding a task increases list length by 1" + Property 2: "task list contains the added task" → Property 1 may be redundant
279
+ - Property 3: "muting prevents messages" + Property 4: "muted rooms reject non-moderator messages" → Can be combined
280
+ - Property 5: "parsing preserves structure" + Property 6: "round-trip parsing is identity" → Property 6 subsumes Property 5
281
+
282
+
283
+ ### Correctness Properties Requirements
284
+
285
+ **AI MUST write a brief explanation at the start of this section:**
286
+
287
+ > A property is a characteristic or behavior that should hold true across all valid executions of a system—essentially, a formal statement about what the system should do. Properties serve as the bridge between human-readable specifications and machine-verifiable correctness guarantees.
288
+
289
+ **Every property MUST:**
290
+ - Contain explicit "for all" or "for any" statement (universal quantification)
291
+ - Reference specific requirements it validates (e.g., "**Validates: Requirements 1.2, 3.4**")
292
+ - Be implementable as a property-based test
293
+ - Come from a testable acceptance criterion
294
+
295
+ **Property Format:**
296
+
297
+ ```markdown
298
+ Property N: [Property Title]
299
+ *For any* [domain of inputs], [expected behavior should hold].
300
+ **Validates: Requirements X.Y, X.Z**
301
+ ```
302
+
303
+ **Example Properties:**
304
+
305
+ ```markdown
306
+ Property 1: Task addition preserves list integrity
307
+ *For any* task list and valid (non-empty) task description, adding it to the task list
308
+ should result in the length of the task list growing by one and the new task being retrievable.
309
+ **Validates: Requirements 1.1, 1.4**
310
+
311
+ Property 2: Whitespace-only inputs are rejected
312
+ *For any* string composed entirely of whitespace characters, the system should reject it
313
+ as invalid input and the task list should remain unchanged.
314
+ **Validates: Requirements 1.2**
315
+
316
+ Property 3: Serialization round-trip preserves data
317
+ *For any* valid system object, serializing then deserializing should produce an equivalent object.
318
+ **Validates: Requirements 3.1**
319
+ ```
320
+
321
+ ### Testing Strategy Requirements
322
+
323
+ **Dual Testing Approach:**
324
+ - Unit tests: Verify specific examples, edge cases, error conditions
325
+ - Property tests: Verify universal properties across all inputs
326
+ - Both are complementary and necessary for comprehensive coverage
327
+
328
+ **Property-Based Testing Configuration:**
329
+ - Minimum 100 iterations per property test
330
+ - Each property test MUST reference its design document property
331
+ - Tag format: `// Feature: {feature_name}, Property {number}: {property_text}`
332
+ - Each correctness property MUST be implemented by a SINGLE property-based test
333
+
334
+
335
+ ---
336
+
337
+ ## Phase 3: Task Breakdown
338
+
339
+ ### Objective
340
+
341
+ Create actionable implementation plan with requirement traceability. Iterate until user explicitly approves.
342
+
343
+ ### Process
344
+
345
+ 1. **AI converts design to discrete tasks**
346
+ 2. **AI adds property-based test tasks** for each correctness property
347
+ 3. **AI marks test-related tasks as optional** with `*` suffix
348
+ 4. **AI adds checkpoint tasks** at reasonable breaks
349
+ 5. **AI presents for review** using userInput tool
350
+ 6. **User reviews and decides on optional tasks**
351
+ 7. **AI iterates** based on feedback
352
+ 8. **Repeat 6-7** until user explicitly approves
353
+
354
+ ### AI Constraints
355
+
356
+ - MUST create `.ai/specs/{feature-name}/tasks.md`
357
+ - MUST return to design if user indicates design changes needed
358
+ - MUST return to requirements if user indicates additional requirements needed
359
+ - MUST use these specific instructions:
360
+ > Convert the feature design into a series of prompts for a code-generation LLM that will implement each step with incremental progress. Make sure that each prompt builds on the previous prompts, and ends with wiring things together. There should be no hanging or orphaned code that isn't integrated into a previous step. Focus ONLY on tasks that involve writing, modifying, or testing code.
361
+ - MUST use userInput tool with reason 'spec-tasks-review'
362
+ - MUST ask about optional tasks: "The current task list marks some tasks (e.g. tests, documentation) as optional to focus on core features first. Would you like to: 1) Keep optional tasks (faster MVP), or 2) Make all tasks required (comprehensive from start)?"
363
+
364
+ ### Task List Format
365
+
366
+ **Structure:**
367
+ - Maximum two levels of hierarchy
368
+ - Top-level items (epics) only when needed
369
+ - Sub-tasks numbered with decimal notation (1.1, 1.2, 2.1)
370
+ - Each item must be a checkbox
371
+ - Simple structure is preferred
372
+
373
+ **Task Item Requirements:**
374
+ - Clear objective involving writing, modifying, or testing code
375
+ - Additional information as sub-bullets under the task
376
+ - Specific references to requirements (granular sub-requirements, not just user stories)
377
+ - File location for implementation tasks
378
+
379
+
380
+ ### Testing Task Patterns
381
+
382
+ **Property-Based Tests:**
383
+ - MUST be written for universal properties
384
+ - Unit tests and property tests are complementary
385
+ - Testing MUST NOT have stand-alone tasks
386
+ - Testing SHOULD be sub-tasks under parent tasks
387
+
388
+ **Optional Task Marking:**
389
+ - Test-related sub-tasks SHOULD be marked optional by postfixing with `*`
390
+ - Test-related sub-tasks include: unit tests, property tests, integration tests
391
+ - Top-level tasks MUST NOT be postfixed with `*`
392
+ - Only sub-tasks can have the `*` postfix
393
+ - Optional sub-tasks are visually distinguished in UI and can be skipped
394
+ - Core implementation tasks should never be marked optional
395
+
396
+ **Implementation Rules:**
397
+ - AI MUST NOT implement sub-tasks postfixed with `*`
398
+ - AI MUST implement sub-tasks NOT prefixed with `*`
399
+ - Example: `- [ ]* 2.2 Write integration tests` → DO NOT implement
400
+ - Example: `- [ ] 2.2 Write unit tests` → MUST implement
401
+
402
+ ### Task Content Requirements
403
+
404
+ **Incremental Steps:**
405
+ - Each task builds on previous steps
406
+ - Discrete, manageable coding steps
407
+ - Each step validates core functionality early through code
408
+
409
+ **Requirements Coverage:**
410
+ - Each task references specific requirements
411
+ - All requirements covered by implementation tasks
412
+ - No excessive implementation details (already in design)
413
+ - Assume all context documents available during implementation
414
+
415
+ **Checkpoints:**
416
+ - Include checkpoint tasks at reasonable breaks
417
+ - Checkpoint format: "Ensure all tests pass, ask the user if questions arise."
418
+ - Multiple checkpoints are okay
419
+
420
+ **Property-Based Test Tasks:**
421
+ - Include tasks for turning correctness properties into property-based tests
422
+ - Each property MUST be its own separate sub-task
423
+ - Place property sub-tasks close to implementation (catch errors early)
424
+ - Annotate each property with its property number
425
+ - Annotate each property with the requirements clause number it checks
426
+ - Each task MUST explicitly reference a property from the design document
427
+
428
+
429
+ ### Coding Tasks Only
430
+
431
+ **AI MUST ONLY include tasks that can be performed by a coding agent.**
432
+
433
+ **Allowed tasks:**
434
+ - Writing, modifying, or testing specific code components
435
+ - Creating or modifying files
436
+ - Implementing functions, classes, interfaces
437
+ - Writing automated tests
438
+ - Concrete tasks specifying what files/components to create/modify
439
+
440
+ **Explicitly FORBIDDEN tasks:**
441
+ - User acceptance testing or user feedback gathering
442
+ - Deployment to production or staging environments
443
+ - Performance metrics gathering or analysis
444
+ - Running the application to test end-to-end flows (use automated tests instead)
445
+ - User training or documentation creation
446
+ - Business process or organizational changes
447
+ - Marketing or communication activities
448
+ - Any task that cannot be completed through code
449
+
450
+ ### Example Task Format
451
+
452
+ ```markdown
453
+ # Implementation Plan: [Feature Name]
454
+
455
+ ## Overview
456
+ [Brief description of the implementation approach]
457
+
458
+ ## Tasks
459
+
460
+ - [ ] 1. Set up project structure and core interfaces
461
+ - Create directory structure
462
+ - Define core interfaces and types
463
+ - Set up testing framework
464
+ - _Requirements: X.Y_
465
+ - _Location: `src/features/[domain]/`_
466
+
467
+ - [ ] 2. Implement core functionality
468
+ - [ ] 2.1 Implement [Component A]
469
+ - Write implementation for core logic
470
+ - _Requirements: X.Y, X.Z_
471
+ - _Location: `src/server/[domain]/[feature]-service.ts`_
472
+
473
+ - [ ]* 2.2 Write property test for [Component A]
474
+ - **Property N: [Property Title]**
475
+ - **Validates: Requirements X.Y**
476
+ - _Location: `src/server/[domain]/__tests__/[feature].property.test.ts`_
477
+
478
+ - [ ] 3. Checkpoint - Ensure all tests pass
479
+ - Ensure all tests pass, ask the user if questions arise.
480
+ ```
481
+
482
+ ### Workflow Completion
483
+
484
+ **This workflow is ONLY for creating design and planning artifacts.**
485
+
486
+ - AI MUST NOT attempt to implement the feature as part of this workflow
487
+ - AI MUST clearly communicate that this workflow is complete once artifacts are created
488
+ - AI MUST inform the user they can begin executing tasks by:
489
+ - Opening the tasks.md file
490
+ - Clicking "Start task" next to task items
491
+
492
+
493
+ ---
494
+
495
+ ## EARS Patterns Reference
496
+
497
+ ### Pattern Definitions
498
+
499
+ | Pattern | Template | When to Use | Example |
500
+ |---------|----------|-------------|---------|
501
+ | **Ubiquitous** | `THE [system] SHALL [action]` | Fundamental properties that always apply | THE System SHALL validate email format |
502
+ | **Event-Driven** | `WHEN [trigger] THEN the [system] SHALL [action]` | Behavior initiated by a specific event | WHEN user clicks submit THEN the System SHALL save the form |
503
+ | **State-Driven** | `WHILE [state] the [system] SHALL [action]` | Behavior active during a defined state | WHILE loading data the System SHALL display a spinner |
504
+ | **Optional** | `WHERE [feature] the [system] SHALL [action]` | Feature-specific requirements | WHERE dark mode is enabled the System SHALL use dark theme |
505
+ | **Unwanted** | `IF [condition] THEN the [system] SHALL [action]` | Error handling, fault tolerance | IF network fails THEN the System SHALL show error message |
506
+ | **Complex** | `[WHERE] [WHILE] [WHEN/IF] the [system] SHALL [action]` | Multi-condition requirements | WHERE notifications enabled WHEN new message arrives THEN the System SHALL show notification |
507
+
508
+ ### Pattern Rules
509
+
510
+ - Each requirement must follow exactly one pattern
511
+ - System names must be defined in the Glossary
512
+ - Complex patterns must maintain the specified clause order: WHERE → WHILE → WHEN/IF → THE → SHALL
513
+ - All technical terms must be defined before use
514
+
515
+ ### Good vs Bad Examples
516
+
517
+ **✅ Good (EARS-compliant):**
518
+ ```markdown
519
+ 1. WHEN a user submits the invitation form THEN the System SHALL validate the email format
520
+ 2. WHILE the user is authenticated, the System SHALL display the notification count
521
+ 3. IF the invitation token is expired, THEN the System SHALL display an error message
522
+ 4. THE System SHALL hash passwords using Argon2
523
+ 5. WHERE two-factor authentication is enabled, the System SHALL require a verification code
524
+ ```
525
+
526
+ **❌ Bad (Vague, untestable):**
527
+ ```markdown
528
+ 1. The system should handle invitations properly
529
+ 2. Users can send invitations
530
+ 3. The invitation feature works correctly
531
+ 4. The system shall be fast
532
+ 5. The system shall handle errors gracefully
533
+ ```
534
+
535
+
536
+ ---
537
+
538
+ ## INCOSE Quality Rules
539
+
540
+ Every requirement MUST comply with these quality rules:
541
+
542
+ ### Clarity and Precision
543
+
544
+ | Rule | Description | Example |
545
+ |------|-------------|---------|
546
+ | **Active voice** | Clearly state who does what | ✅ "The System SHALL validate input" vs ❌ "Input shall be validated" |
547
+ | **No vague terms** | Avoid "quickly", "adequate", "reasonable", "user-friendly" | ✅ "SHALL respond within 200ms" vs ❌ "SHALL respond quickly" |
548
+ | **No pronouns** | Don't use "it", "them", "they" - use specific names | ✅ "The Parser SHALL validate" vs ❌ "It shall validate" |
549
+ | **Consistent terminology** | Use defined terms from the Glossary consistently | Always use "User" not "person", "member", "individual" |
550
+
551
+ ### Testability
552
+
553
+ | Rule | Description | Example |
554
+ |------|-------------|---------|
555
+ | **Explicit conditions** | All conditions must be measurable or verifiable | ✅ "WHEN count > 100" vs ❌ "WHEN there are many items" |
556
+ | **Measurable criteria** | Use specific, quantifiable criteria where applicable | ✅ "SHALL complete in 500ms" vs ❌ "SHALL be fast" |
557
+ | **Realistic tolerances** | Specify realistic timing and performance bounds | ✅ "SHALL support 1000 concurrent users" |
558
+ | **One thought per requirement** | Each requirement should test one thing | Split complex requirements into multiple criteria |
559
+
560
+ ### Completeness
561
+
562
+ | Rule | Description | Example |
563
+ |------|-------------|---------|
564
+ | **No escape clauses** | Avoid "where possible", "if feasible", "as appropriate" | ✅ "SHALL validate email" vs ❌ "SHALL validate email where possible" |
565
+ | **No absolutes** | Avoid "never", "always", "100%" unless truly absolute | ✅ "SHALL reject invalid input" vs ❌ "SHALL never fail" |
566
+ | **Solution-free** | Focus on what, not how (save implementation for design) | ✅ "SHALL authenticate user" vs ❌ "SHALL use JWT tokens" |
567
+
568
+ ### Positive Statements
569
+
570
+ | Rule | Description | Example |
571
+ |------|-------------|---------|
572
+ | **No negative statements** | Use "SHALL" not "SHALL NOT" when possible | ✅ "SHALL return error code" vs ❌ "SHALL not crash" |
573
+ | **State what should happen** | Not what shouldn't happen | ✅ "SHALL log error and continue" vs ❌ "SHALL not stop on error" |
574
+ | **Exception** | Error handling requirements may use negative statements when necessary | "IF error occurs THEN SHALL not expose stack trace" |
575
+
576
+ ### Common Violations to Avoid
577
+
578
+ | Violation | Problem | Fix |
579
+ |-----------|---------|-----|
580
+ | `The system shall quickly process requests` | Vague term | `WHEN a request is received, THE System SHALL process it within 200ms` |
581
+ | `It shall validate the input` | Pronoun | `THE Validator SHALL validate the input` |
582
+ | `The system shall not crash` | Negative statement | `WHEN an error occurs, THE System SHALL log the error and continue operation` |
583
+ | `The system shall handle errors where possible` | Escape clause | `WHEN an error occurs, THE System SHALL return an error code` |
584
+
585
+
586
+ ---
587
+
588
+ ## Correctness Properties Guide
589
+
590
+ ### What Are Correctness Properties?
591
+
592
+ A property is a characteristic or behavior that should hold true across **all valid executions** of a system. Properties are:
593
+
594
+ - **Universal**: Apply to all inputs in a domain, not just specific examples
595
+ - **Formal**: Precisely stated with clear conditions
596
+ - **Testable**: Can be verified through property-based testing
597
+ - **Traceable**: Link directly to specific requirements
598
+
599
+ ### Converting EARS to Properties
600
+
601
+ The process of converting acceptance criteria to properties:
602
+
603
+ 1. **Analyze the criterion** - Is it about specific examples or general behavior?
604
+ 2. **Identify the domain** - What are all possible inputs?
605
+ 3. **State the invariant** - What must always be true?
606
+ 4. **Add universal quantifier** - "For any..." or "For all..."
607
+ 5. **Link to requirements** - Reference the original criteria
608
+
609
+ ### Conversion Examples
610
+
611
+ #### Example 1: Task Management
612
+
613
+ **Acceptance Criterion:**
614
+ ```
615
+ 1.1 WHEN a user types a task description and presses Enter THEN the system SHALL create a new task and add it to the list
616
+ ```
617
+
618
+ **Prework Analysis:**
619
+ ```
620
+ Thoughts: This is testing a UI interaction. It requires that we start with a valid task
621
+ description (non-empty), trigger the UI elements that add it to the list, then confirm
622
+ that the list is now longer. This applies to all valid task descriptions.
623
+ Testable: yes - property
624
+ ```
625
+
626
+ **Property:**
627
+ ```markdown
628
+ Property 1: Task addition grows the task list
629
+ *For any* task list and valid (non-empty) task description, adding it to the task list
630
+ should result in the length of the task list growing by one.
631
+ **Validates: Requirements 1.1**
632
+ ```
633
+
634
+ #### Example 2: Input Validation
635
+
636
+ **Acceptance Criterion:**
637
+ ```
638
+ 1.2 WHEN a user attempts to add an empty task THEN the system SHALL prevent the addition and maintain the current state
639
+ ```
640
+
641
+ **Prework Analysis:**
642
+ ```
643
+ Thoughts: This seems at first like an example, but "empty" might mean more than just
644
+ the empty string. We should think about empty as meaning all whitespace strings. This
645
+ is testing that our input validation correctly rejects invalid inputs.
646
+ Testable: yes - property
647
+ ```
648
+
649
+ **Property:**
650
+ ```markdown
651
+ Property 2: Whitespace tasks are invalid
652
+ *For any* string composed entirely of whitespace characters, adding it to the task list
653
+ should be rejected, and the task list should be unchanged.
654
+ **Validates: Requirements 1.2**
655
+ ```
656
+
657
+
658
+ #### Example 3: Serialization
659
+
660
+ **Acceptance Criterion:**
661
+ ```
662
+ 3.1 WHEN storing objects to disk THEN the system SHALL encode them using JSON
663
+ ```
664
+
665
+ **Prework Analysis:**
666
+ ```
667
+ Thoughts: This requirement is talking about serialization, which is best validated by
668
+ round tripping. We can generate random objects, serialize them, deserialize them, and
669
+ verify we get equivalent objects back.
670
+ Testable: yes - property
671
+ ```
672
+
673
+ **Property:**
674
+ ```markdown
675
+ Property 3: Serialization round-trip preserves data
676
+ *For any* valid system object, serializing then deserializing should produce an
677
+ equivalent object.
678
+ **Validates: Requirements 3.1**
679
+ ```
680
+
681
+ #### Example 4: Room Moderation
682
+
683
+ **Acceptance Criteria:**
684
+ ```
685
+ 6.1 WHEN a moderator kicks a user THEN the system SHALL remove the user from the room and prevent immediate rejoin
686
+ 6.2 WHEN a moderator mutes a room THEN the system SHALL prevent non-moderator users from sending messages
687
+ ```
688
+
689
+ **Prework Analysis:**
690
+ ```
691
+ 6.1: This isn't about specific users/rooms, it's about how all rooms/users should behave.
692
+ We can generate a random room filled with random users, issue a kick command, then check
693
+ if the user is still there.
694
+ Testable: yes - property
695
+
696
+ 6.2: This isn't specific, it's general. We can create a random room, then create random
697
+ users of both moderator and non-moderator status. Then we can mute the room, and pick a
698
+ random user to send a message. Finally, whether that message sent should be equal to
699
+ their being a moderator.
700
+ Testable: yes - property
701
+ ```
702
+
703
+ **Properties:**
704
+ ```markdown
705
+ Property 1: Kick removes user from room
706
+ *For any* chat room and any user, when a moderator kicks that user, the user should no
707
+ longer appear in the room's participant list.
708
+ **Validates: Requirements 6.1**
709
+
710
+ Property 2: Mute prevents non-moderator messages
711
+ *For any* muted chat room and any non-moderator user, that user should be unable to send
712
+ messages while the room remains muted.
713
+ **Validates: Requirements 6.2**
714
+ ```
715
+
716
+ ### Non-Testable Criteria
717
+
718
+ Some acceptance criteria are not testable as properties:
719
+
720
+ **Example: UI Feel**
721
+ ```
722
+ 1.5 WHEN the input field receives focus THEN the system SHALL provide subtle visual feedback without disrupting the calm aesthetic
723
+
724
+ Thoughts: This is testing a UI interaction. It's a requirement for how the UI feels for
725
+ a user, which isn't a computable property.
726
+ Testable: no
727
+ ```
728
+
729
+ **Example: Architecture Goals**
730
+ ```
731
+ 8.1 WHEN transport mechanisms are changed THEN the message handling and UI components SHALL remain unaffected
732
+
733
+ Thoughts: This is talking about how the program should be organized for separation of
734
+ responsibility, not a functional requirement.
735
+ Testable: no
736
+ ```
737
+
738
+
739
+ ---
740
+
741
+ ## Property-Based Testing
742
+
743
+ ### Overview
744
+
745
+ Property-based testing (PBT) validates software correctness by testing universal properties across many generated inputs. Each property is a formal specification that should hold for all valid inputs.
746
+
747
+ ### Core Principles
748
+
749
+ 1. **Universal Quantification**: Every property must contain an explicit "for all" statement
750
+ 2. **Requirements Traceability**: Each property must reference the requirements it validates
751
+ 3. **Executable Specifications**: Properties must be implementable as automated tests
752
+ 4. **Comprehensive Coverage**: Properties should cover all testable acceptance criteria
753
+
754
+ ### Property Test Structure
755
+
756
+ ```typescript
757
+ import fc from 'fast-check'
758
+
759
+ describe('Property: [Property Name]', () => {
760
+ it('should hold for all valid inputs', () => {
761
+ // Feature: [feature-name], Property [N]: [property text]
762
+ fc.assert(
763
+ fc.property(
764
+ // Generators for inputs
765
+ fc.string().filter(s => s.trim().length > 0), // Valid task description
766
+ (taskDescription) => {
767
+ // Setup
768
+ const taskList = createTaskList()
769
+ const initialLength = taskList.length
770
+
771
+ // Action
772
+ taskList.add(taskDescription)
773
+
774
+ // Assert property holds
775
+ expect(taskList.length).toBe(initialLength + 1)
776
+ expect(taskList.contains(taskDescription)).toBe(true)
777
+ }
778
+ ),
779
+ { numRuns: 100 } // Minimum 100 iterations
780
+ )
781
+ })
782
+ })
783
+ ```
784
+
785
+ ### Configuration Requirements
786
+
787
+ - **Minimum iterations**: 100 runs per property test
788
+ - **Tag format**: `// Feature: {feature_name}, Property {number}: {property_text}`
789
+ - **One property per test**: Each correctness property gets exactly one test
790
+ - **Smart generators**: Constrain input space intelligently
791
+
792
+ ### Generator Examples
793
+
794
+ ```typescript
795
+ // Generate valid email addresses
796
+ const emailGen = fc.tuple(
797
+ fc.stringOf(fc.char().filter(c => /[a-z0-9]/.test(c)), { minLength: 1 }),
798
+ fc.constantFrom('gmail.com', 'yahoo.com', 'example.com')
799
+ ).map(([local, domain]) => `${local}@${domain}`)
800
+
801
+ // Generate valid task objects
802
+ const taskGen = fc.record({
803
+ id: fc.uuid(),
804
+ description: fc.string({ minLength: 1, maxLength: 200 }),
805
+ status: fc.constantFrom('open', 'in_progress', 'done'),
806
+ priority: fc.constantFrom('low', 'medium', 'high'),
807
+ })
808
+
809
+ // Generate non-empty arrays
810
+ const nonEmptyArrayGen = fc.array(fc.anything(), { minLength: 1 })
811
+
812
+ // Generate whitespace-only strings
813
+ const whitespaceGen = fc.stringOf(fc.constantFrom(' ', '\t', '\n'), { minLength: 1 })
814
+ ```
815
+
816
+
817
+ ---
818
+
819
+ ## Common Property Patterns
820
+
821
+ ### 1. Invariants
822
+
823
+ **Description:** Properties that remain constant despite changes to structure or order.
824
+
825
+ **Examples:**
826
+ - Collection size after map operation
827
+ - Contents after sort operation
828
+ - Tree balance after insertion
829
+ - Object constraints: `obj.start <= obj.end`
830
+
831
+ **Pattern:**
832
+ ```markdown
833
+ Property: [Operation] preserves [invariant]
834
+ *For any* [data structure], [operation] should preserve [invariant].
835
+ ```
836
+
837
+ **Code Example:**
838
+ ```typescript
839
+ fc.assert(
840
+ fc.property(fc.array(fc.integer()), (arr) => {
841
+ const sorted = [...arr].sort((a, b) => a - b)
842
+ expect(sorted.length).toBe(arr.length) // Size invariant
843
+ expect(new Set(sorted)).toEqual(new Set(arr)) // Content invariant
844
+ })
845
+ )
846
+ ```
847
+
848
+ ### 2. Round-Trip Properties
849
+
850
+ **Description:** Combining an operation with its inverse returns to the original value.
851
+
852
+ **Examples:**
853
+ - Serialization/deserialization: `decode(encode(x)) == x`
854
+ - Parsing/printing: `parse(format(x)) == x`
855
+ - Encryption/decryption: `decrypt(encrypt(x)) == x`
856
+ - Insert/contains: `insert(x); contains(x) == true`
857
+
858
+ **Pattern:**
859
+ ```markdown
860
+ Property: [Operation] round-trip preserves data
861
+ *For any* valid [type], [operation] then [inverse operation] should produce an equivalent value.
862
+ ```
863
+
864
+ **Code Example:**
865
+ ```typescript
866
+ fc.assert(
867
+ fc.property(taskGen, (task) => {
868
+ const json = JSON.stringify(task)
869
+ const parsed = JSON.parse(json)
870
+ expect(parsed).toEqual(task) // Round-trip equality
871
+ })
872
+ )
873
+ ```
874
+
875
+ **Critical:** ALWAYS test round-trip properties for parsers and serializers!
876
+
877
+ ### 3. Idempotence
878
+
879
+ **Description:** Operations where doing it twice equals doing it once: `f(x) = f(f(x))`
880
+
881
+ **Examples:**
882
+ - Distinct filter on a set
883
+ - Database upsert operations
884
+ - Message deduplication
885
+ - Setting a value to the same value
886
+
887
+ **Pattern:**
888
+ ```markdown
889
+ Property: [Operation] is idempotent
890
+ *For any* [input], applying [operation] multiple times should produce the same result as applying it once.
891
+ ```
892
+
893
+ **Code Example:**
894
+ ```typescript
895
+ fc.assert(
896
+ fc.property(fc.array(fc.integer()), (arr) => {
897
+ const distinct1 = distinct(arr)
898
+ const distinct2 = distinct(distinct1)
899
+ expect(distinct2).toEqual(distinct1) // Idempotence
900
+ })
901
+ )
902
+ ```
903
+
904
+
905
+ ### 4. Metamorphic Properties
906
+
907
+ **Description:** Relationships that must hold between components without knowing specific values.
908
+
909
+ **Examples:**
910
+ - `len(filter(x)) <= len(x)` - Filtering never increases length
911
+ - `sort(x)[0] <= sort(x)[n]` - First element is smallest
912
+ - `hash(x) == hash(x)` - Hash is deterministic
913
+
914
+ **Pattern:**
915
+ ```markdown
916
+ Property: [Relationship] holds between [components]
917
+ *For any* [input], [relationship] should hold.
918
+ ```
919
+
920
+ **Code Example:**
921
+ ```typescript
922
+ fc.assert(
923
+ fc.property(
924
+ fc.array(fc.integer()),
925
+ fc.func(fc.boolean()),
926
+ (arr, predicate) => {
927
+ const filtered = arr.filter(predicate)
928
+ expect(filtered.length).toBeLessThanOrEqual(arr.length)
929
+ }
930
+ )
931
+ )
932
+ ```
933
+
934
+ ### 5. Model-Based Testing
935
+
936
+ **Description:** Compare optimized implementation against a simple, obviously correct reference implementation.
937
+
938
+ **Examples:**
939
+ - Fast sort vs. bubble sort
940
+ - Optimized search vs. linear search
941
+ - Cache vs. direct database query
942
+
943
+ **Pattern:**
944
+ ```markdown
945
+ Property: [Optimized implementation] matches [reference implementation]
946
+ *For any* [input], [optimized] should produce the same result as [reference].
947
+ ```
948
+
949
+ **Code Example:**
950
+ ```typescript
951
+ fc.assert(
952
+ fc.property(fc.array(fc.integer()), (arr) => {
953
+ const optimized = quickSort(arr)
954
+ const reference = bubbleSort(arr)
955
+ expect(optimized).toEqual(reference)
956
+ })
957
+ )
958
+ ```
959
+
960
+ ### 6. Confluence
961
+
962
+ **Description:** Order of operations doesn't matter - all paths lead to the same result.
963
+
964
+ **Examples:**
965
+ - Commutative operations: `a + b == b + a`
966
+ - Concurrent updates converge
967
+ - Event order independence
968
+
969
+ **Pattern:**
970
+ ```markdown
971
+ Property: [Operations] are order-independent
972
+ *For any* [inputs] and [order], the result should be the same.
973
+ ```
974
+
975
+ **Code Example:**
976
+ ```typescript
977
+ fc.assert(
978
+ fc.property(
979
+ fc.integer(),
980
+ fc.integer(),
981
+ (a, b) => {
982
+ expect(add(a, b)).toBe(add(b, a)) // Commutativity
983
+ }
984
+ )
985
+ )
986
+ ```
987
+
988
+ ### 7. Error Conditions
989
+
990
+ **Description:** Generate invalid inputs and ensure proper error handling.
991
+
992
+ **Examples:**
993
+ - Empty string validation
994
+ - Out-of-bounds array access
995
+ - Invalid enum values
996
+ - Malformed JSON
997
+
998
+ **Pattern:**
999
+ ```markdown
1000
+ Property: [Invalid inputs] are rejected
1001
+ *For any* [invalid input], the system should reject it with [error type].
1002
+ ```
1003
+
1004
+ **Code Example:**
1005
+ ```typescript
1006
+ fc.assert(
1007
+ fc.property(
1008
+ fc.stringOf(fc.constantFrom(' ', '\t', '\n'), { minLength: 1 }),
1009
+ (whitespace) => {
1010
+ expect(() => createTask(whitespace)).toThrow('Invalid input')
1011
+ }
1012
+ )
1013
+ )
1014
+ ```
1015
+
1016
+
1017
+ ---
1018
+
1019
+ ## Workflow Commands
1020
+
1021
+ ### Starting the Workflow
1022
+
1023
+ To initiate the AI Specification Workflow, use any of these commands:
1024
+
1025
+ ```
1026
+ Create a spec for [feature description]
1027
+ ```
1028
+
1029
+ ```
1030
+ I want to build [feature description]. Let's create a specification.
1031
+ ```
1032
+
1033
+ ```
1034
+ Generate requirements for [feature description]
1035
+ ```
1036
+
1037
+ The AI will automatically:
1038
+ 1. Determine a feature name in kebab-case
1039
+ 2. Create `.ai/specs/{feature-name}/` directory
1040
+ 3. Begin Phase 1: Requirements Gathering
1041
+
1042
+ ### During the Workflow
1043
+
1044
+ **Requesting Changes:**
1045
+ ```
1046
+ Change requirement 2.3 to include [modification]
1047
+ ```
1048
+
1049
+ ```
1050
+ Add a requirement for [new functionality]
1051
+ ```
1052
+
1053
+ ```
1054
+ The design should use [technology] instead
1055
+ ```
1056
+
1057
+ **Asking Questions:**
1058
+ ```
1059
+ Why did you choose [design decision]?
1060
+ ```
1061
+
1062
+ ```
1063
+ Can you explain property 3 in more detail?
1064
+ ```
1065
+
1066
+ ```
1067
+ What does this requirement mean?
1068
+ ```
1069
+
1070
+ **Approving Phases:**
1071
+ ```
1072
+ Yes, the requirements look good
1073
+ ```
1074
+
1075
+ ```
1076
+ Approved, move to design
1077
+ ```
1078
+
1079
+ ```
1080
+ Looks great, proceed to tasks
1081
+ ```
1082
+
1083
+ **Rejecting/Iterating:**
1084
+ ```
1085
+ No, I need to change [aspect]
1086
+ ```
1087
+
1088
+ ```
1089
+ Not quite, let's revise [section]
1090
+ ```
1091
+
1092
+ ```
1093
+ Go back to requirements, we need to add [feature]
1094
+ ```
1095
+
1096
+ ### After Workflow Completion
1097
+
1098
+ **Starting Implementation:**
1099
+ 1. Open `.ai/specs/{feature-name}/tasks.md`
1100
+ 2. Click "Start task" next to a task item
1101
+ 3. AI will implement the task following the specification
1102
+
1103
+ **Updating Specifications:**
1104
+ ```
1105
+ Update the [feature-name] spec to include [change]
1106
+ ```
1107
+
1108
+ ```
1109
+ Add a new requirement to [feature-name]
1110
+ ```
1111
+
1112
+ ---
1113
+
1114
+ ## Troubleshooting
1115
+
1116
+ ### Common Issues
1117
+
1118
+ #### Issue: AI proceeds without approval
1119
+
1120
+ **Symptom:** AI moves to next phase without asking for approval
1121
+
1122
+ **Solution:**
1123
+ - Stop the AI immediately
1124
+ - Say: "Wait, I didn't approve yet. Let me review the [requirements/design/tasks]."
1125
+ - AI should return to review state
1126
+
1127
+ #### Issue: Requirements don't follow EARS patterns
1128
+
1129
+ **Symptom:** Acceptance criteria use informal language
1130
+
1131
+ **Solution:**
1132
+ - Point out specific criteria: "Requirement 2.3 doesn't follow EARS patterns"
1133
+ - AI will correct and explain the proper pattern
1134
+
1135
+
1136
+ #### Issue: Missing correctness properties
1137
+
1138
+ **Symptom:** Design document doesn't include Correctness Properties section
1139
+
1140
+ **Solution:**
1141
+ - Say: "The design is missing correctness properties"
1142
+ - AI will analyze requirements and add properties
1143
+
1144
+ #### Issue: Properties don't reference requirements
1145
+
1146
+ **Symptom:** Properties lack "Validates: Requirements X.Y" annotations
1147
+
1148
+ **Solution:**
1149
+ - Say: "Properties need to reference specific requirements"
1150
+ - AI will add requirement traceability
1151
+
1152
+ #### Issue: Tasks don't include property tests
1153
+
1154
+ **Symptom:** No property-based test tasks in tasks.md
1155
+
1156
+ **Solution:**
1157
+ - Say: "Add property-based test tasks for each correctness property"
1158
+ - AI will add test tasks with property annotations
1159
+
1160
+ #### Issue: Too many optional tasks
1161
+
1162
+ **Symptom:** Most test tasks are marked optional with `*`
1163
+
1164
+ **Solution:**
1165
+ - During Phase 3 approval, choose: "Make all tasks required (comprehensive from start)"
1166
+ - AI will remove `*` markers from test tasks
1167
+
1168
+ #### Issue: AI starts implementing during spec workflow
1169
+
1170
+ **Symptom:** AI begins writing code instead of just creating specs
1171
+
1172
+ **Solution:**
1173
+ - Say: "Stop. We're only creating specifications, not implementing yet."
1174
+ - AI will return to spec creation mode
1175
+
1176
+ ### Getting Help
1177
+
1178
+ **Ask for clarification:**
1179
+ ```
1180
+ Can you explain the difference between a property and a unit test?
1181
+ ```
1182
+
1183
+ ```
1184
+ What's the purpose of the prework analysis?
1185
+ ```
1186
+
1187
+ ```
1188
+ Why do we need EARS patterns?
1189
+ ```
1190
+
1191
+ **Request examples:**
1192
+ ```
1193
+ Show me an example of a round-trip property
1194
+ ```
1195
+
1196
+ ```
1197
+ Give me an example of a good vs bad requirement
1198
+ ```
1199
+
1200
+ ```
1201
+ What does a complete design document look like?
1202
+ ```
1203
+
1204
+ **Review existing specs:**
1205
+ ```
1206
+ Show me the project-invitation spec as an example
1207
+ ```
1208
+
1209
+ ```
1210
+ How did we handle properties in the social-login spec?
1211
+ ```
1212
+
1213
+ ---
1214
+
1215
+ ## Best Practices
1216
+
1217
+ ### For Requirements
1218
+
1219
+ 1. **Start broad, refine iteratively** - Don't try to get everything perfect on first pass
1220
+ 2. **Focus on user value** - Every requirement should trace to a user story
1221
+ 3. **Be specific about edge cases** - Don't leave error handling vague
1222
+ 4. **Define all terms** - Use the Glossary liberally
1223
+ 5. **Call out parsers explicitly** - Always include round-trip requirements
1224
+
1225
+ ### For Design
1226
+
1227
+ 1. **Research before designing** - Let AI gather context about technologies
1228
+ 2. **Review prework carefully** - Ensure testability analysis is correct
1229
+ 3. **Challenge redundant properties** - Fewer, better properties > many overlapping ones
1230
+ 4. **Think about generators** - Can you generate random inputs for this property?
1231
+ 5. **Link everything** - Every property should reference specific requirements
1232
+
1233
+ ### For Tasks
1234
+
1235
+ 1. **Keep tasks atomic** - Each task should be completable in one session
1236
+ 2. **Order matters** - Tasks should build incrementally
1237
+ 3. **Checkpoints are valuable** - Don't skip validation points
1238
+ 4. **Optional tests are okay** - For MVP, mark tests optional and add later
1239
+ 5. **File locations help** - Specific paths make implementation easier
1240
+
1241
+
1242
+ ---
1243
+
1244
+ ## Workflow Diagram
1245
+
1246
+ ```mermaid
1247
+ stateDiagram-v2
1248
+ [*] --> Requirements: User provides feature idea
1249
+
1250
+ Requirements: Generate requirements.md
1251
+ Requirements --> ReviewReq: Present for approval
1252
+
1253
+ ReviewReq: User reviews requirements
1254
+ ReviewReq --> Requirements: Request changes
1255
+ ReviewReq --> Design: Explicit approval
1256
+
1257
+ Design: Generate design.md
1258
+ Design --> Prework: Complete main sections
1259
+ Prework: Analyze acceptance criteria
1260
+ Prework --> Reflection: Identify testable criteria
1261
+ Reflection: Eliminate redundant properties
1262
+ Reflection --> Properties: Generate properties
1263
+ Properties: Write Correctness Properties
1264
+ Properties --> ReviewDesign: Present for approval
1265
+
1266
+ ReviewDesign: User reviews design
1267
+ ReviewDesign --> Design: Request changes
1268
+ ReviewDesign --> Tasks: Explicit approval
1269
+
1270
+ Tasks: Generate tasks.md
1271
+ Tasks --> ReviewTasks: Present for approval
1272
+
1273
+ ReviewTasks: User reviews tasks
1274
+ ReviewTasks --> Tasks: Request changes
1275
+ ReviewTasks --> OptionalChoice: Explicit approval
1276
+
1277
+ OptionalChoice: Keep optional tasks?
1278
+ OptionalChoice --> Complete: User chooses
1279
+
1280
+ Complete: Workflow complete
1281
+ Complete --> [*]: Ready for implementation
1282
+ ```
1283
+
1284
+ ---
1285
+
1286
+ ## Quick Reference
1287
+
1288
+ ### Phase Checklist
1289
+
1290
+ **Phase 1: Requirements**
1291
+ - [ ] Feature name determined (kebab-case)
1292
+ - [ ] requirements.md created
1293
+ - [ ] All criteria follow EARS patterns
1294
+ - [ ] All requirements pass INCOSE checks
1295
+ - [ ] Glossary defines all terms
1296
+ - [ ] User explicitly approved
1297
+
1298
+ **Phase 2: Design**
1299
+ - [ ] design.md created
1300
+ - [ ] Research conducted and documented
1301
+ - [ ] Architecture diagrams included
1302
+ - [ ] Database schema defined
1303
+ - [ ] Prework analysis completed
1304
+ - [ ] Property reflection performed
1305
+ - [ ] Correctness Properties written
1306
+ - [ ] All properties reference requirements
1307
+ - [ ] Testing strategy defined
1308
+ - [ ] User explicitly approved
1309
+
1310
+ **Phase 3: Tasks**
1311
+ - [ ] tasks.md created
1312
+ - [ ] Tasks are coding-focused only
1313
+ - [ ] Each task references requirements
1314
+ - [ ] Property test tasks included
1315
+ - [ ] Test tasks marked optional (if desired)
1316
+ - [ ] Checkpoint tasks included
1317
+ - [ ] File locations specified
1318
+ - [ ] User explicitly approved
1319
+ - [ ] Optional task decision made
1320
+
1321
+ ### Key Files
1322
+
1323
+ | File | Location | Purpose |
1324
+ |------|----------|---------|
1325
+ | Requirements | `.ai/specs/{feature}/requirements.md` | WHAT to build |
1326
+ | Design | `.ai/specs/{feature}/design.md` | HOW to build it |
1327
+ | Tasks | `.ai/specs/{feature}/tasks.md` | Implementation plan |
1328
+ | Requirements Template | `docs/spec/templates/requirements-template.md` | Manual creation template |
1329
+ | Design Template | `docs/spec/templates/design-template.md` | Manual creation template |
1330
+ | Tasks Template | `docs/spec/templates/tasks-template.md` | Manual creation template |
1331
+
1332
+
1333
+ ### Property Patterns Quick Reference
1334
+
1335
+ | Pattern | When to Use | Example |
1336
+ |---------|-------------|---------|
1337
+ | **Invariants** | Properties that don't change | `length(map(f, list)) == length(list)` |
1338
+ | **Round-trip** | Operation + inverse = identity | `parse(print(x)) == x` |
1339
+ | **Idempotence** | f(x) = f(f(x)) | `distinct(distinct(x)) == distinct(x)` |
1340
+ | **Metamorphic** | Relationships between components | `length(filter(x)) <= length(x)` |
1341
+ | **Model-based** | Optimized vs reference | `quickSort(x) == bubbleSort(x)` |
1342
+ | **Confluence** | Order independence | `a + b == b + a` |
1343
+ | **Error conditions** | Invalid input handling | `validate(whitespace) throws error` |
1344
+
1345
+ ### EARS Patterns Quick Reference
1346
+
1347
+ | Pattern | Template | Example |
1348
+ |---------|----------|---------|
1349
+ | **Ubiquitous** | `THE [system] SHALL [action]` | THE System SHALL validate email format |
1350
+ | **Event-Driven** | `WHEN [trigger] THEN [system] SHALL [action]` | WHEN user clicks submit THEN System SHALL save |
1351
+ | **State-Driven** | `WHILE [state] [system] SHALL [action]` | WHILE loading System SHALL show spinner |
1352
+ | **Optional** | `WHERE [feature] [system] SHALL [action]` | WHERE dark mode System SHALL use dark theme |
1353
+ | **Unwanted** | `IF [condition] THEN [system] SHALL [action]` | IF error THEN System SHALL log and continue |
1354
+ | **Complex** | `[WHERE] [WHILE] [WHEN/IF] [system] SHALL` | WHERE enabled WHEN message THEN System SHALL notify |
1355
+
1356
+ ---
1357
+
1358
+ ## Examples
1359
+
1360
+ ### Complete Workflow Example
1361
+
1362
+ See these specs for complete examples:
1363
+
1364
+ 1. **Project Invitation** - `.ai/specs/project-invitation/`
1365
+ - Complex RBAC requirements
1366
+ - Email integration
1367
+ - Multiple correctness properties
1368
+
1369
+ 2. **Social Login Integration** - `.ai/specs/social-login-integration/`
1370
+ - Authentication flow
1371
+ - OAuth integration
1372
+ - Security properties
1373
+
1374
+ 3. **Issue Annotation Integration** - `.ai/specs/issue-annotation-integration/`
1375
+ - UI-heavy feature
1376
+ - Visual feedback requirements
1377
+ - Component properties
1378
+
1379
+ ### Property Examples by Domain
1380
+
1381
+ **Data Validation:**
1382
+ ```markdown
1383
+ Property: Email validation rejects invalid formats
1384
+ *For any* string that doesn't match email regex, the validator should reject it.
1385
+ **Validates: Requirements 1.2**
1386
+ ```
1387
+
1388
+ **State Management:**
1389
+ ```markdown
1390
+ Property: State transitions preserve invariants
1391
+ *For any* valid state and valid transition, the resulting state should maintain all invariants.
1392
+ **Validates: Requirements 2.3, 2.4**
1393
+ ```
1394
+
1395
+ **API Integration:**
1396
+ ```markdown
1397
+ Property: API responses match schema
1398
+ *For any* successful API call, the response should validate against the defined Zod schema.
1399
+ **Validates: Requirements 3.1**
1400
+ ```
1401
+
1402
+ **UI Behavior:**
1403
+ ```markdown
1404
+ Property: Form submission clears input
1405
+ *For any* valid form submission, the input fields should be cleared after successful submission.
1406
+ **Validates: Requirements 4.2**
1407
+ ```
1408
+
1409
+ ---
1410
+
1411
+ ## Related Documentation
1412
+
1413
+ - [Product Development Guide](./PRODUCT_DEVELOPMENT_GUIDE.md) - Complete SDLC workflow
1414
+ - [Specification Workflow Integration](./SPECIFICATION_WORKFLOW_INTEGRATION.md) - Integration guide
1415
+ - [Requirements Template](./templates/requirements-template.md) - Manual requirements creation
1416
+ - [Design Template](./templates/design-template.md) - Manual design creation
1417
+ - [Tasks Template](./templates/tasks-template.md) - Manual tasks creation
1418
+
1419
+ ---
1420
+
1421
+ ## Feedback and Improvements
1422
+
1423
+ This workflow is continuously refined based on usage. If you encounter issues or have suggestions:
1424
+
1425
+ 1. Document the issue with specific examples
1426
+ 2. Propose improvements with rationale
1427
+ 3. Update this document with lessons learned
1428
+ 4. Share successful patterns with the team
1429
+
1430
+ ---
1431
+
1432
+ **Last Updated:** 2026-01-14
1433
+ **Version:** 1.0.0
1434
+ **Maintained By:** Development Team