@reicek/neataptic-ts 0.1.15 → 0.1.18
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/.github/copilot-instructions.md +123 -15
- package/.prettierrc.json +12 -0
- package/bench-browser/bench-entry.ts +1 -1
- package/bench-browser/dev.bundle.1759662879868-23916.js +10517 -0
- package/bench-browser/dev.bundle.js +229 -229
- package/bench-browser/prod.bundle.1759662879868-23916.js +41 -0
- package/bench-browser/prod.bundle.js +955 -955
- package/docs/architecture/README.md +85 -168
- package/docs/architecture/index.html +76 -152
- package/docs/architecture/network/README.md +161 -366
- package/docs/architecture/network/index.html +79 -282
- package/docs/assets/ascii-maze.bundle.js +41 -41
- package/docs/assets/ascii-maze.bundle.js.map +4 -4
- package/docs/methods/README.md +4 -6
- package/docs/methods/index.html +3 -8
- package/docs/multithreading/README.md +21 -5
- package/docs/multithreading/index.html +8 -6
- package/docs/multithreading/workers/README.md +2 -2
- package/docs/multithreading/workers/browser/README.md +10 -2
- package/docs/multithreading/workers/browser/index.html +6 -4
- package/docs/multithreading/workers/index.html +2 -2
- package/docs/multithreading/workers/node/README.md +27 -1
- package/docs/multithreading/workers/node/index.html +20 -3
- package/docs/neat/README.md +8569 -756
- package/docs/neat/index.html +5521 -624
- package/docs/src/README.md +133 -321
- package/docs/src/index.html +123 -182
- package/docs/utils/README.md +11 -26
- package/docs/utils/index.html +9 -27
- package/eslint.config.mjs +57 -0
- package/package.json +9 -1
- package/plans/ES2023 migration +40 -176
- package/plans/HyperMorphoNEAT.md +360 -578
- package/plans/Memory_Optimization.md +4 -3
- package/src/README.md +133 -321
- package/src/architecture/README.md +85 -168
- package/src/architecture/activationArrayPool.ts +5 -1
- package/src/architecture/architect.ts +24 -21
- package/src/architecture/connection.ts +71 -31
- package/src/architecture/group.ts +44 -31
- package/src/architecture/layer.ts +95 -72
- package/src/architecture/network/README.md +161 -366
- package/src/architecture/network/network.activate.ts +37 -23
- package/src/architecture/network/network.connect.ts +18 -7
- package/src/architecture/network/network.deterministic.ts +32 -11
- package/src/architecture/network/network.evolve.ts +157 -62
- package/src/architecture/network/network.gating.ts +17 -4
- package/src/architecture/network/network.genetic.ts +107 -72
- package/src/architecture/network/network.mutate.ts +120 -70
- package/src/architecture/network/network.onnx.ts +399 -269
- package/src/architecture/network/network.prune.ts +44 -22
- package/src/architecture/network/network.remove.ts +21 -10
- package/src/architecture/network/network.serialize.ts +222 -104
- package/src/architecture/network/network.slab.ts +245 -91
- package/src/architecture/network/network.standalone.ts +61 -34
- package/src/architecture/network/network.stats.ts +20 -5
- package/src/architecture/network/network.topology.ts +16 -4
- package/src/architecture/network/network.training.ts +302 -144
- package/src/architecture/network.ts +193 -106
- package/src/architecture/node.ts +96 -64
- package/src/architecture/nodePool.ts +35 -43
- package/src/methods/README.md +4 -6
- package/src/methods/activation.ts +8 -4
- package/src/methods/cost.ts +3 -3
- package/src/methods/mutation.ts +63 -29
- package/src/methods/rate.ts +11 -9
- package/src/multithreading/README.md +21 -5
- package/src/multithreading/multi.ts +31 -23
- package/src/multithreading/types.ts +20 -0
- package/src/multithreading/workers/README.md +2 -2
- package/src/multithreading/workers/browser/README.md +10 -2
- package/src/multithreading/workers/browser/testworker.ts +22 -8
- package/src/multithreading/workers/node/README.md +27 -1
- package/src/multithreading/workers/node/testworker.ts +36 -19
- package/src/multithreading/workers/node/worker.ts +36 -28
- package/src/multithreading/workers/workers.ts +8 -4
- package/src/neat/README.md +8569 -756
- package/src/neat/neat.adaptive.ts +158 -373
- package/src/neat/neat.adaptive.utils.ts +1553 -0
- package/src/neat/neat.compat.ts +46 -107
- package/src/neat/neat.compat.utils.ts +278 -0
- package/src/neat/neat.diversity.ts +18 -178
- package/src/neat/neat.diversity.utils.ts +359 -0
- package/src/neat/neat.evaluate.auto-distance.utils.ts +210 -0
- package/src/neat/neat.evaluate.constants.utils.ts +42 -0
- package/src/neat/neat.evaluate.entropy-compat.utils.ts +67 -0
- package/src/neat/neat.evaluate.entropy-sharing.utils.ts +78 -0
- package/src/neat/neat.evaluate.fitness.utils.ts +48 -0
- package/src/neat/neat.evaluate.novelty.utils.ts +225 -0
- package/src/neat/neat.evaluate.objectives.utils.ts +50 -0
- package/src/neat/neat.evaluate.speciation.utils.ts +35 -0
- package/src/neat/neat.evaluate.ts +46 -300
- package/src/neat/neat.evaluate.types.utils.ts +198 -0
- package/src/neat/neat.evaluate.utils.ts +9 -0
- package/src/neat/neat.evolve.adaptive.utils.ts +224 -0
- package/src/neat/neat.evolve.objectives.utils.ts +241 -0
- package/src/neat/neat.evolve.population.utils.ts +513 -0
- package/src/neat/neat.evolve.runtime.utils.ts +128 -0
- package/src/neat/neat.evolve.speciation.utils.ts +251 -0
- package/src/neat/neat.evolve.telemetry.utils.ts +39 -0
- package/src/neat/neat.evolve.ts +241 -988
- package/src/neat/neat.evolve.types.ts +320 -0
- package/src/neat/neat.evolve.utils.ts +7 -0
- package/src/neat/neat.export.ts +98 -39
- package/src/neat/neat.harness.types.ts +35 -0
- package/src/neat/neat.helpers.ts +119 -54
- package/src/neat/neat.lineage.ts +46 -131
- package/src/neat/neat.lineage.utils.ts +387 -0
- package/src/neat/neat.multiobjective.archive.utils.ts +59 -0
- package/src/neat/neat.multiobjective.category.utils.ts +335 -0
- package/src/neat/neat.multiobjective.crowding.utils.ts +512 -0
- package/src/neat/neat.multiobjective.dominance.utils.ts +403 -0
- package/src/neat/neat.multiobjective.fronts.utils.ts +177 -0
- package/src/neat/neat.multiobjective.objectives.utils.ts +75 -0
- package/src/neat/neat.multiobjective.ts +33 -200
- package/src/neat/neat.multiobjective.types.utils.ts +112 -0
- package/src/neat/neat.multiobjective.utils.ts +9 -0
- package/src/neat/neat.mutation.add-conn.utils.ts +278 -0
- package/src/neat/neat.mutation.add-node.utils.ts +309 -0
- package/src/neat/neat.mutation.dead-ends.utils.ts +229 -0
- package/src/neat/neat.mutation.flow.utils.ts +355 -0
- package/src/neat/neat.mutation.min-hidden.utils.ts +281 -0
- package/src/neat/neat.mutation.select.utils.ts +347 -0
- package/src/neat/neat.mutation.ts +211 -596
- package/src/neat/neat.mutation.types.ts +193 -0
- package/src/neat/neat.mutation.utils.ts +6 -0
- package/src/neat/neat.objectives.ts +36 -63
- package/src/neat/neat.objectives.utils.ts +195 -0
- package/src/neat/neat.pruning.ts +79 -141
- package/src/neat/neat.pruning.utils.ts +375 -0
- package/src/neat/neat.selection.ts +53 -180
- package/src/neat/neat.selection.utils.ts +470 -0
- package/src/neat/neat.speciation.ts +108 -432
- package/src/neat/neat.speciation.utils.ts +926 -0
- package/src/neat/neat.species.ts +34 -73
- package/src/neat/neat.species.utils.ts +156 -0
- package/src/neat/neat.telemetry.buffer.utils.ts +58 -0
- package/src/neat/neat.telemetry.complexity.utils.ts +250 -0
- package/src/neat/neat.telemetry.diversity.utils.ts +214 -0
- package/src/neat/neat.telemetry.entropy.utils.ts +111 -0
- package/src/neat/neat.telemetry.exports.ts +205 -222
- package/src/neat/neat.telemetry.exports.utils.ts +428 -0
- package/src/neat/neat.telemetry.lineage.utils.ts +359 -0
- package/src/neat/neat.telemetry.objectives.utils.ts +216 -0
- package/src/neat/neat.telemetry.operator.utils.ts +20 -0
- package/src/neat/neat.telemetry.performance.utils.ts +30 -0
- package/src/neat/neat.telemetry.rng.utils.ts +22 -0
- package/src/neat/neat.telemetry.selection.utils.ts +108 -0
- package/src/neat/neat.telemetry.ts +351 -794
- package/src/neat/neat.telemetry.types.ts +51 -0
- package/src/neat/neat.telemetry.utils.ts +11 -0
- package/src/neat/neat.types.ts +582 -35
- package/src/neat.ts +142 -96
- package/src/utils/README.md +11 -26
- package/src/utils/memory.ts +143 -73
- package/srcLint.md +185 -0
- package/test/architecture/activationArrayPool.capacity.test.ts +15 -4
- package/test/architecture/activationArrayPool.test.ts +2 -2
- package/test/architecture/connection.test.ts +16 -5
- package/test/architecture/group.test.ts +51 -37
- package/test/architecture/layer.test.ts +173 -103
- package/test/architecture/node.test.ts +53 -47
- package/test/benchmarks/benchmark.browser.headless.test.ts +62 -23
- package/test/benchmarks/benchmark.buildVariants.test.ts +4 -4
- package/test/benchmarks/benchmark.fieldAudit.test.ts +26 -7
- package/test/benchmarks/benchmark.memory.test.ts +191 -78
- package/test/benchmarks/benchmark.nodePool.determinism.test.ts +9 -2
- package/test/benchmarks/benchmark.nodePool.memory.test.ts +9 -2
- package/test/benchmarks/benchmark.nodePool.removeRelease.test.ts +10 -2
- package/test/benchmarks/benchmark.nodePool.stress.test.ts +5 -4
- package/test/benchmarks/benchmark.report.test.ts +7 -7
- package/test/benchmarks/benchmark.serialization.gater.test.ts +56 -16
- package/test/benchmarks/benchmark.slab.fragmentation.bounds.test.ts +13 -4
- package/test/benchmarks/benchmark.slab.fragmentation.trend.test.ts +17 -7
- package/test/benchmarks/benchmark.variance.escalation.test.ts +12 -1
- package/test/benchmarks/benchmark.variance.test.ts +25 -4
- package/test/examples/asciiMaze/asciiMaze.e2e.test.ts +6 -85
- package/test/examples/asciiMaze/asciiMaze.ts +0 -10
- package/test/examples/asciiMaze/browser-entry.ts +115 -43
- package/test/examples/asciiMaze/browserLogger.ts +32 -19
- package/test/examples/asciiMaze/browserTerminalUtility.ts +1 -1
- package/test/examples/asciiMaze/dashboardManager.ts +311 -169
- package/test/examples/asciiMaze/evolutionEngine/engineState.ts +807 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionLoop.ts +1722 -0
- package/test/examples/asciiMaze/evolutionEngine/neatConfiguration.ts +309 -0
- package/test/examples/asciiMaze/evolutionEngine/networkInspection.ts +434 -0
- package/test/examples/asciiMaze/evolutionEngine/optionsAndSetup.ts +433 -0
- package/test/examples/asciiMaze/evolutionEngine/populationDynamics.ts +1696 -0
- package/test/examples/asciiMaze/evolutionEngine/populationPruning.ts +670 -0
- package/test/examples/asciiMaze/evolutionEngine/rngAndTiming.ts +145 -0
- package/test/examples/asciiMaze/evolutionEngine/sampling.ts +299 -0
- package/test/examples/asciiMaze/evolutionEngine/scratchPools.ts +445 -0
- package/test/examples/asciiMaze/evolutionEngine/setupHelpers.ts +283 -0
- package/test/examples/asciiMaze/evolutionEngine/telemetryMetrics.ts +1625 -0
- package/test/examples/asciiMaze/evolutionEngine/trainingWarmStart.ts +617 -0
- package/test/examples/asciiMaze/evolutionEngine.ts +383 -8432
- package/test/examples/asciiMaze/fitness.ts +7 -7
- package/test/examples/asciiMaze/interfaces.ts +454 -9
- package/test/examples/asciiMaze/mazeMovement.ts +166 -150
- package/test/examples/asciiMaze/mazeUtils.ts +30 -46
- package/test/examples/asciiMaze/mazeVision.ts +7 -7
- package/test/examples/asciiMaze/mazeVisualization.ts +54 -51
- package/test/examples/asciiMaze/mazes.ts +42 -63
- package/test/examples/asciiMaze/networkRefinement.ts +35 -24
- package/test/examples/asciiMaze/networkVisualization.ts +354 -178
- package/test/examples/asciiMaze/refineWinner.ts +4 -4
- package/test/examples/asciiMaze/terminalUtility.ts +1 -1
- package/test/methods/activation.test.ts +17 -78
- package/test/methods/connection.test.ts +4 -3
- package/test/methods/cost.test.ts +3 -3
- package/test/methods/crossover.test.ts +6 -2
- package/test/methods/gating.test.ts +9 -3
- package/test/methods/mutation.test.ts +11 -8
- package/test/methods/optimizers.advanced.test.ts +15 -7
- package/test/methods/optimizers.behavior.test.ts +25 -16
- package/test/methods/optimizers.formula.test.ts +68 -48
- package/test/methods/selection.test.ts +1 -1
- package/test/multithreading/activations.functions.test.ts +3 -2
- package/test/multithreading/multi.test.ts +56 -37
- package/test/multithreading/worker.node.process.test.ts +3 -3
- package/test/multithreading/workers.coverage.test.ts +21 -13
- package/test/neat/{neat.adaptive.ancestorUniq.cooldown.skip.test.ts → neat.adaptive.ancestorUniq.cooldown.test.ts} +16 -7
- package/test/neat/neat.adaptive.ancestorUniq.epsilon.test.ts +39 -10
- package/test/neat/neat.adaptive.ancestorUniq.lineagePressure.test.ts +39 -10
- package/test/neat/neat.adaptive.complexityBudget.connShrink.test.ts +7 -5
- package/test/neat/neat.adaptive.complexityBudget.growth.novelty.test.ts +7 -5
- package/test/neat/neat.adaptive.complexityBudget.minClamp.test.ts +3 -3
- package/test/neat/neat.adaptive.complexityBudget.test.ts +4 -2
- package/test/neat/neat.adaptive.complexityBudget.trend.test.ts +5 -7
- package/test/neat/neat.adaptive.criterion.complexity.test.ts +13 -8
- package/test/neat/neat.adaptive.minimalCriterion.rejection.test.ts +8 -4
- package/test/neat/neat.adaptive.mutation.amount.adapt.test.ts +12 -7
- package/test/neat/neat.adaptive.mutation.anneal.strategy.test.ts +9 -7
- package/test/neat/neat.adaptive.mutation.exploreLow.strategy.test.ts +9 -7
- package/test/neat/neat.adaptive.mutation.strategy.test.ts +12 -5
- package/test/neat/neat.adaptive.mutation.twotier.balance.test.ts +8 -4
- package/test/neat/neat.adaptive.mutation.twotier.fallback.single.test.ts +6 -4
- package/test/neat/neat.adaptive.operator.adaptation.decay.balance.test.ts +14 -11
- package/test/neat/neat.adaptive.operator.bandit.decay.test.ts +5 -5
- package/test/neat/neat.adaptive.operator.decay.test.ts +4 -2
- package/test/neat/neat.adaptive.phasedComplexity.test.ts +5 -3
- package/test/neat/neat.adaptive.phasedComplexity.toggle.test.ts +5 -5
- package/test/neat/neat.adaptive.pruning.test.ts +5 -2
- package/test/neat/neat.additional.coverage.test.ts +43 -23
- package/test/neat/neat.advanced.enhancements.test.ts +2 -2
- package/test/neat/neat.advanced.test.ts +36 -19
- package/test/neat/neat.compat.distance.cache.test.ts +21 -7
- package/test/neat/neat.diversity.autocompat.test.ts +13 -5
- package/test/neat/neat.diversity.metrics.test.ts +1 -0
- package/test/neat/neat.diversity.stats.test.ts +14 -15
- package/test/neat/neat.enhancements.test.ts +36 -23
- package/test/neat/neat.entropy.ancestorAdaptive.test.ts +54 -29
- package/test/neat/neat.entropy.compat.csv.test.ts +7 -11
- package/test/neat/neat.export.meta.fromjson.test.ts +3 -2
- package/test/neat/neat.export.state.rehydrate.test.ts +8 -7
- package/test/neat/neat.fastmode.autotune.test.ts +10 -6
- package/test/neat/neat.helpers.spawn.pool.test.ts +18 -12
- package/test/neat/neat.innovation.test.ts +123 -44
- package/test/neat/neat.lineage.antibreeding.test.ts +34 -16
- package/test/neat/neat.lineage.buildAnc.window.test.ts +15 -7
- package/test/neat/neat.lineage.entropy.test.ts +36 -24
- package/test/neat/neat.lineage.inbreeding.test.ts +51 -32
- package/test/neat/neat.lineage.pressure.test.ts +10 -4
- package/test/neat/neat.multiobjective.adaptive.test.ts +13 -9
- package/test/neat/neat.multiobjective.dynamic.schedule.test.ts +9 -10
- package/test/neat/neat.multiobjective.dynamic.test.ts +11 -4
- package/test/neat/neat.multiobjective.fastsort.delegation.test.ts +41 -26
- package/test/neat/neat.multiobjective.prune.test.ts +14 -8
- package/test/neat/neat.mutation.addconn.cycle.guard.test.ts +38 -21
- package/test/neat/neat.mutation.undefined.pool.test.ts +10 -4
- package/test/neat/neat.objectives.register.clear.test.ts +14 -6
- package/test/neat/neat.offspring.allocation.test.ts +1 -2
- package/test/neat/neat.operator.bandit.test.ts +1 -1
- package/test/neat/neat.operator.phases.test.ts +18 -6
- package/test/neat/neat.pruneInactive.behavior.test.ts +26 -11
- package/test/neat/neat.pruning.adaptive.test.ts +16 -5
- package/test/neat/neat.reenable.adaptation.test.ts +16 -10
- package/test/neat/neat.rng.state.test.ts +33 -15
- package/test/neat/neat.selection.strategies.test.ts +15 -11
- package/test/neat/neat.spawn.add.test.ts +68 -35
- package/test/neat/neat.speciation.age.penalty.test.ts +63 -33
- package/test/neat/neat.speciation.assign.existing.test.ts +64 -24
- package/test/neat/neat.speciation.auto.tuning.jitter.test.ts +78 -38
- package/test/neat/neat.speciation.create.newSpecies.test.ts +59 -25
- package/test/neat/neat.speciation.fitnessSharing.equal.test.ts +33 -5
- package/test/neat/neat.speciation.fitnessSharing.kernel.test.ts +33 -6
- package/test/neat/neat.speciation.pid.threshold.clip.max.test.ts +68 -29
- package/test/neat/neat.speciation.pid.threshold.clip.min.test.ts +68 -29
- package/test/neat/neat.speciation.stagnation.prune.test.ts +23 -9
- package/test/neat/neat.speciation.test.ts +2 -0
- package/test/neat/neat.species.history.fallbacks.test.ts +59 -14
- package/test/neat/neat.telemetry.advanced.test.ts +124 -64
- package/test/neat/neat.telemetry.csv.lineage.test.ts +12 -7
- package/test/neat/neat.telemetry.fastmode.diversity.test.ts +52 -9
- package/test/neat/neat.telemetry.objective.events.test.ts +64 -13
- package/test/neat/neat.telemetry.parity.test.ts +13 -7
- package/test/neat/neat.telemetry.select.entropy.cache.test.ts +37 -12
- package/test/neat/neat.telemetry.stream.test.ts +10 -2
- package/test/neat/neat.telemetry.test.ts +1 -1
- package/test/neat/neat.test.ts +62 -39
- package/test/neat/neat.utilities.test.ts +37 -19
- package/test/network/acyclic.topoorder.test.ts +4 -4
- package/test/network/checkpoint.metricshook.test.ts +6 -2
- package/test/network/error.handling.test.ts +99 -67
- package/test/network/evolution.test.ts +22 -19
- package/test/network/genetic.test.ts +40 -21
- package/test/network/learning.capability.test.ts +15 -7
- package/test/network/mutation.effects.test.ts +84 -64
- package/test/network/network.activate.test.ts +38 -12
- package/test/network/network.deterministic.test.ts +20 -5
- package/test/network/network.evolve.branches.test.ts +28 -20
- package/test/network/network.evolve.multithread.branches.test.ts +78 -56
- package/test/network/network.evolve.test.ts +47 -25
- package/test/network/network.gating.removal.test.ts +17 -12
- package/test/network/network.mutate.additional.test.ts +6 -5
- package/test/network/network.mutate.edgecases.test.ts +3 -1
- package/test/network/network.mutate.test.ts +4 -2
- package/test/network/network.prune.earlyexit.test.ts +39 -5
- package/test/network/network.pruning.test.ts +1 -1
- package/test/network/network.remove.errors.test.ts +6 -6
- package/test/network/network.slab.alloc.stats.reuse.test.ts +18 -8
- package/test/network/network.slab.async.test.ts +114 -42
- package/test/network/network.slab.capacity.test.ts +47 -37
- package/test/network/network.slab.fallbacks.test.ts +26 -6
- package/test/network/network.slab.fast.gain.parity.test.ts +29 -10
- package/test/network/network.slab.fast.gating.guard.test.ts +26 -11
- package/test/network/network.slab.fast.parity.test.ts +17 -9
- package/test/network/network.slab.flags.test.ts +26 -6
- package/test/network/network.slab.gain.omission.test.ts +29 -9
- package/test/network/network.slab.gain.release-on-reset.test.ts +33 -13
- package/test/network/network.slab.phase3.test.ts +24 -6
- package/test/network/network.slab.plasticity.test.ts +39 -13
- package/test/network/network.slab.versioning.test.ts +24 -4
- package/test/network/network.stats.test.ts +32 -7
- package/test/network/network.training.advanced.test.ts +45 -18
- package/test/network/network.training.basic.test.ts +128 -55
- package/test/network/network.training.helpers.test.ts +20 -17
- package/test/network/onnx.export.test.ts +170 -95
- package/test/network/onnx.recurrent.fused.test.ts +70 -54
- package/test/network/pruning.topology.test.ts +77 -36
- package/test/network/regularization.determinism.test.ts +19 -5
- package/test/network/regularization.dropconnect.validation.test.ts +2 -2
- package/test/network/regularization.stochasticdepth.test.ts +27 -12
- package/test/network/regularization.test.ts +94 -74
- package/test/network/regularization.weightnoise.test.ts +9 -4
- package/test/network/standalone.test.ts +27 -25
- package/test/network/structure.serialization.test.ts +160 -152
- package/test/onnx/onnx.conv.groundwork.test.ts +11 -7
- package/test/onnx/onnx.conv.infer.test.ts +8 -4
- package/test/onnx/onnx.conv.pool.flatten.test.ts +2 -2
- package/test/onnx/onnx.conv.pool.validation.test.ts +30 -20
- package/test/onnx/onnx.export.test.ts +53 -39
- package/test/onnx/onnx.import.test.ts +9 -5
- package/test/onnx/onnx.roundtrip.test.ts +3 -3
- package/test/training/training.determinism.mixed-precision.test.ts +7 -5
- package/test/training/training.earlystopping.test.ts +9 -9
- package/test/training/training.edge-cases.test.ts +24 -8
- package/test/training/training.extensions.test.ts +8 -7
- package/test/training/training.gradient.features.test.ts +7 -5
- package/test/training/training.gradient.refinements.test.ts +13 -5
- package/test/training/training.optimizer.test.ts +13 -2
- package/test/training/training.plateau.smoothing.test.ts +1 -1
- package/test/training/training.smoothing.types.test.ts +16 -12
- package/test/training/training.train.options.coverage.test.ts +1 -1
- package/test/utils/console-helper.ts +12 -8
- package/test/utils/jest-setup.ts +48 -33
- package/test/utils/pollUntil.test.ts +6 -6
- package/test/utils/pollUntil.ts +8 -8
- package/test/utils/test-helpers.ts +25 -20
- package/plans/ASCII_MAZE_enhancements.md +0 -0
|
@@ -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,60 @@ 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
|
+
|
|
90
|
+
8. Local helper structure preference:
|
|
91
|
+
- For new or refactored functions that introduce internal helpers, order the function as:
|
|
92
|
+
1) Local variables/constants at top
|
|
93
|
+
2) Declarative logic (calls to helpers)
|
|
94
|
+
3) Return (fold)
|
|
95
|
+
4) Internal helper function declarations at the end of the parent function
|
|
96
|
+
- Helpers should be small and pure where practical, with step-level inline comments and JSDoc.
|
|
97
|
+
|
|
98
|
+
9. Mandatory implementation pattern (always; keep cognitive complexity low):
|
|
99
|
+
- Applies to all new code and any modified/refactored code in `src/` and `test/`.
|
|
100
|
+
- Prefer a *declarative top-level flow* ("collect → transform → fold/return") over deeply nested control flow.
|
|
101
|
+
- Avoid ternary chains (especially nested) for multi-branch fallback logic; use named resolver helpers with early returns instead.
|
|
102
|
+
- When normalizing legacy/loose data, isolate type assertions/casting into a single helper and keep the rest strongly typed.
|
|
103
|
+
- Keep helpers after the fold, and give each helper a single responsibility (SOLID: SRP). If the logic reads like a decision tree, it likely wants 2–4 small helpers.
|
|
104
|
+
|
|
105
|
+
Example (ideal structure)
|
|
106
|
+
-------------------------
|
|
107
|
+
```ts
|
|
108
|
+
export function exampleMethod(input: Input) {
|
|
109
|
+
const constants = /* ... */;
|
|
110
|
+
const locals = /* ... */;
|
|
111
|
+
|
|
112
|
+
if (/* guard */) return /* fold */;
|
|
113
|
+
|
|
114
|
+
const stepOne = helperOne(input, locals, constants);
|
|
115
|
+
const stepTwo = helperTwo(stepOne, locals, constants);
|
|
116
|
+
return helperThree(stepTwo, locals, constants);
|
|
117
|
+
|
|
118
|
+
/** @param value - Input. @returns Intermediate. */
|
|
119
|
+
function helperOne(value: Input, _locals: unknown, _constants: unknown): Intermediate {
|
|
120
|
+
// Step 1: ...
|
|
121
|
+
return /* ... */;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** @param value - Intermediate. @returns Intermediate. */
|
|
125
|
+
function helperTwo(value: Intermediate, _locals: unknown, _constants: unknown): Intermediate {
|
|
126
|
+
// Step 1: ...
|
|
127
|
+
return /* ... */;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** @param value - Intermediate. @returns Output. */
|
|
131
|
+
function helperThree(value: Intermediate, _locals: unknown, _constants: unknown): Output {
|
|
132
|
+
// Step 1: Fold/return.
|
|
133
|
+
return /* ... */;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type Input = unknown;
|
|
138
|
+
type Intermediate = unknown;
|
|
139
|
+
type Output = unknown;
|
|
140
|
+
```
|
|
141
|
+
|
|
29
142
|
Automated validations to run before finalizing a suggestion
|
|
30
143
|
-------------------------------------------------------
|
|
31
144
|
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 +156,9 @@ When you modify or create files under `src/` or `test/`, run (or advise running)
|
|
|
43
156
|
Quick checks to run (recommended)
|
|
44
157
|
--------------------------------
|
|
45
158
|
- 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
159
|
- Tests heuristic: flag test files that contain more than one `expect(` occurrence (these should be split into multiple `it()` blocks).
|
|
48
160
|
- JSDoc: for new exported symbols, ensure a JSDoc block with `@param`/`@returns` exists (or flag if missing).
|
|
161
|
+
- ES2023 modernization: flag legacy patterns and suggest modern equivalents (see below one-liners).
|
|
49
162
|
|
|
50
163
|
PowerShell examples (local validation)
|
|
51
164
|
-------------------------------------
|
|
@@ -54,23 +167,18 @@ When you modify or create files under `src/` or `test/`, run (or advise running)
|
|
|
54
167
|
npx tsc --noEmit -p tsconfig.json
|
|
55
168
|
```
|
|
56
169
|
|
|
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
170
|
What to include with a suggestion
|
|
71
171
|
--------------------------------
|
|
72
172
|
- A short validation summary (TypeScript: pass/fail, short-id matches: list or 0, test-expect heuristic: list or 0, JSDoc missing: list or 0).
|
|
173
|
+
- 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
174
|
- 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
175
|
|
|
75
|
-
|
|
176
|
+
Test failure workflow
|
|
177
|
+
---------------------
|
|
178
|
+
When fixing multiple test failures:
|
|
179
|
+
1. Create/update a comprehensive plan document (e.g., `plans/TestsFix.md`)
|
|
180
|
+
2. Apply ALL fixes systematically without running tests
|
|
181
|
+
3. Validate TypeScript compilation with `npx tsc --noEmit -p tsconfig.test.json`
|
|
182
|
+
4. ONLY run `npm test` after all planned fixes are complete
|
|
183
|
+
5. Analyze results and iterate on remaining issues
|
|
76
184
|
|
package/.prettierrc.json
ADDED