From adc49bde1cb7c0360a87a14a96b5880d1d5db6ec Mon Sep 17 00:00:00 2001 From: James Briggs <35938317+jamescalam@users.noreply.github.com> Date: Tue, 1 Dec 2026 18:47:41 +0800 Subject: [PATCH 1/3] Docs: with no shell, references/shepherd.md writes new pages only from page.html, its marks kept and its ledger empty; a blank ask gets the title and nothing else (docs.js blank with a shell) Co-authored-by: Pointman Co-authored-by: Claude --- README.md | 1 + docs/SKILL.md | 11 ++++- docs/assets/docs.js | 17 ++++++++ docs/references/shepherd.md | 84 +++++++++++++++++++++++++++++++++++++ tests/noshell.js | 81 +++++++++++++++++++++++++++++++++++ tests/ownership.js | 4 +- tests/run.js | 2 +- 7 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 docs/references/shepherd.md create mode 100644 tests/noshell.js diff --git a/README.md b/README.md index be54fa8..14543da 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ An agent with this skill writes a document on a space while the person watches: | `docs/SKILL.md` | Part one: the first command, and the pace | | `docs/references/outline.md` | Printed by `start`: the outline | | `docs/references/writing.md` | Printed by `outline`: sections, comments, facts, length, done | +| `docs/references/shepherd.md` | For an agent with no shell (Shepherd, or the MCP alone): new pages only, a blank page or a first draft | | `docs/references/page.html` | The starter page: no script, light and dark, A4 print | | `docs/assets/docs.js` | Every command the agent runs, so a person allows one script | | `docs/assets/blank-live-link*.html` | Spacesheep's working-on-it page, with and without its description: a space showing it counts as blank | diff --git a/docs/SKILL.md b/docs/SKILL.md index c84b049..6d8ea06 100644 --- a/docs/SKILL.md +++ b/docs/SKILL.md @@ -1,11 +1,15 @@ --- name: docs -description: Use when someone wants a document written on a page they and others will read, comment on and edit together, such as a proposal, a letter, a brief, a plan, a policy or a report. It writes the document live on a space, section by section, so the person watches it fill in, and it never changes words they typed without their yes. +description: Use when someone wants a document written on a page they and others will read, comment on and edit together, such as a proposal, a letter, a brief, a plan, a policy or a report, or a blank document they write on themselves ("a blank doc I can write on"). It writes the document live on a space, section by section, so the person watches it fill in, and it never changes words they typed without their yes. license: MIT --- # Docs +**With no shell (a Shepherd turn, or the spacesheep MCP alone), first read +references/shepherd.md (`use_skill`, or `get_skill` with `path`): it replaces the steps +below.** + **First, before you read on or decide anything:** run `node /assets/docs.js -C start `, with the space the person gave you (`start --new ""` with none), where `<folder>` is an empty folder @@ -13,6 +17,11 @@ you work in. It puts a status on the page at once and says what the space holds. it's empty, it prints how to write the outline, the next command. When it holds a document already, it lists its blocks and prints the rest of this skill. +**A blank ask** ("a blank doc I can write on", "an empty doc"): after `start`, run +`node <this skill's folder>/assets/docs.js -C <folder> blank "<title>"` in place of the +outline. The page gets the title and nothing else, open in Edit, and is the person's to +write on: send nothing more to it. + **The person watches the page fill in.** The status is your first command, ahead of all thinking; the headings follow within 30 seconds, and a new section at least every 45. Plan one section, write it, then plan the next: never plan the whole document before its diff --git a/docs/assets/docs.js b/docs/assets/docs.js index 04d61cf..d817d9c 100644 --- a/docs/assets/docs.js +++ b/docs/assets/docs.js @@ -619,6 +619,23 @@ const COMMANDS = { return 0; }, + // A blank page the person writes on themselves: the starter with its title as their first line, and nothing + // of the tool's, so no ledger. It opens in Edit; every line on it is theirs, the title too. + blank(ctx, args) { + const title = plain("title", args[0]); + if (!title) throw new Error('blank: give the title: blank "<title>"'); + const r = ctx.io.read(), html = r.files["index.html"] || ""; + if (!blank(html)) { + ctx.io.push({ status: "Stopped: this space holds a page already", stopped: true }); + throw new Error("blank: this space holds a page already, and it's never written over. Nothing changed. For a blank page, start --new in a new folder"); + } + const page = fs.readFileSync(STARTER, "utf8").replace("<title>Document", `${esc(title)}`).replace('
\n', `
\n

${esc(title)}

\n`); + ctx.io.push({ html: page }); + ctx.io.save({ parent: r.version, label: "Blank page", files: [{ path: "index.html", content: page }] }); + ctx.log("the blank page is on the space, open in Edit, and saved. Write nothing more on it: tell the person it's ready for them to type on"); + return 0; + }, + // The title and every heading, each section saying "Writing…", on open tabs and saved. outline(ctx, args) { let pages = null; diff --git a/docs/references/shepherd.md b/docs/references/shepherd.md new file mode 100644 index 0000000..bc60b90 --- /dev/null +++ b/docs/references/shepherd.md @@ -0,0 +1,84 @@ +# Docs with no shell + +Read this when you have no shell: a Spacesheep Shepherd turn, or an agent with only the +spacesheep MCP's tools. There is no docs.js, so you write the page yourself. This page +replaces SKILL.md's steps. Read this skill's files with `use_skill` (`file`, and `offset` +for the next part), or through the MCP with `get_skill` (`skill` `@spacesheep/docs`, +`path`). + +## New pages only + +docs.js is what keeps the person's words safe while it edits a page. Without it, you write +a page once and never save over it. Write only: + +- on a new space, or +- on the space you're on when its page is empty: nothing in its body, such as the app's + empty sheet, this skill's page.html with nothing typed on it, or the "working on it" page. + +A page with anything on it is the person's, even one word. Don't save it. Propose a change +in your reply (through the MCP, as a comment on its block with `create_comment`), or say +an agent with a shell can make it with the Docs skill. + +## The page + +Read references/page.html and copy it whole, from `` to ``. Change +only the `` and what goes inside `<main data-ss-id="d-doc">`. Keep its two marks +exactly as they are: + +- `<meta name="ss-edit" content="open">`: the page opens in Edit, so the person can type + on it at once, and their typing saves to the space. +- `<meta name="docs-ledger" content="">`, empty. Only docs.js fills it. Empty means every + block counts as the person's, so docs.js never rewrites one without asking. + +## A blank ask + +"A blank doc I can write on", "an empty doc", "a page for my notes": the person writes it +themselves. The page holds the title and nothing else, with no outline and no placeholders. +The title is theirs, or "Untitled document" when they named none. It goes in `<title>` and +as the one line in `<main>`: + + <main data-ss-id="d-doc"> + <h1>Packing list</h1> + </main> + +Save it (below), then reply in one line with its link: it's ready for them to type on. + +## A document + +Decide the title and three to seven headings, then write the whole document in one write, +in order: the title, the opening, then each section. It streams onto the page as you +write it, so the person watches it fill in. Read references/writing.md's "The text" and +"Facts and length" first: they hold here too. + + <h1 data-ss-id="d-title">Sublet proposal</h1> + <section data-ss-id="d-s0"> + <p data-ss-id="d-s0-1">What this is and what it asks, in one or two sentences.</p> + </section> + <section data-ss-id="d-s1"> + <h2 data-ss-id="d-s1-h">What I'm asking</h2> + <p data-ss-id="d-s1-1">To sublet from <mark class="blank" tabindex="0">[start date]</mark>.</p> + <ul data-ss-id="d-s1-2"><li>One point</li><li>Another</li></ul> + </section> + +Use only `p`, `h3`, `ul` or `ol` with `li`, `blockquote`, `strong`, `em`, `br` and +`<a href="https://…">`. Write `&` as `&` and `<` as `<`. A fact the person didn't +give is a blank: `<mark class="blank" tabindex="0">[landlord's name]</mark>`. + +## Saving it + +- **Shepherd, on the dashboard:** `create_space` with the title, πŸ“„ and the page. +- **Shepherd, on a space whose page is empty:** the whole page as your `@page` block. +- **Through the MCP:** for a new space, first `create_live_link` (`live_link`) with the + title, πŸ“„ and the status "Writing the document", and give its link in your reply at once. + Then `create_version` with the space as `space`, `files` + `[{"path": "index.html", "content": <the page>}]`, `label` "Document" (or "Blank page"), + `skill` "@spacesheep/docs" and `keep_others` true. On a space they have, read it first + with `get_file` (`index.html`), and pass the version you read as `parent`, so a change + made since is refused rather than saved over. An older connector's `deploy` takes + `uuid`, `files` and `version_name` instead. + +## After it's saved + +The page is the person's now. Never save it again, even to fix your own words. When they +ask for a change, propose it as "New pages only" says. Then reply in two or three lines: +what the document holds, and the blanks for them to fill in. diff --git a/tests/noshell.js b/tests/noshell.js new file mode 100644 index 0000000..4a22cbe --- /dev/null +++ b/tests/noshell.js @@ -0,0 +1,81 @@ +// The no-shell path (references/shepherd.md): an agent with no docs.js writes new pages only, from page.html with +// its two marks, and the ledger left empty, so docs.js counts every block on them as the person's. Its examples +// are read from shepherd.md itself, so the words and the tool can't drift apart. Loaded by tests/run.js. +"use strict"; +const assert = require("assert"); +const path = require("path"); +const fs = require("fs"); +const os = require("os"); +const { fakeSpace } = require("./fake"); + +module.exports = function ({ test, ROOT }) { + const D = require(path.join(ROOT, "docs/assets/docs.js")); + const read = (f) => fs.readFileSync(path.join(ROOT, "docs", f), "utf8"); + const starter = read("references/page.html"), guide = read("references/shepherd.md"); + const tmp = () => fs.mkdtempSync(path.join(os.tmpdir(), "docs-noshell-")); + const go = (s, dir, args) => { const lines = []; const code = D.run({ io: s.io, dir, log: (l) => lines.push(String(l)) }, args); return { code, out: lines.join("\n") }; }; + // shepherd.md's indented examples, in order: the blank page's <main>, then the document's. + const examples = guide.split(/\n\n/).filter((b) => /^ {4}</.test(b)).map((b) => b.replace(/^ {4}/gm, "")); + const MARKS = ['<meta name="ss-edit" content="open">', '<meta name="docs-ledger" content="">']; + // The page as shepherd.md says to make it: page.html whole, its title and its <main> changed, nothing else. + const pageWith = (title, main) => starter.replace("<title>Document", `${title}`).replace(/
\n<\/main>/, main); + // docs.js on a page it didn't make: every command that writes refuses, and nothing is drawn or saved. + const untouched = (page) => { + const s = fakeSpace({ "index.html": page }), dir = tmp(); + for (const args of [["start", s.id], ["outline", "T", "One"], ["blank", "T"]]) { + const r = go(s, dir, args); + assert.notStrictEqual(r.code, 0, `${args[0]}: refused`); + assert.match(r.out, /never written over/); + } + assert.strictEqual(s.files["index.html"], page); + assert.strictEqual(s.saves.length, 0); + assert.ok(!s.pushes.some((p) => p.html || p.edits), "nothing drawn on it"); + }; + + test("shepherd.md keeps both of page.html's marks, and SKILL.md sends a no-shell agent to it first", () => { + for (const m of MARKS) { assert.ok(starter.includes(m), `page.html has ${m}`); assert.ok(guide.includes(m), `shepherd.md says to keep ${m}`); } + const body = read("SKILL.md").split(/^# Docs\n/m)[1].trim(); + assert.match(body.split("\n\n")[0], /no shell[\s\S]*references\/shepherd\.md/, "the first paragraph"); + assert.strictEqual(examples.length, 2, "the blank page's main, then the document's"); + }); + + test("a blank ask: the page is page.html with the title and nothing else, as docs.js blank makes it, and the person's", () => { + const [main] = examples, title = /

([^<]+)<\/h1>/.exec(main)[1]; + const page = pageWith(title, main); + for (const m of MARKS) assert.ok(page.includes(m)); + assert.ok(!/data-ss-id="d-(?!doc)/.test(page.slice(page.indexOf(""))), "no block of the tool's"); + const s = fakeSpace(), dir = tmp(); + assert.strictEqual(go(s, dir, ["start", s.id]).code, 0); + assert.strictEqual(go(s, dir, ["blank", title]).code, 0); + assert.strictEqual(s.files["index.html"], page, "docs.js blank makes the same page"); + assert.strictEqual(s.saves.length, 1); + assert.strictEqual(D.ledgerOf(page), null, "no ledger: every line on it is the person's"); + untouched(page); + }); + + test("a first draft: page.html with the document, its ledger empty, so docs.js counts every block as the person's", () => { + const doc = examples[1], page = pageWith("Sublet proposal", `
\n${doc}\n
`); + for (const m of MARKS) assert.ok(page.includes(m)); + const tags = new Set([...doc.matchAll(/<([a-z][a-z0-9]*)/g)].map((m) => m[1])); + for (const t of tags) assert.ok(["h1", "h2", "section", "p", "h3", "ul", "ol", "li", "blockquote", "strong", "em", "br", "a", "mark"].includes(t), `the example uses only allowed tags: ${t}`); + assert.strictEqual(D.ledgerOf(page), null); + untouched(page); + }); + + test("a page a person has typed in is never saved over: docs.js blank refuses it, and shepherd.md says to save only new pages", () => { + const typed = starter.replace('
\n', '
\n

My own first line

\n'); + const s = fakeSpace({ "index.html": typed }), dir = tmp(); + assert.strictEqual(go(s, dir, ["start", s.id]).code, 0, "start reads it as blank but for their line"); + const r = go(s, dir, ["blank", "Notes"]); + assert.notStrictEqual(r.code, 0); + assert.match(r.out, /never written over/); + assert.strictEqual(s.files["index.html"], typed); + assert.strictEqual(s.saves.length, 0); + assert.ok(!s.pushes.some((p) => p.html || p.edits)); + // The person types on the blank page: it stays theirs. + untouched(pageWith("Packing list", '
\n

Packing list

\n

Socks

\n
')); + assert.match(guide, /## New pages only/); + assert.match(guide, /Never save it again/); + assert.match(guide, /`parent`/, "an MCP save onto a space names the version it read"); + }); +}; diff --git a/tests/ownership.js b/tests/ownership.js index 0a09703..e878c2a 100644 --- a/tests/ownership.js +++ b/tests/ownership.js @@ -28,7 +28,7 @@ module.exports = function ({ test, ROOT }) { return close > open ? null : best; }; // The commands every test below must cover: a new command fails this until it is in the walk. - const WALKED = ["start", "outline", "write", "blocks", "done", "edit", "comments", "reply", "propose", "apply"]; + const WALKED = ["start", "blank", "outline", "write", "blocks", "done", "edit", "comments", "reply", "propose", "apply"]; test("every command the tool has is in the person's-block walk", () => { assert.deepStrictEqual(Object.keys(D.COMMANDS).sort(), WALKED.slice().sort()); @@ -84,6 +84,7 @@ module.exports = function ({ test, ROOT }) { ["blocks", "2"], ["start", s.id], ["outline", "Another title", "Another heading"], + ["blank", "A blank page"], ["done"], ]; // The person asks for changes in comments: on their own typed block, on the tool's block, on the whole page. @@ -112,6 +113,7 @@ module.exports = function ({ test, ROOT }) { const code = D.run({ io: s.io, dir, log: (l) => lines.push(String(l)), stdin: () => stdin }, [cmd, ...rest]); if (cmd === "edit" && rest[0] !== "d-s0-1") assert.notStrictEqual(code, 0, `edit ${rest[0]}: refused, it's the person's`); if (cmd === "apply") assert.notStrictEqual(code, 0, "apply with no yes: refused"); + if (cmd === "blank") assert.notStrictEqual(code, 0, "blank on a document: refused"); if (cmd === "propose" && !proposal) { const m = /comment (\w{8})/.exec(lines.join("\n")); proposal = m && s.comments.find((c) => c.id.startsWith(m[1])).id; } check(st.slice(0, 2).join(" ")); } diff --git a/tests/run.js b/tests/run.js index 813ed33..e27b5d8 100644 --- a/tests/run.js +++ b/tests/run.js @@ -7,7 +7,7 @@ function test(name, fn) { try { fn(); pass++; console.log(`ok ${name}`); } catch (e) { fail++; console.log(`FAIL ${name}\n ${String(e && e.stack || e).split("\n").slice(0, 3).join("\n ")}`); } } -for (const f of ["ownership", "commands", "comments", "property", "review", "typed", "edit"]) { +for (const f of ["ownership", "commands", "comments", "property", "review", "typed", "edit", "noshell"]) { try { require(path.join(__dirname, f + ".js"))({ test, ROOT }); } catch (e) { fail++; console.log(`FAIL ${f}.js didn't load: ${String(e.message).split("\n")[0]}`); } } From 4b8db4cf2c795a98b6257cfed14a9c77e5df47a9 Mon Sep 17 00:00:00 2001 From: James Briggs <35938317+jamescalam@users.noreply.github.com> Date: Tue, 1 Dec 2026 18:47:41 +0800 Subject: [PATCH 2/3] Changelog: v1.0.4, Docs with no shell writes new pages only, and a blank ask is Docs, with the folder's hash Co-authored-by: Pointman Co-authored-by: Claude --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cd4176..bfe9a5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ Each release is a heading with its tag. The release workflow uses the words under it as the release's notes. +## v1.0.4 + +- Docs works with no shell (a Shepherd turn, or the spacesheep MCP alone). SKILL.md's first line sends such an agent to references/shepherd.md, which replaces the docs.js steps: the agent writes the page itself from page.html, keeping `` and the `docs-ledger` meta, so the page opens in Edit and typing on it saves to the space. +- With no shell, Docs makes new pages only: a blank page or a first draft, in one write, on a new space or on one whose page is empty. It never saves over a page that has anything on it; it proposes the change instead, or says an agent with a shell can make it. The ledger stays empty, so docs.js later counts every block on such a page as the person's and never rewrites one without a yes. +- A blank ask ("a blank doc I can write on", "an empty doc") is Docs too: the page gets its title and nothing else, open in Edit, with no outline. With a shell, `docs.js blank ""` makes the same page, and refuses a space that holds anything. +- The skill's description names a blank document the person writes themselves. +- The folder's hash is `52b2c9140fb1`. + ## v1.0.3 - Docs pages open in Edit: the page carries `<meta name="ss-edit" content="open">`, so a person who may edit it can type on it straight away, even while Docs is still writing. Docs writes around what they type and never waits for them or undoes it. From 029a0fbeee43660e20b3232956168ca3450b78b8 Mon Sep 17 00:00:00 2001 From: James Briggs <35938317+jamescalam@users.noreply.github.com> Date: Tue, 1 Dec 2026 18:54:01 +0800 Subject: [PATCH 3/3] Docs: with no shell, the MCP makes a new space with create_space and never create_version; docs.js blank writes a title with $ patterns as typed Co-authored-by: Pointman <noreply@pointman.ai> Co-authored-by: Claude <noreply@anthropic.com> --- CHANGELOG.md | 6 +++--- docs/assets/docs.js | 3 ++- docs/references/shepherd.md | 25 ++++++++++++------------- tests/noshell.js | 25 ++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe9a5e..d52d27c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,10 @@ Each release is a heading with its tag. The release workflow uses the words unde ## v1.0.4 - Docs works with no shell (a Shepherd turn, or the spacesheep MCP alone). SKILL.md's first line sends such an agent to references/shepherd.md, which replaces the docs.js steps: the agent writes the page itself from page.html, keeping `<meta name="ss-edit" content="open">` and the `docs-ledger` meta, so the page opens in Edit and typing on it saves to the space. -- With no shell, Docs makes new pages only: a blank page or a first draft, in one write, on a new space or on one whose page is empty. It never saves over a page that has anything on it; it proposes the change instead, or says an agent with a shell can make it. The ledger stays empty, so docs.js later counts every block on such a page as the person's and never rewrites one without a yes. -- A blank ask ("a blank doc I can write on", "an empty doc") is Docs too: the page gets its title and nothing else, open in Edit, with no outline. With a shell, `docs.js blank "<title>"` makes the same page, and refuses a space that holds anything. +- With no shell, Docs makes new pages only: a blank page or a first draft, in one write, on a new space or, in a Shepherd turn, on one whose page is empty. Through the spacesheep MCP it makes a new space with `create_space` and never calls `create_version`, which merges onto a space's newer edits. It never saves over a page that has anything on it; it proposes the change instead, or says an agent with a shell can make it. The ledger stays empty, so docs.js later counts every block on such a page as the person's and never rewrites one without a yes. +- A blank ask ("a blank doc I can write on", "an empty doc") is Docs too: the page gets its title and nothing else, open in Edit, with no outline. With a shell, `docs.js blank "<title>"` makes the same page, and refuses a space that holds anything. A title with `$&` or `$'` in it is written as typed. - The skill's description names a blank document the person writes themselves. -- The folder's hash is `52b2c9140fb1`. +- The folder's hash is `51887724c53f`. ## v1.0.3 diff --git a/docs/assets/docs.js b/docs/assets/docs.js index d817d9c..0c9f6ea 100644 --- a/docs/assets/docs.js +++ b/docs/assets/docs.js @@ -629,7 +629,8 @@ const COMMANDS = { ctx.io.push({ status: "Stopped: this space holds a page already", stopped: true }); throw new Error("blank: this space holds a page already, and it's never written over. Nothing changed. For a blank page, start --new in a new folder"); } - const page = fs.readFileSync(STARTER, "utf8").replace("<title>Document", `${esc(title)}`).replace('
\n', `
\n

${esc(title)}

\n`); + // Replacer functions, so a "$&" or "$'" in the title is text and not a replacement pattern. + const page = fs.readFileSync(STARTER, "utf8").replace("Document", () => `${esc(title)}`).replace('
\n', () => `
\n

${esc(title)}

\n`); ctx.io.push({ html: page }); ctx.io.save({ parent: r.version, label: "Blank page", files: [{ path: "index.html", content: page }] }); ctx.log("the blank page is on the space, open in Edit, and saved. Write nothing more on it: tell the person it's ready for them to type on"); diff --git a/docs/references/shepherd.md b/docs/references/shepherd.md index bc60b90..f0a4772 100644 --- a/docs/references/shepherd.md +++ b/docs/references/shepherd.md @@ -12,12 +12,14 @@ docs.js is what keeps the person's words safe while it edits a page. Without it, a page once and never save over it. Write only: - on a new space, or -- on the space you're on when its page is empty: nothing in its body, such as the app's - empty sheet, this skill's page.html with nothing typed on it, or the "working on it" page. +- in a Shepherd turn, on the space you're on when its page is empty: nothing in its body, + such as the app's empty sheet, this skill's page.html with nothing typed on it, or the + "working on it" page. -A page with anything on it is the person's, even one word. Don't save it. Propose a change -in your reply (through the MCP, as a comment on its block with `create_comment`), or say -an agent with a shell can make it with the Docs skill. +Through the MCP, write only new spaces. A page with anything on it is the person's, even +one word, and through the MCP so is any space that exists already. Don't save it. Propose +a change in your reply (through the MCP, as a comment on its block with `create_comment`), +or say an agent with a shell can make it with the Docs skill. ## The page @@ -68,14 +70,11 @@ give is a blank: `[landlord's name]`. - **Shepherd, on the dashboard:** `create_space` with the title, πŸ“„ and the page. - **Shepherd, on a space whose page is empty:** the whole page as your `@page` block. -- **Through the MCP:** for a new space, first `create_live_link` (`live_link`) with the - title, πŸ“„ and the status "Writing the document", and give its link in your reply at once. - Then `create_version` with the space as `space`, `files` - `[{"path": "index.html", "content": }]`, `label` "Document" (or "Blank page"), - `skill` "@spacesheep/docs" and `keep_others` true. On a space they have, read it first - with `get_file` (`index.html`), and pass the version you read as `parent`, so a change - made since is refused rather than saved over. An older connector's `deploy` takes - `uuid`, `files` and `version_name` instead. +- **Through the MCP:** a new space only. `create_space` with the title, πŸ“„, `files` + `[{"path": "index.html", "content": }]` and `label` "Document" (or "Blank + page"), then give its link in your reply. Never `create_version`: on a space that exists, + it merges your page with what's there, and the person's words with it. On a space they + have, propose the change instead, as "New pages only" says. ## After it's saved diff --git a/tests/noshell.js b/tests/noshell.js index 4a22cbe..43e676f 100644 --- a/tests/noshell.js +++ b/tests/noshell.js @@ -53,6 +53,18 @@ module.exports = function ({ test, ROOT }) { untouched(page); }); + test("docs.js blank writes a title with $ patterns as text: one , one <main>, the title escaped in both", () => { + const title = "R$&D $' $` $$ & <b>"; + const s = fakeSpace(), dir = tmp(); + assert.strictEqual(go(s, dir, ["start", s.id]).code, 0); + assert.strictEqual(go(s, dir, ["blank", title]).code, 0); + const page = s.files["index.html"], shown = D.esc(title); + assert.strictEqual(page.match(/<title>/g).length, 1, "one <title>"); + assert.strictEqual(page.match(/<main\b/g).length, 1, "one <main>"); + assert.ok(page.includes(`<title>${shown}`), "the title, as typed"); + assert.ok(page.includes(`
\n

${shown}

\n
`), "the heading, as typed, and nothing else in
"); + }); + test("a first draft: page.html with the document, its ledger empty, so docs.js counts every block as the person's", () => { const doc = examples[1], page = pageWith("Sublet proposal", `
\n${doc}\n
`); for (const m of MARKS) assert.ok(page.includes(m)); @@ -76,6 +88,17 @@ module.exports = function ({ test, ROOT }) { untouched(pageWith("Packing list", '
\n

Packing list

\n

Socks

\n
')); assert.match(guide, /## New pages only/); assert.match(guide, /Never save it again/); - assert.match(guide, /`parent`/, "an MCP save onto a space names the version it read"); + }); + + test("the MCP save makes a new space with create_space, using only fields it takes, and never saves onto one", () => { + const mcp = /- \*\*Through the MCP:\*\*([\s\S]*?)(?=\n- |\n\n|$)/.exec(guide)[1]; + assert.match(mcp, /`create_space`/); + // create_space's fields, from spacesheep's shared/doors.json: what the bullet passes must be among them. + const TAKES = ["title", "emoji", "description", "visibility", "files", "label"]; + const named = [...mcp.matchAll(/`(\w+)`(?! *:)/g)].map((m) => m[1]).filter((n) => !/^create_|^get_/.test(n)); + for (const n of named) assert.ok(TAKES.includes(n), `create_space takes ${n}`); + // create_version merges onto a space's newer edits: it's named only to forbid it. + assert.match(mcp, /Never `create_version`/); + for (const n of ["skill", "keep_others", "parent", "live_link"]) assert.ok(!mcp.includes("`" + n + "`"), `no ${n}`); }); };