Fill a lesson's Reword boxes with the words Ask for suggestions sends

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-29 10:49:42 -08:00
1 parent e0f82cc36b
commit 834b71e82d
7 files changed
+143 -7

No files matched your search

+17 -3
View File
@@ -872,6 +872,8 @@ export const ITEM_KINDS = new Set([
export const LESSON_ROW_TYPES = ["lesson", "doubt", "gone", "agents-fix", "tidy", "log-line", "area"];
const LESSON_ROW_TEXT = ["why", "kind", "area", "origin", "note", "before", "after", "found", "heading", "file", "name", "change", "wording", "wordingWhy"];
const LESSON_ROW_LISTS = ["about", "areas", "flags", "lessons", "paths", "targets"];
// The choices that open a row for editing: only these take suggested words.
const SUGGESTED_EDIT_WORDS = new Set(["Reword", "Reword and move", "Rename"]);
const LESSONS_RIGHT = {
kind: "lessons",
rows: [{ id: "w1", type: "lesson", text: "Run a page test with node scripts/node-test.mjs <file>.", choices: ["Keep", "Reword", "Drop"] }],
@@ -986,18 +988,30 @@ function lessonsProblems(item, at) {
});
if (item.checked != null) problems.push(...lessonsCheckedProblems(item.checked, at));
// The agent's answer to Ask for suggestions, readable by the page: row id to
// one of that row's own choice words. It outlines a button; it never picks.
// one of that row's own choice words, or { choice, text?, why? } where the
// choice opens an edit and the words are what its boxes start on. It
// outlines a button; it never picks.
const sug = item.suggested;
const SUGGESTED_RIGHT = { suggested: { w1: "Keep", w2: "Drop" } };
const SUGGESTED_RIGHT = { suggested: { w1: "Keep", w2: { choice: "Reword", text: "The new words.", why: "Why it matters." } } };
if (sug != null && !isPlainObject(sug)) {
problems.push(rule(at, "suggested", "must be an object of row id to one of that row's choice words, or null", SUGGESTED_RIGHT));
} else if (sug != null) {
const byId = new Map((hasRows ? item.rows : []).filter(isPlainObject).map((r) => [r.id, r]));
for (const [id, word] of Object.entries(sug)) {
for (const [id, given] of Object.entries(sug)) {
const row = byId.get(id);
const word = isPlainObject(given) ? given.choice : given;
if (!row) problems.push(rule(at, `suggested "${id}"`, "names no row on this card. Use the row ids the card was posted with", SUGGESTED_RIGHT));
else if (typeof word !== "string" || !(row.choices || []).includes(word)) {
problems.push(rule(at, `suggested "${id}"`, `must be one of that row's choices (${(row.choices || []).join(", ")})`, SUGGESTED_RIGHT));
} else if (isPlainObject(given)) {
for (const key of Object.keys(given)) {
if (!["choice", "text", "why"].includes(key)) problems.push(rule(at, `suggested "${id}" ${key}`, "is not allowed: a suggestion takes choice, text and why only", SUGGESTED_RIGHT));
}
for (const key of ["text", "why"]) {
if (given[key] == null) continue;
if (!SUGGESTED_EDIT_WORDS.has(word)) problems.push(rule(at, `suggested "${id}" ${key}`, `goes only with a choice that opens an edit (${[...SUGGESTED_EDIT_WORDS].join(", ")}). Leave it out`, SUGGESTED_RIGHT));
else if (typeof given[key] !== "string" || !given[key].trim()) problems.push(rule(at, `suggested "${id}" ${key}`, "must be a non-empty string, or left out", SUGGESTED_RIGHT));
}
}
}
}