pumuki 6.3.182 → 6.3.184

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.
package/VERSION CHANGED
@@ -1 +1 @@
1
- v6.3.182
1
+ v6.3.184
@@ -6,12 +6,14 @@ import {
6
6
  findKotlinLiskovSubstitutionMatch,
7
7
  findKotlinOpenClosedWhenMatch,
8
8
  findKotlinPresentationSrpMatch,
9
+ hasKotlinCoroutineTryCatchUsage,
9
10
  hasKotlinDispatcherMainBoundaryLeakUsage,
10
11
  hasKotlinGlobalScopeUsage,
11
12
  hasKotlinHardcodedBackgroundDispatcherUsage,
12
13
  hasKotlinLiveDataStateExposureUsage,
13
14
  hasKotlinManualCoroutineScopeInViewModelUsage,
14
15
  hasKotlinRunBlockingUsage,
16
+ hasKotlinSupervisorScopeUsage,
15
17
  hasKotlinThreadSleepCall,
16
18
  } from './android';
17
19
 
@@ -191,6 +193,84 @@ class SyncOrdersUseCase {
191
193
  assert.equal(hasKotlinHardcodedBackgroundDispatcherUsage(source), false);
192
194
  });
193
195
 
196
+ test('hasKotlinSupervisorScopeUsage detecta supervisorScope con parentesis y llaves', () => {
197
+ const parenthesesSource = `
198
+ class SyncOrdersUseCase {
199
+ suspend fun execute() = supervisorScope {
200
+ launch { syncRemote() }
201
+ }
202
+ }
203
+ `;
204
+ const genericSource = `
205
+ class SyncOrdersUseCase {
206
+ suspend fun execute() = supervisorScope<Unit> {
207
+ launch { syncRemote() }
208
+ }
209
+ }
210
+ `;
211
+ assert.equal(hasKotlinSupervisorScopeUsage(parenthesesSource), true);
212
+ assert.equal(hasKotlinSupervisorScopeUsage(genericSource), true);
213
+ });
214
+
215
+ test('hasKotlinSupervisorScopeUsage ignora imports, comentarios, strings y nombres parciales', () => {
216
+ const source = `
217
+ import kotlinx.coroutines.supervisorScope
218
+ // supervisorScope { launch { } }
219
+ val sample = "supervisorScope { launch { } }"
220
+ class SyncOrdersUseCase {
221
+ suspend fun execute() = customSupervisorScope { }
222
+ }
223
+ `;
224
+ assert.equal(hasKotlinSupervisorScopeUsage(source), false);
225
+ });
226
+
227
+ test('hasKotlinCoroutineTryCatchUsage detecta try-catch dentro de contexto coroutine', () => {
228
+ const suspendSource = `
229
+ class SyncOrdersUseCase {
230
+ suspend fun execute() {
231
+ try {
232
+ syncRemote()
233
+ } catch (error: IOException) {
234
+ recover(error)
235
+ }
236
+ }
237
+ }
238
+ `;
239
+ const launchSource = `
240
+ class SyncOrdersUseCase {
241
+ fun execute() {
242
+ launch {
243
+ try {
244
+ syncRemote()
245
+ } catch (error: IOException) {
246
+ recover(error)
247
+ }
248
+ }
249
+ }
250
+ }
251
+ `;
252
+ assert.equal(hasKotlinCoroutineTryCatchUsage(suspendSource), true);
253
+ assert.equal(hasKotlinCoroutineTryCatchUsage(launchSource), true);
254
+ });
255
+
256
+ test('hasKotlinCoroutineTryCatchUsage ignora imports, comentarios, strings y try-catch no coroutine', () => {
257
+ const source = `
258
+ import kotlin.runCatching
259
+ // suspend fun execute() { try { syncRemote() } catch (error: IOException) { recover(error) } }
260
+ val sample = "try { syncRemote() } catch (error: IOException) { recover(error) }"
261
+ class SyncOrdersUseCase {
262
+ fun execute() {
263
+ try {
264
+ syncRemote()
265
+ } catch (error: IOException) {
266
+ recover(error)
267
+ }
268
+ }
269
+ }
270
+ `;
271
+ assert.equal(hasKotlinCoroutineTryCatchUsage(source), false);
272
+ });
273
+
194
274
  test('findKotlinPresentationSrpMatch devuelve payload semantico para SRP-Android en presentation', () => {
195
275
  const source = `
196
276
  import android.content.SharedPreferences
@@ -259,6 +259,23 @@ export const hasKotlinHardcodedBackgroundDispatcherUsage = (source: string): boo
259
259
  return collectKotlinRegexLines(source, /\bDispatchers\s*\.\s*(?:IO|Default)\b/).length > 0;
260
260
  };
261
261
 
262
+ export const hasKotlinSupervisorScopeUsage = (source: string): boolean => {
263
+ return collectKotlinRegexLines(source, /\bsupervisorScope\s*(?:<[^>\n]+>\s*)?(?:\(|\{)/).length > 0;
264
+ };
265
+
266
+ export const hasKotlinCoroutineTryCatchUsage = (source: string): boolean => {
267
+ const sanitizedSource = source
268
+ .split(/\r?\n/)
269
+ .map((line) => stripKotlinLineForSemanticScan(line))
270
+ .filter((line) => !line.trimStart().startsWith('import '))
271
+ .join('\n');
272
+
273
+ return (
274
+ /\btry\s*\{[\s\S]*\bcatch\s*\(/.test(sanitizedSource) &&
275
+ /\b(?:suspend\s+fun|launch\s*\{|async\s*\{|withContext\s*\(|supervisorScope\s*(?:<[^>\n]+>\s*)?(?:\(|\{))/.test(sanitizedSource)
276
+ );
277
+ };
278
+
262
279
  export const hasKotlinThreadSleepCall = (source: string): boolean => {
263
280
  return scanCodeLikeSource(source, ({ source: kotlinSource, index, current }) => {
264
281
  if (current !== 'T') {
@@ -649,6 +649,8 @@ const textDetectorRegistry: ReadonlyArray<TextDetectorRegistryEntry> = [
649
649
  { platform: 'android', pathCheck: isAndroidPresentationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinManualCoroutineScopeInViewModelUsage, ruleId: 'heuristics.android.coroutines.manual-scope-in-viewmodel.ast', code: 'HEURISTICS_ANDROID_COROUTINES_MANUAL_SCOPE_IN_VIEWMODEL_AST', message: 'AST heuristic detected manual CoroutineScope inside an Android ViewModel where viewModelScope should be preferred.' },
650
650
  { platform: 'android', pathCheck: isAndroidNonPresentationKotlinPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinDispatcherMainBoundaryLeakUsage, ruleId: 'heuristics.android.coroutines.dispatchers-main-boundary-leak.ast', code: 'HEURISTICS_ANDROID_COROUTINES_DISPATCHERS_MAIN_BOUNDARY_LEAK_AST', message: 'AST heuristic detected Dispatchers.Main outside Android presentation code.' },
651
651
  { platform: 'android', pathCheck: isAndroidDomainOrApplicationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinHardcodedBackgroundDispatcherUsage, ruleId: 'heuristics.android.coroutines.hardcoded-background-dispatcher.ast', code: 'HEURISTICS_ANDROID_COROUTINES_HARDCODED_BACKGROUND_DISPATCHER_AST', message: 'AST heuristic detected hard-coded Dispatchers.IO or Dispatchers.Default in Android domain/application code.' },
652
+ { platform: 'android', pathCheck: isAndroidDomainOrApplicationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinSupervisorScopeUsage, ruleId: 'heuristics.android.coroutines.supervisor-scope.ast', code: 'HEURISTICS_ANDROID_COROUTINES_SUPERVISOR_SCOPE_AST', message: 'AST heuristic detected supervisorScope usage in Android domain/application code.' },
653
+ { platform: 'android', pathCheck: isAndroidDomainOrApplicationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinCoroutineTryCatchUsage, ruleId: 'heuristics.android.coroutines.try-catch.ast', code: 'HEURISTICS_ANDROID_COROUTINES_TRY_CATCH_AST', message: 'AST heuristic detected try-catch handling in Android coroutine code.' },
652
654
  ];
653
655
 
654
656
  const extractWorkflowHeuristicFacts = (
@@ -3,7 +3,7 @@ import test from 'node:test';
3
3
  import { androidRules } from './android';
4
4
 
5
5
  test('androidRules define reglas heurísticas locked para plataforma android', () => {
6
- assert.equal(androidRules.length, 12);
6
+ assert.equal(androidRules.length, 14);
7
7
 
8
8
  const ids = androidRules.map((rule) => rule.id);
9
9
  assert.deepEqual(ids, [
@@ -14,6 +14,8 @@ test('androidRules define reglas heurísticas locked para plataforma android', (
14
14
  'heuristics.android.coroutines.manual-scope-in-viewmodel.ast',
15
15
  'heuristics.android.coroutines.dispatchers-main-boundary-leak.ast',
16
16
  'heuristics.android.coroutines.hardcoded-background-dispatcher.ast',
17
+ 'heuristics.android.coroutines.supervisor-scope.ast',
18
+ 'heuristics.android.coroutines.try-catch.ast',
17
19
  'heuristics.android.solid.srp.presentation-mixed-responsibilities.ast',
18
20
  'heuristics.android.solid.ocp.discriminator-branching.ast',
19
21
  'heuristics.android.solid.dip.concrete-framework-dependency.ast',
@@ -60,6 +62,14 @@ test('androidRules define reglas heurísticas locked para plataforma android', (
60
62
  byId.get('heuristics.android.coroutines.hardcoded-background-dispatcher.ast')?.then.code,
61
63
  'HEURISTICS_ANDROID_COROUTINES_HARDCODED_BACKGROUND_DISPATCHER_AST'
62
64
  );
65
+ assert.equal(
66
+ byId.get('heuristics.android.coroutines.supervisor-scope.ast')?.then.code,
67
+ 'HEURISTICS_ANDROID_COROUTINES_SUPERVISOR_SCOPE_AST'
68
+ );
69
+ assert.equal(
70
+ byId.get('heuristics.android.coroutines.try-catch.ast')?.then.code,
71
+ 'HEURISTICS_ANDROID_COROUTINES_TRY_CATCH_AST'
72
+ );
63
73
  assert.equal(
64
74
  byId.get('heuristics.android.solid.srp.presentation-mixed-responsibilities.ast')?.then.code,
65
75
  'HEURISTICS_ANDROID_SOLID_SRP_PRESENTATION_MIXED_RESPONSIBILITIES_AST'
@@ -135,6 +135,46 @@ export const androidRules: RuleSet = [
135
135
  code: 'HEURISTICS_ANDROID_COROUTINES_HARDCODED_BACKGROUND_DISPATCHER_AST',
136
136
  },
137
137
  },
138
+ {
139
+ id: 'heuristics.android.coroutines.supervisor-scope.ast',
140
+ description:
141
+ 'Detects supervisorScope usage in Android domain/application code.',
142
+ severity: 'WARN',
143
+ platform: 'android',
144
+ locked: true,
145
+ when: {
146
+ kind: 'Heuristic',
147
+ where: {
148
+ ruleId: 'heuristics.android.coroutines.supervisor-scope.ast',
149
+ },
150
+ },
151
+ then: {
152
+ kind: 'Finding',
153
+ message:
154
+ 'AST heuristic detected supervisorScope usage in Android domain/application code.',
155
+ code: 'HEURISTICS_ANDROID_COROUTINES_SUPERVISOR_SCOPE_AST',
156
+ },
157
+ },
158
+ {
159
+ id: 'heuristics.android.coroutines.try-catch.ast',
160
+ description:
161
+ 'Detects try-catch error handling in Android coroutine code.',
162
+ severity: 'WARN',
163
+ platform: 'android',
164
+ locked: true,
165
+ when: {
166
+ kind: 'Heuristic',
167
+ where: {
168
+ ruleId: 'heuristics.android.coroutines.try-catch.ast',
169
+ },
170
+ },
171
+ then: {
172
+ kind: 'Finding',
173
+ message:
174
+ 'AST heuristic detected try-catch handling in Android coroutine code.',
175
+ code: 'HEURISTICS_ANDROID_COROUTINES_TRY_CATCH_AST',
176
+ },
177
+ },
138
178
  {
139
179
  id: 'heuristics.android.solid.srp.presentation-mixed-responsibilities.ast',
140
180
  description:
@@ -126,7 +126,9 @@ app/
126
126
  ✅ `skills.android.guideline.android.coroutines-async-await-no-callbacks` debe mapear a señales ejecutables existentes de uso inseguro de coroutines, empezando por `GlobalScope` y `runBlocking`.
127
127
  ✅ `skills.android.guideline.android.viewmodelscope-scope-de-viewmodel-cancelado-automa-ticamente` debe mapear a señales ejecutables de scopes manuales dentro de `ViewModel`, empezando por `CoroutineScope(...)` construido en presentation.
128
128
  ✅ `skills.android.guideline.android.dispatchers-main-ui-io-network-disk-default-cpu` debe mapear a señales ejecutables de dispatchers mal ubicados: `Dispatchers.Main` fuera de `presentation` y `Dispatchers.IO` / `Dispatchers.Default` hardcodeados en `domain` o `application` en lugar de entrar por frontera inyectable.
129
- El baseline inicial de coroutines es parcial: cubre APIs bloqueantes, scopes no estructurados, scopes manuales en `ViewModel`, filtraciones de `Dispatchers.Main` y hardcode de dispatchers de background en dominio/aplicación, pero no declara todavía cobertura completa de `Flow`, `supervisorScope`, dispatchers ni cancelación cooperativa.
129
+ `skills.android.guideline.android.supervisorscope-errores-no-cancelan-otros-jobs` debe mapear a señal ejecutable de `supervisorScope` en `domain` o `application`.
130
+ ✅ `skills.android.guideline.android.try-catch-manejo-de-errores-en-coroutines` debe mapear a señal ejecutable de `try/catch` dentro de código coroutine en `domain` o `application`.
131
+ ✅ El baseline inicial de coroutines es parcial: cubre APIs bloqueantes, scopes no estructurados, scopes manuales en `ViewModel`, filtraciones de `Dispatchers.Main`, hardcode de dispatchers de background en dominio/aplicación, `supervisorScope` y `try/catch` en coroutines, pero no declara todavía cobertura completa de `Flow`, dispatchers ni cancelación cooperativa.
130
132
  ✅ Si se amplía esta cobertura, cada nueva regla debe aterrizar como detector AST/textual semántico con test dirigido antes de declararse cubierta en el registry.
131
133
 
132
134
  ### Enforcement AST inicial de Flow/StateFlow Android
@@ -231,6 +231,14 @@ const registryByRuleId: Record<string, SkillsDetectorBinding> = {
231
231
  'heuristics.android.coroutines.hardcoded-background-dispatcher.ast',
232
232
  ]
233
233
  ),
234
+ 'skills.android.guideline.android.supervisorscope-errores-no-cancelan-otros-jobs': heuristicDetector(
235
+ 'android.coroutines.supervisor-scope',
236
+ ['heuristics.android.coroutines.supervisor-scope.ast']
237
+ ),
238
+ 'skills.android.guideline.android.try-catch-manejo-de-errores-en-coroutines': heuristicDetector(
239
+ 'android.coroutines.try-catch',
240
+ ['heuristics.android.coroutines.try-catch.ast']
241
+ ),
234
242
  'skills.android.guideline.android.stateflow-estado-mutable-observable': heuristicDetector(
235
243
  'android.flow.state-exposure',
236
244
  ['heuristics.android.flow.livedata-state-exposure.ast']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki",
3
- "version": "6.3.182",
3
+ "version": "6.3.184",
4
4
  "description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
5
5
  "main": "index.js",
6
6
  "bin": {
package/skills.lock.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "1.0",
3
3
  "compilerVersion": "1.0.0",
4
- "generatedAt": "2026-05-12T20:34:49.636Z",
4
+ "generatedAt": "2026-05-12T20:47:37.241Z",
5
5
  "bundles": [
6
6
  {
7
7
  "name": "android-guidelines",