Add module namespaces and harden L1/agent after the import redesign.

Bind imports to library names with bare path calls (and use), forward optional host args through mq wrappers, stabilize writeback replacement newlines, and document the M1/M2 decisions.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-07 13:28:32 +08:00
1 parent 99132ac8fc
commit 1f23e2ed93
108 files changed
+3228 -1023

No files matched your search

+4 -2
View File
@@ -11,14 +11,16 @@ description: Run bound code fences and inline sources via local interpreters
## run
+ `code`
+ `stdin`=None
**> host_foreign_run code=`code`**
**> host_foreign_run code=`code` stdin=`stdin`**
## run_lang
+ `lang`
+ `source`
+ `stdin`=None
**> host_foreign_run_lang lang=`lang` source=`source`**
**> host_foreign_run_lang lang=`lang` source=`source` stdin=`stdin`**
## langs
+2 -1
View File
@@ -10,8 +10,9 @@ description: JSON parse/stringify (shared EN/ZH import)
## stringify
+ `value`
+ `indent`=None
**> host_json_stringify value=`value`**
**> host_json_stringify value=`value` indent=`indent`**
## get
+ `value`
+17 -4
View File
@@ -176,25 +176,38 @@ description: High-school math — num, random, formula, plot
## solve
+ `formula`
+ `var`
+ `min`=None
+ `max`=None
**> host_solve formula=`formula` var=`var`**
**> host_solve formula=`formula` var=`var` min=`min` max=`max`**
## plot
+ `formula`
+ `var`
+ `min`
+ `max`
+ `steps`=None
+ `path`=None
+ `derivative`=None
+ `grid`=None
**> host_plot formula=`formula` var=`var` min=`min` max=`max`**
**> host_plot formula=`formula` var=`var` min=`min` max=`max` steps=`steps` path=`path` derivative=`derivative` grid=`grid`**
## plot_points
+ `xs`
+ `ys`
+ `path`=None
+ `grid`=None
**> host_plot_points xs=`xs` ys=`ys`**
**> host_plot_points xs=`xs` ys=`ys` path=`path` grid=`grid`**
## plot_conic
+ `kind`
+ `a`
+ `b`=None
+ `h`=None
+ `k`=None
+ `path`=None
+ `grid`=None
**> host_plot_conic kind=`kind` a=`a`**
**> host_plot_conic kind=`kind` a=`a` b=`b` h=`h` k=`k` path=`path` grid=`grid`**
+9 -3
View File
@@ -5,26 +5,32 @@ description: English HTTP(S) wrappers. Optional headers / content_type via host
## http_get
+ `url`
+ `headers`=None
HTTPS supported. Optional named arg `headers=` (map).
**> host_http_get url=`url`**
**> host_http_get url=`url` headers=`headers`**
## http_post
+ `url`
+ `body`
+ `content_type`=None
+ `headers`=None
Default content type is JSON. Optional `content_type=` / `headers=` (map).
**> host_http_post url=`url` body=`body`**
**> host_http_post url=`url` body=`body` content_type=`content_type` headers=`headers`**
## http_request
+ `method`
+ `url`
+ `body`=None
+ `content_type`=None
+ `headers`=None
Optional `body=` / `content_type=` / `headers=`.
**> host_http_request method=`method` url=`url`**
**> host_http_request method=`method` url=`url` body=`body` content_type=`content_type` headers=`headers`**
## url_encode
+ `text`
+7
View File
@@ -15,3 +15,10 @@ description: Load optional native ABI plugins (.dll / .so / .dylib)
## list
**> host_plugin_list**
## native_path
+ `name`
Resolve installed / local native plugin path (e.g. `agent`).
**> host_ext_native_path name=`name`**
+4 -2
View File
@@ -15,10 +15,11 @@ description: English system wrappers (load_dotenv accepts optional path via host
**> host_env_set name=`name` value=`value`**
## load_dotenv
+ `path`=None
Load `.env` (optional named arg `path=`). Existing process env is not overridden.
**> host_dotenv_load**
**> host_dotenv_load path=`path`**
## args
@@ -35,5 +36,6 @@ Load `.env` (optional named arg `path=`). Existing process env is not overridden
## exec
+ `cmd`
+ `args`=None
**> host_exec cmd=`cmd`**
**> host_exec cmd=`cmd` args=`args`**
+22 -7
View File
@@ -6,27 +6,42 @@ description: Persist run output in .mq.md (Jupyter-style writeback)
## record
+ `value`
+ `at_end`=False
+ `key`=None
+ `line`=None
Write `value` to `<!-- marqdo-out … -->` in the entry file. Default: insert or replace the block immediately below the call; `at_end=true` appends a single block at EOF.
Write `value` to `<!-- marqdo-out … -->` in the entry file. Default: insert or replace the block immediately below the call; `at_end=true` replaces the unkeyed EOF block. With `key=` (e.g. `ok` / `error`), replace or create that **named** slot only — slots do not overwrite each other. Optional `line=` anchors the block under that source line (needed when writing from a subtask).
**> host_writeback_record value=`value` at_end=`at_end`**
**> host_writeback_record value=`value` at_end=`at_end` key=`key` line=`line`**
## get
+ `at_end`=False
+ `key`=None
+ `line`=None
Read persisted output for the current call site (adjacent block), or the EOF block when `at_end=true`.
Read persisted output for the current call site (adjacent unkeyed block), the unkeyed EOF block when `at_end=true`, or a named slot when `key=` is set.
**> host_writeback_get at_end=`at_end`**
**> host_writeback_get at_end=`at_end` key=`key` line=`line`**
## clear
+ `at_end`=False
+ `key`=None
+ `line`=None
Remove the adjacent or EOF output block.
Remove the adjacent, EOF, or named output block.
**> host_writeback_clear at_end=`at_end`**
**> host_writeback_clear at_end=`at_end` key=`key` line=`line`**
## ensure
+ `key`
+ `placeholder`=pending
+ `line`=None
Create a named slot with `placeholder` if missing. Never overwrites an existing slot body.
**> host_writeback_ensure key=`key` placeholder=`placeholder` line=`line`**
## list
List all output blocks in the entry file.
List all output blocks in the entry file (includes `key` when named).
**> host_writeback_list**
+4 -2
View File
@@ -11,14 +11,16 @@ description: 通过本机解释器运行绑定的代码围栏与内联源码
## 运行
+ `代码`
+ `标准输入`=None
**> host_foreign_run code=`代码`**
**> host_foreign_run code=`代码` stdin=`标准输入`**
## 按语言运行
+ `语言`
+ `源码`
+ `标准输入`=None
**> host_foreign_run_lang lang=`语言` source=`源码`**
**> host_foreign_run_lang lang=`语言` source=`源码` stdin=`标准输入`**
## 语言表
+7
View File
@@ -15,3 +15,10 @@ description: 加载可选原生 ABI 插件(.dll / .so / .dylib)
## 列出
**> host_plugin_list**
## 原生路径
+ `名`
解析已安装或本地原生插件路径(如 `agent`)。
**> host_ext_native_path name=`名`**
+17 -4
View File
@@ -176,25 +176,38 @@ description: 高中数学 — 数值、随机、公式、作图
## 求解
+ `formula`
+ `var`
+ `min`=None
+ `max`=None
**> host_solve formula=`formula` var=`var`**
**> host_solve formula=`formula` var=`var` min=`min` max=`max`**
## 绘图
+ `formula`
+ `var`
+ `min`
+ `max`
+ `steps`=None
+ `path`=None
+ `derivative`=None
+ `grid`=None
**> host_plot formula=`formula` var=`var` min=`min` max=`max`**
**> host_plot formula=`formula` var=`var` min=`min` max=`max` steps=`steps` path=`path` derivative=`derivative` grid=`grid`**
## 绘点列
+ `xs`
+ `ys`
+ `path`=None
+ `grid`=None
**> host_plot_points xs=`xs` ys=`ys`**
**> host_plot_points xs=`xs` ys=`ys` path=`path` grid=`grid`**
## 绘圆锥
+ `kind`
+ `a`
+ `b`=None
+ `h`=None
+ `k`=None
+ `path`=None
+ `grid`=None
**> host_plot_conic kind=`kind` a=`a`**
**> host_plot_conic kind=`kind` a=`a` b=`b` h=`h` k=`k` path=`path` grid=`grid`**
+4 -2
View File
@@ -15,10 +15,11 @@ description: 中文系统包装(加载环境 可选 路径=)
**> host_env_set name=`名` value=`值`**
## 加载环境
+ `路径`=None
加载 `.env`(可选具名实参 `路径=`)。不覆盖已有进程环境变量。
**> host_dotenv_load**
**> host_dotenv_load path=`路径`**
## 参数表
@@ -35,5 +36,6 @@ description: 中文系统包装(加载环境 可选 路径=)
## 执行
+ `命令`
+ `参数`=None
**> host_exec cmd=`命令`**
**> host_exec cmd=`命令` args=`参数`**
+9 -3
View File
@@ -5,26 +5,32 @@ description: 中文 HTTP(S) 包装。可选 headers / content_type 经宿主别
## 获取
+ `地址`
+ `headers`=None
支持 HTTPS。可选具名实参 `headers=`(映射)。
**> host_http_get url=`地址`**
**> host_http_get url=`地址` headers=`headers`**
## 提交
+ `地址`
+ `内容`
+ `content_type`=None
+ `headers`=None
默认 Content-Type 为 JSON。可选 `content_type=` / `headers=`。
**> host_http_post url=`地址` body=`内容`**
**> host_http_post url=`地址` body=`内容` content_type=`content_type` headers=`headers`**
## 请求
+ `方法`
+ `地址`
+ `body`=None
+ `content_type`=None
+ `headers`=None
可选 `body=` / `content_type=` / `headers=`。
**> host_http_request method=`方法` url=`地址`**
**> host_http_request method=`方法` url=`地址` body=`body` content_type=`content_type` headers=`headers`**
## 编码地址
+ `内容`
+21 -6
View File
@@ -6,24 +6,39 @@ description: 将运行结果写回 .mq.md(Jupyter 式自写回)
## 写回
+ `值`
+ `末尾`=False
+ `键`=None
+ `行`=None
在入口文件中写入 `<!-- marqdo-out … -->`。默认在调用行下方插入或替换;`末尾=true` 时在文件末尾保留单块。
在入口文件中写入 `<!-- marqdo-out … -->`。默认在调用行下方插入或替换;`末尾=true` 时替换无键末尾块。带 `键=`(如 `ok` / `error` / `成功` / `失败`)时只更新该命名槽,互不覆盖。可选 `行=` 锚定到指定源码行(子任务写回时需要)。
**> host_writeback_record value=`值` at_end=`末尾`**
**> host_writeback_record value=`值` at_end=`末尾` key=`键` line=`行`**
## 取
+ `末尾`=False
+ `键`=None
+ `行`=None
读取当前调用处紧邻块,或 `末尾=true` 时读取文件末尾块。
读取当前调用处紧邻无键块、无键末尾块,或命名槽。
**> host_writeback_get at_end=`末尾`**
**> host_writeback_get at_end=`末尾` key=`键` line=`行`**
## 清除
+ `末尾`=False
+ `键`=None
+ `行`=None
删除紧邻块或末尾块。
删除紧邻块、末尾块或命名槽。
**> host_writeback_clear at_end=`末尾`**
**> host_writeback_clear at_end=`末尾` key=`键` line=`行`**
## 确保
+ `键`
+ `占位`=pending
+ `行`=None
若命名槽不存在则创建并写入占位;已存在则不改动。
**> host_writeback_ensure key=`键` placeholder=`占位` line=`行`**
## 列出