# PCB Console — Language Reference

**POCKET_CUP_BOX_CONSOLE** is the REPL inside `kernel.html`.
Type a command, press `RUN_ADMIN_CMD`. Output appears in the console below.

The PCB is part of `kernel.js` — the same interpreter runs in every page that loads the kernel, but the DOM elements (`#pcb-source`, `#pcb-output`) are only present in `kernel.html`.

---

## Hello World

```
hello
```

Plain ASCII text with no `= . (` → each character maps to a seed point via char code:

```
x = 100 + cos(i * 0.4) * charCode * 0.7
y = 100 + sin(i * 0.4) * charCode * 0.7
```

The word `hello` becomes 5 seed points spiraling outward. `buildManifold` is called immediately. The manifold reifies from your text.

Higher char codes spiral further out. Lowercase clusters tighter than uppercase.

---

## Command Dispatch

The PCB reads the input and dispatches by shape:

| Input | What happens |
|-------|-------------|
| `sys.connect(...)` | Opens Frontier channel (Claude API). Status → `FRONTIER: OPEN` |
| `manifold.([x,y,...])` | Injects coordinate pairs as seed points, calls `buildManifold` |
| Contains `=` `.` or `(` | Evaluated as live JavaScript against the kernel scope |
| Plain text — Frontier open | Sent to Claude. Response may be text or a single executable JS line |
| Plain text — Frontier closed | ASCII → orbital seed mapping → `buildManifold` |
| `E>.<3` | Injects a heart curve |

**Side effect on every run:** the char sum of the input modulates `flickerRate` and `wobbleBase`. Every command subtly reshapes the manifold's behavior.

---

## sys.connect

```
sys.connect('frontier')
```

Opens the Liminal channel. After this, plain text goes to Claude (`claude-sonnet-4-6`, max 1000 tokens).

Claude lives inside the manifold scope. It can reply in plain English **or** emit a single line of JS that is executed live. Kernel scope available to it: `wobbleBase`, `heat`, `flickerRate`, `friendList`, `scene`, `adjacency`.

If the reply contains `= . (` and no spaces, the kernel executes it automatically.

---

## manifold.([ ])

Inject seed points by coordinate pairs in draw-space (0–200):

```
manifold.([100,100, 150,80, 80,130, 120,160])
```

Each pair is `x, y`. The manifold rebuilds from these points immediately.

To inject a circle of 8 points via the REPL:

```javascript
pcb.run('manifold.([' + Array.from({length:8}, (_,i) => {
  const t = (i/8)*Math.PI*2;
  return (100+70*Math.cos(t)).toFixed(1)+','+(100+70*Math.sin(t)).toFixed(1);
}).join(',') + '])')
```

---

## Live JavaScript REPL

Any input containing `=`, `.`, or `(` is eval'd directly against the kernel scope:

```javascript
wobbleBase = 3.5
```
```javascript
heat.fill(200)
```
```javascript
flickerRate = 0.08
```
```javascript
friendList.forEach(f => f.life = 9999)
```
```javascript
buildManifold(seedPoints)
```

**Kernel scope:**

| Variable | Type | What it controls |
|----------|------|-----------------|
| `wobbleBase` | number | Per-vertex XY jitter amplitude each frame |
| `flickerRate` | number | Material opacity oscillation speed |
| `heat` | Float32Array | Per-vertex heat — drives z-displacement via oracle |
| `friendList` | Friend[] | Active agents — walk adjacency, inject heat, respawn |
| `seedPoints` | `{x,y}[]` | Current seed array |
| `originalVertices` | number[] | Rest-state vertex positions (flat xyz) |
| `adjacency` | number[][] | Vertex neighbor lists |
| `scene` | THREE.Scene | Full Three.js scene |
| `manifoldMesh` | THREE.Mesh | The manifold mesh |
| `seamLine` | THREE.Line | The diagonal seam |
| `tick` | number | Frame counter |
| `buildManifold(pts)` | function | Rebuild mesh from seed array |
| `computeManifoldPositions(pts, m)` | function | Pure Sym² math — returns flat pos array |

---

## Oracle Heuristics

Not a PCB command — the **ORACLE** input field in the workbench (or `kernelHooks.oracle` in cartridges).

An expression string evaluated per-vertex per-frame. Variables in scope: `t` (tick), `d` (radial dist * 0.001), `i` (vertex index), `heat` (Float32Array).

Result `w` multiplies heat for z-displacement:

```
z = originalZ + heat[i] * w
```

Examples:

```javascript
Math.sin(t * 0.05) * 5
```
```javascript
Math.sin(t * 0.04 + d * Math.PI) * 14
```
```javascript
0.8 + Math.log(1 + Math.max(0, heat[i])) * 0.6
```

---

## ASCII Mapping

When Frontier is closed and input has no `= . (`:

```
unworkbench
```

Each character `i` with char code `val`:
- `x = 100 + cos(i * 0.4) * val * 0.7`
- `y = 100 + sin(i * 0.4) * val * 0.7`

The points are passed to `buildManifold`. Every word is a unique manifold.

