docs: align skill and docs with ext/web W7+P3 completion
Update Marqdo AI skill (SKILL/reference/examples) with ext/web authoring rules and API summary; reconcile web-net-capabilities conclusions and blog checklist with shipped W0–W7+P3 surface. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
eafa203205
commit
4956460773
12 files changed
+352
-127
No files matched your search
@@ -4,8 +4,9 @@ description: >-
|
||||
Author and edit Marqdo programs (.mq.md): Markdown markers are executable
|
||||
syntax (functions, calls, statements, returns, control flow). Use when writing
|
||||
or modifying .mq.md files, teaching Marqdo, generating Marqdo from prose,
|
||||
importing lib/*, running marqdo CLI, or when the user mentions Marqdo,
|
||||
mq.md, markup-as-syntax, or code-as-documentation.
|
||||
importing lib/* or ext/web, running marqdo CLI, building dynamic sites with
|
||||
ext/web, or when the user mentions Marqdo, mq.md, markup-as-syntax,
|
||||
code-as-documentation, or web/网页 extension.
|
||||
---
|
||||
|
||||
# Marqdo development
|
||||
@@ -132,13 +133,50 @@ import clock:lib/time.mq.md
|
||||
- Instance methods stay `` > `obj`.method `` (backticks on the receiver only).
|
||||
- `lib/…` resolves via `MARQDO_LIB`, cwd `lib/`, or `lib/` next to the `marqdo` binary.
|
||||
- Design: [module-namespace.md](../../doc/design/module-namespace.md).
|
||||
- Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm` / `add agent` (see `doc/design/ext-cli.md`). `ext/llm` — chat; `ext/agent` — document-driven agents: **step** (default writeback) / **plan** workbook ([ext-agent.md](../../doc/design/ext-agent.md), [ext-agent-plan.md](../../doc/design/ext-agent-plan.md)).
|
||||
- Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm|agent|web|quantum` (see `doc/design/ext-cli.md`). `ext/llm` — chat; `ext/agent` — document-driven agents: **step** (default writeback) / **plan** workbook ([ext-agent.md](../../doc/design/ext-agent.md), [ext-agent-plan.md](../../doc/design/ext-agent-plan.md)); **`ext/web`** — dynamic sites (W0–W7 + P3 complete; see below).
|
||||
- Native plugins: `lib/plugin` — `## load` / `unload` / `list`. C ABI: `include/marqdo_abi.h`.
|
||||
- Prefer `table.put` / `表.改` for list/map element updates; keep `json` for parse/stringify/quote (see `doc/design/stdlib-table.md`).
|
||||
- Builtins (no import): `print`/`打印`, `input`/`输入`, `len`/`长度`, `str`/`文本`, `int`/`整数`; literals `True`/`真`, `False`/`假`, `None`/`空`; logic `and`/`且`, `or`/`或`, `not`/`非`.
|
||||
|
||||
Stdlib map: [reference.md](reference.md).
|
||||
|
||||
## Official extension: `ext/web` (dynamic sites)
|
||||
|
||||
Install: `marqdo ext add web` (ZH id: `网页`). Build native plugin first: `cargo build --release -p marqdo_plugin_web`.
|
||||
|
||||
Import **one language file** — never mix EN/ZH API names in the same `.mq.md`:
|
||||
|
||||
- EN: `import web:ext/web/web.mq.md`
|
||||
- ZH: `导入 网页:ext/web/网页.mq.md`
|
||||
|
||||
**Hard rules (web):**
|
||||
|
||||
- Authors use **GFM tables + `#` classes** — no `json.parse` / `json.set` glue, no hand-built part JSON.
|
||||
- Table cells stay **literal strings**; path text like `` `posts`.`title` `` is resolved by web classes.
|
||||
- **`ext/**` never calls `host_*`** — hot path is native `plugins/web` ABI.
|
||||
- HTTPS: terminate at reverse proxy; set `cookie_secure=True` on auth (no in-process TLS).
|
||||
|
||||
**Typical layout:**
|
||||
|
||||
```text
|
||||
index.mq.md # entry + home page table + listen
|
||||
pages/ # sub-pages
|
||||
components/ # reusable |属性|值|样式| tables
|
||||
styles/ # CSS modules
|
||||
db/ # schema + open/init
|
||||
data/ # sqlite runtime (gitignore)
|
||||
```
|
||||
|
||||
**Core objects (EN / ZH):** `# page`/`页面`, `# style`/`样式`, `# db`/`数据库`, `# form`/`表单`, `# app`/`应用`, `# auth`/`鉴权`, `# cache`/`缓存`, `# storage`/`存储`.
|
||||
|
||||
**Typical flow:** `db.init` → `page.compose_components` + `page.compose_main` → `page.render` → `app` with `route` / `static` / `configure` / `listen`.
|
||||
|
||||
**Shipped surface (W0–W7 + P3):** middleware + JSON API (`app.configure`); transactions, pagination, FTS search (`db.migrate`, `db.fts`, `db.search`); security (argon2, CSRF, SQLite sessions, login rate limit); SEO / RSS / Markdown (`page.meta`, `route_rss`, `lib/net.markdown_parse`); upload / download / gallery; sitemap / robots / error pages / redirects; RBAC (`app.gate`, user `role`); audit timestamps + FK in `db.init`; ETag on downloads.
|
||||
|
||||
Design: [ext-web.md](../../doc/design/ext-web.md) · capability matrix: [web-net-capabilities.md](../../doc/design/web-net-capabilities.md) · example: [examples/marqdo-blog/](../../examples/marqdo-blog/).
|
||||
|
||||
Web patterns: [examples.md](examples.md) §13 · API index: [reference.md](reference.md).
|
||||
|
||||
## AI authoring workflow
|
||||
|
||||
1. Decide language surface (English builtins + `lib/text.mq.md`, or Chinese + `lib/文本.mq.md`).
|
||||
@@ -160,6 +198,9 @@ Stdlib map: [reference.md](reference.md).
|
||||
| Forgetting `---` after nested `##` helper | Add `---` / `***` / `****` |
|
||||
| Import `lib/text` then call bare `split` | `> text.split …` (qualified) |
|
||||
| Import `lib/text` then call `拆分` | Match file language (`text.split`, not 文本) |
|
||||
| `json.set` to build page parts | GFM tables + `page.compose_*` / `web.page` methods |
|
||||
| Mix `web.page` and `网页.页面` in one file | One import language per `.mq.md` |
|
||||
| Call `host_web_*` from `ext/web` | Use `# app` / `# db` methods; plugin ABI only |
|
||||
|
||||
## Checklist before finishing
|
||||
|
||||
@@ -169,4 +210,5 @@ Stdlib map: [reference.md](reference.md).
|
||||
- [ ] `# main` exists when the file is an entry program
|
||||
- [ ] Nested functions ended with `---` / `***` / `****` when needed
|
||||
- [ ] Imports and call names share the same language file
|
||||
- [ ] Web sites: tables + web classes only (no JSON glue); `data/` gitignored
|
||||
- [ ] `marqdo run` succeeds (or errors addressed)
|
||||
@@ -232,3 +232,42 @@ if x > 0:
|
||||
2. *
|
||||
> print text=y-other
|
||||
```
|
||||
|
||||
## 13. Dynamic site (ext/web, minimal)
|
||||
|
||||
```markdown
|
||||
---
|
||||
title: hello-site
|
||||
import web:ext/web/web.mq.md
|
||||
import db:db/index.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`shell` =
|
||||
|
||||
| 组件 | 样式 |
|
||||
|------|------|
|
||||
| nav | |
|
||||
|
||||
`main` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| title | posts.title | |
|
||||
| body | posts.summary | |
|
||||
|
||||
*store = > db.open*
|
||||
*css = "body{font-family:sans-serif}"*
|
||||
*page = > web.page title="Hello"*
|
||||
*page = > page.compose_components components=`shell`*
|
||||
*page = > page.compose_main main=`main`*
|
||||
*page = > page.css css=`css`*
|
||||
*app = > web.app page=`page` port=8080*
|
||||
*app = > app.static prefix="/static" dir="static"*
|
||||
> listen app=`app`
|
||||
```
|
||||
|
||||
- Import `ext/web/web.mq.md` **or** `ext/web/网页.mq.md` — not both; match API language to the file.
|
||||
- Full blog/CMS patterns: `examples/marqdo-blog/` (routes, SEO, RSS, auth, upload, WS).
|
||||
- Run after `marqdo ext add web` and building `marqdo_plugin_web`.
|
||||
@@ -12,8 +12,8 @@ marqdo view PATH # docs browser, default port 7429
|
||||
marqdo debug PATH # debugger UI, default port 7430
|
||||
marqdo catalog PATH -o .marqdo
|
||||
marqdo ext list
|
||||
marqdo ext add llm|agent
|
||||
marqdo ext remove llm|agent
|
||||
marqdo ext add llm|agent|web|quantum
|
||||
marqdo ext remove llm|agent|web|quantum
|
||||
```
|
||||
|
||||
Diagnostics look like `path:line:col: message` (1-based line/col).
|
||||
@@ -54,9 +54,29 @@ Import one file; use **that** file’s function names.
|
||||
| `lib/foreign.mq.md` | `lib/外联.mq.md` | run foreign fenced blocks |
|
||||
| `ext/llm.mq.md` | `ext/大模型.mq.md` | `# llm` / `# 大模型` object + chat methods |
|
||||
| `ext/agent.mq.md` | `ext/智能体.mq.md` | agent **framework** (layout now; LLM orchestration roadmap in `ext-agent.md`) |
|
||||
| `ext/web/web.mq.md` | `ext/web/网页.mq.md` | dynamic sites — see **ext/web** section below |
|
||||
|
||||
Open the imported `.mq.md` under `lib/` or `ext/` to see exact `##` / `#` names and parameters. Gold tests: `tests/lib/`, `tests/structure/`, `tests/ext/`.
|
||||
|
||||
## ext/web (dynamic sites)
|
||||
|
||||
Install: `marqdo ext add web` (`网页`). Native: `cargo build --release -p marqdo_plugin_web`.
|
||||
|
||||
| EN import | ZH import | Core types |
|
||||
|-----------|-----------|------------|
|
||||
| `ext/web/web.mq.md` | `ext/web/网页.mq.md` | `# page` `# style` `# db` `# form` `# app` `# auth` `# cache` `# storage` |
|
||||
|
||||
| Area | EN methods (representative) | Notes |
|
||||
|------|----------------------------|-------|
|
||||
| Page | `compose_components`, `compose_main`, `render`, `meta`, `paginate` | GFM tables; cells are literal path strings |
|
||||
| DB | `init`, `insert`, `select`, `paginate`, `get`, `update`, `delete`, `migrate`, `fts`, `search`, `count`, `事务`/`txn` | init supports `unique`/`index`/`fk`; auto `created_at`/`updated_at` |
|
||||
| App | `route`, `static`, `configure`, `listen`, `auth`, `gate`, `upload`, `download`, `gallery`, `route_rss`, `redirect`, `error_page`, `sitemap`, `robots` | W0–W7 + P3 complete |
|
||||
| Auth | `login`, `check`, `logout`, `hash_password` | argon2 + CSRF + SQLite sessions; `role` for RBAC |
|
||||
|
||||
Drivers (Postgres / Redis / S3): `db url=postgres://…`, `cache url=memory:`, `storage url=file:…` — see `doc/design/ext-web-drivers.md`.
|
||||
|
||||
Example project: `examples/marqdo-blog/`. Capability matrix: `doc/design/web-net-capabilities.md`.
|
||||
|
||||
## Formula + plot (math)
|
||||
|
||||
```markdown
|
||||
@@ -132,4 +152,6 @@ See `doc/design/call-arguments.md`.
|
||||
| `doc/design/ext-llm.md` | `ext/llm` |
|
||||
| `doc/design/ext-agent.md` | `ext/agent` agent **framework** (layout shipped; LLM orchestration roadmap) |
|
||||
| `doc/design/ext-cli.md` | `marqdo ext list/add/remove` |
|
||||
| `doc/design/ext-web.md` | `ext/web` dynamic sites (author API) |
|
||||
| `doc/design/web-net-capabilities.md` | ext/web capability matrix (W0–W7 + P3) |
|
||||
| `doc/design/view-debug.md` | view / debug hosts |
|
||||
+2
-1
@@ -4,7 +4,8 @@
|
||||
|
||||
### Added
|
||||
- **`ext/web` 样式装配(`web_style` / `网页.样式装配`)**: 样式即数据表格 —— GFM 样式表(`|选择器|属性|值|`,可用 `|媒体|` 列分组进 `@media` 块)经 `样式装配` 函数转成 CSS 文本,再拼装成完整主题。替代"整段手写 CSS 字符串"的写法,贯彻 文档即代码。见 [marqdo-blog](examples/marqdo-blog/styles/theme.mq.md)。
|
||||
- **网络能力调研(`doc/design/web-net-capabilities.md`)**: 盘点 `ext/web` + `plugins/web` + `lib/net` 现状,对照主流语言网络栈(FastAPI / Express / Flask / axum),给出「开发一个完整 Web 项目」所需能力的差距清单与分波次补强路线(W1 中间件+JSON → W2 数据层 → W3 安全硬化 → W4 内容标配 → W5 上传 → W6 进阶)。
|
||||
- **网络能力调研(`doc/design/web-net-capabilities.md`)**: 盘点 `ext/web` + `plugins/web` + `lib/net` 现状,对照主流语言网络栈(FastAPI / Express / Flask / axum),给出「开发一个完整 Web 项目」所需能力的差距清单与分波次补强路线(W1–W7 + P3,**2026-08-28 已全部落地**)。
|
||||
- **AI Skill + 文档(ext/web 完结复核)**: `skills/marqdo/` 与 `.cursor/skills/marqdo/` 增加 **ext/web 动态站** 专节(硬规则、API 摘要、§13 最小站点样例);`doc/design/web-net-capabilities.md` 结论/对照表与 W7+P3 实现对齐;`doc/design/ai-skill.md` 更新用途说明。
|
||||
|
||||
### Changed
|
||||
- **Frontmatter import syntax**: `import bind:target` / `导入 bind:target` (file `.mq.md` or short name `lib.member`). Removed legacy `> path.mq.md` / `> use` imports. See [module-namespace.md](doc/design/module-namespace.md).
|
||||
|
||||
@@ -106,7 +106,7 @@ marqdo catalog public -o .marqdo
|
||||
- **`marqdo catalog` / `sync`**:OKF 风格 YAML + 模块概念页
|
||||
- **`marqdo version --check`**:与 GitHub 最新 release 对比
|
||||
- 标准库:**内置于二进制**(v0.1.2+);磁盘 `lib/` 或 `MARQDO_LIB` 可覆盖。模块含文本、文件、系统、时间、JSON、网络、数学、外联、插件、**自写回**、**子任务**
|
||||
- **官方扩展库 `ext/`**(本版重点,**非** stdlib):`llm` · `agent` · `web` · `quantum`。安装:`marqdo ext list` / `add …` / `remove`(见 [ext-cli.md](doc/design/ext-cli.md);默认 `~/.marqdo/ext` 或 `MARQDO_EXT`)。原生插件先 `cargo build -p marqdo_plugin_*` 再 `ext add`。设计:[ext-llm](doc/design/ext-llm.md) · [ext-agent](doc/design/ext-agent.md) · [ext-web](doc/design/ext-web.md) · [ext-quantum](doc/design/ext-quantum.md)
|
||||
- **官方扩展库 `ext/`**(本版重点,**非** stdlib):`llm` · `agent` · **`web`(W0–W7 + P3 完结,见 [marqdo-blog](examples/marqdo-blog/))** · `quantum`。安装:`marqdo ext list` / `add …` / `remove`(见 [ext-cli.md](doc/design/ext-cli.md);默认 `~/.marqdo/ext` 或 `MARQDO_EXT`)。原生插件先 `cargo build -p marqdo_plugin_*` 再 `ext add`。设计:[ext-llm](doc/design/ext-llm.md) · [ext-agent](doc/design/ext-agent.md) · [ext-web](doc/design/ext-web.md) · [web-net-capabilities](doc/design/web-net-capabilities.md) · [ext-quantum](doc/design/ext-quantum.md)
|
||||
- **原生插件 ABI**:[`include/marqdo_abi.h`](include/marqdo_abi.h) · [ext-abi.md](doc/design/ext-abi.md);`plugins/{demo,agent,web,quantum}`
|
||||
- **用户静态站**:`public/` → `view output` → CI 发布 [gh-pages](https://cflmy.github.io/marqdo/)
|
||||
- **VS Code 扩展**:分支 **`vscode-extension`**(`main` 不跟踪源码;见 [vscode-extension-commit.md](doc/design/vscode-extension-commit.md));Release 附带 `.vsix`
|
||||
|
||||
@@ -3,22 +3,22 @@
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | 已提供 |
|
||||
| 日期 | 2026-08-05 |
|
||||
| 日期 | 2026-08-05(初版)· 2026-08-28(ext/web 完结复核) |
|
||||
| 路径 | [`skills/marqdo/`](../../skills/marqdo/)(权威);Cursor 镜像 [`.cursor/skills/marqdo/`](../../.cursor/skills/marqdo/) |
|
||||
|
||||
---
|
||||
|
||||
## 目的
|
||||
|
||||
让接入方(Cursor Agent、其它支持 Agent Skills 的模型宿主)在**加载本 skill 后**即可按 v0.1 语法正确编写 / 修改 `.mq.md`,而不把 Markdown 习惯或 Python 控制流误套到 Marqdo。
|
||||
让接入方(Cursor Agent、其它支持 Agent Skills 的模型宿主)在**加载本 skill 后**即可按 v0.2 语法正确编写 / 修改 `.mq.md`,并在使用 **`ext/web` 动态站** 时遵循 GFM 表 + 类方法作者面(不混中英 API、不写 JSON 袋胶水)。
|
||||
|
||||
## 内容
|
||||
|
||||
| 文件 | 用途 |
|
||||
|------|------|
|
||||
| `SKILL.md` | 必读:硬规则、标记表、工作流、反模式 |
|
||||
| `reference.md` | 按需:CLI、stdlib 索引、边界 |
|
||||
| `examples.md` | 按需:可复制样例 |
|
||||
| `SKILL.md` | 必读:硬规则、标记表、**ext/web 动态站**、工作流、反模式 |
|
||||
| `reference.md` | 按需:CLI、stdlib/ext 索引、**ext/web API 摘要** |
|
||||
| `examples.md` | 按需:可复制样例(含 §13 最小站点) |
|
||||
|
||||
## 使用
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | **Accepted · 完成**(SQLite 作者面:页面装配 / db CRUD+`where` / form / 嵌入主区 / `app.route` / 路由 `/_part` / admin UI / `app.static`;Postgres 等见 §9) |
|
||||
| 状态 | **Accepted · W0–W7 + P3 完结**(SQLite/Postgres 作者面:页面装配 / db CRUD+`where` / form / 嵌入主区 / `app.route` / 路由 `/_part` / admin UI / RBAC / 上传相册 / SEO·RSS·sitemap;Postgres 等见 §9) |
|
||||
| 日期 | 2026-08-11 |
|
||||
| 相关 | [markdown-mapping.md](markdown-mapping.md) · [module-namespace.md](module-namespace.md) · [objects.md](objects.md) · [ext-abi.md](ext-abi.md) · [ext-cli.md](ext-cli.md) · [stdlib-i18n.md](stdlib-i18n.md) |
|
||||
| 安装(目标) | `marqdo ext add web`(中英:`web` / `网页`) |
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | **调研结论(Draft)** |
|
||||
| 日期 | 2026-08-26 |
|
||||
| 状态 | **Accepted · W0–W7 + P3 完结**(2026-08-28 复核) |
|
||||
| 日期 | 2026-08-26(初稿)· 2026-08-28(完结复核) |
|
||||
| 相关 | [ext-web.md](ext-web.md) · [ext-web-net.md](ext-web-net.md) · [ext-abi.md](ext-abi.md) · [stdlib-modules.md](stdlib-modules.md) |
|
||||
| 目标 | 盘点 `ext/web` + `plugins/web` + `lib/net` 现状,对照主流语言网络栈,给出「开发一个完整 Web 项目」所需能力的差距清单与补强路线 |
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
## 0. 一句话结论
|
||||
|
||||
**当前 `plugins/web` 已覆盖「单页渲染 + SQLite 表单 CRUD + 简易 admin 门禁 + echo WebSocket + 中间件管道(CORS/安全头/gzip/请求体限制)+ JSON API + 数据层深化(连接池/事务/分页/查询表达力)」,足以支撑中小型内容站点与前后端分离 API;但距「完整项目」(博客/CMS/社区)仍缺四类能力:③ 安全硬化(密码哈希 / CSRF / 限流 / 会话持久化);④ 内容站点标配(SEO / 搜索 / RSS / 分页导航);① 中余下上传下载 / HTTPS / 日志 / 错误页。** 全部按「基础设施进 `lib/net`,领域能力进 `plugins/web` + `ext/web`」的既有边界补强。
|
||||
**`ext/web` + `plugins/web` 已完成 W0–W7 + P3 路线图**:中间件/JSON API、数据层(连接池/事务/分页/FTS/迁移/外键/审计时间戳)、安全硬化(argon2/CSRF/会话持久化/限速/RBAC)、内容站点标配(SEO/RSS/Markdown/分页 UI)、上传下载/相册/ETag、sitemap/robots/错误页/重定向、WebSocket 广播与访问日志。足以在 Marqdo 上实现博客/CMS/中小型 API 站点;**未内置**的仅剩标签页模板(D6,可用路由+`db.count` 自建)与应用层反垃圾。边界不变:**纯解析进 `lib/net`,HTTP 服务器与领域能力进 `plugins/web` + `ext/web` 作者面**。
|
||||
|
||||
|
||||
---
|
||||
@@ -30,8 +30,9 @@
|
||||
| `url_encode` / `编码地址` | host `net.rs` | ✅ URL 编码 |
|
||||
| `cookie_parse` / `解析Cookie` | host `net.rs` | ✅ RFC6265 子集(请求头/响应头) |
|
||||
| `multipart_parse` / `解析多部分` | host `net.rs` | ✅ multipart/form-data 解析 |
|
||||
| `markdown_parse` / `解析Markdown` | host `net.rs` | ✅ GFM/Markdown → HTML(纯解析,W4c) |
|
||||
|
||||
**标准库网络原语已比较齐备**:客户端 GET/POST/SSE、URL 编码、cookie、multipart 都有。缺的是**响应元信息(响应头/Set-Cookie 取出)、上传(multipart 文件)与下载(二进制)**。
|
||||
**标准库网络原语已齐备**:客户端 GET/POST/SSE、URL 编码、cookie、multipart、Markdown 解析。服务器侧上传/下载/ETag 在 `plugins/web`(A5/P3)。
|
||||
|
||||
### 1.2 `plugins/web`(ABI v2,领域能力)
|
||||
|
||||
@@ -48,17 +49,15 @@
|
||||
| 鉴权 | `web_auth_login/check/logout/new` · `web_app_auth` | `/admin` 登录门禁 |
|
||||
| WebSocket | `web_ws_connect`(客户端)· `web_app_route_ws`(服务器) | 单请求-响应式客户端 + echo 服务器 |
|
||||
|
||||
**关键实现事实(决定差距):**
|
||||
**关键实现事实(2026-08-28 W7+P3 后):**
|
||||
|
||||
- **中间件层已落地**(W1):`app.configure`/`应用.装配` 通过 GFM 表装配 CORS、安全响应头、gzip 压缩、请求体上限、JSON API 路由,`监听` 时统一挂到 axum `Router`(`middleware.rs`)。「配置即数据、装配即函数」。
|
||||
- **JSON API 已落地**(W1):`|路径|方法|表|条件|排序|上限|` 表声明端点,响应 `application/json`,支持 DB 查询 + 排序 + 上限。
|
||||
- **数据层深化已落地**(W2):进程级**连接池**(WAL + `busy_timeout` + `foreign_keys`)+ **事务** API(`db.事务` → `txn.insert/提交/回滚`,`txn` 句柄带 `_type` 走 Marqdo 类分发)+ **结果集裸查询**(`db.query` 返回 `{rows, count}`)+ **分页**(`select`/`paginate` 支持 `offset`,返回 `{rows, total}`)+ **查询表达力**(where 支持 OR 组 / `in` / `between` / `is null` / `like`)+ **聚合计数**(`db.count`)。
|
||||
- **无文件上传**:无 multipart extractor,`multipart_parse` 只在标准库侧做了纯解析,服务器没接收。
|
||||
- **会话为进程内内存**:重启即失效、多 worker 不共享;session id 非加密强度;密码明文存储比对。
|
||||
- **无 HTTPS**:仅 `TcpListener::bind` HTTP。
|
||||
- **无迁移机制**:schema 版本表 + 迁移脚本缺失;索引/唯一/外键声明待增强(init 表增强)。
|
||||
- **WebSocket 仅 echo**:无广播/房间/多客户端/业务分发。
|
||||
- **尚无自定义 404/500 错误页、无访问日志、无 ETag/Cache-Control 缓存头、无重定向增强。**
|
||||
- **中间件 + JSON API**(W1):`app.configure` 装配 CORS、安全头、gzip、请求体上限、JSON 端点。
|
||||
- **数据层**(W2/W6/W7/P3):连接池、事务、分页、OR/IN/BETWEEN、`db.count`、迁移、FTS5 搜索、init 唯一/索引/外键、审计时间戳。
|
||||
- **安全**(W3s/P3):argon2、CSRF、SQLite 会话、CSPRNG session id、登录限速、RBAC(`app.gate` + 用户 `role`)。
|
||||
- **内容站点**(W4c/W7):SEO `page.meta`、RSS、Markdown 正文、`page.paginate`、sitemap/robots。
|
||||
- **媒体**(W5/P3):multipart 上传、下载、`app.gallery`、ETag/Cache-Control。
|
||||
- **运维向**(W6/W7):访问日志、自定义 404/500、301/307 重定向、WS 广播;HTTPS 由反代终止 + `cookie_secure`。
|
||||
- **仍属应用层约定**:标签聚合页模板(D6)、评论反垃圾、草稿/定时发布(表+where 即可)。
|
||||
|
||||
---
|
||||
|
||||
@@ -82,27 +81,29 @@
|
||||
|
||||
### 2.2 「完整 Web 框架」能力清单(FastAPI / Express / Flask / axum 共通项)
|
||||
|
||||
| 能力 | FastAPI | Express | Flask | axum | 说明 |
|
||||
> **marqdo 列**反映 **2026-08-28 W7+P3 完结** 后状态(见 §3 差距表)。
|
||||
|
||||
| 能力 | FastAPI | Express | Flask | axum | marqdo |
|
||||
|---|---|---|---|---|---|
|
||||
| 路由(含动态参数) | ✅ | ✅ | ✅ | ✅ | 三框架全支持;marqdo 已有动态路由 `/post/{slug}` |
|
||||
| 中间件管道 | ✅ | ✅ | ✅ | ✅(tower) | **marqdo 缺失** — 最根本缺口 |
|
||||
| CORS | ✅ 内置 | ✅ 中间件 | ✅ flask-cors | ✅ tower-http | 缺失 |
|
||||
| JSON 请求/响应 | ✅ 原生 | ✅ | ✅ | ✅ | 缺失 |
|
||||
| 校验(schema/字段) | ✅ Pydantic | 手动(zod) | 手动 | ✅ extractor | marqdo 有 form 校验表(够用) |
|
||||
| 静态文件 | ✅ Starlette | ✅ | ✅ | ✅ | ✅ 已有 |
|
||||
| 模板/渲染 | ✅ Jinja | ✅ | ✅ | ✅ | marqdo 用 GFM 表装配(自研) |
|
||||
| 会话 | ✅ | ✅ express-session | ✅ | ✅ | 有(内存,待持久化) |
|
||||
| 鉴权 | ✅ OAuth2/APIKey | ✅ | ✅ | ✅ | 有(admin 门禁,待硬化) |
|
||||
| 文件上传 | ✅ | ✅ multer | ✅ | ✅ | 缺失 |
|
||||
| WebSocket | ✅ | ✅ ws | ✅ Flask-SocketIO | ✅ | 有(echo,待广播) |
|
||||
| 安全头 | ✅ | ✅ helmet | ✅ | ✅ tower-http | 缺失 |
|
||||
| 限流 | ✅ | ✅ | ✅ | ✅ | 缺失 |
|
||||
| 日志 | ✅ | ✅ morgan | ✅ | ✅ | 缺失 |
|
||||
| gzip 压缩 | ✅ | ✅ | ✅ | ✅ | 缺失 |
|
||||
| 分页 | 手动 | 手动 | ✅ paginate | ✅ | marqdo 缺失(db 层无 offset) |
|
||||
| 迁移 | ✅ alembic | ✅ | ✅ | ✅ sqlx | 缺失 |
|
||||
| 测试工具 | ✅ TestClient | ✅ supertest | ✅ | ✅ | 缺失(依赖 gold 测试) |
|
||||
| HTTPS/TLS | 反代 | 反代 | 反代 | ✅ rustls | 缺失(通常反代承担) |
|
||||
| 路由(含动态参数) | ✅ | ✅ | ✅ | ✅ | ✅ 动态路由 `/post/{slug}` |
|
||||
| 中间件管道 | ✅ | ✅ | ✅ | ✅(tower) | ✅ W1 `app.configure` |
|
||||
| CORS | ✅ 内置 | ✅ 中间件 | ✅ flask-cors | ✅ tower-http | ✅ W1 |
|
||||
| JSON 请求/响应 | ✅ 原生 | ✅ | ✅ | ✅ | ✅ W1 JSON API 表 |
|
||||
| 校验(schema/字段) | ✅ Pydantic | 手动(zod) | 手动 | ✅ extractor | ✅ form 校验表 |
|
||||
| 静态文件 | ✅ Starlette | ✅ | ✅ | ✅ | ✅ `app.static` |
|
||||
| 模板/渲染 | ✅ Jinja | ✅ | ✅ | ✅ | ✅ GFM 表装配 |
|
||||
| 会话 | ✅ | ✅ express-session | ✅ | ✅ | ✅ SQLite 持久化(W3s) |
|
||||
| 鉴权 | ✅ OAuth2/APIKey | ✅ | ✅ | ✅ | ✅ admin + RBAC(P3) |
|
||||
| 文件上传 | ✅ | ✅ multer | ✅ | ✅ | ✅ W5 upload |
|
||||
| WebSocket | ✅ | ✅ ws | ✅ Flask-SocketIO | ✅ | ✅ echo + 广播(W6) |
|
||||
| 安全头 | ✅ | ✅ helmet | ✅ | ✅ tower-http | ✅ W1 |
|
||||
| 限流 | ✅ | ✅ | ✅ | ✅ | ✅ 登录限速(W3s) |
|
||||
| 日志 | ✅ | ✅ morgan | ✅ | ✅ | ✅ access_log(W6) |
|
||||
| gzip 压缩 | ✅ | ✅ | ✅ | ✅ | ✅ W1 |
|
||||
| 分页 | 手动 | 手动 | ✅ paginate | ✅ | ✅ db + page UI(W2/W4c) |
|
||||
| 迁移 | ✅ alembic | ✅ | ✅ | ✅ sqlx | ✅ W6 `db.migrate` |
|
||||
| 测试工具 | ✅ TestClient | ✅ supertest | ✅ | ✅ | gold 测试(`tests/ext/web-*`) |
|
||||
| HTTPS/TLS | 反代 | 反代 | 反代 | ✅ rustls | 反代 + `cookie_secure`(W7 文档锁定) |
|
||||
|
||||
---
|
||||
|
||||
@@ -177,22 +178,22 @@
|
||||
|---|---|---|---|
|
||||
| **W1** | 服务器基础设施 | 中间件管道(CORS/安全头/压缩/请求体限制)+ JSON API(`application/json` 响应 + DB 查询端点) | A1 A2 A3 A4 A7 ✅ **已完成** |
|
||||
| **W2** | 数据层深化 | 连接池/busy_timeout/WAL + 事务 API + 结果集裸查询 + 分页(offset) + OR/IN/BETWEEN + 聚合 count | B1 B2 B3 B4 B5 B8 ✅ **已完成** |
|
||||
| **W3** | 安全硬化 | 密码哈希 + CSRF + 会话持久化 + CSPRNG session id + cookie 增强 + 登录限速/锁定 | C1–C7 |
|
||||
| **W4** | 内容站点标配 | SEO 元数据 + sitemap/robots + RSS + Markdown 渲染 + 分页导航 UI + 标签/分类 | D1–D6 |
|
||||
| **W5** | 上传与媒体 | multipart 文件上传接收 + 落盘 + 下载 + 图片库 | A5 D9 ✅ **A5 done**(D9 相册 UI 后续) |
|
||||
| **W6** | 进阶 | 全文搜索(FTS5) + 迁移机制 + 评论系统 + 草稿/发布 + WS 广播 | B6 B9 ✅;WS 广播 + access_log ✅;D7/D8 用表+where |
|
||||
| **W3** | 安全硬化 | 密码哈希 + CSRF + 会话持久化 + CSPRNG session id + cookie 增强 + 登录限速/锁定 | C1–C7 ✅ |
|
||||
| **W4** | 内容站点标配 | SEO 元数据 + sitemap/robots + RSS + Markdown 渲染 + 分页导航 UI + 标签/分类 | D1–D5 ✅;D6 约定 |
|
||||
| **W5** | 上传与媒体 | multipart 文件上传接收 + 落盘 + 下载 + 图片库 | A5 ✅;D9 相册 P3 ✅ |
|
||||
| **W6** | 进阶 | 全文搜索(FTS5) + 迁移机制 + 评论系统 + 草稿/发布 + WS 广播 | B6 B9 ✅;WS 广播 + access_log ✅;D7/D8 用表+where ✅ |
|
||||
| **W7** | 完结打磨 | Cache-Control、自定义 404/500、301 重定向、sitemap/robots、init 唯一/索引、HTTPS 反代文档 | A6 A7 A9 A10 B7 D2 ✅ |
|
||||
| **P3** | 真·网络扩展补齐 | 审计时间戳、外键、RBAC 门禁、媒体相册、下载 ETag | B10 C8 D9 + ETag/FK ✅ |
|
||||
|
||||
### 4.2 边界判定要点(严格遵守既有约束)
|
||||
|
||||
1. **进标准库 `lib/net`**(纯解析、无网络 I/O、支持扩展库开发):
|
||||
- `markdown_parse`(GFM/Markdown → HTML,纯解析)→ D5。
|
||||
- `xml_escape` / RSS/Atom 纯文本装配辅助(如需)→ D3。
|
||||
- `markdown_parse`(GFM/Markdown → HTML,纯解析)→ D5 ✅。
|
||||
- `xml_escape` / RSS/Atom 纯文本装配辅助(如需)→ D3(作者面 `route_rss` 已够用)。
|
||||
- **不得**放进标准库:JSON API、中间件、上传接收、事务、会话(均涉 I/O 或领域语义)。
|
||||
2. **进 `plugins/web`(ABI)**:A1–A10、B1–B10、C1–C8、D7–D8 的插件侧;tower-http 已提供 CORS/压缩/安全头/Trace 等现成 layer,`axum` 提供 `Json`/`Multipart`/`Nest` 等 extractor,**均不新增核心运行时依赖**(已锁定 rustc 1.81)。
|
||||
3. **进 `ext/web` 作者面(Marqdo)**:D1–D4 中纯装配/元数据/分页 UI 部分,以及所有插件能力的 GFM 表包装(中英双面)。
|
||||
4. **已具备、无需新增**:动态路由、静态文件、表单校验/回显、session 增删查、admin 门禁、WebSocket 单连接 echo、SSE 客户端、cookie/multipart 解析。
|
||||
2. **进 `plugins/web`(ABI)**:A1–A10、B1–B10、C1–C8、D7–D8 的插件侧 — **均已落地**(2026-08-28)。
|
||||
3. **进 `ext/web` 作者面(Marqdo)**:D1–D4、A5/D2/D9 等 GFM 表包装 — **均已落地**(中英 `web.mq.md` / `网页.mq.md`)。
|
||||
4. **已具备、无需新增**:动态路由、静态文件、表单校验/回显、session、admin/RBAC、WebSocket、SSE 客户端、cookie/multipart/Markdown 解析。
|
||||
|
||||
### 4.3 作者面示例(示 W4 落地形态,保持「代码即文档」)
|
||||
|
||||
@@ -221,44 +222,42 @@
|
||||
|
||||
---
|
||||
|
||||
## 5. 结论与建议顺序
|
||||
## 5. 结论
|
||||
|
||||
1. **W1(中间件 + JSON)已落地**:`app.configure`/`应用.装配` 用 GFM 表装配 CORS/安全头/gzip/请求体限制/JSON API,经 gold 测试(离线 smoke + 在线 live + curl 实测)与 blog 示例回归验证。
|
||||
2. **W2(数据层)已落地**:连接池/事务/分页/查询表达力/计数经 `ext_web_db_w2_smoke` gold 测试(离线)全绿——事务提交/回滚后 `count` 正确、`IN/BETWEEN/OR` 过滤、`paginate` 返回 `{rows,total}`、裸 SQL 结果集。`database is locked` 与无法分页的实际痛点已解决。
|
||||
3. **W3 安全硬化**:上线前必须完成密码哈希 + CSRF + 会话持久化,否则「完整项目」仅能演示。
|
||||
4. **W4 内容标配**:让博客示例真正「完整」——SEO/Markdown/分页/RSS 是博客系统的门面。
|
||||
5. **W5/W6**:按项目实际需要取舍(上传、搜索、评论、迁移)。
|
||||
**W0–W7 + P3 已全部落地**(路线图见 [roadmap/ext-web.md](../roadmap/ext-web.md))。验收覆盖:
|
||||
|
||||
**一句话:W1(中间件 + JSON)+ W2(事务 + 分页 + 查询表达力)已补齐;离「完整项目」最近的敲门砖变成「密码哈希 + CSRF」和「SEO/Markdown/RSS」两块。这两块补齐后,博客/CMS/社区类站点即可在 `ext/web` 上完整实现;其余为锦上添花。**
|
||||
- 离线/在线 gold:`tests/ext/web-*-smoke.mq.md`(含 security、drivers、upload、w6、w7、p3)
|
||||
- 完整示例:`examples/marqdo-blog/`(列表/详情/标签/RSS/后台/上传/WS)
|
||||
- 作者面:`ext/web/web.mq.md` · `ext/web/网页.mq.md`
|
||||
- AI 编写指引:`skills/marqdo/`(§ ext/web)
|
||||
|
||||
**后续可选(非阻塞)**:标签页内置模板(D6)、cookie 签名、会话条数硬上限、应用层反垃圾、进程内 TLS(仍建议反代)。
|
||||
|
||||
**一句话:`ext/web` 已是可上线级别的 Marqdo 动态站扩展;博客/CMS/中小型 API 可在表格 + 类方法作者面上完整实现。**
|
||||
|
||||
---
|
||||
|
||||
## 6. 附:现有能力自测对照表(对博客示例逐项)
|
||||
|
||||
| 博客功能 | 现状 | 需要的补强 |
|
||||
|---|---|---|
|
||||
| 文章列表(首页) | ✅ 已实现 | — |
|
||||
| 文章详情(动态路由) | ✅ 已实现 | — |
|
||||
| 标签/分类 | ⚠️ 可做(db where) | 计数聚合(B8 ✅ 已有 `db.count`) |
|
||||
| 分页 | ✅ db 层(`paginate` 返回 `{rows,total}`) | 页面导航 UI(D4) |
|
||||
| 搜索 | ❌ | B9(FTS5) |
|
||||
| SEO 元数据 | ⚠️ 可手写 | D1 系统化 |
|
||||
| RSS | ❌ | D3 |
|
||||
| 评论 | ⚠️ 表单可做 | 审核/反垃圾 |
|
||||
| 后台写文章 | ✅ admin CRUD | 草稿/发布(D8) |
|
||||
| 上传配图 | ❌ | A5 + D9 |
|
||||
| 用户登录 | ⚠️ admin 门禁 | 密码哈希/CSRF/限流(W3) |
|
||||
## 6. 附:博客示例能力对照(`examples/marqdo-blog`)
|
||||
|
||||
| 博客功能 | 现状 |
|
||||
|---|---|
|
||||
| 文章列表(首页) | ✅ |
|
||||
| 文章详情(动态路由) | ✅ |
|
||||
| 标签/分类 | ✅ 路由 + `db.where` + `db.count` |
|
||||
| 分页 | ✅ `db.paginate` + `page.paginate` |
|
||||
| 搜索 | ✅ FTS5 `db.search` |
|
||||
| SEO 元数据 | ✅ `page.meta` |
|
||||
| RSS | ✅ `app.route_rss` |
|
||||
| 评论 | ✅ 表 + form + where(反垃圾属应用层) |
|
||||
| 后台写文章 | ✅ admin CRUD + RBAC |
|
||||
| 草稿/发布 | ✅ `status` 字段 + where |
|
||||
| 上传配图 | ✅ `app.upload` + `app.gallery` |
|
||||
| 用户登录 | ✅ argon2 + CSRF + SQLite 会话 + 限速 |
|
||||
| sitemap / robots | ✅ W7 |
|
||||
| 实时终端(WS) | ✅ W6 广播 |
|
||||
|
||||
---
|
||||
|
||||
## 7. 附:正文渲染现状(决定 D5 的必要性)
|
||||
## 7. 附:Markdown 正文渲染(D5,已落地)
|
||||
|
||||
博客详情页正文由 `plugins/web/src/render.rs` 的 `render_article_body` 渲染,但它是**「Markdown-ish」极简子集**,仅支持:
|
||||
|
||||
- 段落(`\n\n` 分段)
|
||||
- `# ` / `## ` 标题(统一渲染为 `<h2>`)
|
||||
- ` ``` ` 围栏代码块(转义后进 `<pre>`)
|
||||
|
||||
**不支持**:有序/无序列表、行内代码、粗体/斜体、链接、图片、表格、引用块、代码高亮。
|
||||
**结论**:博客正文的 Markdown 渲染是真实缺口 → D5(`markdown_parse` 纯解析原语进 `lib/net` 标准库,与 `cookie_parse`/`multipart_parse` 同模式,由 `plugins/web` 渲染层或 `ext/web` 作者面调用)优先级 **P0**。
|
||||
博客详情页正文经 `lib/net.markdown_parse`(`host_markdown_parse`)解析为 HTML,由 `plugins/web` 渲染层在页面装配时调用(W4c)。作者存储 Markdown 字符串于 DB,展示侧自动渲染 GFM 子集(标题、列表、链接、代码块等)。纯解析留在标准库;**不得**在 `ext/web` 作者面直接调 `host_*`。
|
||||
@@ -34,7 +34,7 @@ ext/llm — OpenAI-compatible chat. Design: doc/design/ext-llm.md
|
||||
|
||||
ext/agent — agent framework + native plugin. Design: doc/design/ext-agent.md
|
||||
|
||||
ext/web — HTTP / SQLite site helpers + native plugin. Design: doc/design/ext-web.md
|
||||
ext/web — HTTP / SQLite·Postgres site helpers + native plugin. **W0–W7 + P3 complete** (middleware, CRUD+FTS, security, SEO/RSS, upload/gallery, RBAC, sitemap). Design: doc/design/ext-web.md · capabilities: doc/design/web-net-capabilities.md · example: examples/marqdo-blog/
|
||||
|
||||
ext/quantum — circuits, draw, noise, formula matrix custom gates. Design: doc/design/ext-quantum.md
|
||||
|
||||
|
||||
+70
-18
@@ -4,8 +4,9 @@ description: >-
|
||||
Author and edit Marqdo programs (.mq.md): Markdown markers are executable
|
||||
syntax (functions, calls, statements, returns, control flow). Use when writing
|
||||
or modifying .mq.md files, teaching Marqdo, generating Marqdo from prose,
|
||||
importing lib/*, running marqdo CLI, or when the user mentions Marqdo,
|
||||
mq.md, markup-as-syntax, or code-as-documentation.
|
||||
importing lib/* or ext/web, running marqdo CLI, building dynamic sites with
|
||||
ext/web, or when the user mentions Marqdo, mq.md, markup-as-syntax,
|
||||
code-as-documentation, or web/网页 extension.
|
||||
---
|
||||
|
||||
# Marqdo development
|
||||
@@ -20,16 +21,17 @@ Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords.
|
||||
2. **Output is not `**bold**`.** Print with `> print text=…` (or `> 打印 内容=…`). Bold `**…**` is **return value only**.
|
||||
3. **Prose vs code:** after a blank line, an unmarked first line starts a **comment paragraph**; every following non-blank line stays comment until the next blank line. Put a **blank line** between narration and executable lines.
|
||||
4. **Do not invent keywords** `if` / `else` / `while` / `for` / `def` / `return`. Control flow is Markdown: **`+` params** (under heading), **`1.` `2.` … branches**, **`-` loops**, arm `N. *` = else, `#` = **object/type**, `##`+ = **function/method**, `**…**` = return.
|
||||
5. **Identifiers use backticks** — params `` + `name` ``. **Exemptions:** foreach `` - [item](coll) ``; footnote `` name[^key] ``; **inside italic `*…*` / bold `**…**`**, bare ids are variables (strings need `"…"` / `'…'`; ticks still ok).
|
||||
5. **Identifiers use backticks** — params `` + `name` ``. **Exemptions:** foreach `` - [item](coll) ``; footnote `` name[^key] ``; **inside italic `*…*` / bold `**…**`**, bare ids are **variables** (Python-style unified namespace) and method-call receivers are bare too. **Drop the backticks on value-expression variable names and method receivers inside `*…*` / `**…**`** — they are redundant once the `*…*`/`**…**` markers mark the segment as code: `*分类 = 分类[^苹果]*`, `**n * 2**`, `*p = > page.主体装配 组件=home*`. **Text literals must be quoted**: `*a = > text.split value=src sep=","*`. Backticks **still required** where a bare word is *not* a variable in **standalone `>` calls** (bare = text there): `` > str `n` ``, `` > `obj`.method ``. **No trailing space** inside `*…*` / `**…**` wrapped code: the closing marker must touch the last token directly (`*a = 1*`, `**n**`), never `` *a = 1 * ``.
|
||||
6. **Structure lines are not wrapped in italics.** `#` `>` `+` `-` `|` lines stand alone; use `*…*` only for general statements (bindings / expressions).
|
||||
7. **Paths in bare expressions:** `/` is division. Prefer `` `path` `` vars, same-dir names, or call args — not raw `a/b` in expressions.
|
||||
7. **Paths:** In bare *expressions* `/` is division. In **call args / param defaults**, unspaced `a/b` and quoted `".marqdo/agent-kb"` are path text — no `json.parse` needed.
|
||||
8. Prefer ending side-effect-only function bodies with a lone `---` or `***` line (or `****` empty return) so later siblings are not swallowed.
|
||||
9. **`ext/**` never calls `host_*`.** Agent/OKF helpers are plugin names (`agent_kb_*`, …) after `plugin.load`. Do **not** add agent/OKF domain code to `src/host/` (core bloat). See `doc/design/ext-agent.md` §4.
|
||||
|
||||
## Markup → meaning (v0.2)
|
||||
|
||||
| Marker | Meaning |
|
||||
|--------|---------|
|
||||
| `#` | **Object / type** (constructor body). `# main` = entry object. `# Child = > Parent` = inherit. |
|
||||
| `#` | **Object / type** (constructor body). `# main` = entry object. `# Child = > Parent` = inherit (**no** implicit parent constructor; call `` `self` = > Parent … `` explicitly when needed). |
|
||||
| `##` … `######` | **Function / method** (nesting by heading depth). |
|
||||
| `` + `name` `` under heading | Parameter (optional `` `name`=default ``) |
|
||||
| `1.` `2.` … in body | Branch arm (condition or `N. *` else). **Same-indent restart at `1.` = new branch statement** (not more arms of the previous list). |
|
||||
@@ -37,9 +39,11 @@ Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords.
|
||||
| Line `N. *` | Else arm |
|
||||
| `> fn args` | Call (named `k=v` or positional) |
|
||||
| `` > `obj`.method args `` | Method call (`obj` must be a map with `_type`) |
|
||||
| Frontmatter `import bind:path.mq.md` / `import bind:lib.member` / `导入` | Import file or short-name member |
|
||||
| `*…*` | Statement (bind / expr) |
|
||||
| `**…**` | Return value |
|
||||
| Frontmatter `import bind:path.mq.md` / `导入` | Import file (bind library name) |
|
||||
| Frontmatter `import bind:lib.member` / `导入` | Short name for a library member (same keyword; no separate `use`) |
|
||||
| `> lib.member …` / `> lib.Type.member …` | Call via bare dotted path (instance methods need `` `var`.m ``) |
|
||||
| `*…*` | Statement (bind / expr) — closing `*` touches last token, **no trailing space**; bare ids are variables |
|
||||
| `**…**` | Return value — closing `**` touches last token, **no trailing space**; bare ids are variables |
|
||||
| `****` or `**` + spaces + `**` | Return `None` and end function body |
|
||||
| Lone `---` / `***` in function body | End function body (no value) |
|
||||
| GFM table after empty RHS bind | Collection (1-col list / ≥2-col map / `@`·`行`·`row` → list of maps); `` `x`[^1] `` / `` `m`[^key] `` |
|
||||
@@ -87,17 +91,17 @@ Chinese builtins (same functions, no import):
|
||||
## Statements, returns, branches
|
||||
|
||||
```markdown
|
||||
*`x` = 1*
|
||||
*`y` = `x` + 2*
|
||||
*x = 1*
|
||||
*y = x + 2*
|
||||
|
||||
## add_one
|
||||
+ `n`
|
||||
|
||||
**`n` + 1**
|
||||
**n + 1**
|
||||
```
|
||||
|
||||
```markdown
|
||||
*`n` = 0*
|
||||
*n = 0*
|
||||
|
||||
1. `n` > 0
|
||||
> print text=positive
|
||||
@@ -109,29 +113,70 @@ Chinese builtins (same functions, no import):
|
||||
|
||||
## Frontmatter imports + stdlib
|
||||
|
||||
Use `import bind:target` (`导入` equivalent). Target is a `.mq.md` file or a dotted member short name.
|
||||
Imports use `import bind:target` (`导入` equivalent): file (`.mq.md`) or short name (`lib.member`). Members are **not** flattened into the caller. Call with a bare dotted path:
|
||||
|
||||
```markdown
|
||||
---
|
||||
title: example
|
||||
import text:lib/text.mq.md
|
||||
import trim_text:text.str_trim
|
||||
import clock:lib/time.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`xs` = > text.split value=a,b,c sep=,*
|
||||
*xs = > text.split value="a,b,c" sep=","*
|
||||
> print text=`xs`
|
||||
*t = > clock.now_unix*
|
||||
```
|
||||
|
||||
- Import **English** or **Chinese** library file; call that file’s API names via `lib.member` (do not mix).
|
||||
- Import **English** or **Chinese** library file; call that file’s API names via `lib.member` (do not mix languages).
|
||||
- Instance methods stay `` > `obj`.method `` (backticks on the receiver only).
|
||||
- `lib/…` resolves via `MARQDO_LIB`, cwd `lib/`, or `lib/` next to the `marqdo` binary.
|
||||
- Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm` / `add agent` (see `doc/design/ext-cli.md`). `ext/llm` — chat; `ext/agent` — agent framework (layout + ABI; compose LLM per `doc/design/ext-agent.md`).
|
||||
- Design: [module-namespace.md](../../doc/design/module-namespace.md).
|
||||
- Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm|agent|web|quantum` (see `doc/design/ext-cli.md`). `ext/llm` — chat; `ext/agent` — document-driven agents: **step** (default writeback) / **plan** workbook ([ext-agent.md](../../doc/design/ext-agent.md), [ext-agent-plan.md](../../doc/design/ext-agent-plan.md)); **`ext/web`** — dynamic sites (W0–W7 + P3 complete; see below).
|
||||
- Native plugins: `lib/plugin` — `## load` / `unload` / `list`. C ABI: `include/marqdo_abi.h`.
|
||||
- Prefer `table.put` / `表.改` for list/map element updates; keep `json` for parse/stringify/quote (see `doc/design/stdlib-table.md`).
|
||||
- Builtins (no import): `print`/`打印`, `input`/`输入`, `len`/`长度`, `str`/`文本`, `int`/`整数`; literals `True`/`真`, `False`/`假`, `None`/`空`; logic `and`/`且`, `or`/`或`, `not`/`非`.
|
||||
|
||||
Stdlib map: [reference.md](reference.md).
|
||||
|
||||
## Official extension: `ext/web` (dynamic sites)
|
||||
|
||||
Install: `marqdo ext add web` (ZH id: `网页`). Build native plugin first: `cargo build --release -p marqdo_plugin_web`.
|
||||
|
||||
Import **one language file** — never mix EN/ZH API names in the same `.mq.md`:
|
||||
|
||||
- EN: `import web:ext/web/web.mq.md`
|
||||
- ZH: `导入 网页:ext/web/网页.mq.md`
|
||||
|
||||
**Hard rules (web):**
|
||||
|
||||
- Authors use **GFM tables + `#` classes** — no `json.parse` / `json.set` glue, no hand-built part JSON.
|
||||
- Table cells stay **literal strings**; path text like `` `posts`.`title` `` is resolved by web classes.
|
||||
- **`ext/**` never calls `host_*`** — hot path is native `plugins/web` ABI.
|
||||
- HTTPS: terminate at reverse proxy; set `cookie_secure=True` on auth (no in-process TLS).
|
||||
|
||||
**Typical layout:**
|
||||
|
||||
```text
|
||||
index.mq.md # entry + home page table + listen
|
||||
pages/ # sub-pages
|
||||
components/ # reusable |属性|值|样式| tables
|
||||
styles/ # CSS modules
|
||||
db/ # schema + open/init
|
||||
data/ # sqlite runtime (gitignore)
|
||||
```
|
||||
|
||||
**Core objects (EN / ZH):** `# page`/`页面`, `# style`/`样式`, `# db`/`数据库`, `# form`/`表单`, `# app`/`应用`, `# auth`/`鉴权`, `# cache`/`缓存`, `# storage`/`存储`.
|
||||
|
||||
**Typical flow:** `db.init` → `page.compose_components` + `page.compose_main` → `page.render` → `app` with `route` / `static` / `configure` / `listen`.
|
||||
|
||||
**Shipped surface (W0–W7 + P3):** middleware + JSON API (`app.configure`); transactions, pagination, FTS search (`db.migrate`, `db.fts`, `db.search`); security (argon2, CSRF, SQLite sessions, login rate limit); SEO / RSS / Markdown (`page.meta`, `route_rss`, `lib/net.markdown_parse`); upload / download / gallery; sitemap / robots / error pages / redirects; RBAC (`app.gate`, user `role`); audit timestamps + FK in `db.init`; ETag on downloads.
|
||||
|
||||
Design: [ext-web.md](../../doc/design/ext-web.md) · capability matrix: [web-net-capabilities.md](../../doc/design/web-net-capabilities.md) · example: [examples/marqdo-blog/](../../examples/marqdo-blog/).
|
||||
|
||||
Web patterns: [examples.md](examples.md) §13 · API index: [reference.md](reference.md).
|
||||
|
||||
## AI authoring workflow
|
||||
|
||||
1. Decide language surface (English builtins + `lib/text.mq.md`, or Chinese + `lib/文本.mq.md`).
|
||||
@@ -148,8 +193,14 @@ Stdlib map: [reference.md](reference.md).
|
||||
| `# main` then prose then code with no blank line | Blank line before code |
|
||||
| `if x > 0:` | `1. `x` > 0` |
|
||||
| `* > print text=hi *` | `> print text=hi` |
|
||||
| `` *`a` = 1 * `` (trailing space + backticks) | `*a = 1*` — bare bind, no trailing space before `*` / `**` |
|
||||
| `*xs = > text.split value=a,b sep=,*` (bare text args) | `*xs = > text.split value="a,b" sep=","*` — quote text literals; bare words are variables |
|
||||
| Forgetting `---` after nested `##` helper | Add `---` / `***` / `****` |
|
||||
| Import `lib/text` then call `拆分` | Match file language |
|
||||
| Import `lib/text` then call bare `split` | `> text.split …` (qualified) |
|
||||
| Import `lib/text` then call `拆分` | Match file language (`text.split`, not 文本) |
|
||||
| `json.set` to build page parts | GFM tables + `page.compose_*` / `web.page` methods |
|
||||
| Mix `web.page` and `网页.页面` in one file | One import language per `.mq.md` |
|
||||
| Call `host_web_*` from `ext/web` | Use `# app` / `# db` methods; plugin ABI only |
|
||||
|
||||
## Checklist before finishing
|
||||
|
||||
@@ -159,4 +210,5 @@ Stdlib map: [reference.md](reference.md).
|
||||
- [ ] `# main` exists when the file is an entry program
|
||||
- [ ] Nested functions ended with `---` / `***` / `****` when needed
|
||||
- [ ] Imports and call names share the same language file
|
||||
- [ ] Web sites: tables + web classes only (no JSON glue); `data/` gitignored
|
||||
- [ ] `marqdo run` succeeds (or errors addressed)
|
||||
+65
-17
@@ -38,14 +38,14 @@ Greeting via a nested function:
|
||||
```markdown
|
||||
# main
|
||||
|
||||
*`a` = 2*
|
||||
*`b` = > add_one n=`a`*
|
||||
*a = 2*
|
||||
*b = > add_one n=`a`*
|
||||
> print text=`b`
|
||||
|
||||
## add_one
|
||||
+ `n`
|
||||
|
||||
**`n` + 1**
|
||||
**n + 1**
|
||||
```
|
||||
|
||||
## 5. Branch with else
|
||||
@@ -53,7 +53,7 @@ Greeting via a nested function:
|
||||
```markdown
|
||||
# main
|
||||
|
||||
*`n` = 0*
|
||||
*n = 0*
|
||||
|
||||
1. `n` > 0
|
||||
> print text=positive
|
||||
@@ -89,10 +89,10 @@ Greeting via a nested function:
|
||||
|------|------|
|
||||
| 水果 | 蔬菜 |
|
||||
|
||||
*`种` = 分类[^苹果] *
|
||||
*种 = 分类[^苹果]*
|
||||
> print text=`种`
|
||||
|
||||
*`第一` = 篮子[^1] *
|
||||
*第一 = 篮子[^1]*
|
||||
```
|
||||
|
||||
One column → list; ≥2 columns + one data row → map; ≥2 columns + many rows → map of lists. Data cells are expressions (same as call-arg values): bare words, numbers, `` `var` ``, quoted strings; URLs and `gpt-4o-mini` stay text via path/hyphen folding. Footnotes: lists use 1-based digit indices; maps use key text (including digit keys like `[^00]`). Foreach on a map walks **keys**.
|
||||
@@ -106,7 +106,7 @@ Row-oriented records (SQL-like): first header `@` / `行` / `row` → list of ma
|
||||
|----|------|------|
|
||||
| 1 | 苹果 | 2 |
|
||||
|
||||
*`名` = `订单`[^1][^品名] *
|
||||
*名 = 订单[^1][^品名]*
|
||||
```
|
||||
|
||||
## 7. Import text stdlib
|
||||
@@ -119,7 +119,7 @@ import text:lib/text.mq.md
|
||||
|
||||
# main
|
||||
|
||||
*`parts` = > split value=a,b,c sep=,*
|
||||
*parts = > split value=a,b,c sep=,*
|
||||
> print text=`parts`
|
||||
```
|
||||
|
||||
@@ -129,7 +129,7 @@ import text:lib/text.mq.md
|
||||
# main
|
||||
|
||||
This whole paragraph is a comment, including lines that look like code:
|
||||
*`not_executed` = 1*
|
||||
*not_executed = 1*
|
||||
> print text=also still comment
|
||||
|
||||
After a blank line, code runs:
|
||||
@@ -147,7 +147,7 @@ import math:lib/math.mq.md
|
||||
|
||||
# main
|
||||
|
||||
*`t` = > num value=3.5*
|
||||
*t = > num value=3.5*
|
||||
> print text=`t`
|
||||
```
|
||||
|
||||
@@ -163,19 +163,28 @@ See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` construc
|
||||
## hello
|
||||
+ `who`
|
||||
|
||||
*`msg` = "Hello, `who`!" *
|
||||
**`msg`**
|
||||
*msg = "Hello, `who`!"*
|
||||
**msg**
|
||||
|
||||
# Loud = > Greeter
|
||||
|
||||
## hello
|
||||
+ `who`
|
||||
|
||||
*`msg` = "HELLO, `who`!" *
|
||||
**`msg`**
|
||||
*msg = "HELLO, `who`!"*
|
||||
**msg**
|
||||
```
|
||||
|
||||
`_type` stays the most specific name (`Loud`). Methods walk the base chain; same-name `##` on the child overrides. No implicit super in v1.
|
||||
`_type` stays the most specific name (`Loud`). Methods walk the base chain; same-name `##` on the child overrides. **No implicit super** — if the child needs parent fields, call the parent explicitly:
|
||||
|
||||
```markdown
|
||||
# Child = > Parent
|
||||
+ `name`
|
||||
|
||||
*self = > Parent name=`name`*
|
||||
*self = > json.set map=`self` key=extra value=1*
|
||||
**self**
|
||||
```
|
||||
|
||||
## 11. Agent layout (ABI)
|
||||
|
||||
@@ -188,8 +197,8 @@ import agent:ext/agent.mq.md
|
||||
|
||||
> load_native
|
||||
|
||||
*`ws` = > agent *
|
||||
*`n` = > `ws`.ensure_layout *
|
||||
*ws = > agent*
|
||||
*n = > `ws`.ensure_layout*
|
||||
> print text=`n`
|
||||
```
|
||||
|
||||
@@ -223,3 +232,42 @@ if x > 0:
|
||||
2. *
|
||||
> print text=y-other
|
||||
```
|
||||
|
||||
## 13. Dynamic site (ext/web, minimal)
|
||||
|
||||
```markdown
|
||||
---
|
||||
title: hello-site
|
||||
import web:ext/web/web.mq.md
|
||||
import db:db/index.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`shell` =
|
||||
|
||||
| 组件 | 样式 |
|
||||
|------|------|
|
||||
| nav | |
|
||||
|
||||
`main` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| title | posts.title | |
|
||||
| body | posts.summary | |
|
||||
|
||||
*store = > db.open*
|
||||
*css = "body{font-family:sans-serif}"*
|
||||
*page = > web.page title="Hello"*
|
||||
*page = > page.compose_components components=`shell`*
|
||||
*page = > page.compose_main main=`main`*
|
||||
*page = > page.css css=`css`*
|
||||
*app = > web.app page=`page` port=8080*
|
||||
*app = > app.static prefix="/static" dir="static"*
|
||||
> listen app=`app`
|
||||
```
|
||||
|
||||
- Import `ext/web/web.mq.md` **or** `ext/web/网页.mq.md` — not both; match API language to the file.
|
||||
- Full blog/CMS patterns: `examples/marqdo-blog/` (routes, SEO, RSS, auth, upload, WS).
|
||||
- Run after `marqdo ext add web` and building `marqdo_plugin_web`.
|
||||
@@ -12,8 +12,8 @@ marqdo view PATH # docs browser, default port 7429
|
||||
marqdo debug PATH # debugger UI, default port 7430
|
||||
marqdo catalog PATH -o .marqdo
|
||||
marqdo ext list
|
||||
marqdo ext add llm|agent
|
||||
marqdo ext remove llm|agent
|
||||
marqdo ext add llm|agent|web|quantum
|
||||
marqdo ext remove llm|agent|web|quantum
|
||||
```
|
||||
|
||||
Diagnostics look like `path:line:col: message` (1-based line/col).
|
||||
@@ -43,7 +43,7 @@ Import one file; use **that** file’s function names.
|
||||
| EN import | ZH import | Typical APIs (EN / ZH) |
|
||||
|-----------|-----------|-------------------------|
|
||||
| `lib/text.mq.md` | `lib/文本.mq.md` | text helpers / 去空白·拆分·拼接… |
|
||||
| `lib/table.mq.md` | `lib/表.mq.md` | table/rows helpers |
|
||||
| `lib/table.mq.md` | `lib/表.mq.md` | `put`/`改` + list/map(见 `doc/design/stdlib-table.md`) |
|
||||
| `lib/fs.mq.md` | `lib/文件.mq.md` | filesystem |
|
||||
| `lib/sys.mq.md` | `lib/系统.mq.md` | process / cwd / load_dotenv |
|
||||
| `lib/plugin.mq.md` | `lib/插件.mq.md` | load native ABI plugins (`doc/design/ext-abi.md`) |
|
||||
@@ -54,9 +54,29 @@ Import one file; use **that** file’s function names.
|
||||
| `lib/foreign.mq.md` | `lib/外联.mq.md` | run foreign fenced blocks |
|
||||
| `ext/llm.mq.md` | `ext/大模型.mq.md` | `# llm` / `# 大模型` object + chat methods |
|
||||
| `ext/agent.mq.md` | `ext/智能体.mq.md` | agent **framework** (layout now; LLM orchestration roadmap in `ext-agent.md`) |
|
||||
| `ext/web/web.mq.md` | `ext/web/网页.mq.md` | dynamic sites — see **ext/web** section below |
|
||||
|
||||
Open the imported `.mq.md` under `lib/` or `ext/` to see exact `##` / `#` names and parameters. Gold tests: `tests/lib/`, `tests/structure/`, `tests/ext/`.
|
||||
|
||||
## ext/web (dynamic sites)
|
||||
|
||||
Install: `marqdo ext add web` (`网页`). Native: `cargo build --release -p marqdo_plugin_web`.
|
||||
|
||||
| EN import | ZH import | Core types |
|
||||
|-----------|-----------|------------|
|
||||
| `ext/web/web.mq.md` | `ext/web/网页.mq.md` | `# page` `# style` `# db` `# form` `# app` `# auth` `# cache` `# storage` |
|
||||
|
||||
| Area | EN methods (representative) | Notes |
|
||||
|------|----------------------------|-------|
|
||||
| Page | `compose_components`, `compose_main`, `render`, `meta`, `paginate` | GFM tables; cells are literal path strings |
|
||||
| DB | `init`, `insert`, `select`, `paginate`, `get`, `update`, `delete`, `migrate`, `fts`, `search`, `count`, `事务`/`txn` | init supports `unique`/`index`/`fk`; auto `created_at`/`updated_at` |
|
||||
| App | `route`, `static`, `configure`, `listen`, `auth`, `gate`, `upload`, `download`, `gallery`, `route_rss`, `redirect`, `error_page`, `sitemap`, `robots` | W0–W7 + P3 complete |
|
||||
| Auth | `login`, `check`, `logout`, `hash_password` | argon2 + CSRF + SQLite sessions; `role` for RBAC |
|
||||
|
||||
Drivers (Postgres / Redis / S3): `db url=postgres://…`, `cache url=memory:`, `storage url=file:…` — see `doc/design/ext-web-drivers.md`.
|
||||
|
||||
Example project: `examples/marqdo-blog/`. Capability matrix: `doc/design/web-net-capabilities.md`.
|
||||
|
||||
## Formula + plot (math)
|
||||
|
||||
```markdown
|
||||
@@ -71,7 +91,7 @@ $$
|
||||
x^2 - 2
|
||||
$$
|
||||
|
||||
*`_svg` = > plot formula=`f` var=x min=-3 max=3 *
|
||||
*_svg = > plot formula=`f` var=x min=-3 max=3*
|
||||
```
|
||||
|
||||
Empty RHS assignment + following `$$…$$` binds a formula value. Narrative-only `$$` without binding is display, not assignment.
|
||||
@@ -132,4 +152,6 @@ See `doc/design/call-arguments.md`.
|
||||
| `doc/design/ext-llm.md` | `ext/llm` |
|
||||
| `doc/design/ext-agent.md` | `ext/agent` agent **framework** (layout shipped; LLM orchestration roadmap) |
|
||||
| `doc/design/ext-cli.md` | `marqdo ext list/add/remove` |
|
||||
| `doc/design/ext-web.md` | `ext/web` dynamic sites (author API) |
|
||||
| `doc/design/web-net-capabilities.md` | ext/web capability matrix (W0–W7 + P3) |
|
||||
| `doc/design/view-debug.md` | view / debug hosts |
|
||||
Reference in new issue
Block a user