@reicek/neataptic-ts 0.1.15 → 0.1.16

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 (301) hide show
  1. package/.github/copilot-instructions.md +71 -15
  2. package/.prettierrc.json +12 -0
  3. package/bench-browser/bench-entry.ts +1 -1
  4. package/bench-browser/dev.bundle.1759662879868-23916.js +10517 -0
  5. package/bench-browser/dev.bundle.js +229 -229
  6. package/bench-browser/prod.bundle.1759662879868-23916.js +41 -0
  7. package/bench-browser/prod.bundle.js +955 -955
  8. package/docs/architecture/README.md +42 -125
  9. package/docs/architecture/index.html +33 -109
  10. package/docs/architecture/network/README.md +144 -349
  11. package/docs/architecture/network/index.html +64 -267
  12. package/docs/assets/ascii-maze.bundle.js +41 -41
  13. package/docs/assets/ascii-maze.bundle.js.map +4 -4
  14. package/docs/methods/README.md +4 -6
  15. package/docs/methods/index.html +3 -8
  16. package/docs/multithreading/README.md +21 -5
  17. package/docs/multithreading/index.html +8 -6
  18. package/docs/multithreading/workers/README.md +2 -2
  19. package/docs/multithreading/workers/browser/README.md +10 -2
  20. package/docs/multithreading/workers/browser/index.html +6 -4
  21. package/docs/multithreading/workers/index.html +2 -2
  22. package/docs/multithreading/workers/node/README.md +27 -1
  23. package/docs/multithreading/workers/node/index.html +20 -3
  24. package/docs/neat/README.md +295 -261
  25. package/docs/neat/index.html +146 -231
  26. package/docs/src/README.md +71 -70
  27. package/docs/src/index.html +58 -69
  28. package/docs/utils/README.md +11 -26
  29. package/docs/utils/index.html +9 -27
  30. package/eslint.config.mjs +57 -0
  31. package/package.json +9 -1
  32. package/plans/ES2023 migration +40 -176
  33. package/plans/Memory_Optimization.md +2 -1
  34. package/src/README.md +71 -70
  35. package/src/architecture/README.md +42 -125
  36. package/src/architecture/activationArrayPool.ts +5 -1
  37. package/src/architecture/architect.ts +11 -8
  38. package/src/architecture/connection.ts +71 -31
  39. package/src/architecture/group.ts +38 -25
  40. package/src/architecture/layer.ts +69 -48
  41. package/src/architecture/network/README.md +144 -349
  42. package/src/architecture/network/network.activate.ts +33 -19
  43. package/src/architecture/network/network.connect.ts +17 -6
  44. package/src/architecture/network/network.deterministic.ts +32 -11
  45. package/src/architecture/network/network.evolve.ts +151 -56
  46. package/src/architecture/network/network.gating.ts +16 -3
  47. package/src/architecture/network/network.genetic.ts +106 -66
  48. package/src/architecture/network/network.mutate.ts +96 -44
  49. package/src/architecture/network/network.onnx.ts +353 -219
  50. package/src/architecture/network/network.prune.ts +36 -14
  51. package/src/architecture/network/network.remove.ts +20 -9
  52. package/src/architecture/network/network.serialize.ts +214 -96
  53. package/src/architecture/network/network.slab.ts +218 -72
  54. package/src/architecture/network/network.standalone.ts +50 -20
  55. package/src/architecture/network/network.stats.ts +20 -5
  56. package/src/architecture/network/network.topology.ts +16 -4
  57. package/src/architecture/network/network.training.ts +270 -112
  58. package/src/architecture/network.ts +167 -82
  59. package/src/architecture/node.ts +76 -44
  60. package/src/architecture/nodePool.ts +35 -43
  61. package/src/methods/README.md +4 -6
  62. package/src/methods/activation.ts +7 -3
  63. package/src/methods/mutation.ts +63 -29
  64. package/src/methods/rate.ts +2 -0
  65. package/src/multithreading/README.md +21 -5
  66. package/src/multithreading/multi.ts +29 -21
  67. package/src/multithreading/types.ts +20 -0
  68. package/src/multithreading/workers/README.md +2 -2
  69. package/src/multithreading/workers/browser/README.md +10 -2
  70. package/src/multithreading/workers/browser/testworker.ts +22 -8
  71. package/src/multithreading/workers/node/README.md +27 -1
  72. package/src/multithreading/workers/node/testworker.ts +29 -15
  73. package/src/multithreading/workers/node/worker.ts +36 -28
  74. package/src/multithreading/workers/workers.ts +8 -4
  75. package/src/neat/README.md +295 -261
  76. package/src/neat/neat.adaptive.ts +147 -26
  77. package/src/neat/neat.compat.ts +51 -13
  78. package/src/neat/neat.diversity.ts +33 -15
  79. package/src/neat/neat.evaluate.ts +157 -33
  80. package/src/neat/neat.evolve.ts +572 -210
  81. package/src/neat/neat.export.ts +94 -37
  82. package/src/neat/neat.harness.types.ts +35 -0
  83. package/src/neat/neat.helpers.ts +117 -52
  84. package/src/neat/neat.multiobjective.ts +41 -9
  85. package/src/neat/neat.mutation.ts +444 -225
  86. package/src/neat/neat.objectives.ts +32 -17
  87. package/src/neat/neat.pruning.ts +43 -14
  88. package/src/neat/neat.selection.ts +60 -39
  89. package/src/neat/neat.speciation.ts +187 -372
  90. package/src/neat/neat.species.ts +35 -20
  91. package/src/neat/neat.telemetry.exports.ts +88 -55
  92. package/src/neat/neat.telemetry.ts +448 -486
  93. package/src/neat/neat.types.ts +176 -11
  94. package/src/neat.ts +146 -41
  95. package/src/utils/README.md +11 -26
  96. package/src/utils/memory.ts +135 -70
  97. package/srcLint.md +185 -0
  98. package/test/architecture/activationArrayPool.capacity.test.ts +15 -4
  99. package/test/architecture/activationArrayPool.test.ts +2 -2
  100. package/test/architecture/connection.test.ts +16 -5
  101. package/test/architecture/group.test.ts +34 -20
  102. package/test/architecture/layer.test.ts +101 -35
  103. package/test/architecture/node.test.ts +36 -28
  104. package/test/benchmarks/benchmark.browser.headless.test.ts +62 -23
  105. package/test/benchmarks/benchmark.buildVariants.test.ts +3 -3
  106. package/test/benchmarks/benchmark.fieldAudit.test.ts +25 -6
  107. package/test/benchmarks/benchmark.memory.test.ts +187 -67
  108. package/test/benchmarks/benchmark.nodePool.determinism.test.ts +9 -2
  109. package/test/benchmarks/benchmark.nodePool.memory.test.ts +8 -1
  110. package/test/benchmarks/benchmark.nodePool.removeRelease.test.ts +10 -2
  111. package/test/benchmarks/benchmark.nodePool.stress.test.ts +4 -3
  112. package/test/benchmarks/benchmark.report.test.ts +6 -6
  113. package/test/benchmarks/benchmark.serialization.gater.test.ts +56 -16
  114. package/test/benchmarks/benchmark.slab.fragmentation.bounds.test.ts +13 -4
  115. package/test/benchmarks/benchmark.slab.fragmentation.trend.test.ts +17 -7
  116. package/test/benchmarks/benchmark.variance.escalation.test.ts +12 -1
  117. package/test/benchmarks/benchmark.variance.test.ts +24 -3
  118. package/test/examples/asciiMaze/asciiMaze.e2e.test.ts +4 -83
  119. package/test/examples/asciiMaze/asciiMaze.ts +0 -10
  120. package/test/examples/asciiMaze/browser-entry.ts +104 -33
  121. package/test/examples/asciiMaze/browserLogger.ts +22 -12
  122. package/test/examples/asciiMaze/dashboardManager.ts +222 -77
  123. package/test/examples/asciiMaze/evolutionEngine/engineState.ts +807 -0
  124. package/test/examples/asciiMaze/evolutionEngine/evolutionLoop.ts +1722 -0
  125. package/test/examples/asciiMaze/evolutionEngine/neatConfiguration.ts +309 -0
  126. package/test/examples/asciiMaze/evolutionEngine/networkInspection.ts +434 -0
  127. package/test/examples/asciiMaze/evolutionEngine/optionsAndSetup.ts +433 -0
  128. package/test/examples/asciiMaze/evolutionEngine/populationDynamics.ts +1696 -0
  129. package/test/examples/asciiMaze/evolutionEngine/populationPruning.ts +670 -0
  130. package/test/examples/asciiMaze/evolutionEngine/rngAndTiming.ts +145 -0
  131. package/test/examples/asciiMaze/evolutionEngine/sampling.ts +299 -0
  132. package/test/examples/asciiMaze/evolutionEngine/scratchPools.ts +445 -0
  133. package/test/examples/asciiMaze/evolutionEngine/setupHelpers.ts +279 -0
  134. package/test/examples/asciiMaze/evolutionEngine/telemetryMetrics.ts +1619 -0
  135. package/test/examples/asciiMaze/evolutionEngine/trainingWarmStart.ts +617 -0
  136. package/test/examples/asciiMaze/evolutionEngine.ts +382 -8431
  137. package/test/examples/asciiMaze/interfaces.ts +450 -6
  138. package/test/examples/asciiMaze/mazeMovement.ts +99 -83
  139. package/test/examples/asciiMaze/mazeUtils.ts +17 -28
  140. package/test/examples/asciiMaze/mazeVisualization.ts +7 -4
  141. package/test/examples/asciiMaze/mazes.ts +38 -59
  142. package/test/examples/asciiMaze/networkRefinement.ts +23 -14
  143. package/test/examples/asciiMaze/networkVisualization.ts +294 -111
  144. package/test/examples/asciiMaze/refineWinner.ts +3 -3
  145. package/test/methods/activation.test.ts +12 -73
  146. package/test/methods/connection.test.ts +3 -2
  147. package/test/methods/crossover.test.ts +6 -2
  148. package/test/methods/gating.test.ts +9 -3
  149. package/test/methods/mutation.test.ts +11 -7
  150. package/test/methods/optimizers.advanced.test.ts +15 -7
  151. package/test/methods/optimizers.behavior.test.ts +24 -15
  152. package/test/methods/optimizers.formula.test.ts +68 -48
  153. package/test/multithreading/activations.functions.test.ts +3 -2
  154. package/test/multithreading/multi.test.ts +55 -36
  155. package/test/multithreading/worker.node.process.test.ts +3 -3
  156. package/test/multithreading/workers.coverage.test.ts +19 -10
  157. package/test/neat/{neat.adaptive.ancestorUniq.cooldown.skip.test.ts → neat.adaptive.ancestorUniq.cooldown.test.ts} +12 -6
  158. package/test/neat/neat.adaptive.ancestorUniq.epsilon.test.ts +15 -8
  159. package/test/neat/neat.adaptive.ancestorUniq.lineagePressure.test.ts +15 -8
  160. package/test/neat/neat.adaptive.complexityBudget.connShrink.test.ts +8 -5
  161. package/test/neat/neat.adaptive.complexityBudget.growth.novelty.test.ts +7 -5
  162. package/test/neat/neat.adaptive.complexityBudget.minClamp.test.ts +3 -3
  163. package/test/neat/neat.adaptive.complexityBudget.test.ts +4 -2
  164. package/test/neat/neat.adaptive.complexityBudget.trend.test.ts +5 -7
  165. package/test/neat/neat.adaptive.criterion.complexity.test.ts +10 -6
  166. package/test/neat/neat.adaptive.minimalCriterion.rejection.test.ts +8 -4
  167. package/test/neat/neat.adaptive.mutation.amount.adapt.test.ts +11 -6
  168. package/test/neat/neat.adaptive.mutation.anneal.strategy.test.ts +9 -6
  169. package/test/neat/neat.adaptive.mutation.exploreLow.strategy.test.ts +9 -6
  170. package/test/neat/neat.adaptive.mutation.strategy.test.ts +10 -5
  171. package/test/neat/neat.adaptive.mutation.twotier.balance.test.ts +8 -3
  172. package/test/neat/neat.adaptive.mutation.twotier.fallback.single.test.ts +6 -3
  173. package/test/neat/neat.adaptive.operator.adaptation.decay.balance.test.ts +14 -10
  174. package/test/neat/neat.adaptive.operator.bandit.decay.test.ts +5 -5
  175. package/test/neat/neat.adaptive.operator.decay.test.ts +4 -2
  176. package/test/neat/neat.adaptive.phasedComplexity.test.ts +5 -3
  177. package/test/neat/neat.adaptive.phasedComplexity.toggle.test.ts +5 -5
  178. package/test/neat/neat.adaptive.pruning.test.ts +5 -2
  179. package/test/neat/neat.additional.coverage.test.ts +42 -22
  180. package/test/neat/neat.advanced.test.ts +29 -19
  181. package/test/neat/neat.compat.distance.cache.test.ts +21 -7
  182. package/test/neat/neat.diversity.autocompat.test.ts +12 -5
  183. package/test/neat/neat.diversity.metrics.test.ts +1 -0
  184. package/test/neat/neat.diversity.stats.test.ts +14 -15
  185. package/test/neat/neat.enhancements.test.ts +37 -24
  186. package/test/neat/neat.entropy.ancestorAdaptive.test.ts +54 -29
  187. package/test/neat/neat.entropy.compat.csv.test.ts +7 -11
  188. package/test/neat/neat.export.meta.fromjson.test.ts +3 -2
  189. package/test/neat/neat.export.state.rehydrate.test.ts +8 -7
  190. package/test/neat/neat.fastmode.autotune.test.ts +10 -6
  191. package/test/neat/neat.helpers.spawn.pool.test.ts +17 -11
  192. package/test/neat/neat.innovation.test.ts +120 -41
  193. package/test/neat/neat.lineage.antibreeding.test.ts +34 -16
  194. package/test/neat/neat.lineage.buildAnc.window.test.ts +15 -7
  195. package/test/neat/neat.lineage.entropy.test.ts +35 -23
  196. package/test/neat/neat.lineage.inbreeding.test.ts +51 -32
  197. package/test/neat/neat.lineage.pressure.test.ts +10 -4
  198. package/test/neat/neat.multiobjective.adaptive.test.ts +11 -7
  199. package/test/neat/neat.multiobjective.dynamic.schedule.test.ts +9 -10
  200. package/test/neat/neat.multiobjective.dynamic.test.ts +11 -4
  201. package/test/neat/neat.multiobjective.fastsort.delegation.test.ts +41 -27
  202. package/test/neat/neat.multiobjective.prune.test.ts +14 -8
  203. package/test/neat/neat.mutation.addconn.cycle.guard.test.ts +36 -21
  204. package/test/neat/neat.mutation.undefined.pool.test.ts +10 -4
  205. package/test/neat/neat.objectives.register.clear.test.ts +14 -6
  206. package/test/neat/neat.offspring.allocation.test.ts +1 -2
  207. package/test/neat/neat.operator.bandit.test.ts +1 -1
  208. package/test/neat/neat.operator.phases.test.ts +18 -6
  209. package/test/neat/neat.pruneInactive.behavior.test.ts +26 -11
  210. package/test/neat/neat.pruning.adaptive.test.ts +16 -5
  211. package/test/neat/neat.reenable.adaptation.test.ts +16 -10
  212. package/test/neat/neat.rng.state.test.ts +33 -15
  213. package/test/neat/neat.selection.strategies.test.ts +15 -11
  214. package/test/neat/neat.spawn.add.test.ts +68 -35
  215. package/test/neat/neat.speciation.age.penalty.test.ts +63 -33
  216. package/test/neat/neat.speciation.assign.existing.test.ts +64 -24
  217. package/test/neat/neat.speciation.auto.tuning.jitter.test.ts +78 -38
  218. package/test/neat/neat.speciation.create.newSpecies.test.ts +58 -25
  219. package/test/neat/neat.speciation.fitnessSharing.equal.test.ts +33 -5
  220. package/test/neat/neat.speciation.fitnessSharing.kernel.test.ts +33 -6
  221. package/test/neat/neat.speciation.pid.threshold.clip.max.test.ts +68 -29
  222. package/test/neat/neat.speciation.pid.threshold.clip.min.test.ts +68 -29
  223. package/test/neat/neat.speciation.stagnation.prune.test.ts +23 -9
  224. package/test/neat/neat.speciation.test.ts +2 -0
  225. package/test/neat/neat.species.history.fallbacks.test.ts +59 -14
  226. package/test/neat/neat.telemetry.advanced.test.ts +113 -53
  227. package/test/neat/neat.telemetry.csv.lineage.test.ts +12 -7
  228. package/test/neat/neat.telemetry.fastmode.diversity.test.ts +52 -9
  229. package/test/neat/neat.telemetry.objective.events.test.ts +64 -13
  230. package/test/neat/neat.telemetry.parity.test.ts +12 -6
  231. package/test/neat/neat.telemetry.select.entropy.cache.test.ts +37 -12
  232. package/test/neat/neat.telemetry.stream.test.ts +10 -2
  233. package/test/neat/neat.telemetry.test.ts +1 -1
  234. package/test/neat/neat.test.ts +52 -31
  235. package/test/neat/neat.utilities.test.ts +38 -20
  236. package/test/network/acyclic.topoorder.test.ts +4 -4
  237. package/test/network/checkpoint.metricshook.test.ts +6 -2
  238. package/test/network/error.handling.test.ts +88 -56
  239. package/test/network/evolution.test.ts +17 -14
  240. package/test/network/genetic.test.ts +40 -21
  241. package/test/network/learning.capability.test.ts +15 -7
  242. package/test/network/mutation.effects.test.ts +80 -60
  243. package/test/network/network.activate.test.ts +35 -9
  244. package/test/network/network.deterministic.test.ts +20 -5
  245. package/test/network/network.evolve.branches.test.ts +27 -19
  246. package/test/network/network.evolve.multithread.branches.test.ts +78 -56
  247. package/test/network/network.evolve.test.ts +46 -24
  248. package/test/network/network.gating.removal.test.ts +17 -12
  249. package/test/network/network.mutate.additional.test.ts +2 -1
  250. package/test/network/network.mutate.edgecases.test.ts +3 -1
  251. package/test/network/network.mutate.test.ts +4 -2
  252. package/test/network/network.prune.earlyexit.test.ts +38 -4
  253. package/test/network/network.remove.errors.test.ts +3 -3
  254. package/test/network/network.slab.alloc.stats.reuse.test.ts +18 -8
  255. package/test/network/network.slab.async.test.ts +113 -41
  256. package/test/network/network.slab.capacity.test.ts +46 -36
  257. package/test/network/network.slab.fallbacks.test.ts +26 -6
  258. package/test/network/network.slab.fast.gain.parity.test.ts +29 -10
  259. package/test/network/network.slab.fast.gating.guard.test.ts +26 -11
  260. package/test/network/network.slab.fast.parity.test.ts +17 -9
  261. package/test/network/network.slab.flags.test.ts +23 -5
  262. package/test/network/network.slab.gain.omission.test.ts +26 -8
  263. package/test/network/network.slab.gain.release-on-reset.test.ts +31 -13
  264. package/test/network/network.slab.phase3.test.ts +21 -5
  265. package/test/network/network.slab.plasticity.test.ts +36 -12
  266. package/test/network/network.slab.versioning.test.ts +21 -3
  267. package/test/network/network.stats.test.ts +32 -7
  268. package/test/network/network.training.advanced.test.ts +45 -18
  269. package/test/network/network.training.basic.test.ts +124 -51
  270. package/test/network/network.training.helpers.test.ts +10 -7
  271. package/test/network/onnx.export.test.ts +164 -89
  272. package/test/network/onnx.recurrent.fused.test.ts +66 -52
  273. package/test/network/pruning.topology.test.ts +75 -34
  274. package/test/network/regularization.determinism.test.ts +14 -4
  275. package/test/network/regularization.stochasticdepth.test.ts +23 -12
  276. package/test/network/regularization.test.ts +82 -62
  277. package/test/network/regularization.weightnoise.test.ts +9 -4
  278. package/test/network/standalone.test.ts +8 -6
  279. package/test/network/structure.serialization.test.ts +128 -124
  280. package/test/onnx/onnx.conv.groundwork.test.ts +11 -7
  281. package/test/onnx/onnx.conv.infer.test.ts +8 -4
  282. package/test/onnx/onnx.conv.pool.flatten.test.ts +1 -1
  283. package/test/onnx/onnx.conv.pool.validation.test.ts +30 -20
  284. package/test/onnx/onnx.export.test.ts +41 -28
  285. package/test/onnx/onnx.import.test.ts +9 -5
  286. package/test/onnx/onnx.roundtrip.test.ts +2 -2
  287. package/test/training/training.determinism.mixed-precision.test.ts +7 -5
  288. package/test/training/training.earlystopping.test.ts +8 -8
  289. package/test/training/training.edge-cases.test.ts +24 -8
  290. package/test/training/training.extensions.test.ts +8 -7
  291. package/test/training/training.gradient.features.test.ts +5 -5
  292. package/test/training/training.gradient.refinements.test.ts +11 -5
  293. package/test/training/training.optimizer.test.ts +13 -2
  294. package/test/training/training.plateau.smoothing.test.ts +1 -1
  295. package/test/training/training.smoothing.types.test.ts +16 -12
  296. package/test/training/training.train.options.coverage.test.ts +1 -1
  297. package/test/utils/console-helper.ts +9 -7
  298. package/test/utils/jest-setup.ts +44 -31
  299. package/test/utils/pollUntil.test.ts +1 -1
  300. package/test/utils/pollUntil.ts +7 -7
  301. package/test/utils/test-helpers.ts +19 -14
@@ -4,6 +4,65 @@ Purpose
4
4
  -------
5
5
  When generating, modifying, or suggesting code that touches files under `src/` or `test/`, follow the project `STYLEGUIDE.md` rules and perform the quick validations listed below before returning suggestions.
6
6
 
7
+ **CRITICAL: Fix-first strategy for test failures**
8
+ ---------------------------------------------------
9
+ When asked to fix multiple test failures:
10
+
11
+ 1. **FOCUS on fixing ALL issues systematically BEFORE running tests**
12
+ - Create or update a comprehensive fix plan (e.g., `plans/TestsFix.md`)
13
+ - Categorize errors by type (TypeScript compilation, async/await, runtime logic)
14
+ - Prioritize: HIGH (compilation blockers) → MEDIUM (easy fixes) → LOW (investigation needed)
15
+ - Mark completed items with ✅ as you progress
16
+
17
+ 2. **DO NOT run tests or check test output during the fix phase**
18
+ - Avoid running `npm test`, `npm run test:silent`, or any test execution commands
19
+ - Do NOT run partial test checks like `Select-String -Pattern "●"` to see failures
20
+ - Do NOT attempt to run individual tests to "verify" fixes
21
+ - TypeScript compilation checks (`npx tsc --noEmit`) are acceptable to validate type fixes
22
+ - **REMEMBER**: You already have the test failure output - use it to guide your fixes
23
+
24
+ 3. **ONLY run full test suite AFTER all fixes are applied**
25
+ - Apply ALL planned fixes first (optimistically)
26
+ - Use `npm test` or `npm run test:silent` for final validation ONLY
27
+ - Analyze remaining failures and update the plan accordingly
28
+ - If you feel tempted to run a test, STOP and apply more fixes instead
29
+
30
+ 4. **Follow the plan strictly**
31
+ - Do not improvise or skip ahead
32
+ - Execute fixes in the documented priority order
33
+ - Update the plan with ✅ checkmarks and status notes as you complete each item
34
+ - Mark ALL items completed before running tests
35
+
36
+ **Why this matters:**
37
+ - Running tests interrupts the systematic fix workflow
38
+ - Test output during fixes causes distraction and context switching
39
+ - You already have all the error information needed to fix issues
40
+ - Optimistic fixing is faster than iterative test-fix-test cycles
41
+ - This strategy ensures thorough, complete fixes before validation
42
+
43
+ This strategy prevents distraction, maintains focus, and ensures systematic completion of all fixes before validation.
44
+
45
+
46
+ ES2023-first policy (strict)
47
+ ----------------------------
48
+ For educational clarity and a modern look, always prefer idiomatic ES2023 syntax when it improves readability or safety without changing behavior. This repo is intentionally opinionated: use the immutable array methods and modern language constructs by default.
49
+
50
+ Prefer (non-exhaustive):
51
+ - Arrays: `toSorted`, `toReversed`, `toSpliced`, `with`, `.at(-1)`, `findLast`, `findLastIndex`.
52
+ - Objects: spread/rest over `Object.assign` for shallow copies and merges.
53
+ - Optional chaining `?.` and nullish coalescing `??` (avoid `||` for defaulting unless you mean falsy semantics).
54
+ - Deep clone: `structuredClone` (or the project helper `safeStructuredClone` when cross-env safety is needed).
55
+ - Errors: `Error` with `{ cause }` (e.g., `new Error(msg, { cause })`).
56
+ - Numerics: numeric separators for long literals (for readability only, not to change values).
57
+ - Modules: ES modules `import`/`export` over CommonJS `require`/`module.exports` (follow the repo’s phase plan; new code should be ESM).
58
+
59
+ Avoid (legacy/less clear):
60
+ - In-place `sort`, `reverse`, `splice` in code paths that expect immutability; use the ES2023 immutable variants above.
61
+ - `Object.assign({}, obj)` or `Object.assign([], arr)` for cloning; use object/array spread.
62
+ - `JSON.parse(JSON.stringify(x))` for deep clone; use `structuredClone`/`safeStructuredClone`.
63
+ - Index math like `arr[arr.length - 1]`; prefer `arr.at(-1)` when readability benefits.
64
+ - CommonJS `require()` in new or refactored modules; prefer ESM.
65
+
7
66
  How to use these instructions
8
67
  -----------------------------
9
68
  - Always prefer to produce code that already satisfies the style guide.
@@ -26,6 +85,8 @@ Strict rules to enforce (apply to any suggestion touching `src/` or `test/`)
26
85
 
27
86
  6. Lookup tables and enums: prefer a single table/enum for small fixed mappings (for example direction deltas) and helper methods like `#opposite(direction)` rather than scattered arithmetic.
28
87
 
88
+ 7. Types: avoid `any` and `unknown` in `src/` and `test/`. Use precise types or `// eslint-disable-next-line @typescript-eslint/no-explicit-any` with a short justification comment.
89
+
29
90
  Automated validations to run before finalizing a suggestion
30
91
  -------------------------------------------------------
31
92
  When you modify or create files under `src/` or `test/`, run (or advise running) these quick validations. If you cannot run them, still make sure your suggestion would pass them.
@@ -43,9 +104,9 @@ When you modify or create files under `src/` or `test/`, run (or advise running)
43
104
  Quick checks to run (recommended)
44
105
  --------------------------------
45
106
  - TypeScript: run `npm run build` and report pass/fail.
46
- - Short-id scan: flag uses of the short identifiers regex `\b(dx|dy|d|i|a|b|c|p|o|idx|cand|tries)\b` in changed files.
47
107
  - Tests heuristic: flag test files that contain more than one `expect(` occurrence (these should be split into multiple `it()` blocks).
48
108
  - JSDoc: for new exported symbols, ensure a JSDoc block with `@param`/`@returns` exists (or flag if missing).
109
+ - ES2023 modernization: flag legacy patterns and suggest modern equivalents (see below one-liners).
49
110
 
50
111
  PowerShell examples (local validation)
51
112
  -------------------------------------
@@ -54,23 +115,18 @@ When you modify or create files under `src/` or `test/`, run (or advise running)
54
115
  npx tsc --noEmit -p tsconfig.json
55
116
  ```
56
117
 
57
- Short-id scan:
58
- ```powershell
59
- Get-ChildItem -Path src,test -Recurse -Include *.ts,*.tsx | Select-String -Pattern '\b(dx|dy|d|i|a|b|c|p|o|idx|cand|tries)\b' -NotMatch '\b(i|j)\b' -List
60
- ```
61
-
62
- Test heuristic:
63
- ```powershell
64
- Get-ChildItem -Path test -Recurse -Include *.ts,*.tsx | ForEach-Object {
65
- $count = (Get-Content $_.FullName | Select-String 'expect\(' -AllMatches).Matches.Count
66
- if ($count -gt 1) { Write-Output "$($_.FullName): $count expects" }
67
- }
68
- ```
69
-
70
118
  What to include with a suggestion
71
119
  --------------------------------
72
120
  - A short validation summary (TypeScript: pass/fail, short-id matches: list or 0, test-expect heuristic: list or 0, JSDoc missing: list or 0).
121
+ - ES2023: list any flagged legacy patterns and the intended replacements (e.g., `Object.assign` -> spread, `arr[arr.length-1]` -> `arr.at(-1)`, `JSON.parse(JSON.stringify())` -> `structuredClone`).
73
122
  - If any issue can't be safely fixed automatically, include a TODO comment at the top of the changed file and a one-line explanation in the patch.
74
123
 
75
- - A runnable patch or new file content that follows the rules above.
124
+ Test failure workflow
125
+ ---------------------
126
+ When fixing multiple test failures:
127
+ 1. Create/update a comprehensive plan document (e.g., `plans/TestsFix.md`)
128
+ 2. Apply ALL fixes systematically without running tests
129
+ 3. Validate TypeScript compilation with `npx tsc --noEmit -p tsconfig.test.json`
130
+ 4. ONLY run `npm test` after all planned fixes are complete
131
+ 5. Analyze results and iterate on remaining issues
76
132
 
@@ -0,0 +1,12 @@
1
+ {
2
+ "singleQuote": true,
3
+ "parser": "typescript",
4
+ "overrides": [
5
+ {
6
+ "files": "*.ts",
7
+ "options": {
8
+ "parser": "typescript"
9
+ }
10
+ }
11
+ ]
12
+ }
@@ -68,5 +68,5 @@ function run(): BrowserBenchRecord[] {
68
68
  results: run(),
69
69
  };
70
70
 
71
- // eslint-disable-next-line no-console
71
+
72
72
  console.log('[NEATAPTIC_BROWSER_BENCH] ready');