Start web skill=tools migration with in-package layout law.
Add root/index and layout skills that force file-partitioned pages and ban HTML/CSS injection as the default path; wire ext add, docs, and call coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
24dcb97354
commit
bb06dad134
17 files changed
+1065
-41
No files matched your search
+239
-10
@@ -4,6 +4,7 @@ title: ext/web/web
|
||||
description: >-
|
||||
Web Artifact facade (ADR 0007) — page · route · serve · render · inspect · use.
|
||||
Document/Endpoint first-class. No compose_* / configure / author ensure_plugin.
|
||||
Agents: read ext/web/index.mq.md first (layout file-partition law).
|
||||
import:
|
||||
cap: ext/web/_capability.mq.md
|
||||
page_mod: ext/web/page.mq.md
|
||||
@@ -13,7 +14,24 @@ import:
|
||||
table: lib/table.mq.md
|
||||
---
|
||||
|
||||
Importing this module is the web **capability** (native plugin loads on first facade call).
|
||||
Importing this module is the web capability (native plugin loads on first facade
|
||||
call). Cold-start agents should open ext/web/index.mq.md before calling tools
|
||||
here. Pages are file-partitioned View/Markdown assemblies — not HTML injection.
|
||||
Layout skill: ext/web/layout/index.mq.md.
|
||||
|
||||
## For AI agents
|
||||
|
||||
Every ## below is a tool. Prefer --effects plugin. For how to split nav /
|
||||
sidebar / footer into files, call layout rules first:
|
||||
|
||||
Call example (plain text):
|
||||
marqdo call ext/web/layout/index.mq.md rules --json
|
||||
marqdo call ext/web/web.mq.md inspect --effects plugin --json
|
||||
|
||||
Do not use dom_patch / raw HTML to build a whole Document homepage. Prefer
|
||||
type: web Artifact files under a site root and web.serve.
|
||||
|
||||
*None*
|
||||
|
||||
## page
|
||||
+ `title`=""
|
||||
@@ -25,7 +43,26 @@ Importing this module is the web **capability** (native plugin loads on first fa
|
||||
+ `data_order`=""
|
||||
+ `data_where`=""
|
||||
|
||||
Construct a Document handle. Prefer `type: web` Artifact files discovered by `serve`.
|
||||
Construct a Document handle with title, route, method, Markdown body, optional
|
||||
View nodes, and flat data_source / data_order / data_where keys. Prefer
|
||||
discovering type: web Artifact files via serve rather than hand-building every
|
||||
page in memory. nodes must be the unified View schema, never a private dialect
|
||||
or an HTML string shell.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| title | text | document title |
|
||||
| route | text | path |
|
||||
| method | text | HTTP method |
|
||||
| body | text | Markdown body |
|
||||
| nodes | any | View table or None |
|
||||
| data_source | text | table name |
|
||||
| data_order | text | order key |
|
||||
| data_where | text | filters |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | page handle |
|
||||
|
||||
*> page_mod.page title=`title` route=`route` method=`method` body=`body` nodes=`nodes` data_source=`data_source` data_order=`data_order` data_where=`data_where`*
|
||||
|
||||
@@ -40,8 +77,27 @@ Construct a Document handle. Prefer `type: web` Artifact files discovered by `se
|
||||
+ `auth`=""
|
||||
+ `class`=""
|
||||
|
||||
Register a declared Document page or Endpoint (`fn` = `lib.member`).
|
||||
Optional `class`: `execute` | `short` | `read` | `control`.
|
||||
Register a declared Document page or Endpoint on app. path and method identify
|
||||
the HTTP surface. page holds a Document; fn names an Endpoint lib.member.
|
||||
request / response / auth / class document the contract. Optional class values
|
||||
include execute, short, read, control. User routes must be declared — never
|
||||
implicit. After building the route object this tool registers it on the app.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| app | any | app handle |
|
||||
| path | text | URL path |
|
||||
| method | text | HTTP method |
|
||||
| page | any | Document or None |
|
||||
| fn | text | endpoint member |
|
||||
| request | text | request kind |
|
||||
| response | text | response kind |
|
||||
| auth | text | auth tag |
|
||||
| class | text | route class |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | registration result |
|
||||
|
||||
**r = > route_mod.route app=`app` path=`path` method=`method` page=`page` fn=`fn` request=`request` response=`response` auth=`auth` class=`class`**
|
||||
*> `r`.register app=`app`*
|
||||
@@ -53,7 +109,23 @@ Optional `class`: `execute` | `short` | `read` | `control`.
|
||||
+ `title`=""
|
||||
+ `db`=None
|
||||
|
||||
Render a Document or View nodes to HTML (offline / preview).
|
||||
Render a Document or View nodes to HTML for offline preview. Prefer nodes from
|
||||
file-partitioned components. When doc is set, delegates to page.render. When
|
||||
only nodes are set, renders that View table. Otherwise renders Markdown body.
|
||||
Requires the native plugin. Do not treat this as permission to paste a full HTML
|
||||
homepage — keep using View tables and Markdown.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| doc | any | Document or None |
|
||||
| nodes | any | View table or None |
|
||||
| body | text | Markdown |
|
||||
| title | text | title |
|
||||
| db | any | optional db |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | HTML or payload |
|
||||
|
||||
> cap.load
|
||||
1. `doc`
|
||||
@@ -67,7 +139,18 @@ Render a Document or View nodes to HTML (offline / preview).
|
||||
+ `app`
|
||||
+ `middleware`
|
||||
|
||||
First-class middleware — pass a GFM table (security headers, cors row, etc.). Replaces `configure(...)` junk drawer.
|
||||
Attach first-class middleware to app. Pass a GFM table (security headers, cors
|
||||
row, and similar). This replaces the old configure(...) junk drawer with an
|
||||
explicit table authors can read.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| app | any | app handle |
|
||||
| middleware | any | middleware table |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | app handle |
|
||||
|
||||
> cap.load
|
||||
*> web_app_use app=`app` middleware=`middleware`*
|
||||
@@ -75,7 +158,17 @@ First-class middleware — pass a GFM table (security headers, cors row, etc.).
|
||||
## inspect
|
||||
+ `app`=None
|
||||
|
||||
Return `{declared, system}` route tables for introspection (code-as-documentation).
|
||||
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 selects which application to inspect.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| app | any | app or None |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | {declared, system} |
|
||||
|
||||
> cap.load
|
||||
*> web_inspect app=`app`*
|
||||
@@ -88,7 +181,23 @@ Return `{declared, system}` route tables for introspection (code-as-documentatio
|
||||
+ `static_dir`=""
|
||||
+ `middleware`=None
|
||||
|
||||
Scan `root/**/*.mq.md` for `type: web|endpoint` (ZH `类型: 网页|端点`), register declared routes, attach system routes, listen.
|
||||
Scan root for type web or endpoint Artifacts, register declared routes, attach
|
||||
system routes, and listen on host:port. The site directory should already follow
|
||||
the layout law (components split until simple). Optional db and middleware bind
|
||||
resources without stuffing them into this facade as author APIs.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| root | text | site root |
|
||||
| host | text | bind host |
|
||||
| port | number | port |
|
||||
| db | any | optional db |
|
||||
| static_dir | text | static files |
|
||||
| middleware | any | optional middleware |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | serve result |
|
||||
|
||||
> cap.load
|
||||
*> web_serve_root root=`root` host=`host` port=`port` db=`db` static_dir=`static_dir` middleware=`middleware`*
|
||||
@@ -99,12 +208,40 @@ Scan `root/**/*.mq.md` for `type: web|endpoint` (ZH `类型: 网页|端点`), re
|
||||
+ `source`=""
|
||||
+ `boot`=True
|
||||
|
||||
Describe WASM bridge embed tags for a page that needs client Marqdo. This is not
|
||||
a substitute for Document layout: still partition nav and main in files, then
|
||||
embed the bridge where interaction needs it.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| bridge | text | bridge script URL |
|
||||
| wasm | text | wasm URL |
|
||||
| source | text | optional source |
|
||||
| boot | bool | auto boot |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | embed descriptor |
|
||||
|
||||
*> client_mod.embed bridge=`bridge` wasm=`wasm` source=`source` boot=`boot`*
|
||||
|
||||
## text_patch
|
||||
+ `sel`
|
||||
+ `text`
|
||||
|
||||
Client patch: set text content for CSS selector sel. Use for small interactive
|
||||
updates after a Document is already laid out with View tables — not for building
|
||||
the initial homepage shell.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| sel | text | CSS selector |
|
||||
| text | text | new text |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | patch descriptor |
|
||||
|
||||
*> client_mod.text_patch sel=`sel` text=`text`*
|
||||
|
||||
## dom_patch
|
||||
@@ -113,6 +250,21 @@ Scan `root/**/*.mq.md` for `type: web|endpoint` (ZH `类型: 网页|端点`), re
|
||||
+ `attrs`=None
|
||||
+ `remove`=False
|
||||
|
||||
Client patch for selector sel with optional html, attrs, or remove. Treat html
|
||||
here as a surgical update, never as the primary way to author nav, sidebar, or
|
||||
footer. Layout law still applies to the Document that hosts the selector.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| sel | text | CSS selector |
|
||||
| html | text | optional HTML fragment |
|
||||
| attrs | any | optional attrs |
|
||||
| remove | bool | remove node |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | patch descriptor |
|
||||
|
||||
*> client_mod.dom_patch sel=`sel` html=`html` attrs=`attrs` remove=`remove`*
|
||||
|
||||
## make_style
|
||||
@@ -120,7 +272,19 @@ Scan `root/**/*.mq.md` for `type: web|endpoint` (ZH `类型: 网页|端点`), re
|
||||
+ `table`
|
||||
+ `strict`=False
|
||||
|
||||
Style table → CSS (data, not hidden page DSL).
|
||||
Compile a named style table into CSS. Styles remain data next to content; this
|
||||
is not a hidden page DSL. Prefer referencing style names from View style columns
|
||||
after file-partitioned components define their look.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| name | text | style name |
|
||||
| table | any | property table |
|
||||
| strict | bool | strict mode |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | CSS / style handle |
|
||||
|
||||
> cap.load
|
||||
*> web_style name=`name` table=`table` strict=`strict`*
|
||||
@@ -128,12 +292,34 @@ Style table → CSS (data, not hidden page DSL).
|
||||
## make_images
|
||||
+ `table`
|
||||
|
||||
Build image descriptors from a readable table of sources and alts. Keep media
|
||||
declarations in Markdown tables beside the Document that uses them.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| table | any | images table |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | images payload |
|
||||
|
||||
> cap.load
|
||||
*> web_images table=`table`*
|
||||
|
||||
## make_head
|
||||
+ `table`
|
||||
|
||||
Build head resource rows (link, script, icon) from a table. Prefer declaring
|
||||
head needs as data rather than injecting opaque HTML head strings.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| table | any | head table |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | head payload |
|
||||
|
||||
> cap.load
|
||||
*> web_head table=`table`*
|
||||
|
||||
@@ -148,7 +334,13 @@ Style table → CSS (data, not hidden page DSL).
|
||||
+ `layout`=None
|
||||
+ `asset_version`=None
|
||||
|
||||
Low-level app handle for advanced mounts. Prefer `web.serve` for Artifact sites.
|
||||
Low-level app handle for advanced mounts. Prefer web.serve for Artifact sites
|
||||
that already follow file-partition layout. Optional page, db, host, port, admin
|
||||
flags, shell_css, layout, and asset_version configure the runtime without a
|
||||
configure junk drawer of unrelated kwargs. Authors who need only Document
|
||||
discovery should stay on serve; agents should not invent HTML shells on this
|
||||
object. Methods static, listen, and gate hang off the returned handle for
|
||||
mounts that remain table- and Metadata-driven.
|
||||
|
||||
> cap.load
|
||||
*> web_app_new page=`page` db=`db` admin=`admin` host=`host` port=`port` admin_prefix=`admin_prefix` login_redirect=None logout_redirect=None shell_css=`shell_css` layout=`layout` asset_version=`asset_version`*
|
||||
@@ -157,10 +349,30 @@ Low-level app handle for advanced mounts. Prefer `web.serve` for Artifact sites.
|
||||
+ `dir`
|
||||
+ `mount`=/static
|
||||
|
||||
Mount static files from dir at mount path on this app. Use for bridge scripts and
|
||||
assets referenced by Documents — not for dumping an HTML-only site tree that
|
||||
bypasses Artifact Documents.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| dir | text | filesystem directory |
|
||||
| mount | text | URL mount |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | app handle |
|
||||
|
||||
*> web_app_static app=`self` dir=`dir` mount=`mount`*
|
||||
|
||||
## listen
|
||||
|
||||
Start listening with the already configured app host and port. Prefer serve for
|
||||
root scanning; listen is for advanced app handles after manual route setup.
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | listen result |
|
||||
|
||||
*> web_listen app=`self`*
|
||||
|
||||
## gate
|
||||
@@ -171,4 +383,21 @@ Low-level app handle for advanced mounts. Prefer `web.serve` for Artifact sites.
|
||||
+ `on_deny`=forbid
|
||||
+ `exclude`=None
|
||||
|
||||
Attach an authorization gate on path for this app. roles, permissions, match,
|
||||
on_deny, and exclude document who may enter. Auth resources live in ext/security;
|
||||
this method only wires the gate onto the web app surface.
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| path | text | gated path |
|
||||
| roles | any | roles |
|
||||
| permissions | text | permissions |
|
||||
| match | text | match mode |
|
||||
| on_deny | text | deny behavior |
|
||||
| exclude | any | exclusions |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| result | any | app handle |
|
||||
|
||||
*> web_app_gate app=`self` path=`path` roles=`roles` permissions=`permissions` match=`match` on_deny=`on_deny` exclude=`exclude`*
|
||||
Reference in new issue
Block a user