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

+1 -1
View File
@@ -69,7 +69,7 @@ The seven noting skills (and any skill sent here by Start's Review now) run it b
2. `items` empty and no `firstAsk`: say nothing and skip this step.
3. `firstAsk` present: see The first ask below, instead of 4 to 7.
4. Show `opening` first when present.
5. **On the web console:** post the returned `card` as one `lessons` item with `--wait` (a new `id` when an earlier lessons card is in the session). Its reply has one line per decision ("Keep: ...", "Reword: ...") and a `Decisions:` line holding them as JSON: that JSON is step 6's file, plus what a choice still needs. A `Suggestions wanted on` line for it: reply in its `thread` and, in the same patch, send `suggested` (row id to one of that row's `choices`, such as `{"w1":"Keep"}`), which outlines those buttons without choosing them. **In a terminal:** ask each group in `rounds` with your question tool, one question per item with exactly its `choices` and nothing pre-selected (`heading`, `text`, `why`, `origin` and `note` are what the person reads; an area shows its `name` and `paths`); with no question tool, a numbered list. Show the card's `checked` line first ("Checked 6 lessons in 40 seconds by a fresh helper that could only read", "... by the same agent that noted them", or "The check could not run: <reason>"). Read each item's `check` and `tag` into its text in this order: every Fail, then every Doubt (each as "Fail <test>: <reason>"), then the pass line ("Passed the other N", "Passed the check" with none, and no pass line when all four found something), then its `tag` when present. A `suggestion` is offered as a Reword carrying exactly those words, which the person may adjust. A choice that needs more (step 6) asks the person for it.
5. **On the web console:** post the returned `card` as one `lessons` item with `--wait` (a new `id` when an earlier lessons card is in the session). Its reply has one line per decision ("Keep: ...", "Reword: ...") and a `Decisions:` line holding them as JSON: that JSON is step 6's file, plus what a choice still needs. A `Suggestions wanted on` line for it: reply in its `thread` and, in the same patch, send `suggested` (row id to one of that row's `choices`, such as `{"w1":"Keep"}`), which outlines those buttons without choosing them. A Reword you suggest goes with the words you would use, `{"w2":{"choice":"Reword","text":"<the lesson>","why":"<its reason>"}}` (either may be left out): the page puts them in that row's boxes when its Reword is open, so give the same words in the thread. **In a terminal:** ask each group in `rounds` with your question tool, one question per item with exactly its `choices` and nothing pre-selected (`heading`, `text`, `why`, `origin` and `note` are what the person reads; an area shows its `name` and `paths`); with no question tool, a numbered list. Show the card's `checked` line first ("Checked 6 lessons in 40 seconds by a fresh helper that could only read", "... by the same agent that noted them", or "The check could not run: <reason>"). Read each item's `check` and `tag` into its text in this order: every Fail, then every Doubt (each as "Fail <test>: <reason>"), then the pass line ("Passed the other N", "Passed the check" with none, and no pass line when all four found something), then its `tag` when present. A `suggestion` is offered as a Reword carrying exactly those words, which the person may adjust. A choice that needs more (step 6) asks the person for it.
6. Write the decisions, one `{ "id", "choice" }` per answered item plus what its choice needs, to a JSON file in the console session folder, or the OS temp folder in a terminal, never in the project. Run `decide --file <path>` and print its `closing` line, such as "Kept 2 (1 reworded), retired 1. 1 still waiting." What a choice needs:
- Reword of a lesson, a doubt or a lesson whose files are gone: the new `text`, plus `why`, `kind`, `about` or `area` when they change.
- Rename of an area: the new `name`, plus `paths` when they change.
+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));
}
}
}
}
+15
View File
@@ -237,6 +237,21 @@ export function lessonOriginal(row) {
return row.text || "";
}
/**
* The agent's suggestion for a row (Ask for suggestions): `{ choice, text, why }`
* from either form `suggested` takes, a bare choice word or an object. The
* words are kept only for a choice that opens an edit; null without one.
*/
export function lessonSuggestion(item, row) {
const all = item && item.suggested && typeof item.suggested === "object" ? item.suggested : null;
const given = all && row ? all[row.id] : null;
if (typeof given === "string") return { choice: given, text: "", why: "" };
if (!given || typeof given !== "object" || typeof given.choice !== "string") return null;
const edit = LESSON_EDIT_WORDS.has(given.choice);
const words = (v) => (edit && typeof v === "string" && v.trim() ? v.trim() : "");
return { choice: given.choice, text: words(given.text), why: words(given.why) };
}
/** The edit's words in the same form as lessonOriginal, or the original when untouched. */
function lessonTyped(row, edit) {
const field = lessonEditField(row).key;
+33 -2
View File
@@ -43,6 +43,7 @@ import {
lessonEditStart,
lessonEditField,
lessonReworded,
lessonSuggestion,
startsTicked,
} from "../answers.js";
import { el, hiddenText, icon, md, stateMark } from "../render.js";
@@ -1758,7 +1759,9 @@ function lessonsDraft(item) {
}
const picks = d && d.picks && typeof d.picks === "object" ? d.picks : {};
const edits = d && d.edits && typeof d.edits === "object" ? d.edits : {};
return { picks, edits, leaveAll: Boolean(d && d.leaveAll) };
// Which suggested words were already put in a row's boxes, so they go in once.
const applied = d && d.applied && typeof d.applied === "object" ? d.applied : {};
return { picks, edits, applied, leaveAll: Boolean(d && d.leaveAll) };
}
// The answer the draft stands for, or null with the field still missing.
@@ -1829,8 +1832,10 @@ function buildLessons(card, item, staged) {
const how = lessonsCheckedLine(item.checked);
if (how) card.appendChild(el("p", "lessons-checked", how));
const list = el("ul", "lessons-rows");
const filled = lessonsFillSuggested(item, draft);
for (const row of item.rows || []) list.appendChild(lessonRow(item, row, draft, commit));
card.appendChild(list);
if (filled) commit(false);
const { missing } = lessonsAnswer(item, draft);
error.hidden = !missing;
@@ -1908,6 +1913,32 @@ function lessonCheckLines(li, item, row, draft, commit) {
li.appendChild(box);
}
// A suggestion with words (Ask for suggestions) fills the boxes of a row whose
// edit is open on the suggested choice: once per suggestion, whether the edit
// was open when it landed or opened after, so typing afterwards stays.
function lessonsFillSuggested(item, draft) {
let filled = false;
for (const row of item.rows || []) {
const sug = lessonSuggestion(item, row);
if (!sug || (!sug.text && !sug.why) || draft.picks[row.id] !== sug.choice) continue;
const stamp = JSON.stringify([sug.text, sug.why]);
if (draft.applied[row.id] === stamp) continue;
const edit = draft.edits[row.id] || lessonEditStart(row);
if (sug.text) {
const key = lessonEditField(row).key;
// A log line that would become several lessons keeps them: one
// suggested sentence never stands in for the whole list.
if (key !== "lessons") edit[key] = sug.text;
else if (!Array.isArray(edit.lessons) || edit.lessons.length <= 1) edit.lessons = [sug.text];
}
if (sug.why && "why" in edit) edit.why = sug.why;
draft.edits[row.id] = edit;
draft.applied[row.id] = stamp;
filled = true;
}
return filled;
}
// One waiting item: what it is, why, where it came from, and its own choices.
function lessonRow(item, row, draft, commit) {
const pick = draft.picks[row.id] || "";
@@ -1977,7 +2008,7 @@ function lessonRow(item, row, draft, commit) {
group.setAttribute("aria-label", "Choices for: " + (row.text || row.id));
// The agent's suggestion (Ask for suggestions) outlines its word; it is
// never a pick, so nothing is chosen for the person.
const suggested = item.suggested && typeof item.suggested === "object" ? item.suggested[row.id] : null;
const suggested = lessonSuggestion(item, row)?.choice ?? null;
choices.forEach((word, i) => {
const on = pick === word;
const hint = suggested === word;