Files
miti99bot/scripts/stub-kv.js
T
tiennm99 b52fa7094e feat(loldle): tunable max guesses per subject + retuned defaults
Drop classic loldle from 8 → 6 (7-axis grid leaks too much per guess for 8
to feel earned) and emoji from 5 → 4 (3 emojis are usually unmistakable).
Add a hidden /<module>_setmax <n> command per loldle module so a chat can
override its own round length (1-10). Override stored at config:<subject>
in each module's KV; getMaxGuesses() falls back to the default when unset.
2026-05-07 14:10:01 +07:00

47 lines
1.2 KiB
JavaScript

/**
* @file stub-kv — no-op binding stubs used by scripts/register.js.
*
* The register script imports buildRegistry() to derive the public command
* list at deploy time. Module init hooks in this codebase dereference
* runtime bindings like `env.KV` (via createStore) and `env.AI` (semantle).
* These stubs satisfy the shape without doing any real IO. All init hooks
* are assumed read-only (or tolerant of missing state) at registration time.
* If a future module writes inside init(), update the matching stub to
* swallow writes safely.
*/
/** @type {KVNamespace} */
export const stubKv = {
async get() {
return null;
},
async put() {
// no-op
},
async delete() {
// no-op
},
async list() {
return {
keys: [],
list_complete: true,
cursor: undefined,
};
},
// getWithMetadata is part of the KVNamespace type but unused by CFKVStore
// — provide a stub so duck-typing doesn't trip.
async getWithMetadata() {
return { value: null, metadata: null };
},
};
/**
* Workers AI binding stub. Semantle's init() wires `createClient(env.AI)`
* which only type-checks `.run` — no inference ever fires during register.
*/
export const stubAi = {
async run() {
return { data: [] };
},
};