@eddacraft/anvil-adapters 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/AGENTS.md +180 -0
  2. package/BMAD_ADAPTER_SPEC.md +489 -0
  3. package/LICENSE +14 -0
  4. package/README.md +500 -0
  5. package/dist/aps-markdown/adapter.d.ts +102 -0
  6. package/dist/aps-markdown/adapter.d.ts.map +1 -0
  7. package/dist/aps-markdown/adapter.js +351 -0
  8. package/dist/aps-markdown/index.d.ts +8 -0
  9. package/dist/aps-markdown/index.d.ts.map +1 -0
  10. package/dist/aps-markdown/index.js +7 -0
  11. package/dist/base/file-discovery.d.ts +63 -0
  12. package/dist/base/file-discovery.d.ts.map +1 -0
  13. package/dist/base/file-discovery.js +246 -0
  14. package/dist/base/index.d.ts +10 -0
  15. package/dist/base/index.d.ts.map +1 -0
  16. package/dist/base/index.js +9 -0
  17. package/dist/base/registry.d.ts +155 -0
  18. package/dist/base/registry.d.ts.map +1 -0
  19. package/dist/base/registry.js +227 -0
  20. package/dist/base/testing.d.ts +102 -0
  21. package/dist/base/testing.d.ts.map +1 -0
  22. package/dist/base/testing.js +221 -0
  23. package/dist/base/types.d.ts +255 -0
  24. package/dist/base/types.d.ts.map +1 -0
  25. package/dist/base/types.js +78 -0
  26. package/dist/base/utils.d.ts +127 -0
  27. package/dist/base/utils.d.ts.map +1 -0
  28. package/dist/base/utils.js +254 -0
  29. package/dist/bmad/format-adapter.d.ts +76 -0
  30. package/dist/bmad/format-adapter.d.ts.map +1 -0
  31. package/dist/bmad/format-adapter.js +186 -0
  32. package/dist/bmad/index.d.ts +12 -0
  33. package/dist/bmad/index.d.ts.map +1 -0
  34. package/dist/bmad/index.js +10 -0
  35. package/dist/bmad/parser.d.ts +12 -0
  36. package/dist/bmad/parser.d.ts.map +1 -0
  37. package/dist/bmad/parser.js +181 -0
  38. package/dist/bmad/serializer.d.ts +16 -0
  39. package/dist/bmad/serializer.d.ts.map +1 -0
  40. package/dist/bmad/serializer.js +170 -0
  41. package/dist/bmad/types.d.ts +127 -0
  42. package/dist/bmad/types.d.ts.map +1 -0
  43. package/dist/bmad/types.js +47 -0
  44. package/dist/bmad/utils.d.ts +120 -0
  45. package/dist/bmad/utils.d.ts.map +1 -0
  46. package/dist/bmad/utils.js +480 -0
  47. package/dist/common/index.d.ts +3 -0
  48. package/dist/common/index.d.ts.map +1 -0
  49. package/dist/common/index.js +2 -0
  50. package/dist/common/registry.d.ts +18 -0
  51. package/dist/common/registry.d.ts.map +1 -0
  52. package/dist/common/registry.js +58 -0
  53. package/dist/common/types.d.ts +68 -0
  54. package/dist/common/types.d.ts.map +1 -0
  55. package/dist/common/types.js +12 -0
  56. package/dist/generic/format-adapter.d.ts +64 -0
  57. package/dist/generic/format-adapter.d.ts.map +1 -0
  58. package/dist/generic/format-adapter.js +159 -0
  59. package/dist/generic/index.d.ts +10 -0
  60. package/dist/generic/index.d.ts.map +1 -0
  61. package/dist/generic/index.js +9 -0
  62. package/dist/generic/parser.d.ts +11 -0
  63. package/dist/generic/parser.d.ts.map +1 -0
  64. package/dist/generic/parser.js +106 -0
  65. package/dist/generic/serializer.d.ts +11 -0
  66. package/dist/generic/serializer.d.ts.map +1 -0
  67. package/dist/generic/serializer.js +118 -0
  68. package/dist/generic/types.d.ts +52 -0
  69. package/dist/generic/types.d.ts.map +1 -0
  70. package/dist/generic/types.js +6 -0
  71. package/dist/generic/utils.d.ts +51 -0
  72. package/dist/generic/utils.d.ts.map +1 -0
  73. package/dist/generic/utils.js +232 -0
  74. package/dist/index.d.ts +15 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +31 -0
  77. package/dist/speckit/export.d.ts +22 -0
  78. package/dist/speckit/export.d.ts.map +1 -0
  79. package/dist/speckit/export.js +384 -0
  80. package/dist/speckit/format-adapter.d.ts +104 -0
  81. package/dist/speckit/format-adapter.d.ts.map +1 -0
  82. package/dist/speckit/format-adapter.js +488 -0
  83. package/dist/speckit/import-v2.d.ts +33 -0
  84. package/dist/speckit/import-v2.d.ts.map +1 -0
  85. package/dist/speckit/import-v2.js +361 -0
  86. package/dist/speckit/import.d.ts +16 -0
  87. package/dist/speckit/import.d.ts.map +1 -0
  88. package/dist/speckit/import.js +247 -0
  89. package/dist/speckit/index.d.ts +5 -0
  90. package/dist/speckit/index.d.ts.map +1 -0
  91. package/dist/speckit/index.js +4 -0
  92. package/dist/speckit/parser.d.ts +28 -0
  93. package/dist/speckit/parser.d.ts.map +1 -0
  94. package/dist/speckit/parser.js +283 -0
  95. package/dist/speckit/parsers/plan-parser.d.ts +71 -0
  96. package/dist/speckit/parsers/plan-parser.d.ts.map +1 -0
  97. package/dist/speckit/parsers/plan-parser.js +216 -0
  98. package/dist/speckit/parsers/spec-parser.d.ts +67 -0
  99. package/dist/speckit/parsers/spec-parser.d.ts.map +1 -0
  100. package/dist/speckit/parsers/spec-parser.js +255 -0
  101. package/dist/speckit/parsers/tasks-parser.d.ts +57 -0
  102. package/dist/speckit/parsers/tasks-parser.d.ts.map +1 -0
  103. package/dist/speckit/parsers/tasks-parser.js +157 -0
  104. package/package.json +23 -0
  105. package/project.json +29 -0
  106. package/src/__tests__/adapter-edge-cases.test.ts +937 -0
  107. package/src/__tests__/bmad-format-adapter.test.ts +1470 -0
  108. package/src/__tests__/fixtures/aps/expected-output.json +83 -0
  109. package/src/__tests__/fixtures/bmad/invalid-malformed-yaml.md +16 -0
  110. package/src/__tests__/fixtures/bmad/invalid-no-requirements.md +23 -0
  111. package/src/__tests__/fixtures/bmad/invalid-only-yaml.md +16 -0
  112. package/src/__tests__/fixtures/bmad/invalid-too-short.md +3 -0
  113. package/src/__tests__/fixtures/bmad/invalid-wrong-format.md +40 -0
  114. package/src/__tests__/fixtures/bmad/valid-agent.md +27 -0
  115. package/src/__tests__/fixtures/bmad/valid-architecture.md +116 -0
  116. package/src/__tests__/fixtures/bmad/valid-complex-prd.md +161 -0
  117. package/src/__tests__/fixtures/bmad/valid-epic.md +73 -0
  118. package/src/__tests__/fixtures/bmad/valid-minimal-prd.md +19 -0
  119. package/src/__tests__/fixtures/bmad/valid-prd.md +107 -0
  120. package/src/__tests__/fixtures/bmad/valid-story.md +107 -0
  121. package/src/__tests__/fixtures/bmad/valid-task.md +79 -0
  122. package/src/__tests__/fixtures/bmad/valid-v6-prd.md +35 -0
  123. package/src/__tests__/fixtures/generic/plan-detailed.md +39 -0
  124. package/src/__tests__/fixtures/generic/prd-simple.md +27 -0
  125. package/src/__tests__/fixtures/generic/rfc-example.md +26 -0
  126. package/src/__tests__/fixtures/generic/todo-list.md +23 -0
  127. package/src/__tests__/fixtures/speckit/sample-plan.md +63 -0
  128. package/src/__tests__/fixtures/speckit/sample-spec-namespaced.md +50 -0
  129. package/src/__tests__/fixtures/speckit/sample-spec.md +105 -0
  130. package/src/__tests__/fixtures/speckit/sample-tasks.md +87 -0
  131. package/src/__tests__/fixtures/speckit-official/auth-feature/plan.md +272 -0
  132. package/src/__tests__/fixtures/speckit-official/auth-feature/spec.md +149 -0
  133. package/src/__tests__/fixtures/speckit-official/auth-feature/tasks.md +169 -0
  134. package/src/__tests__/generic-format-adapter.test.ts +398 -0
  135. package/src/__tests__/speckit-export.test.ts +233 -0
  136. package/src/__tests__/speckit-format-adapter.test.ts +832 -0
  137. package/src/__tests__/speckit-import-v2.test.ts +253 -0
  138. package/src/__tests__/speckit-import.test.ts +209 -0
  139. package/src/__tests__/speckit-parser.test.ts +219 -0
  140. package/src/__tests__/speckit-spec-parser.test.ts +120 -0
  141. package/src/aps-markdown/__tests__/__fixtures__/simple-leaf.aps.md +17 -0
  142. package/src/aps-markdown/__tests__/adapter.test.ts +393 -0
  143. package/src/aps-markdown/adapter.ts +455 -0
  144. package/src/aps-markdown/index.ts +8 -0
  145. package/src/base/__tests__/registry.test.ts +515 -0
  146. package/src/base/file-discovery.ts +305 -0
  147. package/src/base/index.ts +10 -0
  148. package/src/base/registry.ts +263 -0
  149. package/src/base/testing.ts +334 -0
  150. package/src/base/types.ts +342 -0
  151. package/src/base/utils.ts +306 -0
  152. package/src/bmad/format-adapter.ts +227 -0
  153. package/src/bmad/index.ts +21 -0
  154. package/src/bmad/parser.ts +224 -0
  155. package/src/bmad/serializer.ts +206 -0
  156. package/src/bmad/types.ts +135 -0
  157. package/src/bmad/utils.ts +575 -0
  158. package/src/common/index.ts +2 -0
  159. package/src/common/registry.ts +72 -0
  160. package/src/common/types.ts +84 -0
  161. package/src/generic/__tests__/serializer.test.ts +167 -0
  162. package/src/generic/format-adapter.ts +200 -0
  163. package/src/generic/index.ts +11 -0
  164. package/src/generic/parser.ts +129 -0
  165. package/src/generic/serializer.ts +134 -0
  166. package/src/generic/types.ts +53 -0
  167. package/src/generic/utils.ts +270 -0
  168. package/src/index.ts +48 -0
  169. package/src/speckit/export.ts +489 -0
  170. package/src/speckit/format-adapter.ts +595 -0
  171. package/src/speckit/import-v2.ts +445 -0
  172. package/src/speckit/import.ts +305 -0
  173. package/src/speckit/index.ts +4 -0
  174. package/src/speckit/parser.ts +351 -0
  175. package/src/speckit/parsers/plan-parser.ts +342 -0
  176. package/src/speckit/parsers/spec-parser.ts +379 -0
  177. package/src/speckit/parsers/tasks-parser.ts +246 -0
  178. package/tsconfig.json +26 -0
  179. package/tsconfig.lib.json +21 -0
  180. package/tsconfig.lib.tsbuildinfo +1 -0
  181. package/tsconfig.spec.json +9 -0
  182. package/tsconfig.tsbuildinfo +1 -0
  183. package/vitest.config.ts +14 -0
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: 'User Story'
3
+ version: '1.0.0'
4
+ description: 'Email/Password Registration Story'
5
+ output_file: 'US-001.md'
6
+ variables:
7
+ story_id: 'US-001'
8
+ epic_id: 'EPIC-001'
9
+ author: 'Product Manager'
10
+ date: '2025-10-23'
11
+ ---
12
+
13
+ # US-001: User Registration with Email and Password
14
+
15
+ **Author:** Product Manager **Date:** 2025-10-23 **Version:** 1.0 **Epic:**
16
+ EPIC-001
17
+
18
+ ## Change Log
19
+
20
+ | Date | Version | Description | Author |
21
+ | :--------- | :------ | :------------ | :-------------- |
22
+ | 2025-10-23 | 1.0 | Story created | Product Manager |
23
+
24
+ ## User Story
25
+
26
+ As a new user, I want to create an account using my email address and password
27
+ so that I can access the platform and save my preferences.
28
+
29
+ ## Description
30
+
31
+ This story covers the complete email/password registration flow, including form
32
+ display, validation, account creation, and email verification. The registration
33
+ form should be simple and intuitive whilst collecting necessary information for
34
+ account setup.
35
+
36
+ ## Acceptance Criteria
37
+
38
+ 1. Registration form displays with email and password fields
39
+ 2. Email field validates format (RFC 5322 compliant)
40
+ 3. Password field enforces minimum requirements:
41
+ - At least 8 characters
42
+ - Contains uppercase and lowercase letters
43
+ - Contains at least one number
44
+ - Contains at least one special character
45
+ 4. Password confirmation field matches password
46
+ 5. Terms and conditions checkbox is required
47
+ 6. Form submission creates user record in database
48
+ 7. Verification email is sent to provided email address
49
+ 8. Success message displays after registration
50
+ 9. Error messages are clear and actionable
51
+ 10. Form is accessible via keyboard navigation
52
+
53
+ ## Technical Implementation
54
+
55
+ FR-11: Registration form shall be implemented as React component
56
+
57
+ FR-12: Form validation shall use Zod schema validation
58
+
59
+ FR-13: Password hashing shall use bcrypt with 12 rounds
60
+
61
+ FR-14: Verification email shall use transactional email service
62
+
63
+ ## Test Cases
64
+
65
+ ### TC-001: Successful Registration
66
+
67
+ - **Given:** User is on registration page
68
+ - **When:** User enters valid email, password, confirms password, accepts terms
69
+ - **Then:** Account is created, verification email sent, success message shown
70
+
71
+ ### TC-002: Invalid Email Format
72
+
73
+ - **Given:** User is on registration page
74
+ - **When:** User enters invalid email format (e.g., "notanemail")
75
+ - **Then:** Error message "Please enter a valid email address" is displayed
76
+
77
+ ### TC-003: Password Too Weak
78
+
79
+ - **Given:** User is on registration page
80
+ - **When:** User enters password "pass"
81
+ - **Then:** Error message lists missing password requirements
82
+
83
+ ### TC-004: Passwords Don't Match
84
+
85
+ - **Given:** User is on registration page
86
+ - **When:** User enters different values in password and confirm password
87
+ - **Then:** Error message "Passwords do not match" is displayed
88
+
89
+ ### TC-005: Terms Not Accepted
90
+
91
+ - **Given:** User is on registration page
92
+ - **When:** User submits form without accepting terms
93
+ - **Then:** Error message "You must accept the terms and conditions" is
94
+ displayed
95
+
96
+ ## Definition of Done
97
+
98
+ - [ ] Frontend registration component implemented
99
+ - [ ] Backend API endpoint implemented
100
+ - [ ] Form validation working on client and server
101
+ - [ ] Unit tests written and passing (>90% coverage)
102
+ - [ ] Integration tests written and passing
103
+ - [ ] Email verification flow tested
104
+ - [ ] Accessibility requirements met (WCAG 2.1 AA)
105
+ - [ ] Code reviewed and approved
106
+ - [ ] QA testing completed
107
+ - [ ] Documentation updated
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: 'Task Document'
3
+ version: '1.0.0'
4
+ description: 'Implement JWT Token Generation'
5
+ output_file: 'TASK-001.md'
6
+ variables:
7
+ task_id: 'TASK-001'
8
+ story_id: 'US-001'
9
+ author: 'Developer'
10
+ date: '2025-10-24'
11
+ ---
12
+
13
+ # TASK-001: Implement JWT Token Generation
14
+
15
+ **Author:** Developer **Date:** 2025-10-24 **Version:** 1.0 **Story:** US-001
16
+
17
+ ## Change Log
18
+
19
+ | Date | Version | Description | Author |
20
+ | :--------- | :------ | :----------- | :-------- |
21
+ | 2025-10-24 | 1.0 | Task created | Developer |
22
+
23
+ ## Task Description
24
+
25
+ Implement JWT token generation functionality for user authentication. The system
26
+ needs to generate secure, signed JWT tokens upon successful login that can be
27
+ validated on subsequent requests.
28
+
29
+ ## Technical Requirements
30
+
31
+ FR-15: JWT tokens shall be signed using RS256 algorithm FR-16: Tokens shall
32
+ include user ID, email, and role claims FR-17: Token generation shall use
33
+ environment variable for secret key FR-18: Tokens shall have configurable
34
+ expiration time (default 24 hours)
35
+
36
+ NFR-11: Token generation shall complete within 50ms NFR-12: Tokens shall be
37
+ stateless and self-contained
38
+
39
+ ## Implementation Details
40
+
41
+ **Files to Modify:**
42
+
43
+ - `src/auth/token.service.ts` - Create new service
44
+ - `src/auth/token.service.test.ts` - Add test suite
45
+ - `src/config/jwt.config.ts` - Add JWT configuration
46
+ - `.env.example` - Add JWT secret placeholder
47
+
48
+ **Dependencies:**
49
+
50
+ - jsonwebtoken: ^9.0.0
51
+ - @types/jsonwebtoken: ^9.0.0
52
+
53
+ ## Test Coverage
54
+
55
+ Must achieve >95% code coverage with tests for:
56
+
57
+ 1. Token generation with valid user data
58
+ 2. Token signing with correct algorithm
59
+ 3. Token expiration handling
60
+ 4. Invalid secret key handling
61
+ 5. Missing claims error handling
62
+
63
+ ## Acceptance Criteria
64
+
65
+ 1. JWT service generates valid tokens
66
+ 2. Tokens can be verified and decoded
67
+ 3. Tokens include all required claims
68
+ 4. Tokens expire at configured time
69
+ 5. All tests passing with >95% coverage
70
+ 6. Code reviewed and approved
71
+
72
+ ## Definition of Done
73
+
74
+ - [ ] Token service implemented
75
+ - [ ] Unit tests written and passing
76
+ - [ ] Integration tests with auth flow completed
77
+ - [ ] Code coverage >95%
78
+ - [ ] Security review completed
79
+ - [ ] Documentation updated
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: 'Product Requirements Document'
3
+ version: '6.0.0'
4
+ description: 'BMAD v6 PRD with hyphenated variables'
5
+ output_file: '{project-root}/docs/PRD.md'
6
+ author: 'v6 Author'
7
+ date: '2026-01-15'
8
+ ---
9
+
10
+ # Product Requirements Document
11
+
12
+ ## Change Log
13
+
14
+ | Date | Version | Description | Author |
15
+ | :--------- | :------ | :------------------ | :-------- |
16
+ | 2026-01-15 | 6.0.0 | v6 format migration | v6 Author |
17
+
18
+ ## Executive Summary
19
+
20
+ This PRD describes the migration to BMAD v6 format with updated folder structure
21
+ and variable syntax. The project uses `_bmad/_config` for configuration and
22
+ `{project-root}` for path references.
23
+
24
+ ## Functional Requirements
25
+
26
+ <!-- prettier-ignore -->
27
+ FR-01: Support `_bmad` folder structure for project configuration
28
+ FR-02: Support `_config` folder for module configuration
29
+ FR-03: Expand `{project-root}` hyphenated variable syntax
30
+
31
+ ## Non-Functional Requirements
32
+
33
+ <!-- prettier-ignore -->
34
+ NFR-01: Maintain backward compatibility with `.bmad` and `_cfg` folders
35
+ NFR-02: Support both `{project_root}` and `{project-root}` variable formats
@@ -0,0 +1,39 @@
1
+ # Implementation Plan: API Redesign
2
+
3
+ ## Overview
4
+
5
+ This plan outlines the redesign of our REST API to improve performance,
6
+ scalability, and developer experience. The migration will happen in phases to
7
+ minimize disruption.
8
+
9
+ ## Goals
10
+
11
+ - Reduce API response time by 50%
12
+ - Improve API documentation quality
13
+ - Implement versioning strategy
14
+ - Add comprehensive error handling
15
+
16
+ ## Requirements
17
+
18
+ 1. All endpoints must support JSON response format
19
+ 2. Authentication must use OAuth 2.0
20
+ 3. Rate limiting must be applied per user
21
+ 4. Error responses must follow RFC 7807 format
22
+ 5. All endpoints must have OpenAPI 3.0 documentation
23
+
24
+ ## Features
25
+
26
+ - GraphQL endpoint for complex queries
27
+ - Webhook support for real-time updates
28
+ - Batch operation endpoints
29
+ - Pagination with cursor-based navigation
30
+ - Field filtering and sparse fieldsets
31
+
32
+ ## Tasks
33
+
34
+ 1. Audit existing API endpoints
35
+ 2. Design new API schema
36
+ 3. Implement versioning infrastructure
37
+ 4. Migrate endpoints to v2
38
+ 5. Update client libraries
39
+ 6. Deploy to production
@@ -0,0 +1,27 @@
1
+ # Product Requirements Document
2
+
3
+ ## Purpose
4
+
5
+ Build a user dashboard that displays key metrics and allows data export.
6
+
7
+ ## Requirements
8
+
9
+ - Display user activity metrics
10
+ - Show real-time statistics
11
+ - Allow CSV export of data
12
+ - Support date range filtering
13
+ - Include visualization charts
14
+
15
+ ## Goals
16
+
17
+ - Improve user engagement by 20%
18
+ - Reduce support tickets related to data access
19
+ - Enable self-service analytics
20
+
21
+ ## Tasks
22
+
23
+ - [ ] Design dashboard layout
24
+ - [ ] Implement metrics API
25
+ - [ ] Add export functionality
26
+ - [ ] Create visualization components
27
+ - [ ] Write tests for all features
@@ -0,0 +1,26 @@
1
+ # RFC: Caching Strategy
2
+
3
+ ## Overview
4
+
5
+ This RFC proposes a comprehensive caching strategy to improve application
6
+ performance and reduce database load.
7
+
8
+ ## Goals
9
+
10
+ - Reduce database queries by 70%
11
+ - Improve page load times
12
+ - Minimize cache invalidation complexity
13
+
14
+ ## Requirements
15
+
16
+ - Must support distributed caching
17
+ - Cache TTL must be configurable per resource type
18
+ - Must handle cache invalidation on data updates
19
+ - Should support cache warming for critical paths
20
+
21
+ ## Features
22
+
23
+ - Redis-based distributed cache
24
+ - Multi-level caching (memory + Redis)
25
+ - Automatic cache invalidation
26
+ - Cache analytics and monitoring
@@ -0,0 +1,23 @@
1
+ # Project TODO
2
+
3
+ ## Overview
4
+
5
+ This document tracks tasks for the Q1 2025 project deliverables.
6
+
7
+ ## Tasks
8
+
9
+ - Set up CI/CD pipeline
10
+ - Configure monitoring and alerting
11
+ - Implement authentication system
12
+ - Add rate limiting
13
+ - Write API documentation
14
+ - Conduct security audit
15
+ - Deploy to staging environment
16
+ - Perform load testing
17
+
18
+ ## Features
19
+
20
+ - OAuth 2.0 integration
21
+ - JWT token management
22
+ - Role-based access control
23
+ - API key authentication
@@ -0,0 +1,63 @@
1
+ # Implementation Plan
2
+
3
+ Generated from APS: aps-1234abcd
4
+
5
+ ## Summary
6
+
7
+ Implement a user authentication system with JWT tokens to secure API endpoints
8
+ and manage user sessions effectively.
9
+
10
+ ## Implementation Steps
11
+
12
+ 1. **Set up project dependencies**
13
+ - Install required npm packages
14
+ - Dependencies: None
15
+
16
+ 2. **Create database schema for users**
17
+ - Design user table structure
18
+ - Dependencies: Step 1
19
+
20
+ 3. **Implement password hashing utilities**
21
+ - Create bcrypt wrapper functions
22
+ - Dependencies: Step 1
23
+
24
+ 4. **Create JWT token service**
25
+ - Implement token generation and verification
26
+ - Dependencies: Step 1
27
+
28
+ 5. **Build authentication controller**
29
+ - Implement register, login, and refresh endpoints
30
+ - Dependencies: Step 3, Step 4
31
+
32
+ 6. **Create authentication middleware**
33
+ - Build token verification middleware
34
+ - Dependencies: Step 4
35
+
36
+ 7. **Set up authentication routes**
37
+ - Configure Express routes
38
+ - Dependencies: Step 5, Step 6
39
+
40
+ 8. **Add rate limiting**
41
+ - Configure rate limiting for auth endpoints
42
+ - Dependencies: Step 7
43
+
44
+ 9. **Create integration tests**
45
+ - Write comprehensive test suite
46
+ - Dependencies: Step 8
47
+
48
+ 10. **Update documentation**
49
+ - Document API endpoints and usage
50
+ - Dependencies: Step 9
51
+
52
+ ## Validation Requirements
53
+
54
+ - Required checks: lint, test, coverage, secrets
55
+ - All tests must pass with 80% coverage minimum
56
+ - No hardcoded secrets in codebase
57
+ - ESLint must pass with no errors
58
+
59
+ ## Timeline
60
+
61
+ - Estimated completion: 2-3 days
62
+ - Critical path: Steps 1-7 must be completed sequentially
63
+ - Parallel work possible: Documentation can be written alongside implementation
@@ -0,0 +1,50 @@
1
+ # Specification
2
+
3
+ ## Intent
4
+
5
+ Implement user authentication with OAuth2 support using the SpecKit agent-first
6
+ workflow.
7
+
8
+ ## Overview
9
+
10
+ This specification defines the authentication feature using SpecKit's
11
+ agent-first architecture. Use `/speckit.clarify` for any ambiguous requirements
12
+ and `/speckit.analyze` for cross-artifact validation.
13
+
14
+ ## Goals
15
+
16
+ - Implement OAuth2 authentication flow
17
+ - Support multiple identity providers
18
+ - Integrate with speckit.analyze for validation
19
+
20
+ ## Requirements
21
+
22
+ - Node.js 18+ runtime
23
+ - OAuth2 client library
24
+ - Session management middleware
25
+
26
+ ## Changes
27
+
28
+ ### Files to Create
29
+
30
+ #### Create src/auth/oauth2.ts
31
+
32
+ OAuth2 authentication handler with provider abstraction.
33
+
34
+ ```typescript
35
+ export class OAuth2Handler {
36
+ async authenticate(provider: string): Promise<AuthResult> {
37
+ // Implementation
38
+ }
39
+ }
40
+ ```
41
+
42
+ #### Create src/auth/session.ts
43
+
44
+ Session management middleware for authenticated users.
45
+
46
+ ### Files to Update
47
+
48
+ #### Update src/app.ts
49
+
50
+ Add authentication middleware to the application pipeline.
@@ -0,0 +1,105 @@
1
+ # Specification
2
+
3
+ ## Intent
4
+
5
+ Implement a user authentication system with JWT tokens to secure API endpoints
6
+ and manage user sessions effectively.
7
+
8
+ ## Overview
9
+
10
+ This specification outlines the implementation of a JWT-based authentication
11
+ system that will provide secure access control for our API endpoints. The system
12
+ will support user registration, login, logout, and token refresh functionality.
13
+
14
+ ## Goals
15
+
16
+ - Implement secure user authentication using JWT tokens
17
+ - Add middleware for protecting API routes
18
+ - Support token refresh mechanism for long-lived sessions
19
+ - Implement proper password hashing and validation
20
+ - Add rate limiting for authentication endpoints
21
+
22
+ ## Requirements
23
+
24
+ - Node.js 18+ runtime environment
25
+ - Express.js web framework
26
+ - jsonwebtoken library for JWT handling
27
+ - bcrypt for password hashing
28
+ - Redis for session management (optional)
29
+
30
+ ## Changes
31
+
32
+ ### Files to Create
33
+
34
+ #### Create authentication controller at `src/controllers/auth.controller.ts`
35
+
36
+ This controller will handle all authentication-related endpoints including
37
+ registration, login, and token refresh.
38
+
39
+ ```typescript
40
+ import { Request, Response } from 'express';
41
+ import jwt from 'jsonwebtoken';
42
+ import bcrypt from 'bcrypt';
43
+
44
+ export class AuthController {
45
+ async register(req: Request, res: Response) {
46
+ // Implementation here
47
+ }
48
+
49
+ async login(req: Request, res: Response) {
50
+ // Implementation here
51
+ }
52
+
53
+ async refresh(req: Request, res: Response) {
54
+ // Implementation here
55
+ }
56
+ }
57
+ ```
58
+
59
+ #### Create authentication middleware at `src/middleware/auth.middleware.ts`
60
+
61
+ Middleware to verify JWT tokens and protect routes.
62
+
63
+ ```typescript
64
+ import { Request, Response, NextFunction } from 'express';
65
+ import jwt from 'jsonwebtoken';
66
+
67
+ export function authenticateToken(
68
+ req: Request,
69
+ res: Response,
70
+ next: NextFunction
71
+ ) {
72
+ // Token verification logic
73
+ }
74
+ ```
75
+
76
+ ### Files to Update
77
+
78
+ #### Update main application file `src/app.ts`
79
+
80
+ Add authentication routes and middleware to the Express application.
81
+
82
+ #### Update environment configuration `src/config/env.ts`
83
+
84
+ Add JWT secret and token expiration settings.
85
+
86
+ ### Configuration Changes
87
+
88
+ #### Update `.env` file
89
+
90
+ Add the following environment variables:
91
+
92
+ - JWT_SECRET: Secret key for signing tokens
93
+ - JWT_EXPIRES_IN: Token expiration time
94
+ - REFRESH_TOKEN_EXPIRES_IN: Refresh token expiration time
95
+
96
+ ### Dependencies to Add
97
+
98
+ - jsonwebtoken: For creating and verifying JWT tokens
99
+ - bcrypt: For password hashing
100
+ - express-rate-limit: For rate limiting authentication endpoints
101
+
102
+ ### Scripts to Execute
103
+
104
+ - Run database migrations to add user table
105
+ - Generate RSA key pair for token signing (optional)
@@ -0,0 +1,87 @@
1
+ # Tasks
2
+
3
+ Generated from APS: aps-1234abcd Last updated: 2024-01-15T10:30:00Z
4
+
5
+ ## Task List
6
+
7
+ - [x] ✅ Set up project dependencies
8
+ - [x] Install jsonwebtoken package
9
+ - [x] Install bcrypt package
10
+ - [x] Install express-rate-limit package
11
+ - [x] Update package.json scripts
12
+
13
+ - [x] ✅ Create database schema for users
14
+ - [x] Design user table structure
15
+ - [x] Write migration script
16
+ - [x] Run migration
17
+
18
+ - [x] ✅ Implement password hashing utilities
19
+ - [x] Create bcrypt wrapper functions
20
+ - [x] Add password validation rules
21
+ - [x] Write unit tests
22
+
23
+ - [ ] ⏳ Create JWT token service
24
+ - [x] Implement token generation
25
+ - [ ] Implement token verification
26
+ - [ ] Add refresh token logic
27
+ - [ ] Write unit tests
28
+
29
+ - [ ] ⏳ Build authentication controller
30
+ - [ ] Implement register endpoint
31
+ - [ ] Implement login endpoint
32
+ - [ ] Implement refresh endpoint
33
+ - [ ] Add input validation
34
+
35
+ - [ ] ⏳ Create authentication middleware
36
+ - [ ] Build token verification middleware
37
+ - [ ] Add role-based access control
38
+ - [ ] Handle token expiration
39
+
40
+ - [ ] ⏳ Set up authentication routes
41
+ - [ ] Configure Express routes
42
+ - [ ] Apply middleware to protected routes
43
+ - [ ] Add error handling
44
+
45
+ - [ ] ⏳ Add rate limiting
46
+ - [ ] Configure rate limiting for auth endpoints
47
+ - [ ] Set appropriate limits
48
+ - [ ] Test rate limiting
49
+
50
+ - [ ] ⏳ Create integration tests
51
+ - [ ] Write registration tests
52
+ - [ ] Write login tests
53
+ - [ ] Write protected route tests
54
+ - [ ] Test error scenarios
55
+
56
+ - [ ] ⏳ Update documentation
57
+ - [ ] Document API endpoints
58
+ - [ ] Add usage examples
59
+ - [ ] Update README
60
+
61
+ ## Progress
62
+
63
+ - Total tasks: 10
64
+ - Completed: 3
65
+ - Remaining: 7
66
+ - Progress: 30%
67
+
68
+ ## Execution History
69
+
70
+ ### 2024-01-15 10:00:00
71
+
72
+ - Status: in_progress
73
+ - Executor: developer@example.com
74
+ - Completed tasks 1-3
75
+
76
+ ### 2024-01-14 15:30:00
77
+
78
+ - Status: started
79
+ - Executor: developer@example.com
80
+ - Initial setup and planning
81
+
82
+ ## Notes
83
+
84
+ - Bcrypt rounds set to 10 for development, should be 12 for production
85
+ - JWT secret needs to be stored securely in environment variables
86
+ - Consider implementing logout functionality with token blacklisting
87
+ - Rate limiting values may need adjustment based on usage patterns