@chanmeng666/archlang 0.4.0 β†’ 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,169 +1,175 @@
1
- <!-- AGENT-FIRST NOTICE -->
2
- > [!IMPORTANT]
3
- > ### πŸ€– Read this with your AI agent β€” don't read it by hand.
4
- > This repo is written agent-first. Point Claude Code, GitHub Copilot, Cursor, or any agent at it:
5
- > *"Read the README and AGENTS.md, then help me run / extend this."*
6
- > Structure + [`AGENTS.md`](AGENTS.md) are optimized for agent comprehension.
7
- <!-- /AGENT-FIRST NOTICE -->
8
-
9
- <div align="center">
10
-
11
- # ArchLang
12
-
13
- A small declarative language that compiles to professional SVG floor plans β€” like Typst/LaTeX, but for architecture.
14
-
15
- [![License](https://img.shields.io/github/license/chanmeng666/archlang?style=flat-square)](LICENSE)
16
- [![Issues](https://img.shields.io/github/issues/chanmeng666/archlang?style=flat-square)](https://github.com/chanmeng666/archlang/issues)
17
- [![Stars](https://img.shields.io/github/stars/chanmeng666/archlang?style=flat-square)](https://github.com/chanmeng666/archlang/stargazers)
18
- [![Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-EA4AAA?style=flat-square&logo=githubsponsors)](https://github.com/sponsors/ChanMeng666)
19
-
20
- </div>
21
-
22
- ## 🌟 Introduction
23
-
24
- **ArchLang** is a tiny language for floor plans. You write a `.arch` source file that
25
- *declares* a plan β€” walls, rooms, doors, windows, dimensions β€” and the compiler renders
26
- it to a clean, professional **SVG**. Think of it as **Typst/LaTeX for architecture**:
27
- text in, a precise drawing out.
28
-
29
- It is **explicit and parametric**. Every element has exact coordinates and sizes in
30
- millimetres, so the output is **deterministic** (the same source always produces the same
31
- drawing) and **editable** (changing one number changes exactly one thing). That makes it
32
- ideal both for humans and for AI agents that author or tweak plans and re-render β€” e.g.
33
- *"make the bedroom 1 m wider"* becomes a one-number diff, not a re-roll of a raster image.
34
-
35
- The compiler is **pure TypeScript with zero runtime dependencies** and runs identically in
36
- **Node and the browser** β€” so the [playground](playground/index.html) is fully client-side.
37
-
38
- > ArchLang is the floor-plan engine behind [ArchCanvas](https://github.com/chanmeng666/archcanvas),
39
- > an AI design agent β€” but it stands alone and is useful in any app or script.
40
-
41
- ## ✨ Features
42
-
43
- - **Code β†’ professional drawing.** PochΓ©-hatched walls, door swing arcs, window glazing,
44
- computed room areas, dimension lines, a north arrow, a scale bar, and a title block.
45
- - **Explicit + deterministic.** Integer-millimetre coordinates with optional **grid snapping**;
46
- byte-for-byte stable output, so renders are cacheable and testable.
47
- - **Zero dependencies, isomorphic.** Hand-written lexer + recursive-descent parser; runs in
48
- Node and the browser. No native binaries, no fonts to bundle.
49
- - **Errors as data.** `compile()` *returns* `errors`/`warnings` with line numbers β€” it never
50
- throws on bad source β€” which makes a tight authoring or LLM self-correction loop trivial.
51
- - **Library + CLI + playground.** Use the `compile()` API, the `arch` CLI, or the live editor.
52
-
53
- ## πŸš€ Getting Started
54
-
55
- ### Prerequisites
56
-
57
- - **Node.js β‰₯ 18** to use the CLI or build from source. The library itself is dependency-free
58
- and also runs in any modern browser.
59
-
60
- ### Install
61
-
62
- ```bash
63
- npm install @chanmeng666/archlang
64
- ```
65
-
66
- ### Build from source / develop
67
-
68
- ```bash
69
- npm install # install dev dependencies
70
- npm run build # build the library + CLI (dist/)
71
- npm test # run the test suite (vitest)
72
- npm run cli -- compile examples/studio.arch -o studio.svg # run the CLI from source
73
- ```
74
-
75
- ## πŸ“– Usage
76
-
77
- **As a library:**
78
-
79
- ```ts
80
- import { compile } from "@chanmeng666/archlang";
81
-
82
- const source = `
83
- plan "Tiny" {
84
- units mm
85
- grid 50
86
- wall exterior thickness 200 { (0,0) (4000,0) (4000,3000) (0,3000) close }
87
- room id=r at (0,0) size 4000x3000 label "Studio"
88
- door at (2000,3000) width 900 wall exterior hinge left swing in
89
- window at (0,1500) width 1200 wall exterior
90
- }`;
91
-
92
- const { svg, errors, warnings } = compile(source);
93
- if (errors.length) console.error(errors);
94
- else writeFileSync("tiny.svg", svg); // a finished floor plan
95
- ```
96
-
97
- **As a CLI:**
98
-
99
- ```bash
100
- arch compile floorplan.arch -o floorplan.svg # compile once
101
- arch compile floorplan.arch -w 1000 # set output width (px)
102
- arch watch floorplan.arch # recompile on save
103
- ```
104
-
105
- **A taste of the language** (see [`examples/`](examples) and the
106
- [Language Reference](docs/language-reference.md)):
107
-
108
- ```
109
- plan "Studio 1BR" {
110
- units mm
111
- grid 50
112
- scale 1:50
113
- north up
114
-
115
- wall exterior thickness 200 { (0,0) (7000,0) (7000,6000) (0,6000) close }
116
- wall partition thickness 100 { (4000,0) (4000,4000) }
117
-
118
- room id=r_living at (0,0) size 4000x6000 label "Living / Kitchen"
119
- room id=r_bed at (4000,0) size 3000x4000 label "Bedroom"
120
-
121
- door id=d_main at (1000,6000) width 1000 wall exterior hinge left swing in
122
- window at (2500,0) width 1800 wall exterior
123
-
124
- dim (0,6000)->(7000,6000) offset 600 text "7000"
125
- title { project "Studio Apartment" drawn_by "ArchLang" date "2026" }
126
- }
127
- ```
128
-
129
- ### Try it live
130
-
131
- Open [`playground/index.html`](playground/index.html) β€” a fully client-side editor with live
132
- preview, example plans, and SVG download. (After `npm install`, regenerate the browser bundle with
133
- `npx esbuild src/index.ts --bundle --format=esm --outfile=playground/lib/archlang.js`.)
134
-
135
- ## πŸ“š Documentation
136
-
137
- - **[Language Reference](docs/language-reference.md)** β€” every statement, with syntax and defaults.
138
- - **[Examples](examples)** β€” `studio.arch`, `two-bed.arch`.
139
- - **[AGENTS.md](AGENTS.md)** β€” orientation for AI agents working in this repo.
140
-
141
- ## 🀝 Contributing
142
-
143
- Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) and our
144
- [Code of Conduct](CODE_OF_CONDUCT.md). Use the issue and pull-request templates when you open one.
145
-
146
- ## ❀️ Support & Sponsor
147
-
148
- - Questions? Open a [Discussion](https://github.com/chanmeng666/archlang/discussions) or see [SUPPORT.md](SUPPORT.md).
149
- - Found a security issue? Follow [SECURITY.md](SECURITY.md).
150
- - If this project helps you, consider [sponsoring](https://github.com/sponsors/ChanMeng666) β˜•.
151
-
152
- ## πŸ“„ License
153
-
154
- Released under the [MIT](LICENSE) license.
155
-
156
- ---
157
-
158
- <!-- CHAN MENG PERSONAL BRAND -->
159
- <div align="center">
160
- <a href="https://github.com/ChanMeng666" target="_blank">
161
- <img src="./.github/brand/chan-meng-logo.svg" alt="Chan Meng" width="160" />
162
- </a>
163
-
164
- <p><strong>Chan Meng</strong><br/>Need a custom app like this one? I build them β€” let's talk.</p>
165
-
166
- <a href="mailto:chanmeng.dev@gmail.com"><img src="https://img.shields.io/badge/Email-chanmeng.dev@gmail.com-EA4335?style=flat-square&logo=gmail&logoColor=white" alt="Email Chan Meng"/></a>
167
- <a href="https://github.com/ChanMeng666"><img src="https://img.shields.io/badge/GitHub-ChanMeng666-181717?style=flat-square&logo=github&logoColor=white" alt="Chan Meng on GitHub"/></a>
168
- </div>
169
- <!-- /CHAN MENG PERSONAL BRAND -->
1
+ <!-- AGENT-FIRST NOTICE -->
2
+ > [!IMPORTANT]
3
+ > ### πŸ€– Read this with your AI agent β€” don't read it by hand.
4
+ > This repo is written agent-first. Point Claude Code, GitHub Copilot, Cursor, or any agent at it:
5
+ > *"Read the README and AGENTS.md, then help me run / extend this."*
6
+ > Structure + [`AGENTS.md`](AGENTS.md) are optimized for agent comprehension.
7
+ <!-- /AGENT-FIRST NOTICE -->
8
+
9
+ <div align="center">
10
+
11
+ # ArchLang
12
+
13
+ A small declarative language that compiles to professional SVG floor plans β€” like Typst/LaTeX, but for architecture.
14
+
15
+ [![License](https://img.shields.io/github/license/chanmeng666/archlang?style=flat-square)](LICENSE)
16
+ [![Issues](https://img.shields.io/github/issues/chanmeng666/archlang?style=flat-square)](https://github.com/chanmeng666/archlang/issues)
17
+ [![Stars](https://img.shields.io/github/stars/chanmeng666/archlang?style=flat-square)](https://github.com/chanmeng666/archlang/stargazers)
18
+ [![Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-EA4AAA?style=flat-square&logo=githubsponsors)](https://github.com/sponsors/ChanMeng666)
19
+
20
+ </div>
21
+
22
+ ## 🌟 Introduction
23
+
24
+ **ArchLang** is a tiny language for floor plans. You write a `.arch` source file that
25
+ *declares* a plan β€” walls, rooms, doors, windows, dimensions β€” and the compiler renders
26
+ it to a clean, professional **SVG**. Think of it as **Typst/LaTeX for architecture**:
27
+ text in, a precise drawing out.
28
+
29
+ It is **explicit and parametric**. Every element has exact coordinates and sizes in
30
+ millimetres, so the output is **deterministic** (the same source always produces the same
31
+ drawing) and **editable** (changing one number changes exactly one thing). That makes it
32
+ ideal both for humans and for AI agents that author or tweak plans and re-render β€” e.g.
33
+ *"make the bedroom 1 m wider"* becomes a one-number diff, not a re-roll of a raster image.
34
+
35
+ The compiler is **pure TypeScript with zero runtime dependencies** and runs identically in
36
+ **Node and the browser** β€” so the [playground](playground/index.html) is fully client-side.
37
+
38
+ > ArchLang is the floor-plan engine behind [ArchCanvas](https://github.com/chanmeng666/archcanvas),
39
+ > an AI design agent β€” but it stands alone and is useful in any app or script.
40
+
41
+ ## ✨ Features
42
+
43
+ - **Code β†’ professional drawing.** PochΓ©-hatched walls, door swing arcs, window glazing,
44
+ computed room areas, dimension lines, a north arrow, a scale bar, and a title block.
45
+ - **Explicit + deterministic.** Integer-millimetre coordinates with optional **grid snapping**;
46
+ byte-for-byte stable output, so renders are cacheable and testable.
47
+ - **Zero dependencies, isomorphic.** Hand-written lexer + recursive-descent parser; runs in
48
+ Node and the browser. No native binaries, no fonts to bundle.
49
+ - **Errors as data.** `compile()` *returns* `errors`/`warnings` with line numbers β€” it never
50
+ throws on bad source β€” which makes a tight authoring or LLM self-correction loop trivial.
51
+ - **Library + CLI + playground.** Use the `compile()` API, the `arch` CLI, or the live editor.
52
+
53
+ ## πŸš€ Getting Started
54
+
55
+ ### Prerequisites
56
+
57
+ - **Node.js β‰₯ 18** to use the CLI or build from source. The library itself is dependency-free
58
+ and also runs in any modern browser.
59
+
60
+ ### Install
61
+
62
+ ```bash
63
+ npm install @chanmeng666/archlang
64
+ ```
65
+
66
+ ### Build from source / develop
67
+
68
+ ```bash
69
+ npm install # install dev dependencies
70
+ npm run build # build the library + CLI (dist/)
71
+ npm test # run the test suite (vitest)
72
+ npm run cli -- compile examples/studio.arch -o studio.svg # run the CLI from source
73
+ ```
74
+
75
+ ## πŸ“– Usage
76
+
77
+ **As a library:**
78
+
79
+ ```ts
80
+ import { compile } from "@chanmeng666/archlang";
81
+
82
+ const source = `
83
+ plan "Tiny" {
84
+ units mm
85
+ grid 50
86
+ wall exterior thickness 200 { (0,0) (4000,0) (4000,3000) (0,3000) close }
87
+ room id=r at (0,0) size 4000x3000 label "Studio"
88
+ door at (2000,3000) width 900 wall exterior hinge left swing in
89
+ window at (0,1500) width 1200 wall exterior
90
+ }`;
91
+
92
+ const { svg, errors, warnings } = compile(source);
93
+ if (errors.length) console.error(errors);
94
+ else writeFileSync("tiny.svg", svg); // a finished floor plan
95
+ ```
96
+
97
+ **As a CLI:**
98
+
99
+ ```bash
100
+ arch compile floorplan.arch -o floorplan.svg # compile once
101
+ arch compile floorplan.arch -w 1000 # set output width (px)
102
+ arch watch floorplan.arch # recompile on save
103
+ ```
104
+
105
+ **A taste of the language** (see [`examples/`](examples) and the
106
+ [Language Reference](docs/language-reference.md)):
107
+
108
+ ```
109
+ plan "Studio 1BR" {
110
+ units mm
111
+ grid 50
112
+ scale 1:50
113
+ north up
114
+
115
+ wall exterior thickness 200 { (0,0) (7000,0) (7000,6000) (0,6000) close }
116
+ wall partition thickness 100 { (4000,0) (4000,4000) }
117
+
118
+ room id=r_living at (0,0) size 4000x6000 label "Living / Kitchen"
119
+ room id=r_bed at (4000,0) size 3000x4000 label "Bedroom"
120
+
121
+ door id=d_main at (1000,6000) width 1000 wall exterior hinge left swing in
122
+ window at (2500,0) width 1800 wall exterior
123
+
124
+ dim (0,6000)->(7000,6000) offset 600 text "7000"
125
+ title { project "Studio Apartment" drawn_by "ArchLang" date "2026" }
126
+ }
127
+ ```
128
+
129
+ ### Try it live
130
+
131
+ The [`playground/`](playground) is a Vite + CodeMirror 6 app β€” a client-side editor with syntax
132
+ highlighting, inline lint (fed by the compiler's `diagnostics`), live SVG preview, example plans,
133
+ and SVG download. Run it with:
134
+
135
+ ```bash
136
+ npm run build # build the core (the playground consumes dist/)
137
+ npm install --prefix playground
138
+ npm run dev --prefix playground # open the printed localhost URL
139
+ ```
140
+
141
+ ## πŸ“š Documentation
142
+
143
+ - **[Language Reference](docs/language-reference.md)** β€” every statement, with syntax and defaults.
144
+ - **[Examples](examples)** β€” `studio.arch`, `two-bed.arch`.
145
+ - **[AGENTS.md](AGENTS.md)** β€” orientation for AI agents working in this repo.
146
+
147
+ ## 🀝 Contributing
148
+
149
+ Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) and our
150
+ [Code of Conduct](CODE_OF_CONDUCT.md). Use the issue and pull-request templates when you open one.
151
+
152
+ ## ❀️ Support & Sponsor
153
+
154
+ - Questions? Open a [Discussion](https://github.com/chanmeng666/archlang/discussions) or see [SUPPORT.md](SUPPORT.md).
155
+ - Found a security issue? Follow [SECURITY.md](SECURITY.md).
156
+ - If this project helps you, consider [sponsoring](https://github.com/sponsors/ChanMeng666) β˜•.
157
+
158
+ ## πŸ“„ License
159
+
160
+ Released under the [MIT](LICENSE) license.
161
+
162
+ ---
163
+
164
+ <!-- CHAN MENG PERSONAL BRAND -->
165
+ <div align="center">
166
+ <a href="https://github.com/ChanMeng666" target="_blank">
167
+ <img src="./.github/brand/chan-meng-logo.svg" alt="Chan Meng" width="160" />
168
+ </a>
169
+
170
+ <p><strong>Chan Meng</strong><br/>Need a custom app like this one? I build them β€” let's talk.</p>
171
+
172
+ <a href="mailto:chanmeng.dev@gmail.com"><img src="https://img.shields.io/badge/Email-chanmeng.dev@gmail.com-EA4335?style=flat-square&logo=gmail&logoColor=white" alt="Email Chan Meng"/></a>
173
+ <a href="https://github.com/ChanMeng666"><img src="https://img.shields.io/badge/GitHub-ChanMeng666-181717?style=flat-square&logo=github&logoColor=white" alt="Chan Meng on GitHub"/></a>
174
+ </div>
175
+ <!-- /CHAN MENG PERSONAL BRAND -->