Skip to content

Commit adcdfe3

Browse files
ChanMeng666claude
andcommitted
docs: sync agent docs to v1.2.0 + add CLAUDE.md
Bring the agent-facing docs to the current shipped state so an AI agent reads an accurate, complete picture: - AGENTS.md: v1.2.0 status table (core 1.2.0, vscode 0.3.0 pending upload, 388 tests), the v1.2 capability summary, new modules, and gotchas for the shared door-swing geometry, fixture-by-category dispatch, and the import-free studio. - README.md: features now list drawn fixtures, the architectural-soundness lint rules, and dims auto; the "taste" snippet replaced with a lint-clean example (enclosed bath, real fixtures) instead of the old stop-short partition. - llms.txt: note the soundness checks, fixtures, and dims auto in the USE loop. - CLAUDE.md (new): imports AGENTS.md as the canonical source, plus the non-negotiable invariants (purity/determinism, generated files, errors-as-data) and the CLI-based verification loop. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2367832 commit adcdfe3

4 files changed

Lines changed: 109 additions & 20 deletions

File tree

AGENTS.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,25 @@ ArchLang — A small declarative language that compiles to professional SVG floo
1313

1414
## Project status & where things live (current)
1515

16-
**ArchLang is shipped and launched (v1.1.0).** This is a published, deployed monorepo —
16+
**ArchLang is shipped and launched (v1.2.0).** This is a published, deployed monorepo —
1717
not a work-in-progress. Treat the live artifacts below as the source of truth.
1818

1919
| Thing | Current | Where |
2020
|-------|---------|-------|
21-
| **Core package** | `@chanmeng666/archlang@1.1.0` (published, `latest`) | npmjs.com/package/@chanmeng666/archlang |
21+
| **Core package** | `@chanmeng666/archlang@1.2.0` (published, `latest`) | npmjs.com/package/@chanmeng666/archlang |
2222
| **Agent interface** | the `arch` **CLI** (`--json`, exit codes, stdin) + `SKILL.md` + `spec.llm.md`**no MCP** | `src/cli.ts`, `SKILL.md`, `spec.llm.md` |
23-
| **VS Code extension** | `ChanMeng.archlang@0.2.0` (published, live) | marketplace.visualstudio.com/items?itemName=ChanMeng.archlang |
23+
| **VS Code extension** | `ChanMeng.archlang@0.2.0` live on the Marketplace; **`0.3.0` packaged, pending web upload** (`editors/vscode/archlang-0.3.0.vsix`) | marketplace.visualstudio.com/items?itemName=ChanMeng.archlang |
2424
| **Playground** | deployed | https://archlang-playground.vercel.app |
2525
| **Docs site** | deployed (VitePress) | https://archlang-docs.vercel.app |
26-
| **Git** | `main`, tags `v1.0.0``v1.1.0` (latest) | github.com/ChanMeng666/archlang |
27-
| **Tests** | 371 passing (41 files); typecheck + build clean ||
26+
| **Git** | `main`, tags `v1.0.0``v1.2.0` (latest) | github.com/ChanMeng666/archlang |
27+
| **Tests** | 388 passing (42 files); typecheck + build clean ||
28+
29+
**Latest release — v1.2.0 (architectural soundness, fixtures, auto-dims).** The mechanical compiler
30+
was sound but blind to tacit architectural knowledge. v1.2 adds: four `arch lint` rules
31+
(`W_BATH_VIA_BEDROOM`, `W_ROOM_NOT_ENCLOSED`, `W_SWING_OBSTRUCTED`, `W_ROOM_NO_FIXTURE`); **drawn
32+
fixture symbols** (`furniture wc|basin|shower|bathtub|kitchen_sink|counter|fridge|stove` render real
33+
plan glyphs, with `examples/lib/fixtures.arch` as a component library); `dims auto [overall|rooms|all]`
34+
to synthesize dimension strings; and a corrected, lint-clean `examples/studio.arch`. See `CHANGELOG.md`.
2835

2936
> Beware older docs that predate the launch: `docs/IMPLEMENTATION-PLAN-v0.7-v1.0.md`
3037
> is the (now-completed) roadmap, and the earlier half of `docs/WORK-LOG.md` is
@@ -49,9 +56,13 @@ not a work-in-progress. Treat the live artifacts below as the source of truth.
4956
└─ test/ vitest: snapshot + fast-check + unit + visual-regression + CLI/describe/lint/eval
5057
```
5158

52-
Key `src/` modules added in v1.1 (all pure, exported from `src/index.ts`): `describe.ts`
53-
(semantic summary), `lint.ts` (architectural soundness rules), `analyze.ts` (shared resolve
54-
pipeline + rectilinear geometry behind both). The agent-facing CLI lives in `src/cli.ts`.
59+
Key agent-facing `src/` modules (all pure, exported from `src/index.ts`): `describe.ts`
60+
(semantic summary), `lint.ts` (architectural soundness rules — v1.2 added circulation/enclosure/
61+
swing-clearance/fixture checks), `analyze.ts` (shared resolve pipeline + rectilinear geometry —
62+
door connectivity, perimeter enclosure — behind both `describe` and `lint`). `geometry.ts` holds the
63+
shared door-swing quarter-disc geometry used by both the renderer and the linter;
64+
`elements/fixtures-glyphs.ts` (v1.2) draws the fixture symbols. The agent-facing CLI lives in
65+
`src/cli.ts`.
5566

5667
A single `npm install` at the root bootstraps every workspace.
5768

@@ -155,7 +166,16 @@ source (.arch)
155166
- **`npm run dev`** (repo root) runs `tsup --watch` (a rebuild watcher), not a web server. The
156167
playground/docs sites are separate Vite apps — use `npm run playground:dev` / `docs:dev`.
157168
- **Door `hinge left/right` is relative to the wall's traversal direction**, not the screen —
158-
so the hinge side can flip depending on the order of a wall's points.
169+
so the hinge side can flip depending on the order of a wall's points. The swing quarter-disc is
170+
computed once in `geometry.ts` (`doorSwing`) and shared by `door.render()` and the
171+
`W_SWING_OBSTRUCTED` lint rule — keep them on that one helper.
172+
- **Fixtures draw by category, not a new element kind.** `furniture.render()` dispatches the
173+
category to `elements/fixtures-glyphs.ts`; a known fixture (`wc`, `basin`, `shower`, `bathtub`,
174+
`kitchen_sink`/`sink`, `counter`, `fridge`, `stove`…) draws a symbol and ignores its `label`,
175+
anything else falls back to the labelled rectangle. The lint rules key off the **room label**
176+
(`/bath|wc|shower/i`, `/kitchen/i`) and the **fixture category** — keep those classifiers in sync.
177+
- **`examples/studio.arch` is import-free on purpose** (`test/world.test.ts` asserts the flagship
178+
compiles from a single file with no World). Use inline `furniture <fixture>` there, not imports.
159179

160180
## Reading Order
161181

CLAUDE.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# CLAUDE.md
2+
3+
Guidance for Claude Code (and any AI agent) working in this repository.
4+
5+
The **canonical, always-current** project status, architecture, commands, and conventions live in
6+
**[AGENTS.md](AGENTS.md)** — read it first. It is imported below so it loads with this file; for the
7+
exact shipped state and versions, defer to AGENTS.md → "Project status" and `CHANGELOG.md` rather
8+
than memory.
9+
10+
@AGENTS.md
11+
12+
## Orientation (the rest is in AGENTS.md)
13+
14+
- **What this is:** ArchLang — a small declarative language that compiles `.arch` floor-plan source
15+
to professional **SVG** (also DXF/PDF/PNG). Pure TypeScript, **zero runtime dependencies**,
16+
isomorphic (runs in Node and the browser). A published, deployed monorepo, not a WIP.
17+
- **Build & run:** `npm run build` · `npm test` (vitest) ·
18+
`npm run cli -- compile examples/studio.arch -o out.svg`. A single root `npm install` bootstraps
19+
every workspace.
20+
21+
## Non-negotiable invariants (break these and CI fails)
22+
23+
- **`compile()` is pure, synchronous, deterministic.** No I/O, no `Date.now()`, no `Math.random()`
24+
in `src/` core; output is byte-for-byte stable and snapshot/golden-tested. Node APIs and real time
25+
are allowed **only** in `src/cli.ts`; everything else gets its environment via the `World` seam.
26+
Route number formatting through `fmt()` so floats don't drift.
27+
- **Don't hand-edit generated files.** `dist/`, `editors/*.tmLanguage.json`,
28+
`playground/src/arch-language.js`, `docs/error-codes.md`, and `spec.llm.md` are generated — edit
29+
the source (`src/grammar/tokens.ts`, `src/error-catalog.ts`, `examples/`) and run the matching
30+
`npm run gen:grammars` / `gen:errors` / `gen:spec`. CI fails on drift.
31+
- **Errors are returned, never thrown** for user-source problems: push a `Diagnostic` with a byte
32+
`span` and a catalogued `E_*`/`W_*` code (`src/error-catalog.ts` — a test enforces every raised
33+
code has an entry and vice-versa).
34+
- **Adding an element = one module** in `src/elements/` exporting an `ElementDef`, registered in
35+
`src/elements/defs.ts`. Dispatch goes through the registry, not a switch.
36+
37+
## Verify your work the way the tool is used
38+
39+
After a change, prove it through the CLI, not by eyeballing SVG:
40+
`arch compile --json` (renders, errors-as-data) · `arch describe --json` (rooms, areas, adjacency,
41+
door connections) · `arch lint --json` (architectural soundness). Keep the flagship
42+
`examples/studio.arch` **lint-clean and import-free**, and update snapshots/goldens
43+
(`vitest -u`, `UPDATE_GOLDENS=1 vitest run test/visual.test.ts`) only after reviewing the diff.
44+
45+
## Conventions
46+
47+
Follow [Conventional Commits](https://www.conventionalcommits.org/). Run the lint/test commands
48+
before proposing changes. Commit or push only when asked. Keep AGENTS.md and this file accurate when
49+
you change build steps, structure, or conventions.

README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ is fully client-side.
4545

4646
- **Code → professional drawing.** Poché-hatched walls (by material), door swing arcs, window
4747
glazing, computed room areas, dimension lines, layers, line weights/types, a north arrow, a
48-
scale bar, and a title block.
48+
scale bar, and a title block. **Drawn fixture symbols** for WC, basin, shower, bathtub, sink,
49+
counter, fridge and stove (with a `lib/fixtures.arch` component library), and `dims auto` to
50+
synthesize dimension strings for you.
51+
- **Architectural soundness, not just syntax.** `arch lint` checks habitability *and* tacit
52+
professional knowledge: a bathroom reachable only through a bedroom, a wet room that isn't fully
53+
walled in, a door whose swing hits furniture or another door, a bath/kitchen with no fixtures, a
54+
windowless bedroom, an unenterable room, a too-narrow door. All tunable via the ruleset.
4955
- **Four export formats.** **SVG** and **DXF** with zero dependencies; **PDF** (vector,
5056
selectable text) and **PNG** (deterministic raster) via optional, lazily-loaded add-ons that
5157
the default install never pulls.
@@ -148,26 +154,33 @@ rendering an image**.
148154
[Language Reference](docs/language-reference.md)):
149155

150156
```
151-
plan "Studio 1BR" {
157+
plan "One-bed" {
152158
units mm
153159
grid 50
154160
scale 1:50
155161
north up
162+
dims auto overall
156163
157-
wall exterior thickness 200 { (0,0) (7000,0) (7000,6000) (0,6000) close }
158-
wall partition thickness 100 { (4000,0) (4000,4000) }
164+
wall exterior thickness 200 { (0,0) (6000,0) (6000,4000) (0,4000) close }
165+
wall partition thickness 100 { (4000,0) (4000,4000) } # full-height: bath stays enclosed
159166
160-
room id=r_living at (0,0) size 4000x6000 label "Living / Kitchen"
161-
room id=r_bed at (4000,0) size 3000x4000 label "Bedroom"
167+
room id=r_living at (0,0) size 4000x4000 label "Living / Kitchen"
168+
room id=r_bath at (4000,0) size 2000x4000 label "Bath"
162169
163-
door id=d_main at (1000,6000) width 1000 wall exterior hinge left swing in
164-
window at (2500,0) width 1800 wall exterior
170+
door id=d_main at (1000,4000) width 1000 wall exterior hinge left swing in
171+
door id=d_bath at (4000,1500) width 800 wall partition hinge left swing in
172+
window at (2000,0) width 1800 wall exterior
165173
166-
dim (0,6000)->(7000,6000) offset 600 text "7000"
167-
title { project "Studio Apartment" drawn_by "ArchLang" date "2026" }
174+
furniture kitchen_sink at (300,300) size 800x600 # draws a real sink symbol
175+
furniture wc at (5300,300) size 400x700 # …and a WC
176+
177+
title { project "One-bed" drawn_by "ArchCanvas" date "2026" }
168178
}
169179
```
170180

181+
> The full, lint-clean flagship example (enclosed bath off a central hall, fitted kitchen + bath,
182+
> dimension strings) is [`examples/studio.arch`](examples/studio.arch).
183+
171184
### Try it live
172185

173186
**[archlang-playground.vercel.app](https://archlang-playground.vercel.app)** — a client-side

llms.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ npx @chanmeng666/archlang lint plan.arch --json # architectural
3232
```
3333

3434
Loop: `spec` → write `.arch` → `compile --json` → if `ok:false` (exit 2) fix via each
35-
`diagnostics[].fix` → `describe --json` to confirm intent. See [SKILL.md](https://github.com/chanmeng666/archlang/blob/main/SKILL.md).
35+
`diagnostics[].fix` → `describe --json` to confirm intent → `lint --json` to confirm soundness.
36+
See [SKILL.md](https://github.com/chanmeng666/archlang/blob/main/SKILL.md).
37+
38+
`lint` catches tacit architectural mistakes, not just syntax: a bathroom reached only through a
39+
bedroom, a wet room that isn't fully walled in, a door swing hitting furniture, a bath/kitchen with
40+
no fixtures, a windowless bedroom, an unenterable room, a too-narrow door. Draw real fixtures with
41+
`furniture wc|basin|shower|bathtub|kitchen_sink|counter|fridge|stove …` (or the `lib/fixtures.arch`
42+
library), and let `dims auto` place dimension strings for you.
3643

3744
## To CONTRIBUTE (work on the repo)
3845

0 commit comments

Comments
 (0)