mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-04-28 04:20:38 +00:00
3be799d68a
Followed code-reviewer audit. Findings applied: - twentyq/README.md, twentyq/index.js header — claimed "function calling" + ANSWER_FUNCTION_SCHEMA / submit_answer; rewrite to JSON-in-content matching what the code actually does. Added generateRoundStart line. - wrangler.toml [ai] comment — list both bge-m3 (semantle/doantu) AND gemma-4 (twentyq) consumers; drop neuron math that no longer matched. - scripts/stub-kv.js — drop reference to nonexistent REGISTER_DRYRUN flag. - twentyq/ai-client.redactSecret — strip dead "if (out.length > 0)" branch (String.replace cannot produce empty string from the inputs we pass). - handlers.test.js — drop noise saveGame() before "no games" stats assert; add ai.run call-count guards on two-AI-call flows. - docs/codebase-summary.md — full rewrite of Active Modules table (semantle/doantu/lolschedule/twentyq were missing); fix vitest 2→4 + wrangler 3→4 versions; replace stale 200-test count with current ~450. - docs/architecture.md — file tree includes lolschedule/semantle/doantu/ twentyq + cron-dispatcher + sql-store* + scripts/migrate.js; moduleRegistry snippet matches src/modules/index.js. - docs/todo.md — entire file obsolete (D1 UUID populated, cron live). Deleted. Tests: 449 pass, lint clean.
47 lines
1.2 KiB
JavaScript
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: [] };
|
|
},
|
|
};
|