@eddacraft/anvil-aps 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 (121) hide show
  1. package/AGENTS.md +155 -0
  2. package/LICENSE +14 -0
  3. package/README.md +57 -0
  4. package/TODO.md +40 -0
  5. package/dist/filter/context-bundle.d.ts +81 -0
  6. package/dist/filter/context-bundle.d.ts.map +1 -0
  7. package/dist/filter/context-bundle.js +230 -0
  8. package/dist/filter/index.d.ts +85 -0
  9. package/dist/filter/index.d.ts.map +1 -0
  10. package/dist/filter/index.js +169 -0
  11. package/dist/index.d.ts +16 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +15 -0
  14. package/dist/loader/index.d.ts +80 -0
  15. package/dist/loader/index.d.ts.map +1 -0
  16. package/dist/loader/index.js +253 -0
  17. package/dist/parser/index.d.ts +24 -0
  18. package/dist/parser/index.d.ts.map +1 -0
  19. package/dist/parser/index.js +22 -0
  20. package/dist/parser/parse-document.d.ts +17 -0
  21. package/dist/parser/parse-document.d.ts.map +1 -0
  22. package/dist/parser/parse-document.js +219 -0
  23. package/dist/parser/parse-index.d.ts +31 -0
  24. package/dist/parser/parse-index.d.ts.map +1 -0
  25. package/dist/parser/parse-index.js +251 -0
  26. package/dist/parser/parse-task.d.ts +30 -0
  27. package/dist/parser/parse-task.d.ts.map +1 -0
  28. package/dist/parser/parse-task.js +261 -0
  29. package/dist/state/index.d.ts +307 -0
  30. package/dist/state/index.d.ts.map +1 -0
  31. package/dist/state/index.js +689 -0
  32. package/dist/templates/generator.d.ts +71 -0
  33. package/dist/templates/generator.d.ts.map +1 -0
  34. package/dist/templates/generator.js +723 -0
  35. package/dist/templates/index.d.ts +5 -0
  36. package/dist/templates/index.d.ts.map +1 -0
  37. package/dist/templates/index.js +4 -0
  38. package/dist/types/index.d.ts +131 -0
  39. package/dist/types/index.d.ts.map +1 -0
  40. package/dist/types/index.js +107 -0
  41. package/dist/validator/index.d.ts +83 -0
  42. package/dist/validator/index.d.ts.map +1 -0
  43. package/dist/validator/index.js +611 -0
  44. package/docs/APS-Anvil-Integration.md +750 -0
  45. package/docs/APS-Conventions.md +635 -0
  46. package/docs/APS-NonGoals.md +455 -0
  47. package/docs/APS-Planning-Spec-v0.1.md +362 -0
  48. package/examples/README.md +170 -0
  49. package/examples/feature-auth.aps.md +87 -0
  50. package/examples/refactor-error-handling.aps.md +119 -0
  51. package/examples/system-ecommerce/APS.md +57 -0
  52. package/examples/system-ecommerce/modules/auth.aps.md +38 -0
  53. package/examples/system-ecommerce/modules/cart.aps.md +53 -0
  54. package/examples/system-ecommerce/modules/payments.aps.md +68 -0
  55. package/examples/system-ecommerce/modules/products.aps.md +53 -0
  56. package/package.json +34 -0
  57. package/project.json +37 -0
  58. package/scripts/generate-templates.js +33 -0
  59. package/src/filter/context-bundle.ts +312 -0
  60. package/src/filter/filter.test.ts +317 -0
  61. package/src/filter/index.ts +249 -0
  62. package/src/index.ts +16 -0
  63. package/src/loader/index.ts +364 -0
  64. package/src/loader/loader.test.ts +224 -0
  65. package/src/parser/__fixtures__/invalid-task-id-not-padded.aps.md +7 -0
  66. package/src/parser/__fixtures__/invalid-task-id.aps.md +8 -0
  67. package/src/parser/__fixtures__/minimal-task.aps.md +7 -0
  68. package/src/parser/__fixtures__/non-scope-hyphenated.aps.md +10 -0
  69. package/src/parser/__fixtures__/simple-index.aps.md +35 -0
  70. package/src/parser/__fixtures__/simple-plan.aps.md +19 -0
  71. package/src/parser/index.ts +30 -0
  72. package/src/parser/parse-document.test.ts +603 -0
  73. package/src/parser/parse-document.ts +262 -0
  74. package/src/parser/parse-index.test.ts +316 -0
  75. package/src/parser/parse-index.ts +298 -0
  76. package/src/parser/parse-task.test.ts +476 -0
  77. package/src/parser/parse-task.ts +325 -0
  78. package/src/state/__fixtures__/invalid-plan.aps.md +9 -0
  79. package/src/state/__fixtures__/test-plan.aps.md +20 -0
  80. package/src/state/index.ts +879 -0
  81. package/src/state/state.test.ts +645 -0
  82. package/src/templates/generator.test.ts +378 -0
  83. package/src/templates/generator.ts +776 -0
  84. package/src/templates/index.ts +5 -0
  85. package/src/types/index.ts +168 -0
  86. package/src/validator/__fixtures__/broken-links.aps.md +10 -0
  87. package/src/validator/__fixtures__/circular-deps-index.aps.md +26 -0
  88. package/src/validator/__fixtures__/circular-modules/module-a.aps.md +9 -0
  89. package/src/validator/__fixtures__/circular-modules/module-b.aps.md +9 -0
  90. package/src/validator/__fixtures__/circular-modules/module-c.aps.md +9 -0
  91. package/src/validator/__fixtures__/dup-modules/module-a.aps.md +9 -0
  92. package/src/validator/__fixtures__/dup-modules/module-b.aps.md +9 -0
  93. package/src/validator/__fixtures__/duplicate-ids-index.aps.md +15 -0
  94. package/src/validator/__fixtures__/invalid-task-id.aps.md +17 -0
  95. package/src/validator/__fixtures__/missing-confidence.aps.md +9 -0
  96. package/src/validator/__fixtures__/missing-h1.aps.md +5 -0
  97. package/src/validator/__fixtures__/missing-intent.aps.md +9 -0
  98. package/src/validator/__fixtures__/missing-modules-section.aps.md +7 -0
  99. package/src/validator/__fixtures__/missing-tasks-section.aps.md +7 -0
  100. package/src/validator/__fixtures__/modules/auth.aps.md +17 -0
  101. package/src/validator/__fixtures__/modules/payments.aps.md +13 -0
  102. package/src/validator/__fixtures__/scope-mismatch.aps.md +14 -0
  103. package/src/validator/__fixtures__/valid-index.aps.md +24 -0
  104. package/src/validator/__fixtures__/valid-leaf.aps.md +22 -0
  105. package/src/validator/index.ts +776 -0
  106. package/src/validator/validator.test.ts +269 -0
  107. package/templates/index-full.md +94 -0
  108. package/templates/index-minimal.md +16 -0
  109. package/templates/index-template.md +63 -0
  110. package/templates/leaf-full.md +76 -0
  111. package/templates/leaf-minimal.md +14 -0
  112. package/templates/leaf-template.md +55 -0
  113. package/templates/simple-full.md +56 -0
  114. package/templates/simple-minimal.md +14 -0
  115. package/templates/simple-template.md +30 -0
  116. package/tsconfig.json +19 -0
  117. package/tsconfig.lib.json +14 -0
  118. package/tsconfig.lib.tsbuildinfo +1 -0
  119. package/tsconfig.spec.json +9 -0
  120. package/tsconfig.tsbuildinfo +1 -0
  121. package/vitest.config.ts +15 -0
@@ -0,0 +1,362 @@
1
+ # APS Planning Spec v0.1
2
+
3
+ > **Anvil Planning Spec (APS)** — A Markdown-based format for LLM-readable
4
+ > planning documents.
5
+
6
+ ## Overview
7
+
8
+ The Anvil Planning Spec (APS) defines a structured Markdown format for planning
9
+ documents that are:
10
+
11
+ - **Human-readable** — Plain Markdown, familiar conventions
12
+ - **LLM-friendly** — Structured with clear headings and key-value fields
13
+ - **Graph-aware** — Supports modular plans with dependencies
14
+ - **Execution-ready** — Bridges from planning to task execution
15
+
16
+ ### Design Goals
17
+
18
+ 1. **Single source of truth** — Planning docs are canonical, not derived
19
+ 2. **Separation of concerns** — Planning (source) vs Execution (derived state)
20
+ 3. **Validation-first** — Clear rules, early feedback
21
+ 4. **Scoped context** — LLMs see only what they need
22
+
23
+ ### Non-Goals
24
+
25
+ See [APS-NonGoals.md](./APS-NonGoals.md) for explicit non-goals.
26
+
27
+ ---
28
+
29
+ ## Document Types
30
+
31
+ APS supports two document types:
32
+
33
+ 1. **Leaf Spec** — Contains tasks for a single module or feature
34
+ 2. **Index File** — Organises multiple leaf specs into a plan graph
35
+
36
+ ### Single-File Plans
37
+
38
+ For simple plans, a single leaf spec is sufficient:
39
+
40
+ ```markdown
41
+ # Feature: User Authentication
42
+
43
+ **Scope:** AUTH **Owner:** @alice **Priority:** high
44
+
45
+ ## Tasks
46
+
47
+ ### AUTH-001: Implement login endpoint
48
+
49
+ ...
50
+ ```
51
+
52
+ ### Multi-File Plans
53
+
54
+ For complex plans, use an index file + leaf specs:
55
+
56
+ ```
57
+ docs/planning/
58
+ system.aps.md # Index file
59
+ modules/
60
+ auth.aps.md # Leaf spec
61
+ payments.aps.md # Leaf spec
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Index File Structure
67
+
68
+ Index files organise leaf specs and define module metadata.
69
+
70
+ ### Required Sections
71
+
72
+ #### `# [Plan Title]` (H1)
73
+
74
+ The plan title (H1 heading). Only one H1 per file.
75
+
76
+ #### `## Modules` (H2)
77
+
78
+ Lists modules with metadata. Each module is an H3 heading.
79
+
80
+ **Example:**
81
+
82
+ ```markdown
83
+ ## Modules
84
+
85
+ ### auth
86
+
87
+ - **Path:** [./modules/auth.aps.md](./modules/auth.aps.md)
88
+ - **Scope:** AUTH
89
+ - **Owner:** @alice
90
+ - **Priority:** high
91
+ - **Tags:** security, core
92
+ - **Dependencies:** (none)
93
+
94
+ ### payments
95
+
96
+ - **Path:** [./modules/payments.aps.md](./modules/payments.aps.md)
97
+ - **Scope:** PAY
98
+ - **Owner:** @bob
99
+ - **Priority:** medium
100
+ - **Tags:** billing, stripe
101
+ - **Dependencies:** auth
102
+ ```
103
+
104
+ ### Module Metadata Fields
105
+
106
+ | Field | Required | Format | Purpose |
107
+ | ----------------- | -------- | ---------------------------- | ----------------------- |
108
+ | **Path:** | Yes | Markdown link | Link to leaf spec file |
109
+ | **Scope:** | No | Uppercase prefix (e.g. AUTH) | Namespace for task IDs |
110
+ | **Owner:** | No | @username | Person/team responsible |
111
+ | **Priority:** | No | `low`, `medium`, `high` | Priority level |
112
+ | **Tags:** | No | Comma-separated list | Labels for filtering |
113
+ | **Dependencies:** | No | Comma-separated module IDs | Modules this depends on |
114
+
115
+ ### Optional Sections
116
+
117
+ - **`## Overview`** — High-level description
118
+ - **`## Open Questions`** — Unresolved questions
119
+ - **`## Decisions`** — Architectural decisions with dates
120
+
121
+ ---
122
+
123
+ ## Leaf Spec Structure
124
+
125
+ Leaf specs contain tasks for a single module or feature.
126
+
127
+ ### Required Sections
128
+
129
+ #### `# [Module Title]` (H1)
130
+
131
+ The module title (H1 heading). Only one H1 per file.
132
+
133
+ #### Module Metadata Line
134
+
135
+ Immediately after the H1, include scope/owner/priority:
136
+
137
+ ```markdown
138
+ # Authentication Module
139
+
140
+ **Scope:** AUTH **Owner:** @alice **Priority:** high
141
+ ```
142
+
143
+ #### `## Tasks` (H2)
144
+
145
+ Contains task definitions. Each task is an H3 heading.
146
+
147
+ ### Task Structure
148
+
149
+ Each task follows this format:
150
+
151
+ ```markdown
152
+ ### AUTH-001: Implement login endpoint
153
+
154
+ **Intent:** Create POST /auth/login endpoint that validates credentials and
155
+ returns JWT **Expected Outcome:** Working login endpoint with tests
156
+ **Confidence:** high **Scopes:** AUTH **Tags:** security, api **Dependencies:**
157
+ DB-001 **Inputs:**
158
+
159
+ - User credentials (email, password)
160
+ - Database connection
161
+
162
+ **Status:** open
163
+ ```
164
+
165
+ ### Task Fields
166
+
167
+ | Field | Required | Format | Purpose |
168
+ | --------------------- | -------- | ------------------------ | ------------------------------------- |
169
+ | **Intent:** | Yes | Single sentence | What the task aims to achieve |
170
+ | **Expected Outcome:** | No | Text | Success criteria |
171
+ | **Confidence:** | No | `low`, `medium`, `high` | Certainty about approach |
172
+ | **Scopes:** | No | Comma-separated prefixes | What can be changed (LLM constraints) |
173
+ | **Tags:** | No | Comma-separated labels | For filtering and search |
174
+ | **Dependencies:** | No | Comma-separated task IDs | Tasks that must complete first |
175
+ | **Inputs:** | No | Bulleted list | Required inputs or context |
176
+ | **Status:** | No | See status values below | Current execution state |
177
+
178
+ ### Task Status Values
179
+
180
+ | Status | Meaning |
181
+ | ----------- | --------------------------------------- |
182
+ | `open` | Not started (default) |
183
+ | `locked` | Being worked on (via `anvil plan lock`) |
184
+ | `completed` | Finished successfully |
185
+ | `cancelled` | Abandoned or no longer needed |
186
+
187
+ **Note:** Status is managed externally in `.anvil/state.json`, not in the
188
+ planning doc.
189
+
190
+ ### Task ID Format
191
+
192
+ Task IDs must follow the format: `<SCOPE>-<NUMBER>`
193
+
194
+ **Examples:**
195
+
196
+ - `AUTH-001` ✓
197
+ - `PAY-042` ✓
198
+ - `auth-001` ✗ (lowercase scope)
199
+ - `AUTH001` ✗ (missing hyphen)
200
+
201
+ Task IDs must be unique across the entire plan graph.
202
+
203
+ ### Optional Sections
204
+
205
+ - **`## Dependencies`** — Module-level dependencies
206
+ - **`## Notes`** — Additional context
207
+
208
+ ---
209
+
210
+ ## Conventions
211
+
212
+ See [APS-Conventions.md](./APS-Conventions.md) for detailed conventions on:
213
+
214
+ - File naming (`.aps.md` extension)
215
+ - Link rules (relative paths, in-repo only)
216
+ - ID uniqueness (error on duplicates)
217
+ - Heading hierarchy
218
+ - Root file discovery
219
+
220
+ ---
221
+
222
+ ## Scopes vs Tags
223
+
224
+ **Scopes** and **Tags** serve different purposes:
225
+
226
+ ### Scopes (Hard Boundaries)
227
+
228
+ Scopes define **what code/files can be changed** during task execution. They
229
+ constrain the LLM's operating context.
230
+
231
+ **Example:**
232
+
233
+ ```markdown
234
+ **Scopes:** AUTH, DB
235
+ ```
236
+
237
+ This means the LLM can only modify files in the `AUTH` and `DB` scopes.
238
+
239
+ ### Tags (Soft Labels)
240
+
241
+ Tags are labels for **filtering and search**. They don't constrain behaviour.
242
+
243
+ **Example:**
244
+
245
+ ```markdown
246
+ **Tags:** security, high-risk, needs-review
247
+ ```
248
+
249
+ This helps filter tasks but doesn't restrict what can be changed.
250
+
251
+ ---
252
+
253
+ ## Validation Rules
254
+
255
+ APS documents must pass validation before execution:
256
+
257
+ ### Errors (Blocking)
258
+
259
+ - Missing required sections (`## Modules`, `## Tasks`)
260
+ - Missing required fields (`Path:` in modules, `Intent:` in tasks)
261
+ - Invalid task ID format
262
+ - Duplicate task IDs across plan graph
263
+ - Broken links
264
+ - Circular module dependencies
265
+
266
+ ### Warnings (Non-blocking)
267
+
268
+ - Missing Confidence field
269
+ - Scope mismatch (task scope not in parent module scope)
270
+ - Orphan leaf specs (not referenced from index)
271
+
272
+ See Phase 6 implementation for full validation rules.
273
+
274
+ ---
275
+
276
+ ## Example: Simple Feature Plan
277
+
278
+ ```markdown
279
+ # Feature: User Authentication
280
+
281
+ **Scope:** AUTH **Owner:** @alice **Priority:** high
282
+
283
+ > Implement basic username/password authentication.
284
+
285
+ ## Tasks
286
+
287
+ ### AUTH-001: Create user model
288
+
289
+ **Intent:** Define User model with email, password hash, created_at **Expected
290
+ Outcome:** User model with validation and tests **Confidence:** high **Scopes:**
291
+ AUTH, DB **Tags:** models, database
292
+
293
+ ### AUTH-002: Implement login endpoint
294
+
295
+ **Intent:** Create POST /auth/login that validates credentials **Expected
296
+ Outcome:** Working endpoint with JWT generation **Confidence:** high **Scopes:**
297
+ AUTH **Tags:** api, security **Dependencies:** AUTH-001
298
+
299
+ ## Notes
300
+
301
+ - Consider OAuth in future iteration
302
+ ```
303
+
304
+ ---
305
+
306
+ ## Example: Multi-Module Plan
307
+
308
+ **Index file:** `docs/planning/system.aps.md`
309
+
310
+ ```markdown
311
+ # System: E-commerce Platform
312
+
313
+ ## Overview
314
+
315
+ Build core e-commerce functionality.
316
+
317
+ ## Modules
318
+
319
+ ### auth
320
+
321
+ - **Path:** [./modules/auth.aps.md](./modules/auth.aps.md)
322
+ - **Scope:** AUTH
323
+ - **Owner:** @alice
324
+ - **Priority:** high
325
+ - **Tags:** security, core
326
+
327
+ ### payments
328
+
329
+ - **Path:** [./modules/payments.aps.md](./modules/payments.aps.md)
330
+ - **Scope:** PAY
331
+ - **Owner:** @bob
332
+ - **Priority:** medium
333
+ - **Tags:** billing, stripe
334
+ - **Dependencies:** auth
335
+ ```
336
+
337
+ **Leaf file:** `docs/planning/modules/auth.aps.md`
338
+
339
+ ```markdown
340
+ # Authentication Module
341
+
342
+ **Scope:** AUTH **Owner:** @alice **Priority:** high
343
+
344
+ ## Tasks
345
+
346
+ ### AUTH-001: Implement login
347
+
348
+ **Intent:** Create login endpoint **Confidence:** high **Scopes:** AUTH
349
+ ```
350
+
351
+ ---
352
+
353
+ ## Integration with Anvil
354
+
355
+ See [APS-Anvil-Integration.md](./APS-Anvil-Integration.md) for how planning docs
356
+ become execution plans.
357
+
358
+ ---
359
+
360
+ ## Version History
361
+
362
+ - **v0.1** (2025-12-17) — Initial specification
@@ -0,0 +1,170 @@
1
+ # APS Examples
2
+
3
+ This directory contains example planning documents demonstrating different APS
4
+ patterns and use cases.
5
+
6
+ ## Examples Overview
7
+
8
+ ### 1. Feature Plan: User Authentication
9
+
10
+ **File:** `feature-auth.aps.md`
11
+
12
+ **Type:** Single-file plan
13
+
14
+ **Demonstrates:**
15
+
16
+ - Simple, self-contained feature plan
17
+ - Sequential task dependencies
18
+ - Clear task structure with Intent, Expected Outcome, Confidence
19
+ - Multi-scope tasks (AUTH + DB, AUTH + API)
20
+ - Module-level dependencies section
21
+ - Deferred work documented in Notes
22
+
23
+ **Use this as a template for:** Small to medium features with clear scope
24
+
25
+ ---
26
+
27
+ ### 2. System Plan: E-commerce Platform MVP
28
+
29
+ **Files:** `system-ecommerce/APS.md` + `modules/*.aps.md`
30
+
31
+ **Type:** Multi-file plan (index + 4 leaf specs)
32
+
33
+ **Demonstrates:**
34
+
35
+ - Large system broken into modules
36
+ - Index file with module metadata (Scope, Owner, Priority, Tags, Dependencies)
37
+ - Module dependency graph (auth → products → cart → payments)
38
+ - Open Questions section in index
39
+ - Decisions section with dates
40
+ - Different confidence levels across tasks
41
+ - Cross-module dependencies between tasks
42
+
43
+ **Modules:**
44
+
45
+ - `auth.aps.md` — Authentication (3 tasks, high confidence)
46
+ - `products.aps.md` — Product catalog (5 tasks, mixed confidence)
47
+ - `cart.aps.md` — Shopping cart (5 tasks, medium confidence with open questions)
48
+ - `payments.aps.md` — Stripe payments (6 tasks, includes low confidence task)
49
+
50
+ **Use this as a template for:** Large systems with multiple modules and team
51
+ ownership
52
+
53
+ ---
54
+
55
+ ### 3. Refactor Plan: API Error Handling
56
+
57
+ **File:** `refactor-error-handling.aps.md`
58
+
59
+ **Type:** Single-file plan
60
+
61
+ **Demonstrates:**
62
+
63
+ - Refactoring with uncertainty (low/medium/high confidence mix)
64
+ - Multi-scope tasks across many modules (API, AUTH, PROD, CART, PAY, INFRA,
65
+ DOCS)
66
+ - Research/audit tasks (API-001 with low confidence)
67
+ - Design tasks before implementation
68
+ - Multiple parallel refactor tasks (API-005 through API-008)
69
+ - Open questions documenting unknowns
70
+ - Notes about rollout strategy and considerations
71
+
72
+ **Confidence distribution:**
73
+
74
+ - Low: 3 tasks (audit, monitoring integration, unknowns)
75
+ - Medium: 4 tasks (design, implementation with dependencies on external systems)
76
+ - High: 4 tasks (clear implementation with established patterns)
77
+
78
+ **Use this as a template for:** Technical debt, refactoring, infrastructure work
79
+ with unknowns
80
+
81
+ ---
82
+
83
+ ## Key Patterns Demonstrated
84
+
85
+ ### Task Structure
86
+
87
+ All examples show proper task formatting:
88
+
89
+ ```markdown
90
+ ### SCOPE-001: Task title
91
+
92
+ **Intent:** What the task achieves **Expected Outcome:** Success criteria
93
+ **Confidence:** low|medium|high **Scopes:** SCOPE1, SCOPE2 **Tags:** tag1, tag2
94
+ **Dependencies:** SCOPE-XXX **Inputs:**
95
+
96
+ - Required input 1
97
+ ```
98
+
99
+ ### Confidence Levels
100
+
101
+ - **High:** Well-understood, clear path (most tasks in feature-auth)
102
+ - **Medium:** Generally clear with some unknowns (cart pricing, payment
103
+ webhooks)
104
+ - **Low:** Uncertain approach, needs exploration (error audit, monitoring
105
+ integration)
106
+
107
+ ### Multi-Scope Tasks
108
+
109
+ Tasks that touch multiple areas use comma-separated scopes:
110
+
111
+ ```markdown
112
+ **Scopes:** AUTH, DB, API
113
+ ```
114
+
115
+ ### Dependencies
116
+
117
+ - **Module dependencies:** In index file under each module
118
+ - **Task dependencies:** In task metadata with IDs
119
+
120
+ ### Deferred Work
121
+
122
+ All examples document out-of-scope items in Notes:
123
+
124
+ - "OAuth integration deferred"
125
+ - "Image upload deferred to separate module"
126
+ - "Refunds deferred to phase 2"
127
+
128
+ ---
129
+
130
+ ## Using These Examples
131
+
132
+ ### As Learning Material
133
+
134
+ 1. Read `feature-auth.aps.md` first for basic structure
135
+ 2. Explore `system-ecommerce/` for multi-module plans
136
+ 3. Study `refactor-error-handling.aps.md` for uncertainty handling
137
+
138
+ ### As Templates
139
+
140
+ 1. Copy the example closest to your use case
141
+ 2. Replace scope prefixes with your own
142
+ 3. Update tasks to match your requirements
143
+ 4. Adjust confidence based on your knowledge
144
+
145
+ ### For Validation Testing
146
+
147
+ These examples can be used to test the APS validator:
148
+
149
+ - All should pass structural validation
150
+ - All should have valid task ID formats
151
+ - All should have resolvable links (in system-ecommerce)
152
+
153
+ ---
154
+
155
+ ## File Naming Conventions
156
+
157
+ - **Single-file plans:** `[type]-[name].aps.md` (e.g., `feature-auth.aps.md`)
158
+ - **Multi-file plans:** `[name]/APS.md` as index, `modules/*.aps.md` as leaf
159
+ specs
160
+
161
+ ---
162
+
163
+ ## Next Steps
164
+
165
+ After exploring these examples:
166
+
167
+ 1. Read the [APS Planning Spec](../docs/APS-Planning-Spec-v0.1.md) for full
168
+ format details
169
+ 2. Check [APS Conventions](../docs/APS-Conventions.md) for detailed rules
170
+ 3. Use the template generator: `pnpm generate-templates`
@@ -0,0 +1,87 @@
1
+ # Feature: User Authentication
2
+
3
+ **Scope:** AUTH **Owner:** @alice **Priority:** high
4
+
5
+ > Implement basic username/password authentication with JWT tokens for the
6
+ > e-commerce platform.
7
+
8
+ ## Tasks
9
+
10
+ ### AUTH-001: Create user database model
11
+
12
+ **Intent:** Define User model with email, password hash, and timestamps
13
+ **Expected Outcome:** User model with validation, migrations, and unit tests
14
+ **Confidence:** high **Scopes:** AUTH, DB **Tags:** database, models, security
15
+ **Inputs:**
16
+
17
+ - Database connection configuration
18
+ - Password hashing library (bcrypt)
19
+
20
+ ### AUTH-002: Implement password hashing service
21
+
22
+ **Intent:** Create service for secure password hashing and verification using
23
+ bcrypt **Expected Outcome:** Service with hash() and verify() methods, tested
24
+ with edge cases **Confidence:** high **Scopes:** AUTH **Tags:** security,
25
+ services **Dependencies:** AUTH-001
26
+
27
+ ### AUTH-003: Create registration endpoint
28
+
29
+ **Intent:** Implement POST /auth/register endpoint that validates input and
30
+ creates user accounts **Expected Outcome:** Working endpoint that returns 201
31
+ with user data (excluding password) **Confidence:** high **Scopes:** AUTH, API
32
+ **Tags:** api, endpoints **Dependencies:** AUTH-001, AUTH-002 **Inputs:**
33
+
34
+ - Email validation rules
35
+ - Password strength requirements (min 8 chars, 1 uppercase, 1 number, 1 special)
36
+
37
+ ### AUTH-004: Implement JWT token generation
38
+
39
+ **Intent:** Create service for generating and signing JWT tokens with user
40
+ claims **Expected Outcome:** Service that generates tokens with configurable
41
+ expiry (default 24h) **Confidence:** high **Scopes:** AUTH **Tags:** security,
42
+ jwt, tokens **Inputs:**
43
+
44
+ - JWT secret from environment variables
45
+ - Token expiry configuration
46
+
47
+ ### AUTH-005: Create login endpoint
48
+
49
+ **Intent:** Implement POST /auth/login that validates credentials and returns
50
+ JWT token **Expected Outcome:** Working endpoint that returns 200 with token on
51
+ success, 401 on failure **Confidence:** high **Scopes:** AUTH, API **Tags:**
52
+ api, endpoints, security **Dependencies:** AUTH-001, AUTH-002, AUTH-004
53
+
54
+ ### AUTH-006: Add authentication middleware
55
+
56
+ **Intent:** Create Express middleware that validates JWT tokens and attaches
57
+ user to request **Expected Outcome:** Middleware that protects routes, returns
58
+ 401 for invalid/missing tokens **Confidence:** high **Scopes:** AUTH, API
59
+ **Tags:** middleware, security **Dependencies:** AUTH-004
60
+
61
+ ### AUTH-007: Implement logout endpoint
62
+
63
+ **Intent:** Create POST /auth/logout endpoint that invalidates current token
64
+ **Expected Outcome:** Endpoint that adds token to blacklist and returns 200
65
+ **Confidence:** medium **Scopes:** AUTH, CACHE **Tags:** api, endpoints
66
+ **Dependencies:** AUTH-006 **Inputs:**
67
+
68
+ - Redis connection for token blacklist
69
+
70
+ ### AUTH-008: Add integration tests
71
+
72
+ **Intent:** Create end-to-end tests covering full authentication flow **Expected
73
+ Outcome:** Test suite covering register → login → authenticated request → logout
74
+ **Confidence:** high **Scopes:** AUTH, API **Tags:** testing, integration
75
+ **Dependencies:** AUTH-003, AUTH-005, AUTH-007
76
+
77
+ ## Dependencies
78
+
79
+ - Database connection and migrations system (assumed existing)
80
+ - Redis for token blacklist (AUTH-007)
81
+
82
+ ## Notes
83
+
84
+ - Consider OAuth integration in future iteration (Google, GitHub)
85
+ - Email verification not in scope for this iteration
86
+ - Password reset flow deferred to separate feature plan
87
+ - Rate limiting should be added to login/register endpoints (separate task)