fwdloop 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/authoring.js +5 -3
- package/src/checkpick.js +1 -1
- package/src/pageask.js +33 -5
- package/src/panel/author.js +16 -6
- package/src/panel/data.js +2 -1
- package/src/panel/index.html +27 -9
- package/src/panel/result.js +2 -1
- package/src/setup.js +11 -5
- package/src/sheetfind.js +3 -1
- package/types/authoring.d.ts +2 -1
- package/types/checkpick.d.ts +1 -0
- package/types/pageask.d.ts +12 -2
- package/types/sheetfind.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fwdloop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Describe a job as steps and guardrails; an agent builds the workflow, pauses for humans where you said, checks every step happened, and reruns it under budgets it cannot touch.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/authoring.js
CHANGED
|
@@ -91,7 +91,7 @@ export function specHash({
|
|
|
91
91
|
* answer file counts as no answer. No questions file = `{ questions: [], open: [] }`.
|
|
92
92
|
* @param {string} planDir
|
|
93
93
|
* A question the page look raised (M10 piece 3) also carries `source: 'look'`, `ask` ('reading' | 'cant-check'), `ruleNo`, `ruleText` and `proposal`; an answer file carries `at`.
|
|
94
|
-
* @returns {{ questions: {k:number, line:number, question:string, answer:string|null, at?:string, rule?:string|null, source?:string, ask?:string, ruleNo?:number, ruleText?:string, proposal?:string|null, check?:Record<string, any>, pairRule?:number}[], open: {k:number, line:number, question:string, answer:null}[] }}
|
|
94
|
+
* @returns {{ questions: {k:number, line:number, question:string, answer:string|null, at?:string, rule?:string|null, choice?:'agree'|'drop'|'rule', source?:string, ask?:string, ruleNo?:number, ruleText?:string, proposal?:string|null, check?:Record<string, any>, pairRule?:number}[], open: {k:number, line:number, question:string, answer:null}[] }}
|
|
95
95
|
*/
|
|
96
96
|
export function readQuestions(planDir) {
|
|
97
97
|
const none = { questions: [], open: [] };
|
|
@@ -107,15 +107,17 @@ export function readQuestions(planDir) {
|
|
|
107
107
|
let at;
|
|
108
108
|
/** @type {string|null|undefined} the `~` rule the answer added (null = it left the rule Not checked), as the answer file recorded it */
|
|
109
109
|
let rule;
|
|
110
|
+
/** @type {'agree'|'drop'|'rule'|undefined} M10 am29: which one the answer used (`agree`, `drop` or `rule`), when the file records it */
|
|
111
|
+
let choice;
|
|
110
112
|
if (a.ok) {
|
|
111
113
|
try {
|
|
112
114
|
const j = JSON.parse(a.text);
|
|
113
115
|
const t = j?.answer;
|
|
114
|
-
if (typeof t === 'string' && t.trim() !== '') { answer = t; if (typeof j.at === 'string') at = j.at; if (j.rule === null || typeof j.rule === 'string') rule = j.rule; }
|
|
116
|
+
if (typeof t === 'string' && t.trim() !== '') { answer = t; if (typeof j.at === 'string') at = j.at; if (j.rule === null || typeof j.rule === 'string') rule = j.rule; if (j.choice === 'agree' || j.choice === 'drop' || j.choice === 'rule') choice = j.choice; }
|
|
115
117
|
} catch { /* unreadable = unanswered */ }
|
|
116
118
|
}
|
|
117
119
|
return {
|
|
118
|
-
k, line: q.line, question: String(q.question), answer, ...(at === undefined ? {} : { at }), ...(rule === undefined ? {} : { rule }),
|
|
120
|
+
k, line: q.line, question: String(q.question), answer, ...(at === undefined ? {} : { at }), ...(rule === undefined ? {} : { rule }), ...(choice === undefined ? {} : { choice }),
|
|
119
121
|
...(q.source === 'look' ? { source: 'look', ask: q.ask, ruleNo: q.ruleNo, ruleText: q.ruleText, proposal: typeof q.proposal === 'string' ? q.proposal : null, ...(q.check && typeof q.check === 'object' ? { check: q.check } : {}), ...(Number.isInteger(q.pairRule) ? { pairRule: q.pairRule } : {}) } : {}),
|
|
120
122
|
};
|
|
121
123
|
});
|
package/src/checkpick.js
CHANGED
|
@@ -205,7 +205,7 @@ export function countCheck(text) {
|
|
|
205
205
|
/** the can't-check ask, as the signed words say it */
|
|
206
206
|
export const CANT_CHECK_WORDS = "I can't check this. Your own words, or Not checked?";
|
|
207
207
|
/** how every answer is told, once (am2 item 2's words) */
|
|
208
|
-
const HOW_TO_ANSWER = (/** @type {number} */ line, /** @type {boolean} */ agree) => `${agree ? 'Answer "agree" to use it, or type your own words' : 'Type your own words'} (your answer is added as a new ~ rule on line ${line}), or answer "drop it" to leave it Not checked.`;
|
|
208
|
+
export const HOW_TO_ANSWER = (/** @type {number} */ line, /** @type {boolean} */ agree) => `${agree ? 'Answer "agree" to use it, or type your own words' : 'Type your own words'} (your answer is added as a new ~ rule on line ${line}), or answer "drop it" to leave it Not checked.`;
|
|
209
209
|
|
|
210
210
|
/**
|
|
211
211
|
* The asks for the rows: `Line n, guardrail "<…>": I propose <check in plain words>.` for a kept check, `Line n, guardrail "<…>": I can't check this. Your own words, or
|
package/src/pageask.js
CHANGED
|
@@ -16,6 +16,8 @@ import { redactSecrets } from './redact.js';
|
|
|
16
16
|
import { lineRules, boundInWords, wordsSaidOn } from './pagebits.js';
|
|
17
17
|
import { validReading } from './pagerules.js';
|
|
18
18
|
import { isCountGuardrail } from './declaration.js';
|
|
19
|
+
import { HOW_TO_ANSWER } from './checkpick.js';
|
|
20
|
+
import { columnTail } from './sheetfind.js';
|
|
19
21
|
|
|
20
22
|
/** the most asks before drafting; more than this is a job to rewrite, not a questionnaire (am1) */
|
|
21
23
|
export const MAX_LOOK_ASKS = 3;
|
|
@@ -70,9 +72,16 @@ export function ruleWords(f) {
|
|
|
70
72
|
|
|
71
73
|
/** the words of a reading ask: the ONE spelling, and {@link readingOfQuestion} reads it back (the Result tab's "(you confirmed)") */
|
|
72
74
|
const READING_HEAD = ' I read it as: ';
|
|
73
|
-
const
|
|
75
|
+
const READING_ASKED = '. Agree?';
|
|
76
|
+
/** the part of a reading ask that tells the CLI's typed words (M10 am29: the panel shows the question without it) */
|
|
77
|
+
const READING_ANSWER = ' Answer "agree"';
|
|
78
|
+
const READING_TAIL = `${READING_ASKED}${READING_ANSWER}`;
|
|
79
|
+
/** @param {number} n @returns {string} the rest of a reading ask after its answer words */
|
|
80
|
+
const readingRest = (n) => `, or type your own reading (your answer is added as a new ~ rule on line ${n}).`;
|
|
81
|
+
/** @param {number} n @returns {string} the answer words a can't-check ask ends with (said once, here, and cut in the panel) */
|
|
82
|
+
const cantCheckTail = (n) => ` Answer "${DROP_IT}", or type how to check it (your answer is added as a new ~ rule on line ${n}).`;
|
|
74
83
|
/** @param {number} n @param {string} rule @param {string} reading @returns {string} */
|
|
75
|
-
const readingQuestion = (n, rule, reading) => `Your line ${n} says "${rule}".${READING_HEAD}${reading}${READING_TAIL}
|
|
84
|
+
const readingQuestion = (n, rule, reading) => `Your line ${n} says "${rule}".${READING_HEAD}${reading}${READING_TAIL}${readingRest(n)}`;
|
|
76
85
|
/** @param {unknown} q a recorded question @returns {string|null} the reading a reading ask proposed, or null when it was another kind of question */
|
|
77
86
|
export function readingOfQuestion(q) {
|
|
78
87
|
const s = String(q ?? '');
|
|
@@ -81,6 +90,19 @@ export function readingOfQuestion(q) {
|
|
|
81
90
|
return a >= 0 && b > a ? s.slice(a + READING_HEAD.length, b) : null;
|
|
82
91
|
}
|
|
83
92
|
|
|
93
|
+
/**
|
|
94
|
+
* M10 am29: a look question as the PANEL shows it: the code's own answer words (`Answer "agree"…` / `answer "drop it"…`) cut off the end, because the buttons and the box say it.
|
|
95
|
+
* Only the known tails are cut, matched exactly as a suffix (never a pattern over the prose); a question that ends in none of them is returned whole. The stored question is never changed.
|
|
96
|
+
* @param {{question: string, line: number, source?: string}} q @returns {string}
|
|
97
|
+
*/
|
|
98
|
+
export function panelQuestionText(q) {
|
|
99
|
+
const text = String(q.question);
|
|
100
|
+
if (q.source !== 'look') return text;
|
|
101
|
+
const tails = [`${READING_ANSWER}${readingRest(q.line)}`, cantCheckTail(q.line), columnTail(q.line), ` ${HOW_TO_ANSWER(q.line, true)}`, ` ${HOW_TO_ANSWER(q.line, false)}`];
|
|
102
|
+
const hit = tails.find((t) => text.endsWith(t));
|
|
103
|
+
return hit === undefined ? text : text.slice(0, text.length - hit.length);
|
|
104
|
+
}
|
|
105
|
+
|
|
84
106
|
/**
|
|
85
107
|
* The early asks CODE forces before any paid drafting, from the look's own result. One ask per rule text on a line; readings first, then can't-check
|
|
86
108
|
* asks, each in line order. The caller applies the cap and the answer gate.
|
|
@@ -118,7 +140,7 @@ export function askableFromLook(look, jobLines) {
|
|
|
118
140
|
seen.add(key);
|
|
119
141
|
cants.push({
|
|
120
142
|
line: l.n, rule: n, source: 'look', ask: 'cant-check', ruleText: rule,
|
|
121
|
-
question: `Your line ${l.n} says "${rule}". I can't check this on the page. Drop it
|
|
143
|
+
question: `Your line ${l.n} says "${rule}". I can't check this on the page. Drop it?${cantCheckTail(l.n)}`,
|
|
122
144
|
});
|
|
123
145
|
});
|
|
124
146
|
}
|
|
@@ -144,12 +166,18 @@ export function tooManyAsksText(asks) {
|
|
|
144
166
|
* person's own words, taken word for word with newlines folded to spaces. A question that is not a look ask is never changed: its answer is its rule.
|
|
145
167
|
* M10 am16: a shape guardrail's ask (`ask: 'check'` proposes a check, `'no-check'` found none) takes the same words: `agree` takes the proposal (and the check it
|
|
146
168
|
* carries, `check`), `drop it` leaves the rule Not checked (either kind), anything else is the person's own words (`own`: a `~` rule on the line, no check).
|
|
147
|
-
* @param {{source?: string, ask?: string, proposal?: string|null, check?: Record<string, any>}} q @param {unknown} typed
|
|
169
|
+
* @param {{source?: string, ask?: string, proposal?: string|null, check?: Record<string, any>}} q @param {unknown} typed @param {'agree'|'drop'|'rule'} [choice] M10 am29: the button used; absent = today's words reading (CLI, old files)
|
|
148
170
|
* @returns {{rule: string|null, left: boolean, check?: Record<string, any>, own?: boolean}} `rule` = the words written as a new `~` rule (null when the rule is left Not checked)
|
|
149
171
|
*/
|
|
150
|
-
export function ruleOfAnswer(q, typed) {
|
|
172
|
+
export function ruleOfAnswer(q, typed, choice) {
|
|
151
173
|
const typedText = String(typed ?? '').replace(/\s*\n\s*/g, ' ').trim();
|
|
152
174
|
if (q.source !== 'look') return { rule: typedText, left: false };
|
|
175
|
+
if (choice !== undefined) { // M10 am29: a typed choice decides, never the words; the box (`rule`) keeps its words whole
|
|
176
|
+
const shapeC = q.ask === 'check' || q.ask === 'no-check';
|
|
177
|
+
if (choice === 'agree' && typeof q.proposal === 'string' && (q.ask === 'reading' || q.ask === 'check')) return { rule: q.proposal, left: false, ...(q.ask === 'check' && q.check ? { check: q.check } : {}) };
|
|
178
|
+
if (choice === 'drop') return { rule: null, left: true };
|
|
179
|
+
return { rule: typedText, left: false, ...(shapeC ? { own: true } : {}) };
|
|
180
|
+
}
|
|
153
181
|
const text = stripAgreeLead(typedText); // F240: "yes, check it as ..." is the person's own words minus the leading "yes,"
|
|
154
182
|
const shape = q.ask === 'check' || q.ask === 'no-check';
|
|
155
183
|
if ((q.ask === 'reading' || q.ask === 'check') && typeof q.proposal === 'string' && isAgree(text)) return { rule: q.proposal, left: false, ...(q.ask === 'check' && q.check ? { check: q.check } : {}) };
|
package/src/panel/author.js
CHANGED
|
@@ -38,7 +38,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
38
38
|
import {
|
|
39
39
|
ANSWER_FILE, NOT_CHECKED_FILE, OPEN_QUESTION_SAY, PANEL_DRAFTS_DIR, readQuestions, readoutHeadIndexes, scrub, signDraft,
|
|
40
40
|
} from '../authoring.js';
|
|
41
|
-
import { ruleOfAnswer } from '../pageask.js';
|
|
41
|
+
import { ruleOfAnswer, panelQuestionText, DROP_IT } from '../pageask.js';
|
|
42
42
|
import { checkFlowName, nextRunId, readFileInside, readdirInside } from '../flow.js';
|
|
43
43
|
import { readModelRecord } from '../flowmodel.js';
|
|
44
44
|
import { isFwdloopAlive } from '../liveness.js';
|
|
@@ -279,7 +279,7 @@ export function createAuthor(opts) {
|
|
|
279
279
|
const q = rel === 'draft' ? firstQs : readQuestions(join(dir, rel));
|
|
280
280
|
if (q.open.length > 0) {
|
|
281
281
|
const lineText = (line) => parseJobBox(typeof card?.job === 'string' ? card.job : '').steps[line - 1]?.text ?? null;
|
|
282
|
-
const questions = q.questions.map((x) => ({ k: x.k, line: x.line, lineText: lineText(x.line), question: scrub(x.question, keys), answered: x.answer !== null, ...(x.source === 'look' ? { source: 'look' } : {}) }));
|
|
282
|
+
const questions = q.questions.map((x) => ({ k: x.k, line: x.line, lineText: lineText(x.line), question: scrub(x.question, keys), answered: x.answer !== null, ...(x.source === 'look' ? { source: 'look', ask: x.ask, proposes: typeof x.proposal === 'string' && (x.ask === 'reading' || x.ask === 'check'), drops: Number.isInteger(x.ruleNo), shown: scrub(panelQuestionText(x), keys) } : {}) }));
|
|
283
283
|
return { ...shared, stepList: stepListOf(dir, rel, keys, true), phase: 'questions-open', plan: rel, questions, openK: q.open[0].k, total: q.questions.length };
|
|
284
284
|
}
|
|
285
285
|
if (q.questions.length > 0) return { ...shared, phase: 'stopped', say: ANSWERS_NOT_DRAFTED_SAY };
|
|
@@ -750,7 +750,14 @@ export function createAuthor(opts) {
|
|
|
750
750
|
// space (one `~` line is one line) instead of refused. Every other question keeps its own gate (blank, one line).
|
|
751
751
|
const look = q.source === 'look';
|
|
752
752
|
// hamr 2026-11-07 (ruling 2A): a leading `~` the person typed is dropped quietly (the job line adds its own); the ONE place, so a tilde-only answer is a blank answer
|
|
753
|
-
|
|
753
|
+
// M10 am29: the button used rides as a typed `choice`; absent = the words reading (CLI and old pages). agree needs a proposal, drop/agree are look asks only.
|
|
754
|
+
const choice = b.choice;
|
|
755
|
+
if (choice !== undefined) {
|
|
756
|
+
const proposes = look && typeof q.proposal === 'string' && (q.ask === 'reading' || q.ask === 'check');
|
|
757
|
+
if (choice !== 'agree' && choice !== 'drop' && choice !== 'rule') return { status: 400, body: { ok: false, refused: 'bad-choice', say: 'That answer is not one of the choices. Nothing was saved.' } };
|
|
758
|
+
if ((choice === 'agree' && !proposes) || (choice === 'drop' && !look)) return { status: 400, body: { ok: false, refused: 'bad-choice', say: 'That choice is not offered for this question. Nothing was saved.' } };
|
|
759
|
+
}
|
|
760
|
+
const answer = choice === 'agree' ? 'agree' : choice === 'drop' ? DROP_IT : typeof b.answer === 'string' ? (look ? b.answer.replace(/\s*\n\s*/g, ' ') : b.answer).trim().replace(/^(?:~\s*)+/, '') : '';
|
|
754
761
|
if (answer === '') return { status: 400, body: { ok: false, refused: 'blank-answer', say: look ? LOOK_BLANK_ANSWER_SAY : BLANK_ANSWER_SAY } };
|
|
755
762
|
if (!look && /[\r\n]/.test(answer)) return { status: 400, body: { ok: false, refused: 'one-line', say: ONE_LINE_ANSWER_SAY } };
|
|
756
763
|
if (keys.some((k) => k.length >= 8 && answer.includes(k))) return { status: 400, body: { ok: false, refused: 'key', say: 'This answer contains an API key. Keys go in Settings only. Nothing was saved.' } };
|
|
@@ -759,14 +766,17 @@ export function createAuthor(opts) {
|
|
|
759
766
|
const answerFile = join(planDir, ANSWER_FILE(v.openK));
|
|
760
767
|
const at = new Date().toISOString();
|
|
761
768
|
// what this answer does (ruleOfAnswer, the one place): the `~` rule it adds, or the rule it leaves Not checked
|
|
762
|
-
const effect = ruleOfAnswer(q, answer);
|
|
769
|
+
const effect = ruleOfAnswer(q, answer, choice);
|
|
770
|
+
// M10 am30: a rule left Not checked is a `<line>.<rule>` pair, so only a question about one of the person's `~` rules (an integer ruleNo) can be dropped; any other drop is refused here, nothing written, nothing sent to the drafter
|
|
771
|
+
if (effect.left && !Number.isInteger(q.ruleNo)) return { status: 400, body: { ok: false, refused: 'bad-choice', say: 'That question is about the job line, not one of your ~ rules, so there is nothing to drop. Agree, or type your own words. Nothing was saved.' } };
|
|
763
772
|
// the whole redraft is checked at $0 BEFORE the answer is written, so a refusal leaves the question open and nothing on disk
|
|
764
773
|
/** @type {any} */
|
|
765
774
|
let redraft = null;
|
|
766
775
|
if (last) {
|
|
767
776
|
const all = full.map((x) => {
|
|
768
777
|
const typed = x.k === v.openK ? answer : x.answer;
|
|
769
|
-
|
|
778
|
+
const ch = x.k === v.openK ? choice : x.choice;
|
|
779
|
+
return { line: x.line, question: x.question, answer: typed, ...ruleOfAnswer(x, typed, ch), ruleNo: x.ruleNo, ruleText: x.ruleText, ask: x.ask, ...(x.pairRule === undefined ? {} : { pairRule: x.pairRule }) };
|
|
770
780
|
});
|
|
771
781
|
const adds = all.filter((x) => x.rule !== null);
|
|
772
782
|
const grown = applyAnswers(typeof v.card.job === 'string' ? v.card.job : '', all);
|
|
@@ -784,7 +794,7 @@ export function createAuthor(opts) {
|
|
|
784
794
|
try {
|
|
785
795
|
// the human row of the draft log (am2 item 4): the question, the answer, the line, the time; a look ask also carries what code proposed and the rule the answer added, as their own fields
|
|
786
796
|
writeFileSync(answerFile, `${JSON.stringify({
|
|
787
|
-
k: v.openK, line: q.line, question: q.question, answer, at,
|
|
797
|
+
k: v.openK, line: q.line, question: q.question, answer, ...(choice === undefined ? {} : { choice }), at,
|
|
788
798
|
...(look ? { source: 'look', ask: q.ask, ruleNo: q.ruleNo, ruleText: q.ruleText, proposal: q.proposal ?? null, rule: effect.rule } : {}),
|
|
789
799
|
})}\n`, { mode: 0o600, flag: 'wx' });
|
|
790
800
|
} catch (e) {
|
package/src/panel/data.js
CHANGED
|
@@ -42,6 +42,7 @@ import { readSetup } from '../setup.js';
|
|
|
42
42
|
import { parseHintBlock } from '../learn.js';
|
|
43
43
|
import { checkedLines, notCheckedView, NOT_CHECKED_LABEL } from '../checked.js';
|
|
44
44
|
import { LABEL_PICKED } from '../checkwords.js';
|
|
45
|
+
import { panelQuestionText } from '../pageask.js';
|
|
45
46
|
import { csvRolesOf, askSheetCard } from '../sheetblock.js';
|
|
46
47
|
import { readSheetChecks } from '../sheet-record.js';
|
|
47
48
|
import {
|
|
@@ -1941,7 +1942,7 @@ export function getDraftBlock(flowDir, runDir) {
|
|
|
1941
1942
|
rows.push(human(r, n, { action: 'card (you)', gap }));
|
|
1942
1943
|
} else if (r.kind === 'note') rows.push(human(r, n, { action: 'note (you)', gap: String(r.text ?? '') }));
|
|
1943
1944
|
// M10 am2 item 4: a question the page look raised and your answer, under the drafting step, in bareloop's words (`you were asked:` / `you said:`)
|
|
1944
|
-
else if (r.kind === 'human') rows.push(human(r, n, { action: `you were asked: ${r
|
|
1945
|
+
else if (r.kind === 'human') rows.push(human(r, n, { action: `you were asked: ${panelQuestionText(r)}`, gap: `you said: ${r.answer}${r.source === 'look' && typeof r.rule === 'string' && r.rule !== '' ? ` ${LABEL_PICKED}` : ''}` }));
|
|
1945
1946
|
else if (r.kind === 'draft') { rows.push(model(r, n, 'draft')); rows.push(...tryRows(r, n)); }
|
|
1946
1947
|
else if (r.kind === 'change') { rows.push(model(r, n, `change ${r.n}`)); rows.push(...tryRows(r, n)); }
|
|
1947
1948
|
else if (r.kind === 'startover') { rows.push(model(r, n, 'start over')); rows.push(...tryRows(r, n)); }
|
package/src/panel/index.html
CHANGED
|
@@ -740,6 +740,10 @@
|
|
|
740
740
|
.chat-question .q-line{font-size:12px;color:var(--text-faint);margin-top:4px;overflow-wrap:anywhere;}
|
|
741
741
|
.chat-question .q-text{font-size:13px;margin-top:4px;overflow-wrap:anywhere;white-space:pre-wrap;}
|
|
742
742
|
.chat-question textarea{display:block;width:100%;max-width:100%;box-sizing:border-box;margin-top:8px;min-height:3.4em;font:inherit;padding:6px 8px;border:1px solid var(--border-strong);border-radius:0;background:var(--bg);color:var(--text);resize:vertical;}
|
|
743
|
+
.chat-question .q-choices{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;}
|
|
744
|
+
.chat-question .q-choices .btn{flex:1 1 auto;min-width:0;}
|
|
745
|
+
.chat-question .q-or{display:block;font-size:12px;color:var(--text-faint);margin-top:8px;text-transform:none;letter-spacing:normal;font-weight:normal;}
|
|
746
|
+
.chat-question .q-or + textarea{margin-top:4px;}
|
|
743
747
|
.chat-question .q-err{color:var(--red);}
|
|
744
748
|
.chat-extras{display:flex;flex-direction:column;gap:10px;margin-bottom:10px;}
|
|
745
749
|
.chat-extras:empty{display:none;}
|
|
@@ -1398,6 +1402,11 @@
|
|
|
1398
1402
|
<div class="q-head" id="chat-q-head" data-testid="chat-q-head"></div>
|
|
1399
1403
|
<div class="q-line" id="chat-q-line" data-testid="chat-q-line"></div>
|
|
1400
1404
|
<div class="q-text" id="chat-q-text" data-testid="chat-q-text"></div>
|
|
1405
|
+
<div class="q-choices" id="chat-q-choices" data-testid="chat-q-choices" hidden>
|
|
1406
|
+
<button class="btn small" type="button" id="chat-q-agree" data-testid="chat-q-agree" hidden>Agree</button>
|
|
1407
|
+
<button class="btn small" type="button" id="chat-q-drop" data-testid="chat-q-drop" hidden>Drop it</button>
|
|
1408
|
+
</div>
|
|
1409
|
+
<label class="q-or" id="chat-q-or" data-testid="chat-q-or" for="chat-q-answer">Or type a new rule:</label>
|
|
1401
1410
|
<textarea id="chat-q-answer" data-testid="chat-q-answer" rows="2" autocomplete="off" spellcheck="false" aria-label="Your answer" placeholder="Your answer, on one line"></textarea>
|
|
1402
1411
|
<div class="hint q-err" id="chat-q-error" data-testid="chat-q-error" role="alert"></div>
|
|
1403
1412
|
<button class="btn primary wide" type="button" id="chat-q-send" data-testid="chat-q-send">Send</button>
|
|
@@ -5533,6 +5542,9 @@
|
|
|
5533
5542
|
var qAnswer = document.getElementById("chat-q-answer");
|
|
5534
5543
|
var qError = document.getElementById("chat-q-error");
|
|
5535
5544
|
var qSend = document.getElementById("chat-q-send");
|
|
5545
|
+
var qChoices = document.getElementById("chat-q-choices");
|
|
5546
|
+
var qAgree = document.getElementById("chat-q-agree");
|
|
5547
|
+
var qDrop = document.getElementById("chat-q-drop");
|
|
5536
5548
|
var extrasEl = document.getElementById("chat-extras");
|
|
5537
5549
|
var newBox = document.getElementById("jf-new");
|
|
5538
5550
|
var runBox = document.getElementById("jf-run");
|
|
@@ -5781,13 +5793,13 @@
|
|
|
5781
5793
|
if(!q) return null;
|
|
5782
5794
|
// M10 am2 item 1 / am5 item 1: a question the page look raised is ONE plain chat message (bareloop's words); the head and line rows stay empty
|
|
5783
5795
|
if(q.source === "look"){
|
|
5784
|
-
return { key: String(state.draftId) + ":" + q.k, k: q.k, head: "", line: "", question: "A question the plan raised (" + q.k + " of " + state.total + "), about job line " + q.line + ": " + q.question };
|
|
5796
|
+
return { key: String(state.draftId) + ":" + q.k, k: q.k, head: "", line: "", question: "A question the plan raised (" + q.k + " of " + state.total + "), about job line " + q.line + ": " + (typeof q.shown === "string" ? q.shown : q.question), agree: q.proposes === true, drop: q.drops === true };
|
|
5785
5797
|
}
|
|
5786
5798
|
return {
|
|
5787
5799
|
key: String(state.draftId) + ":" + q.k, k: q.k,
|
|
5788
5800
|
head: "A question the plan raised (" + q.k + " of " + state.total + ")",
|
|
5789
5801
|
line: q.lineText ? "About job line " + q.line + ": " + q.lineText : "About job line " + q.line,
|
|
5790
|
-
question: q.question
|
|
5802
|
+
question: q.question, agree: false, drop: false
|
|
5791
5803
|
};
|
|
5792
5804
|
}
|
|
5793
5805
|
// pure: what sits beside a green plan: Your answers (only when the plan was drafted with some), Checked (the machine's sentences from the
|
|
@@ -6648,6 +6660,8 @@
|
|
|
6648
6660
|
qKey = v.key;
|
|
6649
6661
|
qHead.textContent = v.head; qLine.textContent = v.line; qText.textContent = v.question;
|
|
6650
6662
|
qHead.hidden = v.head === ""; qLine.hidden = v.line === ""; // a look question is one plain message: no empty rows
|
|
6663
|
+
// M10 am29: every question has the labelled box; a look question also has Agree (only when it proposes something) and Drop it
|
|
6664
|
+
qAgree.hidden = !v.agree; qDrop.hidden = !v.drop; qChoices.hidden = !(v.agree || v.drop);
|
|
6651
6665
|
qAnswer.value = ""; qError.textContent = "";
|
|
6652
6666
|
}
|
|
6653
6667
|
}
|
|
@@ -6843,17 +6857,19 @@
|
|
|
6843
6857
|
}
|
|
6844
6858
|
|
|
6845
6859
|
// Send (amendments 24/25): the answer to the question now open. A blank answer is refused by the server in plain words and the question stays open.
|
|
6846
|
-
|
|
6860
|
+
// M10 am29: a choice button posts its own choice and nothing else; the box's button posts the box's words as a new rule (choice "rule"), never read as agree or drop it
|
|
6861
|
+
function doAnswer(choice){
|
|
6847
6862
|
if(qBusy || !sessionId || !lastState || lastState.phase !== "questions-open") return;
|
|
6848
|
-
qBusy = true; qSend.disabled = true; qError.textContent = "";
|
|
6863
|
+
qBusy = true; qSend.disabled = true; qAgree.disabled = true; qDrop.disabled = true; qError.textContent = "";
|
|
6849
6864
|
var id = sessionId;
|
|
6850
|
-
|
|
6851
|
-
|
|
6865
|
+
var body = choice === "agree" || choice === "drop" ? {k: lastState.openK, choice: choice} : {k: lastState.openK, answer: qAnswer.value, choice: "rule"};
|
|
6866
|
+
authorPost("/api/author/" + id + "/answer", body).then(function(r){
|
|
6867
|
+
qBusy = false; qSend.disabled = false; qAgree.disabled = false; qDrop.disabled = false;
|
|
6852
6868
|
if(id !== sessionId) return;
|
|
6853
6869
|
if(!(r.status >= 200 && r.status < 300 && r.body && r.body.ok === true)){ qError.textContent = refusalText(r); return; }
|
|
6854
6870
|
qAnswer.value = "";
|
|
6855
6871
|
poll();
|
|
6856
|
-
}).catch(function(){ qBusy = false; qSend.disabled = false; qError.textContent = NETWORK_SAY; });
|
|
6872
|
+
}).catch(function(){ qBusy = false; qSend.disabled = false; qAgree.disabled = false; qDrop.disabled = false; qError.textContent = NETWORK_SAY; });
|
|
6857
6873
|
}
|
|
6858
6874
|
function doDraft(startedOverFrom){
|
|
6859
6875
|
clearFieldErrors();
|
|
@@ -7098,8 +7114,10 @@
|
|
|
7098
7114
|
reviseBtn.addEventListener("click", function(){ if(reviseBtn.disabled) return; if(lastState && lastState.card) fillCardFields(lastState.card); reviseOpen = true; refreshStartEnabled(); fitCardBoxes(); });
|
|
7099
7115
|
// Start over (amendment 14 item 3): the same draft call as Draft, from the card as it is now; the old draft's files stay (a new draft id, 2 new revises)
|
|
7100
7116
|
startOverBtn.addEventListener("click", function(){ if(!startOverBtn.disabled) doDraft(sessionId); });
|
|
7101
|
-
qSend.addEventListener("click", doAnswer);
|
|
7102
|
-
|
|
7117
|
+
qSend.addEventListener("click", function(){ doAnswer("rule"); });
|
|
7118
|
+
qAgree.addEventListener("click", function(){ doAnswer("agree"); });
|
|
7119
|
+
qDrop.addEventListener("click", function(){ doAnswer("drop"); });
|
|
7120
|
+
qAnswer.addEventListener("keydown", function(e){ if(e.key === "Enter" && !e.shiftKey){ e.preventDefault(); doAnswer("rule"); } });
|
|
7103
7121
|
mainBtn.addEventListener("click", function(){
|
|
7104
7122
|
if(mainBtn.disabled) return;
|
|
7105
7123
|
if(mainAction === "draft") doDraft(mainStartOver ? sessionId : null);
|
package/src/panel/result.js
CHANGED
|
@@ -144,7 +144,8 @@ export function confirmedFactNames(setupRows, lineN, signedRule, factNames) {
|
|
|
144
144
|
const names = new Set();
|
|
145
145
|
const written = lineRules({ rule: signedRule });
|
|
146
146
|
for (const h of Array.isArray(setupRows) ? setupRows : []) {
|
|
147
|
-
|
|
147
|
+
// M10 am29: a row that records its typed choice is read by it (a box answer "agree" is a rule, never a confirmation); the words only when the row has none
|
|
148
|
+
if (h?.kind !== 'human' || h.source !== 'look' || h.line !== lineN || !(typeof h.choice === 'string' ? h.choice === 'agree' : isAgree(h.answer))) continue; // eslint-disable-line no-continue
|
|
148
149
|
const reading = readingOfQuestion(h.question);
|
|
149
150
|
if (reading === null || !written.includes(reading)) continue; // eslint-disable-line no-continue
|
|
150
151
|
for (const name of factNames) if (reading.startsWith(`${name} `)) names.add(name);
|
package/src/setup.js
CHANGED
|
@@ -61,22 +61,28 @@ function planRow(sessionDir, rel, kind, n) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* M10 am2 item 4: one row per question the
|
|
65
|
-
* from the answer files). The question, the answer, the line and the time, plus the proposal and the rule the answer added as their own fields (never cut
|
|
64
|
+
* M10 am2 item 4 (and M14 am3: also a question the drafter raised): one row per question the plan asked and the person answered, in the plan folder that
|
|
65
|
+
* raised it (the draft log's human rows, read from the answer files). The question, the answer, the line and the time, plus the proposal and the rule the answer added as their own fields (never cut
|
|
66
66
|
* out of the question text). A question nobody answered leaves no row.
|
|
67
67
|
* @param {string} sessionDir @param {string} rel
|
|
68
68
|
*/
|
|
69
69
|
function humanRows(sessionDir, rel) {
|
|
70
|
-
|
|
70
|
+
/** @type {any[]} the look rows carry look-only fields (and a recorded choice), the drafter rows do not */
|
|
71
|
+
const answered = readQuestions(join(sessionDir, rel)).questions.filter((q) => q.answer !== null).map((q) => (q.source === 'look' ? {
|
|
71
72
|
kind: 'human', n: q.k, at: q.at ?? null, source: 'look', ask: q.ask, question: q.question, answer: q.answer, line: q.line,
|
|
72
|
-
ruleNo: q.ruleNo, ruleText: q.ruleText, proposal: q.proposal ?? null, rule: q.rule ?? null,
|
|
73
|
+
ruleNo: q.ruleNo, ruleText: q.ruleText, proposal: q.proposal ?? null, rule: q.rule ?? null, ...(q.choice === undefined ? {} : { choice: q.choice }),
|
|
74
|
+
} : {
|
|
75
|
+
// M14 am3: a question the drafter raised and the person answered is the same row, with no look-only fields (so no picked label)
|
|
76
|
+
kind: 'human', n: q.k, at: q.at ?? null, question: q.question, answer: q.answer, line: q.line,
|
|
73
77
|
}));
|
|
78
|
+
// a kept row's n counts the answered LOOK rows only, as before M14 am3 (a page-look row never changes)
|
|
79
|
+
const lookAnswered = answered.filter((r) => r.source === 'look').length;
|
|
74
80
|
// M10 am17 (6): a pick kept from the last draft is the same row, from this plan's picks record (not an answer file), its answer being the words `kept from last draft`
|
|
75
81
|
const kept = Array.isArray(readJson(join(sessionDir, rel), RECORD_FILE)?.kept) ? readJson(join(sessionDir, rel), RECORD_FILE).kept : [];
|
|
76
82
|
const keptRows = kept.map((k, i) => {
|
|
77
83
|
const [ask] = checkAsks([{ line: k.line, rule: k.rule, text: k.ruleText, check: k.check ?? null, why: null }]);
|
|
78
84
|
return {
|
|
79
|
-
kind: 'human', n:
|
|
85
|
+
kind: 'human', n: lookAnswered + i + 1, at: null, source: 'look', ask: ask.ask, question: ask.question, answer: KEPT_WORDS, line: k.line,
|
|
80
86
|
ruleNo: k.rule, ruleText: k.ruleText, proposal: ask.reading ?? null, rule: k.added ?? null,
|
|
81
87
|
};
|
|
82
88
|
});
|
package/src/sheetfind.js
CHANGED
|
@@ -47,4 +47,6 @@ export function findColumn(csvText, word) {
|
|
|
47
47
|
* `no column 'Price'; 'Amount' has numbers in 40 of 40 rows. Use it? Answer "agree", or type your own words (your answer is added as a new ~ rule on line N).`
|
|
48
48
|
* @param {string} word @param {FoundAsk} found @param {number} line @returns {string}
|
|
49
49
|
*/
|
|
50
|
-
export const columnQuestion = (word, found, line) => `no column '${word}'; '${found.column}' has numbers in ${found.numbers} of ${found.rows} rows. Use it
|
|
50
|
+
export const columnQuestion = (word, found, line) => `no column '${word}'; '${found.column}' has numbers in ${found.numbers} of ${found.rows} rows. Use it?${columnTail(line)}`;
|
|
51
|
+
/** @param {number} line @returns {string} the answer words the column question ends with (M10 am29: the panel cuts exactly this) */
|
|
52
|
+
export const columnTail = (line) => ` Answer "agree", or type your own words (your answer is added as a new ~ rule on line ${line}).`;
|
package/types/authoring.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export function specHash({ proseText, declarationText, inputFactsText, readoutTe
|
|
|
23
23
|
* answer file counts as no answer. No questions file = `{ questions: [], open: [] }`.
|
|
24
24
|
* @param {string} planDir
|
|
25
25
|
* A question the page look raised (M10 piece 3) also carries `source: 'look'`, `ask` ('reading' | 'cant-check'), `ruleNo`, `ruleText` and `proposal`; an answer file carries `at`.
|
|
26
|
-
* @returns {{ questions: {k:number, line:number, question:string, answer:string|null, at?:string, rule?:string|null, source?:string, ask?:string, ruleNo?:number, ruleText?:string, proposal?:string|null, check?:Record<string, any>, pairRule?:number}[], open: {k:number, line:number, question:string, answer:null}[] }}
|
|
26
|
+
* @returns {{ questions: {k:number, line:number, question:string, answer:string|null, at?:string, rule?:string|null, choice?:'agree'|'drop'|'rule', source?:string, ask?:string, ruleNo?:number, ruleText?:string, proposal?:string|null, check?:Record<string, any>, pairRule?:number}[], open: {k:number, line:number, question:string, answer:null}[] }}
|
|
27
27
|
*/
|
|
28
28
|
export function readQuestions(planDir: string): {
|
|
29
29
|
questions: {
|
|
@@ -33,6 +33,7 @@ export function readQuestions(planDir: string): {
|
|
|
33
33
|
answer: string | null;
|
|
34
34
|
at?: string;
|
|
35
35
|
rule?: string | null;
|
|
36
|
+
choice?: "agree" | "drop" | "rule";
|
|
36
37
|
source?: string;
|
|
37
38
|
ask?: string;
|
|
38
39
|
ruleNo?: number;
|
package/types/checkpick.d.ts
CHANGED
|
@@ -168,6 +168,7 @@ export const SUGGEST_SCHEMA: Readonly<{
|
|
|
168
168
|
}>;
|
|
169
169
|
/** the can't-check ask, as the signed words say it */
|
|
170
170
|
export const CANT_CHECK_WORDS: "I can't check this. Your own words, or Not checked?";
|
|
171
|
+
export function HOW_TO_ANSWER(line: number, agree: boolean): string;
|
|
171
172
|
/**
|
|
172
173
|
* `check` = the check the person agreed to (null for their own words); `added` = the `~` rule the answer wrote on the line; `own` = their own words
|
|
173
174
|
*/
|
package/types/pageask.d.ts
CHANGED
|
@@ -7,6 +7,16 @@ export function moneyAs(f: any, n: string | number, symbolFirst: boolean): strin
|
|
|
7
7
|
export function ruleWords(f: any): string;
|
|
8
8
|
/** @param {unknown} q a recorded question @returns {string|null} the reading a reading ask proposed, or null when it was another kind of question */
|
|
9
9
|
export function readingOfQuestion(q: unknown): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* M10 am29: a look question as the PANEL shows it: the code's own answer words (`Answer "agree"…` / `answer "drop it"…`) cut off the end, because the buttons and the box say it.
|
|
12
|
+
* Only the known tails are cut, matched exactly as a suffix (never a pattern over the prose); a question that ends in none of them is returned whole. The stored question is never changed.
|
|
13
|
+
* @param {{question: string, line: number, source?: string}} q @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
export function panelQuestionText(q: {
|
|
16
|
+
question: string;
|
|
17
|
+
line: number;
|
|
18
|
+
source?: string;
|
|
19
|
+
}): string;
|
|
10
20
|
/**
|
|
11
21
|
* The early asks CODE forces before any paid drafting, from the look's own result. One ask per rule text on a line; readings first, then can't-check
|
|
12
22
|
* asks, each in line order. The caller applies the cap and the answer gate.
|
|
@@ -46,7 +56,7 @@ export function tooManyAsksText(asks: {
|
|
|
46
56
|
* person's own words, taken word for word with newlines folded to spaces. A question that is not a look ask is never changed: its answer is its rule.
|
|
47
57
|
* M10 am16: a shape guardrail's ask (`ask: 'check'` proposes a check, `'no-check'` found none) takes the same words: `agree` takes the proposal (and the check it
|
|
48
58
|
* carries, `check`), `drop it` leaves the rule Not checked (either kind), anything else is the person's own words (`own`: a `~` rule on the line, no check).
|
|
49
|
-
* @param {{source?: string, ask?: string, proposal?: string|null, check?: Record<string, any>}} q @param {unknown} typed
|
|
59
|
+
* @param {{source?: string, ask?: string, proposal?: string|null, check?: Record<string, any>}} q @param {unknown} typed @param {'agree'|'drop'|'rule'} [choice] M10 am29: the button used; absent = today's words reading (CLI, old files)
|
|
50
60
|
* @returns {{rule: string|null, left: boolean, check?: Record<string, any>, own?: boolean}} `rule` = the words written as a new `~` rule (null when the rule is left Not checked)
|
|
51
61
|
*/
|
|
52
62
|
export function ruleOfAnswer(q: {
|
|
@@ -54,7 +64,7 @@ export function ruleOfAnswer(q: {
|
|
|
54
64
|
ask?: string;
|
|
55
65
|
proposal?: string | null;
|
|
56
66
|
check?: Record<string, any>;
|
|
57
|
-
}, typed: unknown): {
|
|
67
|
+
}, typed: unknown, choice?: "agree" | "drop" | "rule"): {
|
|
58
68
|
rule: string | null;
|
|
59
69
|
left: boolean;
|
|
60
70
|
check?: Record<string, any>;
|
package/types/sheetfind.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export function findColumn(csvText: string, word: string): FoundHeader | FoundAs
|
|
|
13
13
|
/** a column fits when a plain number fills at least this share of the rows (F71 (b)) */
|
|
14
14
|
export const FIT_RATIO: 0.9;
|
|
15
15
|
export function columnQuestion(word: string, found: FoundAsk, line: number): string;
|
|
16
|
+
export function columnTail(line: number): string;
|
|
16
17
|
/**
|
|
17
18
|
* the word IS a column (nothing to ask)
|
|
18
19
|
*/
|