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:
1 parent
99132ac8fc
commit
1f23e2ed93
108 files changed
+3228
-1023
No files matched your search
@@ -0,0 +1,8 @@
|
||||
---
|
||||
title: path to instance method needs receiver
|
||||
> ../structure/ns/helpers.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
> helpers.Box.tag s=x
|
||||
@@ -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
@@ -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`
|
||||
@@ -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 *
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@ title: ext llm import
|
||||
|
||||
# main
|
||||
|
||||
> load_env
|
||||
> llm.load_env
|
||||
|
||||
> print text=ext-ok
|
||||
+112
-14
@@ -113,6 +113,44 @@ fn structure_import() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn structure_ns_path3() {
|
||||
assert_out(
|
||||
"tests/structure/ns/path3.mq.md",
|
||||
"ok
|
||||
constructed",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn structure_ns_use() {
|
||||
assert_out("tests/structure/ns/use.mq.md", "hi");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bytecode_ns_path3() {
|
||||
assert_out_backend(
|
||||
"tests/structure/ns/path3.mq.md",
|
||||
"bytecode",
|
||||
"ok
|
||||
constructed",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bytecode_ns_use() {
|
||||
assert_out_backend("tests/structure/ns/use.mq.md", "bytecode", "hi");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_ns_instance_method() {
|
||||
assert_err(
|
||||
"tests/errors/ns-instance-method.mq.md",
|
||||
"8:1",
|
||||
"instance method",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn structure_fn_end_hr() {
|
||||
@@ -686,10 +724,12 @@ fn lib_plugin_demo() {
|
||||
} else {
|
||||
"libdemo.so"
|
||||
};
|
||||
let built = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("target")
|
||||
.join("debug")
|
||||
.join(lib_name);
|
||||
let target_dir = std::env::var_os("CARGO_TARGET_DIR")
|
||||
.map(std::path::PathBuf::from)
|
||||
.unwrap_or_else(|| {
|
||||
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("target")
|
||||
});
|
||||
let built = target_dir.join("debug").join(lib_name);
|
||||
assert!(
|
||||
built.is_file(),
|
||||
"missing plugin artifact {}",
|
||||
@@ -775,6 +815,13 @@ fn ext_cli_add_list_remove_llm() {
|
||||
|
||||
#[test]
|
||||
fn ext_cli_add_agent() {
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_agent"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build agent plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_agent");
|
||||
|
||||
let tmp = tempfile_dir("marqdo-ext-agent");
|
||||
let src = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("ext");
|
||||
let bin = env!("CARGO_BIN_EXE_marqdo");
|
||||
@@ -788,12 +835,32 @@ fn ext_cli_add_agent() {
|
||||
assert!(status.success(), "ext add agent failed");
|
||||
assert!(tmp.join("ai").join("agent.mq.md").is_file());
|
||||
assert!(tmp.join("ai").join("智能体.mq.md").is_file());
|
||||
assert!(
|
||||
tmp.join("native").join(if cfg!(windows) {
|
||||
"agent.dll"
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"libagent.dylib"
|
||||
} else {
|
||||
"libagent.so"
|
||||
})
|
||||
.is_file()
|
||||
|| tmp.join("agent.plugin").is_file(),
|
||||
"agent native plugin should be installed"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_agent_framework_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_agent"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build agent plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_agent");
|
||||
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_marqdo"))
|
||||
.args(["run", "tests/ext/agent-smoke.mq.md"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.output()
|
||||
.expect("run agent-smoke");
|
||||
let code = output.status.code().unwrap_or(1);
|
||||
@@ -802,21 +869,40 @@ fn ext_agent_framework_smoke() {
|
||||
assert_eq!(code, 0, "agent-smoke stderr={stderr}");
|
||||
assert_eq!(
|
||||
stdout.trim_end(),
|
||||
"skill-ok\ntools-ok\nsource-ok\n2\n0\nmain",
|
||||
"skill-ok\ntools-ok\nsource-ok\nprotocol-ok\n获取时间\n获取时间\nok-time\n2\n0\nmain",
|
||||
"agent-smoke"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_llm_complete_live() {
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_marqdo"))
|
||||
.args(["run", "tests/ext/llm-complete.mq.md"])
|
||||
.output()
|
||||
.expect("run llm-complete");
|
||||
let code = output.status.code().unwrap_or(1);
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert_eq!(code, 0, "llm-complete stderr={stderr}");
|
||||
let reply = stdout.trim_end().to_lowercase();
|
||||
assert!(
|
||||
reply.contains("pong"),
|
||||
"expected pong in reply, got {stdout:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_agent_run_live() {
|
||||
let env_file = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/ext/.env");
|
||||
if !env_file.is_file() {
|
||||
eprintln!("skip ext_agent_run_live: missing {}", env_file.display());
|
||||
return;
|
||||
}
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_agent"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build agent plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_agent");
|
||||
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_marqdo"))
|
||||
.args(["run", "tests/ext/agent-run-live.mq.md"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.output()
|
||||
.expect("run agent-run-live");
|
||||
let code = output.status.code().unwrap_or(1);
|
||||
@@ -826,14 +912,26 @@ fn ext_agent_run_live() {
|
||||
let lines: Vec<&str> = stdout.trim_end().lines().collect();
|
||||
assert!(lines.len() >= 3, "agent-run-live stdout={stdout}");
|
||||
assert!(
|
||||
lines[0].contains('-') && lines[0].chars().any(|c| c.is_ascii_digit()),
|
||||
"expected time in reply, got {:?}",
|
||||
lines[0].chars().any(|c| c.is_ascii_digit()),
|
||||
"expected date in reply, got {:?}",
|
||||
lines[0]
|
||||
);
|
||||
assert_eq!(lines[1], "2", "history after run");
|
||||
assert_eq!(lines[1], "2", "history after step");
|
||||
assert_eq!(lines[2], "0", "history after clear");
|
||||
// Caller may persist the step map via lib/writeback; agent itself does not write.
|
||||
let src = std::fs::read_to_string(
|
||||
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/ext/agent-run-live.mq.md"),
|
||||
)
|
||||
.expect("read agent-run-live after run");
|
||||
assert!(
|
||||
src.contains("\"status\"") || src.contains("marqdo-out"),
|
||||
"expected caller writeback of step result map"
|
||||
);
|
||||
assert!(
|
||||
!stdout.contains("marqdo-out"),
|
||||
"writeback must not be printed to stdout"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_net_encode() {
|
||||
assert_out("tests/lib/net-encode.mq.md", "a+b");
|
||||
|
||||
@@ -10,6 +10,6 @@ title: foreign python hello
|
||||
print("hello-from-python")
|
||||
```
|
||||
|
||||
*`out` = > run code=`hi` *
|
||||
*`out` = > foreign.run code=`hi` *
|
||||
|
||||
> print text=`out`
|
||||
@@ -5,6 +5,6 @@ title: foreign run_lang
|
||||
|
||||
# main
|
||||
|
||||
*`out` = > run_lang lang=python source=print(2+2) *
|
||||
*`out` = > foreign.run_lang lang=python source=print(2+2) *
|
||||
|
||||
> print text=`out`
|
||||
@@ -5,13 +5,13 @@ title: fs read/exists
|
||||
|
||||
# main
|
||||
|
||||
*`ok` = > exists path=hello.txt *
|
||||
*`ok` = > fs.exists path=hello.txt *
|
||||
|
||||
1. `ok`
|
||||
> print text=exists
|
||||
2. *
|
||||
> print text=missing
|
||||
|
||||
*`t` = > read_text path=hello.txt *
|
||||
*`t` = > fs.read_text path=hello.txt *
|
||||
|
||||
> print text=`t`
|
||||
@@ -5,6 +5,6 @@ title: json quote
|
||||
|
||||
# main
|
||||
|
||||
*`q` = > quote text=hi *
|
||||
*`q` = > json.quote text=hi *
|
||||
|
||||
> print text=`q`
|
||||
@@ -6,18 +6,18 @@ title: json roundtrip
|
||||
|
||||
# main
|
||||
|
||||
*`raw` = > read_text path=sample.json *
|
||||
*`raw` = > fs.read_text path=sample.json *
|
||||
|
||||
*`obj` = > parse text=`raw` *
|
||||
*`obj` = > json.parse text=`raw` *
|
||||
|
||||
*`ty` = > type `obj` *
|
||||
|
||||
> print text=`ty`
|
||||
|
||||
*`a` = > get value=`obj` key=a *
|
||||
*`a` = > json.get value=`obj` key=a *
|
||||
|
||||
> print text=`a`
|
||||
|
||||
*`out` = > stringify value=`obj` *
|
||||
*`out` = > json.stringify value=`obj` *
|
||||
|
||||
> print text=`out`
|
||||
@@ -10,16 +10,16 @@ $$
|
||||
x^3
|
||||
$$
|
||||
|
||||
*`df` = > diff formula=`f` var=x *
|
||||
*`df` = > math.diff formula=`f` var=x *
|
||||
|
||||
*`ty` = > type `df` *
|
||||
|
||||
> print text=`ty`
|
||||
|
||||
*`df2` = > diff formula=`df` var=x *
|
||||
*`df2` = > math.diff formula=`df` var=x *
|
||||
|
||||
> print text=`df2`
|
||||
|
||||
*`y` = > eval formula=`df` var=x value=2 *
|
||||
*`y` = > math.eval formula=`df` var=x value=2 *
|
||||
|
||||
> print text=`y`
|
||||
@@ -14,14 +14,14 @@ $$
|
||||
|
||||
> print text=`ty`
|
||||
|
||||
*`df` = > diff formula=`f` var=x *
|
||||
*`df` = > math.diff formula=`f` var=x *
|
||||
|
||||
> print text=`df`
|
||||
|
||||
*`roots` = > solve formula=`f` var=x *
|
||||
*`roots` = > math.solve formula=`f` var=x *
|
||||
|
||||
> print text=`roots`
|
||||
|
||||
*`y` = > eval formula=`f` var=x value=3 *
|
||||
*`y` = > math.eval formula=`f` var=x value=3 *
|
||||
|
||||
> print text=`y`
|
||||
@@ -10,7 +10,7 @@ $$
|
||||
x^2
|
||||
$$
|
||||
|
||||
*`svg` = > plot formula=`f` var=x min=-2 max=2 *
|
||||
*`svg` = > math.plot formula=`f` var=x min=-2 max=2 *
|
||||
|
||||
*`ok` = > type `svg` *
|
||||
|
||||
|
||||
@@ -5,15 +5,15 @@ title: math random seed
|
||||
|
||||
# main
|
||||
|
||||
> seed value=42
|
||||
> math.seed value=42
|
||||
|
||||
*`a` = > random_int min=1 max=10 *
|
||||
*`a` = > math.random_int min=1 max=10 *
|
||||
|
||||
*`b` = > random_int min=1 max=10 *
|
||||
*`b` = > math.random_int min=1 max=10 *
|
||||
|
||||
> seed value=42
|
||||
> math.seed value=42
|
||||
|
||||
*`c` = > random_int min=1 max=10 *
|
||||
*`c` = > math.random_int min=1 max=10 *
|
||||
|
||||
> print text=`a`
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@ title: net url_encode
|
||||
|
||||
# main
|
||||
|
||||
*`e` = > url_encode text=a b *
|
||||
*`e` = > net.url_encode text=a b *
|
||||
|
||||
> print text=`e`
|
||||
@@ -7,9 +7,9 @@ description: Loads demo cdylib; path from MARQDO_TEST_PLUGIN (set by gold harnes
|
||||
|
||||
# main
|
||||
|
||||
*`p` = > env_get name=MARQDO_TEST_PLUGIN *
|
||||
*`p` = > sys.env_get name=MARQDO_TEST_PLUGIN *
|
||||
|
||||
> load path=`p`
|
||||
> plugin.load path=`p`
|
||||
|
||||
*`sum` = > demo_add a=1 b=2 *
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ title: subtask spawn fn
|
||||
|
||||
# main
|
||||
|
||||
*`args` = > parse text={"n":21} *
|
||||
*`args` = > json.parse text={"n":21} *
|
||||
|
||||
*`id` = > spawn fn=worker args=`args` *
|
||||
*`id` = > subtask.spawn fn=worker args=`args` *
|
||||
|
||||
*`v` = > wait id=`id` *
|
||||
*`v` = > subtask.wait id=`id` *
|
||||
|
||||
> print text=`v`
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ title: subtask foreign spawn
|
||||
print(7 + 8)
|
||||
```
|
||||
|
||||
*`id` = > spawn code=`py` *
|
||||
*`id` = > subtask.spawn code=`py` *
|
||||
|
||||
*`out` = > wait id=`id` *
|
||||
*`out` = > subtask.wait id=`id` *
|
||||
|
||||
> print text=`out`
|
||||
@@ -5,8 +5,8 @@ title: subtask spawn join
|
||||
|
||||
# main
|
||||
|
||||
*`id` = > spawn path=subtask-child.mq.md *
|
||||
*`id` = > subtask.spawn path=subtask-child.mq.md *
|
||||
|
||||
*`code` = > wait id=`id` *
|
||||
*`code` = > subtask.wait id=`id` *
|
||||
|
||||
> print text=done
|
||||
@@ -5,7 +5,7 @@ title: sys cwd
|
||||
|
||||
# main
|
||||
|
||||
*`d` = > cwd *
|
||||
*`d` = > sys.cwd *
|
||||
|
||||
*`n` = > len `d` *
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ title: sys dotenv
|
||||
|
||||
# main
|
||||
|
||||
> write_text path=dotenv-fixture.env text=MARQDO_DOTENV_FIXTURE=loaded
|
||||
> fs.write_text path=dotenv-fixture.env text=MARQDO_DOTENV_FIXTURE=loaded
|
||||
|
||||
> load_dotenv path=dotenv-fixture.env
|
||||
> sys.load_dotenv path=dotenv-fixture.env
|
||||
|
||||
*`v` = > env_get name=MARQDO_DOTENV_FIXTURE *
|
||||
*`v` = > sys.env_get name=MARQDO_DOTENV_FIXTURE *
|
||||
|
||||
> print text=`v`
|
||||
@@ -5,12 +5,12 @@ title: time format/parse
|
||||
|
||||
# main
|
||||
|
||||
*`s` = > format unix=0 pattern=%Y-%m-%d *
|
||||
*`s` = > time.format unix=0 pattern=%Y-%m-%d *
|
||||
|
||||
> print text=`s`
|
||||
|
||||
*`u` = > parse text=1970-01-01 00:00:00 pattern=%Y-%m-%d %H:%M:%S *
|
||||
*`u` = > time.parse text=1970-01-01 00:00:00 pattern=%Y-%m-%d %H:%M:%S *
|
||||
|
||||
> print text=`u`
|
||||
|
||||
> sleep_ms ms=0
|
||||
> time.sleep_ms ms=0
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: async writeback via subtask
|
||||
description: Fire-and-forget persist_slot with explicit line=; join on exit.
|
||||
> lib/writeback.mq.md
|
||||
> lib/subtask.mq.md
|
||||
> lib/json.mq.md
|
||||
---
|
||||
|
||||
## persist_slot
|
||||
+ `key`
|
||||
+ `value`
|
||||
+ `line`
|
||||
|
||||
> writeback.ensure key=ok placeholder=pending line=`line`
|
||||
> writeback.ensure key=error placeholder=pending line=`line`
|
||||
> writeback.record value=`value` key=`key` line=`line`
|
||||
****
|
||||
|
||||
# main
|
||||
|
||||
*`anchor` = > host_outer_call_line *
|
||||
<!-- marqdo-out ok
|
||||
async-ok
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- marqdo-out error
|
||||
pending
|
||||
-->
|
||||
|
||||
*`wb` = > json.parse text={"key":"ok","value":"async-ok"} *
|
||||
*`wb` = > json.set map=`wb` key=line value=`anchor` *
|
||||
> subtask.spawn fn=persist_slot args=`wb`
|
||||
|
||||
> print text=spawned
|
||||
@@ -5,7 +5,7 @@ title: writeback get
|
||||
|
||||
# main
|
||||
|
||||
*`out` = > get *
|
||||
*`out` = > writeback.get *
|
||||
|
||||
<!-- marqdo-out
|
||||
hello-writeback
|
||||
|
||||
@@ -10,6 +10,6 @@ title: foreign zh
|
||||
print("中文外联")
|
||||
```
|
||||
|
||||
*`out` = > 运行 代码=`hi` *
|
||||
*`out` = > 外联.运行 代码=`hi` *
|
||||
|
||||
> print text=`out`
|
||||
@@ -5,12 +5,12 @@ title: math num + zh
|
||||
|
||||
# main
|
||||
|
||||
*`p` = > 圆周率 *
|
||||
*`p` = > 数学.圆周率 *
|
||||
|
||||
*`t` = > type `p` *
|
||||
|
||||
> print text=`t`
|
||||
|
||||
*`s` = > 正弦 value=0 *
|
||||
*`s` = > 数学.正弦 value=0 *
|
||||
|
||||
> print text=`s`
|
||||
@@ -5,13 +5,13 @@ title: 中文文件库
|
||||
|
||||
# main
|
||||
|
||||
*`有` = > 存在 路径=hello.txt *
|
||||
*`有` = > 文件.存在 路径=hello.txt *
|
||||
|
||||
1. `有`
|
||||
> 打印 内容=存在
|
||||
2. *
|
||||
> 打印 内容=缺失
|
||||
|
||||
*`t` = > 读文本 路径=hello.txt *
|
||||
*`t` = > 文件.读文本 路径=hello.txt *
|
||||
|
||||
> 打印 内容=`t`
|
||||
@@ -6,7 +6,7 @@ title: import official lib (Chinese)
|
||||
|
||||
# main
|
||||
|
||||
*`t` = > 去空白 s= x *
|
||||
*`t` = > 文本.去空白 s= x *
|
||||
|
||||
> 打印 内容=`t`
|
||||
|
||||
@@ -17,10 +17,10 @@ title: import official lib (Chinese)
|
||||
| a |
|
||||
| b |
|
||||
|
||||
*`n` = > 行数 xs=`xs`*
|
||||
*`n` = > 表.行数 xs=`xs`*
|
||||
|
||||
> 打印 内容=`n`
|
||||
|
||||
*`row` = > 取行 xs=`xs` i=0*
|
||||
*`row` = > 表.取行 xs=`xs` i=0*
|
||||
|
||||
> 打印 内容=`row`
|
||||
@@ -7,8 +7,8 @@ title: 跨文件导入示例
|
||||
|
||||
导入 `utils.mq.md` 后:用返回值绑定,再输出;并直接调用问候。
|
||||
|
||||
*`y` = > 加一 n=41*
|
||||
*`y` = > utils.加一 n=41*
|
||||
|
||||
> print text=`y`
|
||||
|
||||
> 问候 谁=Marqdo
|
||||
> utils.问候 谁=Marqdo
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
title: namespace path helpers
|
||||
---
|
||||
|
||||
## pack
|
||||
|
||||
Nested free function (not an object method) for `helpers.pack.label`.
|
||||
|
||||
### label
|
||||
+ `s`
|
||||
|
||||
**`s`**
|
||||
|
||||
# Box
|
||||
|
||||
## tag
|
||||
+ `s`
|
||||
|
||||
**`s`**
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
title: three-segment library path
|
||||
> helpers.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`v` = > helpers.pack.label s=ok*
|
||||
|
||||
> print text=`v`
|
||||
|
||||
*`b` = > helpers.Box *
|
||||
|
||||
> print text=constructed
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
title: frontmatter use short name
|
||||
> lib/text.mq.md
|
||||
> use text.str_trim as trim_text
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`t` = > trim_text s= hi *
|
||||
|
||||
> print text=`t`
|
||||
@@ -6,32 +6,32 @@ title: object handle smoke
|
||||
# counter
|
||||
+ `n`
|
||||
|
||||
*`t` = > parse text={"p":"{\"n\":","s":"}"} *
|
||||
*`t` = > json.parse text={"p":"{\"n\":","s":"}"} *
|
||||
*`qn` = > str `n` *
|
||||
*`p` = > get value=`t` key=p *
|
||||
*`s` = > get value=`t` key=s *
|
||||
*`p` = > json.get value=`t` key=p *
|
||||
*`s` = > json.get value=`t` key=s *
|
||||
*`raw` = `p` + `qn` + `s` *
|
||||
**> parse text=`raw`**
|
||||
**> json.parse text=`raw`**
|
||||
|
||||
## bump
|
||||
|
||||
*`n` = > get value=`self` key=n *
|
||||
*`n` = > json.get value=`self` key=n *
|
||||
*`n2` = `n` + 1*
|
||||
*`t` = > parse text={"p":"{\"n\":","s":"}"} *
|
||||
*`t` = > json.parse text={"p":"{\"n\":","s":"}"} *
|
||||
*`qn` = > str `n2` *
|
||||
*`p` = > get value=`t` key=p *
|
||||
*`s` = > get value=`t` key=s *
|
||||
*`p` = > json.get value=`t` key=p *
|
||||
*`s` = > json.get value=`t` key=s *
|
||||
*`raw` = `p` + `qn` + `s` *
|
||||
*`m` = > parse text=`raw` *
|
||||
*`m` = > json.parse text=`raw` *
|
||||
**`m`**
|
||||
|
||||
# main
|
||||
|
||||
*`c` = > counter n=3 *
|
||||
*`ty` = > get value=`c` key=_type *
|
||||
*`ty` = > json.get value=`c` key=_type *
|
||||
> print text=`ty`
|
||||
*`n` = > get value=`c` key=n *
|
||||
*`n` = > json.get value=`c` key=n *
|
||||
> print text=`n`
|
||||
*`c2` = > `c`.bump *
|
||||
*`n2` = > get value=`c2` key=n *
|
||||
*`n2` = > json.get value=`c2` key=n *
|
||||
> print text=`n2`
|
||||
Reference in new issue
Block a user