Remove stepCount/stepSize; patterns own their geometry

The stepCount and stepSize knobs were two controls for one quantity users
actually care about (reach), and the number of steps is an implementation
detail nobody meaningfully tunes. Each pattern has a natural size and
resolution — a jitter is inherently small, an arc a broad curve — so those
now live as constants in each strategy rather than as global config.

- strategies.ts: each pattern defines its own step count and size; MoveContext
  drops `config` down to pure geometry (start/width/height/rng), and the
  module no longer imports Config at all (dissolving the type-only-import
  cycle workaround). line stays byte-for-byte: 250 one-pixel steps.
- executor.ts: executePath takes `config` for pacing (stepDelay); the path
  itself needs nothing from it.
- config.ts / cli.ts / move.ts / config.default.json: drop stepCount and
  stepSize from the type, seed, validation, resolver, CLI flags (-n, -s),
  and help. stepDelay stays as the one pacing lever.
- configFile.ts: tolerate the removed keys instead of rejecting them — every
  pre-1.3.0 install seeded stepCount, so a hard "unknown key" failure on
  upgrade is avoided. They're ignored with a one-line stderr notice; genuine
  unknown keys still error.

The -n/--step-count CLI flag (shipped since 1.0.0) is now an unknown option;
config files degrade gracefully, command lines don't. Stays in the unpushed
1.3.0 release. 64 tests pass.
This commit is contained in:
2026-08-14 12:56:22 -05:00
parent db3310c247
commit ec33648e74
15 changed files with 233 additions and 224 deletions
+5 -20
View File
@@ -27,8 +27,8 @@ import { isPatternName, type PatternName } from "./strategies.ts";
// Single source of truth for default values. The same file ships in the
// install tree and is copied to $XDG_CONFIG_HOME/move/config.json on a
// fresh install (only if no config exists there yet). Values use the CLI
// units (seconds for time fields, ms for stepDelay, pixels for stepCount);
// the seconds->ms conversion happens below where DEFAULT_CONFIG is built.
// units (seconds for time fields, ms for stepDelay); the seconds->ms
// conversion happens below where DEFAULT_CONFIG is built.
import seedRaw from "../scripts/config.default.json" with { type: "json" };
/**
@@ -42,12 +42,9 @@ import seedRaw from "../scripts/config.default.json" with { type: "json" };
* - `stepDelay` — pause between individual synthetic mouse steps inside
* a sweep. Also the window in which the user can
* "interrupt" by moving the cursor. Milliseconds.
* - `stepCount` — number of steps in a single sweep. Count.
* - `stepSize` — pixels moved per step. Decouples "how many steps"
* from "how far each step travels" so non-linear
* patterns can span meaningful distances. Pixels.
* - `pattern` — name of the movement strategy to use (see
* `strategies.ts`; e.g. `line`, `walk`, `arc`).
* `strategies.ts`; e.g. `line`, `walk`, `arc`). Each
* pattern owns its own size and step count.
* - `verbose` — whether per-sweep / interrupt / bounds events are
* logged. The startup banner is always printed.
*/
@@ -55,8 +52,6 @@ export interface Config {
readonly moveInterval: number;
readonly checkInterval: number;
readonly stepDelay: number;
readonly stepCount: number;
readonly stepSize: number;
readonly pattern: PatternName;
readonly verbose: boolean;
}
@@ -71,8 +66,6 @@ interface SeedShape {
moveInterval: number; // seconds
checkInterval: number; // seconds
stepDelay: number; // milliseconds
stepCount: number; // count
stepSize: number; // pixels
pattern: string; // strategy name
verbose: boolean;
}
@@ -82,7 +75,7 @@ function assertSeedShape(raw: unknown): asserts raw is SeedShape {
throw new Error("scripts/config.default.json: root must be an object");
}
const r = raw as Record<string, unknown>;
for (const key of ["moveInterval", "checkInterval", "stepDelay", "stepCount", "stepSize"] as const) {
for (const key of ["moveInterval", "checkInterval", "stepDelay"] as const) {
const v = r[key];
if (typeof v !== "number" || !Number.isFinite(v) || v <= 0) {
throw new Error(`scripts/config.default.json: '${key}' must be a positive finite number (got ${JSON.stringify(v)})`);
@@ -110,8 +103,6 @@ export const DEFAULT_CONFIG: Config = {
moveInterval: seed.moveInterval * 1000,
checkInterval: seed.checkInterval * 1000,
stepDelay: seed.stepDelay,
stepCount: seed.stepCount,
stepSize: seed.stepSize,
pattern: seed.pattern,
verbose: seed.verbose,
};
@@ -125,8 +116,6 @@ export const DEFAULT_CONFIG: Config = {
* Numeric fields are in CLI / config-file units:
* moveInterval, checkInterval — seconds
* stepDelay — milliseconds
* stepCount — count
* stepSize — pixels
*
* `pattern` is a strategy name (`string | undefined`) and `verbose` is
* `boolean | undefined`, so every field shares the same "first defined
@@ -142,8 +131,6 @@ export interface ConfigOverrides {
readonly moveInterval: number | undefined;
readonly checkInterval: number | undefined;
readonly stepDelay: number | undefined;
readonly stepCount: number | undefined;
readonly stepSize: number | undefined;
readonly pattern: string | undefined;
readonly verbose: boolean | undefined;
}
@@ -210,8 +197,6 @@ export function resolveConfig(file: ConfigOverrides | null, cli: ConfigOverrides
moveInterval: pickSeconds(cli.moveInterval, file?.moveInterval, DEFAULT_CONFIG.moveInterval),
checkInterval: pickSeconds(cli.checkInterval, file?.checkInterval, DEFAULT_CONFIG.checkInterval),
stepDelay: pickRaw(cli.stepDelay, file?.stepDelay, DEFAULT_CONFIG.stepDelay),
stepCount: pickRaw(cli.stepCount, file?.stepCount, DEFAULT_CONFIG.stepCount),
stepSize: pickRaw(cli.stepSize, file?.stepSize, DEFAULT_CONFIG.stepSize),
pattern: pickRaw(cli.pattern, file?.pattern, DEFAULT_CONFIG.pattern),
verbose: pickRaw(cli.verbose, file?.verbose, DEFAULT_CONFIG.verbose),
};