Add v0.2 surface syntax, writeback/subtask stdlib, and view input deferral.
Use + for parameters, ordered-list branches, backtick identifiers, and quoted strings with escapes. Add writeback and subtask host libs, optional parameter defaults, narrative-bold comment fix, and defer view execution until preset stdin is submitted. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
92d88fe761
commit
63e5be80ab
116 files changed
+2226
-559
No files matched your search
@@ -7,6 +7,6 @@ title: bad arity
|
||||
> needs_one
|
||||
|
||||
## needs_one
|
||||
- x
|
||||
+ `x`
|
||||
|
||||
> print text=`x`
|
||||
@@ -1,40 +0,0 @@
|
||||
---
|
||||
title: ext/agent run live (DeepSeek)
|
||||
description: Real 执行 via tests/ext/.env (gitignored). Skipped in CI when .env missing.
|
||||
> ext/ai/agent.mq.md
|
||||
> lib/time.mq.md
|
||||
---
|
||||
|
||||
## 获取时间
|
||||
|
||||
*`u` = > now_unix *
|
||||
**> format unix=`u` pattern=%Y%m%d **
|
||||
|
||||
# main
|
||||
|
||||
> load_env
|
||||
|
||||
*`模型` = > llm *
|
||||
|
||||
`工具表` =
|
||||
| 工具 |
|
||||
|------|
|
||||
| 获取时间 |
|
||||
|
||||
*`助手` = > agent model=`模型` tools=`工具表` user_prompt=你是测试助手。需要工具时,必须只回复一行 TOOL:函数名,不要其它文字。 *
|
||||
|
||||
*`id` = > get value=`助手` key=id *
|
||||
|
||||
*`回复` = > `助手`.run extra=请调用获取时间工具,并把当前日期告诉用户。 *
|
||||
|
||||
> print text=`回复`
|
||||
|
||||
*`历史1` = > host_agent_history_get id=`id` *
|
||||
*`条数1` = > len value=`历史1` *
|
||||
> print text=`条数1`
|
||||
|
||||
> `助手`.clear_history
|
||||
|
||||
*`历史2` = > host_agent_history_get id=`id` *
|
||||
*`条数2` = > len value=`历史2` *
|
||||
> print text=`条数2`
|
||||
@@ -20,24 +20,24 @@ description: Ctor, context, clear_history — no network. Gold suite.
|
||||
|
||||
*`has_skill` = > split value=`ctx` sep=Marqdo *
|
||||
*`sk_n` = > len value=`has_skill` *
|
||||
+ `sk_n` > 1
|
||||
1. `sk_n` > 1
|
||||
> print text=skill-ok
|
||||
+ *
|
||||
2. *
|
||||
> print text=skill-missing
|
||||
|
||||
*`has_tools` = > split value=`ctx` sep=获取时间 *
|
||||
*`tool_n` = > len value=`has_tools` *
|
||||
+ `tool_n` > 1
|
||||
1. `tool_n` > 1
|
||||
> print text=tools-ok
|
||||
+ *
|
||||
2. *
|
||||
> print text=tools-missing
|
||||
|
||||
*`src` = > host_module_source *
|
||||
*`has_src` = > split value=`src` sep=probe *
|
||||
*`src_n` = > len value=`has_src` *
|
||||
+ `src_n` > 1
|
||||
1. `src_n` > 1
|
||||
> print text=source-ok
|
||||
+ *
|
||||
2. *
|
||||
> print text=source-missing
|
||||
|
||||
*`turn` = > parse text={"role":"user","content":"one"} *
|
||||
|
||||
@@ -129,6 +129,19 @@ fn structure_paragraph_comment() {
|
||||
assert_out("tests/structure/paragraph-comment.mq.md", "ok");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn structure_narrative_bold() {
|
||||
assert_out("tests/structure/narrative-bold.mq.md", "ok");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn structure_optional_param() {
|
||||
assert_out(
|
||||
"tests/structure/optional-param.mq.md",
|
||||
"Hi, Ada!\nHello, Bob!",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keywords_print() {
|
||||
assert_out(
|
||||
@@ -348,6 +361,23 @@ fn keywords_input() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keywords_input_escape() {
|
||||
for backend in ["tree", "bytecode"] {
|
||||
assert_out_stdin(
|
||||
"tests/keywords/input-escape.mq.md",
|
||||
backend,
|
||||
"Ada\n",
|
||||
"Name:\nHello Ada!",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keywords_quoted_string() {
|
||||
assert_out("tests/keywords/quoted-string.mq.md", "a\nb");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keywords_input_stdin_file() {
|
||||
let (code, stdout, stderr) = run(&[
|
||||
@@ -557,6 +587,28 @@ fn view_output_writes_html() {
|
||||
assert!(dir.join("pages").join("hello.mq.md.html").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn view_input_static_awaits_stdin() {
|
||||
let dir = tempfile_dir("mq-input-view");
|
||||
let (code, _, stderr) = run(&[
|
||||
"view",
|
||||
"output",
|
||||
"tests/keywords/input.mq.md",
|
||||
"-o",
|
||||
dir.to_str().unwrap(),
|
||||
]);
|
||||
assert_eq!(code, 0, "{stderr}");
|
||||
let page = std::fs::read_to_string(dir.join("pages").join("input.mq.md.html")).unwrap();
|
||||
assert!(
|
||||
page.contains("Fill preset input") || page.contains("status-pill pending"),
|
||||
"should defer execution, not fail"
|
||||
);
|
||||
assert!(
|
||||
!page.contains("input needs a line"),
|
||||
"static export should not surface input error before stdin"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_fs_read() {
|
||||
assert_out("tests/lib/fs-read.mq.md", "exists\nhello-lib");
|
||||
@@ -590,6 +642,16 @@ fn lib_sys_dotenv() {
|
||||
assert_out("tests/lib/sys-dotenv.mq.md", "loaded");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_writeback_get() {
|
||||
assert_out("tests/lib/writeback-get.mq.md", "hello-writeback");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_subtask_spawn() {
|
||||
assert_out("tests/lib/subtask-spawn.mq.md", "done");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_json_quote() {
|
||||
assert_out("tests/lib/json-quote.mq.md", "\"hi\"");
|
||||
|
||||
@@ -7,14 +7,14 @@ title: 布尔与逻辑关键字
|
||||
*`a` = True*
|
||||
*`b` = False*
|
||||
|
||||
+ `a` and not `b`
|
||||
1. `a` and not `b`
|
||||
> print text=ok
|
||||
+ *
|
||||
2. *
|
||||
> print text=fail
|
||||
|
||||
*`probe` = 1*
|
||||
|
||||
+ None
|
||||
1. None
|
||||
> print text=none-truthy
|
||||
+ *
|
||||
2. *
|
||||
> print text=none-falsy
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
title: input quoted prompt
|
||||
stdin: Ada
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`name` = > input prompt="Name:\n"*
|
||||
|
||||
> print text=Hello `name`!
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: quoted string literal
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`s` = "a\nb"*
|
||||
|
||||
> print text=`s`
|
||||
@@ -7,14 +7,14 @@ title: 中文布尔与逻辑
|
||||
*`a` = 真*
|
||||
*`b` = 假*
|
||||
|
||||
+ `a` 且 非 `b`
|
||||
1. `a` 且 非 `b`
|
||||
> 打印 内容=ok
|
||||
+ *
|
||||
2. *
|
||||
> 打印 内容=fail
|
||||
|
||||
*`probe` = 1*
|
||||
|
||||
+ 空
|
||||
1. 空
|
||||
> 打印 内容=none-truthy
|
||||
+ *
|
||||
2. *
|
||||
> 打印 内容=none-falsy
|
||||
@@ -7,9 +7,9 @@ title: fs read/exists
|
||||
|
||||
*`ok` = > exists path=hello.txt *
|
||||
|
||||
+ `ok`
|
||||
1. `ok`
|
||||
> print text=exists
|
||||
+ *
|
||||
2. *
|
||||
> print text=missing
|
||||
|
||||
*`t` = > read_text path=hello.txt *
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: subtask child
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
> print text=child-ok
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: subtask spawn join
|
||||
> lib/subtask.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`id` = > spawn path=subtask-child.mq.md *
|
||||
|
||||
*`code` = > wait id=`id` *
|
||||
|
||||
> print text=done
|
||||
@@ -9,7 +9,7 @@ title: sys cwd
|
||||
|
||||
*`n` = > len `d` *
|
||||
|
||||
+ `n` > 0
|
||||
1. `n` > 0
|
||||
> print text=cwd-ok
|
||||
+ *
|
||||
2. *
|
||||
> print text=cwd-empty
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
title: writeback get
|
||||
> lib/writeback.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`out` = > get *
|
||||
|
||||
<!-- marqdo-out
|
||||
hello-writeback
|
||||
-->
|
||||
|
||||
> print text=`out`
|
||||
@@ -7,9 +7,9 @@ title: 中文文件库
|
||||
|
||||
*`有` = > 存在 路径=hello.txt *
|
||||
|
||||
+ `有`
|
||||
1. `有`
|
||||
> 打印 内容=存在
|
||||
+ *
|
||||
2. *
|
||||
> 打印 内容=缺失
|
||||
|
||||
*`t` = > 读文本 路径=hello.txt *
|
||||
|
||||
@@ -6,9 +6,9 @@ title: 分支示例
|
||||
|
||||
*`x` = 0*
|
||||
|
||||
+ `x` > 0
|
||||
1. `x` > 0
|
||||
> print text=正数
|
||||
+ `x` < 0
|
||||
2. `x` < 0
|
||||
> print text=负数
|
||||
+ *
|
||||
3. *
|
||||
> print text=零
|
||||
@@ -12,5 +12,5 @@ title: 集合(表格)示例
|
||||
| 梨 |
|
||||
| 桃 |
|
||||
|
||||
- [果](篮子)
|
||||
- [`果`](`篮子`)
|
||||
> print text=`果`
|
||||
@@ -8,7 +8,7 @@ description: **** 空返回并结束函数体
|
||||
> 问候 谁=Marqdo
|
||||
|
||||
## 问候
|
||||
- 谁
|
||||
+ `谁`
|
||||
|
||||
> print text=Hi `谁`!
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ description: --- 结束嵌套函数体,后续调用属于外层
|
||||
> 问候 谁=World
|
||||
|
||||
## 问候
|
||||
- 谁
|
||||
+ `谁`
|
||||
|
||||
> print text=Hello `谁`!
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ description: 供 frontmatter > 导入;返回用粗体;副作用用输出函
|
||||
---
|
||||
|
||||
## 加一
|
||||
- n
|
||||
+ `n`
|
||||
|
||||
**`n` + 1**
|
||||
|
||||
## 问候
|
||||
- 谁
|
||||
+ `谁`
|
||||
|
||||
> print text=你好,`谁`!
|
||||
@@ -21,5 +21,5 @@ title: 循环示例
|
||||
| 苹果 |
|
||||
| 梨 |
|
||||
|
||||
- [果](篮子)
|
||||
- [`果`](`篮子`)
|
||||
> print text=今天吃`果`
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: narrative bold in comment paragraph
|
||||
description: **强调** mid-line must stay comment, not return syntax
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
说明如下
|
||||
|
||||
**强调信息**是什么什么
|
||||
|
||||
> print text=ok
|
||||
@@ -10,6 +10,6 @@ description: Recommended entry — nested fn; print builtin; bold return
|
||||
> 问候 谁=World
|
||||
|
||||
## 问候
|
||||
- 谁
|
||||
+ `谁`
|
||||
|
||||
> print text=Hello `谁`!
|
||||
@@ -4,7 +4,7 @@ title: object handle smoke
|
||||
---
|
||||
|
||||
# counter
|
||||
- n
|
||||
+ `n`
|
||||
|
||||
*`t` = > parse text={"p":"{\"n\":","s":"}"} *
|
||||
*`qn` = > str `n` *
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: optional param default
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
> tag name=Ada
|
||||
|
||||
> tag name=Bob suffix=Hello
|
||||
|
||||
## tag
|
||||
+ `name`
|
||||
+ `suffix`=Hi
|
||||
|
||||
> print text=`suffix`, `name`!
|
||||
@@ -14,6 +14,6 @@ description: `> fn value` binds by parameter order; named form still works
|
||||
> 问候 谁=World
|
||||
|
||||
## 问候
|
||||
- 谁
|
||||
+ `谁`
|
||||
|
||||
> print text=Hello `谁`!
|
||||
Reference in new issue
Block a user