Help¶‹ PreviousNext ›
How-tos for the d2 prototype. Each one is a short list of steps; pick the task you want to do.
Guides, one topic each: Projects (creating one, members, roles and permissions) and Expressions (the expression language by example, and every core function). All help topics: Help.
Connect your AI¶
Your AI assistant can read and write this wiki, your memories, the domain and the objects through the API. It takes three things: network access, a token and the diesel2 skill.
- Let your AI reach d2. Allow
d2.aiheroapps.com(or*.aiheroapps.com) in your AI's network or web-access settings. In Claude, that's the list of allowed domains for code execution in your project or workspace. - Make a token for it. Reading is open (except in private projects), but saving needs a token. Open Tokens from your user menu in the project (or go to
/tokens), make one for your AI with a name, a level and an expiry, and give it to your AI in the chat when it asks. Never paste it into a topic or a memory; revoke it on the same page when you're done. - Install the diesel2 skill. Open diesel2, press Markdown, and save the text as
SKILL.mdin a folder nameddiesel2. Add that folder to your AI as a skill; in Claude, zip the folder and upload it as a custom skill. - Try it. Ask your AI to "list the topics in my d2 project". It should come back with Home and the rest of your project's topics.
- Let it remember. Ask it to "remember in d2 that I follow copper producers". A new entry appears under ai:memories, where you can read and correct it.
If something goes wrong, see When things go wrong.
Create a project¶
- Log in, open Home (your projects), and type a name under New project: lower-case letters, digits and dashes. It becomes the address,
<name>.aiheroapps.com. - Pick what kind of project it is: Hero (your own app, no code), Creator (you model and build) or Pro (the full kit: fiddle, flows, API). It sets the menu and the home page you start with; you can change it later in the project's Settings.
- You're its owner and admin, and it opens on its home page. Its public page (the landing) is what visitors see.
- Who can join: on the project's Members page, choose request (the default: people ask, an admin approves), open (anyone can join) or private (members only: visitors see at most the landing page, and only people an admin adds get in). Invite someone by email there too; the invite works whatever the setting.
- Bring your AI: make it a token on the project's Tokens page, see Connect your AI.
Write a wiki topic¶
- Open the Wiki and press New topic. Names are letters, digits,
-and_, with no spaces. - Write markdown on the left; the preview on the right updates as you type.
- Link a topic with
[[Frostline]]and an object with[[Company:FLR]]. A link to a topic that doesn't exist yet shows in red; click it to create that topic. - Press Save (or ⌘/Ctrl + S). The first save asks for the write token.
- To delete a topic, open it, press Edit, then Delete. It goes to the trash for 30 days, with its history, and can be restored from there.
Add a class to the domain¶
- Open mining-domain and press Edit, or write a Spec topic of your own.
- Add a line such as
$class Drone (@key id: String, @label name: String, owner: <>Company). - Save. The class appears in the model graph and the object browser.
- If the save shows problems, fix them; the object browser's home page also lists the model checks. domain-modelling has the rules.
Add or edit an object¶
- Open the class in the object browser, for example Company.
- Press New Company, or open an object and press Edit.
- Fill in the form, press Review changes, then Save. Required fields must have a value; a field marked
?in the class can stay empty.
Add an image or a file¶
- Open Files in the menu and pick one or more files: images (png, jpg, gif, webp), pdf, or text (txt, md, csv, json, yaml and other text files), up to 5 MB each.
- Add a few tags (they're how you find files again). Members only is ticked to start with: untick it for a file anyone may see, like a logo on a public page.
- Press Upload, then Copy markdown on the file and paste it into a topic.
Files are served from cdn.aidieselapps.com, a separate address, so an uploaded file can never act as a page of your project. Your AI can upload them too (the skill explains how).
Try an expression¶
- Open the Fiddle.
- Type one expression per line, for example
[1, 2, 3] map (x => x * 2), orname = valueto use it on later lines. - Results show on the right. Pick Load an example to see what the language can do.
Write a rule and run it¶
- Open the Fiddle and pick the Specs tab. hello is open: a rule that answers the message
hello.greet. - Change the greeting, for example
"Hi, ${name}!". The right side checks it as you type. Press Save. - Pick the Stories tab and hello. It sends the message and runs its
$expectlines; the one you just broke shows ✗ with what it got. - Fix the story's
$expectto match, and it runs again as you type. Save it too. - For more, pick order (guards, a discount, a rejected order) or alerts (lists, notifications, shared flow values). Runs never change your data.
Show data in a table¶
- Edit any topic (a home page, a notes page) and add a block:
```table class: Holding columns: company, shares, company.price as Price, value totals: value sort: value desc ``` - Save. The table is live: it shows the objects as they are now, each row opens its form, and + Add makes a new one.
- Columns can follow a reference (
company.price) and computed fields work like any other (@calcin the class, see diesel2).
Make an app¶
An app is a page with a free hand: your own HTML, CSS and scripts, reading and writing the project's data.
- Open the Wiki under apps and press New, or ask your AI to "make an app that shows …". An app is an
App:topic holding a whole HTML page. - In its script, get and save data with
d2.api, as whoever is looking at it:const list = await d2.api("GET", "/api/v2/dom/Holding") await d2.api("POST", "/api/v2/diesel/run", { story: "$send market.refresh", scratch: false }) - Save, and open it at
/app/<name>(the topic has an Open the app button). Link it from your home page with a card:📈 | My app | /app/<name> | what it does. - Framed or full page: by default an app opens under the top bar and scrolls inside it. Add
layout: fullto its frontmatter to give it the whole window (a console, something for your phone's home screen); a small ⌂ button leads back. - For now a full-page app runs as whoever opens it, with their login: only let people you trust edit one.
Add a live widget¶
For a small live piece inside a page (prices from the web, a chart), put HTML and a script in an ```embedhtml block. It runs in a sandbox, takes the page's colours and fonts, and sizes itself; it can fetch from sources that allow any site. d2portfolio's market cards are one.
Make your own stylesheet¶
Don't like the built-in looks? Your AI can make you a new one. A stylesheet is just a Style topic, so all it needs is Connect your AI.
- Ask your AI. For example: "In d2, make me a stylesheet called yahoo: the logo in the top bar says YAHOO, the background is dark green and the fonts are magenta."
- Let it check its work. It saves a topic
Style:yahoo. If d2 reports problems with it, the AI fixes them and saves again. - Pick it. Open Styles, find it under Style topics and press Use this stylesheet. Every page switches, the logo text included.
- Tweak it. Ask for changes ("make the links yellow"), or open the topic and edit its
styleblock yourself. Reload a page to see the result. - Go back any time: press Use this stylesheet on stylesheet-orange1, the default.
Start over¶
- Go to Home and press the red Reset all button.
- Confirm. The demo domain, its objects and every wiki topic go back to how they started, and everything you added is gone, your Style topics included.
When things go wrong¶
- "write needs a bearer token" or E_AUTH: the token is missing or wrong. In a browser, the page asks again; for your AI, give it the token again.
- Your AI says the connection is blocked:
d2.aiheroapps.comisn't allowed in its network settings yet (step 1 of Connect your AI). - E_VALIDATION when saving an object: the message names each field that doesn't fit the class. Fix those fields and save again.
- A stylesheet shows "Has errors" on Styles: the list under it says which lines are wrong. Fix the topic, or ask your AI to.
- Your changes vanished: storage is in memory for now, so a redeploy, a restart or Reset all brings back the demo. Keep anything important somewhere else as well.
- Something else: every page has a twin in the API; add
/api/v2in front of the path to see the raw JSON, for example /api/v2/dom/val/Company:FLR.