diff --git a/docs/SKILL.md b/docs/SKILL.md
index c274ec1..c84b049 100644
--- a/docs/SKILL.md
+++ b/docs/SKILL.md
@@ -18,5 +18,9 @@ thinking; the headings follow within 30 seconds, and a new section at least ever
Plan one section, write it, then plan the next: never plan the whole document before its
first section goes in.
+**The person may be typing on the page while you write.** Docs pages open in Edit for
+them. What they type is theirs: `docs.js` writes around it and never changes it, and
+`blocks` shows it. Don't wait for them to stop, and don't repeat or undo what they wrote.
+
You write text, never the page: `docs.js` turns it into the page, shows it on every open
tab and saves it. Never deploy, push or edit the page any other way.
diff --git a/docs/assets/blank-starter-1.0.html b/docs/assets/blank-starter-1.0.html
new file mode 100644
index 0000000..a906224
--- /dev/null
+++ b/docs/assets/blank-starter-1.0.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+Document
+
+
+
+
+
+
+
+
diff --git a/docs/assets/docs.js b/docs/assets/docs.js
index d6d5f20..04d61cf 100644
--- a/docs/assets/docs.js
+++ b/docs/assets/docs.js
@@ -35,6 +35,7 @@ const WRITING = path.join(__dirname, "..", "references", "writing.md");
const OUTLINE = path.join(__dirname, "..", "references", "outline.md");
const BLANK_LIVE_LINK = path.join(__dirname, "blank-live-link.html"), BLANK_LIVE_LINK_NODESC = path.join(__dirname, "blank-live-link-nodesc.html");
const BLANK_NEW_SPACE = path.join(__dirname, "blank-new-space.html");
+const BLANK_STARTER_1 = path.join(__dirname, "blank-starter-1.0.html");
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
const PLACEHOLDER = "Writing…";
const WORDS_FAR = 600; // words no A4 page of the starter holds
@@ -155,6 +156,67 @@ function ledgerMeta(html) {
const LEDGER = { exec: (html) => { const t = ledgerMeta(html); return t ? [t] : null; } };
function ledgerOf(html) { const t = ledgerMeta(html), m = t && /content="([^"]*)"/.exec(t); if (!m) return null; try { return JSON.parse(decode(m[1])); } catch { return null; } }
const ledgerTag = (L) => ``;
+// The page opens in Edit: Spacesheep's frame reads when the page loads, and
+// opens it in Edit for a person who may edit it (16 Nov 2026). The starter carries it. A page of this skill made
+// before then gets it with its next save, as part of the ledger change every save makes, right after the ledger
+// in its head; it takes effect the next time the page is opened. A page with a meta of that name already, with
+// any value, keeps it as it is. start only reads, so it never adds it.
+const EDIT_META = '';
+// An element's attributes as the browser reads its start tag: names lower-cased (ASCII only), the first of a
+// repeated name kept, values in either quote or none, separated by whitespace or "/". Values are as written;
+// attrText decodes them.
+const HTML_WS = "\t\n\f\r ";
+function attrsOf(html, el) {
+ const s = html.slice(el.start + 1 + el.name.length, el.openEnd - 1), out = new Map(), ws = (c) => HTML_WS.includes(c);
+ let i = 0;
+ while (i < s.length) {
+ while (i < s.length && (ws(s[i]) || s[i] === "/")) i++;
+ if (i >= s.length) break;
+ let j = i + 1; // a name's first character can be "="
+ while (j < s.length && !ws(s[j]) && s[j] !== "/" && s[j] !== "=") j++;
+ const name = s.slice(i, j).replace(/[A-Z]/g, (c) => c.toLowerCase());
+ i = j;
+ while (i < s.length && ws(s[i])) i++;
+ let value = "";
+ if (s[i] === "=") {
+ i++;
+ while (i < s.length && ws(s[i])) i++;
+ if (s[i] === '"' || s[i] === "'") { const k = s.indexOf(s[i], i + 1), end = k < 0 ? s.length : k; value = s.slice(i + 1, end); i = end + 1; }
+ else { let k = i; while (k < s.length && !ws(s[k])) k++; value = s.slice(i, k); i = k; }
+ }
+ if (!out.has(name)) out.set(name, value);
+ }
+ return out;
+}
+// A value as the browser decodes it, as far as comparing it with a plain ASCII name needs: numeric references,
+// with or without their ";", become their character (anything outside ASCII, or 0, as U+FFFD). No named reference
+// stands for a letter, a digit or "-", so one is left as written: a value holding one equals no plain name, as in
+// the browser.
+const attrText = (v) => v.replace(/(?:[xX]([0-9a-fA-F]+)|([0-9]+));?/g, (m, h, d) => { const n = h ? parseInt(h, 16) : parseInt(d, 10); return n > 0 && n < 0x80 ? String.fromCharCode(n) : "\uFFFD"; });
+// A meta named ss-edit as the browser sees it: an element whose tag name is exactly "meta", whose name attribute
+// (the first one) decodes to ss-edit, compared ASCII case-insensitively as meta names are. One inside a
+// isn't in the page; one in a comment or in raw text (a script, a style) isn't an element.
+function hasEditMeta(html) {
+ let found = false;
+ const look = (el) => { for (const c of el.children) {
+ if (c.name === "template") continue;
+ if (c.name === "meta" && HTML_WS.concat("/>").includes(html[c.start + 5])) {
+ const v = attrsOf(html, c).get("name");
+ if (v !== undefined && attrText(v).replace(/[A-Z]/g, (x) => x.toLowerCase()) === "ss-edit") found = true;
+ }
+ look(c);
+ } };
+ look(parse(html));
+ return found;
+}
+function editAdd(html) {
+ const t = ledgerMeta(html);
+ if (!t || hasEditMeta(html)) return "";
+ let inHead = false;
+ walk(parse(html), (e) => { if (e.name === "meta" && outer(html, e) === t && e.parent.name === "head") inHead = true; });
+ return inHead ? "\n" + EDIT_META : "";
+}
+const ledgerSwap = (html, NL) => ({ old_string: LEDGER.exec(html)[0], new_string: ledgerTag(NL) + editAdd(html) });
// Whose each block of a section is, and where the section is.
function sectionView(html, root, L, n) {
@@ -212,7 +274,7 @@ function planWrite(html, n, text) {
for (const [a, b, h] of splices.sort((x, y) => y[0] - x[0])) secNew = secNew.slice(0, a - v.sec.start) + h + secNew.slice(b - v.sec.start);
const replacements = [];
if (secNew !== secOld) replacements.push({ old_string: secOld, new_string: secNew });
- replacements.push({ old_string: LEDGER.exec(html)[0], new_string: ledgerTag(NL) });
+ replacements.push(ledgerSwap(html, NL));
return { edits, replacements, kept, changed: edits.length, ledger: NL };
}
@@ -244,7 +306,7 @@ function planBlock(html, id, text, { mine, sigWas }) {
if (rest.length) edits.push({ anchor: id, op: "insert_after", html: rest.join("\n") });
}
const secOld = outer(html, sec), secNew = secOld.slice(0, rep[0] - sec.start) + rep[2] + secOld.slice(rep[1] - sec.start);
- return { edits, replacements: [{ old_string: secOld, new_string: secNew }, { old_string: LEDGER.exec(html)[0], new_string: ledgerTag(NL) }], kept: [], ledger: NL };
+ return { edits, replacements: [{ old_string: secOld, new_string: secNew }, ledgerSwap(html, NL)], kept: [], ledger: NL };
}
// The starter with this document's title and headings, each with a placeholder, after whatever its holds
@@ -268,7 +330,7 @@ function buildPage(starter, title, headings, pages, theirTitle) {
});
const swaps = [
[/[\s\S]*?<\/title>/, () => `${esc(title)}`],
- [//, () => ledgerTag(L)],
+ [//, () => ledgerTag(L) + editAdd(starter)],
[/(]*>)([\s\S]*?)(<\/main>)/, (m, a, kept, b) => `${a}${kept.replace(/\s+$/, "")}\n${parts.join("\n")}\n${b}`],
];
let page = starter;
@@ -285,7 +347,8 @@ const spaceOf = (ctx) => { try { return fs.readFileSync(spaceFile(ctx.dir), "utf
// Blank is a short closed list of whole pages, compared after dropping whitespace: an empty file, this skill's
// starter before any outline, staging's "working on it" page (live_link, saved 14 Nov 2026) in its two forms,
// with a description line and without, whose title and description are plain-text slots, and the app's empty
-// sheet a space starts as from New space or Start from blank (saved 15 Nov 2026), whose title is a plain-text slot. Everything else is the person's page, however empty it looks: a wrong "not
+// sheet a space starts as from New space or Start from blank (saved 15 Nov 2026), whose title is a plain-text slot,
+// and the starter as Docs 1.0.0 to 1.0.2 made it, before it opened in Edit. Everything else is the person's page, however empty it looks: a wrong "not
// blank" costs one question; a wrong "blank" deletes someone's work.
const flat = (t) => String(t).replace(/\s+/g, "");
// Each slot is text only and stays where it is, in its exact tag; nothing is taken out before the comparison.
@@ -305,13 +368,14 @@ function newSpaceSlots(html) {
return titles.length === 1 && /[^<]*<\/title>/.test(html) ? html.replace(/[^<]*<\/title>/, "T") : null;
}
let BLANKS = null;
-const blanks = () => BLANKS || (BLANKS = [STARTER, BLANK_LIVE_LINK, BLANK_LIVE_LINK_NODESC, BLANK_NEW_SPACE].map((f) => flat(fs.readFileSync(f, "utf8"))));
+const blanks = () => BLANKS || (BLANKS = [STARTER, BLANK_LIVE_LINK, BLANK_LIVE_LINK_NODESC, BLANK_NEW_SPACE, BLANK_STARTER_1].map((f) => flat(fs.readFileSync(f, "utf8"))));
+const isStarter = (f) => f === blanks()[0] || f === blanks()[4];
function blank(html) {
const B = blanks(), h = flat(html), slotted = liveLinkSlots(String(html)), sf = slotted === null ? null : flat(slotted);
const ns = newSpaceSlots(String(html)), nf = ns === null ? null : flat(ns);
- return h === "" || h === B[0] || sf === B[1] || sf === B[2] || nf === B[3];
+ return h === "" || isStarter(h) || sf === B[1] || sf === B[2] || nf === B[3];
}
-// Docs' starter with lines the person typed on it, and nothing else: the app saves the first line inside the
+// Docs' starter (either form) with lines the person typed on it, and nothing else: the app saves the first line inside the
// starter's , or in above it (before 16 Nov 2026). The lines are the person's: each stays where it
// is, as it is, and the document goes after them. Text blocks only, so a picture, a frame, a script, a form, a
// handler or an id of the tool's makes the page theirs. Answers the lines with their words, or null.
@@ -350,7 +414,7 @@ function typedLines(html) {
if (!lines.length || !lines.every((el) => typedOk(html, el, true))) return null;
let rest = html;
for (const el of lines.slice().sort((a, b) => b.start - a.start)) rest = rest.slice(0, el.start) + rest.slice(el.end);
- if (flat(rest) !== blanks()[0]) return null;
+ if (!isStarter(flat(rest))) return null;
return lines.map((el) => ({ inMain: el.parent === main, text: words(inner(html, el)) }));
}
const foreign = (html) => !ledgerOf(html) && !blank(html) && !typedLines(html);
@@ -436,7 +500,7 @@ function closeRun(ctx, r, html, L) {
const NL = Object.assign({}, L, { checked: true });
const live = noopPatch(html, parse(html), L);
try {
- ctx.io.save(Object.assign({ parent: r.version, label: "Checked", replacements: [{ old_string: span, new_string: ledgerTag(NL) + span.slice(tag.length) }] }, live ? { live_patch: [live] } : {}));
+ ctx.io.save(Object.assign({ parent: r.version, label: "Checked", replacements: [{ old_string: span, new_string: ledgerTag(NL) + editAdd(html) + span.slice(tag.length) }] }, live ? { live_patch: [live] } : {}));
return true;
} catch (e) { if (!isConflict(e)) throw e; return false; }
}
@@ -578,7 +642,7 @@ const COMMANDS = {
const edit = { anchor: "d-doc", op: "append_into", html: page.slice(at, m1.closeStart).trim() };
const swap = (re) => ({ old_string: re.exec(html)[0], new_string: re.exec(page)[0] });
a = ctx.io.push({ edits: [edit] });
- try { ctx.io.save({ parent: r.version, label: "Outline", replacements: [swap(/[\s\S]*?<\/title>/), swap(LEDGER), { old_string: outer(html, m0), new_string: outer(page, m1) }], live_patch: [edit] }); }
+ try { ctx.io.save({ parent: r.version, label: "Outline", replacements: [swap(/[\s\S]*?<\/title>/), { old_string: LEDGER.exec(html)[0], new_string: LEDGER.exec(page)[0] + editAdd(html) }, { old_string: outer(html, m0), new_string: outer(page, m1) }], live_patch: [edit] }); }
catch (e) {
if (!isConflict(e)) throw e;
ctx.io.push({ edits: [...(theirs ? [] : ["d-title"]), ...["", ...headings].map((_, k) => `d-s${k}`)].map((id) => ({ anchor: id, op: "remove" })) });
@@ -657,8 +721,9 @@ const COMMANDS = {
NL.proposals = NL.proposals || {};
NL.proposals[cid] = { changes: [{ block: id, sig: sig(html, el), text: String(text) }] };
try {
- ctx.io.save({ parent: r.version, label: `Proposal on ${id}`, replacements: [{ old_string: LEDGER.exec(html)[0], new_string: ledgerTag(NL) }] });
- afterSave(ctx, html.replace(LEDGER.exec(html)[0], () => ledgerTag(NL)), null);
+ const swap = ledgerSwap(html, NL);
+ ctx.io.save({ parent: r.version, label: `Proposal on ${id}`, replacements: [swap] });
+ afterSave(ctx, html.replace(swap.old_string, () => swap.new_string), null);
ctx.log(`proposed on ${id}: comment ${cid.slice(0, 8)}. Nothing changes until the person answers yes there; then apply ${cid.slice(0, 8)}`);
return 0;
} catch (e) { if (!isConflict(e)) throw e; ctx.io.resolve(cid); }
@@ -683,7 +748,7 @@ const COMMANDS = {
});
P.changes.forEach((ch, i) => commit(ctx, `${ch.block}, as proposed`, null, (html) => {
const p = planBlock(html, ch.block, ch.text, { sigWas: ch.sig });
- if (i === P.changes.length - 1) { delete p.ledger.proposals[c.id]; p.replacements[p.replacements.length - 1] = { old_string: LEDGER.exec(html)[0], new_string: ledgerTag(p.ledger) }; }
+ if (i === P.changes.length - 1) { delete p.ledger.proposals[c.id]; p.replacements[p.replacements.length - 1] = ledgerSwap(html, p.ledger); }
return p;
}));
ctx.io.comment({ reply_to: c.id, body: AGENT + "Changed, as you said yes to." });
diff --git a/docs/references/page.html b/docs/references/page.html
index a906224..f74770d 100644
--- a/docs/references/page.html
+++ b/docs/references/page.html
@@ -6,6 +6,7 @@
Document
+