[rust] T6-1: CODE verb layer + starter harness in al-sdk (Rust CODE should read like JS CODE, not a graphics driver) #37
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The JS CODE starter (see
js/runner_functions.js) ships a tick driver (setInterval(cb, 250)) plus a combat verb layer —loot(),get_nearest_monster({min_xp,max_att}),change_target(t),is_moving(t),is_in_range(t),can_attack(t),use_hp_or_mp(),set_message(s),attack(t)— so a combat loop is ~15 lines of body.The Rust SDK (T3-4 / T5-1) exposes only the wire-level primitives (
walk,attack,nearest_monster,is_in_range,use_hp_or_mp,Snapshot) and no verb layer and no starter harness. Soexamples/hellois ~300 lines of scaffold (connect_env → set_sink → on_death → auto_respawn → on_tick_async → run_for → exit-code table) before a single tick runs, and the predicates force the user to hand-buildRangeInput/AttackInput/MonsterArgsstructs. It reads like writing your own graphics driver to render shapes, not using raylib to draw shapes (sleepy's words).Goal
A convenience layer so a combat/farming loop is ~15-25 lines of user code, and a fresh crate does not re-derive the connect/sink/death/respawn/run/exit scaffold.
Design (guidance, not a mandate)
al-sdk(a newal_sdk::codemodule) so the layering rule holds: a user crate depends only onal-sdk. Do not add a crate user crates must depend on.al_sdk::code::run(|snap| async move {…})or aCode::new().on_tick(…).run()) that doesconnect_env+ stdoutset_sink+on_death+auto_respawn+ the run loop + the exit-code table, and hands the user just the tick body (the async slot, so it canawaitverbs).loot,get_nearest_monster(args) -> Option<Monster>,change_target,is_moving,is_in_range,can_attack,use_hp_or_mp,set_message,walk_to/toward. Keep the existing predicate structs as the implementation; the verbs are the ergonomic front. Scope is the combat/farming core that T5-1 + the starter use — NOT a 1:1 port of banking/crafting/duels/shops (that is T5-2 / later).examples/starter) that a human opens and edits: the harness + a commented combat body, ~30 lines total.Acceptance
examples/helloandexamples/farm_basicare ported onto the harness+verbs (their hand-rolled scaffold collapses to the harness) and still pass their gates.al-sdk); the quality gate (offline + live) is green.File by orchestrator, 2026-09-22. Re-scoped from the /rust-code PoC after sleepy's 'graphics driver vs raylib' feedback.