Build

Code and working pages

The 10 tools for code and working pages. Before an agent first makes one, it reads guide topic code or pages.

create_code

Put code in a space for people to read, edit together live and review: one or more files (a script, a module, a config, a small project). People see the files in a code editor, comment on lines, and see each version as a diff. Read guide topic "code" first. To make a web page or small app people can use, use create_page instead.

Parameters

space_idstringrequired
titlestringrequired
filesobject[]required
Show child attributes
pathstringrequired
Where it goes: "src/app.ts", "README.md" (folders with /).
contentstringrequired
messagestring
What this first version is, as a commit message.

read_code

A code item's files as they are now, people's live edits included, and its version number. Pass paths to read only some; numbered: true puts line numbers in front of each line (what comments on lines refer to).

Parameters

item_idstringrequired
pathsstring[]
numberedboolean

edit_code

Change a code item's files while people may be editing them: everyone with it open sees the change at once, and it becomes a new version with your message (people see it as a diff in History). Read the files first (read_code). Prefer replace with the exact current text for small changes; write a whole file for new files or rewrites. All edits in one call are one version; if one can't apply, none do.

Parameters

item_idstringrequired
messagestringrequired
What changed and why, as a commit message: "Validate the email before sending".
editsobject[]required
Show child attributes
opstringrequired
write (a whole file, made if new), replace (exact text in a file — prefer this for small changes, so people typing elsewhere in the file are untouched), delete, rename. One of write, replace, delete, rename.
pathstring
The file. A page's or a report's edit without one is to index.html; a code item's edit needs it.
contentstring
write: the whole file.
findstring
replace: the exact text now in the file (spaces and line breaks too); include enough lines that it matches once.
replacestring
replace: what it becomes.
allboolean
replace: change every match, not just one.
tostring
rename: the new path.

code_history

The versions of a code item, a page or a report (its files), newest first: number, message, who made it (a person or an agent), when, and which files it changed. People's typing is grouped into one version per person until they pause for five minutes.

Parameters

item_idstringrequired

code_diff

A unified diff (as git diff prints it) for a code item, a page or a report: what one version changed (version), or between two versions (from, to; to "now" for the files as they are this moment, people's typing included). Pass path for one file.

Parameters

item_idstringrequired
versioninteger
What this version changed, against the one before it.
frominteger
tointeger | "now"
Default "now".
pathstring

code_restore

Put a code item's, a page's or a report's files back as they were in a version. It becomes a new version ("Restored version N"); nothing is lost — the versions after it stay in the history.

Parameters

item_idstringrequired
versionintegerrequired

create_page

Make a working web page in a space: HTML, CSS and JavaScript that run when people open it — a calculator, a quiz, a tracker, an interactive chart, a game, a simulation, custom 3D, generative art. People use it live, see its code, comment on a part of it or a line, and see each version as a diff. Give index.html (where it starts); put CSS and JavaScript in it or in files beside it (style.css, app.js) that it links. It runs in a sandbox: no localStorage or cookies, and nothing from Artifacts; libraries load from a CDN by full URL. A prototype (a product or app people click through) or a website (a landing page, a site, pricing, docs, an article): before its first write, do the steps of guide topic "prototype" or "website" in order: a template's guide, its rules, one design system read whole, the template's example. It is never designed without them, however short or simple the request. Anything else: guide topic "pages", and page-design, page-games, page-3d, page-simulations or page-art for what it is. A prototype or a website is built one part at a time: give its head, the design system's whole :root block, its styles and first finished part; edit_page adds the rest, a part a call. Run it with render_page and lint_page once it is whole.

Parameters

space_idstringrequired
titlestringrequired
kindstring
When it is one: kept on the page, so whoever changes it later reads the right guide. One of prototype, website.
htmlstringrequired
index.html: a whole document. For a large page, its head, styles and first finished part; edit_page adds the rest.
filesobject[]
Files beside it: CSS, JavaScript, JSON, SVG.
Show child attributes
pathstringrequired
Where it goes: "src/app.ts", "README.md" (folders with /).
contentstringrequired
messagestring

read_page

A working page's files (index.html and the files beside it) as they are now, people's live edits included, and its version number. numbered: true puts line numbers in front of each line.

Parameters

item_idstringrequired
pathsstring[]
numberedboolean

edit_page

Change a working page's files while people may be using or editing it (a prototype or a website, when it is still empty or is being redesigned: first the steps of guide topic "prototype" or "website", in order — a template's guide, its rules, one design system, the template's example — then one part a call): everyone with it open gets the new page at once, and it becomes a new version with your message. Same edits as edit_code (replace exact text, write a whole file, delete, rename); index.html stays. Run it with render_page after.

Parameters

item_idstringrequired
messagestringrequired
What changed, as a commit message.
editsobject[]required
Show child attributes
opstringrequired
write (a whole file, made if new), replace (exact text in a file — prefer this for small changes, so people typing elsewhere in the file are untouched), delete, rename. One of write, replace, delete, rename.
pathstring
The file. A page's or a report's edit without one is to index.html; a code item's edit needs it.
contentstring
write: the whole file.
findstring
replace: the exact text now in the file (spaces and line breaks too); include enough lines that it matches once.
replacestring
replace: what it becomes.
allboolean
replace: change every match, not just one.
tostring
rename: the new path.

render_page

Run a working page as people see it (scripts on) and check all of it in one call: JavaScript errors, console errors and failed requests; its layout at desktop and phone widths, in words (what sticks out of the frame, text cut off, images and fonts that did not load, small tap targets, leftover placeholders); and pictures of the whole page. For a prototype or a website it also gives the anti-slop findings and whether the page wears the space's brand or a design system: every must_fix is fixed before you hand over. Call it once the page is built, not after every edit. steps clicks and types through it in order — { click: "#add" }, { type: { selector: "#email", text: "a@b.co" } }, { press: "Enter" }, { scroll: 800 }, { wait: 1000 } — and shows it after them. Fix every JavaScript error before you hand a page over.

Parameters

item_idstringrequired
widthinteger
The width the pictures are taken at. Default 1280. The layout is checked at this width and at a phone's (390) either way.
heightinteger
Default 800.
from_yinteger
Where the pictures start, in px from the top (default 0). A call shows the whole page, up to eight screens; a longer page says where to continue.
picturesboolean
false: errors and layout findings only, no pictures. For re-checking after a fix.
stepsobject[]
Show child attributes
clickstring
A CSS selector to click.
typeobject
Show child attributes
selectorstringrequired
textstringrequired
pressstring
A key: "Enter", "Escape", "ArrowDown".
scrollnumber
Scroll to this y.
waitnumber
Milliseconds to wait after the step (default 400).