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

+56
View File
@@ -0,0 +1,56 @@
---
title: ext/agent step (DeepSeek)
description: Real agent.step with tool via lib/subtask. Credentials from tests/ext/.env.
> lib/time.mq.md
> lib/writeback.mq.md
> lib/json.mq.md
> ext/ai/llm.mq.md
> ext/ai/agent.mq.md
---
## 获取时间
*`u` = > time.now_unix *
*`s` = > time.format unix=`u` pattern=%Y-%m-%d *
**`s`**
# main
> llm.load_env path=.env
*`模型` = > llm.llm *
`工具表` =
| 工具 |
|------|
| 获取时间 |
*`助手` = > agent.agent model=`模型` tools=`工具表` standing=You are a Marqdo agent. When you need the current date, reply with exactly one line CALL:获取时间 and nothing else. *
*`out` = > `助手`.step task=请调用获取时间工具,然后用一句话告诉用户今天的日期。 *
*`status` = > json.get value=`out` key=status *
*`回复` = > json.get value=`out` key=result *
*`body` = > json.stringify value=`out` *
> print text=`回复`
1. `status` == ok
> writeback.record value=`body` key=ok
<!-- marqdo-out ok
{"decision":"CALL:获取时间","result":"今天是2026年8月7日。","status":"ok","task":"请调用获取时间工具,然后用一句话告诉用户今天的日期。","tool":"获取时间","tool_result":"\"2026-08-07\""}
-->
2. *
> writeback.record value=`body` key=error
*`id` = > json.get value=`助手` key=id *
*`历史` = > agent_history_get id=`id` *
*`条数` = > len value=`历史` *
> print text=`条数`
> `助手`.clear_history
*`历史2` = > agent_history_get id=`id` *
*`条数2` = > len value=`历史2` *
> print text=`条数2`
+43 -16
View File
@@ -1,22 +1,31 @@
---
title: ext/agent framework smoke (offline)
description: Ctor, context, clear_history — no network. Gold suite.
title: ext/agent framework smoke
description: Real llm handle from tests/ext/.env; context, extract_tool_name, run_tool via subtask.
> ext/ai/llm.mq.md
> lib/json.mq.md
> ext/ai/agent.mq.md
---
## 获取时间
*`esc` = > json.parse text={"v":"ok-time"} *
**> json.get value=`esc` key=v**
# main
> llm.load_env path=.env
`工具表` =
| 工具 |
|------|
| 获取时间 |
*`占位模型` = > parse text={"_type":"llm"} *
*`助手` = > agent model=`占位模型` tools=`工具表` user_prompt=you are a dispatcher *
*`模型` = > llm.llm *
*`助手` = > agent.agent model=`模型` tools=`工具表` standing=you are a readable Marqdo agent *
*`id` = > get value=`助手` key=id *
*`id` = > json.get value=`助手` key=id *
*`ctx` = > build_agent_context agent=`助手` extra=probe *
*`ctx` = > agent.build_step_context agent=`助手` task=probe *
*`has_skill` = > split value=`ctx` sep=Marqdo *
*`sk_n` = > len value=`has_skill` *
@@ -32,29 +41,47 @@ description: Ctor, context, clear_history — no network. Gold suite.
2. *
> print text=tools-missing
*`src` = > host_module_source *
*`has_src` = > split value=`src` sep=probe *
*`has_src` = > split value=`ctx` sep=probe *
*`src_n` = > len value=`has_src` *
1. `src_n` > 1
> print text=source-ok
2. *
> print text=source-missing
*`turn` = > parse text={"role":"user","content":"one"} *
> host_agent_history_append id=`id` item=`turn`
*`turn2` = > parse text={"role":"assistant","content":"two"} *
> host_agent_history_append id=`id` item=`turn2`
*`has_act` = > split value=`ctx` sep=CALL: *
*`act_n` = > len value=`has_act` *
1. `act_n` > 1
> print text=protocol-ok
2. *
> print text=protocol-missing
*`h1` = > host_agent_history_get id=`id` *
*`samples` = > json.parse text={"r":"CALL:获取时间","m":"think\nCALL:获取时间"} *
*`raw1` = > json.get value=`samples` key=r *
*`name1` = > agent.extract_tool_name reply=`raw1` *
> print text=`name1`
*`raw2` = > json.get value=`samples` key=m *
*`name2` = > agent.extract_tool_name reply=`raw2` *
> print text=`name2`
*`tool_out` = > agent.run_tool tools=`工具表` name=获取时间 *
> print text=`tool_out`
*`turn` = > json.parse text={"role":"user","content":"one"} *
> agent_history_append id=`id` item=`turn`
*`turn2` = > json.parse text={"role":"assistant","content":"two"} *
> agent_history_append id=`id` item=`turn2`
*`h1` = > agent_history_get id=`id` *
*`n1` = > len value=`h1` *
> print text=`n1`
> `助手`.clear_history
*`h2` = > host_agent_history_get id=`id` *
*`h2` = > agent_history_get id=`id` *
*`n2` = > len value=`h2` *
> print text=`n2`
*`site` = > host_call_site *
*`fn` = > get value=`site` key=function *
*`site` = > agent_call_site *
*`fn` = > json.get value=`site` key=function *
> print text=`fn`
+4 -4
View File
@@ -1,14 +1,14 @@
---
title: ext llm DeepSeek complete (live)
description: Live OpenAI-compatible chat via DeepSeek. Needs tests/ext/.env (gitignored). Not in gold suite.
title: ext llm DeepSeek complete
description: OpenAI-compatible chat via DeepSeek. Credentials from tests/ext/.env.
> ext/ai/llm.mq.md
---
# main
> load_env
> llm.load_env path=.env
*`model` = > llm *
*`model` = > llm.llm *
*`reply` = > `model`.complete prompt=Reply with exactly one English word: pong *
+1 -1
View File
@@ -5,6 +5,6 @@ title: ext llm import
# main
> load_env
> llm.load_env
> print text=ext-ok