Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ The `.decoder.json` format is defined in `src/engine/schema.ts`. See `docs/ARCHI

## Use it from an agent

`skills/decoder` is an agent skill (a `SKILL.md` in the open skills format) that teaches an agent to author, validate and package exhibits with this repository. Install it into the agent you use:
`skills/decoder` is an agent skill (a `SKILL.md` in the open skills format) that teaches an agent to author, validate and package exhibits. The skill runs commands through `npx primitive-decoder`, so it works without a checkout. Install it with the open skills installer:

```sh
npx skills add Primitivelabai/decoder --skill decoder
```

Or, from a checkout, install it into the agent you use:

```sh
npm run install-skill -- claude # ~/.claude/skills/decoder
Expand All @@ -118,7 +124,7 @@ npm run install-skill -- agents # ~/.agents/skills/decoder (shared folder rea
npm run install-skill -- --dir <path>
```

The installer copies the skill and records this checkout's path beside it, so the agent knows where to run commands. Restart the agent afterwards. For an agent without skill support, give it the contents of `skills/decoder/SKILL.md` as instructions.
The checkout installer also records the checkout's path beside the skill, so the agent can open the Studio and read the built-in exhibits there. Restart the agent afterwards. For an agent without skill support, give it the contents of `skills/decoder/SKILL.md` as instructions.

Then ask for something like _"make a decoder exhibit of a bicycle derailleur"_.

Expand Down
31 changes: 14 additions & 17 deletions skills/decoder/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ Decoder turns a structured description of a system into an interactive 3D exhibi

## Where the tool lives

All commands run from the root of a decoder checkout.
Run every command with `npx primitive-decoder <command>` from the folder that holds the project file. No checkout is needed. Node.js 22.12 or newer is required.

1. If `DECODER_HOME.txt` sits next to this file, it holds the checkout path. Use it.
2. Otherwise clone `https://github.com/Primitivelabai/decoder`, then run `npm install` in it.

Node.js 22.12 or newer is required.
A checkout is needed only to open the Studio, to change the engine, or to read the built-in exhibits locally. If `DECODER_HOME.txt` sits next to this file, it holds a checkout path: there `npm run decoder -- <command>` runs the same commands from source. Otherwise clone `https://github.com/Primitivelabai/decoder` and run `npm install`.

## Core rule

Never edit renderer, Studio or runtime code to represent a subject. Everything about a subject goes in its `.decoder.json` file, using the schema in `src/engine/schema.ts` and the procedural geometry vocabulary. If a subject seems to need engine changes, simplify the model instead and record the simplification as an assumption.
Never edit renderer, Studio or runtime code to represent a subject. Everything about a subject goes in its `.decoder.json` file, using the `.decoder.json` schema ([src/engine/schema.ts](https://github.com/Primitivelabai/decoder/blob/main/src/engine/schema.ts)) and the geometry vocabulary in [GEOMETRY.md](GEOMETRY.md). If a subject seems to need engine changes, simplify the model instead and record the simplification as an assumption.

## Workflow

1. **Start a project.**
`npm run decoder -- init <name>.decoder.json "<Title>"`
Study a built-in exhibit in `src/projects/` that is close to the subject before writing your own.
`npx primitive-decoder init <name>.decoder.json "<Title>"`
Study a built-in exhibit in [src/projects/](https://github.com/Primitivelabai/decoder/tree/main/src/projects) that is close to the subject before writing your own.

2. **Describe three synchronised layers.**
- `components`: nested parts, each with `geometry`, `materialId`, `transform`, `disassembly` and `evidence`. Every geometry type, its params and defaults, plus modifiers and booleans, are listed in [GEOMETRY.md](GEOMETRY.md). Unknown params are ignored silently, so check spelling there.
Expand All @@ -33,20 +30,20 @@ Never edit renderer, Studio or runtime code to represent a subject. Everything a
- `simulation` and `behaviours`: safe declarative expressions (`sin`, `cos`, `clamp`, `lerp`, `if`, `mod`, `sliderCrank`, `conrodAngle`, lookup tables, ODEs and state machines). No code is ever evaluated.

3. **Validate until clean.**
`npm run decoder -- validate <name>.decoder.json`
`npx primitive-decoder validate <name>.decoder.json`
Fix every error on the component it names (`MISSING_MATERIAL`, `UNKNOWN_GEOMETRY_TYPE`, `INVALID_GEOMETRY_DIMENSION`, `INVALID_EXPRESSION`, `BROKEN_PARENT_REFERENCE` and so on). Treat warnings as work to do, not noise.

4. **Inspect and simulate.**
`npm run decoder -- inspect <name>.decoder.json` prints diagnostics, bounds and the disassembly plan.
`npm run decoder -- preview <name>.decoder.json` steps one cycle and prints the state table. Check that the numbers make physical sense and that units match their labels.
`npx primitive-decoder inspect <name>.decoder.json` prints diagnostics, bounds and the disassembly plan.
`npx primitive-decoder preview <name>.decoder.json` steps one cycle and prints the state table. Check that the numbers make physical sense and that units match their labels.

5. **Produce outputs.**
- Technical plate: `npm run decoder -- render <name>.decoder.json plate.svg <aesthetic>` where aesthetic is `patent`, `museum_plate`, `industrial_manual`, `scientific_journal`, `minimal_editorial` or `technical_atlas`.
- Offline exhibit: `npm run decoder -- package <name>.decoder.json exhibit.html`
- Geometry: `npm run decoder -- export <name>.decoder.json <svg|obj|stl|step|json>`
- Full check: `npm run decoder -- test <name>.decoder.json`
- Technical plate: `npx primitive-decoder render <name>.decoder.json plate.svg <aesthetic>` where aesthetic is `patent`, `museum_plate`, `industrial_manual`, `scientific_journal`, `minimal_editorial` or `technical_atlas`.
- Offline exhibit: `npx primitive-decoder package <name>.decoder.json exhibit.html`
- Geometry: `npx primitive-decoder export <name>.decoder.json <svg|obj|stl|step|json>`
- Full check: `npx primitive-decoder test <name>.decoder.json`

6. **Show it.** `npm run dev` opens the Studio at `http://127.0.0.1:3000`. Use **Studio → Import JSON** to load the project.
6. **Show it.** Open the packaged HTML in a browser. For the Studio, run `npm run dev` in a checkout: it opens at `http://127.0.0.1:3000`. Use **Studio → Import JSON** to load the project.

## Evidence discipline

Expand All @@ -65,4 +62,4 @@ Every component, relationship and project summary declares `evidence.classificat
- `validate` reports no errors.
- `preview` outputs are finite and their units are right.
- The packaged HTML opens with the network off and plays.
- Run `npm run test:core` and `npm test` if you changed anything outside the project file.
- If you changed anything outside the project file (in a checkout), run `npm run test:core` and `npm test`.
Loading