atdoc-core 0.1.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/LICENSE +21 -0
- package/README.md +33 -0
- package/configs/atdoc-setting.json +30 -0
- package/dist/Adapters.d.ts +18 -0
- package/dist/Adapters.d.ts.map +1 -0
- package/dist/Adapters.js +484 -0
- package/dist/Adapters.js.map +1 -0
- package/dist/Lexer.d.ts +23 -0
- package/dist/Lexer.d.ts.map +1 -0
- package/dist/Lexer.js +292 -0
- package/dist/Lexer.js.map +1 -0
- package/dist/Parser.d.ts +136 -0
- package/dist/Parser.d.ts.map +1 -0
- package/dist/Parser.js +797 -0
- package/dist/Parser.js.map +1 -0
- package/dist/Serializer.d.ts +97 -0
- package/dist/Serializer.d.ts.map +1 -0
- package/dist/Serializer.js +753 -0
- package/dist/Serializer.js.map +1 -0
- package/dist/editor/monarch.d.ts +17 -0
- package/dist/editor/monarch.d.ts.map +1 -0
- package/dist/editor/monarch.js +163 -0
- package/dist/editor/monarch.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +104 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +265 -0
- package/dist/registry.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/docs/en/Block-Syntax-Specification.md +992 -0
- package/docs/en/Inline-Syntax-Specification.md +915 -0
- package/docs/en/README.md +235 -0
- package/package.json +36 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# @Doc — AI-Native Semantic Document Notation
|
|
2
|
+
|
|
3
|
+
<img src="https://wedc.cc/atd.png" width="64"/>
|
|
4
|
+
|
|
5
|
+
> 🌐 Other languages: [Traditional Chinese](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/zh-tw/README.md) ・ [Simplified Chinese](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/zh-cn/README.md) ・ [Japanese (AI translation; may contain errors)](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/ja/README.md) ・ [Korean (AI translation; may contain errors)](https://github.com/WEDC-Studio-Official/AtDoc/blob/main/docs/ko/README.md)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Every generation of document notation solved the dominant problem of its era:
|
|
10
|
+
|
|
11
|
+
| Format | Solved |
|
|
12
|
+
|:---|:---|
|
|
13
|
+
| **Word** | Editing |
|
|
14
|
+
| **HTML** | Rendering |
|
|
15
|
+
| **Markdown** | Human-friendly authoring |
|
|
16
|
+
| **JSON** | Interchange |
|
|
17
|
+
| **JSX** | Composition |
|
|
18
|
+
| **@Doc** | Semantic co-authoring between humans and AI |
|
|
19
|
+
|
|
20
|
+
None of them were designed for AI-generated content.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
**@Doc is a notation designed for three readers:**
|
|
25
|
+
|
|
26
|
+
- Humans who write content.
|
|
27
|
+
- AI that generates content.
|
|
28
|
+
- Compilers that render content.
|
|
29
|
+
|
|
30
|
+
@Doc is not the next Markdown.
|
|
31
|
+
It is the missing notation layer between LLM-generated content and render targets.
|
|
32
|
+
|
|
33
|
+
Three properties that most existing formats optimize for one or two of, but very few treat all three as first-class design goals:
|
|
34
|
+
|
|
35
|
+
| Property | Markdown | HTML | MDX | @Doc |
|
|
36
|
+
|:---|:---:|:---:|:---:|:---:|
|
|
37
|
+
| **AI Generation Stability** | ❌ | ⚠️ | ❌ | ✅ |
|
|
38
|
+
| **Token Efficiency** | ✅ | ❌ | ❌ | ✅ |
|
|
39
|
+
| **Queryable Semantics** | ❌ | ⚠️ | ⚠️ | ✅ |
|
|
40
|
+
| **Multi-target Compilation** | ❌ | ❌ | ⚠️ | ✅ |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Why Everything Else Falls Short
|
|
45
|
+
|
|
46
|
+
### Markdown — Designed for Human Writing, Not Machine Generation
|
|
47
|
+
|
|
48
|
+
LLMs read Markdown fine. The problem is the reverse: ask an LLM to **generate** Markdown for downstream parsing, and the output structure is nearly impossible to guarantee — indentation ambiguity, nested list drift, broken tables, parser dialect gaps.
|
|
49
|
+
|
|
50
|
+
Markdown has no semantic intent. It cannot express "this button is primary" or "this table needs alternating rows."
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### HTML — Structure and Presentation Collapsed Into One
|
|
55
|
+
|
|
56
|
+
HTML can express anything, at the cost of hard-coding presentation logic into structure. Need the same content rendered on a different platform? Rewrite it. Need an AI to generate stable HTML? Face the risk of hallucinated tags and unclosed elements. HTML is a render target, not a notation.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### MDX — Designed for Human Developers, Paid for by AI
|
|
61
|
+
|
|
62
|
+
MDX fuses documents with code, giving human developers maximum expressiveness. For generative models, that freedom translates into something else: higher structural unpredictability and more brittle output.
|
|
63
|
+
|
|
64
|
+
| Dimension | MDX | @Doc |
|
|
65
|
+
|:---|:---|:---|
|
|
66
|
+
| **Core Positioning** | Turns documents into programs (Code-driven) | Turns documents into semantic data (Data-driven) |
|
|
67
|
+
| **AI Generation Stability** | Allows arbitrary JS logic; LLMs easily break syntax | Deterministic grammar; LLM output is predictable |
|
|
68
|
+
| **Bracket Semantics** | `{}` `[]` `<>` overload multiple meanings | `[]` has one global meaning: **Content** |
|
|
69
|
+
| **Token Cost** | Verbose tag closing and JS boilerplate | Grammar is heavily compressed (`w-300px` instead of `w-[300px]`, planned — see the caveat in Core Syntax below) |
|
|
70
|
+
| **Error Handling** | Crashes at render time; one bad character can blank the screen | Caught at parse time; the AI can self-correct within seconds |
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## What @Doc Is
|
|
75
|
+
|
|
76
|
+
The same @Doc source compiles cleanly to Tailwind JIT HTML, inline-style HTML, or any future render target — without changing a single character of the source.
|
|
77
|
+
|
|
78
|
+
Structure and presentation are fully separated. Semantics live in the notation, not the renderer.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Core Syntax
|
|
83
|
+
|
|
84
|
+
The long-term target for every node is the same four-slot structure:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
@node(modifier){styles}[content]<action>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| Slot | Role | Example |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| `@node` | Node type | `@heading` (alias `@h`), `@paragraph` (alias `@p`), `@card` |
|
|
93
|
+
| `(modifier)` | Variant or attribute | `(primary)`, `(ja)` |
|
|
94
|
+
| `{styles}` | Styles or metadata | `{w-300px bg-fff}` |
|
|
95
|
+
| `[content]` | Content slot — **globally unique** | `[Submit]` |
|
|
96
|
+
| `<action>` | Trailing action | `<submit>`, `<install>` |
|
|
97
|
+
|
|
98
|
+
> [!NOTE]
|
|
99
|
+
> **Planned, not current grammar**: the trailing `<action>` slot is not implemented at all — `src/Lexer.ts` has no corresponding token type, and neither Block nor Inline Syntax Specification's formal EBNF defines this production. The `{w-300px bg-fff}`-style Tailwind class example for `{styles}` above is likewise illustrative, not current syntax: `{styles}` today only accepts a comma-separated list of color tokens (named colors or hex), used by `@mark`/`@color`/`@bordered` (see [Inline Syntax Specification §7](./Inline-Syntax-Specification.md#7-mark--color--bordered-styles-semantics)). Only the first three of the four slots — `@node(modifier){styles}[content]` — are currently parseable and test-covered.
|
|
100
|
+
|
|
101
|
+
`[]` has exactly one meaning everywhere in @Doc: **content**. The model never has to guess.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Example
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
@meta[
|
|
109
|
+
title = @Doc 2026 Spec
|
|
110
|
+
description = AI-native semantic document runtime
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
@heading(1)[@Doc Project Specification]
|
|
114
|
+
|
|
115
|
+
@paragraph[This is a plain paragraph, containing inline semantic nodes.]
|
|
116
|
+
|
|
117
|
+
@card(featured)[
|
|
118
|
+
@heading[AI-Native Language]
|
|
119
|
+
@paragraph[A structured markup language with deterministic grammar, designed for bidirectional AST]
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
@table[
|
|
123
|
+
@cols[id,name,price]
|
|
124
|
+
@data[
|
|
125
|
+
[1,Breakfast,60]
|
|
126
|
+
[2,Lunch,80]
|
|
127
|
+
[3,Dinner,90]
|
|
128
|
+
]
|
|
129
|
+
]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
> [!NOTE]
|
|
133
|
+
> The following nodes have been adjusted: `@seo` and `@lang` have been merged into `@meta`; `@title` now uses `@heading` (alias `@h`); `@text` now uses `@paragraph` (alias `@p`); `@btn` is temporarily deprecated. The above is a partial example — the formal specification documents are the source of truth for actual syntax.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Dual-Track Compilation
|
|
138
|
+
|
|
139
|
+
Same AST, two outputs, source code unchanged:
|
|
140
|
+
|
|
141
|
+
**Route A — Tailwind JIT**
|
|
142
|
+
```html
|
|
143
|
+
<h1 class="text-lg w-[120px]">@Doc Project Specification</h1>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Route B — Universal Inline Style**
|
|
147
|
+
```html
|
|
148
|
+
<h1 class="text-lg" style="width: 120px;">@Doc Project Specification</h1>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Dynamic values live in the AST as structured data (`{ prop: "w", value: "120px" }`), not raw strings. The adapter decides the output.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Node Taxonomy
|
|
156
|
+
|
|
157
|
+
### Core Nodes — Structural Primitives
|
|
158
|
+
The document skeleton, atoms that can't be broken down further.
|
|
159
|
+
|
|
160
|
+
`@heading` (alias `@h`) `@paragraph` (alias `@p`) `@quote` `@code` `@list` `@img` `@table`
|
|
161
|
+
|
|
162
|
+
### Semantic Nodes — Semantic Containers
|
|
163
|
+
Two behavior modes:
|
|
164
|
+
|
|
165
|
+
- **Inline Semantic** — renders as a tagged inline element: `@mark[important]`, `@link(example.com)[link]`
|
|
166
|
+
- **Block Metadata** — injects host configuration, renders no HTML: `@meta[key = value]`
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## For AI Developers
|
|
171
|
+
|
|
172
|
+
Having an LLM generate HTML directly is fragile. @Doc gives the model a constrained, deterministic grammar. Errors surface at parse time, not render time.
|
|
173
|
+
|
|
174
|
+
Because `[]` is the only content bracket, the model has nothing to collide with.
|
|
175
|
+
|
|
176
|
+
Token cost is also lower: `w-300px` instead of Tailwind's arbitrary-value syntax `w-[300px]` — the bracket is restored by the compiler, not burned on generation (planned; `{styles}` currently only supports color tokens, see the Core Syntax note above).
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## For Web Developers
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
import { tokenize } from './Lexer';
|
|
184
|
+
import { DocParser } from './Parser';
|
|
185
|
+
import { DocTranspiler } from './Adapters';
|
|
186
|
+
|
|
187
|
+
const tokens = tokenize(source);
|
|
188
|
+
const ast = new DocParser(tokens).parse();
|
|
189
|
+
const html = ast.map(node => DocTranspiler.toTailwindHTML(node)).join('\n');
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Feed in @Doc source, get a structured AST out, and render it with an adapter that matches your stack. Parser and Adapters drop straight into your pipeline with no extra dependencies.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Design Boundaries
|
|
197
|
+
|
|
198
|
+
@Doc is intentionally not a programming language. That's not a limitation — it's a weapon.
|
|
199
|
+
|
|
200
|
+
- No variables
|
|
201
|
+
- No conditionals
|
|
202
|
+
- No loops
|
|
203
|
+
- No macro system
|
|
204
|
+
|
|
205
|
+
Logic lives in the host application. @Doc owns structure, not behavior. That boundary is what makes AI-generated output permanently predictable. The line is intentional and will not move.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Status
|
|
210
|
+
|
|
211
|
+
The core Parser, Lexer, and dual-track adapters are functionally usable. The web-native Lexer and Parser are in active development. An interactive Playground and a CLI tool are on the near-term roadmap.
|
|
212
|
+
|
|
213
|
+
@Doc exists to explore the design space between LLM output and render targets. The core is functional. The rest is being built in the open.
|
|
214
|
+
|
|
215
|
+
**Target: 1.0 Production release on January 1, 2027.**
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## What's in here
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
src/ Lexer, Parser, registry (single source of truth for nodes), Adapters (two HTML render routes)
|
|
223
|
+
src/editor/ Monarch tokenizer for Monaco-style editors
|
|
224
|
+
tests/ Strict Mode test cases for the Lexer/Parser, plus render verification for each node
|
|
225
|
+
configs/ Node configuration for editor/tooling
|
|
226
|
+
*-Specification.md The authoritative grammar of the language (EBNF + semantic rules)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The two `*-Specification.md` files are the authoritative grammar. Code comments occasionally cite per-node companion docs (`Structural-Blocks.md`, `Container-Blocks.md`, …) that aren't part of the v0.1 drop — everything they cover is in the two specifications.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
MIT — see [LICENSE](../../LICENSE).
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "atdoc-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/WEDC-Studio-Official/AtDoc.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/WEDC-Studio-Official/AtDoc",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/",
|
|
13
|
+
"configs/",
|
|
14
|
+
"docs/en/"
|
|
15
|
+
],
|
|
16
|
+
"description": "@Doc — Lexer/Parser/Adapters/registry for the @Doc document language, plus the Monarch editor tokenizer.",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
|
|
21
|
+
"./registry": { "types": "./dist/registry.d.ts", "default": "./dist/registry.js" },
|
|
22
|
+
"./types": { "types": "./dist/types.d.ts", "default": "./dist/types.js" },
|
|
23
|
+
"./Lexer": { "types": "./dist/Lexer.d.ts", "default": "./dist/Lexer.js" },
|
|
24
|
+
"./Parser": { "types": "./dist/Parser.d.ts", "default": "./dist/Parser.js" },
|
|
25
|
+
"./Adapters": { "types": "./dist/Adapters.d.ts", "default": "./dist/Adapters.js" },
|
|
26
|
+
"./editor/monarch": { "types": "./dist/editor/monarch.d.ts", "default": "./dist/editor/monarch.js" }
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.json",
|
|
30
|
+
"prepublishOnly": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^26.1.1",
|
|
34
|
+
"typescript": "^7.0.2"
|
|
35
|
+
}
|
|
36
|
+
}
|