@nerviq/cli 1.18.0 → 1.20.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 (187) hide show
  1. package/LICENSE +23 -23
  2. package/README.md +2 -2
  3. package/bin/cli.js +131 -130
  4. package/package.json +2 -1
  5. package/src/activity.js +1039 -1039
  6. package/src/adoption-advisor.js +299 -299
  7. package/src/aider/config-parser.js +166 -166
  8. package/src/aider/context.js +158 -158
  9. package/src/aider/deep-review.js +316 -316
  10. package/src/aider/domain-packs.js +303 -303
  11. package/src/aider/freshness.js +93 -93
  12. package/src/aider/governance.js +253 -253
  13. package/src/aider/interactive.js +334 -334
  14. package/src/aider/mcp-packs.js +329 -329
  15. package/src/aider/patch.js +214 -214
  16. package/src/aider/plans.js +186 -186
  17. package/src/aider/premium.js +360 -360
  18. package/src/aider/setup.js +404 -404
  19. package/src/aider/techniques.js +16 -16
  20. package/src/analyze.js +951 -951
  21. package/src/anti-patterns.js +485 -485
  22. package/src/audit/instruction-files.js +180 -180
  23. package/src/audit/recommendations.js +577 -577
  24. package/src/auto-suggest.js +154 -154
  25. package/src/badge.js +13 -13
  26. package/src/behavioral-drift.js +801 -801
  27. package/src/benchmark.js +67 -67
  28. package/src/catalog.js +103 -103
  29. package/src/certification.js +128 -128
  30. package/src/codex/config-parser.js +183 -183
  31. package/src/codex/context.js +223 -223
  32. package/src/codex/deep-review.js +493 -493
  33. package/src/codex/domain-packs.js +394 -394
  34. package/src/codex/freshness.js +84 -84
  35. package/src/codex/governance.js +192 -192
  36. package/src/codex/interactive.js +618 -618
  37. package/src/codex/mcp-packs.js +914 -914
  38. package/src/codex/patch.js +209 -209
  39. package/src/codex/plans.js +251 -251
  40. package/src/codex/premium.js +614 -614
  41. package/src/codex/setup.js +591 -591
  42. package/src/context.js +320 -320
  43. package/src/continuous-ops.js +681 -681
  44. package/src/copilot/activity.js +309 -309
  45. package/src/copilot/deep-review.js +346 -346
  46. package/src/copilot/domain-packs.js +372 -372
  47. package/src/copilot/freshness.js +57 -57
  48. package/src/copilot/governance.js +222 -222
  49. package/src/copilot/interactive.js +406 -406
  50. package/src/copilot/mcp-packs.js +826 -826
  51. package/src/copilot/plans.js +253 -253
  52. package/src/copilot/premium.js +451 -451
  53. package/src/copilot/setup.js +488 -488
  54. package/src/cost-tracking.js +61 -61
  55. package/src/cursor/activity.js +301 -301
  56. package/src/cursor/config-parser.js +265 -265
  57. package/src/cursor/context.js +256 -256
  58. package/src/cursor/deep-review.js +334 -334
  59. package/src/cursor/domain-packs.js +368 -368
  60. package/src/cursor/freshness.js +65 -65
  61. package/src/cursor/governance.js +229 -229
  62. package/src/cursor/interactive.js +391 -391
  63. package/src/cursor/mcp-packs.js +828 -828
  64. package/src/cursor/plans.js +254 -254
  65. package/src/cursor/premium.js +469 -469
  66. package/src/cursor/setup.js +488 -488
  67. package/src/dashboard.js +493 -493
  68. package/src/deep-review.js +428 -428
  69. package/src/deprecation.js +98 -98
  70. package/src/diff-only.js +280 -280
  71. package/src/doctor.js +119 -119
  72. package/src/domain-pack-expansion.js +1033 -1033
  73. package/src/domain-packs.js +387 -387
  74. package/src/feedback.js +178 -178
  75. package/src/fix-engine.js +783 -783
  76. package/src/fix-prompts.js +122 -122
  77. package/src/formatters/sarif.js +115 -115
  78. package/src/freshness.js +74 -74
  79. package/src/gemini/config-parser.js +275 -275
  80. package/src/gemini/context.js +290 -221
  81. package/src/gemini/deep-review.js +559 -559
  82. package/src/gemini/domain-packs.js +393 -393
  83. package/src/gemini/freshness.js +66 -66
  84. package/src/gemini/governance.js +201 -201
  85. package/src/gemini/interactive.js +860 -860
  86. package/src/gemini/mcp-packs.js +915 -915
  87. package/src/gemini/plans.js +269 -269
  88. package/src/gemini/premium.js +760 -760
  89. package/src/gemini/setup.js +692 -692
  90. package/src/gemini/techniques.js +105 -33
  91. package/src/governance.js +72 -72
  92. package/src/harmony/add.js +68 -68
  93. package/src/harmony/advisor.js +333 -333
  94. package/src/harmony/canon.js +565 -565
  95. package/src/harmony/cli.js +591 -591
  96. package/src/harmony/drift.js +401 -401
  97. package/src/harmony/governance.js +313 -313
  98. package/src/harmony/memory.js +239 -239
  99. package/src/harmony/sync.js +475 -475
  100. package/src/harmony/watch.js +370 -370
  101. package/src/hook-validation.js +342 -342
  102. package/src/index.js +271 -271
  103. package/src/init.js +184 -184
  104. package/src/instruction-surfaces.js +185 -185
  105. package/src/integrations.js +144 -144
  106. package/src/interactive.js +118 -118
  107. package/src/locales/en.json +1 -1
  108. package/src/locales/es.json +1 -1
  109. package/src/mcp-packs.js +830 -830
  110. package/src/mcp-server.js +726 -726
  111. package/src/mcp-validation.js +337 -337
  112. package/src/nerviq-sync.json +7 -7
  113. package/src/opencode/config-parser.js +109 -109
  114. package/src/opencode/context.js +247 -247
  115. package/src/opencode/deep-review.js +313 -313
  116. package/src/opencode/domain-packs.js +262 -262
  117. package/src/opencode/freshness.js +66 -66
  118. package/src/opencode/governance.js +159 -159
  119. package/src/opencode/interactive.js +392 -392
  120. package/src/opencode/mcp-packs.js +705 -705
  121. package/src/opencode/patch.js +184 -184
  122. package/src/opencode/plans.js +231 -231
  123. package/src/opencode/premium.js +413 -413
  124. package/src/opencode/setup.js +449 -449
  125. package/src/opencode/techniques.js +27 -27
  126. package/src/operating-profile.js +574 -574
  127. package/src/org.js +152 -152
  128. package/src/permission-rules.js +218 -218
  129. package/src/plans.js +839 -839
  130. package/src/platform-change-manifest.js +86 -86
  131. package/src/plugins.js +110 -110
  132. package/src/policy-layers.js +210 -210
  133. package/src/profiles.js +124 -124
  134. package/src/prompt-injection.js +74 -74
  135. package/src/public-api.js +173 -173
  136. package/src/recommendation-rules.js +84 -84
  137. package/src/repo-archetype.js +386 -386
  138. package/src/secret-patterns.js +39 -39
  139. package/src/server.js +527 -527
  140. package/src/setup/analysis.js +607 -607
  141. package/src/setup/runtime.js +172 -172
  142. package/src/setup.js +677 -677
  143. package/src/shared/capabilities.js +194 -194
  144. package/src/source-urls.js +132 -132
  145. package/src/stack-checks.js +565 -565
  146. package/src/supplemental-checks.js +13 -13
  147. package/src/synergy/adaptive.js +261 -261
  148. package/src/synergy/compensation.js +137 -137
  149. package/src/synergy/evidence.js +193 -193
  150. package/src/synergy/learning.js +199 -199
  151. package/src/synergy/patterns.js +227 -227
  152. package/src/synergy/ranking.js +83 -83
  153. package/src/synergy/report.js +165 -165
  154. package/src/synergy/routing.js +146 -146
  155. package/src/techniques/api.js +407 -407
  156. package/src/techniques/automation.js +316 -316
  157. package/src/techniques/compliance.js +257 -257
  158. package/src/techniques/hygiene.js +294 -294
  159. package/src/techniques/instructions.js +243 -243
  160. package/src/techniques/observability.js +226 -226
  161. package/src/techniques/optimization.js +142 -142
  162. package/src/techniques/quality.js +318 -318
  163. package/src/techniques/security.js +237 -237
  164. package/src/techniques/shared.js +443 -443
  165. package/src/techniques/stacks.js +2294 -2294
  166. package/src/techniques/tools.js +106 -106
  167. package/src/techniques/workflow.js +413 -413
  168. package/src/techniques.js +81 -81
  169. package/src/terminology.js +73 -73
  170. package/src/token-estimate.js +35 -35
  171. package/src/usage-patterns.js +99 -99
  172. package/src/verification-metadata.js +145 -145
  173. package/src/watch.js +247 -247
  174. package/src/windsurf/activity.js +302 -302
  175. package/src/windsurf/config-parser.js +267 -267
  176. package/src/windsurf/context.js +249 -249
  177. package/src/windsurf/deep-review.js +337 -337
  178. package/src/windsurf/domain-packs.js +370 -370
  179. package/src/windsurf/freshness.js +36 -36
  180. package/src/windsurf/governance.js +231 -231
  181. package/src/windsurf/interactive.js +388 -388
  182. package/src/windsurf/mcp-packs.js +792 -792
  183. package/src/windsurf/plans.js +247 -247
  184. package/src/windsurf/premium.js +468 -468
  185. package/src/windsurf/setup.js +471 -471
  186. package/src/windsurf/techniques.js +17 -17
  187. package/src/workspace.js +375 -375
@@ -1,407 +1,407 @@
1
- /**
2
- * Api technique fragments.
3
- * Generated mechanically from the legacy techniques.js monolith during HR-09.
4
- */
5
-
6
- const {
7
- findProjectFiles,
8
- hasProjectFile,
9
- readProjectFiles,
10
- } = require('./shared');
11
-
12
- module.exports = {
13
- websocketLib: {
14
- id: 130201,
15
- name: 'WebSocket library configured',
16
- check: (ctx) => {
17
- const deps = ctx.fileContent('package.json') || '';
18
- const pyDeps = ctx.fileContent('requirements.txt') || '';
19
- const goDeps = ctx.fileContent('go.mod') || '';
20
- return /socket\.io|"ws"|sockjs|@nestjs\/websockets|phoenix|channels/i.test(deps) ||
21
- /websockets|channels|tornado/i.test(pyDeps) ||
22
- /gorilla\/websocket|nhooyr\.io\/websocket/i.test(goDeps) || null;
23
- },
24
- impact: 'low',
25
- category: 'realtime',
26
- fix: 'Add a WebSocket library for real-time communication if your app needs live updates.',
27
- confidence: 0.7,
28
- },
29
-
30
- sseEndpoint: {
31
- id: 130202,
32
- name: 'Server-Sent Events patterns detected',
33
- check: (ctx) => {
34
- const codeFiles = findProjectFiles(ctx, /\.(js|ts|jsx|tsx|py|go|rb)$/i);
35
- if (codeFiles.length === 0) return null;
36
- return codeFiles.some(f => {
37
- const content = ctx.fileContent(f) || '';
38
- return /EventSource|text\/event-stream|SSE/i.test(content);
39
- }) || null;
40
- },
41
- impact: 'low',
42
- category: 'realtime',
43
- fix: 'Consider Server-Sent Events (SSE) for server-to-client streaming when full duplex is not needed.',
44
- confidence: 0.7,
45
- },
46
-
47
- realtimeDatabase: {
48
- id: 130203,
49
- name: 'Real-time database configured',
50
- check: (ctx) => {
51
- const deps = ctx.fileContent('package.json') || '';
52
- const pyDeps = ctx.fileContent('requirements.txt') || '';
53
- return /firebase-admin|supabase|convex|pusher/i.test(deps) ||
54
- /firebase-admin|supabase|pusher/i.test(pyDeps) || null;
55
- },
56
- impact: 'low',
57
- category: 'realtime',
58
- fix: 'Add a real-time database (Firebase, Supabase, Convex) for live data synchronization.',
59
- confidence: 0.7,
60
- },
61
-
62
- pubsubPattern: {
63
- id: 130204,
64
- name: 'Pub/sub messaging configured',
65
- check: (ctx) => {
66
- const deps = ctx.fileContent('package.json') || '';
67
- const pyDeps = ctx.fileContent('requirements.txt') || '';
68
- const goDeps = ctx.fileContent('go.mod') || '';
69
- return /ioredis|redis|nats|kafkajs|amqplib|bullmq/i.test(deps) ||
70
- /redis|nats-py|kafka-python|pika|celery/i.test(pyDeps) ||
71
- /go-redis|nats\.go|sarama|amqp091-go/i.test(goDeps) || null;
72
- },
73
- impact: 'low',
74
- category: 'realtime',
75
- fix: 'Add a pub/sub messaging system (Redis, NATS, Kafka, RabbitMQ) for decoupled real-time communication.',
76
- confidence: 0.7,
77
- },
78
-
79
- realtimeAuth: {
80
- id: 130205,
81
- name: 'WebSocket authentication patterns present',
82
- check: (ctx) => {
83
- const codeFiles = findProjectFiles(ctx, /\.(js|ts|jsx|tsx|py|go)$/i);
84
- if (codeFiles.length === 0) return null;
85
- return codeFiles.some(f => {
86
- const content = ctx.fileContent(f) || '';
87
- return /ws.*auth|socket.*token|connection.*auth|handleConnection.*jwt|on.*connect.*verify/i.test(content);
88
- }) || null;
89
- },
90
- impact: 'low',
91
- category: 'realtime',
92
- fix: 'Add authentication to WebSocket connections — validate tokens on connect to prevent unauthorized access.',
93
- confidence: 0.7,
94
- },
95
-
96
- graphqlSchema: {
97
- id: 130206,
98
- name: 'GraphQL schema defined',
99
- check: (ctx) => {
100
- const deps = ctx.fileContent('package.json') || '';
101
- const pyDeps = ctx.fileContent('requirements.txt') || '';
102
- if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
103
- !/graphene|ariadne|strawberry/i.test(pyDeps) &&
104
- !hasProjectFile(ctx, /\.graphql$/i)) return null;
105
- const schemaFiles = findProjectFiles(ctx, /\.(graphql|gql)$/i);
106
- if (schemaFiles.length > 0) return true;
107
- const codeFiles = findProjectFiles(ctx, /\.(js|ts|py)$/i);
108
- return codeFiles.some(f => {
109
- const content = ctx.fileContent(f) || '';
110
- return /buildSchema|makeExecutableSchema|typeDefs|@ObjectType|type Query/i.test(content);
111
- }) || false;
112
- },
113
- impact: 'low',
114
- category: 'graphql',
115
- fix: 'Define a GraphQL schema using .graphql files or schema-first/code-first approach.',
116
- confidence: 0.7,
117
- },
118
-
119
- graphqlResolvers: {
120
- id: 130207,
121
- name: 'GraphQL resolvers implemented',
122
- check: (ctx) => {
123
- const deps = ctx.fileContent('package.json') || '';
124
- const pyDeps = ctx.fileContent('requirements.txt') || '';
125
- if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
126
- !/graphene|ariadne|strawberry/i.test(pyDeps) &&
127
- !hasProjectFile(ctx, /\.graphql$/i)) return null;
128
- const codeFiles = findProjectFiles(ctx, /\.(js|ts|py)$/i);
129
- return codeFiles.some(f => {
130
- const content = ctx.fileContent(f) || '';
131
- return /@Resolver|@Query|@Mutation|resolvers|resolve_/i.test(content) ||
132
- /resolver/i.test(f);
133
- }) || false;
134
- },
135
- impact: 'low',
136
- category: 'graphql',
137
- fix: 'Implement GraphQL resolvers to handle queries, mutations, and field resolution.',
138
- confidence: 0.7,
139
- },
140
-
141
- graphqlCodegen: {
142
- id: 130208,
143
- name: 'GraphQL code generation configured',
144
- check: (ctx) => {
145
- const deps = ctx.fileContent('package.json') || '';
146
- const pyDeps = ctx.fileContent('requirements.txt') || '';
147
- if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
148
- !/graphene|ariadne|strawberry/i.test(pyDeps) &&
149
- !hasProjectFile(ctx, /\.graphql$/i)) return null;
150
- return /@graphql-codegen|graphql-let|graphql-code-generator/i.test(deps) || false;
151
- },
152
- impact: 'low',
153
- category: 'graphql',
154
- fix: 'Add @graphql-codegen for type-safe GraphQL operations and automatic TypeScript type generation.',
155
- confidence: 0.7,
156
- },
157
-
158
- graphqlNPlusOne: {
159
- id: 130209,
160
- name: 'GraphQL N+1 prevention (DataLoader)',
161
- check: (ctx) => {
162
- const deps = ctx.fileContent('package.json') || '';
163
- const pyDeps = ctx.fileContent('requirements.txt') || '';
164
- if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
165
- !/graphene|ariadne|strawberry/i.test(pyDeps) &&
166
- !hasProjectFile(ctx, /\.graphql$/i)) return null;
167
- const codeFiles = findProjectFiles(ctx, /\.(js|ts|py)$/i);
168
- return /dataloader/i.test(deps) ||
169
- /aiodataloader|promise/i.test(pyDeps) ||
170
- codeFiles.some(f => /dataloader|batch.*load|DataLoader/i.test(ctx.fileContent(f) || '')) || false;
171
- },
172
- impact: 'low',
173
- category: 'graphql',
174
- fix: 'Use DataLoader or batch loading patterns to prevent N+1 query problems in GraphQL resolvers.',
175
- confidence: 0.7,
176
- },
177
-
178
- graphqlSubscriptions: {
179
- id: 130210,
180
- name: 'GraphQL subscriptions configured',
181
- check: (ctx) => {
182
- const deps = ctx.fileContent('package.json') || '';
183
- const pyDeps = ctx.fileContent('requirements.txt') || '';
184
- if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
185
- !/graphene|ariadne|strawberry/i.test(pyDeps) &&
186
- !hasProjectFile(ctx, /\.graphql$/i)) return null;
187
- return /subscriptions-transport-ws|graphql-ws/i.test(deps) ||
188
- findProjectFiles(ctx, /\.(js|ts|py)$/i).some(f => {
189
- const content = ctx.fileContent(f) || '';
190
- return /@Subscription|PubSub|subscription\s+\w+/i.test(content);
191
- }) || false;
192
- },
193
- impact: 'low',
194
- category: 'graphql',
195
- fix: 'Configure GraphQL subscriptions with graphql-ws for real-time data pushed to clients.',
196
- confidence: 0.7,
197
- },
198
-
199
- apiVersionHeader: {
200
- id: 130111,
201
- name: 'API versioning pattern present',
202
- check: (ctx) => {
203
- const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb)$/i, 30);
204
- const config = readProjectFiles(ctx, /\.(ya?ml|json)$/i, 20);
205
- return /\/v[12]\/|api-version|Accept-Version|x-api-version/i.test(src + config);
206
- },
207
- impact: 'medium',
208
- category: 'api-versioning',
209
- fix: 'Add API versioning (URL prefix /v1/, header Accept-Version) to manage breaking changes safely.',
210
- confidence: 0.7,
211
- },
212
-
213
- deprecationNotices: {
214
- id: 130112,
215
- name: 'Deprecation notices in API code',
216
- check: (ctx) => {
217
- const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb)$/i, 30);
218
- return /@deprecated|Deprecation|Sunset|x-deprecated/i.test(src);
219
- },
220
- impact: 'low',
221
- category: 'api-versioning',
222
- fix: 'Add @deprecated annotations or Deprecation/Sunset headers to signal API endpoint retirement.',
223
- confidence: 0.7,
224
- },
225
-
226
- apiChangelog: {
227
- id: 130113,
228
- name: 'API changelog exists',
229
- check: (ctx) => {
230
- if (hasProjectFile(ctx, /(^|\/)api-changelog/i)) return true;
231
- const changelog = ctx.fileContent('CHANGELOG.md') || '';
232
- return /\bAPI\b/i.test(changelog);
233
- },
234
- impact: 'low',
235
- category: 'api-versioning',
236
- fix: 'Add an API changelog (CHANGELOG.md with API section or api-changelog file) to document breaking changes.',
237
- confidence: 0.7,
238
- },
239
-
240
- backwardCompat: {
241
- id: 130114,
242
- name: 'Backward compatibility tests or migrations',
243
- check: (ctx) => {
244
- return hasProjectFile(ctx, /(^|\/)(migration|migrate)/i) ||
245
- hasProjectFile(ctx, /(backward|compat).*test/i);
246
- },
247
- impact: 'medium',
248
- category: 'api-versioning',
249
- fix: 'Add backward compatibility tests or migration scripts to validate API changes don\'t break clients.',
250
- confidence: 0.7,
251
- },
252
-
253
- apiDocVersioned: {
254
- id: 130115,
255
- name: 'Versioned API documentation',
256
- check: (ctx) => {
257
- const docs = readProjectFiles(ctx, /(openapi|swagger)\.(ya?ml|json)$/i);
258
- return /version/i.test(docs);
259
- },
260
- impact: 'low',
261
- category: 'api-versioning',
262
- fix: 'Add versioned API documentation (OpenAPI/Swagger spec with version field) for API consumers.',
263
- confidence: 0.7,
264
- },
265
-
266
- cacheLayer: {
267
- id: 130121,
268
- name: 'Cache library in dependencies',
269
- check: (ctx) => {
270
- const pkg = ctx.fileContent('package.json') || '';
271
- if (/redis|memcached|ioredis|node-cache|lru-cache/i.test(pkg)) return true;
272
- const py = readProjectFiles(ctx, /(^|\/)pyproject\.toml$/i) + readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
273
- if (/redis|memcached|django-cache|cachetools/i.test(py)) return true;
274
- return false;
275
- },
276
- impact: 'medium',
277
- category: 'caching',
278
- fix: 'Add a caching layer (redis, memcached, ioredis, lru-cache) to reduce latency and database load.',
279
- confidence: 0.7,
280
- },
281
-
282
- cdnConfigured: {
283
- id: 130122,
284
- name: 'CDN configured',
285
- check: (ctx) => {
286
- const config = readProjectFiles(ctx, /\.(json|ya?ml|toml|conf)$/i, 20);
287
- const src = readProjectFiles(ctx, /\.(jsx?|tsx?)$/i, 20);
288
- return /cloudfront|cloudflare|fastly|cdn/i.test(config + src) ||
289
- (ctx.files.includes('vercel.json') && /headers/i.test(ctx.fileContent('vercel.json') || ''));
290
- },
291
- impact: 'medium',
292
- category: 'caching',
293
- fix: 'Configure a CDN (CloudFront, Cloudflare, Fastly) for static asset delivery and edge caching.',
294
- confidence: 0.7,
295
- },
296
-
297
- cacheHeaders: {
298
- id: 130123,
299
- name: 'Cache-Control headers configured',
300
- check: (ctx) => {
301
- const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb|conf)$/i, 30);
302
- return /Cache-Control|max-age|s-maxage|stale-while-revalidate/i.test(src);
303
- },
304
- impact: 'medium',
305
- category: 'caching',
306
- fix: 'Set Cache-Control headers (max-age, s-maxage, stale-while-revalidate) for HTTP response caching.',
307
- confidence: 0.7,
308
- },
309
-
310
- cacheInvalidation: {
311
- id: 130124,
312
- name: 'Cache invalidation patterns present',
313
- check: (ctx) => {
314
- const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb)$/i, 30);
315
- return /cache.*purge|cache.*bust|cache.*invalidat|\.del\(|\.flush\(/i.test(src);
316
- },
317
- impact: 'low',
318
- category: 'caching',
319
- fix: 'Implement cache invalidation patterns (purge, bust, invalidate) to prevent serving stale data.',
320
- confidence: 0.7,
321
- },
322
-
323
- httpCaching: {
324
- id: 130125,
325
- name: 'ETag or Last-Modified caching',
326
- check: (ctx) => {
327
- const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb|conf)$/i, 30);
328
- return /ETag|Last-Modified|If-None-Match|If-Modified-Since/i.test(src);
329
- },
330
- impact: 'low',
331
- category: 'caching',
332
- fix: 'Implement ETag or Last-Modified headers for conditional HTTP caching and bandwidth savings.',
333
- confidence: 0.7,
334
- },
335
-
336
- rateLimitMiddleware: {
337
- id: 130131,
338
- name: 'Rate limiting middleware configured',
339
- check: (ctx) => {
340
- const pkg = ctx.fileContent('package.json') || '';
341
- if (/express-rate-limit|@nestjs\/throttler|rate-limiter-flexible|koa-ratelimit/i.test(pkg)) return true;
342
- const py = readProjectFiles(ctx, /(^|\/)pyproject\.toml$/i) + readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
343
- if (/django-ratelimit|slowapi|flask-limiter/i.test(py)) return true;
344
- return false;
345
- },
346
- impact: 'medium',
347
- category: 'rate-limiting',
348
- fix: 'Add rate limiting middleware (express-rate-limit, @nestjs/throttler, rate-limiter-flexible) to protect APIs.',
349
- confidence: 0.7,
350
- },
351
-
352
- ddosProtection: {
353
- id: 130132,
354
- name: 'DDoS protection configured',
355
- check: (ctx) => {
356
- const pkg = ctx.fileContent('package.json') || '';
357
- const config = readProjectFiles(ctx, /\.(json|ya?ml|toml|conf)$/i, 20);
358
- return /helmet|cors|cloudflare|waf|ddos/i.test(pkg + config);
359
- },
360
- impact: 'medium',
361
- category: 'rate-limiting',
362
- fix: 'Add DDoS protection (helmet, CORS, WAF, Cloudflare) to defend against abuse and volumetric attacks.',
363
- confidence: 0.7,
364
- },
365
-
366
- backoffStrategy: {
367
- id: 130133,
368
- name: 'Retry/backoff strategy in dependencies',
369
- check: (ctx) => {
370
- const pkg = ctx.fileContent('package.json') || '';
371
- if (/exponential-backoff|p-retry|async-retry|retry|got.*retry|axios-retry/i.test(pkg)) return true;
372
- const py = readProjectFiles(ctx, /(^|\/)pyproject\.toml$/i) + readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
373
- if (/tenacity|backoff|urllib3.*retry/i.test(py)) return true;
374
- return false;
375
- },
376
- impact: 'low',
377
- category: 'rate-limiting',
378
- fix: 'Add a retry/backoff library (p-retry, tenacity, exponential-backoff) for resilient external calls.',
379
- confidence: 0.7,
380
- },
381
-
382
- requestThrottling: {
383
- id: 130134,
384
- name: 'Request throttling in dependencies',
385
- check: (ctx) => {
386
- const pkg = ctx.fileContent('package.json') || '';
387
- return /bottleneck|p-throttle|p-limit|throttle/i.test(pkg);
388
- },
389
- impact: 'low',
390
- category: 'rate-limiting',
391
- fix: 'Add request throttling (bottleneck, p-throttle) to control outbound API call rates.',
392
- confidence: 0.7,
393
- },
394
-
395
- rateLimitHeaders: {
396
- id: 130135,
397
- name: 'Rate limit headers or 429 responses',
398
- check: (ctx) => {
399
- const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb)$/i, 30);
400
- return /X-RateLimit|RateLimit-|429|Too Many Requests/i.test(src);
401
- },
402
- impact: 'low',
403
- category: 'rate-limiting',
404
- fix: 'Return X-RateLimit headers and 429 status codes so clients can handle rate limiting gracefully.',
405
- confidence: 0.7,
406
- },
407
- };
1
+ /**
2
+ * Api technique fragments.
3
+ * Generated mechanically from the legacy techniques.js monolith during HR-09.
4
+ */
5
+
6
+ const {
7
+ findProjectFiles,
8
+ hasProjectFile,
9
+ readProjectFiles,
10
+ } = require('./shared');
11
+
12
+ module.exports = {
13
+ websocketLib: {
14
+ id: 130201,
15
+ name: 'WebSocket library configured',
16
+ check: (ctx) => {
17
+ const deps = ctx.fileContent('package.json') || '';
18
+ const pyDeps = ctx.fileContent('requirements.txt') || '';
19
+ const goDeps = ctx.fileContent('go.mod') || '';
20
+ return /socket\.io|"ws"|sockjs|@nestjs\/websockets|phoenix|channels/i.test(deps) ||
21
+ /websockets|channels|tornado/i.test(pyDeps) ||
22
+ /gorilla\/websocket|nhooyr\.io\/websocket/i.test(goDeps) || null;
23
+ },
24
+ impact: 'low',
25
+ category: 'realtime',
26
+ fix: 'Add a WebSocket library for real-time communication if your app needs live updates.',
27
+ confidence: 0.7,
28
+ },
29
+
30
+ sseEndpoint: {
31
+ id: 130202,
32
+ name: 'Server-Sent Events patterns detected',
33
+ check: (ctx) => {
34
+ const codeFiles = findProjectFiles(ctx, /\.(js|ts|jsx|tsx|py|go|rb)$/i);
35
+ if (codeFiles.length === 0) return null;
36
+ return codeFiles.some(f => {
37
+ const content = ctx.fileContent(f) || '';
38
+ return /EventSource|text\/event-stream|SSE/i.test(content);
39
+ }) || null;
40
+ },
41
+ impact: 'low',
42
+ category: 'realtime',
43
+ fix: 'Consider Server-Sent Events (SSE) for server-to-client streaming when full duplex is not needed.',
44
+ confidence: 0.7,
45
+ },
46
+
47
+ realtimeDatabase: {
48
+ id: 130203,
49
+ name: 'Real-time database configured',
50
+ check: (ctx) => {
51
+ const deps = ctx.fileContent('package.json') || '';
52
+ const pyDeps = ctx.fileContent('requirements.txt') || '';
53
+ return /firebase-admin|supabase|convex|pusher/i.test(deps) ||
54
+ /firebase-admin|supabase|pusher/i.test(pyDeps) || null;
55
+ },
56
+ impact: 'low',
57
+ category: 'realtime',
58
+ fix: 'Add a real-time database (Firebase, Supabase, Convex) for live data synchronization.',
59
+ confidence: 0.7,
60
+ },
61
+
62
+ pubsubPattern: {
63
+ id: 130204,
64
+ name: 'Pub/sub messaging configured',
65
+ check: (ctx) => {
66
+ const deps = ctx.fileContent('package.json') || '';
67
+ const pyDeps = ctx.fileContent('requirements.txt') || '';
68
+ const goDeps = ctx.fileContent('go.mod') || '';
69
+ return /ioredis|redis|nats|kafkajs|amqplib|bullmq/i.test(deps) ||
70
+ /redis|nats-py|kafka-python|pika|celery/i.test(pyDeps) ||
71
+ /go-redis|nats\.go|sarama|amqp091-go/i.test(goDeps) || null;
72
+ },
73
+ impact: 'low',
74
+ category: 'realtime',
75
+ fix: 'Add a pub/sub messaging system (Redis, NATS, Kafka, RabbitMQ) for decoupled real-time communication.',
76
+ confidence: 0.7,
77
+ },
78
+
79
+ realtimeAuth: {
80
+ id: 130205,
81
+ name: 'WebSocket authentication patterns present',
82
+ check: (ctx) => {
83
+ const codeFiles = findProjectFiles(ctx, /\.(js|ts|jsx|tsx|py|go)$/i);
84
+ if (codeFiles.length === 0) return null;
85
+ return codeFiles.some(f => {
86
+ const content = ctx.fileContent(f) || '';
87
+ return /ws.*auth|socket.*token|connection.*auth|handleConnection.*jwt|on.*connect.*verify/i.test(content);
88
+ }) || null;
89
+ },
90
+ impact: 'low',
91
+ category: 'realtime',
92
+ fix: 'Add authentication to WebSocket connections — validate tokens on connect to prevent unauthorized access.',
93
+ confidence: 0.7,
94
+ },
95
+
96
+ graphqlSchema: {
97
+ id: 130206,
98
+ name: 'GraphQL schema defined',
99
+ check: (ctx) => {
100
+ const deps = ctx.fileContent('package.json') || '';
101
+ const pyDeps = ctx.fileContent('requirements.txt') || '';
102
+ if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
103
+ !/graphene|ariadne|strawberry/i.test(pyDeps) &&
104
+ !hasProjectFile(ctx, /\.graphql$/i)) return null;
105
+ const schemaFiles = findProjectFiles(ctx, /\.(graphql|gql)$/i);
106
+ if (schemaFiles.length > 0) return true;
107
+ const codeFiles = findProjectFiles(ctx, /\.(js|ts|py)$/i);
108
+ return codeFiles.some(f => {
109
+ const content = ctx.fileContent(f) || '';
110
+ return /buildSchema|makeExecutableSchema|typeDefs|@ObjectType|type Query/i.test(content);
111
+ }) || false;
112
+ },
113
+ impact: 'low',
114
+ category: 'graphql',
115
+ fix: 'Define a GraphQL schema using .graphql files or schema-first/code-first approach.',
116
+ confidence: 0.7,
117
+ },
118
+
119
+ graphqlResolvers: {
120
+ id: 130207,
121
+ name: 'GraphQL resolvers implemented',
122
+ check: (ctx) => {
123
+ const deps = ctx.fileContent('package.json') || '';
124
+ const pyDeps = ctx.fileContent('requirements.txt') || '';
125
+ if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
126
+ !/graphene|ariadne|strawberry/i.test(pyDeps) &&
127
+ !hasProjectFile(ctx, /\.graphql$/i)) return null;
128
+ const codeFiles = findProjectFiles(ctx, /\.(js|ts|py)$/i);
129
+ return codeFiles.some(f => {
130
+ const content = ctx.fileContent(f) || '';
131
+ return /@Resolver|@Query|@Mutation|resolvers|resolve_/i.test(content) ||
132
+ /resolver/i.test(f);
133
+ }) || false;
134
+ },
135
+ impact: 'low',
136
+ category: 'graphql',
137
+ fix: 'Implement GraphQL resolvers to handle queries, mutations, and field resolution.',
138
+ confidence: 0.7,
139
+ },
140
+
141
+ graphqlCodegen: {
142
+ id: 130208,
143
+ name: 'GraphQL code generation configured',
144
+ check: (ctx) => {
145
+ const deps = ctx.fileContent('package.json') || '';
146
+ const pyDeps = ctx.fileContent('requirements.txt') || '';
147
+ if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
148
+ !/graphene|ariadne|strawberry/i.test(pyDeps) &&
149
+ !hasProjectFile(ctx, /\.graphql$/i)) return null;
150
+ return /@graphql-codegen|graphql-let|graphql-code-generator/i.test(deps) || false;
151
+ },
152
+ impact: 'low',
153
+ category: 'graphql',
154
+ fix: 'Add @graphql-codegen for type-safe GraphQL operations and automatic TypeScript type generation.',
155
+ confidence: 0.7,
156
+ },
157
+
158
+ graphqlNPlusOne: {
159
+ id: 130209,
160
+ name: 'GraphQL N+1 prevention (DataLoader)',
161
+ check: (ctx) => {
162
+ const deps = ctx.fileContent('package.json') || '';
163
+ const pyDeps = ctx.fileContent('requirements.txt') || '';
164
+ if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
165
+ !/graphene|ariadne|strawberry/i.test(pyDeps) &&
166
+ !hasProjectFile(ctx, /\.graphql$/i)) return null;
167
+ const codeFiles = findProjectFiles(ctx, /\.(js|ts|py)$/i);
168
+ return /dataloader/i.test(deps) ||
169
+ /aiodataloader|promise/i.test(pyDeps) ||
170
+ codeFiles.some(f => /dataloader|batch.*load|DataLoader/i.test(ctx.fileContent(f) || '')) || false;
171
+ },
172
+ impact: 'low',
173
+ category: 'graphql',
174
+ fix: 'Use DataLoader or batch loading patterns to prevent N+1 query problems in GraphQL resolvers.',
175
+ confidence: 0.7,
176
+ },
177
+
178
+ graphqlSubscriptions: {
179
+ id: 130210,
180
+ name: 'GraphQL subscriptions configured',
181
+ check: (ctx) => {
182
+ const deps = ctx.fileContent('package.json') || '';
183
+ const pyDeps = ctx.fileContent('requirements.txt') || '';
184
+ if (!/graphql|apollo|@nestjs\/graphql|type-graphql/i.test(deps) &&
185
+ !/graphene|ariadne|strawberry/i.test(pyDeps) &&
186
+ !hasProjectFile(ctx, /\.graphql$/i)) return null;
187
+ return /subscriptions-transport-ws|graphql-ws/i.test(deps) ||
188
+ findProjectFiles(ctx, /\.(js|ts|py)$/i).some(f => {
189
+ const content = ctx.fileContent(f) || '';
190
+ return /@Subscription|PubSub|subscription\s+\w+/i.test(content);
191
+ }) || false;
192
+ },
193
+ impact: 'low',
194
+ category: 'graphql',
195
+ fix: 'Configure GraphQL subscriptions with graphql-ws for real-time data pushed to clients.',
196
+ confidence: 0.7,
197
+ },
198
+
199
+ apiVersionHeader: {
200
+ id: 130111,
201
+ name: 'API versioning pattern present',
202
+ check: (ctx) => {
203
+ const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb)$/i, 30);
204
+ const config = readProjectFiles(ctx, /\.(ya?ml|json)$/i, 20);
205
+ return /\/v[12]\/|api-version|Accept-Version|x-api-version/i.test(src + config);
206
+ },
207
+ impact: 'medium',
208
+ category: 'api-versioning',
209
+ fix: 'Add API versioning (URL prefix /v1/, header Accept-Version) to manage breaking changes safely.',
210
+ confidence: 0.7,
211
+ },
212
+
213
+ deprecationNotices: {
214
+ id: 130112,
215
+ name: 'Deprecation notices in API code',
216
+ check: (ctx) => {
217
+ const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb)$/i, 30);
218
+ return /@deprecated|Deprecation|Sunset|x-deprecated/i.test(src);
219
+ },
220
+ impact: 'low',
221
+ category: 'api-versioning',
222
+ fix: 'Add @deprecated annotations or Deprecation/Sunset headers to signal API endpoint retirement.',
223
+ confidence: 0.7,
224
+ },
225
+
226
+ apiChangelog: {
227
+ id: 130113,
228
+ name: 'API changelog exists',
229
+ check: (ctx) => {
230
+ if (hasProjectFile(ctx, /(^|\/)api-changelog/i)) return true;
231
+ const changelog = ctx.fileContent('CHANGELOG.md') || '';
232
+ return /\bAPI\b/i.test(changelog);
233
+ },
234
+ impact: 'low',
235
+ category: 'api-versioning',
236
+ fix: 'Add an API changelog (CHANGELOG.md with API section or api-changelog file) to document breaking changes.',
237
+ confidence: 0.7,
238
+ },
239
+
240
+ backwardCompat: {
241
+ id: 130114,
242
+ name: 'Backward compatibility tests or migrations',
243
+ check: (ctx) => {
244
+ return hasProjectFile(ctx, /(^|\/)(migration|migrate)/i) ||
245
+ hasProjectFile(ctx, /(backward|compat).*test/i);
246
+ },
247
+ impact: 'medium',
248
+ category: 'api-versioning',
249
+ fix: 'Add backward compatibility tests or migration scripts to validate API changes don\'t break clients.',
250
+ confidence: 0.7,
251
+ },
252
+
253
+ apiDocVersioned: {
254
+ id: 130115,
255
+ name: 'Versioned API documentation',
256
+ check: (ctx) => {
257
+ const docs = readProjectFiles(ctx, /(openapi|swagger)\.(ya?ml|json)$/i);
258
+ return /version/i.test(docs);
259
+ },
260
+ impact: 'low',
261
+ category: 'api-versioning',
262
+ fix: 'Add versioned API documentation (OpenAPI/Swagger spec with version field) for API consumers.',
263
+ confidence: 0.7,
264
+ },
265
+
266
+ cacheLayer: {
267
+ id: 130121,
268
+ name: 'Cache library in dependencies',
269
+ check: (ctx) => {
270
+ const pkg = ctx.fileContent('package.json') || '';
271
+ if (/redis|memcached|ioredis|node-cache|lru-cache/i.test(pkg)) return true;
272
+ const py = readProjectFiles(ctx, /(^|\/)pyproject\.toml$/i) + readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
273
+ if (/redis|memcached|django-cache|cachetools/i.test(py)) return true;
274
+ return false;
275
+ },
276
+ impact: 'medium',
277
+ category: 'caching',
278
+ fix: 'Add a caching layer (redis, memcached, ioredis, lru-cache) to reduce latency and database load.',
279
+ confidence: 0.7,
280
+ },
281
+
282
+ cdnConfigured: {
283
+ id: 130122,
284
+ name: 'CDN configured',
285
+ check: (ctx) => {
286
+ const config = readProjectFiles(ctx, /\.(json|ya?ml|toml|conf)$/i, 20);
287
+ const src = readProjectFiles(ctx, /\.(jsx?|tsx?)$/i, 20);
288
+ return /cloudfront|cloudflare|fastly|cdn/i.test(config + src) ||
289
+ (ctx.files.includes('vercel.json') && /headers/i.test(ctx.fileContent('vercel.json') || ''));
290
+ },
291
+ impact: 'medium',
292
+ category: 'caching',
293
+ fix: 'Configure a CDN (CloudFront, Cloudflare, Fastly) for static asset delivery and edge caching.',
294
+ confidence: 0.7,
295
+ },
296
+
297
+ cacheHeaders: {
298
+ id: 130123,
299
+ name: 'Cache-Control headers configured',
300
+ check: (ctx) => {
301
+ const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb|conf)$/i, 30);
302
+ return /Cache-Control|max-age|s-maxage|stale-while-revalidate/i.test(src);
303
+ },
304
+ impact: 'medium',
305
+ category: 'caching',
306
+ fix: 'Set Cache-Control headers (max-age, s-maxage, stale-while-revalidate) for HTTP response caching.',
307
+ confidence: 0.7,
308
+ },
309
+
310
+ cacheInvalidation: {
311
+ id: 130124,
312
+ name: 'Cache invalidation patterns present',
313
+ check: (ctx) => {
314
+ const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb)$/i, 30);
315
+ return /cache.*purge|cache.*bust|cache.*invalidat|\.del\(|\.flush\(/i.test(src);
316
+ },
317
+ impact: 'low',
318
+ category: 'caching',
319
+ fix: 'Implement cache invalidation patterns (purge, bust, invalidate) to prevent serving stale data.',
320
+ confidence: 0.7,
321
+ },
322
+
323
+ httpCaching: {
324
+ id: 130125,
325
+ name: 'ETag or Last-Modified caching',
326
+ check: (ctx) => {
327
+ const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb|conf)$/i, 30);
328
+ return /ETag|Last-Modified|If-None-Match|If-Modified-Since/i.test(src);
329
+ },
330
+ impact: 'low',
331
+ category: 'caching',
332
+ fix: 'Implement ETag or Last-Modified headers for conditional HTTP caching and bandwidth savings.',
333
+ confidence: 0.7,
334
+ },
335
+
336
+ rateLimitMiddleware: {
337
+ id: 130131,
338
+ name: 'Rate limiting middleware configured',
339
+ check: (ctx) => {
340
+ const pkg = ctx.fileContent('package.json') || '';
341
+ if (/express-rate-limit|@nestjs\/throttler|rate-limiter-flexible|koa-ratelimit/i.test(pkg)) return true;
342
+ const py = readProjectFiles(ctx, /(^|\/)pyproject\.toml$/i) + readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
343
+ if (/django-ratelimit|slowapi|flask-limiter/i.test(py)) return true;
344
+ return false;
345
+ },
346
+ impact: 'medium',
347
+ category: 'rate-limiting',
348
+ fix: 'Add rate limiting middleware (express-rate-limit, @nestjs/throttler, rate-limiter-flexible) to protect APIs.',
349
+ confidence: 0.7,
350
+ },
351
+
352
+ ddosProtection: {
353
+ id: 130132,
354
+ name: 'DDoS protection configured',
355
+ check: (ctx) => {
356
+ const pkg = ctx.fileContent('package.json') || '';
357
+ const config = readProjectFiles(ctx, /\.(json|ya?ml|toml|conf)$/i, 20);
358
+ return /helmet|cors|cloudflare|waf|ddos/i.test(pkg + config);
359
+ },
360
+ impact: 'medium',
361
+ category: 'rate-limiting',
362
+ fix: 'Add DDoS protection (helmet, CORS, WAF, Cloudflare) to defend against abuse and volumetric attacks.',
363
+ confidence: 0.7,
364
+ },
365
+
366
+ backoffStrategy: {
367
+ id: 130133,
368
+ name: 'Retry/backoff strategy in dependencies',
369
+ check: (ctx) => {
370
+ const pkg = ctx.fileContent('package.json') || '';
371
+ if (/exponential-backoff|p-retry|async-retry|retry|got.*retry|axios-retry/i.test(pkg)) return true;
372
+ const py = readProjectFiles(ctx, /(^|\/)pyproject\.toml$/i) + readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
373
+ if (/tenacity|backoff|urllib3.*retry/i.test(py)) return true;
374
+ return false;
375
+ },
376
+ impact: 'low',
377
+ category: 'rate-limiting',
378
+ fix: 'Add a retry/backoff library (p-retry, tenacity, exponential-backoff) for resilient external calls.',
379
+ confidence: 0.7,
380
+ },
381
+
382
+ requestThrottling: {
383
+ id: 130134,
384
+ name: 'Request throttling in dependencies',
385
+ check: (ctx) => {
386
+ const pkg = ctx.fileContent('package.json') || '';
387
+ return /bottleneck|p-throttle|p-limit|throttle/i.test(pkg);
388
+ },
389
+ impact: 'low',
390
+ category: 'rate-limiting',
391
+ fix: 'Add request throttling (bottleneck, p-throttle) to control outbound API call rates.',
392
+ confidence: 0.7,
393
+ },
394
+
395
+ rateLimitHeaders: {
396
+ id: 130135,
397
+ name: 'Rate limit headers or 429 responses',
398
+ check: (ctx) => {
399
+ const src = readProjectFiles(ctx, /\.(jsx?|tsx?|py|go|java|rb)$/i, 30);
400
+ return /X-RateLimit|RateLimit-|429|Too Many Requests/i.test(src);
401
+ },
402
+ impact: 'low',
403
+ category: 'rate-limiting',
404
+ fix: 'Return X-RateLimit headers and 429 status codes so clients can handle rate limiting gracefully.',
405
+ confidence: 0.7,
406
+ },
407
+ };