specweave 0.21.3 → 0.22.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 (235) hide show
  1. package/CLAUDE.md +409 -6
  2. package/README.md +38 -8
  3. package/bin/specweave.js +5 -8
  4. package/dist/plugins/specweave-github/lib/CodeValidator.d.ts +101 -0
  5. package/dist/plugins/specweave-github/lib/CodeValidator.d.ts.map +1 -0
  6. package/dist/plugins/specweave-github/lib/CodeValidator.js +219 -0
  7. package/dist/plugins/specweave-github/lib/CodeValidator.js.map +1 -0
  8. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.d.ts +182 -0
  9. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.d.ts.map +1 -0
  10. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.js +603 -0
  11. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.js.map +1 -0
  12. package/dist/plugins/specweave-github/lib/github-client-v2.d.ts +10 -0
  13. package/dist/plugins/specweave-github/lib/github-client-v2.d.ts.map +1 -1
  14. package/dist/plugins/specweave-github/lib/github-client-v2.js +26 -0
  15. package/dist/plugins/specweave-github/lib/github-client-v2.js.map +1 -1
  16. package/dist/plugins/specweave-github/lib/task-sync.d.ts.map +1 -1
  17. package/dist/plugins/specweave-github/lib/task-sync.js +7 -0
  18. package/dist/plugins/specweave-github/lib/task-sync.js.map +1 -1
  19. package/dist/plugins/specweave-github/lib/types.d.ts +34 -0
  20. package/dist/plugins/specweave-github/lib/types.d.ts.map +1 -1
  21. package/dist/src/cli/commands/init.d.ts.map +1 -1
  22. package/dist/src/cli/commands/init.js +60 -5
  23. package/dist/src/cli/commands/init.js.map +1 -1
  24. package/dist/src/cli/commands/migrate-to-profiles.d.ts +1 -0
  25. package/dist/src/cli/commands/migrate-to-profiles.d.ts.map +1 -1
  26. package/dist/src/cli/commands/migrate-to-profiles.js +12 -1
  27. package/dist/src/cli/commands/migrate-to-profiles.js.map +1 -1
  28. package/dist/src/cli/commands/next-command.d.ts +52 -0
  29. package/dist/src/cli/commands/next-command.d.ts.map +1 -0
  30. package/dist/src/cli/commands/next-command.js +204 -0
  31. package/dist/src/cli/commands/next-command.js.map +1 -0
  32. package/dist/src/cli/commands/sync-specs.d.ts +16 -0
  33. package/dist/src/cli/commands/sync-specs.d.ts.map +1 -0
  34. package/dist/src/cli/commands/sync-specs.js +130 -0
  35. package/dist/src/cli/commands/sync-specs.js.map +1 -0
  36. package/dist/src/cli/count-tasks.d.ts +20 -0
  37. package/dist/src/cli/count-tasks.d.ts.map +1 -0
  38. package/dist/src/cli/count-tasks.js +50 -0
  39. package/dist/src/cli/count-tasks.js.map +1 -0
  40. package/dist/src/config/ConfigManager.d.ts.map +1 -1
  41. package/dist/src/config/ConfigManager.js +2 -1
  42. package/dist/src/config/ConfigManager.js.map +1 -1
  43. package/dist/src/config/types.d.ts +58 -58
  44. package/dist/src/core/cicd/state-manager.d.ts +8 -0
  45. package/dist/src/core/cicd/state-manager.d.ts.map +1 -1
  46. package/dist/src/core/cicd/state-manager.js +60 -15
  47. package/dist/src/core/cicd/state-manager.js.map +1 -1
  48. package/dist/src/core/cost-tracker.d.ts.map +1 -1
  49. package/dist/src/core/cost-tracker.js +2 -1
  50. package/dist/src/core/cost-tracker.js.map +1 -1
  51. package/dist/src/core/iac/template-engine.d.ts.map +1 -1
  52. package/dist/src/core/iac/template-engine.js +28 -0
  53. package/dist/src/core/iac/template-engine.js.map +1 -1
  54. package/dist/src/core/iac/template-generator.d.ts +53 -0
  55. package/dist/src/core/iac/template-generator.d.ts.map +1 -0
  56. package/dist/src/core/iac/template-generator.js +125 -0
  57. package/dist/src/core/iac/template-generator.js.map +1 -0
  58. package/dist/src/core/increment/status-auto-transition.js +3 -3
  59. package/dist/src/core/increment/status-auto-transition.js.map +1 -1
  60. package/dist/src/core/living-docs/CodeValidator.js +1 -1
  61. package/dist/src/core/living-docs/CodeValidator.js.map +1 -1
  62. package/dist/src/core/living-docs/CompletionPropagator.d.ts.map +1 -1
  63. package/dist/src/core/living-docs/CompletionPropagator.js +4 -3
  64. package/dist/src/core/living-docs/CompletionPropagator.js.map +1 -1
  65. package/dist/src/core/living-docs/SpecDistributor.d.ts +5 -0
  66. package/dist/src/core/living-docs/SpecDistributor.d.ts.map +1 -1
  67. package/dist/src/core/living-docs/SpecDistributor.js +12 -0
  68. package/dist/src/core/living-docs/SpecDistributor.js.map +1 -1
  69. package/dist/src/core/living-docs/content-distributor.d.ts.map +1 -1
  70. package/dist/src/core/living-docs/content-distributor.js +11 -1
  71. package/dist/src/core/living-docs/content-distributor.js.map +1 -1
  72. package/dist/src/core/living-docs/living-docs-sync.d.ts +166 -0
  73. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -0
  74. package/dist/src/core/living-docs/living-docs-sync.js +726 -0
  75. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -0
  76. package/dist/src/core/living-docs/project-detector.d.ts.map +1 -1
  77. package/dist/src/core/living-docs/project-detector.js +38 -0
  78. package/dist/src/core/living-docs/project-detector.js.map +1 -1
  79. package/dist/src/core/living-docs/task-project-specific-generator.d.ts +7 -3
  80. package/dist/src/core/living-docs/task-project-specific-generator.d.ts.map +1 -1
  81. package/dist/src/core/living-docs/task-project-specific-generator.js +40 -24
  82. package/dist/src/core/living-docs/task-project-specific-generator.js.map +1 -1
  83. package/dist/src/core/plugin-loader.d.ts +7 -0
  84. package/dist/src/core/plugin-loader.d.ts.map +1 -1
  85. package/dist/src/core/plugin-loader.js +18 -1
  86. package/dist/src/core/plugin-loader.js.map +1 -1
  87. package/dist/src/core/serverless/platform-data-loader.d.ts +8 -0
  88. package/dist/src/core/serverless/platform-data-loader.d.ts.map +1 -1
  89. package/dist/src/core/serverless/platform-data-loader.js +14 -0
  90. package/dist/src/core/serverless/platform-data-loader.js.map +1 -1
  91. package/dist/src/core/serverless/types.d.ts +1 -1
  92. package/dist/src/core/serverless/types.d.ts.map +1 -1
  93. package/dist/src/core/status-line/status-line-manager.d.ts +6 -2
  94. package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
  95. package/dist/src/core/status-line/status-line-manager.js +11 -5
  96. package/dist/src/core/status-line/status-line-manager.js.map +1 -1
  97. package/dist/src/core/status-line/task-counter.d.ts +69 -0
  98. package/dist/src/core/status-line/task-counter.d.ts.map +1 -0
  99. package/dist/src/core/status-line/task-counter.js +107 -0
  100. package/dist/src/core/status-line/task-counter.js.map +1 -0
  101. package/dist/src/core/types/config.d.ts +23 -0
  102. package/dist/src/core/types/config.d.ts.map +1 -1
  103. package/dist/src/core/types/config.js +10 -0
  104. package/dist/src/core/types/config.js.map +1 -1
  105. package/dist/src/core/workflow/autonomous-executor.d.ts +111 -0
  106. package/dist/src/core/workflow/autonomous-executor.d.ts.map +1 -0
  107. package/dist/src/core/workflow/autonomous-executor.js +275 -0
  108. package/dist/src/core/workflow/autonomous-executor.js.map +1 -0
  109. package/dist/src/core/workflow/backlog-scanner.d.ts +94 -0
  110. package/dist/src/core/workflow/backlog-scanner.d.ts.map +1 -0
  111. package/dist/src/core/workflow/backlog-scanner.js +170 -0
  112. package/dist/src/core/workflow/backlog-scanner.js.map +1 -0
  113. package/dist/src/core/workflow/command-invoker.d.ts +86 -0
  114. package/dist/src/core/workflow/command-invoker.d.ts.map +1 -0
  115. package/dist/src/core/workflow/command-invoker.js +131 -0
  116. package/dist/src/core/workflow/command-invoker.js.map +1 -0
  117. package/dist/src/core/workflow/cost-estimator.d.ts +120 -0
  118. package/dist/src/core/workflow/cost-estimator.d.ts.map +1 -0
  119. package/dist/src/core/workflow/cost-estimator.js +222 -0
  120. package/dist/src/core/workflow/cost-estimator.js.map +1 -0
  121. package/dist/src/core/workflow/index.d.ts +20 -0
  122. package/dist/src/core/workflow/index.d.ts.map +1 -0
  123. package/dist/src/core/workflow/index.js +24 -0
  124. package/dist/src/core/workflow/index.js.map +1 -0
  125. package/dist/src/core/workflow/state-manager.d.ts +107 -0
  126. package/dist/src/core/workflow/state-manager.d.ts.map +1 -0
  127. package/dist/src/core/workflow/state-manager.js +126 -0
  128. package/dist/src/core/workflow/state-manager.js.map +1 -0
  129. package/dist/src/core/workflow/workflow-orchestrator.d.ts +93 -0
  130. package/dist/src/core/workflow/workflow-orchestrator.d.ts.map +1 -0
  131. package/dist/src/core/workflow/workflow-orchestrator.js +195 -0
  132. package/dist/src/core/workflow/workflow-orchestrator.js.map +1 -0
  133. package/dist/src/init/ArchitecturePresenter.d.ts +47 -0
  134. package/dist/src/init/ArchitecturePresenter.d.ts.map +1 -0
  135. package/dist/src/init/ArchitecturePresenter.js +180 -0
  136. package/dist/src/init/ArchitecturePresenter.js.map +1 -0
  137. package/dist/src/init/InitFlow.d.ts.map +1 -1
  138. package/dist/src/init/InitFlow.js +30 -1
  139. package/dist/src/init/InitFlow.js.map +1 -1
  140. package/dist/src/init/architecture/CostEstimator.d.ts +52 -0
  141. package/dist/src/init/architecture/CostEstimator.d.ts.map +1 -0
  142. package/dist/src/init/architecture/CostEstimator.js +107 -0
  143. package/dist/src/init/architecture/CostEstimator.js.map +1 -0
  144. package/dist/src/init/architecture/InfrastructureMapper.d.ts +41 -0
  145. package/dist/src/init/architecture/InfrastructureMapper.d.ts.map +1 -0
  146. package/dist/src/init/architecture/InfrastructureMapper.js +140 -0
  147. package/dist/src/init/architecture/InfrastructureMapper.js.map +1 -0
  148. package/dist/src/init/architecture/ProjectGenerator.d.ts +44 -0
  149. package/dist/src/init/architecture/ProjectGenerator.d.ts.map +1 -0
  150. package/dist/src/init/architecture/ProjectGenerator.js +216 -0
  151. package/dist/src/init/architecture/ProjectGenerator.js.map +1 -0
  152. package/dist/src/init/architecture/types.d.ts +10 -10
  153. package/dist/src/init/research/src/config/types.d.ts +8 -8
  154. package/dist/src/metrics/dora-calculator.js +2 -2
  155. package/dist/src/metrics/dora-calculator.js.map +1 -1
  156. package/dist/src/utils/pricing-constants.d.ts +5 -2
  157. package/dist/src/utils/pricing-constants.d.ts.map +1 -1
  158. package/dist/src/utils/pricing-constants.js +3 -2
  159. package/dist/src/utils/pricing-constants.js.map +1 -1
  160. package/package.json +9 -8
  161. package/plugins/specweave/agents/infrastructure/AGENT.md +88 -46
  162. package/plugins/specweave/agents/pm/AGENT.md +58 -1
  163. package/plugins/specweave/commands/specweave-archive-features.md +1 -1
  164. package/plugins/specweave/commands/specweave-archive-increments.md +1 -1
  165. package/plugins/specweave/commands/specweave-check-hooks.md +5 -0
  166. package/plugins/specweave/commands/specweave-done.md +12 -0
  167. package/plugins/specweave/commands/specweave-plan.md +1 -1
  168. package/plugins/specweave/commands/specweave-progress.md +108 -379
  169. package/plugins/specweave/commands/specweave-reopen.md +1 -1
  170. package/plugins/specweave/commands/specweave-restore-feature.md +1 -1
  171. package/plugins/specweave/commands/specweave-sync-specs.md +20 -48
  172. package/plugins/specweave/hooks/lib/update-status-line.sh +44 -35
  173. package/plugins/specweave/hooks/lib/validate-spec-status.sh +163 -0
  174. package/plugins/specweave/hooks/user-prompt-submit.sh +17 -35
  175. package/plugins/specweave/lib/hooks/update-tasks-md.js +52 -9
  176. package/plugins/specweave/lib/hooks/update-tasks-md.ts +77 -16
  177. package/plugins/specweave/templates/iac/aws-lambda/defaults.json +24 -0
  178. package/plugins/specweave/templates/iac/aws-lambda/templates/README.md.hbs +260 -0
  179. package/plugins/specweave/templates/iac/aws-lambda/templates/environments/dev.tfvars.hbs +34 -0
  180. package/plugins/specweave/templates/iac/aws-lambda/templates/environments/prod.tfvars.hbs +37 -0
  181. package/plugins/specweave/templates/iac/aws-lambda/templates/environments/staging.tfvars.hbs +35 -0
  182. package/plugins/specweave/templates/iac/aws-lambda/templates/outputs.tf.hbs +77 -0
  183. package/plugins/specweave/templates/iac/aws-lambda/templates/providers.tf.hbs +36 -0
  184. package/plugins/specweave/templates/iac/aws-lambda/templates/variables.tf.hbs +115 -0
  185. package/plugins/specweave/templates/iac/azure-functions/defaults.json +25 -0
  186. package/plugins/specweave/templates/iac/azure-functions/templates/README.md.hbs +268 -0
  187. package/plugins/specweave/templates/iac/azure-functions/templates/environments/dev.tfvars.hbs +34 -0
  188. package/plugins/specweave/templates/iac/azure-functions/templates/environments/prod.tfvars.hbs +46 -0
  189. package/plugins/specweave/templates/iac/azure-functions/templates/environments/staging.tfvars.hbs +34 -0
  190. package/plugins/specweave/templates/iac/azure-functions/templates/main.tf.hbs +225 -0
  191. package/plugins/specweave/templates/iac/azure-functions/templates/outputs.tf.hbs +89 -0
  192. package/plugins/specweave/templates/iac/azure-functions/templates/provider.tf.hbs +27 -0
  193. package/plugins/specweave/templates/iac/azure-functions/templates/providers.tf.hbs +35 -0
  194. package/plugins/specweave/templates/iac/azure-functions/templates/variables.tf.hbs +124 -0
  195. package/plugins/specweave/templates/iac/firebase/defaults.json +29 -0
  196. package/plugins/specweave/templates/iac/firebase/templates/README.md.hbs +35 -0
  197. package/plugins/specweave/templates/iac/firebase/templates/environments/dev.tfvars.hbs +7 -0
  198. package/plugins/specweave/templates/iac/firebase/templates/environments/prod.tfvars.hbs +7 -0
  199. package/plugins/specweave/templates/iac/firebase/templates/environments/staging.tfvars.hbs +7 -0
  200. package/plugins/specweave/templates/iac/firebase/templates/main.tf.hbs +90 -0
  201. package/plugins/specweave/templates/iac/firebase/templates/outputs.tf.hbs +15 -0
  202. package/plugins/specweave/templates/iac/firebase/templates/providers.tf.hbs +23 -0
  203. package/plugins/specweave/templates/iac/firebase/templates/variables.tf.hbs +42 -0
  204. package/plugins/specweave/templates/iac/gcp-cloud-functions/defaults.json +26 -0
  205. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/README.md.hbs +299 -0
  206. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/dev.tfvars.hbs +36 -0
  207. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/prod.tfvars.hbs +48 -0
  208. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/staging.tfvars.hbs +41 -0
  209. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/main.tf.hbs +192 -0
  210. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/outputs.tf.hbs +66 -0
  211. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/providers.tf.hbs +25 -0
  212. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/variables.tf.hbs +119 -0
  213. package/plugins/specweave/templates/iac/supabase/defaults.json +15 -0
  214. package/plugins/specweave/templates/iac/supabase/templates/README.md.hbs +46 -0
  215. package/plugins/specweave/templates/iac/supabase/templates/main.tf.hbs +50 -0
  216. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +170 -0
  217. package/plugins/specweave-github/agents/github-manager/AGENT.md +39 -7
  218. package/plugins/specweave-github/commands/specweave-github-create-issue.md +5 -5
  219. package/plugins/specweave-github/lib/CodeValidator.js +195 -0
  220. package/plugins/specweave-github/lib/CodeValidator.ts +284 -0
  221. package/plugins/specweave-github/lib/ThreeLayerSyncManager.js +545 -0
  222. package/plugins/specweave-github/lib/ThreeLayerSyncManager.ts +809 -0
  223. package/plugins/specweave-github/lib/github-client-v2.js +29 -0
  224. package/plugins/specweave-github/lib/github-client-v2.ts +30 -0
  225. package/plugins/specweave-github/lib/task-sync.js +4 -0
  226. package/plugins/specweave-github/lib/task-sync.ts +7 -0
  227. package/plugins/specweave-github/lib/types.ts +38 -0
  228. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  229. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +3222 -0
  230. package/src/templates/AGENTS.md.template +22 -1
  231. package/src/templates/CLAUDE.md.template +31 -0
  232. package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts +0 -116
  233. package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts.map +0 -1
  234. package/dist/src/core/living-docs/ThreeLayerSyncManager.js +0 -356
  235. package/dist/src/core/living-docs/ThreeLayerSyncManager.js.map +0 -1
@@ -0,0 +1,115 @@
1
+ # Input Variables for AWS Lambda + API Gateway + DynamoDB
2
+ # Generated by SpecWeave Serverless Architecture Intelligence
3
+
4
+ variable "aws_region" {
5
+ description = "AWS region for all resources"
6
+ type = string
7
+ default = "{{region}}"
8
+ }
9
+
10
+ variable "function_name" {
11
+ description = "Lambda function name"
12
+ type = string
13
+ default = "{{functionName}}"
14
+ }
15
+
16
+ variable "runtime" {
17
+ description = "Lambda runtime (nodejs20.x, python3.12, etc.)"
18
+ type = string
19
+ default = "{{runtime}}"
20
+ }
21
+
22
+ variable "memory_size" {
23
+ description = "Lambda memory size in MB (128-10240)"
24
+ type = number
25
+ default = {{memorySize}}
26
+ }
27
+
28
+ variable "timeout" {
29
+ description = "Lambda timeout in seconds (1-900)"
30
+ type = number
31
+ default = {{timeout}}
32
+ }
33
+
34
+ variable "environment" {
35
+ description = "Environment name (dev, staging, prod)"
36
+ type = string
37
+ default = "{{environment}}"
38
+ }
39
+
40
+ variable "handler" {
41
+ description = "Lambda function handler"
42
+ type = string
43
+ default = "{{handler}}"
44
+ }
45
+
46
+ variable "database_name" {
47
+ description = "DynamoDB table name"
48
+ type = string
49
+ default = "{{databaseName}}"
50
+ }
51
+
52
+ variable "primary_key" {
53
+ description = "DynamoDB primary key (partition key)"
54
+ type = string
55
+ default = "{{primaryKey}}"
56
+ }
57
+
58
+ {{#if sortKey}}
59
+ variable "sort_key" {
60
+ description = "DynamoDB sort key (range key)"
61
+ type = string
62
+ default = "{{sortKey}}"
63
+ }
64
+ {{/if}}
65
+
66
+ variable "log_retention_days" {
67
+ description = "CloudWatch Logs retention in days"
68
+ type = number
69
+ default = {{logRetentionDays}}
70
+ }
71
+
72
+ variable "cors_origins" {
73
+ description = "List of allowed CORS origins for API Gateway"
74
+ type = list(string)
75
+ default = {{tfList corsOrigins}}
76
+ }
77
+
78
+ {{#if enableVpc}}
79
+ variable "vpc_id" {
80
+ description = "VPC ID for Lambda function (if VPC enabled)"
81
+ type = string
82
+ }
83
+
84
+ variable "subnet_ids" {
85
+ description = "Subnet IDs for Lambda function (if VPC enabled)"
86
+ type = list(string)
87
+ }
88
+ {{/if}}
89
+
90
+ {{#if enableSecretsManager}}
91
+ variable "secrets_manager_arns" {
92
+ description = "ARNs of Secrets Manager secrets to access"
93
+ type = list(string)
94
+ default = []
95
+ }
96
+ {{/if}}
97
+
98
+ {{#if enableKms}}
99
+ variable "kms_key_arn" {
100
+ description = "KMS key ARN for encryption"
101
+ type = string
102
+ }
103
+ {{/if}}
104
+
105
+ variable "project_name" {
106
+ description = "Project name for resource tagging"
107
+ type = string
108
+ default = "{{projectName}}"
109
+ }
110
+
111
+ variable "tags" {
112
+ description = "Additional tags for all resources"
113
+ type = map(string)
114
+ default = {}
115
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "location": "eastus",
3
+ "resourceGroupName": "my-functions-rg",
4
+ "functionName": "my-function-app",
5
+ "runtime": "node",
6
+ "runtimeVersion": "20",
7
+ "osType": "linux",
8
+ "skuName": "Y1",
9
+ "environment": "dev",
10
+ "databaseAccountName": "my-cosmosdb-account",
11
+ "databaseName": "my-database",
12
+ "containerName": "my-container",
13
+ "partitionKey": "/id",
14
+ "throughput": 400,
15
+ "corsOrigins": ["*"],
16
+ "projectName": "my-project",
17
+ "enableApplicationInsights": true,
18
+ "enableKeyVault": false,
19
+ "enableVnet": false,
20
+ "enableBackup": false,
21
+ "enableAutomaticFailover": false,
22
+ "enableMultiRegion": false,
23
+ "storageAccountTier": "Standard",
24
+ "storageAccountReplication": "LRS"
25
+ }
@@ -0,0 +1,268 @@
1
+ # Azure Functions + Cosmos DB Terraform Configuration
2
+
3
+ **Generated by SpecWeave Serverless Architecture Intelligence**
4
+
5
+ This Terraform configuration deploys:
6
+ - Azure Function App ({{runtime}} {{runtimeVersion}} on {{osType}})
7
+ - Azure Cosmos DB (SQL API)
8
+ - Azure Storage Account (required for Function App)
9
+ - App Service Plan ({{skuName}} SKU)
10
+ {{#if enableApplicationInsights}}- Application Insights for monitoring{{/if}}
11
+ {{#if enableKeyVault}}- Azure Key Vault for secrets management{{/if}}
12
+
13
+ ## Architecture
14
+
15
+ ```
16
+ Azure Function App ({{functionName}})
17
+ ├── Runtime: {{runtime}} {{runtimeVersion}}
18
+ ├── Plan: {{skuName}} ({{#if (eq skuName "Y1")}}Consumption{{else}}Premium{{/if}})
19
+ └── Storage: {{functionName}}storage
20
+
21
+ Cosmos DB ({{databaseAccountName}})
22
+ ├── Database: {{databaseName}}
23
+ ├── Container: {{containerName}}
24
+ ├── Partition Key: {{partitionKey}}
25
+ └── Throughput: {{throughput}} RU/s
26
+
27
+ {{#if enableApplicationInsights}}
28
+ Application Insights ({{functionName}}-insights)
29
+ └── Type: web
30
+ {{/if}}
31
+
32
+ {{#if enableKeyVault}}
33
+ Key Vault ({{functionName}}-kv)
34
+ └── Secrets: Managed by Function App identity
35
+ {{/if}}
36
+ ```
37
+
38
+ ## Prerequisites
39
+
40
+ 1. **Azure CLI** installed and authenticated:
41
+ ```bash
42
+ az login
43
+ az account set --subscription "YOUR_SUBSCRIPTION_ID"
44
+ ```
45
+
46
+ 2. **Terraform** v1.5.0+ installed:
47
+ ```bash
48
+ terraform version
49
+ ```
50
+
51
+ 3. **Function App code** ready to deploy:
52
+ - Node.js: `package.json`, `index.js`, etc.
53
+ - Python: `requirements.txt`, `__init__.py`, etc.
54
+
55
+ ## Deployment Instructions
56
+
57
+ ### 1. Initialize Terraform
58
+
59
+ ```bash
60
+ terraform init
61
+ ```
62
+
63
+ ### 2. Review the Plan
64
+
65
+ ```bash
66
+ terraform plan
67
+ ```
68
+
69
+ **Expected resources**: ~{{#if enableKeyVault}}10{{else if enableApplicationInsights}}8{{else}}6{{/if}} resources will be created
70
+
71
+ ### 3. Deploy Infrastructure
72
+
73
+ **Development**:
74
+ ```bash
75
+ terraform apply -var-file="environments/dev.tfvars"
76
+ ```
77
+
78
+ **Staging**:
79
+ ```bash
80
+ terraform apply -var-file="environments/staging.tfvars"
81
+ ```
82
+
83
+ **Production**:
84
+ ```bash
85
+ terraform apply -var-file="environments/prod.tfvars"
86
+ ```
87
+
88
+ ### 4. Deploy Function Code
89
+
90
+ After infrastructure is deployed, deploy your function code:
91
+
92
+ ```bash
93
+ # Zip your function code
94
+ cd ../src # Navigate to your function source code
95
+ zip -r function.zip .
96
+
97
+ # Deploy using Azure CLI
98
+ az functionapp deployment source config-zip \
99
+ --resource-group {{resourceGroupName}} \
100
+ --name {{functionName}} \
101
+ --src function.zip
102
+ ```
103
+
104
+ ### 5. Test Your Function
105
+
106
+ ```bash
107
+ # Get function URL
108
+ FUNCTION_URL=$(terraform output -raw function_app_url)
109
+
110
+ # Test HTTP trigger (example)
111
+ curl "${FUNCTION_URL}/api/hello?name=World"
112
+ ```
113
+
114
+ ## Cost Estimation
115
+
116
+ ### Development Environment
117
+
118
+ **Azure Function App (Consumption Plan)**:
119
+ - Execution: 1M requests/month = Free (2M free tier)
120
+ - Execution time: 100,000 GB-s/month = Free (400,000 GB-s free tier)
121
+ - **Total**: $0/month (within free tier)
122
+
123
+ **Cosmos DB**:
124
+ - Throughput: {{throughput}} RU/s × $0.008/hour = ${{multiply throughput 0.008 720}}/month
125
+ - Storage: 1 GB = Free (25 GB free tier)
126
+ - **Total**: ~${{multiply throughput 0.008 720}}/month
127
+
128
+ **Storage Account**:
129
+ - LRS storage: 1 GB = ~$0.02/month
130
+ - Transactions: Minimal cost
131
+ - **Total**: ~$0.50/month
132
+
133
+ **Application Insights**:
134
+ - First 5 GB = Free
135
+ - **Total**: $0/month (within free tier)
136
+
137
+ **Total Monthly Cost (Dev)**: ~${{add (multiply throughput 0.008 720) 0.5}}/month
138
+
139
+ {{#if (eq environment "prod")}}
140
+ ### Production Environment (Estimated)
141
+
142
+ **Note**: Production costs depend on actual usage. Estimate above assumes:
143
+ - 10M requests/month
144
+ - {{throughput}} RU/s Cosmos DB throughput
145
+ - ~10 GB storage
146
+
147
+ For accurate production estimates, use [Azure Pricing Calculator](https://azure.microsoft.com/pricing/calculator/).
148
+ {{/if}}
149
+
150
+ ## Free Tier Optimization Tips
151
+
152
+ 1. **Function App**:
153
+ - Use Consumption Plan (Y1) for variable workloads
154
+ - Stay under 1M executions/month for free tier
155
+ - Optimize memory allocation (lower = cheaper)
156
+
157
+ 2. **Cosmos DB**:
158
+ - Start with 400 RU/s (minimum)
159
+ - Use autoscale for variable workloads
160
+ - Monitor RU consumption in Azure Portal
161
+
162
+ 3. **Application Insights**:
163
+ - First 5 GB/month is free
164
+ - Use sampling to reduce data volume
165
+ - Set retention to 90 days
166
+
167
+ 4. **Storage Account**:
168
+ - Use LRS (cheapest replication)
169
+ - Clean up old blobs and logs
170
+ - Enable lifecycle management
171
+
172
+ ## Monitoring
173
+
174
+ {{#if enableApplicationInsights}}
175
+ **Application Insights** is enabled. View metrics at:
176
+ ```
177
+ https://portal.azure.com/#@/resource${terraform output -raw application_insights_id}/overview
178
+ ```
179
+
180
+ Key metrics to monitor:
181
+ - Request rate and response times
182
+ - Failed requests
183
+ - Cosmos DB RU consumption
184
+ - Function execution count and duration
185
+ {{else}}
186
+ **Application Insights** is not enabled. To enable monitoring:
187
+ 1. Set `enableApplicationInsights = true` in `defaults.json`
188
+ 2. Re-apply Terraform configuration
189
+ {{/if}}
190
+
191
+ ## Security Best Practices
192
+
193
+ 1. **Managed Identity**: Function App uses System-Assigned Managed Identity
194
+ - No credentials in code
195
+ - Automatic rotation
196
+ - Azure RBAC for access control
197
+
198
+ 2. **Secrets Management**:
199
+ {{#if enableKeyVault}}
200
+ - ✅ Key Vault enabled for secrets
201
+ - Store connection strings in Key Vault
202
+ - Reference via `@Microsoft.KeyVault(SecretUri=...)`
203
+ {{else}}
204
+ - ⚠️ Key Vault not enabled
205
+ - Enable with `enableKeyVault = true`
206
+ {{/if}}
207
+
208
+ 3. **HTTPS Only**: Function App enforces HTTPS
209
+ 4. **CORS**: Configured for origins: {{corsOrigins}}
210
+ 5. **Network Security**:
211
+ {{#if enableVnet}}
212
+ - ✅ VNet integration enabled
213
+ {{else}}
214
+ - ⚠️ VNet integration not enabled (public access)
215
+ - Enable with `enableVnet = true`
216
+ {{/if}}
217
+
218
+ ## Cleanup
219
+
220
+ To destroy all resources:
221
+
222
+ ```bash
223
+ terraform destroy
224
+ ```
225
+
226
+ **Warning**: This will permanently delete:
227
+ - Function App and all deployed code
228
+ - Cosmos DB and all data
229
+ - Storage Account and all blobs
230
+ - Application Insights telemetry data
231
+
232
+ ## Troubleshooting
233
+
234
+ ### "Resource name already exists"
235
+ - Azure resource names must be globally unique
236
+ - Modify `appName` in `defaults.json` or `*.tfvars`
237
+
238
+ ### "Insufficient permissions"
239
+ - Ensure you have Owner/Contributor role on subscription
240
+ - Run `az account show` to verify correct subscription
241
+
242
+ ### "Cosmos DB throughput too low"
243
+ - Minimum throughput is 400 RU/s
244
+ - Adjust `throughput` in `defaults.json` or `*.tfvars`
245
+
246
+ ### "Function App not responding"
247
+ - Check Application Insights for errors
248
+ - Verify function code is deployed (`az functionapp deployment list-publishing-credentials`)
249
+ - Check CORS settings if calling from browser
250
+
251
+ ## Next Steps
252
+
253
+ 1. **Deploy your function code** (see step 4 above)
254
+ 2. **Set up CI/CD** with Azure DevOps or GitHub Actions
255
+ 3. **Configure custom domains** for production
256
+ 4. **Set up monitoring alerts** in Application Insights
257
+ 5. **Enable backup** for Cosmos DB (set `enableBackup = true`)
258
+
259
+ ## Support
260
+
261
+ - **Azure Documentation**: https://docs.microsoft.com/azure/azure-functions/
262
+ - **Terraform Azure Provider**: https://registry.terraform.io/providers/hashicorp/azurerm/
263
+ - **SpecWeave**: https://spec-weave.com
264
+
265
+ ---
266
+
267
+ **Generated**: {{currentDate}}
268
+ **SpecWeave Version**: {{specweaveVersion}}
@@ -0,0 +1,34 @@
1
+ # Development Environment Variables for Azure Functions + Cosmos DB
2
+ # Generated by SpecWeave Serverless Architecture Intelligence
3
+
4
+ location = "eastus"
5
+ resource_group_name = "{{projectName}}-dev-rg"
6
+ app_name = "{{projectName}}-dev-app"
7
+ runtime = "{{runtime}}"
8
+ runtime_version = "{{runtimeVersion}}"
9
+ os_type = "Linux"
10
+ sku_name = "Y1" # Consumption Plan (free tier eligible)
11
+ environment = "dev"
12
+
13
+ # Cosmos DB (optimized for dev - minimum cost)
14
+ database_account_name = "{{projectName}}-dev-cosmos"
15
+ database_name = "{{databaseName}}"
16
+ container_name = "{{containerName}}"
17
+ partition_key = "{{partitionKey}}"
18
+ throughput = 400 # Minimum (cheapest)
19
+
20
+ # CORS (allow all for development)
21
+ cors_origins = ["*"]
22
+
23
+ # Storage Account (cheapest options)
24
+ storage_account_tier = "Standard"
25
+ storage_account_replication = "LRS" # Locally Redundant Storage (cheapest)
26
+
27
+ # Project tagging
28
+ project_name = "{{projectName}}"
29
+
30
+ # Free tier optimization
31
+ # - Consumption Plan (Y1) for Function App
32
+ # - 400 RU/s Cosmos DB (minimum, stays within free tier for low usage)
33
+ # - LRS storage (cheapest)
34
+ # - Application Insights first 5 GB free
@@ -0,0 +1,46 @@
1
+ # Production Environment Variables for Azure Functions + Cosmos DB
2
+ # Generated by SpecWeave Serverless Architecture Intelligence
3
+
4
+ location = "eastus"
5
+ resource_group_name = "{{projectName}}-prod-rg"
6
+ app_name = "{{projectName}}-prod-app"
7
+ runtime = "{{runtime}}"
8
+ runtime_version = "{{runtimeVersion}}"
9
+ os_type = "Linux"
10
+ sku_name = "EP2" # Elastic Premium EP2 (production-grade)
11
+ environment = "prod"
12
+
13
+ # Cosmos DB (production settings with backup)
14
+ database_account_name = "{{projectName}}-prod-cosmos"
15
+ database_name = "{{databaseName}}"
16
+ container_name = "{{containerName}}"
17
+ partition_key = "{{partitionKey}}"
18
+ throughput = 4000 # Higher throughput for production
19
+
20
+ # CORS (restrict to production domain only)
21
+ cors_origins = ["https://{{projectName}}.com"]
22
+
23
+ # Storage Account (GRS for geo-redundancy)
24
+ storage_account_tier = "Standard"
25
+ storage_account_replication = "GRS" # Geo-Redundant Storage
26
+
27
+ # Project tagging
28
+ project_name = "{{projectName}}"
29
+
30
+ # Production features (uncomment to enable)
31
+ # enable_automatic_failover = true
32
+ # enable_multi_region = true
33
+ # secondary_regions = ["westus2", "northeurope"]
34
+ # enable_backup = true
35
+ # enable_key_vault = true
36
+ # enable_vnet = true
37
+
38
+ # Production optimizations
39
+ # - Elastic Premium (EP2) for high performance and VNet support
40
+ # - 4000 RU/s Cosmos DB with autoscale option
41
+ # - GRS storage for disaster recovery
42
+ # - Multi-region Cosmos DB (optional, comment out to enable)
43
+ # - Automatic failover enabled (optional)
44
+ # - Continuous backup (optional)
45
+ # - Key Vault for secrets (optional)
46
+ # - VNet integration for secure networking (optional)
@@ -0,0 +1,34 @@
1
+ # Staging Environment Variables for Azure Functions + Cosmos DB
2
+ # Generated by SpecWeave Serverless Architecture Intelligence
3
+
4
+ location = "eastus"
5
+ resource_group_name = "{{projectName}}-staging-rg"
6
+ app_name = "{{projectName}}-staging-app"
7
+ runtime = "{{runtime}}"
8
+ runtime_version = "{{runtimeVersion}}"
9
+ os_type = "Linux"
10
+ sku_name = "EP1" # Elastic Premium (better performance than Consumption)
11
+ environment = "staging"
12
+
13
+ # Cosmos DB (moderate settings)
14
+ database_account_name = "{{projectName}}-staging-cosmos"
15
+ database_name = "{{databaseName}}"
16
+ container_name = "{{containerName}}"
17
+ partition_key = "{{partitionKey}}"
18
+ throughput = 1000 # Higher throughput for staging tests
19
+
20
+ # CORS (restrict to known origins)
21
+ cors_origins = ["https://staging.{{projectName}}.com"]
22
+
23
+ # Storage Account (ZRS for better durability)
24
+ storage_account_tier = "Standard"
25
+ storage_account_replication = "ZRS" # Zone-Redundant Storage
26
+
27
+ # Project tagging
28
+ project_name = "{{projectName}}"
29
+
30
+ # Staging optimizations
31
+ # - Elastic Premium (EP1) for consistent performance
32
+ # - 1000 RU/s Cosmos DB for realistic load testing
33
+ # - ZRS storage for better durability
34
+ # - Single region deployment