hex/ios/TypingConfig/package/scripts/overview.py
Ryan Vogel 17407ee391 ios: the typing-config agent package (words and key positions), and the export's layout state
ios/TypingConfig/package/ is what an export carries besides the logs: SKILL.md, reference/ and
scripts/ (Python 3 standard library, no network). From it alone, a stranger's agent can build a
format-0 .mhexconfig and check it before handing it back.
- SKILL.md tells the agent:
  - what Hex already learns by itself;
  - rules: the text stays in the folder, single words only, every value from a script, tune on
    half A and check on half B, never write an unsimulated zone, less is better;
  - steps from overview to report.
- reference/:
  - typing-config.md, the frozen format;
  - state.md, the export's state/ (phone.json, including layout, and vocabulary.json);
  - log-format.md and typing-config.schema.json, both generated.
- scripts/, key positions:
  - taps.py lines every tap up with the letter or space it was meant for and maps it onto
    today's keys;
  - key_clouds.py shows per-key landing clouds by the letter meant, beside Hex's pressed-key
    average, with aim candidates;
  - zone_edges.py lists every movable edge with the taps that fell just across it;
  - simulate_zones.py says which key every tap would press under proposed zones (with --sweep).
    geometry.py ports KeyboardZoneMap line for line, so the scripts press what the phone would;
  - simulate_aim.py is the touch-model approximation for aim.
- scripts/, the checker: check_config.py re-runs both simulations on the halves the config names
  and rejects any aim or zone whose evidence doesn't match exactly. It also recounts words,
  checks ranges, context and envelope, and fills in the id.
- scripts/, the study's tools: word_outcomes.py (now with session counts and a
  never-correct-to list), words, hexlog, overview, split, space_edges, timings, dictation.
- TypingConfigExportState.layout(_:) gives the phone lane's state writer today's keyboard:
  context, keycap size, touch area, and every key's frame, hitFrame and gapHitFrame.
- build-typing-config.py also writes the package's copies of the schema and of
  docs/typing-logs.md, and --check covers them.

Verified: seven fresh agents (opencode/claude-opus-5-5, told only "Here is a folder. Follow
SKILL.md in it") each produced a config that check_config.py passes with 0 problems.
- Six worked on synthetic one-fault fixtures typed through the real engine with Record typing
  logs; the seventh on Ryan's day 1 (private).
- They found each planted fault: e aimed 0.4 keycap right (aim e +0.30 and e's right edge
  +0.20: 49 taps gained, 0 lost, on the tuning half), a right hand low, own words, a repeated
  real-word slip, and space taps high.
- Where the rules didn't hold, they left the part out: the space zone failed its check half,
  and the slip is one Learn how I type learns itself. The control got no key positions.
- The phone-side replay of these configs follows.
python3 -m py_compile passes for all scripts, and build-typing-config.py --check passes.
2026-11-23 12:47:08 -05:00

55 lines
2.8 KiB
Python

"""What is in the export: days, phone, Hex builds, settings, layouts, sessions, words, and
what the phone had already learned (state/phone.json). Run this first.
python3 scripts/overview.py [EXPORT_DIR]
"""
import json, os, sys, collections
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import hexlog, words as W
ex = hexlog.export_dir(sys.argv[1:])
files = hexlog.files_in(ex)
c = collections.Counter(); builds = collections.Counter(); settings = {}; phones = collections.Counter()
layouts = collections.Counter(); kinds = collections.Counter(); dur = 0.0; taps = 0
for f in files:
for line in open(f, encoding="utf-8"):
e = json.loads(line)
c[e["type"]] += 1
if e["type"] == "session_start":
builds[(e.get("version"), e.get("build"), e.get("surface"))] += 1
phones[(e.get("device"), e.get("system"), e.get("orientation"))] += 1
settings[(e.get("version"), e.get("build"))] = e.get("settings")
kinds[(e.get("traits") or {}).get("keyboardType")] += 1
elif e["type"] == "layout" and "keys" in e:
layouts[(e.get("width"), e.get("height"), e.get("language"), e.get("letters"), e.get("layer"), e.get("hexPlacement"))] += 1
elif e["type"] == "session_end":
dur += (e.get("durationMS") or 0) / 1000
elif e["type"] == "touch" and e.get("phase") == "began":
taps += 1
print("export:", ex)
print("log files:", ", ".join(os.path.basename(f) for f in files))
print("events:", dict(c.most_common()))
print("phone, system, orientation (sessions):", dict(phones))
print("Hex version, build, surface (sessions):", {"%s (%s) %s" % k: n for k, n in builds.items()})
for k, s in settings.items():
print("settings on %s (%s):" % k, json.dumps(s, sort_keys=True))
print("field keyboard types (sessions):", dict(kinds))
print("distinct key layouts (width, height, language, letters, layer, Hex key):")
for k, n in layouts.most_common():
print(" ", k, n)
print("keyboard on screen: %.1f min; touches: %d" % (dur / 60, taps))
words, LAY, sessions = W.load(ex)
by = collections.Counter(cl for w in words for cl in w["cls"])
sc = [w for w in words if W.scorable(w)]
print("words: %d; scorable (meaning known, Hex decided): %d; halves A/B: %d/%d" % (
len(words), len(sc), sum(w["half"] == "A" for w in sc), sum(w["half"] == "B" for w in sc)))
print("word classes:", dict(by.most_common()))
sp = os.path.join(ex, "state", "phone.json")
if os.path.exists(sp):
st = json.load(open(sp))
print("\nstate/phone.json (what Hex had learned when the export was made):")
for k, v in st.items():
s = json.dumps(v, ensure_ascii=False)
print(" %s: %s" % (k, s if len(s) < 300 else s[:300] + "…"))
else:
print("\nno state/phone.json: you can't tell what Hex already learned; say so in the report")