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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm test
- run: node bin/ai-engineering-loop.js doctor --package
- run: node bin/ai-engineering-loop.js eval
Expand All @@ -32,7 +33,9 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npm run check:skills
- run: npm run check:studio
- run: npm run audit:package
- run: npm run measure
- run: npm pack --dry-run
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
run: npm install --global npm@11.6.2
- name: Verify release identity
run: node scripts/verify-release.js "${{ inputs.tag }}"
- name: Install build tools
run: npm ci
- name: Validate package
run: npm run prepublishOnly
- name: Publish with provenance
Expand Down
10 changes: 7 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AGENTS.md: ai-engineering-loop

AEL is an npm CLI (`bin/ai-engineering-loop.js`, alias `ael`) plus host skills that run a gated engineering loop: Goal Contract -> Maker -> verification -> Devil's Advocate -> Judge -> delivery. Plain Node.js (CommonJS, Node >= 18), no build step, no runtime dependencies.
AEL is an npm CLI (`bin/ai-engineering-loop.js`, alias `ael`) plus host skills that run a gated engineering loop: Goal Contract -> Maker -> verification -> Devil's Advocate -> Judge -> delivery. Plain Node.js (CommonJS, Node >= 18), no runtime dependencies. The CLI has no build step; only Studio's browser UI is compiled (Svelte + Vite, devDependencies) into the committed `studio/app/`.

## Start here

Expand All @@ -18,12 +18,13 @@ AEL is an npm CLI (`bin/ai-engineering-loop.js`, alias `ael`) plus host skills t
| `npm run eval` | when touching `evals/` or Judge/DA policy |
| `npm run audit:package` | when touching `package.json` `files` or adding files |
| `npm run measure` | after any skill text change (T1 context budget) |
| `npm run build:studio` / `npm run check:studio` | after editing `studio/src/`, `studio/js/` or `studio/*.css` (rebuild, then check `studio/app/` matches) |

Full pre-publish gate: `npm run check:skills && npm test && npm run doctor && npm run eval && npm run audit:package`.
Full pre-publish gate: `npm run check:skills && npm run check:studio && npm test && npm run doctor && npm run eval && npm run audit:package`.

## Hard rules

- **Generated files.** `.claude/skills/ael/**` and `.agents/skills/ael/**` are built from `skill-src/` by `npm run build:skills`. Never edit them by hand; `check:skills` fails on drift.
- **Generated files.** `.claude/skills/ael/**` and `.agents/skills/ael/**` are built from `skill-src/` by `npm run build:skills`. `studio/app/**` is built from `studio/src/`, `studio/js/` and the CSS by `npm run build:studio`. Never edit them by hand; `check:skills` and `check:studio` fail on drift.
- **Agent prompts.** The Devil's Advocate and Judge prompts live in `agents/shared/*.body.md`. `.claude/agents/*.md` and `.grok/agents/*.md` must carry the same body under their own frontmatter (tested in `tests/skill-host-compat.test.js`).
- **Skill context budget.** T1 parent context (SKILL.md plus the references a T1 run reads) must stay at or under 50% of the baseline in `scripts/measure.js` (tested). Put detail in `core/*.md` (served by `ael docs <name>`) or in references that T1 does not read (`loop-commands`, `loop-report`, `loop-hosts`, `loop-risky`). `ael doctor --harness` shows the headroom.
- **Gate errors.** Every `gateError(...)` in `lib/gates.js` passes `{ why, fix }` (tested). Fixes name the exact next command.
Expand All @@ -42,6 +43,9 @@ Full pre-publish gate: `npm run check:skills && npm test && npm run doctor && np
| `lib/claimed-vs-reality.js` | claimed-vs-reality parsing and the L1/L2/L3 rules |
| `lib/cli-args.js` | flag allowlist for commands that write files |
| `skill-src/ael/` | skill template and stage references (source of truth) |
| `studio/src/` | Studio UI: Svelte components (`App.svelte`, `components/`), Vite entry |
| `studio/js/` | Studio pure helpers and the three.js kitchen scene (imported by the components and by tests) |
| `studio/app/` | built Studio served by `lib/studio-server.js` (generated, shipped) |
| `agents/` | DA, Judge, Maker specs; `agents/shared/` = runtime prompt bodies |
| `core/`, `policies/` | specs served by `ael docs <name>` |
| `schemas/` | JSON Schemas for Run artifacts |
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project are documented here. Versions follow [Semant

## Unreleased

- **Changed:** Studio's interface is rewritten in Svelte 5, compiled with Vite into `studio/app/` (committed and shipped; Svelte and Vite are devDependencies, the CLI still has no runtime dependencies). A projects snapshot now patches only the rows, labels and chips that changed instead of rebuilding the list, the Run header, the details and the ring with `innerHTML`, so focus and typed names survive refreshes and animations no longer stutter on every update.
- **Changed:** smoother kitchen: the 3D scene renders at most 1.5x device pixel ratio and drops to 1x when frames run slow, and the overlay labels read cached sizes instead of forcing a layout per label on every frame.
- **Changed:** Studio's hashed JS/CSS assets are cached by the browser for a year; the page itself still revalidates on every load. Old `/js/*.js`, `/vendor/*` and `/styles.css` URLs are gone.
- **Added:** `npm run build:studio` and `npm run check:studio` (drift check in CI and before publish).

## 3.1.0 - 2026-11-24

A busy Studio kitchen with an order book, delivery approval recorded at once, and AEL never delivers code the Judge did not see (#179, #180).
Expand Down
13 changes: 10 additions & 3 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ The vendored skill text remains authored by the original project. See the upstre

## three.js

Studio's loop ring renders with a vendored, unmodified copy of three.js. It is a shipped static file, not an npm dependency.
Studio's kitchen scene renders with a vendored, unmodified copy of three.js. The vendored files are build input: Vite bundles the parts the scene uses into the shipped Studio chunk.

- Source: https://github.com/mrdoob/three.js (npm package `three`, version 0.185.1, fetched with `npm pack three@0.185.1`)
- License: MIT, shipped as `studio/vendor/three.LICENSE`
- AEL files shipped: `studio/vendor/three.module.min.js` and the `studio/vendor/three.core.min.js` it imports, both copied from the package `build/` folder.
- License: MIT, kept as `studio/vendor/three.LICENSE` and shipped as `studio/app/licenses/three.LICENSE`
- Vendored files: `studio/vendor/three.module.min.js` and the `studio/vendor/three.core.min.js` it imports, both copied from the package `build/` folder.

## Svelte

Studio's interface is written in Svelte and compiled at build time; the small Svelte runtime is bundled into `studio/app/assets/`. Svelte is a devDependency, not a runtime dependency of the CLI.

- Source: https://github.com/sveltejs/svelte (npm package `svelte`, version 5.59.1)
- License: MIT, shipped as `studio/app/licenses/svelte.LICENSE`

## google/elephant-goldfish-model (Elephant-Goldfish Model, EGM)

Expand Down
6 changes: 4 additions & 2 deletions core/local-workflow-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ There is one Studio per machine. It writes its pid, port and URL to `~/.ai-engin

- Binds `127.0.0.1` only and rejects a non-local `Host` header.
- A random per-process token is printed once in the URL on the terminal that started Studio (with `--background` the detached process hands it to that terminal over an IPC channel); the server exchanges it for an `HttpOnly; SameSite=Strict` cookie and removes it from the address bar. The token is never written to disk: not to `studio.json`, not to `studio.log`. A request target that is not a valid URL gets `400 Bad request`.
- CSP `default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'`. Static files come from an explicit allowlist bundled in the package: no CDN, analytics or remote fonts. three.js 0.185.1 (MIT) is vendored in `studio/vendor/`.
- CSP `default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'`. Static files come only from the built app bundled in the package (`studio/app/`: the page, its hashed `assets/` and `diners.json`): no CDN, analytics or remote fonts. The interface is Svelte 5 compiled at build time; three.js 0.185.1 (MIT) is vendored in `studio/vendor/` and bundled into the lazily loaded kitchen chunk.
- Read scope: each project in the registry (`~/.ai-engineering-loop/projects.json`, `ael projects list`) and each worktree listed in its `.ai-engineering-loop/worktrees.json`, and only the `.ai-engineering-loop/` folder inside them. Symlinks out of that folder are refused. The browser never sends a path: projects are addressed by an opaque id (a hash of the real path).

## What you see
Expand Down Expand Up @@ -52,7 +52,9 @@ The named diners are a nod to people who inspired AEL, relaxing over dinner whil

Each entry needs a `name` (at most 40 characters) and may have a `note` (at most 60); Studio keeps the first 6 valid entries, drops the rest, and shows names as escaped text. When no entry is valid it falls back to `studio/diners.json`. `GET /api/me` returns the list as `diners`; there is no endpoint that writes it.

Studio polls the registered projects every 2 s and pushes a `projects` snapshot over server-sent events only when something changed. Each poll walks a Run's directory once to refuse symlinks that leave `.ai-engineering-loop/`. Studio's own page files (HTML, CSS, JS, three.js) are sent with an `ETag` and `cache-control: no-cache`, so a reload revalidates and gets `304 Not Modified` instead of the files again; files of 1 KiB or more are brotli- or gzip-compressed when the browser accepts it. API responses stay `no-store`. The kitchen's three.js module starts loading as soon as the page boots, in parallel with the first API calls.
Studio updates only what changed: each snapshot patches the affected rows, labels and chips in place instead of redrawing panels, so focus, typed text and running animations survive a refresh. The kitchen scene draws at most 1.5 device pixels per CSS pixel and drops to 1x when frames run slow; the 2D labels over it read their sizes from a `ResizeObserver` cache, so the render loop never forces a layout.

Studio polls the registered projects every 2 s and pushes a `projects` snapshot over server-sent events only when something changed. Each poll walks a Run's directory once to refuse symlinks that leave `.ai-engineering-loop/`. Studio's page is sent with an `ETag` and `cache-control: no-cache`, so a reload revalidates and picks up a new build; its content-hashed `assets/` files (JS, CSS, the three.js kitchen chunk) are cached for a year (`private, max-age=31536000, immutable`) and also answer `304 Not Modified` to a matching `ETag`; files of 1 KiB or more are brotli- or gzip-compressed when the browser accepts it. API responses stay `no-store`. The kitchen's three.js module starts loading as soon as the page boots, in parallel with the first API calls.

## Freeze

Expand Down
2 changes: 1 addition & 1 deletion lib/doctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function runDoctor(rootDir = path.join(__dirname, '..'), { projectDir = null, ru
}

const packageFiles = new Set(pkg.files || []);
const requiredPackageEntries = ['bin/', 'lib/', 'core/', 'policies/', 'recipes/', 'schemas/', 'evals/', 'studio/'];
const requiredPackageEntries = ['bin/', 'lib/', 'core/', 'policies/', 'recipes/', 'schemas/', 'evals/', 'studio/app/', 'studio/diners.json'];
const missingPackageEntries = requiredPackageEntries.filter((entry) => !packageFiles.has(entry));
checks.push(check(
'package-assets',
Expand Down
60 changes: 31 additions & 29 deletions lib/studio-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,29 @@ function recordStudioFreeze(root, runId, actor) {
}
const PING_MS = 15_000;
const ASSET_DIR = path.join(__dirname, '..', 'studio');
const STATIC_ASSETS = new Map([
['/', 'index.html'],
['/index.html', 'index.html'],
['/tokens.css', 'tokens.css'],
['/styles.css', 'styles.css'],
['/diners.json', 'diners.json'],
['/js/main.js', 'js/main.js'],
['/js/api.js', 'js/api.js'],
['/js/list.js', 'js/list.js'],
['/js/orders.js', 'js/orders.js'],
['/js/workstation.js', 'js/workstation.js'],
['/js/detail.js', 'js/detail.js'],
['/js/markdown.js', 'js/markdown.js'],
['/js/sheet.js', 'js/sheet.js'],
['/js/bot.js', 'js/bot.js'],
['/js/mood.js', 'js/mood.js'],
['/js/kitchen.js', 'js/kitchen.js'],
['/js/forms.js', 'js/forms.js'],
['/js/stations.js', 'js/stations.js'],
['/js/diners.js', 'js/diners.js'],
['/js/carriers.js', 'js/carriers.js'],
['/js/restaurant.js', 'js/restaurant.js'],
['/js/ring2d.js', 'js/ring2d.js'],
['/vendor/three.module.min.js', 'vendor/three.module.min.js'],
['/vendor/three.core.min.js', 'vendor/three.core.min.js']
]);
const APP_DIR = 'app';
const HASHED_ASSET = /^\/assets\/[A-Za-z0-9_.-]+-[A-Za-z0-9_-]{8}\.(?:js|css)$/;

function appAssets(dir = path.join(ASSET_DIR, APP_DIR)) {
const assets = new Map([
['/', `${APP_DIR}/index.html`],
['/index.html', `${APP_DIR}/index.html`],
['/diners.json', 'diners.json']
]);
let files = [];
try {
files = fs.readdirSync(path.join(dir, 'assets'), { withFileTypes: true });
} catch {
return assets;
}
for (const file of files) {
const route = `/assets/${file.name}`;
if (file.isFile() && HASHED_ASSET.test(route)) assets.set(route, `${APP_DIR}${route}`);
}
return assets;
}

let STATIC_ASSETS = appAssets();
const CONTENT_TYPES = { html: 'text/html', js: 'text/javascript', css: 'text/css', json: 'application/json' };
const CONTENT_SECURITY_POLICY = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'";
const DIAGRAM_POLICY = ["default-src 'none'", "img-src data:", "base-uri 'none'", "form-action 'none'", "frame-ancestors 'self'", 'sandbox'];
Expand Down Expand Up @@ -283,7 +280,11 @@ function etagMatches(header, etag) {
}

function serveAsset(request, response, pathname) {
const asset = STATIC_ASSETS.get(pathname);
let asset = STATIC_ASSETS.get(pathname);
if (!asset && HASHED_ASSET.test(pathname)) {
STATIC_ASSETS = appAssets();
asset = STATIC_ASSETS.get(pathname);
}
let entry;
try {
entry = asset && loadAsset(asset);
Expand All @@ -294,7 +295,8 @@ function serveAsset(request, response, pathname) {
response.writeHead(404, { 'cache-control': 'no-store' }).end('Not found');
return;
}
const headers = { 'cache-control': 'no-cache', etag: entry.etag, vary: 'accept-encoding' };
const cacheControl = HASHED_ASSET.test(pathname) ? 'private, max-age=31536000, immutable' : 'no-cache';
const headers = { 'cache-control': cacheControl, etag: entry.etag, vary: 'accept-encoding' };
if (etagMatches(request.headers['if-none-match'], entry.etag)) {
response.writeHead(304, headers).end();
return;
Expand Down Expand Up @@ -558,4 +560,4 @@ function createStudioServer({
return { server, token, close };
}

module.exports = { createStudioServer };
module.exports = { createStudioServer, appAssets };
Loading
Loading