@nerviq/cli 1.17.3 → 1.19.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 (190) hide show
  1. package/LICENSE +23 -23
  2. package/README.md +4 -4
  3. package/bin/cli.js +61 -274
  4. package/package.json +60 -60
  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/config-parser.js +280 -226
  46. package/src/copilot/context.js +218 -197
  47. package/src/copilot/deep-review.js +346 -346
  48. package/src/copilot/domain-packs.js +372 -372
  49. package/src/copilot/freshness.js +57 -57
  50. package/src/copilot/governance.js +222 -222
  51. package/src/copilot/interactive.js +406 -406
  52. package/src/copilot/mcp-packs.js +826 -826
  53. package/src/copilot/plans.js +253 -253
  54. package/src/copilot/premium.js +451 -451
  55. package/src/copilot/setup.js +488 -488
  56. package/src/copilot/techniques.js +219 -78
  57. package/src/cost-tracking.js +61 -61
  58. package/src/cursor/activity.js +301 -301
  59. package/src/cursor/config-parser.js +265 -265
  60. package/src/cursor/context.js +256 -256
  61. package/src/cursor/deep-review.js +334 -334
  62. package/src/cursor/domain-packs.js +368 -368
  63. package/src/cursor/freshness.js +65 -65
  64. package/src/cursor/governance.js +229 -229
  65. package/src/cursor/interactive.js +391 -391
  66. package/src/cursor/mcp-packs.js +828 -828
  67. package/src/cursor/plans.js +254 -254
  68. package/src/cursor/premium.js +469 -469
  69. package/src/cursor/setup.js +488 -488
  70. package/src/dashboard.js +493 -493
  71. package/src/deep-review.js +428 -428
  72. package/src/deprecation.js +98 -98
  73. package/src/diff-only.js +280 -280
  74. package/src/doctor.js +119 -119
  75. package/src/domain-pack-expansion.js +1033 -1033
  76. package/src/domain-packs.js +387 -387
  77. package/src/feedback.js +178 -178
  78. package/src/fix-engine.js +783 -0
  79. package/src/fix-prompts.js +122 -122
  80. package/src/formatters/sarif.js +115 -115
  81. package/src/freshness.js +74 -74
  82. package/src/gemini/config-parser.js +275 -275
  83. package/src/gemini/context.js +221 -221
  84. package/src/gemini/deep-review.js +559 -559
  85. package/src/gemini/domain-packs.js +393 -393
  86. package/src/gemini/freshness.js +66 -66
  87. package/src/gemini/governance.js +201 -201
  88. package/src/gemini/interactive.js +860 -860
  89. package/src/gemini/mcp-packs.js +915 -915
  90. package/src/gemini/plans.js +269 -269
  91. package/src/gemini/premium.js +760 -760
  92. package/src/gemini/setup.js +692 -692
  93. package/src/gemini/techniques.js +14 -14
  94. package/src/governance.js +72 -72
  95. package/src/harmony/add.js +68 -68
  96. package/src/harmony/advisor.js +333 -333
  97. package/src/harmony/canon.js +565 -565
  98. package/src/harmony/cli.js +591 -591
  99. package/src/harmony/drift.js +401 -401
  100. package/src/harmony/governance.js +313 -313
  101. package/src/harmony/memory.js +239 -239
  102. package/src/harmony/sync.js +475 -475
  103. package/src/harmony/watch.js +370 -370
  104. package/src/hook-validation.js +342 -342
  105. package/src/index.js +271 -271
  106. package/src/init.js +184 -184
  107. package/src/instruction-surfaces.js +185 -185
  108. package/src/integrations.js +144 -144
  109. package/src/interactive.js +118 -118
  110. package/src/locales/en.json +1 -1
  111. package/src/locales/es.json +1 -1
  112. package/src/mcp-packs.js +830 -830
  113. package/src/mcp-server.js +726 -726
  114. package/src/mcp-validation.js +337 -337
  115. package/src/nerviq-sync.json +7 -7
  116. package/src/opencode/config-parser.js +109 -109
  117. package/src/opencode/context.js +247 -247
  118. package/src/opencode/deep-review.js +313 -313
  119. package/src/opencode/domain-packs.js +262 -262
  120. package/src/opencode/freshness.js +66 -66
  121. package/src/opencode/governance.js +159 -159
  122. package/src/opencode/interactive.js +392 -392
  123. package/src/opencode/mcp-packs.js +705 -705
  124. package/src/opencode/patch.js +184 -184
  125. package/src/opencode/plans.js +231 -231
  126. package/src/opencode/premium.js +413 -413
  127. package/src/opencode/setup.js +449 -449
  128. package/src/opencode/techniques.js +27 -27
  129. package/src/operating-profile.js +574 -574
  130. package/src/org.js +152 -152
  131. package/src/permission-rules.js +218 -218
  132. package/src/plans.js +839 -839
  133. package/src/platform-change-manifest.js +86 -86
  134. package/src/plugins.js +110 -110
  135. package/src/policy-layers.js +210 -210
  136. package/src/profiles.js +124 -124
  137. package/src/prompt-injection.js +74 -74
  138. package/src/public-api.js +173 -173
  139. package/src/recommendation-rules.js +84 -84
  140. package/src/repo-archetype.js +386 -386
  141. package/src/secret-patterns.js +39 -39
  142. package/src/server.js +527 -527
  143. package/src/setup/analysis.js +607 -607
  144. package/src/setup/runtime.js +172 -172
  145. package/src/setup.js +677 -677
  146. package/src/shared/capabilities.js +194 -194
  147. package/src/source-urls.js +132 -132
  148. package/src/stack-checks.js +565 -565
  149. package/src/supplemental-checks.js +13 -13
  150. package/src/synergy/adaptive.js +261 -261
  151. package/src/synergy/compensation.js +137 -137
  152. package/src/synergy/evidence.js +193 -193
  153. package/src/synergy/learning.js +199 -199
  154. package/src/synergy/patterns.js +227 -227
  155. package/src/synergy/ranking.js +83 -83
  156. package/src/synergy/report.js +165 -165
  157. package/src/synergy/routing.js +146 -146
  158. package/src/techniques/api.js +407 -407
  159. package/src/techniques/automation.js +316 -316
  160. package/src/techniques/compliance.js +257 -257
  161. package/src/techniques/hygiene.js +294 -294
  162. package/src/techniques/instructions.js +243 -243
  163. package/src/techniques/observability.js +226 -226
  164. package/src/techniques/optimization.js +142 -142
  165. package/src/techniques/quality.js +318 -318
  166. package/src/techniques/security.js +237 -237
  167. package/src/techniques/shared.js +443 -443
  168. package/src/techniques/stacks.js +2294 -2294
  169. package/src/techniques/tools.js +106 -106
  170. package/src/techniques/workflow.js +413 -413
  171. package/src/techniques.js +81 -81
  172. package/src/terminology.js +73 -73
  173. package/src/token-estimate.js +35 -35
  174. package/src/usage-patterns.js +99 -99
  175. package/src/verification-metadata.js +145 -145
  176. package/src/watch.js +247 -247
  177. package/src/windsurf/activity.js +302 -302
  178. package/src/windsurf/config-parser.js +267 -267
  179. package/src/windsurf/context.js +249 -249
  180. package/src/windsurf/deep-review.js +337 -337
  181. package/src/windsurf/domain-packs.js +370 -370
  182. package/src/windsurf/freshness.js +36 -36
  183. package/src/windsurf/governance.js +231 -231
  184. package/src/windsurf/interactive.js +388 -388
  185. package/src/windsurf/mcp-packs.js +792 -792
  186. package/src/windsurf/plans.js +247 -247
  187. package/src/windsurf/premium.js +468 -468
  188. package/src/windsurf/setup.js +471 -471
  189. package/src/windsurf/techniques.js +17 -17
  190. package/src/workspace.js +375 -375
@@ -1,565 +1,565 @@
1
- const { SOURCE_URLS } = require('./source-urls');
2
-
3
- function files(ctx) {
4
- return Array.isArray(ctx.files) ? ctx.files : [];
5
- }
6
-
7
- function fileContent(ctx, filePath) {
8
- return typeof ctx.fileContent === 'function' ? (ctx.fileContent(filePath) || '') : '';
9
- }
10
-
11
- function matchingFiles(ctx, pattern) {
12
- return files(ctx).filter((file) => {
13
- pattern.lastIndex = 0;
14
- return pattern.test(file);
15
- });
16
- }
17
-
18
- function hasMatchingFile(ctx, pattern) {
19
- return matchingFiles(ctx, pattern).length > 0;
20
- }
21
-
22
- function readMatchingFiles(ctx, pattern) {
23
- return matchingFiles(ctx, pattern)
24
- .map((file) => fileContent(ctx, file))
25
- .filter(Boolean)
26
- .join('\n');
27
- }
28
-
29
- function docsText(ctx, docs) {
30
- return String(docs ? docs(ctx) || '' : '');
31
- }
32
-
33
- function workflowText(ctx) {
34
- return matchingFiles(ctx, /(^|[\\/])\.github[\\/]workflows[\\/].+\.ya?ml$/i)
35
- .map((file) => fileContent(ctx, file))
36
- .filter(Boolean)
37
- .join('\n');
38
- }
39
-
40
- function projectText(ctx, docs) {
41
- return [docsText(ctx, docs), workflowText(ctx)].filter(Boolean).join('\n');
42
- }
43
-
44
- function pubspecText(ctx) {
45
- return readMatchingFiles(ctx, /(^|[\\/])pubspec\.yaml$/i);
46
- }
47
-
48
- function hasFlutterSurface(ctx) {
49
- return hasMatchingFile(ctx, /(^|[\\/])pubspec\.yaml$/i);
50
- }
51
-
52
- function hasSwiftSurface(ctx) {
53
- return hasMatchingFile(ctx, /(^|[\\/])Package\.swift$/i) ||
54
- hasMatchingFile(ctx, /\.xcodeproj([\\/]|$)/i) ||
55
- hasMatchingFile(ctx, /(^|[\\/])project\.pbxproj$/i);
56
- }
57
-
58
- function swiftConfigText(ctx) {
59
- return [
60
- readMatchingFiles(ctx, /(^|[\\/])Package\.swift$/i),
61
- readMatchingFiles(ctx, /(^|[\\/])Podfile$/i),
62
- readMatchingFiles(ctx, /(^|[\\/])project\.pbxproj$/i),
63
- readMatchingFiles(ctx, /(^|[\\/])\.swift-version$/i),
64
- ].filter(Boolean).join('\n');
65
- }
66
-
67
- function hasAndroidKotlinSurface(ctx) {
68
- const gradleFiles = matchingFiles(ctx, /(^|[\\/])build\.gradle\.kts$/i);
69
- if (!gradleFiles.length) return false;
70
-
71
- return gradleFiles.some((file) => {
72
- const content = fileContent(ctx, file);
73
- return /android\s*\{|com\.android\.(?:application|library)|id\(["']com\.android\.(?:application|library)["']\)/i.test(content);
74
- });
75
- }
76
-
77
- function androidGradleText(ctx) {
78
- return [
79
- readMatchingFiles(ctx, /(^|[\\/])build\.gradle\.kts$/i),
80
- readMatchingFiles(ctx, /(^|[\\/])settings\.gradle\.kts$/i),
81
- readMatchingFiles(ctx, /(^|[\\/])gradle[\\/]libs\.versions\.toml$/i),
82
- fileContent(ctx, 'gradle.properties'),
83
- ].filter(Boolean).join('\n');
84
- }
85
-
86
- function flutterStateManagementPresent(ctx) {
87
- const pubspec = pubspecText(ctx);
88
- return /flutter_riverpod|hooks_riverpod|riverpod|flutter_bloc|bloc|provider|getx|mobx|stacked/i.test(pubspec);
89
- }
90
-
91
- function flutterCodegenPresent(ctx) {
92
- return /build_runner|freezed|json_serializable|injectable_generator|drift_dev/i.test(pubspecText(ctx)) ||
93
- hasMatchingFile(ctx, /(^|[\\/]).+\.g\.dart$/i);
94
- }
95
-
96
- function flutterBackendIntegrationPresent(ctx) {
97
- return /firebase_|cloud_firestore|firebase_core|supabase_flutter|supabase/i.test(pubspecText(ctx)) ||
98
- hasMatchingFile(ctx, /(^|[\\/])google-services\.json$/i) ||
99
- hasMatchingFile(ctx, /(^|[\\/])GoogleService-Info\.plist$/i) ||
100
- hasMatchingFile(ctx, /(^|[\\/])firebase_options\.dart$/i);
101
- }
102
-
103
- function flutterPlatformSurface(ctx) {
104
- return hasMatchingFile(ctx, /(^|[\\/])android([\\/]|$)/i) ||
105
- hasMatchingFile(ctx, /(^|[\\/])ios([\\/]|$)/i);
106
- }
107
-
108
- function flutterCiSurface(ctx) {
109
- return hasMatchingFile(ctx, /(^|[\\/])fastlane([\\/]|$)/i) ||
110
- hasMatchingFile(ctx, /(^|[\\/])codemagic\.yaml$/i) ||
111
- /fastlane|codemagic|flutter build (?:apk|appbundle|ipa|ios|android)|flutter test/i.test(workflowText(ctx));
112
- }
113
-
114
- function swiftUiSignals(ctx) {
115
- return readMatchingFiles(ctx, /(^|[\\/]).+\.swift$/i);
116
- }
117
-
118
- function kotlinComposeSignals(ctx) {
119
- return [
120
- androidGradleText(ctx),
121
- readMatchingFiles(ctx, /(^|[\\/]).+\.kt$/i),
122
- ].filter(Boolean).join('\n');
123
- }
124
-
125
- function makeCheck({ platform, id, name, category, impact, fix, check }) {
126
- return {
127
- id,
128
- name,
129
- check,
130
- impact,
131
- category,
132
- fix,
133
- sourceUrl: SOURCE_URLS[platform]?.byCategory?.[category] || SOURCE_URLS[platform]?.defaultUrl,
134
- confidence: 0.7,
135
- };
136
- }
137
-
138
- function buildStackChecks({ platform, objectPrefix, idPrefix, docs }) {
139
- const makeId = (family, number) => `${idPrefix}-${family}${String(number).padStart(2, '0')}`;
140
- const makeKey = (suffix) => `${objectPrefix}${suffix}`;
141
-
142
- return {
143
- [makeKey('FlutterPubspecExists')]: makeCheck({
144
- platform,
145
- id: makeId('FL', 1),
146
- name: 'pubspec.yaml exists',
147
- category: 'flutter',
148
- impact: 'high',
149
- fix: 'Add a committed `pubspec.yaml` at the Flutter project root so tooling, dependencies, and instructions have a canonical manifest.',
150
- check: (ctx) => hasFlutterSurface(ctx) ? true : null,
151
- }),
152
- [makeKey('FlutterPubspecLockCommitted')]: makeCheck({
153
- platform,
154
- id: makeId('FL', 2),
155
- name: 'pubspec.lock committed',
156
- category: 'flutter',
157
- impact: 'medium',
158
- fix: 'Commit `pubspec.lock` so Flutter package resolution stays reproducible for contributors and agents.',
159
- check: (ctx) => hasFlutterSurface(ctx) ? hasMatchingFile(ctx, /(^|[\\/])pubspec\.lock$/i) : null,
160
- }),
161
- [makeKey('FlutterVersionSpecified')]: makeCheck({
162
- platform,
163
- id: makeId('FL', 3),
164
- name: 'Flutter version specified (.fvmrc or pubspec)',
165
- category: 'flutter',
166
- impact: 'high',
167
- fix: 'Specify the Flutter SDK version with `.fvmrc` or an explicit SDK constraint in `pubspec.yaml`.',
168
- check: (ctx) => {
169
- if (!hasFlutterSurface(ctx)) return null;
170
- const pubspec = pubspecText(ctx);
171
- return hasMatchingFile(ctx, /(^|[\\/])\.fvmrc$/i) ||
172
- /environment:[\s\S]{0,300}(sdk|flutter)\s*:\s*["'][^"']+["']/i.test(pubspec);
173
- },
174
- }),
175
- [makeKey('FlutterTestDocumented')]: makeCheck({
176
- platform,
177
- id: makeId('FL', 4),
178
- name: 'flutter test documented',
179
- category: 'flutter',
180
- impact: 'high',
181
- fix: 'Document `flutter test` in repo instructions or CI so contributors and agents have a shared verification command.',
182
- check: (ctx) => hasFlutterSurface(ctx)
183
- ? /\bflutter test\b/i.test(projectText(ctx, docs))
184
- : null,
185
- }),
186
- [makeKey('FlutterAnalyzeDocumented')]: makeCheck({
187
- platform,
188
- id: makeId('FL', 5),
189
- name: 'flutter analyze documented',
190
- category: 'flutter',
191
- impact: 'high',
192
- fix: 'Document `flutter analyze` in project instructions or automation so static analysis is part of the default loop.',
193
- check: (ctx) => hasFlutterSurface(ctx)
194
- ? /\bflutter analyze\b/i.test(projectText(ctx, docs))
195
- : null,
196
- }),
197
- [makeKey('FlutterAnalysisOptionsConfigured')]: makeCheck({
198
- platform,
199
- id: makeId('FL', 6),
200
- name: 'analysis_options.yaml configured',
201
- category: 'flutter',
202
- impact: 'high',
203
- fix: 'Add `analysis_options.yaml` to define lint rules and analyzer behavior for the Flutter codebase.',
204
- check: (ctx) => hasFlutterSurface(ctx)
205
- ? hasMatchingFile(ctx, /(^|[\\/])analysis_options\.ya?ml$/i)
206
- : null,
207
- }),
208
- [makeKey('FlutterBuildFlavorsDocumented')]: makeCheck({
209
- platform,
210
- id: makeId('FL', 7),
211
- name: 'Build flavors documented (dev/staging/prod)',
212
- category: 'flutter',
213
- impact: 'medium',
214
- fix: 'Document build flavors such as dev, staging, and prod so mobile builds and environment routing stay predictable.',
215
- check: (ctx) => hasFlutterSurface(ctx)
216
- ? /flavor|flavours|dev|staging|prod|production/i.test(projectText(ctx, docs))
217
- : null,
218
- }),
219
- [makeKey('FlutterPlatformCodeDocumented')]: makeCheck({
220
- platform,
221
- id: makeId('FL', 8),
222
- name: 'Platform-specific code documented (android/ios)',
223
- category: 'flutter',
224
- impact: 'medium',
225
- fix: 'Document Android and iOS specific code paths, native bridges, or platform setup in repo guidance.',
226
- check: (ctx) => {
227
- if (!hasFlutterSurface(ctx)) return null;
228
- if (!flutterPlatformSurface(ctx)) return null;
229
- return /android|ios|platform.?specific|method channel|native code/i.test(projectText(ctx, docs));
230
- },
231
- }),
232
- [makeKey('FlutterStateManagementDocumented')]: makeCheck({
233
- platform,
234
- id: makeId('FL', 9),
235
- name: 'State management documented (Riverpod/Bloc/Provider in deps)',
236
- category: 'flutter',
237
- impact: 'medium',
238
- fix: 'Document the chosen Flutter state-management approach when Riverpod, Bloc, Provider, or similar packages are in use.',
239
- check: (ctx) => {
240
- if (!hasFlutterSurface(ctx)) return null;
241
- if (!flutterStateManagementPresent(ctx)) return null;
242
- return /riverpod|flutter_bloc|bloc|provider|getx|mobx|state management/i.test(projectText(ctx, docs));
243
- },
244
- }),
245
- [makeKey('FlutterCodeGenerationDocumented')]: makeCheck({
246
- platform,
247
- id: makeId('FL', 10),
248
- name: 'Code generation documented (build_runner in devDeps)',
249
- category: 'flutter',
250
- impact: 'medium',
251
- fix: 'Document `build_runner` or the generated-code workflow when the app uses Dart code generation.',
252
- check: (ctx) => {
253
- if (!hasFlutterSurface(ctx)) return null;
254
- if (!flutterCodegenPresent(ctx)) return null;
255
- return /build_runner|codegen|generated code|freezed|json_serializable/i.test(projectText(ctx, docs));
256
- },
257
- }),
258
- [makeKey('FlutterLocalizationConfigured')]: makeCheck({
259
- platform,
260
- id: makeId('FL', 11),
261
- name: 'Localization configured (l10n.yaml)',
262
- category: 'flutter',
263
- impact: 'medium',
264
- fix: 'Add `l10n.yaml` when the app uses Flutter localization so the i18n pipeline is explicit and reproducible.',
265
- check: (ctx) => hasFlutterSurface(ctx)
266
- ? hasMatchingFile(ctx, /(^|[\\/])l10n\.ya?ml$/i)
267
- : null,
268
- }),
269
- [makeKey('FlutterFirebaseOrSupabaseDocumented')]: makeCheck({
270
- platform,
271
- id: makeId('FL', 12),
272
- name: 'Firebase/Supabase configuration documented',
273
- category: 'flutter',
274
- impact: 'high',
275
- fix: 'Document Firebase or Supabase setup, environment binding, and client configuration when those services are present.',
276
- check: (ctx) => {
277
- if (!hasFlutterSurface(ctx)) return null;
278
- if (!flutterBackendIntegrationPresent(ctx)) return null;
279
- return /firebase|supabase|google-services|GoogleService-Info|firebase_options/i.test(projectText(ctx, docs));
280
- },
281
- }),
282
- [makeKey('FlutterAppSigningDocumented')]: makeCheck({
283
- platform,
284
- id: makeId('FL', 13),
285
- name: 'App signing documented',
286
- category: 'flutter',
287
- impact: 'high',
288
- fix: 'Document Android keystores and iOS signing/provisioning so release builds do not depend on tribal knowledge.',
289
- check: (ctx) => hasFlutterSurface(ctx)
290
- ? /signing|keystore|provisioning|certificate|bundle identifier|team id/i.test(projectText(ctx, docs))
291
- : null,
292
- }),
293
- [makeKey('FlutterCiCdMobile')]: makeCheck({
294
- platform,
295
- id: makeId('FL', 14),
296
- name: 'CI/CD for mobile (Fastlane/Codemagic)',
297
- category: 'flutter',
298
- impact: 'medium',
299
- fix: 'Add Fastlane, Codemagic, or equivalent mobile CI/CD automation for repeatable Flutter delivery.',
300
- check: (ctx) => hasFlutterSurface(ctx)
301
- ? flutterCiSurface(ctx)
302
- : null,
303
- }),
304
- [makeKey('FlutterGitignore')]: makeCheck({
305
- platform,
306
- id: makeId('FL', 15),
307
- name: 'Platform-specific .gitignore',
308
- category: 'flutter',
309
- impact: 'medium',
310
- fix: 'Add Flutter-specific ignore rules such as `.dart_tool/`, `.flutter-plugins*`, and platform build outputs to `.gitignore`.',
311
- check: (ctx) => {
312
- if (!hasFlutterSurface(ctx)) return null;
313
- const gitignore = fileContent(ctx, '.gitignore');
314
- return /\.dart_tool\/|\.flutter-plugins|\.flutter-plugins-dependencies|android\/key\.properties|ios\/Flutter\/ephemeral|build\//i.test(gitignore);
315
- },
316
- }),
317
-
318
- [makeKey('SwiftPackageOrXcodeprojExists')]: makeCheck({
319
- platform,
320
- id: makeId('SW', 1),
321
- name: 'Package.swift or .xcodeproj exists',
322
- category: 'swift',
323
- impact: 'high',
324
- fix: 'Commit `Package.swift` or the Xcode project so the Swift/iOS build surface is explicit and reproducible.',
325
- check: (ctx) => hasSwiftSurface(ctx) ? true : null,
326
- }),
327
- [makeKey('SwiftVersionSpecified')]: makeCheck({
328
- platform,
329
- id: makeId('SW', 2),
330
- name: 'Swift version specified (.swift-version)',
331
- category: 'swift',
332
- impact: 'high',
333
- fix: 'Specify the Swift toolchain with `.swift-version` or a `swift-tools-version` declaration.',
334
- check: (ctx) => {
335
- if (!hasSwiftSurface(ctx)) return null;
336
- return hasMatchingFile(ctx, /(^|[\\/])\.swift-version$/i) ||
337
- /swift-tools-version:\s*\d+(?:\.\d+)+/i.test(swiftConfigText(ctx));
338
- },
339
- }),
340
- [makeKey('SwiftLintConfigured')]: makeCheck({
341
- platform,
342
- id: makeId('SW', 3),
343
- name: 'SwiftLint configured (.swiftlint.yml)',
344
- category: 'swift',
345
- impact: 'medium',
346
- fix: 'Configure SwiftLint with `.swiftlint.yml` or equivalent build/CI integration for consistent Swift quality checks.',
347
- check: (ctx) => {
348
- if (!hasSwiftSurface(ctx)) return null;
349
- return hasMatchingFile(ctx, /(^|[\\/])\.swiftlint\.ya?ml$/i) ||
350
- /swiftlint/i.test(swiftConfigText(ctx) + '\n' + workflowText(ctx));
351
- },
352
- }),
353
- [makeKey('SwiftXCTestDocumented')]: makeCheck({
354
- platform,
355
- id: makeId('SW', 4),
356
- name: 'XCTest documented',
357
- category: 'swift',
358
- impact: 'high',
359
- fix: 'Document the XCTest or `xcodebuild test` workflow so iOS verification is part of the default path.',
360
- check: (ctx) => hasSwiftSurface(ctx)
361
- ? /xctest|swift test|xcodebuild[^\n\r]{0,200}\btest\b|test target/i.test(projectText(ctx, docs)) ||
362
- hasMatchingFile(ctx, /(^|[\\/])Tests([\\/]|$)|XCTestCase/i)
363
- : null,
364
- }),
365
- [makeKey('SwiftDependenciesManaged')]: makeCheck({
366
- platform,
367
- id: makeId('SW', 5),
368
- name: 'CocoaPods/SPM dependencies managed (Podfile or Package.swift)',
369
- category: 'swift',
370
- impact: 'high',
371
- fix: 'Use CocoaPods or Swift Package Manager with a committed `Podfile` or `Package.swift` for dependency management.',
372
- check: (ctx) => hasSwiftSurface(ctx)
373
- ? hasMatchingFile(ctx, /(^|[\\/])Podfile$/i) || hasMatchingFile(ctx, /(^|[\\/])Package\.swift$/i)
374
- : null,
375
- }),
376
- [makeKey('SwiftSchemeTargetDocumented')]: makeCheck({
377
- platform,
378
- id: makeId('SW', 6),
379
- name: 'Scheme/target documentation',
380
- category: 'swift',
381
- impact: 'medium',
382
- fix: 'Document Xcode schemes, targets, and the canonical build/test entry points for the repo.',
383
- check: (ctx) => hasSwiftSurface(ctx)
384
- ? /scheme|target|workspace|xcodebuild -scheme/i.test(projectText(ctx, docs))
385
- : null,
386
- }),
387
- [makeKey('SwiftSigningDocumented')]: makeCheck({
388
- platform,
389
- id: makeId('SW', 7),
390
- name: 'Signing configuration documented',
391
- category: 'swift',
392
- impact: 'high',
393
- fix: 'Document signing, provisioning profiles, certificates, and Team ID handling for iOS releases.',
394
- check: (ctx) => hasSwiftSurface(ctx)
395
- ? /signing|provisioning|certificate|team id|bundle identifier/i.test(projectText(ctx, docs))
396
- : null,
397
- }),
398
- [makeKey('SwiftUiApproachDocumented')]: makeCheck({
399
- platform,
400
- id: makeId('SW', 8),
401
- name: 'SwiftUI vs UIKit approach documented',
402
- category: 'swift',
403
- impact: 'medium',
404
- fix: 'Document whether the app uses SwiftUI, UIKit, or a hybrid approach so generated changes follow the right UI architecture.',
405
- check: (ctx) => {
406
- if (!hasSwiftSurface(ctx)) return null;
407
- const source = swiftUiSignals(ctx);
408
- if (!/SwiftUI|UIKit/i.test(source)) return null;
409
- return /swiftui|uikit|hybrid ui/i.test(projectText(ctx, docs));
410
- },
411
- }),
412
- [makeKey('SwiftDataPatternsDocumented')]: makeCheck({
413
- platform,
414
- id: makeId('SW', 9),
415
- name: 'Core Data/SwiftData patterns documented',
416
- category: 'swift',
417
- impact: 'medium',
418
- fix: 'Document Core Data or SwiftData usage patterns when the project persists data through Apple-native storage frameworks.',
419
- check: (ctx) => {
420
- if (!hasSwiftSurface(ctx)) return null;
421
- const source = swiftUiSignals(ctx) + '\n' + swiftConfigText(ctx);
422
- if (!/CoreData|SwiftData/i.test(source)) return null;
423
- return /core data|swiftdata|modelcontext|persistentcontainer/i.test(projectText(ctx, docs));
424
- },
425
- }),
426
- [makeKey('SwiftGitignore')]: makeCheck({
427
- platform,
428
- id: makeId('SW', 10),
429
- name: 'Xcode-specific .gitignore',
430
- category: 'swift',
431
- impact: 'medium',
432
- fix: 'Add Xcode ignore rules such as `DerivedData/`, `xcuserdata/`, and `.build/` to `.gitignore`.',
433
- check: (ctx) => {
434
- if (!hasSwiftSurface(ctx)) return null;
435
- const gitignore = fileContent(ctx, '.gitignore');
436
- return /DerivedData\/|xcuserdata\/|\.build\/|\*\.xcuserstate/i.test(gitignore);
437
- },
438
- }),
439
-
440
- [makeKey('KotlinBuildGradleExists')]: makeCheck({
441
- platform,
442
- id: makeId('KT', 1),
443
- name: 'build.gradle.kts exists',
444
- category: 'kotlin',
445
- impact: 'high',
446
- fix: 'Commit `build.gradle.kts` for the Android/Kotlin project so build logic is explicit and reviewable.',
447
- check: (ctx) => hasAndroidKotlinSurface(ctx) ? true : null,
448
- }),
449
- [makeKey('KotlinVersionSpecified')]: makeCheck({
450
- platform,
451
- id: makeId('KT', 2),
452
- name: 'Kotlin version specified',
453
- category: 'kotlin',
454
- impact: 'high',
455
- fix: 'Specify the Kotlin version in Gradle plugins, version catalogs, or build properties.',
456
- check: (ctx) => {
457
- if (!hasAndroidKotlinSurface(ctx)) return null;
458
- return /kotlin(?:\(["'][^)]+["']\))?\s+version\s+["'][^"']+["']|org\.jetbrains\.kotlin\.[\w.-]+\s+version\s+["'][^"']+["']|kotlin\s*=\s*["'][^"']+["']/i.test(androidGradleText(ctx));
459
- },
460
- }),
461
- [makeKey('KotlinLintConfigured')]: makeCheck({
462
- platform,
463
- id: makeId('KT', 3),
464
- name: 'ktlint/detekt configured',
465
- category: 'kotlin',
466
- impact: 'medium',
467
- fix: 'Configure ktlint or detekt in Gradle or CI so Kotlin style and static-analysis rules stay consistent.',
468
- check: (ctx) => {
469
- if (!hasAndroidKotlinSurface(ctx)) return null;
470
- return hasMatchingFile(ctx, /(^|[\\/])\.?detekt\.ya?ml$/i) ||
471
- /ktlint|detekt/i.test(androidGradleText(ctx) + '\n' + workflowText(ctx));
472
- },
473
- }),
474
- [makeKey('KotlinAndroidTestsDocumented')]: makeCheck({
475
- platform,
476
- id: makeId('KT', 4),
477
- name: 'Android test framework documented',
478
- category: 'kotlin',
479
- impact: 'high',
480
- fix: 'Document the Android test stack such as JUnit, Espresso, Robolectric, or `connectedAndroidTest` in repo guidance.',
481
- check: (ctx) => hasAndroidKotlinSurface(ctx)
482
- ? /androidtest|connectedandroidtest|espresso|robolectric|junit|gradlew test/i.test(projectText(ctx, docs))
483
- : null,
484
- }),
485
- [makeKey('KotlinGradleWrapperCommitted')]: makeCheck({
486
- platform,
487
- id: makeId('KT', 5),
488
- name: 'Gradle wrapper committed (gradlew)',
489
- category: 'kotlin',
490
- impact: 'high',
491
- fix: 'Commit `gradlew` and the Gradle wrapper files so Android builds are reproducible across environments.',
492
- check: (ctx) => hasAndroidKotlinSurface(ctx)
493
- ? hasMatchingFile(ctx, /(^|[\\/])gradlew(?:\.bat)?$/i)
494
- : null,
495
- }),
496
- [makeKey('KotlinBuildVariantsDocumented')]: makeCheck({
497
- platform,
498
- id: makeId('KT', 6),
499
- name: 'Build variants documented',
500
- category: 'kotlin',
501
- impact: 'medium',
502
- fix: 'Document Android build types and product flavors so agents know how to target debug, release, and environment variants.',
503
- check: (ctx) => hasAndroidKotlinSurface(ctx)
504
- ? /build variant|build type|productflavors|flavor|debug|release|staging/i.test(projectText(ctx, docs) + '\n' + androidGradleText(ctx))
505
- : null,
506
- }),
507
- [makeKey('KotlinProguardConfigured')]: makeCheck({
508
- platform,
509
- id: makeId('KT', 7),
510
- name: 'ProGuard/R8 configuration',
511
- category: 'kotlin',
512
- impact: 'medium',
513
- fix: 'Add ProGuard or R8 configuration such as `proguard-rules.pro` and minification settings for release builds.',
514
- check: (ctx) => {
515
- if (!hasAndroidKotlinSurface(ctx)) return null;
516
- return hasMatchingFile(ctx, /(^|[\\/])proguard-rules\.pro$/i) ||
517
- /proguardFiles|minifyEnabled|isMinifyEnabled|shrinkResources|r8/i.test(androidGradleText(ctx));
518
- },
519
- }),
520
- [makeKey('KotlinUiApproachDocumented')]: makeCheck({
521
- platform,
522
- id: makeId('KT', 8),
523
- name: 'Compose vs XML approach documented',
524
- category: 'kotlin',
525
- impact: 'medium',
526
- fix: 'Document whether the Android UI is Jetpack Compose, XML layouts, or hybrid so generated changes follow the right pattern.',
527
- check: (ctx) => {
528
- if (!hasAndroidKotlinSurface(ctx)) return null;
529
- const signals = kotlinComposeSignals(ctx);
530
- const hasCompose = /compose\s*=\s*true|@Composable|androidx\.compose/i.test(signals);
531
- const hasXml = hasMatchingFile(ctx, /(^|[\\/])src[\\/].+[\\/]res[\\/]layout[\\/].+\.xml$/i);
532
- if (!hasCompose && !hasXml) return null;
533
- return /compose|xml|jetpack compose|layout xml|viewbinding/i.test(projectText(ctx, docs));
534
- },
535
- }),
536
- [makeKey('KotlinSigningDocumented')]: makeCheck({
537
- platform,
538
- id: makeId('KT', 9),
539
- name: 'Signing config documented',
540
- category: 'kotlin',
541
- impact: 'high',
542
- fix: 'Document Android release signing, keystores, and environment variable expectations for mobile delivery.',
543
- check: (ctx) => hasAndroidKotlinSurface(ctx)
544
- ? /signingconfig|keystore|release signing|upload key|signing/i.test(projectText(ctx, docs))
545
- : null,
546
- }),
547
- [makeKey('KotlinGitignore')]: makeCheck({
548
- platform,
549
- id: makeId('KT', 10),
550
- name: 'Android-specific .gitignore',
551
- category: 'kotlin',
552
- impact: 'medium',
553
- fix: 'Add Android-specific ignore rules such as `.gradle/`, `local.properties`, and IDE build artifacts to `.gitignore`.',
554
- check: (ctx) => {
555
- if (!hasAndroidKotlinSurface(ctx)) return null;
556
- const gitignore = fileContent(ctx, '.gitignore');
557
- return /\.gradle\/|local\.properties|\*\.iml|captures\/|build_file_checksums\.ser/i.test(gitignore);
558
- },
559
- }),
560
- };
561
- }
562
-
563
- module.exports = {
564
- buildStackChecks,
565
- };
1
+ const { SOURCE_URLS } = require('./source-urls');
2
+
3
+ function files(ctx) {
4
+ return Array.isArray(ctx.files) ? ctx.files : [];
5
+ }
6
+
7
+ function fileContent(ctx, filePath) {
8
+ return typeof ctx.fileContent === 'function' ? (ctx.fileContent(filePath) || '') : '';
9
+ }
10
+
11
+ function matchingFiles(ctx, pattern) {
12
+ return files(ctx).filter((file) => {
13
+ pattern.lastIndex = 0;
14
+ return pattern.test(file);
15
+ });
16
+ }
17
+
18
+ function hasMatchingFile(ctx, pattern) {
19
+ return matchingFiles(ctx, pattern).length > 0;
20
+ }
21
+
22
+ function readMatchingFiles(ctx, pattern) {
23
+ return matchingFiles(ctx, pattern)
24
+ .map((file) => fileContent(ctx, file))
25
+ .filter(Boolean)
26
+ .join('\n');
27
+ }
28
+
29
+ function docsText(ctx, docs) {
30
+ return String(docs ? docs(ctx) || '' : '');
31
+ }
32
+
33
+ function workflowText(ctx) {
34
+ return matchingFiles(ctx, /(^|[\\/])\.github[\\/]workflows[\\/].+\.ya?ml$/i)
35
+ .map((file) => fileContent(ctx, file))
36
+ .filter(Boolean)
37
+ .join('\n');
38
+ }
39
+
40
+ function projectText(ctx, docs) {
41
+ return [docsText(ctx, docs), workflowText(ctx)].filter(Boolean).join('\n');
42
+ }
43
+
44
+ function pubspecText(ctx) {
45
+ return readMatchingFiles(ctx, /(^|[\\/])pubspec\.yaml$/i);
46
+ }
47
+
48
+ function hasFlutterSurface(ctx) {
49
+ return hasMatchingFile(ctx, /(^|[\\/])pubspec\.yaml$/i);
50
+ }
51
+
52
+ function hasSwiftSurface(ctx) {
53
+ return hasMatchingFile(ctx, /(^|[\\/])Package\.swift$/i) ||
54
+ hasMatchingFile(ctx, /\.xcodeproj([\\/]|$)/i) ||
55
+ hasMatchingFile(ctx, /(^|[\\/])project\.pbxproj$/i);
56
+ }
57
+
58
+ function swiftConfigText(ctx) {
59
+ return [
60
+ readMatchingFiles(ctx, /(^|[\\/])Package\.swift$/i),
61
+ readMatchingFiles(ctx, /(^|[\\/])Podfile$/i),
62
+ readMatchingFiles(ctx, /(^|[\\/])project\.pbxproj$/i),
63
+ readMatchingFiles(ctx, /(^|[\\/])\.swift-version$/i),
64
+ ].filter(Boolean).join('\n');
65
+ }
66
+
67
+ function hasAndroidKotlinSurface(ctx) {
68
+ const gradleFiles = matchingFiles(ctx, /(^|[\\/])build\.gradle\.kts$/i);
69
+ if (!gradleFiles.length) return false;
70
+
71
+ return gradleFiles.some((file) => {
72
+ const content = fileContent(ctx, file);
73
+ return /android\s*\{|com\.android\.(?:application|library)|id\(["']com\.android\.(?:application|library)["']\)/i.test(content);
74
+ });
75
+ }
76
+
77
+ function androidGradleText(ctx) {
78
+ return [
79
+ readMatchingFiles(ctx, /(^|[\\/])build\.gradle\.kts$/i),
80
+ readMatchingFiles(ctx, /(^|[\\/])settings\.gradle\.kts$/i),
81
+ readMatchingFiles(ctx, /(^|[\\/])gradle[\\/]libs\.versions\.toml$/i),
82
+ fileContent(ctx, 'gradle.properties'),
83
+ ].filter(Boolean).join('\n');
84
+ }
85
+
86
+ function flutterStateManagementPresent(ctx) {
87
+ const pubspec = pubspecText(ctx);
88
+ return /flutter_riverpod|hooks_riverpod|riverpod|flutter_bloc|bloc|provider|getx|mobx|stacked/i.test(pubspec);
89
+ }
90
+
91
+ function flutterCodegenPresent(ctx) {
92
+ return /build_runner|freezed|json_serializable|injectable_generator|drift_dev/i.test(pubspecText(ctx)) ||
93
+ hasMatchingFile(ctx, /(^|[\\/]).+\.g\.dart$/i);
94
+ }
95
+
96
+ function flutterBackendIntegrationPresent(ctx) {
97
+ return /firebase_|cloud_firestore|firebase_core|supabase_flutter|supabase/i.test(pubspecText(ctx)) ||
98
+ hasMatchingFile(ctx, /(^|[\\/])google-services\.json$/i) ||
99
+ hasMatchingFile(ctx, /(^|[\\/])GoogleService-Info\.plist$/i) ||
100
+ hasMatchingFile(ctx, /(^|[\\/])firebase_options\.dart$/i);
101
+ }
102
+
103
+ function flutterPlatformSurface(ctx) {
104
+ return hasMatchingFile(ctx, /(^|[\\/])android([\\/]|$)/i) ||
105
+ hasMatchingFile(ctx, /(^|[\\/])ios([\\/]|$)/i);
106
+ }
107
+
108
+ function flutterCiSurface(ctx) {
109
+ return hasMatchingFile(ctx, /(^|[\\/])fastlane([\\/]|$)/i) ||
110
+ hasMatchingFile(ctx, /(^|[\\/])codemagic\.yaml$/i) ||
111
+ /fastlane|codemagic|flutter build (?:apk|appbundle|ipa|ios|android)|flutter test/i.test(workflowText(ctx));
112
+ }
113
+
114
+ function swiftUiSignals(ctx) {
115
+ return readMatchingFiles(ctx, /(^|[\\/]).+\.swift$/i);
116
+ }
117
+
118
+ function kotlinComposeSignals(ctx) {
119
+ return [
120
+ androidGradleText(ctx),
121
+ readMatchingFiles(ctx, /(^|[\\/]).+\.kt$/i),
122
+ ].filter(Boolean).join('\n');
123
+ }
124
+
125
+ function makeCheck({ platform, id, name, category, impact, fix, check }) {
126
+ return {
127
+ id,
128
+ name,
129
+ check,
130
+ impact,
131
+ category,
132
+ fix,
133
+ sourceUrl: SOURCE_URLS[platform]?.byCategory?.[category] || SOURCE_URLS[platform]?.defaultUrl,
134
+ confidence: 0.7,
135
+ };
136
+ }
137
+
138
+ function buildStackChecks({ platform, objectPrefix, idPrefix, docs }) {
139
+ const makeId = (family, number) => `${idPrefix}-${family}${String(number).padStart(2, '0')}`;
140
+ const makeKey = (suffix) => `${objectPrefix}${suffix}`;
141
+
142
+ return {
143
+ [makeKey('FlutterPubspecExists')]: makeCheck({
144
+ platform,
145
+ id: makeId('FL', 1),
146
+ name: 'pubspec.yaml exists',
147
+ category: 'flutter',
148
+ impact: 'high',
149
+ fix: 'Add a committed `pubspec.yaml` at the Flutter project root so tooling, dependencies, and instructions have a canonical manifest.',
150
+ check: (ctx) => hasFlutterSurface(ctx) ? true : null,
151
+ }),
152
+ [makeKey('FlutterPubspecLockCommitted')]: makeCheck({
153
+ platform,
154
+ id: makeId('FL', 2),
155
+ name: 'pubspec.lock committed',
156
+ category: 'flutter',
157
+ impact: 'medium',
158
+ fix: 'Commit `pubspec.lock` so Flutter package resolution stays reproducible for contributors and agents.',
159
+ check: (ctx) => hasFlutterSurface(ctx) ? hasMatchingFile(ctx, /(^|[\\/])pubspec\.lock$/i) : null,
160
+ }),
161
+ [makeKey('FlutterVersionSpecified')]: makeCheck({
162
+ platform,
163
+ id: makeId('FL', 3),
164
+ name: 'Flutter version specified (.fvmrc or pubspec)',
165
+ category: 'flutter',
166
+ impact: 'high',
167
+ fix: 'Specify the Flutter SDK version with `.fvmrc` or an explicit SDK constraint in `pubspec.yaml`.',
168
+ check: (ctx) => {
169
+ if (!hasFlutterSurface(ctx)) return null;
170
+ const pubspec = pubspecText(ctx);
171
+ return hasMatchingFile(ctx, /(^|[\\/])\.fvmrc$/i) ||
172
+ /environment:[\s\S]{0,300}(sdk|flutter)\s*:\s*["'][^"']+["']/i.test(pubspec);
173
+ },
174
+ }),
175
+ [makeKey('FlutterTestDocumented')]: makeCheck({
176
+ platform,
177
+ id: makeId('FL', 4),
178
+ name: 'flutter test documented',
179
+ category: 'flutter',
180
+ impact: 'high',
181
+ fix: 'Document `flutter test` in repo instructions or CI so contributors and agents have a shared verification command.',
182
+ check: (ctx) => hasFlutterSurface(ctx)
183
+ ? /\bflutter test\b/i.test(projectText(ctx, docs))
184
+ : null,
185
+ }),
186
+ [makeKey('FlutterAnalyzeDocumented')]: makeCheck({
187
+ platform,
188
+ id: makeId('FL', 5),
189
+ name: 'flutter analyze documented',
190
+ category: 'flutter',
191
+ impact: 'high',
192
+ fix: 'Document `flutter analyze` in project instructions or automation so static analysis is part of the default loop.',
193
+ check: (ctx) => hasFlutterSurface(ctx)
194
+ ? /\bflutter analyze\b/i.test(projectText(ctx, docs))
195
+ : null,
196
+ }),
197
+ [makeKey('FlutterAnalysisOptionsConfigured')]: makeCheck({
198
+ platform,
199
+ id: makeId('FL', 6),
200
+ name: 'analysis_options.yaml configured',
201
+ category: 'flutter',
202
+ impact: 'high',
203
+ fix: 'Add `analysis_options.yaml` to define lint rules and analyzer behavior for the Flutter codebase.',
204
+ check: (ctx) => hasFlutterSurface(ctx)
205
+ ? hasMatchingFile(ctx, /(^|[\\/])analysis_options\.ya?ml$/i)
206
+ : null,
207
+ }),
208
+ [makeKey('FlutterBuildFlavorsDocumented')]: makeCheck({
209
+ platform,
210
+ id: makeId('FL', 7),
211
+ name: 'Build flavors documented (dev/staging/prod)',
212
+ category: 'flutter',
213
+ impact: 'medium',
214
+ fix: 'Document build flavors such as dev, staging, and prod so mobile builds and environment routing stay predictable.',
215
+ check: (ctx) => hasFlutterSurface(ctx)
216
+ ? /flavor|flavours|dev|staging|prod|production/i.test(projectText(ctx, docs))
217
+ : null,
218
+ }),
219
+ [makeKey('FlutterPlatformCodeDocumented')]: makeCheck({
220
+ platform,
221
+ id: makeId('FL', 8),
222
+ name: 'Platform-specific code documented (android/ios)',
223
+ category: 'flutter',
224
+ impact: 'medium',
225
+ fix: 'Document Android and iOS specific code paths, native bridges, or platform setup in repo guidance.',
226
+ check: (ctx) => {
227
+ if (!hasFlutterSurface(ctx)) return null;
228
+ if (!flutterPlatformSurface(ctx)) return null;
229
+ return /android|ios|platform.?specific|method channel|native code/i.test(projectText(ctx, docs));
230
+ },
231
+ }),
232
+ [makeKey('FlutterStateManagementDocumented')]: makeCheck({
233
+ platform,
234
+ id: makeId('FL', 9),
235
+ name: 'State management documented (Riverpod/Bloc/Provider in deps)',
236
+ category: 'flutter',
237
+ impact: 'medium',
238
+ fix: 'Document the chosen Flutter state-management approach when Riverpod, Bloc, Provider, or similar packages are in use.',
239
+ check: (ctx) => {
240
+ if (!hasFlutterSurface(ctx)) return null;
241
+ if (!flutterStateManagementPresent(ctx)) return null;
242
+ return /riverpod|flutter_bloc|bloc|provider|getx|mobx|state management/i.test(projectText(ctx, docs));
243
+ },
244
+ }),
245
+ [makeKey('FlutterCodeGenerationDocumented')]: makeCheck({
246
+ platform,
247
+ id: makeId('FL', 10),
248
+ name: 'Code generation documented (build_runner in devDeps)',
249
+ category: 'flutter',
250
+ impact: 'medium',
251
+ fix: 'Document `build_runner` or the generated-code workflow when the app uses Dart code generation.',
252
+ check: (ctx) => {
253
+ if (!hasFlutterSurface(ctx)) return null;
254
+ if (!flutterCodegenPresent(ctx)) return null;
255
+ return /build_runner|codegen|generated code|freezed|json_serializable/i.test(projectText(ctx, docs));
256
+ },
257
+ }),
258
+ [makeKey('FlutterLocalizationConfigured')]: makeCheck({
259
+ platform,
260
+ id: makeId('FL', 11),
261
+ name: 'Localization configured (l10n.yaml)',
262
+ category: 'flutter',
263
+ impact: 'medium',
264
+ fix: 'Add `l10n.yaml` when the app uses Flutter localization so the i18n pipeline is explicit and reproducible.',
265
+ check: (ctx) => hasFlutterSurface(ctx)
266
+ ? hasMatchingFile(ctx, /(^|[\\/])l10n\.ya?ml$/i)
267
+ : null,
268
+ }),
269
+ [makeKey('FlutterFirebaseOrSupabaseDocumented')]: makeCheck({
270
+ platform,
271
+ id: makeId('FL', 12),
272
+ name: 'Firebase/Supabase configuration documented',
273
+ category: 'flutter',
274
+ impact: 'high',
275
+ fix: 'Document Firebase or Supabase setup, environment binding, and client configuration when those services are present.',
276
+ check: (ctx) => {
277
+ if (!hasFlutterSurface(ctx)) return null;
278
+ if (!flutterBackendIntegrationPresent(ctx)) return null;
279
+ return /firebase|supabase|google-services|GoogleService-Info|firebase_options/i.test(projectText(ctx, docs));
280
+ },
281
+ }),
282
+ [makeKey('FlutterAppSigningDocumented')]: makeCheck({
283
+ platform,
284
+ id: makeId('FL', 13),
285
+ name: 'App signing documented',
286
+ category: 'flutter',
287
+ impact: 'high',
288
+ fix: 'Document Android keystores and iOS signing/provisioning so release builds do not depend on tribal knowledge.',
289
+ check: (ctx) => hasFlutterSurface(ctx)
290
+ ? /signing|keystore|provisioning|certificate|bundle identifier|team id/i.test(projectText(ctx, docs))
291
+ : null,
292
+ }),
293
+ [makeKey('FlutterCiCdMobile')]: makeCheck({
294
+ platform,
295
+ id: makeId('FL', 14),
296
+ name: 'CI/CD for mobile (Fastlane/Codemagic)',
297
+ category: 'flutter',
298
+ impact: 'medium',
299
+ fix: 'Add Fastlane, Codemagic, or equivalent mobile CI/CD automation for repeatable Flutter delivery.',
300
+ check: (ctx) => hasFlutterSurface(ctx)
301
+ ? flutterCiSurface(ctx)
302
+ : null,
303
+ }),
304
+ [makeKey('FlutterGitignore')]: makeCheck({
305
+ platform,
306
+ id: makeId('FL', 15),
307
+ name: 'Platform-specific .gitignore',
308
+ category: 'flutter',
309
+ impact: 'medium',
310
+ fix: 'Add Flutter-specific ignore rules such as `.dart_tool/`, `.flutter-plugins*`, and platform build outputs to `.gitignore`.',
311
+ check: (ctx) => {
312
+ if (!hasFlutterSurface(ctx)) return null;
313
+ const gitignore = fileContent(ctx, '.gitignore');
314
+ return /\.dart_tool\/|\.flutter-plugins|\.flutter-plugins-dependencies|android\/key\.properties|ios\/Flutter\/ephemeral|build\//i.test(gitignore);
315
+ },
316
+ }),
317
+
318
+ [makeKey('SwiftPackageOrXcodeprojExists')]: makeCheck({
319
+ platform,
320
+ id: makeId('SW', 1),
321
+ name: 'Package.swift or .xcodeproj exists',
322
+ category: 'swift',
323
+ impact: 'high',
324
+ fix: 'Commit `Package.swift` or the Xcode project so the Swift/iOS build surface is explicit and reproducible.',
325
+ check: (ctx) => hasSwiftSurface(ctx) ? true : null,
326
+ }),
327
+ [makeKey('SwiftVersionSpecified')]: makeCheck({
328
+ platform,
329
+ id: makeId('SW', 2),
330
+ name: 'Swift version specified (.swift-version)',
331
+ category: 'swift',
332
+ impact: 'high',
333
+ fix: 'Specify the Swift toolchain with `.swift-version` or a `swift-tools-version` declaration.',
334
+ check: (ctx) => {
335
+ if (!hasSwiftSurface(ctx)) return null;
336
+ return hasMatchingFile(ctx, /(^|[\\/])\.swift-version$/i) ||
337
+ /swift-tools-version:\s*\d+(?:\.\d+)+/i.test(swiftConfigText(ctx));
338
+ },
339
+ }),
340
+ [makeKey('SwiftLintConfigured')]: makeCheck({
341
+ platform,
342
+ id: makeId('SW', 3),
343
+ name: 'SwiftLint configured (.swiftlint.yml)',
344
+ category: 'swift',
345
+ impact: 'medium',
346
+ fix: 'Configure SwiftLint with `.swiftlint.yml` or equivalent build/CI integration for consistent Swift quality checks.',
347
+ check: (ctx) => {
348
+ if (!hasSwiftSurface(ctx)) return null;
349
+ return hasMatchingFile(ctx, /(^|[\\/])\.swiftlint\.ya?ml$/i) ||
350
+ /swiftlint/i.test(swiftConfigText(ctx) + '\n' + workflowText(ctx));
351
+ },
352
+ }),
353
+ [makeKey('SwiftXCTestDocumented')]: makeCheck({
354
+ platform,
355
+ id: makeId('SW', 4),
356
+ name: 'XCTest documented',
357
+ category: 'swift',
358
+ impact: 'high',
359
+ fix: 'Document the XCTest or `xcodebuild test` workflow so iOS verification is part of the default path.',
360
+ check: (ctx) => hasSwiftSurface(ctx)
361
+ ? /xctest|swift test|xcodebuild[^\n\r]{0,200}\btest\b|test target/i.test(projectText(ctx, docs)) ||
362
+ hasMatchingFile(ctx, /(^|[\\/])Tests([\\/]|$)|XCTestCase/i)
363
+ : null,
364
+ }),
365
+ [makeKey('SwiftDependenciesManaged')]: makeCheck({
366
+ platform,
367
+ id: makeId('SW', 5),
368
+ name: 'CocoaPods/SPM dependencies managed (Podfile or Package.swift)',
369
+ category: 'swift',
370
+ impact: 'high',
371
+ fix: 'Use CocoaPods or Swift Package Manager with a committed `Podfile` or `Package.swift` for dependency management.',
372
+ check: (ctx) => hasSwiftSurface(ctx)
373
+ ? hasMatchingFile(ctx, /(^|[\\/])Podfile$/i) || hasMatchingFile(ctx, /(^|[\\/])Package\.swift$/i)
374
+ : null,
375
+ }),
376
+ [makeKey('SwiftSchemeTargetDocumented')]: makeCheck({
377
+ platform,
378
+ id: makeId('SW', 6),
379
+ name: 'Scheme/target documentation',
380
+ category: 'swift',
381
+ impact: 'medium',
382
+ fix: 'Document Xcode schemes, targets, and the canonical build/test entry points for the repo.',
383
+ check: (ctx) => hasSwiftSurface(ctx)
384
+ ? /scheme|target|workspace|xcodebuild -scheme/i.test(projectText(ctx, docs))
385
+ : null,
386
+ }),
387
+ [makeKey('SwiftSigningDocumented')]: makeCheck({
388
+ platform,
389
+ id: makeId('SW', 7),
390
+ name: 'Signing configuration documented',
391
+ category: 'swift',
392
+ impact: 'high',
393
+ fix: 'Document signing, provisioning profiles, certificates, and Team ID handling for iOS releases.',
394
+ check: (ctx) => hasSwiftSurface(ctx)
395
+ ? /signing|provisioning|certificate|team id|bundle identifier/i.test(projectText(ctx, docs))
396
+ : null,
397
+ }),
398
+ [makeKey('SwiftUiApproachDocumented')]: makeCheck({
399
+ platform,
400
+ id: makeId('SW', 8),
401
+ name: 'SwiftUI vs UIKit approach documented',
402
+ category: 'swift',
403
+ impact: 'medium',
404
+ fix: 'Document whether the app uses SwiftUI, UIKit, or a hybrid approach so generated changes follow the right UI architecture.',
405
+ check: (ctx) => {
406
+ if (!hasSwiftSurface(ctx)) return null;
407
+ const source = swiftUiSignals(ctx);
408
+ if (!/SwiftUI|UIKit/i.test(source)) return null;
409
+ return /swiftui|uikit|hybrid ui/i.test(projectText(ctx, docs));
410
+ },
411
+ }),
412
+ [makeKey('SwiftDataPatternsDocumented')]: makeCheck({
413
+ platform,
414
+ id: makeId('SW', 9),
415
+ name: 'Core Data/SwiftData patterns documented',
416
+ category: 'swift',
417
+ impact: 'medium',
418
+ fix: 'Document Core Data or SwiftData usage patterns when the project persists data through Apple-native storage frameworks.',
419
+ check: (ctx) => {
420
+ if (!hasSwiftSurface(ctx)) return null;
421
+ const source = swiftUiSignals(ctx) + '\n' + swiftConfigText(ctx);
422
+ if (!/CoreData|SwiftData/i.test(source)) return null;
423
+ return /core data|swiftdata|modelcontext|persistentcontainer/i.test(projectText(ctx, docs));
424
+ },
425
+ }),
426
+ [makeKey('SwiftGitignore')]: makeCheck({
427
+ platform,
428
+ id: makeId('SW', 10),
429
+ name: 'Xcode-specific .gitignore',
430
+ category: 'swift',
431
+ impact: 'medium',
432
+ fix: 'Add Xcode ignore rules such as `DerivedData/`, `xcuserdata/`, and `.build/` to `.gitignore`.',
433
+ check: (ctx) => {
434
+ if (!hasSwiftSurface(ctx)) return null;
435
+ const gitignore = fileContent(ctx, '.gitignore');
436
+ return /DerivedData\/|xcuserdata\/|\.build\/|\*\.xcuserstate/i.test(gitignore);
437
+ },
438
+ }),
439
+
440
+ [makeKey('KotlinBuildGradleExists')]: makeCheck({
441
+ platform,
442
+ id: makeId('KT', 1),
443
+ name: 'build.gradle.kts exists',
444
+ category: 'kotlin',
445
+ impact: 'high',
446
+ fix: 'Commit `build.gradle.kts` for the Android/Kotlin project so build logic is explicit and reviewable.',
447
+ check: (ctx) => hasAndroidKotlinSurface(ctx) ? true : null,
448
+ }),
449
+ [makeKey('KotlinVersionSpecified')]: makeCheck({
450
+ platform,
451
+ id: makeId('KT', 2),
452
+ name: 'Kotlin version specified',
453
+ category: 'kotlin',
454
+ impact: 'high',
455
+ fix: 'Specify the Kotlin version in Gradle plugins, version catalogs, or build properties.',
456
+ check: (ctx) => {
457
+ if (!hasAndroidKotlinSurface(ctx)) return null;
458
+ return /kotlin(?:\(["'][^)]+["']\))?\s+version\s+["'][^"']+["']|org\.jetbrains\.kotlin\.[\w.-]+\s+version\s+["'][^"']+["']|kotlin\s*=\s*["'][^"']+["']/i.test(androidGradleText(ctx));
459
+ },
460
+ }),
461
+ [makeKey('KotlinLintConfigured')]: makeCheck({
462
+ platform,
463
+ id: makeId('KT', 3),
464
+ name: 'ktlint/detekt configured',
465
+ category: 'kotlin',
466
+ impact: 'medium',
467
+ fix: 'Configure ktlint or detekt in Gradle or CI so Kotlin style and static-analysis rules stay consistent.',
468
+ check: (ctx) => {
469
+ if (!hasAndroidKotlinSurface(ctx)) return null;
470
+ return hasMatchingFile(ctx, /(^|[\\/])\.?detekt\.ya?ml$/i) ||
471
+ /ktlint|detekt/i.test(androidGradleText(ctx) + '\n' + workflowText(ctx));
472
+ },
473
+ }),
474
+ [makeKey('KotlinAndroidTestsDocumented')]: makeCheck({
475
+ platform,
476
+ id: makeId('KT', 4),
477
+ name: 'Android test framework documented',
478
+ category: 'kotlin',
479
+ impact: 'high',
480
+ fix: 'Document the Android test stack such as JUnit, Espresso, Robolectric, or `connectedAndroidTest` in repo guidance.',
481
+ check: (ctx) => hasAndroidKotlinSurface(ctx)
482
+ ? /androidtest|connectedandroidtest|espresso|robolectric|junit|gradlew test/i.test(projectText(ctx, docs))
483
+ : null,
484
+ }),
485
+ [makeKey('KotlinGradleWrapperCommitted')]: makeCheck({
486
+ platform,
487
+ id: makeId('KT', 5),
488
+ name: 'Gradle wrapper committed (gradlew)',
489
+ category: 'kotlin',
490
+ impact: 'high',
491
+ fix: 'Commit `gradlew` and the Gradle wrapper files so Android builds are reproducible across environments.',
492
+ check: (ctx) => hasAndroidKotlinSurface(ctx)
493
+ ? hasMatchingFile(ctx, /(^|[\\/])gradlew(?:\.bat)?$/i)
494
+ : null,
495
+ }),
496
+ [makeKey('KotlinBuildVariantsDocumented')]: makeCheck({
497
+ platform,
498
+ id: makeId('KT', 6),
499
+ name: 'Build variants documented',
500
+ category: 'kotlin',
501
+ impact: 'medium',
502
+ fix: 'Document Android build types and product flavors so agents know how to target debug, release, and environment variants.',
503
+ check: (ctx) => hasAndroidKotlinSurface(ctx)
504
+ ? /build variant|build type|productflavors|flavor|debug|release|staging/i.test(projectText(ctx, docs) + '\n' + androidGradleText(ctx))
505
+ : null,
506
+ }),
507
+ [makeKey('KotlinProguardConfigured')]: makeCheck({
508
+ platform,
509
+ id: makeId('KT', 7),
510
+ name: 'ProGuard/R8 configuration',
511
+ category: 'kotlin',
512
+ impact: 'medium',
513
+ fix: 'Add ProGuard or R8 configuration such as `proguard-rules.pro` and minification settings for release builds.',
514
+ check: (ctx) => {
515
+ if (!hasAndroidKotlinSurface(ctx)) return null;
516
+ return hasMatchingFile(ctx, /(^|[\\/])proguard-rules\.pro$/i) ||
517
+ /proguardFiles|minifyEnabled|isMinifyEnabled|shrinkResources|r8/i.test(androidGradleText(ctx));
518
+ },
519
+ }),
520
+ [makeKey('KotlinUiApproachDocumented')]: makeCheck({
521
+ platform,
522
+ id: makeId('KT', 8),
523
+ name: 'Compose vs XML approach documented',
524
+ category: 'kotlin',
525
+ impact: 'medium',
526
+ fix: 'Document whether the Android UI is Jetpack Compose, XML layouts, or hybrid so generated changes follow the right pattern.',
527
+ check: (ctx) => {
528
+ if (!hasAndroidKotlinSurface(ctx)) return null;
529
+ const signals = kotlinComposeSignals(ctx);
530
+ const hasCompose = /compose\s*=\s*true|@Composable|androidx\.compose/i.test(signals);
531
+ const hasXml = hasMatchingFile(ctx, /(^|[\\/])src[\\/].+[\\/]res[\\/]layout[\\/].+\.xml$/i);
532
+ if (!hasCompose && !hasXml) return null;
533
+ return /compose|xml|jetpack compose|layout xml|viewbinding/i.test(projectText(ctx, docs));
534
+ },
535
+ }),
536
+ [makeKey('KotlinSigningDocumented')]: makeCheck({
537
+ platform,
538
+ id: makeId('KT', 9),
539
+ name: 'Signing config documented',
540
+ category: 'kotlin',
541
+ impact: 'high',
542
+ fix: 'Document Android release signing, keystores, and environment variable expectations for mobile delivery.',
543
+ check: (ctx) => hasAndroidKotlinSurface(ctx)
544
+ ? /signingconfig|keystore|release signing|upload key|signing/i.test(projectText(ctx, docs))
545
+ : null,
546
+ }),
547
+ [makeKey('KotlinGitignore')]: makeCheck({
548
+ platform,
549
+ id: makeId('KT', 10),
550
+ name: 'Android-specific .gitignore',
551
+ category: 'kotlin',
552
+ impact: 'medium',
553
+ fix: 'Add Android-specific ignore rules such as `.gradle/`, `local.properties`, and IDE build artifacts to `.gitignore`.',
554
+ check: (ctx) => {
555
+ if (!hasAndroidKotlinSurface(ctx)) return null;
556
+ const gitignore = fileContent(ctx, '.gitignore');
557
+ return /\.gradle\/|local\.properties|\*\.iml|captures\/|build_file_checksums\.ser/i.test(gitignore);
558
+ },
559
+ }),
560
+ };
561
+ }
562
+
563
+ module.exports = {
564
+ buildStackChecks,
565
+ };