Release 2.7.0: executable handbooks and native user-site workflows

This commit is contained in:
cflmy committed 2026-11-10 17:03:06 +08:00
1 parent aa0c4d0f55
commit d9aef957f7
562 files changed
+21064 -20387

No files matched your search

+1 -1
View File
@@ -1 +1 @@
2.6.0
2.7.0
+24
View File
@@ -0,0 +1,24 @@
---
markup: occlusion
title: Native administration resource
import:
table: lib/table.mq.md
---
This single-purpose resource enables the existing native administration surface on a prepared app. It does not construct a page or configure unrelated middleware. Attach real authentication afterwards so the native runtime adds its administration gate before listening. Custom Document desks remain ordinary declared routes and do not need this switch.
## enable
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | map | required | Prepared application retaining its native admin_prefix, normally /admin |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Updated app with native administration enabled; no listener starts |
Use `app` before attaching authentication and before listen. This pure resource composition retains the app's database, discovered Documents and other bindings, and changes only the existing native admin flag. The runtime lists only the business tables associated with explicitly mounted forms, shows up to 100 current rows per table, and links to those actual form resources. It does not enumerate unrelated credential/session tables or expose arbitrary SQL. The native renderer owns this landing page and its reserved route namespace. It does not create a second application configuration API.
Authentication must be configured separately. When it is attached after enabling this surface, the existing native admin policy installs the default administration gate. The caller keeps the returned application and verifies both denied and accepted requests. Enabling a UI is not proof that credentials or database access have been authorized; the explicit server workflow supplies those dependencies.
Return *[Enable only the native administration surface](table.put(in=`app`, at="admin", value=True))*.
+28
View File
@@ -0,0 +1,28 @@
---
markup: occlusion
title: Read-only JSON query routes for a database-backed site
import:
plugin: lib/plugin.mq.md
---
Use this leaf when a prepared web application needs native read-only database JSON routes. Database connections remain owned by db.mq.md; request tenant selection remains owned by the security tenant resource. This module only binds an explicit query table before listening. It does not introduce a second application configuration language.
## mount
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | any | required | Prepared application with its database resource |
| routes | any | required | GFM rows with path, method, table, order, limit and optional tenant_scope |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Updated app containing the selected JSON query route set |
Use `app` and `routes` with plugin. The table uses site-relative paths, database table names, a native order expression and row limits. This binding replaces the application's JSON query route set; supply all desired query routes in one readable table. Other middleware settings are retained. Keep the returned app for subsequent resource bindings and listen.
Set tenant_scope to True only together with tenant.attach from ext/security/tenant.mq.md. With tenant resolution enabled, a scoped query requires a resolved tenant and adds an equality filter on its configured column. Tenant selectors do not authenticate users or prove membership. Protect private data through real authentication and trusted tenant selection; a query-string demonstration deliberately permits choosing either demo tenant.
The native route surface selects rows and returns a JSON object with a rows list; it does not implement arbitrary SQL, write endpoints or form submission. Reading this source grants no network access and mounting does not listen. Extend native query behavior in the existing web middleware implementation, keep database policy visible in the route table, and test missing-tenant as well as cross-tenant responses.
We **native = [Resolve the maintained database/web boundary](plugin.native_path(name="web"))** and **[Load its existing route implementation](plugin.load(path=`native`))**.
Return *[Bind this explicit JSON query route table](web_app_middleware(app=`app`, cors=None, security=None, compress=None, body_limit=None, json_routes=`routes`, access_log=None, cache_control=None, proxy=None, invoke=None))*.
+45
View File
@@ -26,6 +26,51 @@ We retain **`p` = [Locate the installed native plugin](plugin.native_path(name="
We **[End this run with the selected exit status](sys.exit(code=1))**.
Return *None*.
## reference
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| id | text | required | Exact id explicitly registered with mount |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Pure form_ref Resource for component.resource |
Use `id` to reference the same mounted form that handles submissions. This constructor does not create a form, load a plugin or register a route. Serving resolves the id after preparing the request's actual CSRF token and return path. An unknown id is a real request error; it cannot become an empty successful form.
The form's field/rule resource remains the single source for rendering and validation. Error responses retain the current CSRF token so the user can correct a field and resubmit. Authorization belongs to mount's optional role gate and the server's authentication policy, not the visibility of this node.
`resource` =
| _type | id |
|---|---|
| form_ref | `id` |
Return *resource* for explicit placement in the existing View schema.
## mount
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | any | required | Prepared web application with its actual database |
| id | text | required | Explicit system-form identifier used by reference |
| form | any | required | Form resource containing fields, rules and submission action |
| roles | any | None | None keeps public form behavior; otherwise gate the actual system form route |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Updated app with this form and optional server role gate |
Use `app`, `id`, `form` and `roles`=None before listening. Keep the returned app. The native system form route uses the same resource to validate and submit; component.resource only places its reference in the readable page layout. No user route is implicitly registered. System endpoints remain visible through web.inspect.
For a private form, provide roles explicitly so the actual /_form/id GET and POST path is gated as well as any containing page. Merely hiding a form or gating its presentation URL is insufficient. Configure authentication separately. A public creation example can retain roles=None. Existing sessions must submit the correct CSRF token; field-validation retries keep that token in the response.
We **[Load the existing form implementation](_load())** and **mounted = [Bind this form to its explicit system id](web_app_mount_form(app=`app`, id=`id`, form=`form`))**.
1. `roles` != None
We **mounted = [Protect the actual system form endpoint](web_app_gate(app=`mounted`, path="/_form/" + id, roles=`roles`, permissions="", match="exact", on_deny="redirect", exclude=None))**.
Return *mounted* after the explicit form resource and policy are attached.
# form
| 参数 | 类型 | 默认 | 说明 |
+13 -4
View File
@@ -6,12 +6,18 @@ import:
db_api: ext/data/db.mq.md
fs: lib/fs.mq.md
path: lib/path.mq.md
result: lib/result.mq.md
---
Start here when a program needs persistent records, short-lived values, object storage or forms.
The public resource files remain the implementation: [database](db.mq.md) owns schemas and
transactions, [cache](cache.mq.md) owns expiry, [storage](storage.mq.md) owns blobs and upload
validation, and [forms](form.mq.md) separates validation, rendering and submission.
[View queries](view.mq.md) (中文:[视图](视图.mq.md)) retain current records inside recursive View nodes.
[Native administration](admin.mq.md) exposes only mounted forms and their business tables.
中文作者可以使用[表单](表单.mq.md)构造、定义字段规则、引用与挂载资源,使用[后台](后台.mq.md)启用同一个原生管理入口。
[JSON query routes](api.mq.md) bind read-only database responses to a prepared site;
pair tenant-scoped queries with the explicit security tenant resource.
These modules use the native web plugin. In this source checkout build it with
scripts/build-web-plugin.sh; installed packages follow the web package installation route.
@@ -22,7 +28,7 @@ Neither example needs a cloud account, credentials or an external service.
```sh
marqdo call ext/data/index.mq.md memory_cache 'key="manual"' 'value="ready"' --effects plugin --json
marqdo call ext/data/index.mq.md transaction_roundtrip "root=\"$MQ_WORK\"" --effects plugin,fs.write --fs-root "$MQ_WORK" --json
marqdo call ext/data/index.mq.md transaction_roundtrip --effects plugin,fs.write --fs-root "$MQ_WORK" --json
```
A resource constructor creates an object; its methods need that actual receiver. Use the free
@@ -62,19 +68,22 @@ so another operation does not inherit it. Return *stored* as observed, including
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| root | text | required | Absolute disposable root, matching --fs-root; native resource URLs need an absolute path |
| root | text | "." | Expected filesystem root; the default uses the actual --fs-root context |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | The committed row list and native commit/rollback outcomes; the second insert is rolled back |
Use the absolute `root` supplied for --fs-root. This isolated-file example shows the whole ownership sequence: create a schema, begin a transaction,
Use `root`="." for the actual --fs-root context, or pass the same absolute root explicitly. This isolated-file example shows the whole ownership sequence: create a schema, begin a transaction,
write through its receiver, finish it, and read outside it. A second transaction is explicitly
rolled back. The standalone txn constructor wraps the actual native identifier and connection URL;
it does not begin another transaction or invent an identifier.
We **actual_root = [Resolve the actual granted filesystem root](fs.resolve(path="."))** and **expected_root = [Check the optional explicit root](fs.resolve(path=`root`))**.
1. `actual_root` != `expected_root`
Return *[Keep an inconsistent resource root explicit](result.error(code="data.root", message="root must match the granted filesystem root", operation="transaction_roundtrip"))*.
First **directory = [Create an owned temporary directory under the granted root](fs.temp_dir(prefix="data-manual"))**.
The filesystem helper returns a root-relative name. We retain **work_dir = [Resolve that owned name against the explicit root](path.join(a=`root`, b=`directory`))**
The filesystem helper returns a root-relative name. We retain **work_dir = [Resolve the owned name through the actual filesystem context](fs.resolve(path=`directory`))**
and **[Check that this absolute directory is inside the granted filesystem root](fs.stat(path=`work_dir`))**
before giving any path to the native database. We select **database_path = [Choose the SQLite file inside that directory](path.join(a=`work_dir`, b="manual.db"))**
and select **database_url = "sqlite:" + database_path** before creating
+40
View File
@@ -0,0 +1,40 @@
---
markup: occlusion
title: Request-time database View resources
---
Use this single-file resource handbook when a recursively composed page needs current database rows on each request. Construction is pure: it records a query without connecting, selecting or rendering HTML. Place the result in component.resource and retain view: main for startup layout assembly. The application supplies its actual database resource when serving.
Do not combine view: main with automatic data_source metadata. Ordinary Documents keep that metadata path; explicit View pages use this query Resource instead. A missing database, invalid condition or backend failure remains a request error, never a fabricated empty list. See [the request-resource design](../../doc/design/web-view-resources.md).
## query
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| source | text | required | Existing table on the serving application's database |
| where | any | None | Native condition map or list; route placeholders resolve from actual request params |
| order | text | "" | Native database ordering, such as -created_at |
| limit | number | 50 | Integer from 1 through 1000 |
| detail | bool | False | False renders cards; True renders the first matching full article |
| link_prefix | text | "/post/" | Site-relative prefix applied to row slugs, or empty for no prefix |
| tenant_scope | bool | False | Require an attached tenant policy and current tenant filter |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Pure data_query Resource; no query has executed yet |
Use `source`, `where`=None, `order`="", `limit`=50, `detail`=False, `link_prefix`="/post/" and `tenant_scope`=False. The native renderer validates the contract before listening, then selects current records for each request. Card titles and summaries are escaped; article content uses the existing Markdown renderer. Detail mode prefers the complete body/content even when a summary exists.
Rows follow the current Document convention: title, slug or href, summary, body or content, optional created_at/meta and tag. This fixed projection preserves the native card/article surface without restoring a private binding-table DSL. Layout remains in parent components; this resource only supplies one dynamic content region. For a different domain projection, keep a separate documented resource rather than passing arbitrary page configuration.
Conditions are copied before replacing route placeholders, so one request cannot mutate another's retained definition. Path parameters take precedence over query keys. A requested tenant scope requires actual tenant configuration and context; direct selectors do not prove user membership. Link visibility and data filtering do not replace authentication or server authorization.
This constructor needs no effects. Serving needs the actual web/database plugin and the launcher grants. Rendering the Resource offline without request context reports that requirement explicitly. Reading this file does not authorize a query, write or network listener.
`resource` =
| _type | source | where | order | limit | detail | link_prefix | tenant_scope |
|---|---|---|---|---|---|---|---|
| data_query | `source` | `where` | `order` | `limit` | `detail` | `link_prefix` | `tenant_scope` |
Once its intended request behavior is explicit, return *resource* for placement in a View resource node.
+24
View File
@@ -0,0 +1,24 @@
---
markup: occlusion
title: 原生后台资源
import:
admin: ext/data/admin.mq.md
---
本文件与 admin.mq.md 的原生后台开关对应。自定义后台 Document 继续显式声明自己的路由;这里仅启用已有的原生后台。先准备应用,再启用后台、附加鉴权,最后监听。它不承担任意页面配置或数据库管理语言。
## 启用
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 应用 | map | 必填 | 准备站点返回的应用,保留数据库和后台路径 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | map | 只改变原生后台标志的新应用;未开始监听 |
输入`应用`,本操作是纯资源组合,无需插件,不创建路由服务器或新数据库。保留返回的新应用后再附加鉴权,使原生策略安装默认后台门禁。后台只列显式挂载表单关联的业务表,每表展示至多 100 条当前记录,并链接到真实表单。
它不枚举其他凭据、会话表,也不开放任意 SQL。启用展示能力不证明用户已经认证,应验证匿名拒绝与已登录访问两个方向。自定义内容布局继续由 View 与 Document 负责;不要为后台添加新的通用配置袋。
配置后返回 *[启用已有的原生后台能力](admin.enable(app=`应用`))*。
+110
View File
@@ -0,0 +1,110 @@
---
markup: occlusion
title: 表单资源:构造、规则、引用与挂载
import:
form: ext/data/form.mq.md
---
本文件对应英文 form.mq.md 的服务端装配工作流,中文作者直接调用这些具名函数。独立校验、离线表单渲染与直接提交仍使用英文文件对象的 validate、render、submit,不把页面引用当成直接写入工具。字段与规则同属一个原生表单资源,页面只安放引用,服务入口显式挂载它。构造、字段更新、校验与提交需要 plugin;引用是纯计算。以下示例只构造引用,不打开数据库或提交记录。
```sh
marqdo call ext/data/表单.mq.md 引用 '标识="article"' --json
```
准备真实表单时按构造、字段、规则、文案的顺序保留每次返回的新资源,再挂载到已准备的应用。实际处理请求的是 /_form/标识 系统地址。只保护展示页面不能保护提交入口;私有表单应给挂载指定角色,并另行配置鉴权。
## 构造
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 表 | text | 必填 | 已存在的数据库业务表名 |
| 动作 | text | "insert" | 原生提交动作,例如 insert 或 update |
| 标识 | any | None | update 使用的记录标识;插入通常不指定 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | any | 尚未提交的原生表单资源 |
输入`表`、`动作`="insert"与`标识`=None,调用需要 plugin。这里只创建表单资源,不建表、不插入记录,也不验证一次用户请求。继续调用字段与规则保留完整定义;实际数据库来自服务入口的应用资源。缺少原生插件或不支持的动作应保留真实诊断。
构造完成后返回 *[创建指定业务表的原生表单](form.form(table=`表`, action=`动作`, id=`标识`))*。
## 字段
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 资源 | any | 必填 | 构造返回的实际表单资源 |
| 定义 | any | 必填 | name、label、type、required 等字段记录表 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | any | 带字段定义的新表单资源 |
输入`资源`和`定义`。name 应对应业务表字段;label 是展示文案,type 选择原生输入类型,required 使用布尔值。记录表用 @ 首列保持逐行结构。更新需要 plugin,返回值供规则或挂载继续使用;不提交用户输入,也不改变数据库结构。
完成定义后返回 *[将字段绑定到同一个表单](> `资源`.fields fields=`定义`)*。
## 规则
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 资源 | any | 必填 | 已有字段定义的实际表单资源 |
| 定义 | any | 必填 | field、rule、message 记录;例如 required 与 max:120 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | any | 带原生校验规则的新表单资源 |
输入`资源`和`定义`。规则按字段名关联,message 是拒绝输入时显示的原因。服务端仍执行相同规则,不能只依赖浏览器必填属性。此步需要 plugin,但不会尝试插入或更新记录。保留返回值,避免挂载未携带新规则的旧资源。
规则明确后返回 *[绑定实际提交使用的校验规则](> `资源`.rules rules=`定义`)*。
## 文案
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 资源 | any | 必填 | 保留字段和规则的实际表单资源 |
| 提交 | text | "提交" | 提交按钮文字 |
| 取消 | text | "取消" | 取消链接文字 |
| 返回地址 | text | "" | 取消目标;也是原生成功提交返回地址 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | any | 带按钮文字和返回目标的新资源 |
输入`资源`、`提交`="提交"、`取消`="取消"和`返回地址`="",调用需要 plugin。文案是纯文本,不承载 HTML。显式返回地址用于成功后的跳转;没有指定时由原生请求返回路径决定。设置按钮文案本身既不授权提交,也不改变字段校验规则。
配置后返回 *[保留提交、取消与成功返回目标](> `资源`.labels submit=`提交` cancel=`取消` cancel_href=`返回地址`)*。
## 引用
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 标识 | text | 必填 | 服务入口通过挂载显式注册的系统表单标识 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | map | 供组件请求资源节点安放的 form_ref 描述 |
使用`标识`引用实际挂载的表单。构造无需任何副作用,不加载插件、不注册路由,也不伪造字段或 CSRF。请求时才由原生服务读取当前会话、返回路径和同一份字段规则;未挂载的标识保留错误,不能变成空的成功表单。
声明后返回 *[引用请求时的同一个表单](form.reference(id=`标识`))*。
## 挂载
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 应用 | any | 必填 | 已准备、保留数据库与路由上下文的应用 |
| 标识 | text | 必填 | 页面引用与系统 /_form/ 路径使用的标识 |
| 资源 | any | 必填 | 保留字段、规则和文案的实际表单 |
| 角色 | any | None | None 保持公开行为;否则保护实际系统表单 GET 与 POST |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | any | 挂载资源与可选角色门禁后的新应用 |
使用`应用`、`标识`、`资源`与`角色`=None,在监听前授予 plugin 并保留返回的应用。挂载绑定的是明确的系统地址,不暗中注册业务页面。私有表单应指定允许的角色并配置鉴权;仅隐藏控件或保护展示页不足以保护提交。
会话存在时提交必须携带真实 CSRF,字段失败的重试页面仍保留该令牌。系统路径可通过网页检视观察,但检视不能证明数据库可写或当前用户获准提交。公开示例可以保持角色为空,生产策略由调用者明确决定。
准备就绪后返回 *[绑定实际表单处理器及其访问策略](form.mount(app=`应用`, id=`标识`, form=`资源`, roles=`角色`))*。
+40
View File
@@ -0,0 +1,40 @@
---
markup: occlusion
title: 请求期间查询数据库的视图资源
---
本文件是单文件资源手册。递归页面需要随请求变化的数据库记录时,构造这里的查询资源,再放入组件的资源节点。构造本身是纯计算,不连接数据库,也不生成 HTML;实际查询使用监听应用绑定的数据资源。
view: main 仍在启动时装配结构,不能混用自动 data_source 元数据。普通文档可继续使用元数据绑定;显式 View 用本资源表达动态内容。缺少数据库、条件错误或后端故障都保留请求诊断,不伪造空列表。
## 查询
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 源 | text | 必填 | 监听应用数据库中已有的业务表 |
| 条件 | any | None | 原生条件记录或列表;路径占位来自实际请求参数 |
| 排序 | text | "" | 数据库排序,例如 -created_at |
| 上限 | number | 50 | 1 至 1000 之间的整数 |
| 详情 | bool | False | False 显示卡片,True 显示首条完整文章 |
| 链接前缀 | text | "/post/" | 加到短链前的站内路径前缀 |
| 租户作用域 | bool | False | 要求显式租户策略及实际租户上下文 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | map | 尚未查询的 data_query 资源,可放入资源节点 |
使用`源`、`条件`=None、`排序`=""、`上限`=50、`详情`=False、`链接前缀`="/post/"与`租户作用域`=False。服务器先检查资源契约,再在每个请求中查询当前记录。卡片标题与摘要经过转义,完整文章使用已有 Markdown 渲染器;有摘要时,详情仍应显示完整正文,空正文也不会被摘要替换。
返回记录沿用文档的数据约定:title、slug 或 href、summary、body 或 content,以及可选的 created_at/meta 与 tag。父组件继续决定布局,本资源只承担一个动态内容区域。它不恢复旧的页面绑定表,也不接受任意页面配置。需要其他领域投影时,应另立职责清楚的资源。
每次请求先复制条件,再替换实际路径参数,避免污染启动时保留的定义。路径参数优先于同名查询参数。租户作用域要求已有租户策略和已解析租户;请求中的选择值不证明用户属于该租户,数据过滤也不能替代鉴权。
构造不需要副作用权限;服务实际使用插件和监听入口的授权。离线渲染缺少请求上下文时明确报错,不声称已执行查询。阅读源码不会授权数据库访问、写入或启动网络监听。
`资源` =
| _type | source | where | order | limit | detail | link_prefix | tenant_scope |
|---|---|---|---|---|---|---|---|
| data_query | `源` | `条件` | `排序` | `上限` | `详情` | `链接前缀` | `租户作用域` |
请求行为交代清楚后,返回 *资源*,交给组件资源节点安放。
+371
View File
@@ -0,0 +1,371 @@
---
markup: occlusion
title: Engineering boundaries for executable handbooks
import:
plugin: lib/plugin.mq.md
sys: lib/sys.mq.md
paths: lib/path.mq.md
table: lib/table.mq.md
result: lib/result.mq.md
---
This extension supplies the small OS and service boundaries used by executable
engineering handbooks. File reads/writes, JSON/TOML, data decisions, retries and
release ordering remain Marqdo code. The native plugin provides bounded argv
process execution, private authenticated GitHub HTTPS, ZIP inspection and R2
Signature V4 uploads. No Python interpreter or generated shell program is used.
Read the task contract before calling it. Process children and native plugins
have the calling OS user's authority; a plugin grant is broader than a native
filesystem grant. The root parameter selects a working/artifact directory, not
an OS sandbox. Never treat reading this file as authorization to push refs,
change a release, upload assets or run arbitrary commands.
Build this repository's marqdo_plugin_engineering crate before first use; the
development handbook's prepare_engineering task performs that bootstrap through
marqdo call. MARQDO_ENGINEERING_PLUGIN may select a locally built library. Installed
packs use the same plugin resolver as other official extensions. This boundary
is native-only; browser WASM cannot start processes or load this library.
The public operation definitions and private request helper below share one
implementation. For the complete release workflow, read
[the executable release handbook](../../skills/marqdo-release/index.mq.md).
Normal filesystem work uses [the native file tools](../../skills/marqdo-dev/files.mq.md);
this extension is not an alternate file-write API.
## _load
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Load the installed or locally built engineering plugin |
Resolve the library through the existing extension resolver so an installed
pack and a development build share the same public calls. A missing library
produces the normal plugin diagnostic; build or install it rather than hiding
the failure behind a fixed success result. Repeated loads use the host loader's
existing ownership rules. This private boundary requires plugin effects and
never guesses a Python replacement or invents an external interpreter.
We **path = [Resolve the engineering native library](plugin.native_path(name="engineering"))**.
After locating it we return *[Load the bounded engineering operations](plugin.load(path=`path`))*.
## request
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| operation | text | required | command, git_inspect, github, archive, analyze, gzip_text or r2_put |
| payload | map | required | Operation-specific ordinary data; never credential values |
| root | text | "." | Existing working/artifact root for this operation |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result.ok/value/error from the selected boundary |
Use `operation`, `payload` and `root`="." only at a documented native boundary.
Inputs travel as structured plugin values, not strings containing a generated
program. Failed process setup, HTTP, archive validation or signing remains a
failed Result. A successful command request still requires checking value.code
and value.timed_out. No private credential becomes a tool argument or result;
authentication is resolved inside the plugin from existing stores.
We **loaded = [Load this package's native boundary](_load())** and
**base = [Read the granted runtime working root](sys.cwd())** and **resolved_root = root**.
1. not [The requested root is already absolute](paths.is_absolute(path=`root`))
We **resolved_root = base + "/" + root** so process and native filesystem locations agree.
`request_data` =
| operation | payload | root |
|---|---|---|
| `operation` | `payload` | `resolved_root` |
Return *[Perform the explicit native boundary operation](engineering_request(request=`request_data`))*.
## run
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| argv | list | required | Executable followed by individual text arguments |
| cwd | text | "." | Existing directory inside root |
| timeout_ms | number | 120000 | Positive limit through 3600000 milliseconds |
| max_output | number | 262144 | Per-stream capture limit through 16777216 bytes |
| stdin | any | None | Optional text sent to child stdin, then closed |
| env | any | None | Optional child-only text environment values |
| root | text | "." | Root used to resolve cwd and local Git identity |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing code/stdout/stderr/timed_out/truncated |
Use `argv`, `cwd`=".", `timeout_ms`=120000, `max_output`=262144, `stdin`=None,
`env`=None and `root`="." to invoke an existing OS tool. Arguments are passed
individually even when they contain quotes, spaces or shell metacharacters.
Inline shell programs, forced Git updates and hook bypass are rejected; a
checked-in packaging script remains a normal explicit external-tool invocation.
The return distinguishes transport completion from child success. Inspect code
and timed_out before consuming stdout. Output is drained concurrently and kept
within the requested cap so noisy children cannot deadlock their own pipes.
On Unix, timeout kills the child process group; Windows attempts taskkill's tree
termination. Output retained by surviving descendants cannot cause unbounded
waiting. A process environment is child-local and does not mutate the parent.
`payload` =
| argv | cwd | timeout_ms | max_output | stdin | env |
|---|---|---|---|---|---|
| `argv` | `cwd` | `timeout_ms` | `max_output` | `stdin` | `env` |
Return *[Execute the explicit argument vector with bounded capture](request(operation="command", payload=`payload`, root=`root`))*.
## github
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | API path under /repos/cflmy/marqdo/ |
| method | text | "GET" | GET, PATCH or POST; mutations need the user's task instruction |
| data | any | None | JSON body; no authentication data |
| missing | bool | False | Treat GET 404 as a successful None |
| root | text | "." | Checkout used by credential helpers |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing service JSON, None or a redacted transport error |
Use `path`, `method`="GET", `data`=None, `missing`=False and `root`=".".
The plugin resolves GH_TOKEN/GITHUB_TOKEN, Git's configured credential helper or
the checkout owner's existing gh store privately. It tries the configured
GitHub proxy before direct HTTPS. An uncertain POST is not replayed; a caller
must observe whether publication occurred before deciding to retry a mutation.
Only this repository's API paths are accepted. HTTP errors report their status
without reflecting credentials, signed URLs or arbitrary response bodies.
Missing evidence stays missing; a network failure is not a synthetic empty
release. Test endpoint overrides are explicit environment configuration and
belong only in isolated fixture runs.
`payload` =
| path | method | data | missing |
|---|---|---|---|
| `path` | `method` | `data` | `missing` |
Return *[Request private-authenticated repository service JSON](request(operation="github", payload=`payload`, root=`root`))*.
## inspect_zip
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | Existing ZIP or VSIX inside root |
| root | text | "." | Artifact root; symlink escapes are refused |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with entries and selected UTF-8 package metadata |
Use `path` and `root`="." to inspect a binary format without extraction.
The plugin caps entry count and total expanded size, rejects escaping paths and
symlinks, and reads every entry to validate its content/CRC. It retains only
bounded VERSION, Cargo and VSIX metadata text for Marqdo's role-specific checks.
Hashing the archive itself remains lib/fs.file_hash, not an alternate Python IO
path. ZIP metadata cannot prove plugin ABI compatibility or execute a program.
We **payload = [Name the one archive path field](table.put(in=None, at="path", value=`path`))**.
Return *[Inspect the archive format without writing extracted files](request(operation="archive", payload=`payload`, root=`root`))*.
## put_file
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| path | text | required | Verified upload file inside root |
| key | text | required | Explicit R2 key such as vX.Y.Z/filename.zip |
| sha256 | text | required | Previously verified SHA256; changed bytes are rejected |
| root | text | "." | Root containing the local upload file |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with written key, SHA256 and byte count |
Use `path`, `key`, `sha256` and `root`="." for an authorized publication.
The plugin transfers this bounded file across the authenticated service boundary
and rechecks its digest before signing; Marqdo decides which files and keys are
required. Credentials stay in existing R2 environment settings or ~/.marqdo/r2.env.
A configured credential home can select the maintainer's store when running under
another OS identity. Key material is never a parameter, result or command argument.
This is an external write. Successful PUT is evidence for that key only; public
CDN parity is checked separately. The release handbook uploads every pack before
writing VERSION pointers and never sweeps unrelated files from dist. A timeout
remains uncertain publication, so inspect the public object before retrying.
`payload` =
| path | key | sha256 |
|---|---|---|
| `path` | `key` | `sha256` |
Return *[Upload exactly the verified artifact with private R2 signing](request(operation="r2_put", payload=`payload`, root=`root`))*.
## put_text
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| key | text | required | Explicit VERSION key selected by the release workflow |
| text | text | required | Small UTF-8 pointer body with its intended trailing newline |
| root | text | "." | Checkout used to locate existing credential stores |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with written key, SHA256 and byte count |
Use `key`, `text` and `root`="." only after all required publication bytes are
verified. This operation signs a small UTF-8 service body; it does not write a
local file or infer which version should become latest. The calling Marqdo
workflow owns that decision and its ordering. Keys remain explicit so a replay
cannot silently publish a different version from environment state.
As with put_file, service completion does not substitute for reading the public
pointer and checking the associated download hashes.
`payload` =
| key | text |
|---|---|
| `key` | `text` |
Return *[Write the explicitly selected publication pointer](request(operation="r2_put", payload=`payload`, root=`root`))*.
## analyze
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| source | text | required | Exact source text already read through lib/fs |
| include_body | bool | False | Include compiler AST debug evidence for migration review |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result with compiler functions, contracts, diagnostics and narrative ratios |
Use `source` and `include_body`=False to inspect an authored document
without executing it. File access belongs to the caller's native filesystem
step; this operation receives text and uses the actual Marqdo parser and checker.
It does not invent a regular-expression grammar, load imports, run main, open
network resources or infer permission from prose. Full dependency checks still
use marqdo check on the real file.
The returned parameter names, defaults, heading spans and contracts support
editing without guessing the syntax. Narrative ratios come from the same
implementation used by the repository gate. AST debug evidence is optional
because it is large and intended for mechanical migration comparisons, while
the normal result remains a compact source description.
`payload` =
| source | include_body |
|---|---|
| `source` | `include_body` |
Return *[Inspect this text with the real compiler](request(operation="analyze", payload=`payload`))*.
## gzip_text
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| data | map | required | Portable bytes returned by net.get(response="bytes") |
| max_bytes | number | 16777216 | Positive expanded UTF-8 limit, at most 64 MiB |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result containing decoded UTF-8 text or bounded format failure |
Use `data` and `max_bytes`=16777216 at a compressed data boundary.
Native net.get owns the network read and returns portable bytes; this operation
only interprets their gzip format. It accepts concatenated gzip members, validates
their checksums, caps compressed input and expanded output, and rejects non-UTF-8
text. No temporary file, shell pipeline or Python process is involved.
This is useful for a published apt Packages.gz index. A successful HTTP response
alone cannot establish its package version; decode and inspect its real stanzas.
Malformed data or an expansion beyond the cap remains an error. Binary payloads
are outside this text contract. Calling requires plugin, while the caller's
earlier download independently requires network.read.
`payload` =
| data | max_bytes |
|---|---|
| `data` | `max_bytes` |
Return *[Decode the bounded compressed text format](request(operation="gzip_text", payload=`payload`))*.
## check_exit
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| outcome | map | required | Actual Result returned by engineering.run or its command boundary |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Observed process Result; failure retains its complete bounded execution evidence |
Use `outcome` from an actual process call. Starting a process successfully is
different from that process succeeding: command transport can return ok=true
with a nonzero child code. This pure adapter requires code zero and no timeout.
It never starts or retries a process, changes a command or discards failed output.
A setup/transport failure is retained unchanged. A nonzero exit or timeout becomes
a failed Result with the original execution record in value, including stdout,
stderr and truncation flags. This makes --require-ok useful for a complete
callable workflow without treating CLI transport success as a passed build.
Bounded output can be truncated even when the command succeeds; inspect that
flag before describing it as a full log.
This function only classifies supplied observations. It cannot prove that an
arbitrary caller-provided map came from a real command. Development tasks call
run and then this adapter in the same source flow, retaining their actual argv
and result. Release ordering and retry policy remain the caller's responsibility.
1. not access(`outcome`, "ok")
Return *outcome* with its original native setup failure.
We **execution = [Read the actual bounded process observation](access(outcome, "value"))**.
1. access(`execution`, "code") != 0 or access(`execution`, "timed_out")
We **failed = [Distinguish child failure from successful transport](result.error(code="engineering.process_failed", message="nonzero exit or timeout; inspect the actual execution in value", operation="check_exit"))**.
Return *[Keep all observed process evidence on failure](table.put(in=`failed`, at="value", value=`execution`))*.
Return *outcome* after the observed child exits successfully.
## checked
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| argv | list | required | Existing executable and individual text arguments |
| cwd | text | "." | Existing working directory within root |
| timeout_ms | number | 120000 | Positive child duration limit up to one hour |
| max_output | number | 262144 | Bounded bytes retained per stdout/stderr stream |
| stdin | any | None | Optional text sent to child standard input |
| env | any | None | Optional child-only text environment record |
| root | text | "." | Working root matching the intended checkout |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result requiring a zero child exit; actual execution evidence is retained |
Use `argv`, `cwd`=".", `timeout_ms`=120000, `max_output`=262144,
`stdin`=None, `env`=None and `root`="." to execute one existing tool and require
its success in the same callable workflow. It composes run and check_exit rather
than regenerating process management, credential handling or a shell program.
The parameter vector, directory and resource limits keep their existing meaning.
A setup failure, nonzero exit or timeout returns ok=false. Its actual stdout,
stderr and truncation state remain available for diagnosis. A successful result
means the observed child exited successfully; interpreting its business output
still belongs to the caller. Use --require-ok when this single call controls a
dependent external automation. No retry or publication is implied.
This operation requires plugin. Its child retains normal OS authority, and the
native boundary keeps its existing argv guards and private credential rules.
For example, a unit-test task can pass cargo, test, --lib and --offline as four
separate text elements without needing a new generated command script.
After the bounded execution we return *[Require the actual child outcome and preserve all evidence](check_exit(outcome=run(argv=`argv`, cwd=`cwd`, timeout_ms=`timeout_ms`, max_output=`max_output`, stdin=`stdin`, env=`env`, root=`root`)))*.
+182
View File
@@ -0,0 +1,182 @@
---
markup: occlusion
title: 工程拓展:让开发与发版操作成为可调用手册
import:
工程: ./index.mq.md
---
本文件是 [英文工程入口](index.mq.md) 的中文门面,复用同一个原生插件与行为。开发中的文件读取、撰写、哈希与数据处理应先使用标准库;本拓展只补齐进程、私密认证与压缩格式边界。任务的条件、重试和步骤顺序写在 mq.md 中,不再生成 Python 编排器。
首次使用前通过 skills/marqdo-dev/index.mq.md 的 prepare_engineering 构建本机开发解释器和插件。读取库文档不代表授权发布;推送、修改发布说明和上传对象必须属于用户已授权的任务。结果沿用 ok/value/error 字段,进程结果还要检查 code 和 timed_out,不能只根据请求成功就继续依赖步骤。
可在仓库根目录运行 marqdo call ext/engineering/索引.mq.md 运行 '参数=["git","--version"]' --effects plugin --fs-root . --json。完整发版流程位于 skills/marqdo-release/index.mq.md;普通文件操作位于开发目录的 files.mq.md。本地原生插件与子进程具有当前系统用户的权限,浏览器 WASM 不支持这些边界。
## 运行
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 参数 | list | required | 程序名与逐项文本参数,不是 shell 源码 |
| 目录 | text | "." | 根目录内的实际工作目录 |
| 超时毫秒 | number | 120000 | 1 到 3600000 毫秒 |
| 输出上限 | number | 262144 | 每个输出流的字节上限,最多 16 MiB |
| 输入 | any | None | 写入子进程标准输入后关闭;None 表示无输入 |
| 环境 | any | None | 仅影响子进程的文本环境映射 |
| 根目录 | text | "." | 与 --fs-root 一致的工程根目录;插件不提供操作系统沙箱 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:包含 code、stdout、stderr、timed_out 与 truncated |
使用`参数`,工作`目录`=".",`超时毫秒`=120000,`输出上限`=262144,`输入`=None,`环境`=None,`根目录`="."。参数逐项传递,空格、美元符号和引号不会被再次当作 shell 程序求值。命令入口拒绝内联 shell、强推和跳过钩子。
进程启动成功与命令执行成功是两个状态:必须检查 value.code 为零且 timed_out 为 False。输出并发读取并有界保存,避免大量日志堵住子进程。超时会尝试终止进程树,诊断信息保留已知凭据脱敏后的文本。调用需要 plugin;外部工具自己的文件和网络权限仍由操作系统决定。
完成该边界调用后返回*[按明确参数执行维护中的工具](工程.run(argv=`参数`, cwd=`目录`, timeout_ms=`超时毫秒`, max_output=`输出上限`, stdin=`输入`, env=`环境`, root=`根目录`))*。
## 分析源码
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 源码 | text | required | 已经通过固有文件库读取的完整源码 |
| 包含正文 | bool | False | 是否附带大体积 AST 调试证据 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:真实编译器的函数、契约、诊断和叙述比例 |
接收`源码`和`包含正文`=False,仅分析传入文本,不替调用者读取文件。这里复用解释器的真实解析与检查实现,不建立一套正则表达式语法。分析不会加载导入文件、执行 main 或请求外部服务。
参数顺序、默认值和源位置可以支持审阅式迁移;叙述比例采用仓库检查器的相同规则。附加正文仅适合需要逐语句核对的迁移诊断,普通使用先读契约与简要诊断。完整依赖正确性仍需对实际文件执行 marqdo check。调用需要 plugin,并不因源码描述了某个操作就授权执行该操作。
读到分析结果后返回*[用真实编译器检查这段文本](工程.analyze(source=`源码`, include_body=`包含正文`))*。
## 检查压缩包
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 路径 | text | required | 根目录内实际存在的 ZIP 或 VSIX |
| 根目录 | text | "." | 与 --fs-root 一致的工程根目录;插件不提供操作系统沙箱 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:包内条目与有界保存的版本元数据 |
使用`路径`与`根目录`=".",读取格式并校验每个条目的 CRC,整个过程不解压、不执行文件。插件拒绝越界路径、重复名称、软链接和超限展开量;标准库负责压缩包本身的大小与 SHA256。
检查格式通过不代表版本正确、插件 ABI 匹配或业务测试通过。调用者应继续核对具体产物角色、所需条目及 GitHub 提供的摘要。元数据文本有体积与 UTF-8 限制,缺失内容不能被当作已经验证。调用需要 plugin;根目录是工作位置,不能据此推断插件具有文件沙箱。
完成格式校验后返回*[检查真实压缩条目及其 CRC](工程.inspect_zip(path=`路径`, root=`根目录`))*。
## 解码gzip文本
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 数据 | map | required | 固有网络库返回的 portable bytes |
| 上限 | number | 16777216 | 展开后 UTF-8 字节上限,最多 64 MiB |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:解码文本或真实格式、编码、体积错误 |
输入`数据`,设置`上限`=16777216。此任务只解释已经读取的 gzip 字节格式,不下载、不创建临时文件。它支持连接的 gzip 成员、校验校验和,并同时限制压缩输入与展开结果;非 UTF-8 数据也会返回失败。
Ubuntu 的 Packages.gz 就需要这一格式边界。HTTP 请求成功后仍要解码实际索引并查找目标包,不能把 200 状态直接当作可安装证据。文件与网络读取仍由固有库完成,压缩格式缺口由拓展承接;调用需要 plugin,不需要 Python 或 shell 解压流水线。
解码完成后返回*[有界解码已经读取的压缩文本](工程.gzip_text(data=`数据`, max_bytes=`上限`))*。
## GitHub请求
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 路径 | text | required | 本项目 /repos/cflmy/marqdo/ 下的 API 路径 |
| 方法 | text | "GET" | GET 只读;PATCH 与 POST 属于外部写入 |
| 数据 | any | None | 结构化 JSON 请求体,不包含凭据 |
| 允许缺失 | bool | False | GET 的 404 是否表示成功的 None |
| 根目录 | text | "." | 与 --fs-root 一致的工程根目录;插件不提供操作系统沙箱 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:服务 JSON、允许的 None 或脱敏后的失败 |
使用`路径`,`方法`="GET",`数据`=None,`允许缺失`=False,`根目录`="."。原生边界私密读取现有 GitHub 认证存储,先尝试已配置代理再直连;凭据不能成为工具参数或返回值。此接口仅用于本项目服务路径。
POST 的不确定响应不会自动重放,避免重复发布。调用者需要先观察远端是否已经出现目标资源,再决定恢复操作。网络错误保留错误,只有明确允许的 GET 404 才变成 None。调用需要 plugin;读取本手册本身不授权 PATCH 或 POST,具体写入必须来自用户当前任务。
服务请求完成后返回*[通过私密认证边界请求项目服务](工程.github(path=`路径`, method=`方法`, data=`数据`, missing=`允许缺失`, root=`根目录`))*。
## 上传文件
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 路径 | text | required | 根目录内已经验证的上传文件 |
| 对象名 | text | required | 明确的 R2 对象名 |
| 摘要 | text | required | 预先通过固有文件库计算的 SHA256 |
| 根目录 | text | "." | 与 --fs-root 一致的工程根目录;插件不提供操作系统沙箱 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:已写对象、SHA256 与字节数 |
使用`路径`、`对象名`、`摘要`及`根目录`=".",只上传用户已授权发布的具体文件。插件在签名前再次检查摘要,防止校验后文件已经改变。R2 密钥留在既有环境与私密配置中,不传给模型、不写入源码。
此任务只证明这个对象的上传状态,不决定 latest,也不更新 VERSION。发布流程应先验证全部压缩包并上传,再写指针,最后读取公共 CDN 对比实际摘要。超时表示状态不确定,应观察对象而非立即假设没有上传。调用需要 plugin,原生文件整理与摘要计算仍由固有库完成。
完成明确对象的上传后返回*[上传仍与预验摘要一致的文件](工程.put_file(path=`路径`, key=`对象名`, sha256=`摘要`, root=`根目录`))*。
## 上传文本
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 对象名 | text | required | 发布流程明确选择的 VERSION 对象名 |
| 正文 | text | required | 包含预期换行的小体积 UTF-8 指针文本 |
| 根目录 | text | "." | 与 --fs-root 一致的工程根目录;插件不提供操作系统沙箱 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:已写对象、SHA256 与字节数 |
使用`对象名`、`正文`和`根目录`=".",在全部相关压缩包已经验证并上传后更新指定指针。此任务不选择版本,也不判断是否应该成为 latest;这些顺序和决策在发版 mq.md 中公开表达。
凭据仍由私密认证边界处理,正文不是本地文件写入的替代接口。请求成功之后还要读取公共指针及其对应压缩包,缓存延迟必须保持未完成状态,不能把另一次上传当作验证。调用需要 plugin,并且必须属于用户授权的发布任务;单纯阅读文档不能触发对象写入。
完成该指针写入后返回*[写入流程已经确定的发布指针](工程.put_text(key=`对象名`, text=`正文`, root=`根目录`))*。
## 检查退出
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 结果 | map | required | 运行任务返回的真实 Result 与子进程观察 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:只接受零退出且未超时的观察,失败仍保留输出 |
接收`结果`之后,按工程边界已有规则检查退出码和超时状态。进程成功启动不代表编译或测试通过,因此这里把非零退出转成失败 Result,标准输出、错误输出和截断标记仍保留在 value 中。启动失败则沿用原来的诊断。
这个纯函数不再执行、重试或发布任何东西,也不能证明任意传入记录来自真实命令。需要完整的一次调用流程时,使用下方运行并检查,由它在同一份源码里连接真实执行与状态判断。
检查结束后返回*[按实际子进程结果保留成功或失败证据](工程.check_exit(outcome=`结果`))*。
## 运行并检查
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 参数 | list | required | 已维护程序名及逐项文本参数 |
| 目录 | text | "." | 根目录内的实际工作目录 |
| 超时毫秒 | number | 120000 | 正数,最多 3600000 毫秒 |
| 输出上限 | number | 262144 | 每个输出流的有界字节数,最多 16 MiB |
| 输入 | any | None | 可选标准输入文本,发送后关闭 |
| 环境 | any | None | 仅影响子进程的文本环境记录 |
| 根目录 | text | "." | 实际工作根目录;不是操作系统沙箱 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Result:要求真实子进程成功,失败保留 code/stdout/stderr 等观察 |
使用`参数`,工作`目录`=".",`超时毫秒`=120000,`输出上限`=262144,`输入`=None,`环境`=None,`根目录`="."。这里复用运行与检查退出两个已经实现的步骤,不再让智能体撰写另一份命令脚本。参数、私密凭据、进程树超时和输出上限都沿用已有原生边界。
调用需要 plugin。启动失败、非零退出或超时返回 ok=False;配合 --require-ok 可以阻止后续自动化继续。成功只表示这次子进程按零退出结束,具体业务结果仍由调用者判断。子进程拥有正常操作系统权限,不能把根目录参数当作沙箱,也不能把阅读本文当作发布授权。
执行结束后返回*[运行维护中的工具并检查其真实结果](工程.checked(argv=`参数`, cwd=`目录`, timeout_ms=`超时毫秒`, max_output=`输出上限`, stdin=`输入`, env=`环境`, root=`根目录`))*。
+19 -1
View File
@@ -7,7 +7,7 @@ import:
sys: lib/sys.mq.md
---
This file constructs the application Result record only; it does not implement an HTTP transport. For real HTTP requests, response limits and downloads, import lib/net.mq.md. The [network entry](index.mq.md) distinguishes pure URL transformations from native WebSocket exchanges. Keep these responsibilities explicit when extending the package so a readable tool name never implies a missing capability.
This file constructs application Result records and binds explicit server redirects; it does not implement an HTTP client. For real HTTP requests, response limits and downloads, import lib/net.mq.md. The [network entry](index.mq.md) distinguishes pure URL transformations from native WebSocket exchanges. Keep these responsibilities explicit when extending the package so a readable tool name never implies a missing capability.
## _load
@@ -48,3 +48,21 @@ Unified Result map `{ok, value, error}`.
| `ok` | `value` | `error` |
Return *out*.
## redirect
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | any | required | Prepared web application |
| from | text | required | Explicit source route |
| to | text | required | Redirect destination |
| permanent | bool | False | False uses a temporary redirect; True uses the native permanent status |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Updated app with the declared server redirect |
Use `app`, `from`, `to` and `permanent`=False before web.listen. This is a server route policy owned by the network resource, not a client-side history operation. Keep the returned app because binding produces a new value. Redirecting a legacy entry path can coexist with Document and Endpoint discovery without rebuilding the application through removed configure methods. The native runtime validates declared source paths. No listener starts here, and constructing a redirect does not verify that its destination page exists.
We **[Load the existing native HTTP runtime](_load())**.
Return *[Bind this declared HTTP redirect](web_app_redirect(app=`app`, from=`from`, to=`to`, permanent=`permanent`))*.
+1
View File
@@ -10,6 +10,7 @@ This package provides [URL encoding](url.mq.md), the small [HTTP result construc
and a native [WebSocket request/response resource](websocket.mq.md). For HTTP clients with
status, timeout, response limits and downloads, read the standard library net.mq.md directly.
The HTTP leaf here constructs a result record; its name does not imply an implemented HTTP client.
绑定服务端运输使用 websocket.route;中文入口是[实时绑定](实时.mq.md),它与一次客户端 exchange 的生命周期不同。
URL encoding is pure and needs no plugin. This command is ready to run from the repository root:
+22
View File
@@ -26,6 +26,28 @@ We retain **`p` = [Locate the installed native plugin](plugin.native_path(name="
We **[End this run with the selected exit status](sys.exit(code=1))**.
Return *None*.
## route
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | any | required | Prepared application returned by web.prepare |
| path | text | required | Declared WebSocket path, including optional path captures |
| mode | text | "echo" | echo, drain, broadcast or room |
| room_key | text | "" | Room template required by room mode |
| presence | bool | False | Publish native room presence messages |
| require_auth | any | None | None keeps private broadcast/room defaults; False explicitly opens a local demo |
| on_message | text | "" | Optional declared Marqdo callback member |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Updated app with this explicitly declared WebSocket route |
Use `app`, `path`, `mode`="echo", `room_key`="", `presence`=False, `require_auth`=None and `on_message`="" to bind a server transport before web.listen. This function belongs to the network resource; it does not change Document layout or start a socket. Retain the returned app because native resource updates produce a new value. Room mode requires a room_key template; captures such as {id} select the room at request time. Broadcast and room routes require login unless the caller explicitly opts out. Public local demos should say why require_auth=False is intentional. Presence and callbacks retain the native transport's bounded message handling; they are not a client subscription object.
We **[Load the native transport implementation](_load())**.
Return *[Register this declared WebSocket transport](web_app_route_ws(app=`app`, path=`path`, echo=None, mode=`mode`, room_key=`room_key`, on_message=`on_message`, presence=`presence`, require_auth=`require_auth`))*.
# ws
| 参数 | 类型 | 默认 | 说明 |
+30
View File
@@ -0,0 +1,30 @@
---
markup: occlusion
title: 服务端 WebSocket 实时资源
import:
socket: ext/net/websocket.mq.md
---
本文件提供 websocket.mq.md 的路由绑定中文入口。客户端持续连接由浏览器标准库负责,服务器只在准备好的应用上声明运输资源。独立的一次连接/响应测试仍使用英文文件的 ws 与 connect,不把两种生命周期混为一谈。
## 绑定
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 应用 | any | 必填 | 准备站点返回并保留其他资源的应用 |
| 路径 | text | 必填 | 明确声明的套接字路径,可含路径捕获 |
| 模式 | text | "echo" | echo、drain、broadcast 或 room |
| 房间键 | text | "" | room 模式的房间模板,例如文档路径捕获 |
| 在线通知 | bool | False | 是否发布原生在线人数消息 |
| 需要登录 | any | None | None 保留广播/房间私有默认;False 明确公开 |
| 消息回调 | text | "" | 可选已声明 Marqdo 回调成员 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | map | 附加明确 WebSocket 路由的新应用,尚未监听 |
使用`应用`、`路径`、`模式`="echo"、`房间键`=""、`在线通知`=False、`需要登录`=None、`消息回调`=""。授权 plugin,在监听前保留返回的新应用。构造不会连接浏览器、修改 Document 布局或创建后台线程。
room 模式需要房间键,模板在实际请求中代入路径捕获。广播与房间默认要求登录;本地回显示例显式 False,只用于回环地址的公开演示。隐藏导航不能保护连接,身份策略仍由服务器执行。回调与消息上限沿用原生运输,连接错误不能当作空的成功回复。
绑定完成后返回 *[登记同一个应用的实时运输资源](socket.route(app=`应用`, path=`路径`, mode=`模式`, room_key=`房间键`, presence=`在线通知`, require_auth=`需要登录`, on_message=`消息回调`))*。
+53 -3
View File
@@ -26,6 +26,56 @@ We retain **`p` = [Locate the installed native plugin](plugin.native_path(name="
We **[End this run with the selected exit status](sys.exit(code=1))**.
Return *None*.
## attach
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | any | required | Prepared web application |
| users | any | required | Credential table or native database-backed user configuration |
| session_ttl | number | 3600 | Session lifetime in seconds |
| admin_prefix | text | "/admin" | Native administration prefix |
| login_path | text | "/login" | Declared login route |
| login_redirect | text | "" | Optional successful login destination |
| logout_redirect | text | "" | Optional logout destination |
| register | bool | False | Explicitly enable user registration |
| register_path | text | "/register" | Registration route when enabled |
| default_role | text | "user" | Role assigned to a registered user |
| session_url | text | "" | Optional session backend URL |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Updated app with native login/session policy |
Use `app`, `users`, `session_ttl`=3600, `admin_prefix`="/admin", `login_path`="/login", `login_redirect`="", `logout_redirect`="", `register`=False, `register_path`="/register", `default_role`="user" and `session_url`="" before web.listen. This resource owns the login/session policy, while Endpoint auth metadata and explicit gates decide which requests need a session or role. Retain the returned app; construction does not authenticate a request or start a server. Credential tables in local examples are fixtures; real user stores should contain the hashes produced by hash_password. Registration is off until deliberately enabled. Session lifetime is in seconds, and external session backends require their own connection configuration.
We **[Load the native authentication implementation](plugin.load(path=plugin.native_path(name="web")))**.
Return *[Bind the selected login and session policy](web_app_auth(app=`app`, users=`users`, session_ttl=`session_ttl`, admin_prefix=`admin_prefix`, login_redirect=`login_redirect`, logout_redirect=`logout_redirect`, login_path=`login_path`, register=`register`, register_path=`register_path`, default_role=`default_role`, session_url=`session_url`))*.
## gate
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | any | required | Prepared application retaining its actual resources |
| path | text | required | Explicit URL path to protect |
| roles | any | "admin" | Allowed role CSV or list |
| permissions | text | "" | Optional permission CSV; native any-match policy |
| match | text | "prefix" | prefix or exact path matching |
| on_deny | text | "forbid" | forbid or redirect anonymous requests to login |
| exclude | any | None | Explicit path exclusions; native login/logout exclusions remain |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Updated app with a server-enforced gate; no listener starts |
Use `app`, `path`, `roles`="admin", `permissions`="", `match`="prefix", `on_deny`="forbid" and `exclude`=None before listening, with plugin permission. Retain the returned app. This security-owned operation protects real requests; hiding a navigation link does not do that. It reuses the existing native gate and does not mutate Document content or invent routes.
Prefix matching includes the selected path and its slash descendants. The runtime keeps login and logout available to avoid authentication loops. When permissions are supplied, native permission matching applies instead of the role list; any required permission may match. Redirect applies to anonymous denial, while a signed-in subject without access receives forbidden. Test both direct denied requests and authenticated access, and gate the actual form/API endpoint separately if its data is private.
We **[Load the native access-policy implementation](_load())**.
Return *[Bind the explicit server access rule](web_app_gate(app=`app`, path=`path`, roles=`roles`, permissions=`permissions`, match=`match`, on_deny=`on_deny`, exclude=`exclude`))*.
# auth
| 参数 | 类型 | 默认 | 说明 |
@@ -35,14 +85,14 @@ Return *None*.
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Session/auth helper. Constructs a config object; `login` validates against the users table. To gate `/admin` on this app, use `app.auth users=…` instead. |
| result | any | Session/auth helper. Constructs a config object; `login` validates against the users table. To bind native login and protect `/admin`, call attach and gate before listening. |
Use `users`, `session_ttl`=3600 as the inputs for this operation.
Session/auth helper. Constructs a config object; `login` validates against the users table. To gate `/admin` on this app, use `app.auth users=…` instead.
Session/auth helper. Constructs a config object; `login` validates against the users table. To bind native login and protect `/admin`, call attach and gate before listening.
We **[Load the native plugin required by this operation](_load())**.
Return *[Session/auth helper. Constructs a config object; login validates against the users table. To gate /admin on this app, use app.auth users=… instead.](web_auth_new(users=`users`, session_ttl=`session_ttl`))*.
Return *[Session/auth helper. Constructs a config object; login validates against the users table. To bind server login and gates, use this module's attach function before web.listen.](web_auth_new(users=`users`, session_ttl=`session_ttl`))*.
## login
+3
View File
@@ -7,6 +7,9 @@ import:
Use [auth](auth.mq.md) for credential/session operations, [rbac](rbac.mq.md) for role permissions,
and [OIDC](oidc.mq.md) for attaching an external identity provider to an existing web app.
[Tenant selection](tenant.mq.md) supplies explicit request context for scoped data queries;
it does not authenticate a subject or prove tenant membership.
中文服务工作流使用[鉴权绑定](鉴权.mq.md),与 auth.attach 保持相同策略及默认值。
Endpoint authorization remains explicit in the web artifact metadata; a script permission check
does not automatically protect an HTTP route.
+31
View File
@@ -0,0 +1,31 @@
---
markup: occlusion
title: Request tenant selection for database-backed web resources
import:
plugin: lib/plugin.mq.md
---
Tenant selection identifies a request context; authentication and membership are separate decisions. Pair this leaf with explicit scoped routes in ext/data/api.mq.md. Use it before listening and retain the returned application after every binding. The implementation reuses the existing native tenant resolver.
## attach
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | any | required | Prepared application to receive tenant context |
| mode | text | "path" | path, subdomain or header |
| param | text | "t" | Path capture/query key or header name; use X-Tenant-Id explicitly for header mode |
| column | text | "tenant_id" | Database column used by scoped queries |
| default_scope | bool | False | Native default scoping for supported database-backed request handlers |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Updated application with native request tenant resolution |
Use `app`, `mode`="path", `param`="t", `column`="tenant_id" and `default_scope`=False. Path mode first resolves the named route capture, then its query key, then the documented path segments. Subdomain mode uses the first label of a host with at least three labels. Header mode reads the selected header. The native resolver lowercases and keeps ASCII letters, digits, underscores and hyphens; it is not a general tenant-name codec.
Grant plugin and keep the returned application. A later scoped JSON route rejects a missing resolved tenant and adds the tenant-column filter. The default flag applies only to native handlers that support it; ordinary direct database calls do not gain automatic request context. Tenant ids arriving from query parameters, headers or hostnames must be checked against authenticated membership by the application's actual policy.
The local two-tenant example intentionally allows anonymous selection to demonstrate filtering. That behavior cannot establish production access isolation between users. No database row is changed and no socket opens in this binding. Develop resolver behavior in the native tenant package, and verify both selected tenants plus a request without a selector.
We **native = [Resolve the maintained tenant implementation](plugin.native_path(name="web"))** and **[Load the existing request-context boundary](plugin.load(path=`native`))**.
Return *[Attach the explicit request tenant policy](web_app_tenant(app=`app`, mode=`mode`, param=`param`, column=`column`, default_scope=`default_scope`))*.
+57
View File
@@ -0,0 +1,57 @@
---
markup: occlusion
title: 为准备好的应用绑定鉴权
import:
auth: ext/security/auth.mq.md
---
本文件提供 auth.mq.md 的服务端绑定中文入口。凭据验证、会话和路径门禁是不同责任:本入口配置登录会话,业务端点与表单仍需显式访问策略。它不会把隐藏链接当作授权。账户表中的明文密码只适合本地夹具;真实用户应使用英文资源的 hash_password 生成受支持的口令散列,避免记录秘密。
## 绑定
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 应用 | any | 必填 | 已准备并按需启用原生后台的应用 |
| 用户 | any | 必填 | username、password、role 凭据表,或原生用户库配置 |
| 会话时长 | number | 3600 | 会话寿命,单位为秒 |
| 后台前缀 | text | "/admin" | 启用原生后台时安装默认门禁的路径前缀 |
| 登录路径 | text | "/login" | 实际 GET 与 POST 登录地址 |
| 登录返回 | text | "" | 成功登录后的可选目标 |
| 退出返回 | text | "" | 退出后的可选目标 |
| 注册 | bool | False | 明确启用用户注册;默认关闭 |
| 注册路径 | text | "/register" | 启用注册后的系统地址 |
| 默认角色 | text | "user" | 新注册用户的角色 |
| 会话地址 | text | "" | 可选外部会话存储 URI |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | map | 保留原有资源、附加登录和会话策略的新应用 |
使用`应用`、`用户`、`会话时长`=3600、`后台前缀`="/admin"、`登录路径`="/login"、`登录返回`=""、`退出返回`=""、`注册`=False、`注册路径`="/register"、`默认角色`="user"及`会话地址`=""。在监听前授权 plugin 并保留新应用。这里不认证某一次请求,也不启动监听。
原生后台应先启用再绑定鉴权,业务接口的 Endpoint 元数据或显式门禁继续决定所需的身份和角色。注册必须明确启用,外部会话后端另需可用连接。配置成功不能替代拒绝与接受凭据的真实验收;用户数据与口令不要写入检视结果或日志。
绑定完成后返回 *[配置原生登录与会话策略](auth.attach(app=`应用`, users=`用户`, session_ttl=`会话时长`, admin_prefix=`后台前缀`, login_path=`登录路径`, login_redirect=`登录返回`, logout_redirect=`退出返回`, register=`注册`, register_path=`注册路径`, default_role=`默认角色`, session_url=`会话地址`))*。
## 门禁
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 应用 | any | 必填 | 已准备且保留实际资源的应用 |
| 路径 | text | 必填 | 需实际保护的服务器路径 |
| 角色 | any | "admin" | 允许的角色逗号文本或列表 |
| 权限 | text | "" | 可选权限逗号文本,沿用原生任一匹配 |
| 匹配 | text | "prefix" | prefix 前缀或 exact 精确匹配 |
| 拒绝 | text | "forbid" | forbid 禁止或 redirect 让匿名访问转登录 |
| 排除 | any | None | 可选路径排除;原生登录和退出仍保持可用 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | 附加实际服务器访问策略的新应用,尚未监听 |
使用`应用`、`路径`、`角色`="admin"、`权限`=""、`匹配`="prefix"、`拒绝`="forbid"及`排除`=None,在监听前授权 plugin 并保留返回值。本安全资源保护实际请求,不因导航隐藏链接就认定地址安全。前缀覆盖本路径及其斜杠子路径,登录和退出按原生规则排除,避免鉴权循环。
给出权限时采用原生权限匹配,而不是角色清单;任一所需权限命中即可。redirect 只让匿名拒绝转向登录,已登录但不足权限仍收到禁止。表单与 API 还应按实际数据策略保护自己的提交路径;不能只给展示页面加门禁就宣称所有写入已私有化。
绑定完成后返回 *[将明确的访问规则交给安全资源](auth.gate(app=`应用`, path=`路径`, roles=`角色`, permissions=`权限`, match=`匹配`, on_deny=`拒绝`, exclude=`排除`))*。
+30
View File
@@ -5,6 +5,8 @@ description: Browser Runtime helpers (WASM bridge). Prefer lib/browser for effec
import:
cap: ext/web/_capability/index.mq.md
table: lib/table.mq.md
component: ext/web/component/index.mq.md
html: lib/html.mq.md
---
Browser helpers describe the official Marqdo WASM bridge and small effects.
@@ -44,6 +46,7 @@ HTML snippet that loads the official browser Marqdo bridge (route C/D). Defaults
`source`="", `boot`=True . With boot and non-empty source, auto-mounts. No author
JS. Not a substitute for file-partitioned Document layout.
We **bridge = [Escape the bridge URL as an attribute value](html.escape(text=`bridge`))** and **wasm = [Escape the WASM URL as an attribute value](html.escape(text=`wasm`))** and **source = [Escape the client source URL as an attribute value](html.escape(text=`source`))**.
1. `boot`
1. `source` != ""
Return *"<script type=\"module\" src=\"" + bridge + "\" data-mq-wasm=\"" + wasm + "\" data-mq-source-url=\"" + source + "\"></script>"*.
@@ -101,3 +104,30 @@ We retain **`spec` = [Set the html field in the new record](table.put(in=None, a
**_ = 1**
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`spec`))**.
Return *[Set the dom field in the new record](table.put(in=None, at="dom", value=`m`))*.
## nodes
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| bridge | text | "/static/marqdo-bridge.js" | URL of the official browser bridge |
| wasm | text | "/static/marqdo_wasm.wasm" | URL of the built WASM artifact |
| source | text | "" | Optional Marqdo client program URL |
| boot | bool | True | Whether the bridge automatically mounts the client |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Structured script Resource rows for a component Document |
Use `bridge`="/static/marqdo-bridge.js", `wasm`="/static/marqdo_wasm.wasm", `source`="" and `boot`=True in a component tree. The resource references the official bridge as a module and retains the WASM and source addresses as typed attributes. Boot with a nonempty source mounts that Marqdo program; boot=False declares the bridge without automatic mounting. This pure tool creates no server, downloads nothing and writes no JavaScript or HTML. Build the current WASM artifact and mount the actual static directory before serving the page. Prefer these rows to embed when a Document already returns View nodes; embed remains a compatibility string adapter.
`attributes` =
| type | data-mq-wasm |
|---|---|
| module | `wasm` |
1. `boot` and `source` != ""
We **attributes = [Declare the client program to mount](table.put(in=`attributes`, at="data-mq-source-url", value=`source`))**.
1. not `boot`
We **attributes = [Keep automatic mounting disabled](table.put(in=`attributes`, at="data-mq-no-boot", value="1"))**.
Return *[Declare the official bridge as a structured resource](component.asset(url=`bridge`, attrs=`attributes`, slot="marqdo-runtime"))*.
+102 -3
View File
@@ -103,15 +103,16 @@ Return *nodes*.
| kind | text | "column" | Container kind |
| slot | text | "" | Stable region name |
| style | text | "" | Optional class name |
| attrs | any | None | Attribute record for the container, such as id or hidden |
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | One parent containing its child rows |
Use `children`, `kind`="column", `slot`="", `style`="" as the inputs for this operation.
Use `children`, `kind`="column", `slot`="", `style`="", `attrs`=None as the inputs for this operation.
Wrap `children` in one structural row. Default `kind`="column", `slot`=""
and `style`="" . Use row or column for geometry, nav/header/footer/section/aside
and `style`="" . Use row or column for geometry, nav/header/footer/section/aside; form/list/item/select preserve native controls
for a semantic region. The value cell holds the child list itself, not rendered
HTML. The native renderer diagnoses unknown child shapes at the render boundary;
this pure constructor does not claim to validate a full site.
@@ -120,6 +121,104 @@ this pure constructor does not claim to validate a full site.
| @ | type | slot | value | attrs | style |
|---|------|------|-------|-------|-------|
| 1 | `kind` | `slot` | `children` | "" | `style` |
| 1 | `kind` | `slot` | `children` | `attrs` | `style` |
Return *nodes*.
## element
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| kind | text | required | Native leaf kind: input, button, textarea, label, pre, option, text or link |
| value | text | "" | Plain control text or initial input value |
| attrs | any | None | Typed attribute record; legacy text href also works for links |
| slot | text | "" | Stable layout slot |
| style | text | "" | Optional CSS class names |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | One leaf in the existing five-column View schema |
Use `kind`, `value`="", `attrs`=None, `slot`="" and `style`="" when Markdown cannot express a native input or client event target. Supply ids and field names as a record, boolean flags as booleans, and labels as plain text. The renderer escapes values and attribute content; value is never interpreted as HTML. For forms, lists and semantic regions, use wrap with child rows. The constructor is pure; supported kinds, scalar attribute values and forbidden event/style attributes are checked when rendering. Client state belongs in data/aria attributes, while style names reference the page's stylesheet. This keeps controls inspectable without embedding a complete page as HTML.
`nodes` =
| @ | type | slot | value | attrs | style |
|---|---|---|---|---|---|
| 1 | `kind` | `slot` | `value` | `attrs` | `style` |
After describing this control we return *nodes*.
## asset
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| url | text | required | Explicit script or stylesheet URL served by the application |
| kind | text | "script" | script or stylesheet |
| attrs | any | None | Typed attributes such as module type, integrity or data-mq options |
| slot | text | "" | Optional stable resource slot |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | One structured resource leaf in the same five-column View schema |
Use `url`, `kind`="script", `attrs`=None and `slot`="" for an existing resource that the browser must load. A script leaf carries only a URL, never inline author JavaScript; a stylesheet leaf references a separate CSS artifact. Its address stays in value, while attrs holds scalar metadata. The native renderer escapes the URL and attributes, forbids duplicate src/href/rel attributes and rejects script-protocol URLs. Construction is pure and fetches nothing. Keep resource declarations beside the Document component that needs them, after layout and content have been split. The browser loads the actual files when that Document is opened; a node record is not proof that the resource exists.
`nodes` =
| @ | type | slot | value | attrs | style |
|---|---|---|---|---|---|
| 1 | `kind` | `slot` | `url` | `attrs` | "" |
After declaring this resource we return *nodes*.
## resource
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| value | map | required | Typed data_query, form_ref, view_navigation or pure document_head Resource |
| slot | text | "" | Stable component slot for this dynamic region |
| style | text | "" | Optional wrapper class names |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | One resource node in the existing five-column View schema |
Use `value`, `slot`="" and `style`="" to place a resource supplied by its responsible module. Database query resources come from ext/data/view.mq.md; form references from ext/data/form.mq.md; navigation uses the helper below; pure head declarations come from ext/web/head.mq.md. The resource remains a typed value in the value cell, preserving readable composition and its actual input contract.
Construction is pure and does not query data, load a plugin or submit a form. Serving resolves the resource after preparing request parameters, session state and CSRF. Unknown resources fail before listening; missing runtime resources remain request errors. Offline rendering without a request resolver reports missing context for query, form and session navigation. Pure document_head resources are supported by offline preview and collected into the actual head, never shown as body content.
`nodes` =
| @ | type | slot | value | attrs | style |
|---|---|---|---|---|---|
| 1 | resource | `slot` | `value` | None | `style` |
Return *nodes* for the parent layout to place alongside static Markdown and controls.
## navigation
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| items | any | required | Link records with label, href and optional when, class or media |
| region | text | "nav" | nav, sidebar or footer |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Pure navigation Resource, to be placed with component.resource |
Use `items` and `region`="nav" for session-aware link presentation. Link rows describe destinations; when=guest or auth uses the request's actual session. Empty conditions keep links visible. The native navigation renderer retains its existing classes and conditional visibility, while the recursive parent component still owns placement and geometry.
This constructor does not authenticate a user or register a route. Hiding a link cannot protect its destination from direct access. The server must separately attach actual authentication and authorization gates. Reading or constructing navigation never logs in or out; that behavior belongs to the destination's explicit resource and route.
`resource` =
| _type | items | region |
|---|---|---|
| view_navigation | `items` | `region` |
Return *resource* for explicit placement in the same five-column View.
+37
View File
@@ -0,0 +1,37 @@
---
markup: occlusion
title: Document head Resource — SEO, fonts and resource links
---
Use this single-file resource inside the existing five-column View schema. It preserves metadata and native head links when a structured Document owns the page body. Place its returned value through component.resource alongside the layout. The renderer collects it into the actual head, leaving no visible placeholder in body or fragment responses. No new Markdown mark, frontmatter dialect or page mutation chain is involved.
Construction is pure. Rendering validates the closed contract, escapes metadata and uses the same head-link renderer as ordinary Documents. It does not fetch a font, execute a script or prove an external resource exists. Browsers load the declared URLs only when they open the real page. A local pure construction example is ready from the checkout:
```sh
marqdo call ext/web/head.mq.md resource 'meta=[{"key":"description","value":"A readable site"}]' --json
```
## resource
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| meta | any | None | key/value records or a GFM column table; scalar SEO values |
| links | any | None | Native rel/href link records, including optional type, media, crossorigin, defer and async |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Pure document_head descriptor for component.resource; no IO |
Use `meta`=None and `links`=None to declare only what this Document needs. Metadata includes description, og: names and other native SEO names. Native title overrides and canonical/icon link keys retain ordinary Document behavior. Charset, viewport and csrf-token remain owned by the runtime and cannot be redeclared here. An empty descriptor contributes no metadata rather than fabricating a page result.
Links reuse the existing native field aliases, with rel selecting stylesheet, preconnect, preload, icon, script or module behavior. URLs must start with / for site resources or use http(s); protocol-relative URLs, active data schemes and malformed cells fail. Use the official client nodes for the browser bridge rather than inlining business JavaScript. A link does not mount a file or register a server route.
Nested layout modules can contribute head resources. Equal link declarations are deduplicated; conflicting values for the same metadata key are diagnostics rather than silently replacing each other. Fragments omit these declarations because they update an existing Document, while offline preview supports this pure resource without inventing a request session. Request-dependent data, form and navigation resources still require their actual request renderer.
`head` =
| _type | meta | links |
|---|---|---|
| document_head | `meta` | `links` |
After describing the actual metadata and resource addresses, return *head* for explicit placement by the parent component.
+19 -12
View File
@@ -70,9 +70,8 @@ uses the same representation and renderer. Preview from the repo root, then
change into the site directory to start the process:
```text
marqdo run examples/web-layout-handbook/preview.mq.md
cd examples/web-layout-handbook
marqdo run serve.mq.md
marqdo call examples/web-layout-handbook/preview.mq.md main --effects plugin,fs.read,output.write --fs-root examples/web-layout-handbook --json
marqdo call ext/web/web.mq.md serve 'root="examples/web-layout-handbook"' --effects plugin,fs.read,network.write --fs-root examples/web-layout-handbook --json
```
Check /, /about and /api/ping. The first is a genuinely nested layout, the second
@@ -117,7 +116,7 @@ Document, Endpoint and lifecycle boundaries
Ordinary Documents declare type: web, route and title around Markdown body,
retaining the existing Markdown/data-source path. A composed Document also
declares view: main: its # main returns View rows. serve executes that assembly
declares view: main: its ordinary main function returns View rows. serve executes that assembly
once at startup and uses the same renderer as offline preview. Restart after
content changes. Automatic data_source binding uses ordinary Documents and
cannot be mixed with startup assembly. Assembly returns structure; it must not render again or launch
@@ -125,9 +124,17 @@ a server. Request-time interaction belongs in Endpoints with type, path, method,
request and response metadata. Startup assembly is not an automatic request-time
template/data-binding system.
serve is a blocking lifecycle operation for a launcher run with marqdo run.
call is for pure construction, previews and inspection; --effects plugin does
not grant network or filesystem writes, so call serve is not a launch workflow.
serve is a blocking lifecycle operation callable with marqdo call. Grant
plugin,fs.read,network.write for a site that reads Markdown and listens. For
additional resources, compose web.prepare, resource-owned bindings and
web.listen in an ordinary callable launcher. Keep each returned app value.
For current database rows, forms and session-aware navigation, place the typed resources from
ext/data and component.navigation inside the same View tree. Pure document_head resources
preserve SEO and font links in previews as well as responses; they never become body content.
See [the request-resource design](../../doc/design/web-view-resources.md) and the real
[network site](../../examples/web-net-site/index.mq.md).
The network library owns WebSocket routes; the security library owns login
and session policy. Preparing a site opens no listener.
inspect with root scans disk declarations without listening; an empty app in a
fresh process cannot inspect another process's private state.
@@ -142,7 +149,8 @@ Open the module for the next responsibility
[page](page/index.mq.md) supplies handles and offline render;
[route](route/index.mq.md) is for explicit advanced registration, while whole
sites normally use Metadata. [dom](dom/index.mq.md) converts content, retaining
raw HTML only at a compatibility boundary. [client](client/index.mq.md) loads
raw HTML only at a compatibility boundary. [head](head.mq.md) contributes pure SEO/font/resource declarations to the real document head;
[client](client/index.mq.md) loads
the official Marqdo WASM bridge; business effects stay in lib/browser.
[_capability](_capability/index.mq.md) diagnoses loading. The [facade](web.mq.md)
keeps serve/render/inspect and the app API. Data, auth and HTTP clients belong
@@ -159,9 +167,8 @@ Update src/ext_cli.rs if adding package files. Preserve ordinary Documents and
Endpoints when changing startup assembly.
```text
cargo test --locked --test web_handbook
cargo test --locked --test call_cli web_
cargo test --locked --test gold ext_web -- --test-threads=1
marqdo call skills/marqdo-dev/index.mq.md test 'targets=["web_handbook"]' --effects plugin,process.exec --require-ok --json
marqdo call skills/marqdo-dev/index.mq.md test 'targets=["call_cli","gold"]' 'filter="web"' --effects plugin,process.exec --require-ok --json
```
Handbook tests execute the bilingual sh fences and author examples directly,
@@ -194,7 +201,7 @@ The returned rows are a planning aid, not a generated site or a validation certi
| step_C | declare home Document and view main for composed structure |
| step_D | declare more Documents with their own routes |
| step_E | declare Endpoint handlers for request-time work |
| step_F | run serve.mq.md from the site directory |
| step_F | call the blocking serve function with explicit site root and effects |
| step_G | compare preview and live output; test routes and browser geometry |
| stopping_rule | one Markdown responsibility and no internal layout |
+49 -14
View File
@@ -25,8 +25,8 @@ marqdo call ext/web/web.mq.md inspect 'root="examples/web-layout-handbook"' --ef
inspect with root scans declared metadata without starting a server. To inspect
an in-memory app, pass its actual handle; an empty fresh process cannot inspect
another process. serve is a blocking lifecycle operation: write a launcher and
use marqdo run, not call. Explicit view: main Documents assemble once at startup
another process. serve is a blocking lifecycle operation. Call it directly with explicit effects,
or compose prepare, resource bindings and listen in an ordinary callable launcher. Explicit view: main Documents assemble once at startup
through normal functions and imports. Restart after changing their content.
Develop layout structure in layout/component and the Go artifact renderer;
@@ -149,23 +149,21 @@ Return *[Attach first-class middleware to app](web_app_use(app=`app`, middleware
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | any | None | app or None |
| root | text | "" | Site directory to inspect without listening |
| app | any | None | Current prepared application after all explicit Resource bindings |
| root | text | "" | Optional metadata-only scan directory; takes precedence over app |
| 返回 | 类型 | 说明 |
|------|------|------|
| result | any | {declared, system} |
|---|---|---|
| result | map | scope, declared and system; registered reports actual configured handlers, metadata reports file declarations and runtime templates |
Use `app`=None, `root`="" as the inputs for this operation.
Use `app`=None and `root`="" deliberately. After prepare and Resource bindings, pass the retained app before listen to inspect its current routes. The registrar is shared with the actual HTTP server, so later WebSocket, JSON query, form, login, administration and static bindings appear without using a stale startup snapshot. Duplicate or conflicting registrations retain their native diagnostic.
Return declared versus system route tables for introspection. System routes such
as /_part and /_form must appear here. Use this to verify a site after serve or
manual registration. Optional `app`=None selects which application to inspect.
Supplying root scans Artifact metadata only. It does not execute the launcher or Documents, so it cannot observe Resource bindings performed by those functions. scope=metadata makes that limitation explicit; scope=registered reports the handler registrations of the supplied app. Neither scope proves that a server is listening, a database is available or authentication succeeds.
Optional `root`="" scans a site directory when supplied; it does not start a server.
The operation needs plugin. It does not invoke request handlers, create sessions, reset runtime state, open a database or start a listener. Credentials and unrelated app fields are not returned. System routes include the actual configured parameterized form/part paths and session paths; declared routes retain their source identity when available.
We **[Load the native plugin required by this operation](cap.load())**.
Return *[Return declared versus system route tables for introspection](web_inspect(app=`app`, root=`root`))*.
We **[Load the maintained native inspection boundary](cap.load())**.
Return *[Observe the current declarations and registered runtime handlers](web_inspect(app=`app`, root=`root`))*.
## serve
@@ -191,7 +189,7 @@ simple). Optional `db`=None, `static_dir`="", and `middleware`=None bind
resources without stuffing them into this facade as author APIs.
We **[Load the native plugin required by this operation](cap.load())**.
Return *[Scan root="](web_serve_root(root=`root`, host=`host`, port=`port`, db=`db`, static_dir=`static_dir`, middleware=`middleware`))*.
Return *[Discover the site and listen on its configured address](web_serve_root(root=`root`, host=`host`, port=`port`, db=`db`, static_dir=`static_dir`, middleware=`middleware`))*.
## client_embed
@@ -318,6 +316,43 @@ head needs as data rather than injecting opaque HTML head strings.
We **[Load the native plugin required by this operation](cap.load())**.
Return *[Build head resource rows (link, script, icon) from a table. Prefer declaring head needs as data rather than injecting opaque HTML head strings.](web_head(table=`table`))*.
## prepare
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| root | text | "." | Site directory containing declared Documents and Endpoints |
| host | text | "127.0.0.1" | Explicit listen address retained for later listen |
| port | number | 18081 | Port retained for later listen |
| db | any | None | Existing database Resource or None |
| static_dir | text | "" | Optional static directory resolved under the site |
| middleware | any | None | Optional security header table |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Prepared app resource; no socket is opened |
Use `root`=".", `host`="127.0.0.1", `port`=18081, `db`=None, `static_dir`="" and `middleware`=None to discover the same Documents and Endpoints as serve. Startup View assembly runs once here. Bind additional resources to the returned app, retaining each returned app value, before calling listen. The original absolute site root travels with the app so relative endpoint callbacks and static files keep their site context. This is a lifecycle boundary, not an alternative routing language. Reading metadata or evaluating a Document can fail before any listener starts.
We **[Load the existing native web implementation](cap.load())**.
Return *[Discover routes without starting a listener](web_prepare_root(root=`root`, host=`host`, port=`port`, db=`db`, static_dir=`static_dir`, middleware=`middleware`))*.
## listen
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| app | any | required | Prepared app after explicit resource bindings |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Blocking native listener result |
Use `app` after prepare and the resource-owned binding functions. This call opens the configured host and port and blocks for the server lifetime. It works in an ordinary callable launcher reached by marqdo call; grant plugin, filesystem and network effects required by that launcher. Returning a resource description does not start the server. A separate terminal or supervised test process owns shutdown; call does not turn this listener into a background daemon. Relative paths use the site root retained by prepare.
We **[Load the existing native web implementation](cap.load())**.
Return *[Serve the prepared site with its bound resources](web_listen(app=`app`))*.
# app
| 参数 | 类型 | 默认 | 说明 |
+62 -9
View File
@@ -19,7 +19,7 @@ marqdo call ext/web/网页.mq.md 检视 '根="examples/web-layout-handbook"' --e
```
页面结构用五列 View 记录,父值保留子表。纯布局、DOM 构造和客户端描述无需插件。
整站服务通过 launcher 的 marqdo run 启动;检视磁盘站点请给出根目录,不能从新进程
整站服务可通过 marqdo call 直接调用服务函数,也可在普通启动函数中组合准备、资源绑定与监听;检视磁盘站点请给出根目录,不能从新进程
读取另一个进程的私有应用。结构化 Document 使用 视图: main,在启动时执行布局装配。
开发时先复用组件和布局模块,再改对应领域实现;保持中英入口与真实契约一致。
@@ -131,20 +131,20 @@ Artifact,由 `服务` 发现;本工具供预览或程序化构造。节点
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 应用 | any | None | 应用或 None |
| 根 | text | "" | 离线扫描的站点目录 |
| 应用 | any | None | 完成显式资源绑定后保留的当前应用 |
| 根 | text | "" | 可选的元数据扫描目录;给出时优先于应用 |
| 返回 | 类型 | 说明 |
|------|------|------|
| result | any | 路由检视 |
|---|---|---|
| 结果 | map | scope、declared 与 system;区分文件声明和当前应用的实际处理器注册 |
这里使用`应用`=None、`根`=""。
使用`应用`=None、`根`="",应明确选择观察范围。准备应用并绑定资源后,把保留的应用交给检视,再开始监听。清单复用真实服务的路由注册流程,后加的 WebSocket、JSON 查询、表单、登录、后台和静态挂载都会出现,不读取已经过期的启动快照;冲突注册保留原生诊断。
返回 `{declared, system}` 路由表;可选 `应用`=None。
给出根目录时只扫描 Artifact 元数据,不执行启动函数或页面,因此不能观察这些函数运行后才绑定的资源。scope 为 metadata 表示文件声明与运行时模板,为 registered 表示传入应用的实际处理器注册。它们都不能证明已经监听、数据库可用或登录成功。
可选 `根`="",给出时扫描站点目录,不启动服务器。
需要 plugin。此操作不调用请求处理器、不创建或重置会话、不打开数据库、不启动监听,也不返回凭据和无关应用字段。系统清单包含实际配置的表单、片段及会话路径;已有来源信息的声明仍保留文件身份,便于继续阅读实现。
完成后返回*[调用 inspect](web.inspect(app=`应用`, root=`根`))*。
完成后返回 *[观察当前声明及运行时注册](web.inspect(app=`应用`, root=`根`))*。
## 服务
@@ -189,3 +189,56 @@ Artifact,由 `服务` 发现;本工具供预览或程序化构造。节点
`源`=""、`启动`=True。不是用 HTML 字符串拼整页的借口。
完成后返回*[调用 client embed](web.client_embed(bridge=`桥`, wasm=`wasm`, source=`源`, boot=`启动`))*。
## 准备站点
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 根 | text | "." | 含网页与端点声明的站点目录 |
| 主机 | text | "127.0.0.1" | 监听地址;准备阶段不开启端口 |
| 端口 | number | 18081 | 交给稍后监听阶段使用的端口 |
| 数据库 | any | None | 已有数据库资源 |
| 静态目录 | text | "" | 站点内的可选静态资源目录 |
| 中间件 | any | None | 可选安全响应头表 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | 已发现路由并完成启动布局装配的应用资源 |
这里使用`根`="."、`主机`="127.0.0.1"、`端口`=18081、`数据库`=None、`静态目录`=""和`中间件`=None。准备阶段发现 Document 与 Endpoint,执行一次启动布局,但不启动监听。随后把应用交给网络、鉴权等资源的绑定函数,并保留每次返回的新应用,最后调用监听。原始站点的绝对根目录随应用保留,因此端点回调和静态资源的相对路径仍按站点解析。目录读取和布局执行可能在打开端口之前失败,应保留原始诊断。
完成准备后返回*[发现站点并保留其资源上下文](web.prepare(root=`根`, host=`主机`, port=`端口`, db=`数据库`, static_dir=`静态目录`, middleware=`中间件`))*.
## 监听
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 应用 | any | 必填 | 准备站点后已完成资源绑定的应用 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | 阻塞的原生监听结果 |
输入`应用`后才启动已配置的主机和端口。可以在普通可调用启动函数中按顺序准备站点、绑定资源、监听,再通过 marqdo call 执行该函数。监听持续占用当前进程,由调用者或测试监督进程负责停止。显式授予启动流程所需的插件、文件读取与网络写入权限;返回一个应用描述本身不会启动后台服务。
最后返回*[在保留的站点根目录中启动服务](web.listen(app=`应用`))*.
## 编译样式
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 名称 | text | 必填 | 原生类选择器名,可含后代选择器尾部 |
| 属性 | any | 必填 | 属性、值两列的声明式主题表 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | text | 原生样式编译器输出的 CSS 文本 |
使用`名称`与`属性`,授权 plugin。该入口对应英文 make_style,把可读属性表交给已有原生编译器;不接收整页 HTML,也不创造另一套布局语言。名称应由作者控制,对应 View 的样式类与原生内容结构。返回文本不会自动写入或挂载文件,调用者需显式选择生成路径并以原生文件能力保存。
纯属性构造不需要插件,真正编译才在这里加载原生实现。属性值的格式或选择器错误保留真实诊断,不能替换为旧产物继续声称已构建。动态业务数据不应该用来拼接选择器;测试应比较实际编译结果并查看对应区域的渲染效果。
完成编译后返回 *[使用已有主题编译器处理声明](web.make_style(name=`名称`, table=`属性`))*。
+18 -1
View File
@@ -16,7 +16,7 @@ marqdo call ext/web/网页/客户端/索引.mq.md 文本补丁 '选择器="#stat
```
页面结构用五列 View 记录,父值保留子表。纯布局、DOM 构造和客户端描述无需插件。
整站服务通过 launcher 的 marqdo run 启动;检视磁盘站点请给出根目录,不能从新进程
整站服务通过网页.服务或工程入口的 serve 函数用 marqdo call 启动;检视磁盘站点请给出根目录,不能从新进程
读取另一个进程的私有应用。结构化 Document 使用 视图: main,在启动时执行布局装配。
开发时先复用组件和布局模块,再改对应领域实现;保持中英入口与真实契约一致。
@@ -79,3 +79,20 @@ marqdo call ext/web/网页/客户端/索引.mq.md 文本补丁 '选择器="#stat
为选择器 `选择器` 构造 `dom` 效果表。可选 `html`=""、`属性`=None、`移除`=False。
完成后返回*[调用 dom patch](client.dom_patch(sel=`选择器`, html=`html`, attrs=`属性`, remove=`移除`))*。
## 挂载节点
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 桥 | text | "/static/marqdo-bridge.js" | 官方浏览器桥地址 |
| wasm | text | "/static/marqdo_wasm.wasm" | 当前构建的 WASM 产物地址 |
| 源 | text | "" | 可选客户端 Marqdo 程序地址 |
| 启动 | bool | True | 是否自动挂载客户端程序 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | 组件 Document 可直接组合的脚本资源节点 |
这里使用`桥`="/static/marqdo-bridge.js"、`wasm`="/static/marqdo_wasm.wasm"、`源`=""和`启动`=True。节点引用官方模块资源,把 WASM 和程序地址保留为属性数据。启动关闭时只声明桥,不自动执行客户端。构造无需插件,不访问网络,也不生成业务 HTML;浏览器打开页面后才加载实际文件。应先构建当前 WASM 并挂载静态目录,再把这些节点与内容组件组合。旧的字符串挂载工具保留兼容用途。
完成后返回*[将官方运行时作为结构资源声明](client.nodes(bridge=`桥`, wasm=`wasm`, source=`源`, boot=`启动`))*.
@@ -16,7 +16,7 @@ marqdo call ext/web/网页/文档对象模型/索引.mq.md 渲染 'dom=$body' --
```
页面结构用五列 View 记录,父值保留子表。纯布局、DOM 构造和客户端描述无需插件。
整站服务通过 launcher 的 marqdo run 启动;检视磁盘站点请给出根目录,不能从新进程
整站服务通过网页.服务或工程入口的 serve 函数用 marqdo call 启动;检视磁盘站点请给出根目录,不能从新进程
读取另一个进程的私有应用。结构化 Document 使用 视图: main,在启动时执行布局装配。
开发时先复用组件和布局模块,再改对应领域实现;保持中英入口与真实契约一致。
+11 -10
View File
@@ -65,9 +65,8 @@ site/
先从仓库根生成预览,再从站点目录运行服务:
```text
marqdo run examples/web-layout-handbook-zh/preview.mq.md
cd examples/web-layout-handbook-zh
marqdo run serve.mq.md
marqdo call examples/web-layout-handbook-zh/preview.mq.md main --effects plugin,fs.read,output.write --fs-root examples/web-layout-handbook-zh --json
marqdo call ext/web/网页.mq.md 服务 '根="examples/web-layout-handbook-zh"' --effects plugin,fs.read,network.write --fs-root examples/web-layout-handbook-zh --json
```
检查 / 首页、/about 普通文档、/api/ping JSON。首页应真的出现父子嵌套与两个页脚区域,
@@ -106,14 +105,15 @@ markup: occlusion
Document、Endpoint 与运行边界
普通 Document 用 类型: 网页、路由、标题和 Markdown 正文,保留原来的静态/数据源路径。
组件 Document 另外声明 视图: main,其 # main 返回节点列表;服务在启动时执行装配一次,
组件 Document 另外声明 视图: main,其普通 main 函数返回节点列表;服务在启动时执行装配一次,
通过同一渲染器生成 HTML。改内容后重启。自动数据源绑定使用普通 Document,不与此启动装配混用。不要在这个装配函数里再启动服务器或调用渲染;
它返回结构即可。请求期互动放在 Endpoint,声明 类型: 端点、路径、方法、请求、响应,
主程序返回响应值。不要把启动时装配误解为自动的请求期模板绑定。
serve 是长时间运行的生命周期操作,用 launcher 的 marqdo run 启动。
call 适合纯构造、离线预览与检视;--effects plugin 不授予网络或文件写入权限,
不能把 call 服务当成起站方式。网页检视给出根目录时可离线扫描声明;新进程中的空应用
服务是长时间阻塞的生命周期操作,可用 marqdo call 直接调用,并显式授予
plugin、fs.read、network.write。需要更多资源时,在普通启动函数中顺序组合准备站点、
各资源的绑定工具与监听,并保留每次更新后的应用。网络库负责 WebSocket,安全库负责
登录与会话;准备阶段不会打开端口。网页检视给出根目录时可离线扫描声明;新进程中的空应用
不能检视另一个进程的私有路由状态。
```sh
@@ -129,6 +129,7 @@ Markdown 叶子与语义包裹;[页面](页面/索引.mq.md)负责句柄与离
[客户端](客户端/索引.mq.md)挂载 Marqdo WASM,业务交互继续使用 lib/browser;
[能力](能力/索引.mq.md)只诊断原生加载。[门面](../网页.mq.md)保留服务、渲染、检视和应用 API。
数据库、鉴权、HTTP 客户端分别去 ext/data、ext/security、ext/net。
[页头资源](../页头.mq.md)保留真实 SEO、字体与资源声明,能用于离线预览;它不会成为正文或片段占位。数据查询、表单引用和会话导航仍在真实请求中解析,继续沿用五列 View。完整中文实践见 [网络站点入口](../../../examples/web-net-site-zh/index.mq.md)。
开发路线与验收
@@ -138,9 +139,9 @@ Markdown 叶子与语义包裹;[页面](页面/索引.mq.md)负责句柄与离
新增文件时更新 src/ext_cli.rs 安装清单。修改 Document 启动装配要保留普通文档与 API 的行为。
```text
cargo test --locked --test web_handbook
cargo test --locked --test call_cli web_
cargo test --locked --test gold ext_web -- --test-threads=1
marqdo call skills/marqdo-dev/index.mq.md test 'targets=["web_handbook"]' --effects plugin --fs-root . --require-ok --json
marqdo call skills/marqdo-dev/index.mq.md test 'targets=["call_cli"]' 'filter="web_"' --effects plugin --fs-root . --require-ok --json
marqdo call skills/marqdo-dev/index.mq.md test 'targets=["gold"]' 'filter="ext_web"' --effects plugin --fs-root . --require-ok --json
```
手册门禁直接执行本包双语 sh 围栏与作者程序,另外预览并启动参考工程,核对路由、
+90 -2
View File
@@ -16,6 +16,7 @@ import:
marqdo call ext/web/网页/组件/索引.mq.md 正文 '文本="## 可读的叶子"' '槽="介绍"' --json
marqdo call ext/web/网页/组件/索引.mq.md 包裹 '子节点=[{"type":"markdown","value":"左"},{"type":"markdown","value":"右"}]' '种类="row"' --json
marqdo call ext/web/网页/组件/索引.mq.md 合并 '甲=[{"type":"text","value":"前"}]' '乙=[{"type":"text","value":"后"}]' --json
marqdo call ext/web/网页/组件/索引.mq.md 资源 '地址="/static/generated/theme.css"' '种类="stylesheet"' --json
```
复用组件使用 @ 记录表,合并只确定兄弟顺序,不会自动产生双栏。布局请转到
@@ -86,15 +87,102 @@ marqdo call ext/web/网页/组件/索引.mq.md 合并 '甲=[{"type":"text","valu
| 种类 | text | "column" | 容器类型 |
| 槽 | text | "" | 区域名 |
| 样式 | text | "" | 可选类名 |
| 属性 | any | None | 容器属性记录,例如 id 与 hidden |
| 返回 | 类型 | 说明 |
|------|------|------|
| result | list | 包含子节点的父块 |
这里使用`子节点`、`种类`="column"、`槽`=""、`样式`=""。
这里使用`子节点`、`种类`="column"、`槽`=""、`样式`=""、`属性`=None。
将 `子节点` 放进一层父容器,默认 `种类`="column"、`槽`=""、`样式`=""。
几何类型为 row、column;语义类型包括 nav、header、footer、section、aside。
值单元格保留子表,不承载拼好的 HTML;构造器只生成结构,实际形状由渲染器检查。
完成后返回*[调用 wrap](component.wrap(children=`子节点`, kind=`种类`, slot=`槽`, style=`样式`))*。
完成后返回*[调用 wrap](component.wrap(children=`子节点`, kind=`种类`, slot=`槽`, style=`样式`, attrs=`属性`))*。
## 控件
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 种类 | text | 必填 | input、button、textarea、label、pre、option、text 或 link |
| 值 | text | "" | 控件文字或输入框初值 |
| 属性 | any | None | id、name、布尔标志等属性记录 |
| 槽 | text | "" | 布局区域名 |
| 样式 | text | "" | 可选样式类名 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | 现有五列 View 结构中的单个控件叶子 |
这里使用`种类`、`值`=""、`属性`=None、`槽`=""和`样式`=""。当普通 Markdown 无法表示编辑框或客户端事件目标时,才使用原生控件。属性记录中的 required、hidden 等必须是布尔值;控件文字按文本转义,不解释为 HTML。表单、列表和语义区域仍用包裹函数保存子节点关系。构造器本身是纯函数,实际渲染阶段检查类型与属性;事件处理器和内联样式不能混入属性表。客户端状态可用 data 与 aria 属性,外观通过类名引用站点样式表。
完成描述后返回*[构造可检查的原生控件](component.element(kind=`种类`, value=`值`, attrs=`属性`, slot=`槽`, style=`样式`))*.
## 资源
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 地址 | text | 必填 | 应用提供的脚本或样式表 URL |
| 种类 | text | "script" | script 或 stylesheet |
| 属性 | any | None | 模块类型、完整性或 data-mq 等属性记录 |
| 槽 | text | "" | 可选资源区域名 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | 现有五列 View 结构中的单个资源叶子 |
这里使用`地址`、`种类`="script"、`属性`=None、`槽`=""。脚本节点只引用资源地址,不承载内联业务 JavaScript;样式节点引用独立 CSS 文件。地址保留在值列,其余信息保留在属性记录。构造本身不访问网络,也不验证文件存在;原生渲染器负责转义和属性检查,浏览器打开页面后才加载资源。这样运行时桥和主题可以独立组织,不需要把整个页面写成 HTML 字符串。
完成后返回*[声明浏览器需要的独立资源](component.asset(url=`地址`, kind=`种类`, attrs=`属性`, slot=`槽`))*.
## 请求资源
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 值 | map | 必填 | 数据查询、表单引用、导航或纯页头声明的具型资源 |
| 槽 | text | "" | 动态内容区域的稳定名称 |
| 样式 | text | "" | 资源外层的可选类名 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | list | 五列 View 中的一个资源节点 |
使用`值`、`槽`=""与`样式`="",把职责模块提供的资源放进布局。查询来自数据视图模块,表单由表单模块显式挂载,导航由下方工具构造,纯页头来自 ext/web/页头.mq.md。值单元格保留资源本身,父组件不先把子内容渲染成 HTML。
构造是纯计算,不查询数据库、不提交表单,也不加载插件。服务器准备请求参数、会话与 CSRF 后才解析资源。未知种类在监听前失败,缺失运行资源保留实际请求诊断。离线渲染不能伪造请求上下文或返回固定成功;纯页头声明可以离线预览,并收集进真正的 head,不作为正文占位。
`节点` =
| @ | 类型 | 槽 | 值 | 属性 | 样式 |
|---|---|---|---|---|---|
| 1 | resource | `槽` | `值` | None | `样式` |
父布局确定位置后,返回 *节点*,与静态 Markdown 和控件继续组合。
## 导航资源
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 项 | any | 必填 | 含 label、href 及可选 when、class、media 的链接记录 |
| 区域 | text | "nav" | nav、sidebar 或 footer |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | map | 由实际会话决定链接可见性的纯导航资源 |
使用`项`与`区域`="nav"声明链接目的地。when 为 guest 或 auth 时根据当前请求会话筛选;空条件始终显示。父组件仍决定布局,原生导航渲染器保留已有类名和条件显示能力,不在作者源码中拼写整段 HTML。
隐藏链接不能保护目标地址。鉴权与角色门禁仍须由服务端资源显式绑定,构造导航不注册隐式路由,也不执行登录或退出。把返回值放入资源节点后,监听期间才读取真实会话;离线读取不会伪造某个用户的登录状态。
`资源` =
| _type | items | region |
|---|---|---|
| view_navigation | `项` | `区域` |
声明完可见性与目的地后,返回 *资源*,交给相同的五列 View 组合。
+1 -1
View File
@@ -15,7 +15,7 @@ marqdo call ext/web/网页/能力/索引.mq.md 加载 --effects plugin --json
```
页面结构用五列 View 记录,父值保留子表。纯布局、DOM 构造和客户端描述无需插件。
整站服务通过 launcher 的 marqdo run 启动;检视磁盘站点请给出根目录,不能从新进程
整站服务通过网页.服务或工程入口的 serve 函数用 marqdo call 启动;检视磁盘站点请给出根目录,不能从新进程
读取另一个进程的私有应用。结构化 Document 使用 视图: main,在启动时执行布局装配。
开发时先复用组件和布局模块,再改对应领域实现;保持中英入口与真实契约一致。
+1 -1
View File
@@ -16,7 +16,7 @@ marqdo call ext/web/网页/路由/索引.mq.md 注册 '路由=$route' --effects
```
页面结构用五列 View 记录,父值保留子表。纯布局、DOM 构造和客户端描述无需插件。
整站服务通过 launcher 的 marqdo run 启动;检视磁盘站点请给出根目录,不能从新进程
整站服务通过网页.服务或工程入口的 serve 函数用 marqdo call 启动;检视磁盘站点请给出根目录,不能从新进程
读取另一个进程的私有应用。结构化 Document 使用 视图: main,在启动时执行布局装配。
开发时先复用组件和布局模块,再改对应领域实现;保持中英入口与真实契约一致。
+1 -1
View File
@@ -16,7 +16,7 @@ marqdo call ext/web/网页/页面/索引.mq.md 渲染 '页面=$pg' --effects plu
```
页面结构用五列 View 记录,父值保留子表。纯布局、DOM 构造和客户端描述无需插件。
整站服务通过 launcher 的 marqdo run 启动;检视磁盘站点请给出根目录,不能从新进程
整站服务通过网页.服务或工程入口的 serve 函数用 marqdo call 启动;检视磁盘站点请给出根目录,不能从新进程
读取另一个进程的私有应用。结构化 Document 使用 视图: main,在启动时执行布局装配。
开发时先复用组件和布局模块,再改对应领域实现;保持中英入口与真实契约一致。
+31
View File
@@ -0,0 +1,31 @@
---
markup: occlusion
title: 文档页头资源:SEO、字体与资源链接
import:
head: ext/web/head.mq.md
---
本文件对应 head.mq.md。结构化页面将本资源交给组件的请求资源节点,服务器与离线预览都把它收集到真正的 head,不在正文或片段中留下占位。沿用现有五列 View,不增加新标记、嵌套元数据或页面变异链。
```sh
marqdo call ext/web/页头.mq.md 声明 '元数据=[{"key":"description","value":"可读的站点"}]' --json
```
## 声明
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| 元数据 | any | None | key/value 行记录或 GFM 列式表,值为原生标量 |
| 链接 | any | None | rel/href 原生资源记录,支持媒体、跨域及脚本标志 |
| 返回 | 类型 | 说明 |
|---|---|---|
| 结果 | map | 供组件安放的纯 document_head 描述 |
使用`元数据`=None、`链接`=None,构造不需要任何副作用。元数据保留 description、og: 等 SEO 名称,title、canonical、icon 等沿用普通文档约定;charset、viewport 和 csrf-token 归运行时所有,不在这里重声明。
链接复用原生 rel/href 表与中文字段别名,可声明字体预连接、样式、图标或显式脚本资源。地址只允许 / 开头的站内路径与 http(s),不接受活动数据方案或协议相对地址。这里不下载字体、不执行脚本、不挂载静态文件;浏览器打开实际页面后才请求地址。官方桥仍用客户端挂载节点,不在资源里写业务 JavaScript。
多个子组件可以贡献资源,相同链接去重,同名元数据有不同值时保留诊断,不静默覆盖。片段不会重复输出页头;离线预览能处理本纯资源,但查询、表单与会话导航仍需真实请求上下文。缺失文件、网络可用性和页面视觉效果须另做实际验证,构造描述不能证明这些条件。
声明完成后返回 *[复用同一个文档页头契约](head.resource(meta=`元数据`, links=`链接`))*。