@planu/cli 0.27.0 → 0.29.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 (273) hide show
  1. package/dist/config/model-routing-rules.json +98 -0
  2. package/dist/config/tool-groups.json +140 -0
  3. package/dist/engine/ai-cost-estimator/core.d.ts +1 -1
  4. package/dist/engine/ai-cost-estimator/core.d.ts.map +1 -1
  5. package/dist/engine/ai-cost-estimator/core.js +3 -167
  6. package/dist/engine/ai-cost-estimator/core.js.map +1 -1
  7. package/dist/engine/ai-cost-estimator/recommender.d.ts +8 -0
  8. package/dist/engine/ai-cost-estimator/recommender.d.ts.map +1 -0
  9. package/dist/engine/ai-cost-estimator/recommender.js +94 -0
  10. package/dist/engine/ai-cost-estimator/recommender.js.map +1 -0
  11. package/dist/engine/ai-cost-estimator/spec-loader.d.ts +13 -0
  12. package/dist/engine/ai-cost-estimator/spec-loader.d.ts.map +1 -0
  13. package/dist/engine/ai-cost-estimator/spec-loader.js +102 -0
  14. package/dist/engine/ai-cost-estimator/spec-loader.js.map +1 -0
  15. package/dist/engine/code-transforms/transform-engine.d.ts +7 -0
  16. package/dist/engine/code-transforms/transform-engine.d.ts.map +1 -0
  17. package/dist/engine/code-transforms/transform-engine.js +67 -0
  18. package/dist/engine/code-transforms/transform-engine.js.map +1 -0
  19. package/dist/engine/code-transforms/typescript/add-error-handling.d.ts +6 -0
  20. package/dist/engine/code-transforms/typescript/add-error-handling.d.ts.map +1 -0
  21. package/dist/engine/code-transforms/typescript/add-error-handling.js +92 -0
  22. package/dist/engine/code-transforms/typescript/add-error-handling.js.map +1 -0
  23. package/dist/engine/code-transforms/typescript/add-jsdoc.d.ts +6 -0
  24. package/dist/engine/code-transforms/typescript/add-jsdoc.d.ts.map +1 -0
  25. package/dist/engine/code-transforms/typescript/add-jsdoc.js +83 -0
  26. package/dist/engine/code-transforms/typescript/add-jsdoc.js.map +1 -0
  27. package/dist/engine/code-transforms/typescript/add-types.d.ts +3 -0
  28. package/dist/engine/code-transforms/typescript/add-types.d.ts.map +1 -0
  29. package/dist/engine/code-transforms/typescript/add-types.js +182 -0
  30. package/dist/engine/code-transforms/typescript/add-types.js.map +1 -0
  31. package/dist/engine/code-transforms/typescript/ast-utils.d.ts +38 -0
  32. package/dist/engine/code-transforms/typescript/ast-utils.d.ts.map +1 -0
  33. package/dist/engine/code-transforms/typescript/ast-utils.js +90 -0
  34. package/dist/engine/code-transforms/typescript/ast-utils.js.map +1 -0
  35. package/dist/engine/code-transforms/typescript/extract-interface.d.ts +6 -0
  36. package/dist/engine/code-transforms/typescript/extract-interface.d.ts.map +1 -0
  37. package/dist/engine/code-transforms/typescript/extract-interface.js +103 -0
  38. package/dist/engine/code-transforms/typescript/extract-interface.js.map +1 -0
  39. package/dist/engine/code-transforms/typescript/modernize-syntax.d.ts +3 -0
  40. package/dist/engine/code-transforms/typescript/modernize-syntax.d.ts.map +1 -0
  41. package/dist/engine/code-transforms/typescript/modernize-syntax.js +213 -0
  42. package/dist/engine/code-transforms/typescript/modernize-syntax.js.map +1 -0
  43. package/dist/engine/code-transforms/typescript/rename-symbol.d.ts +8 -0
  44. package/dist/engine/code-transforms/typescript/rename-symbol.d.ts.map +1 -0
  45. package/dist/engine/code-transforms/typescript/rename-symbol.js +40 -0
  46. package/dist/engine/code-transforms/typescript/rename-symbol.js.map +1 -0
  47. package/dist/engine/focus-tracker.d.ts.map +1 -1
  48. package/dist/engine/focus-tracker.js +1 -0
  49. package/dist/engine/focus-tracker.js.map +1 -1
  50. package/dist/engine/mermaid/core.d.ts +18 -0
  51. package/dist/engine/mermaid/core.d.ts.map +1 -0
  52. package/dist/engine/mermaid/core.js +88 -0
  53. package/dist/engine/mermaid/core.js.map +1 -0
  54. package/dist/engine/mermaid/diagram-generators.d.ts +22 -0
  55. package/dist/engine/mermaid/diagram-generators.d.ts.map +1 -0
  56. package/dist/engine/mermaid/diagram-generators.js +139 -0
  57. package/dist/engine/mermaid/diagram-generators.js.map +1 -0
  58. package/dist/engine/mermaid/helpers.d.ts +8 -0
  59. package/dist/engine/mermaid/helpers.d.ts.map +1 -0
  60. package/dist/engine/mermaid/helpers.js +61 -0
  61. package/dist/engine/mermaid/helpers.js.map +1 -0
  62. package/dist/engine/mermaid-generator.d.ts +2 -37
  63. package/dist/engine/mermaid-generator.d.ts.map +1 -1
  64. package/dist/engine/mermaid-generator.js +4 -276
  65. package/dist/engine/mermaid-generator.js.map +1 -1
  66. package/dist/engine/model-router/complexity-analyzer.d.ts +26 -0
  67. package/dist/engine/model-router/complexity-analyzer.d.ts.map +1 -0
  68. package/dist/engine/model-router/complexity-analyzer.js +182 -0
  69. package/dist/engine/model-router/complexity-analyzer.js.map +1 -0
  70. package/dist/engine/model-router/cost-estimator.d.ts +6 -0
  71. package/dist/engine/model-router/cost-estimator.d.ts.map +1 -0
  72. package/dist/engine/model-router/cost-estimator.js +60 -0
  73. package/dist/engine/model-router/cost-estimator.js.map +1 -0
  74. package/dist/engine/model-router/historical-learner.d.ts +26 -0
  75. package/dist/engine/model-router/historical-learner.d.ts.map +1 -0
  76. package/dist/engine/model-router/historical-learner.js +91 -0
  77. package/dist/engine/model-router/historical-learner.js.map +1 -0
  78. package/dist/engine/model-router/rules-engine.d.ts +13 -0
  79. package/dist/engine/model-router/rules-engine.d.ts.map +1 -0
  80. package/dist/engine/model-router/rules-engine.js +142 -0
  81. package/dist/engine/model-router/rules-engine.js.map +1 -0
  82. package/dist/engine/planu-config-writer.d.ts +2 -2
  83. package/dist/engine/planu-config-writer.d.ts.map +1 -1
  84. package/dist/engine/planu-config-writer.js +4 -6
  85. package/dist/engine/planu-config-writer.js.map +1 -1
  86. package/dist/engine/spec-coverage/criteria-mapper.d.ts +1 -2
  87. package/dist/engine/spec-coverage/criteria-mapper.d.ts.map +1 -1
  88. package/dist/engine/spec-coverage/criteria-mapper.js +4 -203
  89. package/dist/engine/spec-coverage/criteria-mapper.js.map +1 -1
  90. package/dist/engine/spec-coverage/keyword-extractor.d.ts +10 -0
  91. package/dist/engine/spec-coverage/keyword-extractor.d.ts.map +1 -0
  92. package/dist/engine/spec-coverage/keyword-extractor.js +147 -0
  93. package/dist/engine/spec-coverage/keyword-extractor.js.map +1 -0
  94. package/dist/engine/spec-coverage/test-matchers.d.ts +9 -0
  95. package/dist/engine/spec-coverage/test-matchers.d.ts.map +1 -0
  96. package/dist/engine/spec-coverage/test-matchers.js +59 -0
  97. package/dist/engine/spec-coverage/test-matchers.js.map +1 -0
  98. package/dist/engine/spec-migrator.d.ts +17 -0
  99. package/dist/engine/spec-migrator.d.ts.map +1 -0
  100. package/dist/engine/spec-migrator.js +119 -0
  101. package/dist/engine/spec-migrator.js.map +1 -0
  102. package/dist/engine/spec-templates/catalog-extra.d.ts +1 -1
  103. package/dist/engine/spec-templates/catalog-extra.d.ts.map +1 -1
  104. package/dist/engine/spec-templates/catalog-extra.js +8 -363
  105. package/dist/engine/spec-templates/catalog-extra.js.map +1 -1
  106. package/dist/engine/spec-templates/catalog.d.ts.map +1 -1
  107. package/dist/engine/spec-templates/catalog.js +10 -381
  108. package/dist/engine/spec-templates/catalog.js.map +1 -1
  109. package/dist/engine/spec-templates/templates-api-ui.d.ts +6 -0
  110. package/dist/engine/spec-templates/templates-api-ui.d.ts.map +1 -0
  111. package/dist/engine/spec-templates/templates-api-ui.js +188 -0
  112. package/dist/engine/spec-templates/templates-api-ui.js.map +1 -0
  113. package/dist/engine/spec-templates/templates-auth-crud.d.ts +6 -0
  114. package/dist/engine/spec-templates/templates-auth-crud.d.ts.map +1 -0
  115. package/dist/engine/spec-templates/templates-auth-crud.js +198 -0
  116. package/dist/engine/spec-templates/templates-auth-crud.js.map +1 -0
  117. package/dist/engine/spec-templates/templates-data-security.d.ts +6 -0
  118. package/dist/engine/spec-templates/templates-data-security.d.ts.map +1 -0
  119. package/dist/engine/spec-templates/templates-data-security.js +172 -0
  120. package/dist/engine/spec-templates/templates-data-security.js.map +1 -0
  121. package/dist/engine/spec-templates/templates-perf-integration.d.ts +6 -0
  122. package/dist/engine/spec-templates/templates-perf-integration.d.ts.map +1 -0
  123. package/dist/engine/spec-templates/templates-perf-integration.js +199 -0
  124. package/dist/engine/spec-templates/templates-perf-integration.js.map +1 -0
  125. package/dist/engine/tool-groups/context-analyzer.d.ts +11 -0
  126. package/dist/engine/tool-groups/context-analyzer.d.ts.map +1 -0
  127. package/dist/engine/tool-groups/context-analyzer.js +40 -0
  128. package/dist/engine/tool-groups/context-analyzer.js.map +1 -0
  129. package/dist/engine/tool-groups/group-manager.d.ts +35 -0
  130. package/dist/engine/tool-groups/group-manager.d.ts.map +1 -0
  131. package/dist/engine/tool-groups/group-manager.js +201 -0
  132. package/dist/engine/tool-groups/group-manager.js.map +1 -0
  133. package/dist/engine/vector-store/hnsw.d.ts +37 -0
  134. package/dist/engine/vector-store/hnsw.d.ts.map +1 -0
  135. package/dist/engine/vector-store/hnsw.js +294 -0
  136. package/dist/engine/vector-store/hnsw.js.map +1 -0
  137. package/dist/engine/vector-store/similarity.d.ts +21 -0
  138. package/dist/engine/vector-store/similarity.d.ts.map +1 -0
  139. package/dist/engine/vector-store/similarity.js +86 -0
  140. package/dist/engine/vector-store/similarity.js.map +1 -0
  141. package/dist/engine/vector-store/tfidf.d.ts +35 -0
  142. package/dist/engine/vector-store/tfidf.d.ts.map +1 -0
  143. package/dist/engine/vector-store/tfidf.js +255 -0
  144. package/dist/engine/vector-store/tfidf.js.map +1 -0
  145. package/dist/engine/web-fetcher/registry-loader.d.ts.map +1 -1
  146. package/dist/engine/web-fetcher/registry-loader.js +2 -0
  147. package/dist/engine/web-fetcher/registry-loader.js.map +1 -1
  148. package/dist/index.js +19 -0
  149. package/dist/index.js.map +1 -1
  150. package/dist/storage/vector-store/backend-factory.d.ts +9 -0
  151. package/dist/storage/vector-store/backend-factory.d.ts.map +1 -0
  152. package/dist/storage/vector-store/backend-factory.js +33 -0
  153. package/dist/storage/vector-store/backend-factory.js.map +1 -0
  154. package/dist/storage/vector-store/json-fallback.d.ts +21 -0
  155. package/dist/storage/vector-store/json-fallback.d.ts.map +1 -0
  156. package/dist/storage/vector-store/json-fallback.js +85 -0
  157. package/dist/storage/vector-store/json-fallback.js.map +1 -0
  158. package/dist/storage/vector-store/migrator.d.ts +10 -0
  159. package/dist/storage/vector-store/migrator.d.ts.map +1 -0
  160. package/dist/storage/vector-store/migrator.js +139 -0
  161. package/dist/storage/vector-store/migrator.js.map +1 -0
  162. package/dist/storage/vector-store/sqlite-adapter.d.ts +28 -0
  163. package/dist/storage/vector-store/sqlite-adapter.d.ts.map +1 -0
  164. package/dist/storage/vector-store/sqlite-adapter.js +142 -0
  165. package/dist/storage/vector-store/sqlite-adapter.js.map +1 -0
  166. package/dist/tools/create-spec/constitution-validator.d.ts +4 -0
  167. package/dist/tools/create-spec/constitution-validator.d.ts.map +1 -0
  168. package/dist/tools/create-spec/constitution-validator.js +37 -0
  169. package/dist/tools/create-spec/constitution-validator.js.map +1 -0
  170. package/dist/tools/create-spec/post-creation.d.ts +11 -0
  171. package/dist/tools/create-spec/post-creation.d.ts.map +1 -0
  172. package/dist/tools/create-spec/post-creation.js +48 -0
  173. package/dist/tools/create-spec/post-creation.js.map +1 -0
  174. package/dist/tools/create-spec/spec-builder.d.ts +14 -0
  175. package/dist/tools/create-spec/spec-builder.d.ts.map +1 -0
  176. package/dist/tools/create-spec/spec-builder.js +131 -0
  177. package/dist/tools/create-spec/spec-builder.js.map +1 -0
  178. package/dist/tools/create-spec.d.ts.map +1 -1
  179. package/dist/tools/create-spec.js +42 -172
  180. package/dist/tools/create-spec.js.map +1 -1
  181. package/dist/tools/data-governance/audit-handler.d.ts.map +1 -1
  182. package/dist/tools/data-governance/audit-handler.js +1 -0
  183. package/dist/tools/data-governance/audit-handler.js.map +1 -1
  184. package/dist/tools/design-schema.d.ts.map +1 -1
  185. package/dist/tools/design-schema.js +1 -0
  186. package/dist/tools/design-schema.js.map +1 -1
  187. package/dist/tools/init-project/handler.d.ts.map +1 -1
  188. package/dist/tools/init-project/handler.js +48 -14
  189. package/dist/tools/init-project/handler.js.map +1 -1
  190. package/dist/tools/recommend-model-handler.d.ts +8 -0
  191. package/dist/tools/recommend-model-handler.d.ts.map +1 -0
  192. package/dist/tools/recommend-model-handler.js +65 -0
  193. package/dist/tools/recommend-model-handler.js.map +1 -0
  194. package/dist/tools/register-ai-cost-tools.js +1 -1
  195. package/dist/tools/register-ai-cost-tools.js.map +1 -1
  196. package/dist/tools/register-model-tools.d.ts +3 -0
  197. package/dist/tools/register-model-tools.d.ts.map +1 -0
  198. package/dist/tools/register-model-tools.js +50 -0
  199. package/dist/tools/register-model-tools.js.map +1 -0
  200. package/dist/tools/register-search-tools.d.ts +7 -0
  201. package/dist/tools/register-search-tools.d.ts.map +1 -0
  202. package/dist/tools/register-search-tools.js +34 -0
  203. package/dist/tools/register-search-tools.js.map +1 -0
  204. package/dist/tools/register-spec-tools/core-spec-tools.d.ts.map +1 -1
  205. package/dist/tools/register-spec-tools/core-spec-tools.js +0 -4
  206. package/dist/tools/register-spec-tools/core-spec-tools.js.map +1 -1
  207. package/dist/tools/register-tool-groups.d.ts +7 -0
  208. package/dist/tools/register-tool-groups.d.ts.map +1 -0
  209. package/dist/tools/register-tool-groups.js +39 -0
  210. package/dist/tools/register-tool-groups.js.map +1 -0
  211. package/dist/tools/register-transform-tools.d.ts +3 -0
  212. package/dist/tools/register-transform-tools.d.ts.map +1 -0
  213. package/dist/tools/register-transform-tools.js +29 -0
  214. package/dist/tools/register-transform-tools.js.map +1 -0
  215. package/dist/tools/semantic-search-handler.d.ts +7 -0
  216. package/dist/tools/semantic-search-handler.d.ts.map +1 -0
  217. package/dist/tools/semantic-search-handler.js +72 -0
  218. package/dist/tools/semantic-search-handler.js.map +1 -0
  219. package/dist/tools/suggest-tooling/orchestration-generator.js +1 -1
  220. package/dist/tools/suggest-tooling/orchestration-generator.js.map +1 -1
  221. package/dist/tools/tool-group-handler.d.ts +9 -0
  222. package/dist/tools/tool-group-handler.d.ts.map +1 -0
  223. package/dist/tools/tool-group-handler.js +82 -0
  224. package/dist/tools/tool-group-handler.js.map +1 -0
  225. package/dist/tools/transform-code-handler.d.ts +7 -0
  226. package/dist/tools/transform-code-handler.d.ts.map +1 -0
  227. package/dist/tools/transform-code-handler.js +58 -0
  228. package/dist/tools/transform-code-handler.js.map +1 -0
  229. package/dist/types/advanced-framework.d.ts +47 -0
  230. package/dist/types/advanced-framework.d.ts.map +1 -0
  231. package/dist/types/advanced-framework.js +3 -0
  232. package/dist/types/advanced-framework.js.map +1 -0
  233. package/dist/types/code-transforms.d.ts +114 -0
  234. package/dist/types/code-transforms.d.ts.map +1 -0
  235. package/dist/types/code-transforms.js +11 -0
  236. package/dist/types/code-transforms.js.map +1 -0
  237. package/dist/types/css-framework.d.ts +110 -0
  238. package/dist/types/css-framework.d.ts.map +1 -0
  239. package/dist/types/css-framework.js +3 -0
  240. package/dist/types/css-framework.js.map +1 -0
  241. package/dist/types/dashboard.d.ts +77 -0
  242. package/dist/types/dashboard.d.ts.map +1 -0
  243. package/dist/types/dashboard.js +2 -0
  244. package/dist/types/dashboard.js.map +1 -0
  245. package/dist/types/index.d.ts +4 -0
  246. package/dist/types/index.d.ts.map +1 -1
  247. package/dist/types/index.js +4 -0
  248. package/dist/types/index.js.map +1 -1
  249. package/dist/types/model-routing.d.ts +127 -0
  250. package/dist/types/model-routing.d.ts.map +1 -0
  251. package/dist/types/model-routing.js +3 -0
  252. package/dist/types/model-routing.js.map +1 -0
  253. package/dist/types/project/inputs.d.ts +0 -1
  254. package/dist/types/project/inputs.d.ts.map +1 -1
  255. package/dist/types/spec/core.d.ts +28 -1
  256. package/dist/types/spec/core.d.ts.map +1 -1
  257. package/dist/types/spec/inputs.d.ts +9 -6
  258. package/dist/types/spec/inputs.d.ts.map +1 -1
  259. package/dist/types/tool-groups.d.ts +57 -0
  260. package/dist/types/tool-groups.d.ts.map +1 -0
  261. package/dist/types/tool-groups.js +3 -0
  262. package/dist/types/tool-groups.js.map +1 -0
  263. package/dist/types/ui.d.ts +3 -231
  264. package/dist/types/ui.d.ts.map +1 -1
  265. package/dist/types/ui.js +7 -1
  266. package/dist/types/ui.js.map +1 -1
  267. package/dist/types/vector-store.d.ts +137 -0
  268. package/dist/types/vector-store.d.ts.map +1 -0
  269. package/dist/types/vector-store.js +3 -0
  270. package/dist/types/vector-store.js.map +1 -0
  271. package/package.json +1 -1
  272. package/src/config/model-routing-rules.json +98 -0
  273. package/src/config/tool-groups.json +140 -0
@@ -0,0 +1,198 @@
1
+ // engine/spec-templates/templates-auth-crud.ts — Auth JWT + CRUD entity templates.
2
+ // Extracted from catalog.ts to keep file sizes within limits.
3
+ /** JWT Authentication spec template. */
4
+ export const AUTH_JWT_TEMPLATE = {
5
+ id: 'auth-jwt',
6
+ name: 'JWT Authentication',
7
+ category: 'auth',
8
+ description: 'User authentication flow with JWT tokens: login, logout, refresh, and guards.',
9
+ tags: ['auth', 'jwt', 'security', 'session'],
10
+ variables: [
11
+ {
12
+ key: 'EntityName',
13
+ label: 'Entity name',
14
+ description: 'The name of the authenticated entity (User, Admin, Member…)',
15
+ example: 'User',
16
+ required: true,
17
+ },
18
+ {
19
+ key: 'TokenExpiry',
20
+ label: 'Token expiry',
21
+ description: 'JWT access token expiry duration',
22
+ example: '15 minutes',
23
+ required: false,
24
+ defaultValue: '15 minutes',
25
+ },
26
+ ],
27
+ huTemplate: `# HU: JWT Authentication for {{EntityName}}
28
+
29
+ ## User Story
30
+ As a {{EntityName}}, I want to securely authenticate with JWT tokens so that my session is stateless and protected.
31
+
32
+ ## Acceptance Criteria
33
+
34
+ ### AC-1: Login endpoint
35
+ - [ ] POST /auth/login accepts credentials and returns access + refresh tokens
36
+ - [ ] Access token expires after {{TokenExpiry}}
37
+ - [ ] Refresh token stored server-side and rotated on each use
38
+ - [ ] Failed login returns 401 with no sensitive detail
39
+
40
+ ### AC-2: Protected route guard
41
+ - [ ] Every protected endpoint validates the Bearer token
42
+ - [ ] Expired or invalid tokens return 401
43
+ - [ ] Tampered tokens are rejected and logged
44
+
45
+ ### AC-3: Token refresh
46
+ - [ ] POST /auth/refresh issues new access token given a valid refresh token
47
+ - [ ] Refresh token is single-use (rotation strategy)
48
+
49
+ ### AC-4: Logout
50
+ - [ ] POST /auth/logout invalidates the refresh token server-side
51
+ - [ ] Client-side storage is cleared by the caller
52
+
53
+ ### AC-5: Security requirements
54
+ - [ ] Passwords stored as salted hash (bcrypt or Argon2 equivalent)
55
+ - [ ] HTTPS enforced in production
56
+ - [ ] Rate limiting on /auth/login (max 5 requests/minute per IP)
57
+ - [ ] Brute-force protection with account lockout after N failures
58
+
59
+ ## Out of Scope
60
+ - OAuth2 / SSO providers (create separate spec)
61
+ - Multi-factor authentication (create separate spec)
62
+ `,
63
+ fichaTecnicaTemplate: `# FICHA TÉCNICA: JWT Authentication for {{EntityName}}
64
+
65
+ ## Affected Files
66
+ - auth/login handler
67
+ - auth/refresh handler
68
+ - auth/logout handler
69
+ - auth/middleware (token guard)
70
+ - storage/token-store (refresh token persistence)
71
+ - config/auth-config (token secrets, expiry settings)
72
+
73
+ ## Types / Entities
74
+ - \`{{EntityName}}\`: id, email, passwordHash, createdAt
75
+ - \`AuthTokenPair\`: accessToken, refreshToken, expiresIn
76
+ - \`RefreshTokenRecord\`: token, entityId, expiresAt, usedAt
77
+
78
+ ## Risks
79
+ - Token secret exposure → rotate secrets without downtime (risk: high)
80
+ - Refresh token replay attack → single-use rotation required
81
+ - Brute force on login → rate limiting + lockout required
82
+
83
+ ## Estimation (rough)
84
+ - Dev: 8–16 hours
85
+ - Review: 2–4 hours
86
+ - Difficulty: 3/5
87
+ `,
88
+ progressTemplate: `# PROGRESS: JWT Authentication for {{EntityName}}
89
+
90
+ ## Status: draft
91
+
92
+ ## Criteria
93
+ - [ ] AC-1: Login endpoint
94
+ - [ ] AC-2: Protected route guard
95
+ - [ ] AC-3: Token refresh
96
+ - [ ] AC-4: Logout
97
+ - [ ] AC-5: Security requirements
98
+ `,
99
+ };
100
+ /** CRUD Entity spec template. */
101
+ export const CRUD_ENTITY_TEMPLATE = {
102
+ id: 'crud-entity',
103
+ name: 'CRUD Entity',
104
+ category: 'crud',
105
+ description: 'Full Create/Read/Update/Delete lifecycle for any data entity.',
106
+ tags: ['crud', 'rest', 'api', 'database'],
107
+ variables: [
108
+ {
109
+ key: 'EntityName',
110
+ label: 'Entity name',
111
+ description: 'Name of the entity (singular, PascalCase)',
112
+ example: 'Product',
113
+ required: true,
114
+ },
115
+ {
116
+ key: 'EntityPlural',
117
+ label: 'Entity plural',
118
+ description: 'Plural form of the entity name',
119
+ example: 'Products',
120
+ required: true,
121
+ },
122
+ ],
123
+ huTemplate: `# HU: CRUD for {{EntityName}}
124
+
125
+ ## User Story
126
+ As a user, I want to create, view, update and delete {{EntityPlural}} so that I can manage them effectively.
127
+
128
+ ## Acceptance Criteria
129
+
130
+ ### AC-1: Create {{EntityName}}
131
+ - [ ] POST /{{EntityPlural}} accepts valid payload and persists the entity
132
+ - [ ] Duplicate detection where applicable
133
+ - [ ] Returns the created entity with generated ID and timestamps
134
+
135
+ ### AC-2: List {{EntityPlural}}
136
+ - [ ] GET /{{EntityPlural}} returns paginated list
137
+ - [ ] Supports filtering and sorting by key fields
138
+ - [ ] Empty list returns 200 with empty array (not 404)
139
+
140
+ ### AC-3: Get single {{EntityName}}
141
+ - [ ] GET /{{EntityPlural}}/:id returns the entity or 404
142
+ - [ ] Soft-deleted entities return 404
143
+
144
+ ### AC-4: Update {{EntityName}}
145
+ - [ ] PATCH /{{EntityPlural}}/:id applies partial update
146
+ - [ ] PUT /{{EntityPlural}}/:id replaces the full entity
147
+ - [ ] Returns updated entity on success
148
+
149
+ ### AC-5: Delete {{EntityName}}
150
+ - [ ] DELETE /{{EntityPlural}}/:id performs soft delete by default
151
+ - [ ] Hard delete available as a privileged action
152
+ - [ ] Returns 204 No Content on success
153
+
154
+ ### AC-6: Validation
155
+ - [ ] All inputs validated at the API boundary
156
+ - [ ] Invalid fields return 422 with per-field error messages
157
+ `,
158
+ fichaTecnicaTemplate: `# FICHA TÉCNICA: CRUD for {{EntityName}}
159
+
160
+ ## Affected Files
161
+ - handlers/{{EntityPlural}}/create
162
+ - handlers/{{EntityPlural}}/list
163
+ - handlers/{{EntityPlural}}/get
164
+ - handlers/{{EntityPlural}}/update
165
+ - handlers/{{EntityPlural}}/delete
166
+ - storage/{{EntityPlural}}-repository
167
+ - types/{{EntityName}}
168
+
169
+ ## Types / Entities
170
+ - \`{{EntityName}}\`: id, createdAt, updatedAt, deletedAt (nullable)
171
+ - \`Create{{EntityName}}Input\`: entity fields (validated)
172
+ - \`Update{{EntityName}}Input\`: partial entity fields
173
+ - \`List{{EntityPlural}}Query\`: page, limit, sortBy, order, filters
174
+
175
+ ## Risks
176
+ - Missing soft-delete → data loss risk
177
+ - Unbounded list without pagination → performance risk
178
+ - Missing input validation → injection risk
179
+
180
+ ## Estimation (rough)
181
+ - Dev: 6–12 hours
182
+ - Review: 1–3 hours
183
+ - Difficulty: 2/5
184
+ `,
185
+ progressTemplate: `# PROGRESS: CRUD for {{EntityName}}
186
+
187
+ ## Status: draft
188
+
189
+ ## Criteria
190
+ - [ ] AC-1: Create {{EntityName}}
191
+ - [ ] AC-2: List {{EntityPlural}}
192
+ - [ ] AC-3: Get single {{EntityName}}
193
+ - [ ] AC-4: Update {{EntityName}}
194
+ - [ ] AC-5: Delete {{EntityName}}
195
+ - [ ] AC-6: Validation
196
+ `,
197
+ };
198
+ //# sourceMappingURL=templates-auth-crud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates-auth-crud.js","sourceRoot":"","sources":["../../../src/engine/spec-templates/templates-auth-crud.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,8DAA8D;AAI9D,wCAAwC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,oBAAoB;IAC1B,QAAQ,EAAE,MAAM;IAChB,WAAW,EAAE,+EAA+E;IAC5F,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC;IAC5C,SAAS,EAAE;QACT;YACE,GAAG,EAAE,YAAY;YACjB,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,6DAA6D;YAC1E,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,IAAI;SACf;QACD;YACE,GAAG,EAAE,aAAa;YAClB,KAAK,EAAE,cAAc;YACrB,WAAW,EAAE,kCAAkC;YAC/C,OAAO,EAAE,YAAY;YACrB,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,YAAY;SAC3B;KACF;IACD,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCb;IACC,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;CAwBvB;IACC,gBAAgB,EAAE;;;;;;;;;;CAUnB;CACA,CAAC;AAEF,iCAAiC;AACjC,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,EAAE,EAAE,aAAa;IACjB,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,MAAM;IAChB,WAAW,EAAE,+DAA+D;IAC5E,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC;IACzC,SAAS,EAAE;QACT;YACE,GAAG,EAAE,YAAY;YACjB,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,2CAA2C;YACxD,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,IAAI;SACf;QACD;YACE,GAAG,EAAE,cAAc;YACnB,KAAK,EAAE,eAAe;YACtB,WAAW,EAAE,gCAAgC;YAC7C,OAAO,EAAE,UAAU;YACnB,QAAQ,EAAE,IAAI;SACf;KACF;IACD,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCb;IACC,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BvB;IACC,gBAAgB,EAAE;;;;;;;;;;;CAWnB;CACA,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { SpecTemplateEntry } from '../../types/spec-templates.js';
2
+ /** Data migration spec template. */
3
+ export declare const DATA_MIGRATION_TEMPLATE: SpecTemplateEntry;
4
+ /** Security feature spec template. */
5
+ export declare const SECURITY_FEATURE_TEMPLATE: SpecTemplateEntry;
6
+ //# sourceMappingURL=templates-data-security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates-data-security.d.ts","sourceRoot":"","sources":["../../../src/engine/spec-templates/templates-data-security.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,oCAAoC;AACpC,eAAO,MAAM,uBAAuB,EAAE,iBA8ErC,CAAC;AAEF,sCAAsC;AACtC,eAAO,MAAM,yBAAyB,EAAE,iBAuFvC,CAAC"}
@@ -0,0 +1,172 @@
1
+ // engine/spec-templates/templates-data-security.ts — Data migration + security feature templates.
2
+ // Extracted from catalog-extra.ts to keep file sizes within limits.
3
+ /** Data migration spec template. */
4
+ export const DATA_MIGRATION_TEMPLATE = {
5
+ id: 'data-migration',
6
+ name: 'Data Migration',
7
+ category: 'data',
8
+ description: 'Safe, reversible database or data migration with rollback support.',
9
+ tags: ['migration', 'database', 'schema', 'data'],
10
+ variables: [
11
+ {
12
+ key: 'MigrationName',
13
+ label: 'Migration name',
14
+ description: 'Short descriptive name for this migration',
15
+ example: 'Add email_verified column to users',
16
+ required: true,
17
+ },
18
+ ],
19
+ huTemplate: `# HU: Data Migration — {{MigrationName}}
20
+
21
+ ## User Story
22
+ As a developer, I want to apply the migration "{{MigrationName}}" safely so that production data is not at risk.
23
+
24
+ ## Acceptance Criteria
25
+
26
+ ### AC-1: Migration script
27
+ - [ ] Migration has an "up" (apply) and "down" (rollback) operation
28
+ - [ ] Script is idempotent (safe to run multiple times)
29
+ - [ ] Each step is transactional where supported by the database
30
+
31
+ ### AC-2: Data safety
32
+ - [ ] Pre-migration backup documented in runbook
33
+ - [ ] No destructive operation without a confirmed backup
34
+ - [ ] Migration tested on a staging copy of production data
35
+
36
+ ### AC-3: Zero-downtime strategy
37
+ - [ ] Migration can be applied while the application is running
38
+ - [ ] Backward-compatible schema changes first (expand), then cleanup (contract)
39
+ - [ ] Feature flag used if application code needs to switch behavior
40
+
41
+ ### AC-4: Rollback
42
+ - [ ] Rollback procedure documented and tested
43
+ - [ ] Rollback does not cause data loss
44
+ - [ ] Time to rollback < 15 minutes
45
+
46
+ ### AC-5: Observability
47
+ - [ ] Migration duration logged
48
+ - [ ] Row counts before/after logged for verification
49
+ - [ ] Anomalies (unexpected row counts) trigger alerts
50
+ `,
51
+ fichaTecnicaTemplate: `# FICHA TÉCNICA: Data Migration — {{MigrationName}}
52
+
53
+ ## Affected Files
54
+ - migrations/{{MigrationName}}/up
55
+ - migrations/{{MigrationName}}/down
56
+ - runbooks/{{MigrationName}}-rollback
57
+
58
+ ## Types / Entities
59
+ - Migration metadata: id, name, appliedAt, duration, rolledBack
60
+
61
+ ## Risks
62
+ - Data loss on rollback → mandatory backup before apply
63
+ - Long-running migration → table locks in production
64
+ - Missing idempotency → partial application leaves DB in bad state
65
+
66
+ ## Estimation (rough)
67
+ - Dev: 4–12 hours
68
+ - Review: 2–4 hours
69
+ - Difficulty: 3/5
70
+ `,
71
+ progressTemplate: `# PROGRESS: Data Migration — {{MigrationName}}
72
+
73
+ ## Status: draft
74
+
75
+ ## Criteria
76
+ - [ ] AC-1: Migration script
77
+ - [ ] AC-2: Data safety
78
+ - [ ] AC-3: Zero-downtime strategy
79
+ - [ ] AC-4: Rollback
80
+ - [ ] AC-5: Observability
81
+ `,
82
+ };
83
+ /** Security feature spec template. */
84
+ export const SECURITY_FEATURE_TEMPLATE = {
85
+ id: 'security-feature',
86
+ name: 'Security Feature',
87
+ category: 'security',
88
+ description: 'Security hardening: rate limiting, input sanitization, audit logging, etc.',
89
+ tags: ['security', 'hardening', 'audit', 'rate-limiting'],
90
+ variables: [
91
+ {
92
+ key: 'FeatureName',
93
+ label: 'Security feature name',
94
+ description: 'Name of the security feature being implemented',
95
+ example: 'Rate Limiting',
96
+ required: true,
97
+ },
98
+ {
99
+ key: 'ProtectedResource',
100
+ label: 'Protected resource or area',
101
+ description: 'What is being protected by this feature',
102
+ example: 'authentication endpoints',
103
+ required: true,
104
+ },
105
+ ],
106
+ huTemplate: `# HU: Security Feature — {{FeatureName}}
107
+
108
+ ## User Story
109
+ As a security engineer, I want {{FeatureName}} applied to {{ProtectedResource}} so that attack vectors are reduced.
110
+
111
+ ## Acceptance Criteria
112
+
113
+ ### AC-1: Implementation
114
+ - [ ] {{FeatureName}} implemented at the correct layer (edge, gateway, application)
115
+ - [ ] Configuration externalized (not hardcoded)
116
+ - [ ] Enabled in production, configurable in development
117
+
118
+ ### AC-2: Bypass prevention
119
+ - [ ] Cannot be bypassed by manipulating headers or query parameters
120
+ - [ ] Handles IPv4, IPv6, and forwarded IP headers correctly
121
+ - [ ] Works behind reverse proxies and CDNs
122
+
123
+ ### AC-3: Observability
124
+ - [ ] Blocked/throttled requests logged with reason
125
+ - [ ] Metrics exported: blocked count, block rate, top blocked IPs
126
+ - [ ] Alert triggers when block rate exceeds threshold
127
+
128
+ ### AC-4: Testing
129
+ - [ ] Unit tests cover allowed and blocked cases
130
+ - [ ] Integration tests simulate attack patterns
131
+ - [ ] Penetration test checklist updated
132
+
133
+ ### AC-5: Documentation
134
+ - [ ] Security runbook updated with new feature
135
+ - [ ] Limits and thresholds documented with rationale
136
+ - [ ] On-call playbook updated for incident response
137
+ `,
138
+ fichaTecnicaTemplate: `# FICHA TÉCNICA: Security Feature — {{FeatureName}}
139
+
140
+ ## Affected Files
141
+ - middleware/{{FeatureName}}
142
+ - config/security-config
143
+ - monitoring/security-alerts
144
+ - runbooks/security-incident
145
+
146
+ ## Types / Entities
147
+ - \`{{FeatureName}}Config\`: thresholds, enabled, dryRun
148
+ - \`SecurityEvent\`: type, resource, ip, timestamp, blocked
149
+
150
+ ## Risks
151
+ - False positives blocking legitimate users → dry-run mode first
152
+ - Missing coverage for all entry points → security audit required
153
+ - Misconfiguration under proxy → test in staging with proxy enabled
154
+
155
+ ## Estimation (rough)
156
+ - Dev: 4–12 hours
157
+ - Review: 2–4 hours
158
+ - Difficulty: 3/5
159
+ `,
160
+ progressTemplate: `# PROGRESS: Security Feature — {{FeatureName}}
161
+
162
+ ## Status: draft
163
+
164
+ ## Criteria
165
+ - [ ] AC-1: Implementation
166
+ - [ ] AC-2: Bypass prevention
167
+ - [ ] AC-3: Observability
168
+ - [ ] AC-4: Testing
169
+ - [ ] AC-5: Documentation
170
+ `,
171
+ };
172
+ //# sourceMappingURL=templates-data-security.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates-data-security.js","sourceRoot":"","sources":["../../../src/engine/spec-templates/templates-data-security.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,oEAAoE;AAIpE,oCAAoC;AACpC,MAAM,CAAC,MAAM,uBAAuB,GAAsB;IACxD,EAAE,EAAE,gBAAgB;IACpB,IAAI,EAAE,gBAAgB;IACtB,QAAQ,EAAE,MAAM;IAChB,WAAW,EAAE,oEAAoE;IACjF,IAAI,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC;IACjD,SAAS,EAAE;QACT;YACE,GAAG,EAAE,eAAe;YACpB,KAAK,EAAE,gBAAgB;YACvB,WAAW,EAAE,2CAA2C;YACxD,OAAO,EAAE,oCAAoC;YAC7C,QAAQ,EAAE,IAAI;SACf;KACF;IACD,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Bb;IACC,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;CAmBvB;IACC,gBAAgB,EAAE;;;;;;;;;;CAUnB;CACA,CAAC;AAEF,sCAAsC;AACtC,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IAC1D,EAAE,EAAE,kBAAkB;IACtB,IAAI,EAAE,kBAAkB;IACxB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,4EAA4E;IACzF,IAAI,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,CAAC;IACzD,SAAS,EAAE;QACT;YACE,GAAG,EAAE,aAAa;YAClB,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EAAE,gDAAgD;YAC7D,OAAO,EAAE,eAAe;YACxB,QAAQ,EAAE,IAAI;SACf;QACD;YACE,GAAG,EAAE,mBAAmB;YACxB,KAAK,EAAE,4BAA4B;YACnC,WAAW,EAAE,yCAAyC;YACtD,OAAO,EAAE,0BAA0B;YACnC,QAAQ,EAAE,IAAI;SACf;KACF;IACD,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Bb;IACC,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;;;CAqBvB;IACC,gBAAgB,EAAE;;;;;;;;;;CAUnB;CACA,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { SpecTemplateEntry } from '../../types/spec-templates.js';
2
+ /** Performance optimization spec template. */
3
+ export declare const PERFORMANCE_OPTIMIZATION_TEMPLATE: SpecTemplateEntry;
4
+ /** Third-party integration spec template. */
5
+ export declare const THIRD_PARTY_INTEGRATION_TEMPLATE: SpecTemplateEntry;
6
+ //# sourceMappingURL=templates-perf-integration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates-perf-integration.d.ts","sourceRoot":"","sources":["../../../src/engine/spec-templates/templates-perf-integration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,8CAA8C;AAC9C,eAAO,MAAM,iCAAiC,EAAE,iBAkG/C,CAAC;AAEF,6CAA6C;AAC7C,eAAO,MAAM,gCAAgC,EAAE,iBA8F9C,CAAC"}
@@ -0,0 +1,199 @@
1
+ // engine/spec-templates/templates-perf-integration.ts — Performance + third-party integration templates.
2
+ // Extracted from catalog-extra.ts to keep file sizes within limits.
3
+ /** Performance optimization spec template. */
4
+ export const PERFORMANCE_OPTIMIZATION_TEMPLATE = {
5
+ id: 'performance-optimization',
6
+ name: 'Performance Optimization',
7
+ category: 'performance',
8
+ description: 'Measurable performance improvements with before/after benchmarks.',
9
+ tags: ['performance', 'optimization', 'caching', 'benchmarks'],
10
+ variables: [
11
+ {
12
+ key: 'TargetArea',
13
+ label: 'Target area',
14
+ description: 'The specific area to optimize (e.g. API response time, DB queries)',
15
+ example: 'API response time',
16
+ required: true,
17
+ },
18
+ {
19
+ key: 'CurrentBaseline',
20
+ label: 'Current baseline',
21
+ description: 'Current measured performance metric',
22
+ example: 'P95 latency: 800ms',
23
+ required: false,
24
+ defaultValue: 'TBD — measure before starting',
25
+ },
26
+ {
27
+ key: 'TargetGoal',
28
+ label: 'Target goal',
29
+ description: 'Desired performance metric after optimization',
30
+ example: 'P95 latency: < 200ms',
31
+ required: false,
32
+ defaultValue: 'TBD — define after baseline measurement',
33
+ },
34
+ ],
35
+ huTemplate: `# HU: Performance Optimization — {{TargetArea}}
36
+
37
+ ## User Story
38
+ As a user, I want {{TargetArea}} to be faster so that the application feels responsive.
39
+
40
+ ## Baseline
41
+ - Current: {{CurrentBaseline}}
42
+ - Target: {{TargetGoal}}
43
+
44
+ ## Acceptance Criteria
45
+
46
+ ### AC-1: Baseline measurement
47
+ - [ ] Benchmark suite established before any changes
48
+ - [ ] Metrics captured: P50, P95, P99 latency, throughput, error rate
49
+ - [ ] Benchmark results stored for comparison
50
+
51
+ ### AC-2: Optimization implementation
52
+ - [ ] Root cause of performance issue identified and documented
53
+ - [ ] Optimization applied at the correct layer
54
+ - [ ] No correctness regression introduced by optimization
55
+
56
+ ### AC-3: Cache strategy (if applicable)
57
+ - [ ] Cache invalidation strategy defined
58
+ - [ ] Cache hit rate monitored
59
+ - [ ] Cache warm-up procedure documented
60
+
61
+ ### AC-4: Validation
62
+ - [ ] Post-optimization benchmark shows improvement vs baseline
63
+ - [ ] Target goal reached or documented with explanation if not
64
+ - [ ] Load test confirms improvement holds under concurrent traffic
65
+
66
+ ### AC-5: Observability
67
+ - [ ] Performance metrics added to dashboard
68
+ - [ ] Regression alert configured (auto-detect if P95 degrades)
69
+ `,
70
+ fichaTecnicaTemplate: `# FICHA TÉCNICA: Performance Optimization — {{TargetArea}}
71
+
72
+ ## Affected Files
73
+ - (determined during root-cause analysis)
74
+ - monitoring/dashboards/{{TargetArea}}
75
+ - benchmarks/{{TargetArea}}
76
+
77
+ ## Types / Entities
78
+ - \`BenchmarkResult\`: timestamp, p50, p95, p99, throughput, errorRate
79
+ - \`CacheEntry\` (if caching): key, value, ttl, hitCount
80
+
81
+ ## Risks
82
+ - Optimization that breaks correctness → benchmark must include correctness tests
83
+ - Cache inconsistency → strong consistency tests required
84
+ - Performance regression after unrelated change → regression alert required
85
+
86
+ ## Estimation (rough)
87
+ - Dev: 4–20 hours (highly variable by root cause)
88
+ - Review: 2–4 hours
89
+ - Difficulty: 3–4/5
90
+ `,
91
+ progressTemplate: `# PROGRESS: Performance Optimization — {{TargetArea}}
92
+
93
+ ## Status: draft
94
+
95
+ ## Criteria
96
+ - [ ] AC-1: Baseline measurement
97
+ - [ ] AC-2: Optimization implementation
98
+ - [ ] AC-3: Cache strategy
99
+ - [ ] AC-4: Validation
100
+ - [ ] AC-5: Observability
101
+ `,
102
+ };
103
+ /** Third-party integration spec template. */
104
+ export const THIRD_PARTY_INTEGRATION_TEMPLATE = {
105
+ id: 'third-party-integration',
106
+ name: 'Third-Party Integration',
107
+ category: 'integration',
108
+ description: 'Integrating with an external service (payment, email, SMS, CRM, etc.).',
109
+ tags: ['integration', 'external', 'api', 'webhook'],
110
+ variables: [
111
+ {
112
+ key: 'ServiceName',
113
+ label: 'Service name',
114
+ description: 'Name of the external service to integrate',
115
+ example: 'Stripe',
116
+ required: true,
117
+ },
118
+ {
119
+ key: 'IntegrationPurpose',
120
+ label: 'Purpose',
121
+ description: 'What the integration enables',
122
+ example: 'payment processing',
123
+ required: true,
124
+ },
125
+ ],
126
+ huTemplate: `# HU: {{ServiceName}} Integration
127
+
128
+ ## User Story
129
+ As a developer, I want to integrate {{ServiceName}} so that the platform can handle {{IntegrationPurpose}} reliably.
130
+
131
+ ## Acceptance Criteria
132
+
133
+ ### AC-1: Credentials management
134
+ - [ ] API keys and secrets stored in environment variables (never hardcoded)
135
+ - [ ] Separate credentials for development, staging, and production
136
+ - [ ] Credential rotation documented in runbook
137
+
138
+ ### AC-2: Core integration
139
+ - [ ] {{ServiceName}} SDK or HTTP client initialized with proper config
140
+ - [ ] All calls wrapped in retry logic with exponential backoff
141
+ - [ ] Timeouts configured (no infinite waits)
142
+
143
+ ### AC-3: Error handling
144
+ - [ ] {{ServiceName}} API errors mapped to internal error types
145
+ - [ ] Network failures do not crash the application
146
+ - [ ] Errors logged with enough context for debugging
147
+
148
+ ### AC-4: Webhooks (if applicable)
149
+ - [ ] Webhook endpoint validates signature before processing
150
+ - [ ] Events processed idempotently (replay-safe)
151
+ - [ ] Failed event processing alerts the on-call team
152
+
153
+ ### AC-5: Observability
154
+ - [ ] All outbound calls logged (method, status, latency)
155
+ - [ ] Circuit breaker implemented for high-traffic paths
156
+
157
+ ### AC-6: Testing
158
+ - [ ] Unit tests mock {{ServiceName}} client
159
+ - [ ] Integration tests use sandbox/test environment
160
+ - [ ] Webhook tests replay recorded payloads
161
+ `,
162
+ fichaTecnicaTemplate: `# FICHA TÉCNICA: {{ServiceName}} Integration
163
+
164
+ ## Affected Files
165
+ - integrations/{{ServiceName}}/client
166
+ - integrations/{{ServiceName}}/webhook-handler
167
+ - integrations/{{ServiceName}}/error-mapper
168
+ - config/{{ServiceName}}-config
169
+ - tests/integrations/{{ServiceName}}
170
+
171
+ ## Types / Entities
172
+ - \`{{ServiceName}}Config\`: apiKey, baseUrl, timeout, retries
173
+ - \`{{ServiceName}}Error\`: code, message, retryable
174
+ - \`WebhookEvent\`: id, type, payload, receivedAt
175
+
176
+ ## Risks
177
+ - Vendor API changes without notice → pin SDK version, monitor changelogs
178
+ - Rate limits exceeded → implement request queuing
179
+ - Credentials leaked → secrets manager mandatory
180
+
181
+ ## Estimation (rough)
182
+ - Dev: 8–20 hours
183
+ - Review: 2–4 hours
184
+ - Difficulty: 3/5
185
+ `,
186
+ progressTemplate: `# PROGRESS: {{ServiceName}} Integration
187
+
188
+ ## Status: draft
189
+
190
+ ## Criteria
191
+ - [ ] AC-1: Credentials management
192
+ - [ ] AC-2: Core integration
193
+ - [ ] AC-3: Error handling
194
+ - [ ] AC-4: Webhooks
195
+ - [ ] AC-5: Observability
196
+ - [ ] AC-6: Testing
197
+ `,
198
+ };
199
+ //# sourceMappingURL=templates-perf-integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates-perf-integration.js","sourceRoot":"","sources":["../../../src/engine/spec-templates/templates-perf-integration.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,oEAAoE;AAIpE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,iCAAiC,GAAsB;IAClE,EAAE,EAAE,0BAA0B;IAC9B,IAAI,EAAE,0BAA0B;IAChC,QAAQ,EAAE,aAAa;IACvB,WAAW,EAAE,mEAAmE;IAChF,IAAI,EAAE,CAAC,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,CAAC;IAC9D,SAAS,EAAE;QACT;YACE,GAAG,EAAE,YAAY;YACjB,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,oEAAoE;YACjF,OAAO,EAAE,mBAAmB;YAC5B,QAAQ,EAAE,IAAI;SACf;QACD;YACE,GAAG,EAAE,iBAAiB;YACtB,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,qCAAqC;YAClD,OAAO,EAAE,oBAAoB;YAC7B,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,+BAA+B;SAC9C;QACD;YACE,GAAG,EAAE,YAAY;YACjB,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,+CAA+C;YAC5D,OAAO,EAAE,sBAAsB;YAC/B,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,yCAAyC;SACxD;KACF;IACD,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCb;IACC,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;;CAoBvB;IACC,gBAAgB,EAAE;;;;;;;;;;CAUnB;CACA,CAAC;AAEF,6CAA6C;AAC7C,MAAM,CAAC,MAAM,gCAAgC,GAAsB;IACjE,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,yBAAyB;IAC/B,QAAQ,EAAE,aAAa;IACvB,WAAW,EAAE,wEAAwE;IACrF,IAAI,EAAE,CAAC,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC;IACnD,SAAS,EAAE;QACT;YACE,GAAG,EAAE,aAAa;YAClB,KAAK,EAAE,cAAc;YACrB,WAAW,EAAE,2CAA2C;YACxD,OAAO,EAAE,QAAQ;YACjB,QAAQ,EAAE,IAAI;SACf;QACD;YACE,GAAG,EAAE,oBAAoB;YACzB,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,8BAA8B;YAC3C,OAAO,EAAE,oBAAoB;YAC7B,QAAQ,EAAE,IAAI;SACf;KACF;IACD,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCb;IACC,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;;;;;CAuBvB;IACC,gBAAgB,EAAE;;;;;;;;;;;CAWnB;CACA,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ContextSuggestion } from '../../types/index.js';
2
+ /**
3
+ * Analyzes the last invoked tool and suggests groups that should be activated.
4
+ * Returns suggestions sorted by confidence (highest first).
5
+ */
6
+ export declare function analyzeContext(lastToolUsed: string, enabledGroups: Set<string>): ContextSuggestion[];
7
+ /**
8
+ * Returns the group id that a given tool belongs to, or undefined.
9
+ */
10
+ export declare function findGroupForTool(toolName: string): string | undefined;
11
+ //# sourceMappingURL=context-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-analyzer.d.ts","sourceRoot":"","sources":["../../../src/engine/tool-groups/context-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AAQ/E;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,iBAAiB,EAAE,CA2BrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErE"}
@@ -0,0 +1,40 @@
1
+ import toolGroupsConfigJson from '../../config/tool-groups.json' with { type: 'json' };
2
+ const config = toolGroupsConfigJson;
3
+ const TRIGGER_CONFIDENCE = 0.9;
4
+ const MEMBER_CONFIDENCE = 0.5;
5
+ /**
6
+ * Analyzes the last invoked tool and suggests groups that should be activated.
7
+ * Returns suggestions sorted by confidence (highest first).
8
+ */
9
+ export function analyzeContext(lastToolUsed, enabledGroups) {
10
+ const suggestions = [];
11
+ for (const group of config.groups) {
12
+ if (enabledGroups.has(group.id)) {
13
+ continue;
14
+ }
15
+ const isTrigger = group.triggerTools?.includes(lastToolUsed) ?? false;
16
+ const isMember = group.tools.includes(lastToolUsed);
17
+ if (isTrigger) {
18
+ suggestions.push({
19
+ suggestedGroup: group.id,
20
+ reason: `Tool "${lastToolUsed}" is a trigger for group "${group.name}"`,
21
+ confidence: TRIGGER_CONFIDENCE,
22
+ });
23
+ }
24
+ else if (isMember) {
25
+ suggestions.push({
26
+ suggestedGroup: group.id,
27
+ reason: `Tool "${lastToolUsed}" belongs to group "${group.name}"`,
28
+ confidence: MEMBER_CONFIDENCE,
29
+ });
30
+ }
31
+ }
32
+ return suggestions.sort((a, b) => b.confidence - a.confidence);
33
+ }
34
+ /**
35
+ * Returns the group id that a given tool belongs to, or undefined.
36
+ */
37
+ export function findGroupForTool(toolName) {
38
+ return config.groups.find((g) => g.tools.includes(toolName))?.id;
39
+ }
40
+ //# sourceMappingURL=context-analyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-analyzer.js","sourceRoot":"","sources":["../../../src/engine/tool-groups/context-analyzer.ts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,MAAM,+BAA+B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEvF,MAAM,MAAM,GAAG,oBAAyD,CAAC;AAEzE,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAoB,EACpB,aAA0B;IAE1B,MAAM,WAAW,GAAwB,EAAE,CAAC;IAE5C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,SAAS;QACX,CAAC;QAED,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC;QACtE,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAEpD,IAAI,SAAS,EAAE,CAAC;YACd,WAAW,CAAC,IAAI,CAAC;gBACf,cAAc,EAAE,KAAK,CAAC,EAAE;gBACxB,MAAM,EAAE,SAAS,YAAY,6BAA6B,KAAK,CAAC,IAAI,GAAG;gBACvE,UAAU,EAAE,kBAAkB;aAC/B,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,QAAQ,EAAE,CAAC;YACpB,WAAW,CAAC,IAAI,CAAC;gBACf,cAAc,EAAE,KAAK,CAAC,EAAE;gBACxB,MAAM,EAAE,SAAS,YAAY,uBAAuB,KAAK,CAAC,IAAI,GAAG;gBACjE,UAAU,EAAE,iBAAiB;aAC9B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;AACnE,CAAC"}