feat(markup): finish v0.3 stock migration and green gold

Migrate remaining .mq.md (tests/ext/public/examples), stop elevating local assigns to params, inject form_target in Go libweb, and skip live LLM gold without a real key.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-13 23:43:44 +08:00
1 parent bfb10d172b
commit b5c07385e9
324 files changed
+4572 -4339

No files matched your search

+1 -1
View File
@@ -4,4 +4,4 @@ title: bad int
# main
*x = > int not-a-number*
**x = > int not-a-number**
+1 -1
View File
@@ -4,4 +4,4 @@ title: empty split sep
# main
*xs = > split value="ab" sep=*
**xs = > split value="ab" sep=**
+1 -1
View File
@@ -4,6 +4,6 @@ title: division by zero
# main
*x = 1 / 0*
**x = 1 / 0**
> print text=`x`
+1 -1
View File
@@ -10,6 +10,6 @@ title: footnote missing map key
|------|------|
| 水果 | 蔬菜 |
*x = 分类[^香蕉]*
**x = 分类[^香蕉]**
> print text=`x`
+1 -1
View File
@@ -10,6 +10,6 @@ title: footnote list out of range
|----|
| 苹果 |
*x = 篮子[^2]*
**x = 篮子[^2]**
> print text=`x`
+1 -1
View File
@@ -10,6 +10,6 @@ title: footnote [^0] invalid
|----|
| 苹果 |
*x = 篮子[^0]*
**x = 篮子[^0]**
> print text=`x`
+15 -15
View File
@@ -10,11 +10,11 @@ import sys:lib/sys.mq.md
## probe_tool
**"probe-ok"**
*"probe-ok"*
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
@@ -22,7 +22,7 @@ import sys:lib/sys.mq.md
> sys.exit code=1
> sys.env_set name="OPENAI_API_KEY" value="offline-constitution-dummy"
*model = > llm.llm*
**model = > llm.llm**
`工具表` =
@@ -30,17 +30,17 @@ import sys:lib/sys.mq.md
|------|
| probe_tool |
*助手 = > agent.agent model=`model` tools=`工具表` standing="constitution probe"*
*ctx = > agent.build_step_context agent=`助手` task="constitution-probe-task"*
**助手 = > agent.agent model=`model` tools=`工具表` standing="constitution probe"**
**ctx = > agent.build_step_context agent=`助手` task="constitution-probe-task"**
*a = > split value=`ctx` sep="--- call site ---"*
*b = > split value=`ctx` sep="--- source (.mq.md) ---"*
*c = > split value=`ctx` sep="--- how to act ---"*
*d = > split value=`ctx` sep="Code is documentation"*
*na = > len value=`a`*
*nb = > len value=`b`*
*nc = > len value=`c`*
*nd = > len value=`d`*
**a = > split value=`ctx` sep="--- call site ---"**
**b = > split value=`ctx` sep="--- source (.mq.md) ---"**
**c = > split value=`ctx` sep="--- how to act ---"**
**d = > split value=`ctx` sep="Code is documentation"**
**na = > len value=`a`**
**nb = > len value=`b`**
**nc = > len value=`c`**
**nd = > len value=`d`**
1. `na` > 1
1. `nb` > 1
1. `nc` > 1
@@ -59,8 +59,8 @@ import sys:lib/sys.mq.md
> print text=call-site-missing
> sys.exit code=1
*site = > agent_call_site*
*path = > json.get value=`site` key="path"*
**site = > agent_call_site**
**path = > json.get value=`site` key="path"**
1. `path`
> print text=site-path-ok
2. *
+20 -20
View File
@@ -75,7 +75,7 @@ PAD_END
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
@@ -83,55 +83,55 @@ PAD_END
> sys.exit code=1
> sys.env_set name="OPENAI_API_KEY" value="offline-a3-dummy"
*model = > llm.llm*
*tools = > json.parse text=[]*
*助手 = > agent.agent model=`model` tools=`tools` standing="a3 budget"*
**model = > llm.llm**
**tools = > json.parse text=[]**
**助手 = > agent.agent model=`model` tools=`tools` standing="a3 budget"**
*brief = > agent.source_brief depth="default"*
*has = > split value=`brief` sep="truncated source_len="*
*hn = > len value=`has`*
**brief = > agent.source_brief depth="default"**
**has = > split value=`brief` sep="truncated source_len="**
**hn = > len value=`has`**
1. `hn` > 1
> print text=source-trunc
2. *
> print text=source-full
*deep = > agent.source_brief depth="deep"*
*dhas = > split value=`deep` sep="truncated source_len="*
*dn = > len value=`dhas`*
**deep = > agent.source_brief depth="deep"**
**dhas = > split value=`deep` sep="truncated source_len="**
**dn = > len value=`dhas`**
1. `dn` > 1
> print text=deep-still-trunc
2. *
> print text=deep-wider
*sk = > agent.skill_brief depth="default"*
**sk = > agent.skill_brief depth="default"**
1. `sk`
> print text=skill-ok
2. *
> print text=skill-missing
*rk = > agent.extract_plan_read reply="READ:skill"*
**rk = > agent.extract_plan_read reply="READ:skill"**
1. `rk` == skill
> print text=read-skill-parse
2. *
> print text=read-skill-bad
*obs = > json.parse text={}*
*obs2 = > agent.plan_read_deepen observation=`obs` kind="skill" path="."*
*flag = > json.get value=`obs2` key="read_skill"*
**obs = > json.parse text={}**
**obs2 = > agent.plan_read_deepen observation=`obs` kind="skill" path="."**
**flag = > json.get value=`obs2` key="read_skill"**
1. `flag`
> print text=read-skill-ok
2. *
> print text=read-skill-miss
*ctx = > agent.build_step_context agent=`助手` task="probe" source_depth="default" skill_depth="default"*
*c1 = > split value=`ctx` sep="truncated source_len="*
*cn = > len value=`c1`*
**ctx = > agent.build_step_context agent=`助手` task="probe" source_depth="default" skill_depth="default"**
**c1 = > split value=`ctx` sep="truncated source_len="**
**cn = > len value=`c1`**
1. `cn` > 1
> print text=ctx-trunc
2. *
> print text=ctx-no-trunc
*c2 = > split value=`ctx` sep="READ:source"*
*cn2 = > len value=`c2`*
**c2 = > split value=`ctx` sep="READ:source"**
**cn2 = > len value=`c2`**
1. `cn2` > 1
> print text=ctx-protocol
2. *
+11 -11
View File
@@ -10,11 +10,11 @@ import sys:lib/sys.mq.md
## probe_tool
**"probe-ok"**
*"probe-ok"*
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
@@ -22,25 +22,25 @@ import sys:lib/sys.mq.md
> sys.exit code=1
> sys.env_set name="OPENAI_API_KEY" value="offline-dump-dummy"
*model = > llm.llm*
**model = > llm.llm**
`工具表` =
| 工具 |
|------|
| probe_tool |
*助手 = > agent.agent model=`model` tools=`工具表` standing="dump probe"*
*dump = > agent.dump_step_context agent=`助手` task="dump-probe-task"*
**助手 = > agent.agent model=`model` tools=`工具表` standing="dump probe"**
**dump = > agent.dump_step_context agent=`助手` task="dump-probe-task"**
*site = > json.get value=`dump` key="call_site"*
*path = > json.get value=`site` key="path"*
*chars = > json.get value=`dump` key="prompt_chars"*
*prompt = > json.get value=`dump` key="prompt"*
**site = > json.get value=`dump` key="call_site"**
**path = > json.get value=`site` key="path"**
**chars = > json.get value=`dump` key="prompt_chars"**
**prompt = > json.get value=`dump` key="prompt"**
1. `path`
1. `chars` > 100
*parts = > split value=`prompt` sep="--- call site ---"*
*n = > len value=`parts`*
**parts = > split value=`prompt` sep="--- call site ---"**
**n = > len value=`parts`**
1. `n` > 1
> print text=dump-context-ok
2. *
+10 -10
View File
@@ -8,23 +8,23 @@ import fs:lib/fs.mq.md
# main
*paths = > json.parse text={"f":".marqdo/agent-runs/inspect-fixture.mq.md"}*
*fixture = > json.get value=`paths` key="f"*
*body = > json.parse text={"t":"# main\n\n> print text=hi\n<!-- marqdo-out ok\n{\"status\":\"ok\",\"result\":\"done\"}\n-->\n<!-- marqdo-out error\npending\n-->\n"}*
*t = > json.get value=`body` key="t"*
**paths = > json.parse text={"f":".marqdo/agent-runs/inspect-fixture.mq.md"}**
**fixture = > json.get value=`paths` key="f"**
**body = > json.parse text={"t":"# main\n\n> print text=hi\n<!-- marqdo-out ok\n{\"status\":\"ok\",\"result\":\"done\"}\n-->\n<!-- marqdo-out error\npending\n-->\n"}**
**t = > json.get value=`body` key="t"**
> fs.write_text path=`fixture` text=`t`
*obs = > agent.inspect_workbook path=`fixture` exit_code=0*
*code = > json.get value=`obs` key="exit_code"*
**obs = > agent.inspect_workbook path=`fixture` exit_code=0**
**code = > json.get value=`obs` key="exit_code"**
> print text=`code`
*ok = > json.get value=`obs` key="last_ok"*
*has = > split value=`ok` sep="done"*
*n = > len value=`has`*
**ok = > json.get value=`obs` key="last_ok"**
**has = > split value=`ok` sep="done"**
**n = > len value=`has`**
1. `n` > 1
> print text=ok-slot
2. *
> print text=ok-missing
*err = > json.get value=`obs` key="last_error"*
**err = > json.get value=`obs` key="last_error"**
> print text=`err`
+32 -32
View File
@@ -10,83 +10,83 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
> print text=no-agent-plugin
> sys.exit code=1
*kb = ".marqdo/agent-kb-alias-test"*
*wb = ".marqdo/agent-runs/alias-pong.mq.md"*
*goal = "Reply with exactly the word pong and nothing else."*
*alias = "say pong only"*
*body = "---\ntitle: pong skill\n---\n\n# main\n\n*msg = \"pong\"*\n\n**msg**\n"*
**kb = ".marqdo/agent-kb-alias-test"**
**wb = ".marqdo/agent-runs/alias-pong.mq.md"**
**goal = "Reply with exactly the word pong and nothing else."**
**alias = "say pong only"**
**body = "---\ntitle: pong skill\n---\n\n# main\n\n**msg = \"pong\"**\n\n*msg*\n"**
> fs.write_text path=`wb` text=`body`
*prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb` aliases=`alias`*
*okp = > json.get value=`prom` key="promoted"*
**prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb` aliases=`alias`**
**okp = > json.get value=`prom` key="promoted"**
1. `okp`
> print text=promoted
2. *
> print text=promote-fail
*slug = > json.get value=`prom` key="slug"*
*parts = > json.parse text={"a":"/concepts/tasks/","b":".md"}*
*a = > json.get value=`parts` key="a"*
*b = > json.get value=`parts` key="b"*
*task = kb + a + slug + b*
*src = > fs.read_text path=`task`*
*has = > split value=`src` sep="say pong only"*
*hn = > len value=`has`*
**slug = > json.get value=`prom` key="slug"**
**parts = > json.parse text={"a":"/concepts/tasks/","b":".md"}**
**a = > json.get value=`parts` key="a"**
**b = > json.get value=`parts` key="b"**
**task = kb + a + slug + b**
**src = > fs.read_text path=`task`**
**has = > split value=`src` sep="say pong only"**
**hn = > len value=`has`**
1. `hn` > 1
> print text=alias-written
2. *
> print text=alias-missing
*hit = > agent_kb_lookup kb_dir=`kb` goal=`alias`*
**hit = > agent_kb_lookup kb_dir=`kb` goal=`alias`**
1. `hit`
> print text=alias-ok
2. *
> print text=alias-miss
*mk = > json.get value=`hit` key="match"*
**mk = > json.get value=`hit` key="match"**
> print text=`mk`
*slug_hit = > json.get value=`hit` key="slug"*
**slug_hit = > json.get value=`hit` key="slug"**
1. `slug` == `slug_hit`
> print text=same-slug
2. *
> print text=slug-drift
*exact = > agent_kb_lookup kb_dir=`kb` goal=`goal`*
*mk2 = > json.get value=`exact` key="match"*
**exact = > agent_kb_lookup kb_dir=`kb` goal=`goal`**
**mk2 = > json.get value=`exact` key="match"**
> print text=`mk2`
*g_trip = "帮我规划明天的行程"*
*wb2 = ".marqdo/agent-runs/alias-trip.mq.md"*
*body2 = "---\ntitle: trip\n---\n\n# main\n\n*msg = \"trip-ok\"*\n\n**msg**\n"*
**g_trip = "帮我规划明天的行程"**
**wb2 = ".marqdo/agent-runs/alias-trip.mq.md"**
**body2 = "---\ntitle: trip\n---\n\n# main\n\n**msg = \"trip-ok\"**\n\n*msg*\n"**
> fs.write_text path=`wb2` text=`body2`
*prom2 = > agent_kb_promote kb_dir=`kb` goal=`g_trip` workbook=`wb2`*
*ok2 = > json.get value=`prom2` key="promoted"*
**prom2 = > agent_kb_promote kb_dir=`kb` goal=`g_trip` workbook=`wb2`**
**ok2 = > json.get value=`prom2` key="promoted"**
1. `ok2`
> print text=trip-promoted
2. *
> print text=trip-promote-fail
*g_canon = "你是一个智能体,帮我规划明天的行程"*
*c = > agent_kb_canonicalize goal=`g_canon`*
**g_canon = "你是一个智能体,帮我规划明天的行程"**
**c = > agent_kb_canonicalize goal=`g_canon`**
> print text=`c`
*hit_c = > agent_kb_lookup kb_dir=`kb` goal=`g_canon`*
**hit_c = > agent_kb_lookup kb_dir=`kb` goal=`g_canon`**
1. `hit_c`
> print text=canonical-ok
2. *
> print text=canonical-miss
*mk3 = > json.get value=`hit_c` key="match"*
**mk3 = > json.get value=`hit_c` key="match"**
> print text=`mk3`
*listed = > agent_kb_list_tasks kb_dir=`kb`*
*tc = > json.get value=`listed` key="count"*
**listed = > agent_kb_list_tasks kb_dir=`kb`**
**tc = > json.get value=`listed` key="count"**
1. `tc` > 1
> print text=list-ok
2. *
+22 -22
View File
@@ -10,67 +10,67 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
> print text=no-agent-plugin
> sys.exit code=1
*kb = ".marqdo/agent-kb-near-test"*
*wb = ".marqdo/agent-runs/near-trip.mq.md"*
*goal = "帮我规划明天的行程"*
*body = "---\ntitle: trip\n---\n\n# main\n\n*msg = \"trip-ok\"*\n\n**msg**\n"*
**kb = ".marqdo/agent-kb-near-test"**
**wb = ".marqdo/agent-runs/near-trip.mq.md"**
**goal = "帮我规划明天的行程"**
**body = "---\ntitle: trip\n---\n\n# main\n\n**msg = \"trip-ok\"**\n\n*msg*\n"**
> fs.write_text path=`wb` text=`body`
*prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb`*
*okp = > json.get value=`prom` key="promoted"*
**prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb`**
**okp = > json.get value=`prom` key="promoted"**
1. `okp`
> print text=promoted
2. *
> print text=promote-fail
*slug = > json.get value=`prom` key="slug"*
**slug = > json.get value=`prom` key="slug"**
*g1 = "帮我规划明天行程"*
*hit1 = > agent_kb_lookup kb_dir=`kb` goal=`g1` near_match=True near_threshold=0.78*
**g1 = "帮我规划明天行程"**
**hit1 = > agent_kb_lookup kb_dir=`kb` goal=`g1` near_match=True near_threshold=0.78**
1. `hit1`
> print text=near-ok
2. *
> print text=near-miss
*mk1 = > json.get value=`hit1` key="match"*
**mk1 = > json.get value=`hit1` key="match"**
> print text=`mk1`
*slug1 = > json.get value=`hit1` key="slug"*
**slug1 = > json.get value=`hit1` key="slug"**
1. `slug` == `slug1`
> print text=same-slug
2. *
> print text=slug-drift
*off = > agent_kb_lookup kb_dir=`kb` goal=`g1` near_match=False*
**off = > agent_kb_lookup kb_dir=`kb` goal=`g1` near_match=False**
1. `off`
> print text=off-hit
2. *
> print text=off-miss
*g2 = "明天做什么好"*
*hit2 = > agent_kb_lookup kb_dir=`kb` goal=`g2` near_match=True near_threshold=0.78*
**g2 = "明天做什么好"**
**hit2 = > agent_kb_lookup kb_dir=`kb` goal=`g2` near_match=True near_threshold=0.78**
1. `hit2`
> print text=neg-hit
2. *
> print text=neg-miss
*ranked = > agent_kb_near_match kb_dir=`kb` goal=`g1`*
*best = > json.get value=`ranked` key="best"*
*bs = > json.get value=`best` key="slug"*
**ranked = > agent_kb_near_match kb_dir=`kb` goal=`g1`**
**best = > json.get value=`ranked` key="best"**
**bs = > json.get value=`best` key="slug"**
1. `bs` == `slug`
> print text=rank-ok
2. *
> print text=rank-bad
*tasks = > json.get value=`ranked` key="candidates"*
*prompt = > agent.build_soft_match_prompt goal=`g1` tasks=`tasks`*
*has = > split value=`prompt` sep="score="*
*hn = > len value=`has`*
**tasks = > json.get value=`ranked` key="candidates"**
**prompt = > agent.build_soft_match_prompt goal=`g1` tasks=`tasks`**
**has = > split value=`prompt` sep="score="**
**hn = > len value=`has`**
1. `hn` > 1
> print text=prompt-score-ok
2. *
+36 -36
View File
@@ -11,7 +11,7 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
@@ -19,86 +19,86 @@ import sys:lib/sys.mq.md
> sys.exit code=1
> sys.env_set name="OPENAI_API_KEY" value="offline-a1-dummy"
*model = > llm.llm*
*tools = > json.parse text=[]*
*助手 = > agent.agent model=`model` tools=`tools` standing="offline plan-hit"*
**model = > llm.llm**
**tools = > json.parse text=[]**
**助手 = > agent.agent model=`model` tools=`tools` standing="offline plan-hit"**
*paths = > json.parse text={"kb":".marqdo/agent-kb-a1-plan-hit","wb":".marqdo/agent-runs/a1-pong-solid.mq.md","goal":"Reply with exactly the word pong and nothing else.","near":"Reply with exactly the word pong.","body":"---\ntitle: a1 pong\n---\n\n# main\n\n*msg = \"pong\"*\n\n**msg**\n"}*
*kb = > json.get value=`paths` key="kb"*
*wb = > json.get value=`paths` key="wb"*
*goal = > json.get value=`paths` key="goal"*
*near_g = > json.get value=`paths` key="near"*
*body = > json.get value=`paths` key="body"*
**paths = > json.parse text={"kb":".marqdo/agent-kb-a1-plan-hit","wb":".marqdo/agent-runs/a1-pong-solid.mq.md","goal":"Reply with exactly the word pong and nothing else.","near":"Reply with exactly the word pong.","body":"---\ntitle: a1 pong\n---\n\n# main\n\n**msg = \"pong\"**\n\n*msg*\n"}**
**kb = > json.get value=`paths` key="kb"**
**wb = > json.get value=`paths` key="wb"**
**goal = > json.get value=`paths` key="goal"**
**near_g = > json.get value=`paths` key="near"**
**body = > json.get value=`paths` key="body"**
1. > fs.exists path=`kb`
> fs.remove path=`kb`
2. *
*_ = 1*
**_ = 1**
> fs.write_text path=`wb` text=`body`
*prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb`*
*okp = > json.get value=`prom` key="promoted"*
**prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb`**
**okp = > json.get value=`prom` key="promoted"**
1. `okp`
> print text=promoted
2. *
> print text=promote-fail
> sys.exit code=1
*listed = > agent_kb_list_tasks kb_dir=`kb`*
*tc = > json.get value=`listed` key="count"*
**listed = > agent_kb_list_tasks kb_dir=`kb`**
**tc = > json.get value=`listed` key="count"**
1. `tc` > 0
> print text=list-ok
2. *
> print text=list-bad
> sys.exit code=1
*tasks = > json.get value=`listed` key="tasks"*
*t0 = > at value=`tasks` index=0*
*lf = > json.get value=`t0` key="llm_free"*
**tasks = > json.get value=`listed` key="tasks"**
**t0 = > at value=`tasks` index=0**
**lf = > json.get value=`t0` key="llm_free"**
1. `lf`
> print text=list-free
2. *
> print text=list-not-free
*st = > json.get value=`t0` key="status"*
**st = > json.get value=`t0` key="status"**
> print text=`st`
*desc = > json.get value=`t0` key="description"*
**desc = > json.get value=`t0` key="description"**
1. `desc`
> print text=list-desc
2. *
> print text=list-no-desc
*out = > `助手`.plan goal=`goal` max_rounds=2 writeback=False kb_dir=`kb` explore_n=0 promote=False*
*cache = > json.get value=`out` key="cache"*
**out = > `助手`.plan goal=`goal` max_rounds=2 writeback=False kb_dir=`kb` explore_n=0 promote=False**
**cache = > json.get value=`out` key="cache"**
> print text=`cache`
*mk = > json.get value=`out` key="match"*
**mk = > json.get value=`out` key="match"**
> print text=`mk`
*val = > json.get value=`out` key="result"*
**val = > json.get value=`out` key="result"**
> print text=`val`
*sum = > json.get value=`out` key="summary"*
*has = > split value=`sum` sep="exact"*
*hn = > len value=`has`*
**sum = > json.get value=`out` key="summary"**
**has = > split value=`sum` sep="exact"**
**hn = > len value=`has`**
1. `hn` > 1
> print text=sum-exact
2. *
> print text=sum-bad
*evs = > json.get value=`out` key="events"*
*en = > len value=`evs`*
**evs = > json.get value=`out` key="events"**
**en = > len value=`evs`**
1. `en` > 2
> print text=events-ok
2. *
> print text=events-bad
*e0 = > at value=`evs` index=0*
*t0 = > json.get value=`e0` key="type"*
**e0 = > at value=`evs` index=0**
**t0 = > json.get value=`e0` key="type"**
> print text=`t0`
*d0 = > json.get value=`e0` key="decision"*
**d0 = > json.get value=`e0` key="decision"**
> print text=`d0`
*out2 = > `助手`.plan goal=`near_g` max_rounds=2 writeback=False kb_dir=`kb` explore_n=0 promote=False*
*cache2 = > json.get value=`out2` key="cache"*
**out2 = > `助手`.plan goal=`near_g` max_rounds=2 writeback=False kb_dir=`kb` explore_n=0 promote=False**
**cache2 = > json.get value=`out2` key="cache"**
> print text=`cache2`
*mk2 = > json.get value=`out2` key="match"*
**mk2 = > json.get value=`out2` key="match"**
> print text=`mk2`
*val2 = > json.get value=`out2` key="result"*
**val2 = > json.get value=`out2` key="result"**
> print text=`val2`
+20 -20
View File
@@ -11,56 +11,56 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
> print text=no-agent-plugin
> sys.exit code=1
*paths = > json.parse text={"kb":".marqdo/agent-kb","wb":".marqdo/agent-runs/pong-solid.mq.md","goal":"Reply with exactly the word pong and nothing else.","body":"---\ntitle: pong skill\n---\n\n# main\n\n*msg = \"pong\"*\n\n**msg**\n"}*
*kb = > json.get value=`paths` key="kb"*
*wb = > json.get value=`paths` key="wb"*
*goal = > json.get value=`paths` key="goal"*
*body = > json.get value=`paths` key="body"*
**paths = > json.parse text={"kb":".marqdo/agent-kb","wb":".marqdo/agent-runs/pong-solid.mq.md","goal":"Reply with exactly the word pong and nothing else.","body":"---\ntitle: pong skill\n---\n\n# main\n\n**msg = \"pong\"**\n\n*msg*\n"}**
**kb = > json.get value=`paths` key="kb"**
**wb = > json.get value=`paths` key="wb"**
**goal = > json.get value=`paths` key="goal"**
**body = > json.get value=`paths` key="body"**
> fs.write_text path=`wb` text=`body`
*sig = > agent_goal_sig goal=`goal`*
**sig = > agent_goal_sig goal=`goal`**
> print text=`sig`
*slug0 = > agent_goal_slug goal=`goal`*
**slug0 = > agent_goal_slug goal=`goal`**
> print text=`slug0`
*prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb`*
*okp = > json.get value=`prom` key="promoted"*
**prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb`**
**okp = > json.get value=`prom` key="promoted"**
1. `okp`
> print text=promoted
2. *
> print text=promote-fail
*st = > json.get value=`prom` key="status"*
**st = > json.get value=`prom` key="status"**
> print text=`st`
*slug = > json.get value=`prom` key="slug"*
**slug = > json.get value=`prom` key="slug"**
> print text=`slug`
*hit = > agent_kb_lookup kb_dir=`kb` goal=`goal`*
**hit = > agent_kb_lookup kb_dir=`kb` goal=`goal`**
1. `hit`
> print text=lookup-ok
2. *
> print text=lookup-miss
*res = > json.get value=`hit` key="resource"*
*id = > subtask.spawn path=`res`*
*waited = > subtask.wait id=`id`*
*code = > json.get value=`waited` key="code"*
*val = > json.get value=`waited` key="value"*
**res = > json.get value=`hit` key="resource"**
**id = > subtask.spawn path=`res`**
**waited = > subtask.wait id=`id`**
**code = > json.get value=`waited` key="code"**
**val = > json.get value=`waited` key="value"**
> print text=`code`
> print text=`val`
*hit2 = > agent_kb_lookup kb_dir=`kb` goal=`goal`*
*res2 = > json.get value=`hit2` key="resource"*
**hit2 = > agent_kb_lookup kb_dir=`kb` goal=`goal`**
**res2 = > json.get value=`hit2` key="resource"**
1. `res` == `res2`
> print text=stable-path
2. *
+17 -17
View File
@@ -9,36 +9,36 @@ import sys:lib/sys.mq.md
# main
*parts = > json.parse text={"a":"CALL:lib.fs.exists","b":"ARGS:{\"path\":\".\"}","nl":"\n"}*
*a = > json.get value=`parts` key="a"*
*b = > json.get value=`parts` key="b"*
*nl = > json.get value=`parts` key="nl"*
*t_ok = a + nl + b + nl*
*act = > agent.extract_plan_act reply=`t_ok`*
*kind = > json.get value=`act` key="kind"*
*name = > json.get value=`act` key="name"*
**parts = > json.parse text={"a":"CALL:lib.fs.exists","b":"ARGS:{\"path\":\".\"}","nl":"\n"}**
**a = > json.get value=`parts` key="a"**
**b = > json.get value=`parts` key="b"**
**nl = > json.get value=`parts` key="nl"**
**t_ok = a + nl + b + nl**
**act = > agent.extract_plan_act reply=`t_ok`**
**kind = > json.get value=`act` key="kind"**
**name = > json.get value=`act` key="name"**
> print text=`kind`
> print text=`name`
*out = > agent.run_parent_tool name=`name` path="." reply=`t_ok`*
**out = > agent.run_parent_tool name=`name` path="." reply=`t_ok`**
1. `out`
> print text=exists-ok
2. *
> print text=exists-bad
*deny = > agent.run_parent_tool name="lib.net.get" path="." reply="CALL:lib.net.get"*
*sep = > json.parse text={"s":"not allowed"}*
*s = > json.get value=`sep` key="s"*
*dparts = > split value=`deny` sep=`s`*
*pn = > len value=`dparts`*
**deny = > agent.run_parent_tool name="lib.net.get" path="." reply="CALL:lib.net.get"**
**sep = > json.parse text={"s":"not allowed"}**
**s = > json.get value=`sep` key="s"**
**dparts = > split value=`deny` sep=`s`**
**pn = > len value=`dparts`**
1. `pn` > 1
> print text=deny-ok
2. *
> print text=deny-bad
*cat = > agent.lib_catalog*
*callable = > json.get value=`cat` key="callable"*
*cn = > len value=`callable`*
**cat = > agent.lib_catalog**
**callable = > json.get value=`cat` key="callable"**
**cn = > len value=`callable`**
1. `cn` > 3
> print text=callable-ok
2. *
+1 -1
View File
@@ -12,4 +12,4 @@ description: Tool target for MCP server smoke.
|----|-----|
| true | mcp |
**out**
*out*
+7 -7
View File
@@ -9,23 +9,23 @@ import demo:agent-mcp-server-helpers.mq.md
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
> sys.exit code=1
*srv = > agent.mcp_server name="marqdo-test"*
*srv = > `srv`.tool name="ping" fn="demo.ping" description="ping tool"*
*tools = srv[^tools]*
*n = > len value=`tools`*
**srv = > agent.mcp_server name="marqdo-test"**
**srv = > `srv`.tool name="ping" fn="demo.ping" description="ping tool"**
**tools = srv[^tools]**
**n = > len value=`tools`**
1. `n` == 1
> print text=mcp-tool-ok
2. *
> print text=mcp-tool-fail
*t0 = tools[^1]*
*fn = t0[^fn]*
**t0 = tools[^1]**
**fn = t0[^fn]**
1. `fn` == "demo.ping"
> print text=mcp-fn-ok
2. *
+10 -10
View File
@@ -11,25 +11,25 @@ import fs:lib/fs.mq.md
> llm.load_env path=.env
*model = > llm.llm*
*tools = > json.parse text=[]*
*助手 = > agent.agent model=`model` tools=`tools` standing="offline plan confirm"*
**model = > llm.llm**
**tools = > json.parse text=[]**
**助手 = > agent.agent model=`model` tools=`tools` standing="offline plan confirm"**
*out = > `助手`.plan goal="say hi" confirm=True workbook_dir=".marqdo/agent-runs" writeback=False*
**out = > `助手`.plan goal="say hi" confirm=True workbook_dir=".marqdo/agent-runs" writeback=False**
*st = > json.get value=`out` key="status"*
**st = > json.get value=`out` key="status"**
> print text=`st`
*path = > json.get value=`out` key="workbook"*
*ex = > fs.exists path=`path`*
**path = > json.get value=`out` key="workbook"**
**ex = > fs.exists path=`path`**
1. `ex`
> print text=workbook-ok
2. *
> print text=workbook-missing
*src = > fs.read_text path=`path`*
*parts = > split value=`src` sep="agent.agent"*
*n = > len value=`parts`*
**src = > fs.read_text path=`path`**
**parts = > split value=`src` sep="agent.agent"**
**n = > len value=`parts`**
1. `n` > 1
> print text=skeleton-ok
2. *
+46 -46
View File
@@ -8,97 +8,97 @@ import fs:lib/fs.mq.md
# main
*samples = > json.parse text={"done":"DECISION: DONE\nSUMMARY: all good\n","cont":"DECISION: CONTINUE\nPATCH:\n<<<\nFIND\nold\n===\nREPLACE\nnew\n>>>\n","zh":"决定:完成\n汇总:好了\n","run":"DECISION: RUN\n","zh_run":"决定:运行\n"}*
*d1 = > json.get value=`samples` key="done"*
*r1 = > agent.extract_plan_decision reply=`d1`*
**samples = > json.parse text={"done":"DECISION: DONE\nSUMMARY: all good\n","cont":"DECISION: CONTINUE\nPATCH:\n<<<\nFIND\nold\n===\nREPLACE\nnew\n>>>\n","zh":"决定:完成\n汇总:好了\n","run":"DECISION: RUN\n","zh_run":"决定:运行\n"}**
**d1 = > json.get value=`samples` key="done"**
**r1 = > agent.extract_plan_decision reply=`d1`**
> print text=`r1`
*s1 = > agent.extract_plan_summary reply=`d1`*
**s1 = > agent.extract_plan_summary reply=`d1`**
> print text=`s1`
*d2 = > json.get value=`samples` key="cont"*
*r2 = > agent.extract_plan_decision reply=`d2`*
**d2 = > json.get value=`samples` key="cont"**
**r2 = > agent.extract_plan_decision reply=`d2`**
> print text=`r2`
*d3 = > json.get value=`samples` key="zh"*
*r3 = > agent.extract_plan_decision reply=`d3`*
**d3 = > json.get value=`samples` key="zh"**
**r3 = > agent.extract_plan_decision reply=`d3`**
> print text=`r3`
*d4 = > json.get value=`samples` key="run"*
*r4 = > agent.extract_plan_decision reply=`d4`*
**d4 = > json.get value=`samples` key="run"**
**r4 = > agent.extract_plan_decision reply=`d4`**
> print text=`r4`
*d5 = > json.get value=`samples` key="zh_run"*
*r5 = > agent.extract_plan_decision reply=`d5`*
**d5 = > json.get value=`samples` key="zh_run"**
**r5 = > agent.extract_plan_decision reply=`d5`**
> print text=`r5`
*d6 = "DECISION: DONE\nSUMMARY: first wins\nDECISION: CONTINUE\nPATCH:\nbogus\n"*
*r6 = > agent.extract_plan_decision reply=`d6`*
**d6 = "DECISION: DONE\nSUMMARY: first wins\nDECISION: CONTINUE\nPATCH:\nbogus\n"**
**r6 = > agent.extract_plan_decision reply=`d6`**
> print text=`r6`
*act_call = "CALL:lib_catalog"*
*a1 = > agent.extract_plan_act reply=`act_call`*
*a1k = > json.get value=`a1` key="kind"*
*a1n = > json.get value=`a1` key="name"*
**act_call = "CALL:lib_catalog"**
**a1 = > agent.extract_plan_act reply=`act_call`**
**a1k = > json.get value=`a1` key="kind"**
**a1n = > json.get value=`a1` key="name"**
> print text=`a1k`
> print text=`a1n`
*act_read = "READ:stderr"*
*a2 = > agent.extract_plan_act reply=`act_read`*
*a2k = > json.get value=`a2` key="kind"*
*a2n = > json.get value=`a2` key="name"*
**act_read = "READ:stderr"**
**a2 = > agent.extract_plan_act reply=`act_read`**
**a2k = > json.get value=`a2` key="kind"**
**a2n = > json.get value=`a2` key="name"**
> print text=`a2k`
> print text=`a2n`
*act_dec = > json.get value=`samples` key="done"*
*a3 = > agent.extract_plan_act reply=`act_dec`*
*a3k = > json.get value=`a3` key="kind"*
**act_dec = > json.get value=`samples` key="done"**
**a3 = > agent.extract_plan_act reply=`act_dec`**
**a3k = > json.get value=`a3` key="kind"**
> print text=`a3k`
*cat = > agent.lib_catalog*
*files = > json.get value=`cat` key="files"*
*nf = > len value=`files`*
**cat = > agent.lib_catalog**
**files = > json.get value=`cat` key="files"**
**nf = > len value=`files`**
1. `nf` > 5
> print text=catalog-ok
2. *
> print text=catalog-bad
*dual = > agent.render_workbook_skeleton goal="demo" skeleton="dual"*
*has_r = > split value=`dual` sep="research"*
*n_r = > len value=`has_r`*
**dual = > agent.render_workbook_skeleton goal="demo" skeleton="dual"**
**has_r = > split value=`dual` sep="research"**
**n_r = > len value=`has_r`**
1. `n_r` > 1
> print text=dual-ok
2. *
> print text=dual-missing
*has_s = > split value=`dual` sep="Solidify"*
*n_s = > len value=`has_s`*
**has_s = > split value=`dual` sep="Solidify"**
**n_s = > len value=`has_s`**
1. `n_s` > 1
> print text=solidify-ok
2. *
> print text=solidify-missing
*has_imp = > split value=`dual` sep="import llm:ext/ai/llm.mq.md"*
*n_imp = > len value=`has_imp`*
**has_imp = > split value=`dual` sep="import llm:ext/ai/llm.mq.md"**
**n_imp = > len value=`has_imp`**
1. `n_imp` > 1
> print text=import-ok
2. *
> print text=import-missing
*paths = > json.parse text={"p":".marqdo/agent-runs/decision-patch.md","t":"keep old keep","fence":"alpha beta","p2":".marqdo/agent-runs/decision-fence.md"}*
*path = > json.get value=`paths` key="p"*
*seed = > json.get value=`paths` key="t"*
**paths = > json.parse text={"p":".marqdo/agent-runs/decision-patch.md","t":"keep old keep","fence":"alpha beta","p2":".marqdo/agent-runs/decision-fence.md"}**
**path = > json.get value=`paths` key="p"**
**seed = > json.get value=`paths` key="t"**
> fs.write_text path=`path` text=`seed`
*n = > fs.apply_patch_blocks path=`path` text=`d2`*
**n = > fs.apply_patch_blocks path=`path` text=`d2`**
> print text=`n`
*out = > fs.read_text path=`path`*
**out = > fs.read_text path=`path`**
> print text=`out`
*path2 = > json.get value=`paths` key="p2"*
*seed2 = > json.get value=`paths` key="fence"*
**path2 = > json.get value=`paths` key="p2"**
**seed2 = > json.get value=`paths` key="fence"**
> fs.write_text path=`path2` text=`seed2`
*fence_pack = > json.parse text={"t":"DECISION: CONTINUE\n\u0060\u0060\u0060find\nalpha\n\u0060\u0060\u0060\n\u0060\u0060\u0060replace\nALPHA\n\u0060\u0060\u0060\n"}*
*fence_reply = > json.get value=`fence_pack` key="t"*
*n2 = > fs.apply_patch_blocks path=`path2` text=`fence_reply`*
**fence_pack = > json.parse text={"t":"DECISION: CONTINUE\n\u0060\u0060\u0060find\nalpha\n\u0060\u0060\u0060\n\u0060\u0060\u0060replace\nALPHA\n\u0060\u0060\u0060\n"}**
**fence_reply = > json.get value=`fence_pack` key="t"**
**n2 = > fs.apply_patch_blocks path=`path2` text=`fence_reply`**
> print text=`n2`
*out2 = > fs.read_text path=`path2`*
**out2 = > fs.read_text path=`path2`**
> print text=`out2`
+12 -12
View File
@@ -11,33 +11,33 @@ import fs:lib/fs.mq.md
> llm.load_env path=.env
*model = > llm.llm*
*tools = > json.parse text=[]*
*助手 = > agent.agent model=`model` tools=`tools` standing="You are a Marqdo agent-development master. Prefer DONE when the workbook already satisfies the goal."*
**model = > llm.llm**
**tools = > json.parse text=[]**
**助手 = > agent.agent model=`model` tools=`tools` standing="You are a Marqdo agent-development master. Prefer DONE when the workbook already satisfies the goal."**
*out = > `助手`.plan goal="Reply with exactly the word pong and nothing else." max_rounds=3 writeback=False*
**out = > `助手`.plan goal="Reply with exactly the word pong and nothing else." max_rounds=3 writeback=False**
*st = > json.get value=`out` key="status"*
**st = > json.get value=`out` key="status"**
> print text=`st`
*sum = > json.get value=`out` key="summary"*
**sum = > json.get value=`out` key="summary"**
1. `sum`
> print text=`sum`
2. *
> print text=no-summary
*cache = > json.get value=`out` key="cache"*
**cache = > json.get value=`out` key="cache"**
> print text=`cache`
*path = > json.get value=`out` key="workbook"*
*ex = > fs.exists path=`path`*
**path = > json.get value=`out` key="workbook"**
**ex = > fs.exists path=`path`**
1. `ex`
> print text=workbook-ok
2. *
> print text=workbook-missing
*out2 = > `助手`.plan goal="Reply with exactly the word pong and nothing else." max_rounds=3 writeback=False*
*st2 = > json.get value=`out2` key="status"*
**out2 = > `助手`.plan goal="Reply with exactly the word pong and nothing else." max_rounds=3 writeback=False**
**st2 = > json.get value=`out2` key="status"**
> print text=`st2`
*cache2 = > json.get value=`out2` key="cache"*
**cache2 = > json.get value=`out2` key="cache"**
> print text=`cache2`
+12 -12
View File
@@ -7,30 +7,30 @@ import fs:lib/fs.mq.md
# main
*paths = > json.parse text={"p":".marqdo/agent-runs/observe-fixture.mq.md"}*
*path = > json.get value=`paths` key="p"*
*seed = > json.parse text={"t":"---\ntitle: fixture\n---\n\n# main\n\n<!-- marqdo-out ok\nHUGE_BODY_SHOULD_BE_STRIPPED\n-->\n\n*msg = \"ok\"*\n\n**msg**\n"}*
*text = > json.get value=`seed` key="t"*
**paths = > json.parse text={"p":".marqdo/agent-runs/observe-fixture.mq.md"}**
**path = > json.get value=`paths` key="p"**
**seed = > json.parse text={"t":"---\ntitle: fixture\n---\n\n# main\n\n<!-- marqdo-out ok\nHUGE_BODY_SHOULD_BE_STRIPPED\n-->\n\n**msg = \"ok\"**\n\n*msg*\n"}**
**text = > json.get value=`seed` key="t"**
> fs.write_text path=`path` text=`text`
*obs = > agent.inspect_workbook path=`path` exit_code=0 value="ok"*
*compact = > agent.compact_plan_observation observation=`obs`*
*ex = > json.get value=`compact` key="source_excerpt"*
*parts = > split value=`ex` sep="HUGE_BODY"*
*n = > len value=`parts`*
**obs = > agent.inspect_workbook path=`path` exit_code=0 value="ok"**
**compact = > agent.compact_plan_observation observation=`obs`**
**ex = > json.get value=`compact` key="source_excerpt"**
**parts = > split value=`ex` sep="HUGE_BODY"**
**n = > len value=`parts`**
1. `n` == 1
> print text=excerpt-stripped
2. *
> print text=excerpt-leak
*has = > json.get value=`compact` key="has_value"*
**has = > json.get value=`compact` key="has_value"**
1. `has`
> print text=has-value-ok
2. *
> print text=has-value-bad
*deep = > agent.plan_read_deepen observation=`obs` kind="source" path=`path`*
*ex2 = > json.get value=`deep` key="source_excerpt"*
**deep = > agent.plan_read_deepen observation=`obs` kind="source" path=`path`**
**ex2 = > json.get value=`deep` key="source_excerpt"**
1. `ex2`
> print text=read-source-ok
2. *
+33 -33
View File
@@ -9,63 +9,63 @@ import fs:lib/fs.mq.md
# main
*events = > json.parse text=[]*
*events = > agent.plan_append_round events=`events` round=1 workbook="wb.mq.md" exit_code=0 stream=True*
*from = > json.parse text=[{"type":"delta","text":"Hi"},{"type":"done","result":"Hi"}]*
*events = > agent.plan_merge_deltas events=`events` from=`from` stream=True*
*events = > agent.plan_append_decision events=`events` decision="DONE" stream=True summary="ok"*
*out = > json.parse text={"status":"ok"}*
*out = > agent.plan_finish_stream out=`out` events=`events` stream=True result="child"*
**events = > json.parse text=[]**
**events = > agent.plan_append_round events=`events` round=1 workbook="wb.mq.md" exit_code=0 stream=True**
**from = > json.parse text=[{"type":"delta","text":"Hi"},{"type":"done","result":"Hi"}]**
**events = > agent.plan_merge_deltas events=`events` from=`from` stream=True**
**events = > agent.plan_append_decision events=`events` decision="DONE" stream=True summary="ok"**
**out = > json.parse text={"status":"ok"}**
**out = > agent.plan_finish_stream out=`out` events=`events` stream=True result="child"**
*evs = > json.get value=`out` key="events"*
*n = > len value=`evs`*
**evs = > json.get value=`out` key="events"**
**n = > len value=`evs`**
> print text=`n`
*e0 = > at value=`evs` index=0*
*t0 = > json.get value=`e0` key="type"*
**e0 = > at value=`evs` index=0**
**t0 = > json.get value=`e0` key="type"**
> print text=`t0`
*e1 = > at value=`evs` index=1*
*t1 = > json.get value=`e1` key="type"*
*x1 = > json.get value=`e1` key="text"*
**e1 = > at value=`evs` index=1**
**t1 = > json.get value=`e1` key="type"**
**x1 = > json.get value=`e1` key="text"**
> print text=`t1`
> print text=`x1`
*e2 = > at value=`evs` index=2*
*t2 = > json.get value=`e2` key="type"*
**e2 = > at value=`evs` index=2**
**t2 = > json.get value=`e2` key="type"**
> print text=`t2`
*e3 = > at value=`evs` index=3*
*t3 = > json.get value=`e3` key="type"*
*r3 = > json.get value=`e3` key="result"*
**e3 = > at value=`evs` index=3**
**t3 = > json.get value=`e3` key="type"**
**r3 = > json.get value=`e3` key="result"**
> print text=`t3`
> print text=`r3`
> llm.load_env path=.env
*model = > llm.llm*
*tools = > json.parse text=[]*
*助手 = > agent.agent model=`model` tools=`tools` standing="offline plan stream"*
**model = > llm.llm**
**tools = > json.parse text=[]**
**助手 = > agent.agent model=`model` tools=`tools` standing="offline plan stream"**
*pout = > `助手`.plan goal="say hi" confirm=True workbook_dir=".marqdo/agent-runs" writeback=False stream=True*
**pout = > `助手`.plan goal="say hi" confirm=True workbook_dir=".marqdo/agent-runs" writeback=False stream=True**
*st = > json.get value=`pout` key="status"*
**st = > json.get value=`pout` key="status"**
> print text=`st`
*pevs = > json.get value=`pout` key="events"*
*pn = > len value=`pevs`*
**pevs = > json.get value=`pout` key="events"**
**pn = > len value=`pevs`**
> print text=`pn`
*plast = > at value=`pevs` index=0*
*pt = > json.get value=`plast` key="type"*
**plast = > at value=`pevs` index=0**
**pt = > json.get value=`plast` key="type"**
> print text=`pt`
*aev = > agent.plan_echo_await round=2 workbook="wb.mq.md" stream=True*
*at = > json.get value=`aev` key="type"*
**aev = > agent.plan_echo_await round=2 workbook="wb.mq.md" stream=True**
**at = > json.get value=`aev` key="type"**
> print text=`at`
*ar = > json.get value=`aev` key="round"*
**ar = > json.get value=`aev` key="round"**
> print text=`ar`
*dev = > agent.plan_echo_decompose workbook="wb.mq.md" stream=True*
*dt = > json.get value=`dev` key="type"*
**dev = > agent.plan_echo_decompose workbook="wb.mq.md" stream=True**
**dt = > json.get value=`dev` key="type"**
> print text=`dt`
+14 -14
View File
@@ -10,46 +10,46 @@ import agent:ext/ai/agent.mq.md
## 获取时间
*u = > time.now_unix*
*s = > time.format unix=`u` pattern="%Y-%m-%d"*
**s**
**u = > time.now_unix**
**s = > time.format unix=`u` pattern="%Y-%m-%d"**
*s*
# main
> llm.load_env path="../../.env"
*模型 = > llm.llm*
**模型 = > 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."*
**助手 = > 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="请调用获取时间工具,然后用一句话告诉用户今天的日期。"*
**out = > `助手`.step task="请调用获取时间工具,然后用一句话告诉用户今天的日期。"**
<!-- marqdo-out ok
{"decision":"CALL:获取时间","result":"今天是2026年8月7日。","status":"ok","task":"请调用获取时间工具,然后用一句话告诉用户今天的日期。","tool":"获取时间","tool_result":"\"2026-08-07\""}
-->
*status = > json.get value=`out` key="status"*
*回复 = > json.get value=`out` key="result"*
**status = > json.get value=`out` key="status"**
**回复 = > json.get value=`out` key="result"**
> print text=`回复`
*cached = > writeback.get key="ok"*
**cached = > writeback.get key="ok"**
1. `cached`
> print text=writeback-ok
2. *
> print text=writeback-missing
*id = > json.get value=`助手` key="id"*
*历史 = > agent_history_get id=`id`*
*条数 = > len value=`历史`*
**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`*
**历史2 = > agent_history_get id=`id`**
**条数2 = > len value=`历史2`**
> print text=`条数2`
+28 -28
View File
@@ -8,8 +8,8 @@ import agent:ext/ai/agent.mq.md
## 获取时间
*esc = > json.parse text={"v":"ok-time"}*
**> json.get value=`esc` key="v"**
**esc = > json.parse text={"v":"ok-time"}**
*> json.get value=`esc` key="v"*
# main
@@ -20,68 +20,68 @@ import agent:ext/ai/agent.mq.md
|------|
| 获取时间 |
*模型 = > llm.llm*
*助手 = > agent.agent model=`模型` tools=`工具表` standing="you are a readable Marqdo agent"*
**模型 = > llm.llm**
**助手 = > agent.agent model=`模型` tools=`工具表` standing="you are a readable Marqdo agent"**
*id = > json.get value=`助手` key="id"*
**id = > json.get value=`助手` key="id"**
*ctx = > agent.build_step_context agent=`助手` task="probe"*
**ctx = > agent.build_step_context agent=`助手` task="probe"**
*has_skill = > split value=`ctx` sep="Marqdo"*
*sk_n = > len value=`has_skill`*
**has_skill = > split value=`ctx` sep="Marqdo"**
**sk_n = > len value=`has_skill`**
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`*
**has_tools = > split value=`ctx` sep="获取时间"**
**tool_n = > len value=`has_tools`**
1. `tool_n` > 1
> print text=tools-ok
2. *
> print text=tools-missing
*has_src = > split value=`ctx` sep="probe"*
*src_n = > len value=`has_src`*
**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
*has_act = > split value=`ctx` sep="CALL:"*
*act_n = > len value=`has_act`*
**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
*samples = > json.parse text={"r":"CALL:获取时间","m":"think\nCALL:获取时间"}*
*raw1 = > json.get value=`samples` key="r"*
*name1 = > agent.extract_tool_name reply=`raw1`*
**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`*
**raw2 = > json.get value=`samples` key="m"**
**name2 = > agent.extract_tool_name reply=`raw2`**
> print text=`name2`
*tool_out = > agent.run_tool tools=`工具表` name="获取时间"*
**tool_out = > agent.run_tool tools=`工具表` name="获取时间"**
> print text=`tool_out`
*turn = > json.parse text={"role":"user","content":"one"}*
**turn = > json.parse text={"role":"user","content":"one"}**
> agent_history_append id=`id` item=`turn`
*turn2 = > json.parse text={"role":"assistant","content":"two"}*
**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`*
**h1 = > agent_history_get id=`id`**
**n1 = > len value=`h1`**
> print text=`n1`
> `助手`.clear_history
*h2 = > agent_history_get id=`id`*
*n2 = > len value=`h2`*
**h2 = > agent_history_get id=`id`**
**n2 = > len value=`h2`**
> print text=`n2`
*site = > agent_call_site*
*fn = > json.get value=`site` key="function"*
**site = > agent_call_site**
**fn = > json.get value=`site` key="function"**
> print text=`fn`
+13 -13
View File
@@ -7,27 +7,27 @@ import json:lib/json.mq.md
# main
*samples = > json.parse text={"reuse":"DECISION: REUSE\nSLUG: trip-plan\n","new":"DECISION: NEW\n","zh":"决定:复用\n标识:行程-a\n"}*
*r1 = > json.get value=`samples` key="reuse"*
*d1 = > agent.extract_plan_decision reply=`r1`*
**samples = > json.parse text={"reuse":"DECISION: REUSE\nSLUG: trip-plan\n","new":"DECISION: NEW\n","zh":"决定:复用\n标识:行程-a\n"}**
**r1 = > json.get value=`samples` key="reuse"**
**d1 = > agent.extract_plan_decision reply=`r1`**
> print text=`d1`
*s1 = > agent.extract_soft_match_slug reply=`r1`*
**s1 = > agent.extract_soft_match_slug reply=`r1`**
> print text=`s1`
*r2 = > json.get value=`samples` key="new"*
*d2 = > agent.extract_plan_decision reply=`r2`*
**r2 = > json.get value=`samples` key="new"**
**d2 = > agent.extract_plan_decision reply=`r2`**
> print text=`d2`
*r3 = > json.get value=`samples` key="zh"*
*d3 = > agent.extract_plan_decision reply=`r3`*
**r3 = > json.get value=`samples` key="zh"**
**d3 = > agent.extract_plan_decision reply=`r3`**
> print text=`d3`
*s3 = > agent.extract_soft_match_slug reply=`r3`*
**s3 = > agent.extract_soft_match_slug reply=`r3`**
> print text=`s3`
*tasks = > json.parse text=[{"slug":"a","title":"Alpha"},{"slug":"b","title":"Beta"}]*
*prompt = > agent.build_soft_match_prompt goal="demo" tasks=`tasks`*
*has = > split value=`prompt` sep="DECISION: REUSE"*
*n = > len value=`has`*
**tasks = > json.parse text=[{"slug":"a","title":"Alpha"},{"slug":"b","title":"Beta"}]**
**prompt = > agent.build_soft_match_prompt goal="demo" tasks=`tasks`**
**has = > split value=`prompt` sep="DECISION: REUSE"**
**n = > len value=`has`**
1. `n` > 1
> print text=prompt-ok
2. *
+31 -31
View File
@@ -10,52 +10,52 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
> print text=no-agent-plugin
> sys.exit code=1
*paths = > json.parse text={"root":".marqdo/agent-corpus-a4","fx":".marqdo/agent-runs/a4-mcp-fixture.json","a":".marqdo/agent-corpus-a4/refunds.md","b":".marqdo/agent-corpus-a4/shipping.md"}*
*root = > json.get value=`paths` key="root"*
*fx = > json.get value=`paths` key="fx"*
*pa = > json.get value=`paths` key="a"*
*pb = > json.get value=`paths` key="b"*
**paths = > json.parse text={"root":".marqdo/agent-corpus-a4","fx":".marqdo/agent-runs/a4-mcp-fixture.json","a":".marqdo/agent-corpus-a4/refunds.md","b":".marqdo/agent-corpus-a4/shipping.md"}**
**root = > json.get value=`paths` key="root"**
**fx = > json.get value=`paths` key="fx"**
**pa = > json.get value=`paths` key="a"**
**pb = > json.get value=`paths` key="b"**
1. > fs.exists path=`root`
> fs.remove path=`root`
2. *
*_ = 1*
**_ = 1**
> fs.make_dir path=`root`
*ba = > json.parse text={"t":"# Refund policy\n\nCustomers may request a refund within 30 days of purchase.\n"}*
*body_a = > json.get value=`ba` key="t"*
**ba = > json.parse text={"t":"# Refund policy\n\nCustomers may request a refund within 30 days of purchase.\n"}**
**body_a = > json.get value=`ba` key="t"**
> fs.write_text path=`pa` text=`body_a`
*bb = > json.parse text={"t":"# Shipping\n\nOrders ship in two business days.\n"}*
*body_b = > json.get value=`bb` key="t"*
**bb = > json.parse text={"t":"# Shipping\n\nOrders ship in two business days.\n"}**
**body_b = > json.get value=`bb` key="t"**
> fs.write_text path=`pb` text=`body_b`
*fx_body = > json.parse text={"t":"{\"note\":\"Fixture evidence only; workbook remains authority.\",\"tools\":[{\"name\":\"wiki_get\",\"description\":\"Fetch policy wiki page\"}],\"results\":{\"wiki_get\":{\"page\":\"refunds\",\"text\":\"Refunds within 30 days.\"}}}"}*
*fx_t = > json.get value=`fx_body` key="t"*
**fx_body = > json.parse text={"t":"{\"note\":\"Fixture evidence only; workbook remains authority.\",\"tools\":[{\"name\":\"wiki_get\",\"description\":\"Fetch policy wiki page\"}],\"results\":{\"wiki_get\":{\"page\":\"refunds\",\"text\":\"Refunds within 30 days.\"}}}"}**
**fx_t = > json.get value=`fx_body` key="t"**
> fs.write_text path=`fx` text=`fx_t`
*hit = > agent.corpus_search query="refund 30 days" root=`root` limit=4*
*auth = > json.get value=`hit` key="authority"*
**hit = > agent.corpus_search query="refund 30 days" root=`root` limit=4**
**auth = > json.get value=`hit` key="authority"**
1. `auth` == workbook
> print text=auth-ok
2. *
> print text=auth-bad
*cnt = > json.get value=`hit` key="count"*
**cnt = > json.get value=`hit` key="count"**
1. `cnt` > 0
> print text=corpus-hit
2. *
> print text=corpus-miss
*hits = > json.get value=`hit` key="hits"*
*hn = > len value=`hits`*
**hits = > json.get value=`hit` key="hits"**
**hn = > len value=`hits`**
1. `hn` > 0
*h0 = > at value=`hits` index=0*
*p0 = > json.get value=`h0` key="path"*
**h0 = > at value=`hits` index=0**
**p0 = > json.get value=`h0` key="path"**
1. `p0` == refunds.md
> print text=top-refunds
2. *
@@ -63,31 +63,31 @@ import sys:lib/sys.mq.md
2. *
> print text=top-empty
*listed = > agent.mcp_list_tools fixture=`fx`*
*tools = > json.get value=`listed` key="tools"*
*t0 = > at value=`tools` index=0*
*tn = > json.get value=`t0` key="name"*
**listed = > agent.mcp_list_tools fixture=`fx`**
**tools = > json.get value=`listed` key="tools"**
**t0 = > at value=`tools` index=0**
**tn = > json.get value=`t0` key="name"**
1. `tn` == wiki_get
> print text=mcp-list-ok
2. *
> print text=mcp-list-bad
*called = > agent.mcp_call name="wiki_get" fixture=`fx`*
*ok = > json.get value=`called` key="ok"*
**called = > agent.mcp_call name="wiki_get" fixture=`fx`**
**ok = > json.get value=`called` key="ok"**
1. `ok`
> print text=mcp-call-ok
2. *
> print text=mcp-call-bad
*auth2 = > json.get value=`called` key="authority"*
**auth2 = > json.get value=`called` key="authority"**
1. `auth2` == workbook
> print text=mcp-auth-ok
2. *
> print text=mcp-auth-bad
*reply = > json.parse text={"t":"CALL:corpus_search\nARGS:{\"query\":\"refund\",\"root\":\".marqdo/agent-corpus-a4\",\"limit\":3}\n"}*
*raw = > json.get value=`reply` key="t"*
*via = > agent.run_parent_tool name="corpus_search" path="." reply=`raw`*
*vc = > json.get value=`via` key="count"*
**reply = > json.parse text={"t":"CALL:corpus_search\nARGS:{\"query\":\"refund\",\"root\":\".marqdo/agent-corpus-a4\",\"limit\":3}\n"}**
**raw = > json.get value=`reply` key="t"**
**via = > agent.run_parent_tool name="corpus_search" path="." reply=`raw`**
**vc = > json.get value=`via` key="count"**
1. `vc` > 0
> print text=parent-corpus-ok
2. *
+22 -22
View File
@@ -10,56 +10,56 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="agent"*
**p = > plugin.native_path name="agent"**
1. `p`
> plugin.load path=`p`
2. *
> print text=no-agent-plugin
> sys.exit code=1
*paths = > json.parse text={"wb":".marqdo/agent-runs/a0-continue-wb.mq.md"}*
*wb = > json.get value=`paths` key="wb"*
**paths = > json.parse text={"wb":".marqdo/agent-runs/a0-continue-wb.mq.md"}**
**wb = > json.get value=`paths` key="wb"**
*seed = > json.parse text={"t":"---\ntitle: a0 workbook\n---\n\n# Goal\n\nMARK_A keep\n\n# main\n\n\u002a\u0060r\u0060 = > \u0060worker\u0060.step task=demo \u002a\n\u002a\u002a\u0060r\u0060\u002a\u002a\n"}*
*body = > json.get value=`seed` key="t"*
**seed = > json.parse text={"t":"---\ntitle: a0 workbook\n---\n\n# Goal\n\nMARK_A keep\n\n# main\n\n\u002a\u0060r\u0060 = > \u0060worker\u0060.step task=demo \u002a\n\u002a\u002a\u0060r\u0060\u002a\u002a\n"}**
**body = > json.get value=`seed` key="t"**
> fs.write_text path=`wb` text=`body`
*p1 = > json.parse text={"t":"DECISION: CONTINUE\nPATCH:\n<<<\nFIND\nMARK_A keep\n===\nREPLACE\nMARK_B keep\n>>>\n"}*
*r1 = > json.get value=`p1` key="t"*
*n1 = > fs.apply_patch_blocks path=`wb` text=`r1`*
**p1 = > json.parse text={"t":"DECISION: CONTINUE\nPATCH:\n<<<\nFIND\nMARK_A keep\n===\nREPLACE\nMARK_B keep\n>>>\n"}**
**r1 = > json.get value=`p1` key="t"**
**n1 = > fs.apply_patch_blocks path=`wb` text=`r1`**
> print text=`n1`
*p2 = > json.parse text={"t":"DECISION: CONTINUE\nPATCH:\n<<<\nFIND\nMARK_B keep\n===\nREPLACE\nMARK_C done\n>>>\n"}*
*r2 = > json.get value=`p2` key="t"*
*n2 = > fs.apply_patch_blocks path=`wb` text=`r2`*
**p2 = > json.parse text={"t":"DECISION: CONTINUE\nPATCH:\n<<<\nFIND\nMARK_B keep\n===\nREPLACE\nMARK_C done\n>>>\n"}**
**r2 = > json.get value=`p2` key="t"**
**n2 = > fs.apply_patch_blocks path=`wb` text=`r2`**
> print text=`n2`
*mid = > fs.read_text path=`wb`*
*has_c = > split value=`mid` sep="MARK_C done"*
*nc = > len value=`has_c`*
**mid = > fs.read_text path=`wb`**
**has_c = > split value=`mid` sep="MARK_C done"**
**nc = > len value=`has_c`**
1. `nc` > 1
> print text=continue-ok
2. *
> print text=continue-fail
*obs = > json.parse text={"value":"frozen-answer"}*
*sol = > agent_workbook_solidify path=`wb` observation=`obs`*
*ok = > json.get value=`sol` key="solidified"*
**obs = > json.parse text={"value":"frozen-answer"}**
**sol = > agent_workbook_solidify path=`wb` observation=`obs`**
**ok = > json.get value=`sol` key="solidified"**
1. `ok`
> print text=solidify-ok
2. *
> print text=solidify-fail
*final = > fs.read_text path=`wb`*
*still = > split value=`final` sep=".step"*
*ns = > len value=`still`*
**final = > fs.read_text path=`wb`**
**still = > split value=`final` sep=".step"**
**ns = > len value=`still`**
1. `ns` == 1
> print text=step-gone
2. *
> print text=step-still
*has_ans = > split value=`final` sep="frozen-answer"*
*na = > len value=`has_ans`*
**has_ans = > split value=`final` sep="frozen-answer"**
**na = > len value=`has_ans`**
1. `na` > 1
> print text=answer-ok
2. *
+6 -6
View File
@@ -15,27 +15,27 @@ import sys:lib/sys.mq.md
Mimic agent.step: branch on param named writeback, then persist via aliased lib import.
*out = > json.parse text={"status":"ok","note":"shadow-probe"}*
**out = > json.parse text={"status":"ok","note":"shadow-probe"}**
1. `writeback`
*body = > json.stringify value=`out`*
*st = > json.get value=`out` key="status"*
**body = > json.stringify value=`out`**
**st = > json.get value=`out` key="status"**
1. `st` == "ok"
> wb.record value=`body` key="ok"
2. *
> wb.record value=`body` key="error"
2. *
*_ = 1*
**_ = 1**
****
# main
*b = > box*
**b = > box**
> `b`.go writeback=True
<!-- marqdo-out ok
{"note":"shadow-probe","status":"ok"}
-->
*cached = > writeback.get key="ok"*
**cached = > writeback.get key="ok"**
1. `cached`
> print text=writeback-shadow-ok
2. *
+8 -8
View File
@@ -6,18 +6,18 @@ import json:lib/json.mq.md
# main
*paths = > json.parse text={"p":".marqdo/agent-runs/patch-demo.md","t":"alpha beta gamma"}*
*path = > json.get value=`paths` key="p"*
*seed = > json.get value=`paths` key="t"*
**paths = > json.parse text={"p":".marqdo/agent-runs/patch-demo.md","t":"alpha beta gamma"}**
**path = > json.get value=`paths` key="p"**
**seed = > json.get value=`paths` key="t"**
> fs.write_text path=`path` text=`seed`
> fs.text_patch path=`path` find=beta replace=BETA
*s1 = > fs.read_text path=`path`*
**s1 = > fs.read_text path=`path`**
> print text=`s1`
*reply = > json.parse text={"t":"DECISION: CONTINUE\n<<<\nFIND\nalpha\n===\nREPLACE\nALPHA\n>>>\n<<<\nFIND\ngamma\n===\nREPLACE\nGAMMA\n>>>\n"}*
*t = > json.get value=`reply` key="t"*
*n = > fs.apply_patch_blocks path=`path` text=`t`*
**reply = > json.parse text={"t":"DECISION: CONTINUE\n<<<\nFIND\nalpha\n===\nREPLACE\nALPHA\n>>>\n<<<\nFIND\ngamma\n===\nREPLACE\nGAMMA\n>>>\n"}**
**t = > json.get value=`reply` key="t"**
**n = > fs.apply_patch_blocks path=`path` text=`t`**
> print text=`n`
*s2 = > fs.read_text path=`path`*
**s2 = > fs.read_text path=`path`**
> print text=`s2`
+24 -24
View File
@@ -17,46 +17,46 @@ $$
\begin{pmatrix}5\\5\end{pmatrix}
$$
*`A` = > la.from_formula formula=`A`*
*`b` = > la.from_formula formula=`b`*
*`eps` = > math.div a=1 b=1000*
**`A` = > la.from_formula formula=`A`**
**`b` = > la.from_formula formula=`b`**
**`eps` = > math.div a=1 b=1000**
*`d` = > la.det expr=`A`*
*`d0` = > math.sub a=`d` b=5*
*`d0` = > math.abs value=`d0`*
**`d` = > la.det expr=`A`**
**`d0` = > math.sub a=`d` b=5**
**`d0` = > math.abs value=`d0`**
1. `d0` < `eps`
> print text=det-ok
2. *
> print text=det-fail
*`tr` = > la.trace expr=`A`*
*`t0` = > math.sub a=`tr` b=5*
*`t0` = > math.abs value=`t0`*
**`tr` = > la.trace expr=`A`**
**`t0` = > math.sub a=`tr` b=5**
**`t0` = > math.abs value=`t0`**
1. `t0` < `eps`
> print text=trace-ok
2. *
> print text=trace-fail
*`sol` = > la.solve a=`A` b=`b`*
*`x` = sol[^x]*
*`data` = x[^data]*
*`row0` = > at value=`data` index=0*
*`x0` = > at value=`row0` index=0*
*`e0` = > math.sub a=`x0` b=2*
*`e0` = > math.abs value=`e0`*
**`sol` = > la.solve a=`A` b=`b`**
**`x` = sol[^x]**
**`data` = x[^data]**
**`row0` = > at value=`data` index=0**
**`x0` = > at value=`row0` index=0**
**`e0` = > math.sub a=`x0` b=2**
**`e0` = > math.abs value=`e0`**
1. `e0` < `eps`
> print text=solve-ok
2. *
> print text=solve-fail
*`I` = > la.eye n=2*
*`P` = > la.mul a=`A` b=`I`*
*`E` = > la.explicit expr=`P`*
*`ed` = E[^data]*
*`ed0` = > at value=`ed` index=0*
*`ed00` = > at value=`ed0` index=0*
*`ee` = > math.sub a=`ed00` b=2*
*`ee` = > math.abs value=`ee`*
**`I` = > la.eye n=2**
**`P` = > la.mul a=`A` b=`I`**
**`E` = > la.explicit expr=`P`**
**`ed` = E[^data]**
**`ed0` = > at value=`ed` index=0**
**`ed00` = > at value=`ed0` index=0**
**`ee` = > math.sub a=`ed00` b=2**
**`ee` = > math.abs value=`ee`**
1. `ee` < `eps`
> print text=explicit-ok
2. *
+11 -11
View File
@@ -6,12 +6,12 @@ import la:ext/linalg/linalg.mq.md
# main
*`A` = > la.symbol name="A" rows=2 cols=2*
*`B` = > la.symbol name="B" rows=2 cols=2*
*`Z` = > la.zeros rows=2 cols=2*
**`A` = > la.symbol name="A" rows=2 cols=2**
**`B` = > la.symbol name="B" rows=2 cols=2**
**`Z` = > la.zeros rows=2 cols=2**
*`K` = > la.kron a=`A` b=`B`*
*`kt` = > la.ascii expr=`K`*
**`K` = > la.kron a=`A` b=`B`**
**`kt` = > la.ascii expr=`K`**
> print text=`kt`
`r0` =
@@ -35,14 +35,14 @@ import la:ext/linalg/linalg.mq.md
| `r0` |
| `r1` |
*`L` = > la.block blocks=`blocks`*
*`P` = > la.mul a=`L` b=`L`*
*`C` = > la.collapse expr=`P`*
*`ct` = > la.ascii expr=`C`*
**`L` = > la.block blocks=`blocks`**
**`P` = > la.mul a=`L` b=`L`**
**`C` = > la.collapse expr=`P`**
**`ct` = > la.ascii expr=`C`**
> print text=`ct`
*`ping` = > la.ping*
*`ok` = ping[^ok]*
**`ping` = > la.ping**
**`ok` = ping[^ok]**
1. `ok`
> print text=ping-ok
2. *
+11 -11
View File
@@ -10,10 +10,10 @@ Narration: \((AB)^\top = B^\top A^\top\). The identity is checked by running thi
# main
*`A` = > la.symbol name="A" rows=2 cols=3*
*`B` = > la.symbol name="B" rows=3 cols=2*
*`P` = `A` * `B`*
*`t` = > `P`.T_ascii*
**`A` = > la.symbol name="A" rows=2 cols=3**
**`B` = > la.symbol name="B" rows=3 cols=2**
**`P` = `A` * `B`**
**`t` = > `P`.T_ascii**
> print text=`t`
1. `t` == "B^T*A^T"
> print text=identity-ok
@@ -27,18 +27,18 @@ Narration: \((AB)^\top = B^\top A^\top\). The identity is checked by running thi
| 1 | X | 2 | 2 |
| 2 | Y | 2 | 2 |
*`env` = > la.declare table=`shapes`*
*`X` = env[^X]*
*`Y` = env[^Y]*
*`S` = `X` + `Y`*
*`st` = > la.ascii expr=`S`*
**`env` = > la.declare table=`shapes`**
**`X` = env[^X]**
**`Y` = env[^Y]**
**`S` = `X` + `Y`**
**`st` = > la.ascii expr=`S`**
1. `st` == "X + Y"
> print text=declare-ok
2. *
> print text=declare-fail
*`Pt` = > `P`.T*
*`raw` = > la.ascii expr=`Pt` raw=True*
**`Pt` = > `P`.T**
**`raw` = > la.ascii expr=`Pt` raw=True**
1. `raw` == "(A*B)^T"
> print text=raw-ok
2. *
+25 -25
View File
@@ -12,35 +12,35 @@ $$
\begin{bmatrix}2&0\\0&3\end{bmatrix}
$$
*`M` = > la.from_formula formula=`M`*
*`eps` = > math.div a=1 b=1000*
**`M` = > la.from_formula formula=`M`**
**`eps` = > math.div a=1 b=1000**
*`f` = > la.factorize matrix=`M` kind="eig"*
*`kind` = f[^kind]*
**`f` = > la.factorize matrix=`M` kind="eig"**
**`kind` = f[^kind]**
1. `kind` == eig
> print text=eig-kind-ok
2. *
> print text=eig-kind-fail
*`evals` = f[^eigenvalues]*
*`ev0` = > at value=`evals` index=0*
*`e0` = > math.sub a=`ev0` b=3*
*`e0` = > math.abs value=`e0`*
**`evals` = f[^eigenvalues]**
**`ev0` = > at value=`evals` index=0**
**`e0` = > math.sub a=`ev0` b=3**
**`e0` = > math.abs value=`e0`**
1. `e0` < `eps`
> print text=eig-val-ok
2. *
> print text=eig-val-fail
*`img` = > la.draw factor=`f` kind="eig" path="linalg-factor-eig.svg"*
*`ik` = img[^kind]*
**`img` = > la.draw factor=`f` kind="eig" path="linalg-factor-eig.svg"**
**`ik` = img[^kind]**
1. `ik` == eig
> print text=draw-kind-ok
2. *
> print text=draw-kind-fail
*`svg` = img[^svg]*
*`parts` = > split value=`svg` sep="data-linalg=\"eig\""*
*`pn` = > len value=`parts`*
**`svg` = img[^svg]**
**`parts` = > split value=`svg` sep="data-linalg=\"eig\""**
**`pn` = > len value=`parts`**
1. `pn` > 1
> print text=draw-mark-ok
2. *
@@ -56,23 +56,23 @@ $$
\begin{pmatrix}5\\5\end{pmatrix}
$$
*`A` = > la.from_formula formula=`A`*
*`b` = > la.from_formula formula=`b`*
*`lu` = > la.factorize matrix=`A` kind="lu"*
*`sol` = > la.solve factor=`lu` b=`b`*
*`x` = sol[^x]*
*`data` = x[^data]*
*`row0` = > at value=`data` index=0*
*`x0` = > at value=`row0` index=0*
*`xe` = > math.sub a=`x0` b=2*
*`xe` = > math.abs value=`xe`*
**`A` = > la.from_formula formula=`A`**
**`b` = > la.from_formula formula=`b`**
**`lu` = > la.factorize matrix=`A` kind="lu"**
**`sol` = > la.solve factor=`lu` b=`b`**
**`x` = sol[^x]**
**`data` = x[^data]**
**`row0` = > at value=`data` index=0**
**`x0` = > at value=`row0` index=0**
**`xe` = > math.sub a=`x0` b=2**
**`xe` = > math.abs value=`xe`**
1. `xe` < `eps`
> print text=lu-solve-ok
2. *
> print text=lu-solve-fail
*`svd` = > la.factorize matrix=`M` kind="svd"*
*`sk` = svd[^ascii]*
**`svd` = > la.factorize matrix=`M` kind="svd"**
**`sk` = svd[^ascii]**
1. `sk` == SVD
> print text=svd-ok
2. *
+8 -8
View File
@@ -6,16 +6,16 @@ import la:ext/linalg/linalg.mq.md
# main
*`A` = > la.symbol name="A" rows=2 cols=3*
*`B` = > la.symbol name="B" rows=3 cols=2*
*`P` = > la.mul a=`A` b=`B`*
*`T` = > la.transpose expr=`P`*
*`S` = > la.simplify expr=`T`*
*`txt` = > la.ascii expr=`S`*
**`A` = > la.symbol name="A" rows=2 cols=3**
**`B` = > la.symbol name="B" rows=3 cols=2**
**`P` = > la.mul a=`A` b=`B`**
**`T` = > la.transpose expr=`P`**
**`S` = > la.simplify expr=`T`**
**`txt` = > la.ascii expr=`S`**
> print text=`txt`
*`ping` = > la.ping*
*`ok` = ping[^ok]*
**`ping` = > la.ping**
**`ok` = ping[^ok]**
1. `ok`
> print text=ping-ok
2. *
+14 -14
View File
@@ -6,18 +6,18 @@ import la:ext/linalg/linalg.mq.md
# main
*`A` = > la.symbol name="A" rows=2 cols=2*
*`B` = > la.symbol name="B" rows=2 cols=2*
*`C` = `A` + `B`*
*`ct` = > la.ascii expr=`C`*
**`A` = > la.symbol name="A" rows=2 cols=2**
**`B` = > la.symbol name="B" rows=2 cols=2**
**`C` = `A` + `B`**
**`ct` = > la.ascii expr=`C`**
> print text=`ct`
*`P` = `A` * `B`*
*`Pt` = > `P`.T*
*`st` = > `Pt`.ascii*
**`P` = `A` * `B`**
**`Pt` = > `P`.T**
**`st` = > `Pt`.ascii**
> print text=`st`
*`ty` = C[^_type]*
**`ty` = C[^_type]**
1. `ty` == matrix
> print text=type-ok
2. *
@@ -33,12 +33,12 @@ $$
\begin{bmatrix}2&0\\0&3\end{bmatrix}
$$
*`S` = `M` + `N`*
*`Se` = > la.explicit expr=`S`*
*`d` = Se[^data]*
*`r0` = > at value=`d` index=0*
*`x00` = > at value=`r0` index=0*
*`xs` = > str value=`x00`*
**`S` = `M` + `N`**
**`Se` = > la.explicit expr=`S`**
**`d` = Se[^data]**
**`r0` = > at value=`d` index=0**
**`x00` = > at value=`r0` index=0**
**`xs` = > str value=`x00`**
1. `xs` == "3"
> print text=formula-add-ok
2. *
+30 -30
View File
@@ -18,25 +18,25 @@ $$
\begin{pmatrix}1\\2\\2\end{pmatrix}
$$
*`A` = > la.from_formula formula=`A`*
*`b` = > la.from_formula formula=`b`*
*`eps` = > math.div a=1 b=1000*
**`A` = > la.from_formula formula=`A`**
**`b` = > la.from_formula formula=`b`**
**`eps` = > math.div a=1 b=1000**
*`ls` = > la.lstsq a=`A` b=`b`*
*`x` = ls[^x]*
*`xd` = x[^data]*
*`r0` = > at value=`xd` index=0*
*`x0` = > at value=`r0` index=0*
*`e0` = > math.sub a=`x0` b=1.1666666667*
*`e0` = > math.abs value=`e0`*
**`ls` = > la.lstsq a=`A` b=`b`**
**`x` = ls[^x]**
**`xd` = x[^data]**
**`r0` = > at value=`xd` index=0**
**`x0` = > at value=`r0` index=0**
**`e0` = > math.sub a=`x0` b=1.1666666667**
**`e0` = > math.abs value=`e0`**
1. `e0` < `eps`
> print text=lstsq-ok
2. *
> print text=lstsq-fail
*`nf` = > la.norm expr=`A` ord="fro"*
*`n0` = > math.sub a=`nf` b=2.8284271247*
*`n0` = > math.abs value=`n0`*
**`nf` = > la.norm expr=`A` ord="fro"**
**`n0` = > math.sub a=`nf` b=2.8284271247**
**`n0` = > math.abs value=`n0`**
1. `n0` < `eps`
> print text=norm-ok
2. *
@@ -47,48 +47,48 @@ $$
\begin{bmatrix}2&0\\0&1\end{bmatrix}
$$
*`D` = > la.from_formula formula=`D`*
*`c` = > la.cond expr=`D`*
*`cv` = c[^value]*
*`ce` = > math.sub a=`cv` b=2*
*`ce` = > math.abs value=`ce`*
**`D` = > la.from_formula formula=`D`**
**`c` = > la.cond expr=`D`**
**`cv` = c[^value]**
**`ce` = > math.sub a=`cv` b=2**
**`ce` = > math.abs value=`ce`**
1. `ce` < `eps`
> print text=cond-ok
2. *
> print text=cond-fail
*`rk` = > la.rank expr=`D`*
**`rk` = > la.rank expr=`D`**
1. `rk` == 2
> print text=rank-ok
2. *
> print text=rank-fail
*`raw` = > json.parse text="[[[0,1],[1,0]],[[1,0],[0,-1]]]"*
*`Z` = > la.from_list data=`raw`*
*`dt` = Z[^dtype]*
**`raw` = > json.parse text="[[[0,1],[1,0]],[[1,0],[0,-1]]]"**
**`Z` = > la.from_list data=`raw`**
**`dt` = Z[^dtype]**
1. `dt` == complex
> print text=complex-dtype-ok
2. *
> print text=complex-dtype-fail
*`zn` = > la.norm expr=`Z` ord="fro"*
*`ze` = > math.sub a=`zn` b=2*
*`ze` = > math.abs value=`ze`*
**`zn` = > la.norm expr=`Z` ord="fro"**
**`ze` = > math.sub a=`zn` b=2**
**`ze` = > math.abs value=`ze`**
1. `ze` < `eps`
> print text=complex-norm-ok
2. *
> print text=complex-norm-fail
*`img` = > la.draw factor=`D` kind="heatmap" theme="dark" path="linalg-metrics-heat.svg"*
*`th` = img[^theme]*
**`img` = > la.draw factor=`D` kind="heatmap" theme="dark" path="linalg-metrics-heat.svg"**
**`th` = img[^theme]**
1. `th` == dark
> print text=theme-ok
2. *
> print text=theme-fail
*`svg` = img[^svg]*
*`parts` = > split value=`svg` sep="data-theme=\"dark\""*
*`pn` = > len value=`parts`*
**`svg` = img[^svg]**
**`parts` = > split value=`svg` sep="data-theme=\"dark\""**
**`pn` = > len value=`parts`**
1. `pn` > 1
> print text=theme-mark-ok
2. *
+8 -8
View File
@@ -6,16 +6,16 @@ import la:ext/linalg/线性代数.mq.md
# main
*`A` = > la.符号 名="A" 行=2 列=3*
*`B` = > la.符号 名="B" 行=3 列=2*
*`P` = > la.乘 左=`A` 右=`B`*
*`T` = > la.转置 式=`P`*
*`S` = > la.化简 式=`T`*
*`txt` = > la.文本 式=`S`*
**`A` = > la.符号 名="A" 行=2 列=3**
**`B` = > la.符号 名="B" 行=3 列=2**
**`P` = > la.乘 左=`A` 右=`B`**
**`T` = > la.转置 式=`P`**
**`S` = > la.化简 式=`T`**
**`txt` = > la.文本 式=`S`**
> 打印 内容=`txt`
*`ping` = > la.探测*
*`ok` = ping[^ok]*
**`ping` = > la.探测**
**`ok` = ping[^ok]**
1. `ok`
> 打印 内容=探测-ok
2. *
+2 -2
View File
@@ -8,8 +8,8 @@ import llm:ext/ai/llm.mq.md
> llm.load_env path=.env
*model = > llm.llm*
**model = > llm.llm**
*reply = > `model`.complete prompt="Reply with exactly one English word: pong"*
**reply = > `model`.complete prompt="Reply with exactly one English word: pong"**
> print text=`reply`
+1 -1
View File
@@ -6,6 +6,6 @@ import llm:ext/ai/llm.mq.md
# main
*model = > llm.llm*
**model = > llm.llm**
> print text=`model`[^model]
> print text=`model`[^suffix]
+4 -4
View File
@@ -9,11 +9,11 @@ import json:lib/json.mq.md
> llm.load_env path=.env
*model = > llm.llm*
**model = > llm.llm**
*events = > `model`.complete prompt="Reply with exactly one English word: pong" stream=True echo=True*
*n = > len value=`events`*
**events = > `model`.complete prompt="Reply with exactly one English word: pong" stream=True echo=True**
**n = > len value=`events`**
> print text=`n`
*answer = > llm.stream_result events=`events`*
**answer = > llm.stream_result events=`events`**
> print text=`answer`
+3 -3
View File
@@ -7,8 +7,8 @@ import net:lib/net.mq.md
# main
*fixture = "data: {\"choices\":[{\"delta\":{\"content\":\"Hi\"}}]}\n\ndata: {\"choices\":[{\"delta\":{\"content\":\"!\"}}]}\n\ndata: [DONE]\n"*
**fixture = "data: {\"choices\":[{\"delta\":{\"content\":\"Hi\"}}]}\n\ndata: {\"choices\":[{\"delta\":{\"content\":\"!\"}}]}\n\ndata: [DONE]\n"**
*events = > net.openai_sse_parse text=`fixture`*
*answer = > llm.stream_result events=`events`*
**events = > net.openai_sse_parse text=`fixture`**
**answer = > llm.stream_result events=`events`**
> print text=`answer`
+5 -5
View File
@@ -6,11 +6,11 @@ import quantum:ext/quantum/quantum.mq.md
# main
*qc = > quantum.circuit qubits=1*
*qc = > `qc`.x qubit=0*
*qc = > `qc`.noise kind="amplitude_damping" p=1*
*r = > `qc`.run shots=32 seed=7*
*c0 = r[^counts][^0]*
**qc = > quantum.circuit qubits=1**
**qc = > `qc`.x qubit=0**
**qc = > `qc`.noise kind="amplitude_damping" p=1**
**r = > `qc`.run shots=32 seed=7**
**c0 = r[^counts][^0]**
1. `c0` == 32
> print text=amp-ok
+5 -5
View File
@@ -6,11 +6,11 @@ description: 泡利X 后 振幅阻尼 p=1 全部落回 |0⟩.
# main
*qc = > 量子.电路 比特数=1*
*qc = > `qc`.泡利X 比特=0*
*qc = > `qc`.噪声 种类="振幅阻尼" 概率=1*
*r = > `qc`.运行 次数=32 种子=7*
*c0 = r[^counts][^0]*
**qc = > 量子.电路 比特数=1**
**qc = > `qc`.泡利X 比特=0**
**qc = > `qc`.噪声 种类="振幅阻尼" 概率=1**
**r = > `qc`.运行 次数=32 种子=7**
**c0 = r[^counts][^0]**
1. `c0` == 32
> print text=amp-ok
+14 -14
View File
@@ -6,31 +6,31 @@ import quantum:ext/quantum/quantum.mq.md
# main
*qc = > quantum.circuit qubits=2*
*qc = > `qc`.h qubit=0*
*qc = > `qc`.barrier*
*qc = > `qc`.cx control=0 target=1*
*qc = > `qc`.measure*
**qc = > quantum.circuit qubits=2**
**qc = > `qc`.h qubit=0**
**qc = > `qc`.barrier**
**qc = > `qc`.cx control=0 target=1**
**qc = > `qc`.measure**
*st = > `qc`.state*
*dim = st[^dim]*
**st = > `qc`.state**
**dim = st[^dim]**
1. `dim` == 4
> print text=state-ok
2. *
> print text=state-fail
*img = > `qc`.draw path="quantum-author-draw.svg"*
*kind = img[^kind]*
**img = > `qc`.draw path="quantum-author-draw.svg"**
**kind = img[^kind]**
1. `kind` == circuit
> print text=draw-ok
2. *
> print text=draw-fail
*other = > quantum.circuit qubits=2*
*other = > `other`.x qubit=1*
*qc2 = > `qc`.append op=`other`*
*ops = qc2[^ops]*
*n = > len `ops`*
**other = > quantum.circuit qubits=2**
**other = > `other`.x qubit=1**
**qc2 = > `qc`.append op=`other`**
**ops = qc2[^ops]**
**n = > len `ops`**
1. `n` == 5
> print text=append-ok
2. *
+14 -14
View File
@@ -6,31 +6,31 @@ description: 屏障 / 测量 / 追加 / 态 / 绘图.
# main
*qc = > 量子.电路 比特数=2*
*qc = > `qc`.哈达玛 比特=0*
*qc = > `qc`.屏障*
*qc = > `qc`.控非 控制=0 目标=1*
*qc = > `qc`.测量*
**qc = > 量子.电路 比特数=2**
**qc = > `qc`.哈达玛 比特=0**
**qc = > `qc`.屏障**
**qc = > `qc`.控非 控制=0 目标=1**
**qc = > `qc`.测量**
*st = > `qc`.态*
*dim = st[^dim]*
**st = > `qc`.态**
**dim = st[^dim]**
1. `dim` == 4
> print text=state-ok
2. *
> print text=state-fail
*img = > `qc`.绘图 路径="quantum-author-zh-draw.svg"*
*kind = img[^kind]*
**img = > `qc`.绘图 路径="quantum-author-zh-draw.svg"**
**kind = img[^kind]**
1. `kind` == circuit
> print text=draw-ok
2. *
> print text=draw-fail
*other = > 量子.电路 比特数=2*
*other = > `other`.泡利X 比特=1*
*qc2 = > `qc`.追加 操作=`other`*
*ops = qc2[^ops]*
*n = > len `ops`*
**other = > 量子.电路 比特数=2**
**other = > `other`.泡利X 比特=1**
**qc2 = > `qc`.追加 操作=`other`**
**ops = qc2[^ops]**
**n = > len `ops`**
1. `n` == 5
> print text=append-ok
2. *
+10 -10
View File
@@ -7,15 +7,15 @@ import math:lib/math.mq.md
# main
*qc = > quantum.circuit qubits=2*
*qc = > `qc`.h qubit=0*
*qc = > `qc`.cx control=0 target=1*
*p = > `qc`.probabilities*
**qc = > quantum.circuit qubits=2**
**qc = > `qc`.h qubit=0**
**qc = > `qc`.cx control=0 target=1**
**p = > `qc`.probabilities**
*p00 = p[^00]*
*p11 = p[^11]*
*lo = > math.div a=2 b=5*
*hi = > math.div a=3 b=5*
**p00 = p[^00]**
**p11 = p[^11]**
**lo = > math.div a=2 b=5**
**hi = > math.div a=3 b=5**
1. `p00` > `lo`
1. `p00` < `hi`
@@ -33,8 +33,8 @@ import math:lib/math.mq.md
2. *
> print text=p11-fail
*ping = > quantum_ping*
*ok = ping[^ok]*
**ping = > quantum_ping**
**ok = ping[^ok]**
1. `ok`
> print text=ping-ok
2. *
+7 -7
View File
@@ -12,13 +12,13 @@ $$
\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}
$$
*U = > quantum.gate matrix=`H_matrix` name="U"*
*qc = > quantum.circuit qubits=1*
*qc = > `qc`.apply gate=`U` qubits=0*
*p = > `qc`.probabilities*
*p0 = p[^0]*
*lo = > math.div a=4 b=10*
*hi = > math.div a=6 b=10*
**U = > quantum.gate matrix=`H_matrix` name="U"**
**qc = > quantum.circuit qubits=1**
**qc = > `qc`.apply gate=`U` qubits=0**
**p = > `qc`.probabilities**
**p0 = p[^0]**
**lo = > math.div a=4 b=10**
**hi = > math.div a=6 b=10**
1. `p0` > `lo`
1. `p0` < `hi`
+7 -7
View File
@@ -12,13 +12,13 @@ $$
\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}
$$
*U = > 量子.门 矩阵=`H矩阵` 名="U"*
*qc = > 量子.电路 比特数=1*
*qc = > `qc`.施加 门=`U` 比特=0*
*p = > `qc`.概率*
*p0 = p[^0]*
*lo = > math.div a=4 b=10*
*hi = > math.div a=6 b=10*
**U = > 量子.门 矩阵=`H矩阵` 名="U"**
**qc = > 量子.电路 比特数=1**
**qc = > `qc`.施加 门=`U` 比特=0**
**p = > `qc`.概率**
**p0 = p[^0]**
**lo = > math.div a=4 b=10**
**hi = > math.div a=6 b=10**
1. `p0` > `lo`
1. `p0` < `hi`
+7 -7
View File
@@ -13,19 +13,19 @@ import quantum:ext/quantum/quantum.mq.md
| 1 | H | 0 |
| 2 | CX | 0,1 |
*qc = > quantum.circuit qubits=2 steps=`steps`*
*img = > `qc`.draw kind="probs" path="quantum-draw-probs.svg"*
*kind = img[^kind]*
**qc = > quantum.circuit qubits=2 steps=`steps`**
**img = > `qc`.draw kind="probs" path="quantum-draw-probs.svg"**
**kind = img[^kind]**
1. `kind` == probs
> print text=probs-ok
2. *
> print text=probs-fail
*qc1 = > quantum.circuit qubits=1*
*qc1 = > `qc1`.h qubit=0*
*bloch = > `qc1`.draw kind="bloch" path="quantum-draw-bloch.svg"*
*bk = bloch[^kind]*
**qc1 = > quantum.circuit qubits=1**
**qc1 = > `qc1`.h qubit=0**
**bloch = > `qc1`.draw kind="bloch" path="quantum-draw-bloch.svg"**
**bk = bloch[^kind]**
1. `bk` == bloch
> print text=bloch-ok
+3 -3
View File
@@ -6,9 +6,9 @@ import quantum:ext/quantum/quantum.mq.md
# main
*H = > quantum.gate name="H"*
*img = > `H`.draw kind="matrix" path="quantum-gate-heatmap.svg"*
*kind = img[^kind]*
**H = > quantum.gate name="H"**
**img = > `H`.draw kind="matrix" path="quantum-gate-heatmap.svg"**
**kind = img[^kind]**
1. `kind` == matrix
> print text=heatmap-ok
+5 -5
View File
@@ -7,17 +7,17 @@ import json:lib/json.mq.md
# main
*H_matrix = > json.parse text=[[0.7071067811865475,0.7071067811865475],[0.7071067811865475,-0.7071067811865475]]*
*H = > quantum.gate name="H"*
*ok = > `H`.matches_matrix matrix=`H_matrix`*
**H_matrix = > json.parse text=[[0.7071067811865475,0.7071067811865475],[0.7071067811865475,-0.7071067811865475]]**
**H = > quantum.gate name="H"**
**ok = > `H`.matches_matrix matrix=`H_matrix`**
1. `ok`
> print text=match-ok
2. *
> print text=match-fail
*bad = > json.parse text=[[1,0],[0,1]]*
*no = > `H`.matches_matrix matrix=`bad`*
**bad = > json.parse text=[[1,0],[0,1]]**
**no = > `H`.matches_matrix matrix=`bad`**
1. not `no`
> print text=reject-ok
+20 -20
View File
@@ -9,13 +9,13 @@ import math:lib/math.mq.md
H-Z-H on |0⟩ → |1⟩.
*qc = > quantum.circuit qubits=1*
*qc = > `qc`.h qubit=0*
*qc = > `qc`.z qubit=0*
*qc = > `qc`.h qubit=0*
*p = > `qc`.probabilities*
*p1 = p[^1]*
*lo = > math.div a=9 b=10*
**qc = > quantum.circuit qubits=1**
**qc = > `qc`.h qubit=0**
**qc = > `qc`.z qubit=0**
**qc = > `qc`.h qubit=0**
**p = > `qc`.probabilities**
**p1 = p[^1]**
**lo = > math.div a=9 b=10**
1. `p1` > `lo`
> print text=z-sandwich-ok
@@ -24,11 +24,11 @@ H-Z-H on |0⟩ → |1⟩.
Ry(π) on |0⟩ → |1⟩.
*pi = > math.pi*
*ry = > quantum.circuit qubits=1*
*ry = > `ry`.ry qubit=0 theta=`pi`*
*rp = > `ry`.probabilities*
*rp1 = rp[^1]*
**pi = > math.pi**
**ry = > quantum.circuit qubits=1**
**ry = > `ry`.ry qubit=0 theta=`pi`**
**rp = > `ry`.probabilities**
**rp1 = rp[^1]**
1. `rp1` > `lo`
> print text=ry-ok
@@ -37,14 +37,14 @@ Ry(π) on |0⟩ → |1⟩.
Bell run with fixed seed: both 00 and 11 appear; shots sum.
*bell = > quantum.circuit qubits=2*
*bell = > `bell`.h qubit=0*
*bell = > `bell`.cx control=0 target=1*
*res = > `bell`.run shots=200 seed=42*
*counts = res[^counts]*
*c00 = counts[^00]*
*c11 = counts[^11]*
*shots = res[^shots]*
**bell = > quantum.circuit qubits=2**
**bell = > `bell`.h qubit=0**
**bell = > `bell`.cx control=0 target=1**
**res = > `bell`.run shots=200 seed=42**
**counts = res[^counts]**
**c00 = counts[^00]**
**c11 = counts[^11]**
**shots = res[^shots]**
1. `c00`
1. `c11`
+16 -16
View File
@@ -7,22 +7,22 @@ import math:lib/math.mq.md
# main
*qc = > quantum.circuit qubits=2*
*qc = > `qc`.h qubit=0*
*qc = > `qc`.cx control=0 target=1*
**qc = > quantum.circuit qubits=2**
**qc = > `qc`.h qubit=0**
**qc = > `qc`.cx control=0 target=1**
*rho = > `qc`.density*
*pur = > `rho`.purity*
*lo = > math.div a=9 b=10*
**rho = > `qc`.density**
**pur = > `rho`.purity**
**lo = > math.div a=9 b=10**
1. `pur` > `lo`
> print text=purity-ok
2. *
> print text=purity-fail
*red = > `rho`.partial_trace keep=0*
*rpur = > `red`.purity*
*half_lo = > math.div a=4 b=10*
*half_hi = > math.div a=6 b=10*
**red = > `rho`.partial_trace keep=0**
**rpur = > `red`.purity**
**half_lo = > math.div a=4 b=10**
**half_hi = > math.div a=6 b=10**
1. `rpur` > `half_lo`
1. `rpur` < `half_hi`
> print text=reduce-ok
@@ -31,17 +31,17 @@ import math:lib/math.mq.md
2. *
> print text=reduce-fail
*zz = "ZZ"*
*ezz = > `qc`.expect obs=`zz`*
*zzi = > math.div a=9 b=10*
**zz = "ZZ"**
**ezz = > `qc`.expect obs=`zz`**
**zzi = > math.div a=9 b=10**
1. `ezz` > `zzi`
> print text=expect-ok
2. *
> print text=expect-fail
*sch = > `qc`.schmidt cut=1*
*ent = sch[^entropy]*
*elo = > math.div a=1 b=2*
**sch = > `qc`.schmidt cut=1**
**ent = sch[^entropy]**
**elo = > math.div a=1 b=2**
1. `ent` > `elo`
> print text=schmidt-ok
2. *
+5 -5
View File
@@ -6,11 +6,11 @@ import quantum:ext/quantum/quantum.mq.md
# main
*qc = > quantum.circuit qubits=1*
*qc = > `qc`.i qubit=0*
*qc = > `qc`.noise kind="bitflip" p=1*
*r = > `qc`.run shots=32 seed=3*
*c1 = r[^counts][^1]*
**qc = > quantum.circuit qubits=1**
**qc = > `qc`.i qubit=0**
**qc = > `qc`.noise kind="bitflip" p=1**
**r = > `qc`.run shots=32 seed=3**
**c1 = r[^counts][^1]**
1. `c1` == 32
> print text=noise-ok
+5 -5
View File
@@ -6,11 +6,11 @@ description: 噪声 bitflip p=1 后 I 使全部射中 |1⟩.
# main
*qc = > 量子.电路 比特数=1*
*qc = > `qc`.单位 比特=0*
*qc = > `qc`.噪声 种类="bitflip" 概率=1*
*r = > `qc`.运行 次数=32 种子=3*
*c1 = r[^counts][^1]*
**qc = > 量子.电路 比特数=1**
**qc = > `qc`.单位 比特=0**
**qc = > `qc`.噪声 种类="bitflip" 概率=1**
**r = > `qc`.运行 次数=32 种子=3**
**c1 = r[^counts][^1]**
1. `c1` == 32
> print text=noise-ok
+7 -7
View File
@@ -14,11 +14,11 @@ import math:lib/math.mq.md
| 1 | H | 0 |
| 2 | CX | 0,1 |
*qc = > quantum.circuit qubits=2 steps=`steps`*
*p = > `qc`.probabilities*
*p00 = p[^00]*
*lo = > math.div a=2 b=5*
*hi = > math.div a=3 b=5*
**qc = > quantum.circuit qubits=2 steps=`steps`**
**p = > `qc`.probabilities**
**p00 = p[^00]**
**lo = > math.div a=2 b=5**
**hi = > math.div a=3 b=5**
1. `p00` > `lo`
1. `p00` < `hi`
@@ -28,8 +28,8 @@ import math:lib/math.mq.md
2. *
> print text=steps-fail
*img = > `qc`.draw path="quantum-steps-draw.svg"*
*kind = img[^kind]*
**img = > `qc`.draw path="quantum-steps-draw.svg"**
**kind = img[^kind]**
1. `kind` == circuit
> print text=draw-ok
+8 -8
View File
@@ -6,15 +6,15 @@ import quantum:ext/quantum/quantum.mq.md
# main
*qc = > quantum.circuit qubits=2*
*qc = > `qc`.h qubit=0*
*qc = > `qc`.cx control=0 target=1*
**qc = > quantum.circuit qubits=2**
**qc = > `qc`.h qubit=0**
**qc = > `qc`.cx control=0 target=1**
*h = > `qc`.draw kind="hinton" path="quantum-viz-hinton.svg"*
*q = > `qc`.draw kind="qsphere" path="quantum-viz-qsphere.svg"*
*m = > `qc`.draw kind="multibloch" path="quantum-viz-multibloch.svg"*
**h = > `qc`.draw kind="hinton" path="quantum-viz-hinton.svg"**
**q = > `qc`.draw kind="qsphere" path="quantum-viz-qsphere.svg"**
**m = > `qc`.draw kind="multibloch" path="quantum-viz-multibloch.svg"**
*rho = > `qc`.density*
*c = > `rho`.draw kind="city" path="quantum-viz-city.svg"*
**rho = > `qc`.density**
**c = > `rho`.draw kind="city" path="quantum-viz-city.svg"**
> print text=viz-ok
+7 -7
View File
@@ -7,13 +7,13 @@ import math:lib/math.mq.md
# main
*电路 = > 量子.电路 比特数=1*
*电路 = > `电路`.哈达玛 比特=0*
*电路 = > `电路`.泡利Z 比特=0*
*电路 = > `电路`.哈达玛 比特=0*
*概率 = > `电路`.概率*
*p1 = 概率[^1]*
*lo = > math.div a=9 b=10*
**电路 = > 量子.电路 比特数=1**
**电路 = > `电路`.哈达玛 比特=0**
**电路 = > `电路`.泡利Z 比特=0**
**电路 = > `电路`.哈达玛 比特=0**
**概率 = > `电路`.概率**
**p1 = 概率[^1]**
**lo = > math.div a=9 b=10**
1. `p1` > `lo`
> print text=zh-ok
+22 -22
View File
@@ -8,24 +8,24 @@ import json:lib/json.mq.md
# main
*store = > web.db url="sqlite:web-fixtures/data/admin-smoke.db"*
*schema = > articles.schema*
**store = > web.db url="sqlite:web-fixtures/data/admin-smoke.db"**
**schema = > articles.schema**
> `store`.init name=articles fields=`schema`
> `store`.exec sql="DELETE FROM articles"
> `store`.exec sql="DELETE FROM sqlite_sequence WHERE name='articles'"
*url = > json.get value=`store` key="url"*
**url = > json.get value=`store` key="url"**
*info = > web_db_table_info url=`url` table="articles"*
*cols = > json.get value=`info` key="columns"*
*n = > len value=`cols`*
**info = > web_db_table_info url=`url` table="articles"**
**cols = > json.get value=`info` key="columns"**
**n = > len value=`cols`**
1. `n` >= 2
> print text=schema-ok
2. *
> print text=schema-fail
*fnew = > web_form_from_schema url=`url` table="articles" action="insert"*
*fields = > json.get value=`fnew` key="fields"*
*nf = > len value=`fields`*
**fnew = > web_form_from_schema url=`url` table="articles" action="insert"**
**fields = > json.get value=`fnew` key="fields"**
**nf = > len value=`fields`**
1. `nf` >= 1
> print text=new-form-ok
2. *
@@ -37,36 +37,36 @@ import json:lib/json.mq.md
|-------|------|
| Admin create | via schema form |
*sub = > web_form_submit form=`fnew` data=`row` url=`url`*
*sok = > json.get value=`sub` key="ok"*
**sub = > web_form_submit form=`fnew` data=`row` url=`url`**
**sok = > json.get value=`sub` key="ok"**
1. `sok`
> print text=insert-ok
2. *
> print text=insert-fail
*got = > `store`.get table="articles" id=1*
*title = > json.get value=`got` key="title"*
**got = > `store`.get table="articles" id=1**
**title = > json.get value=`got` key="title"**
1. `title` == "Admin create"
> print text=get-ok
2. *
> print text=get-fail
*fedit = > web_form_from_schema url=`url` table="articles" action="update" id=1*
**fedit = > web_form_from_schema url=`url` table="articles" action="update" id=1**
`patch` =
| title | body |
|-------|------|
| Admin edited | body updated |
*up = > web_form_submit form=`fedit` data=`patch` url=`url`*
*uok = > json.get value=`up` key="ok"*
**up = > web_form_submit form=`fedit` data=`patch` url=`url`**
**uok = > json.get value=`up` key="ok"**
1. `uok`
> print text=update-ok
2. *
> print text=update-fail
*got2 = > `store`.get table="articles" id=1*
*title2 = > json.get value=`got2` key="title"*
**got2 = > `store`.get table="articles" id=1**
**title2 = > json.get value=`got2` key="title"**
1. `title2` == "Admin edited"
> print text=edit-ok
2. *
@@ -78,15 +78,15 @@ import json:lib/json.mq.md
|-------|------|
| | |
*bad = > web_form_submit form=`fnew` data=`empty` url=`url`*
*bok = > json.get value=`bad` key="ok"*
**bad = > web_form_submit form=`fnew` data=`empty` url=`url`**
**bok = > json.get value=`bad` key="ok"**
1. `bok`
> print text=required-should-fail
2. *
> print text=required-ok
*errs = > json.get value=`bad` key="errors"*
*nerr = > len value=`errs`*
**errs = > json.get value=`bad` key="errors"**
**nerr = > len value=`errs`**
1. `nerr` >= 1
> print text=errors-echoed-ok
2. *
+6 -6
View File
@@ -24,13 +24,13 @@ import web:ext/web/web.mq.md
|---|---|---|---|
|"/static/favicon.svg"|mark|brand|eager|
*home = > web.page title="Live assets" intro="<p>assets live</p>"*
*home = > `home`.head table=`head_table`*
*home = > `home`.images table=`images_table`*
**home = > web.page title="Live assets" intro="<p>assets live</p>"**
**home = > `home`.head table=`head_table`**
**home = > `home`.images table=`images_table`**
*app = > web.app page=`home` host=127.0.0.1 port=18092*
*app = > `app`.static dir="web-fixtures/public" mount="/static"*
*app = > `app`.icons table=`icons_table`*
**app = > web.app page=`home` host=127.0.0.1 port=18092**
**app = > `app`.static dir="web-fixtures/public" mount="/static"**
**app = > `app`.icons table=`icons_table`**
> print text=marqdo web assets live starting
> `app`.listen
+18 -18
View File
@@ -36,56 +36,56 @@ import json:lib/json.mq.md
| 2 | icon | "/favicon.ico" |
| 3 | og:image | "/static/logo.svg" |
*home = > web.page title="Assets"*
*home = > `home`.head table=`head_table`*
*home = > `home`.images table=`images_table`*
*home = > `home`.meta meta=`seo`*
**home = > web.page title="Assets"**
**home = > `home`.head table=`head_table`**
**home = > `home`.images table=`images_table`**
**home = > `home`.meta meta=`seo`**
*ih = > json.get value=`home` key="images_html"*
**ih = > json.get value=`home` key="images_html"**
1. `ih` != ""
> print text=images-ok
2. *
> print text=images-fail
*hd = > json.get value=`home` key="head"*
*n = > len `hd`*
**hd = > json.get value=`home` key="head"**
**n = > len `hd`**
1. `n` >= 3
> print text=head-ok
2. *
> print text=head-fail
*meta = > json.get value=`home` key="meta"*
*icon = > json.get value=`meta` key="icon"*
**meta = > json.get value=`home` key="meta"**
**icon = > json.get value=`meta` key="icon"**
1. `icon` == "/favicon.ico"
> print text=meta-icon-ok
2. *
> print text=meta-icon-fail
*app = > web.app page=`home` host=127.0.0.1 port=18091*
*app = > `app`.static dir="web-fixtures/public" mount="/static"*
*app = > `app`.icons table=`icons_table`*
**app = > web.app page=`home` host=127.0.0.1 port=18091**
**app = > `app`.static dir="web-fixtures/public" mount="/static"**
**app = > `app`.icons table=`icons_table`**
*icons = > json.get value=`app` key="icons"*
*ni = > len `icons`*
**icons = > json.get value=`app` key="icons"**
**ni = > len `icons`**
1. `ni` == 2
> print text=icons-ok
2. *
> print text=icons-fail
*sh = > json.get value=`app` key="site_head"*
*ns = > len `sh`*
**sh = > json.get value=`app` key="site_head"**
**ns = > len `sh`**
1. `ns` >= 1
> print text=site-head-ok
2. *
> print text=site-head-fail
*preview = > web.make_images table=`images_table`*
**preview = > web.make_images table=`images_table`**
1. `preview` != ""
> print text=make-images-ok
2. *
> print text=make-images-fail
*hprev = > web.make_head table=`head_table`*
**hprev = > web.make_head table=`head_table`**
1. `hprev` != ""
> print text=make-head-ok
2. *
+19 -19
View File
@@ -8,30 +8,30 @@ import sys:lib/sys.mq.md
# main
*首页 = > web.page title="home"*
*页 = > web.page title="news"*
**首页 = > web.page title="home"**
**页 = > web.page title="news"**
*应用 = > web.app page=`首页` admin=False*
*应用 = > `应用`.route path="/admin/news" page=`页`*
*routes = > json.get value=`应用` key="routes"*
*hit = > json.get value=`routes` key="/admin/news"*
**应用 = > web.app page=`首页` admin=False**
**应用 = > `应用`.route path="/admin/news" page=`页`**
**routes = > json.get value=`应用` key="routes"**
**hit = > json.get value=`routes` key="/admin/news"**
1. `hit`
> print text=free-admin-ok
2. *
> print text=free-admin-fail
> sys.exit code=1
*应用3 = > web.app page=`首页` admin=True admin_prefix="/desk"*
*应用3 = > `应用3`.route path="/admin/news" page=`页`*
*routes3 = > json.get value=`应用3` key="routes"*
*hit3 = > json.get value=`routes3` key="/admin/news"*
**应用3 = > web.app page=`首页` admin=True admin_prefix="/desk"**
**应用3 = > `应用3`.route path="/admin/news" page=`页`**
**routes3 = > json.get value=`应用3` key="routes"**
**hit3 = > json.get value=`routes3` key="/admin/news"**
1. `hit3`
> print text=prefix-frees-admin-ok
2. *
> print text=prefix-frees-admin-fail
> sys.exit code=1
*prefix = > json.get value=`应用3` key="admin_prefix"*
**prefix = > json.get value=`应用3` key="admin_prefix"**
1. `prefix` == "/desk"
> print text=prefix-stored-ok
2. *
@@ -43,14 +43,14 @@ import sys:lib/sys.mq.md
|--------|------|------|
| admin | secret | admin |
*应用4 = > web.app page=`首页` admin=True*
*应用4 = > `应用4`.auth users=`用户表` admin_prefix="/desk" login_redirect="/desk" logout_redirect="/desk/login"*
*prefix4 = > json.get value=`应用4` key="admin_prefix"*
*login4 = > json.get value=`应用4` key="login_redirect"*
*logout4 = > json.get value=`应用4` key="logout_redirect"*
*gates = > json.get value=`应用4` key="gates"*
*g0 = > at value=`gates` index=0*
*gpath = > json.get value=`g0` key="path"*
**应用4 = > web.app page=`首页` admin=True**
**应用4 = > `应用4`.auth users=`用户表` admin_prefix="/desk" login_redirect="/desk" logout_redirect="/desk/login"**
**prefix4 = > json.get value=`应用4` key="admin_prefix"**
**login4 = > json.get value=`应用4` key="login_redirect"**
**logout4 = > json.get value=`应用4` key="logout_redirect"**
**gates = > json.get value=`应用4` key="gates"**
**g0 = > at value=`gates` index=0**
**gpath = > json.get value=`g0` key="path"**
1. `prefix4` == "/desk"
1. `login4` == "/desk"
1. `logout4` == "/desk/login"
+22 -22
View File
@@ -8,21 +8,21 @@ import sys:lib/sys.mq.md
# main
*首页 = > web.page title="home"*
**首页 = > web.page title="home"**
`用户表` =
| 用户名 | 密码 | 角色 |
|--------|------|------|
| admin | secret | admin |
*应用 = > web.app page=`首页` admin=True*
*应用 = > `应用`.auth users=`用户表`*
*gates = > json.get value=`应用` key="gates"*
*g0 = > at value=`gates` index=0*
*path = > json.get value=`g0` key="path"*
*match = > json.get value=`g0` key="match"*
*deny = > json.get value=`g0` key="on_deny"*
*login = > json.get value=`应用` key="login_path"*
**应用 = > web.app page=`首页` admin=True**
**应用 = > `应用`.auth users=`用户表`**
**gates = > json.get value=`应用` key="gates"**
**g0 = > at value=`gates` index=0**
**path = > json.get value=`g0` key="path"**
**match = > json.get value=`g0` key="match"**
**deny = > json.get value=`g0` key="on_deny"**
**login = > json.get value=`应用` key="login_path"**
1. `path` == "/admin"
1. `match` == "prefix"
1. `deny` == "redirect"
@@ -41,14 +41,14 @@ import sys:lib/sys.mq.md
> print text=path-fail
> sys.exit code=1
*应用2 = > web.app page=`首页` admin=False*
*应用2 = > `应用2`.gate path="/desk" roles="admin" match="prefix" on_deny="redirect" exclude="/desk/login"*
*gates2 = > json.get value=`应用2` key="gates"*
*g1 = > at value=`gates2` index=0*
*p2 = > json.get value=`g1` key="path"*
*m2 = > json.get value=`g1` key="match"*
*d2 = > json.get value=`g1` key="on_deny"*
*ex = > json.get value=`g1` key="exclude"*
**应用2 = > web.app page=`首页` admin=False**
**应用2 = > `应用2`.gate path="/desk" roles="admin" match="prefix" on_deny="redirect" exclude="/desk/login"**
**gates2 = > json.get value=`应用2` key="gates"**
**g1 = > at value=`gates2` index=0**
**p2 = > json.get value=`g1` key="path"**
**m2 = > json.get value=`g1` key="match"**
**d2 = > json.get value=`g1` key="on_deny"**
**ex = > json.get value=`g1` key="exclude"**
1. `p2` == "/desk"
1. `m2` == "prefix"
1. `d2` == "redirect"
@@ -67,11 +67,11 @@ import sys:lib/sys.mq.md
> print text=custom-path-fail
> sys.exit code=1
*应用3 = > web.app page=`首页` admin=False*
*应用3 = > `应用3`.gate path="/write*" roles="admin,author"*
*gates3 = > json.get value=`应用3` key="gates"*
*g3 = > at value=`gates3` index=0*
*p3 = > json.get value=`g3` key="path"*
**应用3 = > web.app page=`首页` admin=False**
**应用3 = > `应用3`.gate path="/write*" roles="admin,author"**
**gates3 = > json.get value=`应用3` key="gates"**
**g3 = > at value=`gates3` index=0**
**p3 = > json.get value=`g3` key="path"**
1. `p3`
> print text=star-gate-ok
2. *
+18 -18
View File
@@ -14,17 +14,17 @@ import sys:lib/sys.mq.md
| Home | / |
| Desk | /desk |
*页 = > web.page title="c2" shell_css="off" layout="stacked"*
*页 = > json.set map=`页` key="nav" value=`链`*
*页 = > json.set map=`页` key="sidebar" value=`链`*
*html = > `页`.render*
**页 = > web.page title="c2" shell_css="off" layout="stacked"**
**页 = > json.set map=`页` key="nav" value=`链`**
**页 = > json.set map=`页` key="sidebar" value=`链`**
**html = > `页`.render**
*a = > split value=`html` sep="layout-stacked"*
*na = > len value=`a`*
*b = > split value=`html` sep="has-sidebar"*
*nb = > len value=`b`*
*c = > split value=`html` sep="grid-template-columns:14rem"*
*nc = > len value=`c`*
**a = > split value=`html` sep="layout-stacked"**
**na = > len value=`a`**
**b = > split value=`html` sep="has-sidebar"**
**nb = > len value=`b`**
**c = > split value=`html` sep="grid-template-columns:14rem"**
**nc = > len value=`c`**
1. `na` > 1
1. `nb` == 1
1. `nc` == 1
@@ -39,14 +39,14 @@ import sys:lib/sys.mq.md
> print text=stacked-missing
> sys.exit code=1
*裸 = > web.page title="bare" layout="bare" shell_css="minimal"*
*裸 = > json.set map=`裸` key="nav" value=`链`*
*裸 = > json.set map=`裸` key="sidebar" value=`链`*
*h2 = > `裸`.render*
*d = > split value=`h2` sep="<aside"*
*nd = > len value=`d`*
*e = > split value=`h2` sep="--ink:"*
*ne = > len value=`e`*
**裸 = > web.page title="bare" layout="bare" shell_css="minimal"**
**裸 = > json.set map=`裸` key="nav" value=`链`**
**裸 = > json.set map=`裸` key="sidebar" value=`链`**
**h2 = > `裸`.render**
**d = > split value=`h2` sep="<aside"**
**nd = > len value=`d`**
**e = > split value=`h2` sep="--ink:"**
**ne = > len value=`e`**
1. `nd` == 1
1. `ne` > 1
> print text=bare-minimal-ok
+24 -24
View File
@@ -12,9 +12,9 @@ import sys:lib/sys.mq.md
|--------|------|-----|
| .box | grid-column | "1 / 5" |
*css = > web.make_style name="t" table=`好` strict=True*
*a = > split value=`css` sep="1 / 5"*
*na = > len value=`a`*
**css = > web.make_style name="t" table=`好` strict=True**
**a = > split value=`css` sep="1 / 5"**
**na = > len value=`a`**
1. `na` > 1
> print text=quoted-css-ok
2. *
@@ -27,15 +27,15 @@ import sys:lib/sys.mq.md
| script | /static/a.js | 真 | 3 |
| stylesheet | /static/t.css | | 1 |
*页 = > web.page title="c3" asset_version="appv"*
*页 = > `页`.head table=`头`*
*html = > `页`.render*
*b = > split value=`html` sep="a.js?v=3"*
*nb = > len value=`b`*
*c = > split value=`html` sep="t.css?v=1"*
*nc = > len value=`c`*
*d0 = > split value=`html` sep="script defer"*
*nd0 = > len value=`d0`*
**页 = > web.page title="c3" asset_version="appv"**
**页 = > `页`.head table=`头`**
**html = > `页`.render**
**b = > split value=`html` sep="a.js?v=3"**
**nb = > len value=`b`**
**c = > split value=`html` sep="t.css?v=1"**
**nc = > len value=`c`**
**d0 = > split value=`html` sep="script defer"**
**nd0 = > len value=`d0`**
1. `nb` > 1
1. `nc` > 1
1. `nd0` > 1
@@ -55,11 +55,11 @@ import sys:lib/sys.mq.md
|------|------|------|
| script | /static/b.js | 真 |
*页2 = > web.page title="c3b" asset_version="2026-09-04"*
*页2 = > `页2`.head table=`头2`*
*h2 = > `页2`.render*
*d = > split value=`h2` sep="b.js?v=2026-09-04"*
*nd = > len value=`d`*
**页2 = > web.page title="c3b" asset_version="2026-09-04"**
**页2 = > `页2`.head table=`头2`**
**h2 = > `页2`.render**
**d = > split value=`h2` sep="b.js?v=2026-09-04"**
**nd = > len value=`d`**
1. `nd` > 1
> print text=asset-version-ok
2. *
@@ -71,13 +71,13 @@ import sys:lib/sys.mq.md
|------|------|
| script | /static/sync.js |
*页3 = > web.page title="c3c"*
*页3 = > `页3`.head table=`头3`*
*h3 = > `页3`.render*
*e = > split value=`h3` sep="sync.js"*
*ne = > len value=`e`*
*f = > split value=`h3` sep="script defer"*
*nf = > len value=`f`*
**页3 = > web.page title="c3c"**
**页3 = > `页3`.head table=`头3`**
**h3 = > `页3`.render**
**e = > split value=`h3` sep="sync.js"**
**ne = > len value=`e`**
**f = > split value=`h3` sep="script defer"**
**nf = > len value=`f`**
1. `ne` > 1
1. `nf` == 1
> print text=sync-compat-ok
+22 -22
View File
@@ -17,21 +17,21 @@ import sys:lib/sys.mq.md
| Login | /login | | | guest |
| Gone | /gone | | | hide |
*客 = > web.page title="c4-guest" shell_css="off"*
*`客` = > table.put in=`客` at="nav" value=`链`*
*`客` = > table.put in=`客` at="_logged_in" value=False*
*hg = > `客`.render*
**客 = > web.page title="c4-guest" shell_css="off"**
**`客` = > table.put in=`客` at="nav" value=`链`**
**`客` = > table.put in=`客` at="_logged_in" value=False**
**hg = > `客`.render**
*a = > split value=`hg` sep="/login"*
*na = > len value=`a`*
*b = > split value=`hg` sep="/admin"*
*nb = > len value=`b`*
*c = > split value=`hg` sep="/gone"*
*nc = > len value=`c`*
*d = > split value=`hg` sep="nav-mq-0"*
*nd = > len value=`d`*
*e = > split value=`hg` sep="@media not (max-width: 720px)"*
*ne = > len value=`e`*
**a = > split value=`hg` sep="/login"**
**na = > len value=`a`**
**b = > split value=`hg` sep="/admin"**
**nb = > len value=`b`**
**c = > split value=`hg` sep="/gone"**
**nc = > len value=`c`**
**d = > split value=`hg` sep="nav-mq-0"**
**nd = > len value=`d`**
**e = > split value=`hg` sep="@media not (max-width: 720px)"**
**ne = > len value=`e`**
1. `na` > 1
1. `nb` == 1
1. `nc` == 1
@@ -54,14 +54,14 @@ import sys:lib/sys.mq.md
> print text=guest-login-missing
> sys.exit code=1
*户 = > web.page title="c4-user" shell_css="off"*
*`户` = > table.put in=`户` at="nav" value=`链`*
*`户` = > table.put in=`户` at="_logged_in" value=True*
*hu = > `户`.render*
*f = > split value=`hu` sep="/admin"*
*nf = > len value=`f`*
*g = > split value=`hu` sep="/login"*
*ng = > len value=`g`*
**户 = > web.page title="c4-user" shell_css="off"**
**`户` = > table.put in=`户` at="nav" value=`链`**
**`户` = > table.put in=`户` at="_logged_in" value=True**
**hu = > `户`.render**
**f = > split value=`hu` sep="/admin"**
**nf = > len value=`f`**
**g = > split value=`hu` sep="/login"**
**ng = > len value=`g`**
1. `nf` > 1
1. `ng` == 1
> print text=auth-ok
+8 -8
View File
@@ -8,7 +8,7 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
@@ -22,17 +22,17 @@ import sys:lib/sys.mq.md
| 2 | description | A demo site |
| 3 | og:type | website |
*page = > web.page title="Home"*
*page = > page.meta meta=`meta`*
*mm = page[^meta]*
*m = mm[^title]*
**page = > web.page title="Home"**
**page = > page.meta meta=`meta`**
**mm = page[^meta]**
**m = mm[^title]**
1. `m` == "My Site"
> print text=meta-ok
2. *
> print text=meta-fail
*page = > page.paginate offset=0 limit=5 path="/"*
*poff = page[^paginate][^offset]*
**page = > page.paginate offset=0 limit=5 path="/"**
**poff = page[^paginate][^offset]**
1. `poff` == 0
> print text=paginate-ok
2. *
@@ -44,7 +44,7 @@ import sys:lib/sys.mq.md
|----|-------|------|---------|
| 1 | Hello | /a | First post |
*feed = > web_rss_build title="Blog" link="http://example.com" description="Demo" items=`rows`*
**feed = > web_rss_build title="Blog" link="http://example.com" description="Demo" items=`rows`**
1. `feed` != ""
> print text=rss-ok
2. *
+2 -2
View File
@@ -6,7 +6,7 @@ import web:ext/web/web.mq.md
## open
*store = > web.db url="sqlite::memory:"*
**store = > web.db url="sqlite::memory:"**
`fields` =
@@ -23,4 +23,4 @@ import web:ext/web/web.mq.md
| 1 | hello |
> `store`.insert table=items rows=`seed`
**store**
*store*
+4 -4
View File
@@ -9,15 +9,15 @@ import storemod:web-db-cross-module-lib.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
> sys.exit code=1
*store = > storemod.open*
*rows = > `store`.select table="items" limit=10*
*n = > len value=`rows`*
**store = > storemod.open**
**rows = > `store`.select table="items" limit=10**
**n = > len value=`rows`**
1. `n` >= 1
> print text=cross-db-ok
2. *
+22 -22
View File
@@ -6,7 +6,7 @@ import json:lib/json.mq.md
# main
*store = > web.db url="sqlite:web-fixtures/data/w2-smoke.db"*
**store = > web.db url="sqlite:web-fixtures/data/w2-smoke.db"**
`字段` =
@@ -30,7 +30,7 @@ import json:lib/json.mq.md
> `store`.insert table=posts rows=`数据`
*c = > `store`.count table="posts"*
**c = > `store`.count table="posts"**
1. `c` == 4
> print text=count-ok
2. *
@@ -42,25 +42,25 @@ import json:lib/json.mq.md
|------|------|-----|
| views | = | 30 |
*c2 = > `store`.count table="posts" where=`视图条件`*
**c2 = > `store`.count table="posts" where=`视图条件`**
1. `c2` == 1
> print text=count-where-ok
2. *
> print text=count-where-fail
*page1 = > `store`.paginate table="posts" limit=2 跳过=0*
*total1 = page1[^total]*
*p1r = page1[^rows]*
*n1 = > len value=`p1r`*
**page1 = > `store`.paginate table="posts" limit=2 跳过=0**
**total1 = page1[^total]**
**p1r = page1[^rows]**
**n1 = > len value=`p1r`**
1. `total1` == 4
1. `n1` == 2
> print text=page-ok
2. *
> print text=page-fail
*page2 = > `store`.paginate table="posts" limit=2 跳过=2*
*p2r = page2[^rows]*
*n2 = > len value=`p2r`*
**page2 = > `store`.paginate table="posts" limit=2 跳过=2**
**p2r = page2[^rows]**
**n2 = > len value=`p2r`**
1. `n2` == 2
> print text=page2-ok
2. *
@@ -72,8 +72,8 @@ import json:lib/json.mq.md
|------|------|-----|
| title | in | "Alpha,Beta" |
*in_rows = > `store`.select table="posts" where=`in条件` limit=10*
*nin = > len value=`in_rows`*
**in_rows = > `store`.select table="posts" where=`in条件` limit=10**
**nin = > len value=`in_rows`**
1. `nin` == 2
> print text=in-ok
2. *
@@ -85,8 +85,8 @@ import json:lib/json.mq.md
|------|------|-----|
| views | between | "20,35" |
*bt_rows = > `store`.select table="posts" where=`between条件` limit=10*
*nbt = > len value=`bt_rows`*
**bt_rows = > `store`.select table="posts" where=`between条件` limit=10**
**nbt = > len value=`bt_rows`**
1. `nbt` == 2
> print text=between-ok
2. *
@@ -99,21 +99,21 @@ import json:lib/json.mq.md
| title | = | Alpha | |
| title | = | Gamma | 是 |
*or_rows = > `store`.select table="posts" where=`or条件` limit=10*
*nor = > len value=`or_rows`*
**or_rows = > `store`.select table="posts" where=`or条件` limit=10**
**nor = > len value=`or_rows`**
1. `nor` == 2
> print text=or-ok
2. *
> print text=or-fail
*agg = > `store`.query sql="SELECT title, views FROM posts WHERE views >= 30 ORDER BY views DESC"*
*nagg = agg[^count]*
**agg = > `store`.query sql="SELECT title, views FROM posts WHERE views >= 30 ORDER BY views DESC"**
**nagg = agg[^count]**
1. `nagg` == 2
> print text=query-ok
2. *
> print text=query-fail
*txn = > `store`.事务*
**txn = > `store`.事务**
`更多` =
| title | body | views |
@@ -123,13 +123,13 @@ import json:lib/json.mq.md
> `txn`.insert table=posts rows=`更多`
> `txn`.提交
*c5 = > `store`.count table="posts"*
**c5 = > `store`.count table="posts"**
1. `c5` == 5
> print text=txn-commit-ok
2. *
> print text=txn-commit-fail
*txn2 = > `store`.事务*
**txn2 = > `store`.事务**
`更多2` =
| title | body | views |
@@ -139,7 +139,7 @@ import json:lib/json.mq.md
> `txn2`.insert table=posts rows=`更多2`
> `txn2`.回滚
*c6 = > `store`.count table="posts"*
**c6 = > `store`.count table="posts"**
1. `c6` == 5
> print text=txn-rollback-ok
2. *
+14 -14
View File
@@ -5,7 +5,7 @@ import web:ext/web/web.mq.md
# main
*store = > web.db url="sqlite:web-fixtures/data/w6-smoke.db"*
**store = > web.db url="sqlite:web-fixtures/data/w6-smoke.db"**
`steps` =
@@ -14,17 +14,17 @@ import web:ext/web/web.mq.md
| 1 | CREATE TABLE IF NOT EXISTS posts (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL, body TEXT, status TEXT NOT NULL DEFAULT 'draft') |
| 2 | CREATE TABLE IF NOT EXISTS comments (id INTEGER PRIMARY KEY AUTOINCREMENT, post_id INTEGER NOT NULL, body TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'pending') |
*m1 = > `store`.migrate steps=`steps`*
*a1 = m1[^applied]*
*n1 = > len value=`a1`*
**m1 = > `store`.migrate steps=`steps`**
**a1 = m1[^applied]**
**n1 = > len value=`a1`**
1. `n1` == 2
> print text=migrate-ok
2. *
> print text=migrate-fail
*m2 = > `store`.migrate steps=`steps`*
*a2 = m2[^applied]*
*n2 = > len value=`a2`*
**m2 = > `store`.migrate steps=`steps`**
**a2 = m2[^applied]**
**n2 = > len value=`a2`**
1. `n2` == 0
> print text=migrate-idempotent-ok
2. *
@@ -46,7 +46,7 @@ import web:ext/web/web.mq.md
|------|------|-----|
| status | = | published |
*pc = > `store`.count table="posts" where=`pub`*
**pc = > `store`.count table="posts" where=`pub`**
1. `pc` == 2
> print text=published-filter-ok
2. *
@@ -60,23 +60,23 @@ import web:ext/web/web.mq.md
| 1 | spam | pending |
> `store`.insert table=comments rows=`comments`
*cc = > `store`.count table="comments"*
**cc = > `store`.count table="comments"**
1. `cc` == 2
> print text=comments-ok
2. *
> print text=comments-fail
> `store`.fts table="posts" columns="title,body"
*hit = > `store`.search table="posts" q="hello" limit=10*
*hn = hit[^count]*
**hit = > `store`.search table="posts" q="hello" limit=10**
**hn = hit[^count]**
1. `hn` >= 1
> print text=fts-ok
2. *
> print text=fts-fail
*rows2 = hit[^rows]*
*first = rows2[^1]*
*ft = first[^title]*
**rows2 = hit[^rows]**
**first = rows2[^1]**
**ft = first[^title]**
1. `ft`
> print text=fts-row-ok
2. *
+15 -15
View File
@@ -8,7 +8,7 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
@@ -16,18 +16,18 @@ import sys:lib/sys.mq.md
<!-- cache: memory backend -->
*c = > web.cache url="memory:drivers-smoke"*
**c = > web.cache url="memory:drivers-smoke"**
> `c`.set key="k1" value="v1" ttl=60
*g = > `c`.get key="k1"*
*gv = g[^value]*
**g = > `c`.get key="k1"**
**gv = g[^value]**
1. `gv` == "v1"
> print text=cache-ok
2. *
> print text=cache-fail
> `c`.del key="k1"
*ex = > `c`.exists key="k1"*
*eok = ex[^ok]*
**ex = > `c`.exists key="k1"**
**eok = ex[^ok]**
1. `eok`
> print text=cache-del-fail
2. *
@@ -35,17 +35,17 @@ import sys:lib/sys.mq.md
<!-- storage: file backend -->
*blob = > web.storage url="file:tests/ext/web-fixtures/data/drivers-blobs"*
**blob = > web.storage url="file:tests/ext/web-fixtures/data/drivers-blobs"**
> `blob`.put key="notes/a.txt" body="hello" content_type="text/plain"
*got = > `blob`.get key="notes/a.txt"*
*body = got[^body]*
**got = > `blob`.get key="notes/a.txt"**
**body = got[^body]**
1. `body` == "hello"
> print text=storage-ok
2. *
> print text=storage-fail
*ls = > `blob`.list prefix="notes/"*
*n = ls[^count]*
**ls = > `blob`.list prefix="notes/"**
**n = ls[^count]**
1. `n` == 1
> print text=storage-list-ok
2. *
@@ -55,8 +55,8 @@ import sys:lib/sys.mq.md
<!-- db: postgres URL is accepted as a handle (no live server required) -->
*pg = > web.db url="postgres://marqdo:marqdo@127.0.0.1:5432/marqdo"*
*purl = pg[^url]*
**pg = > web.db url="postgres://marqdo:marqdo@127.0.0.1:5432/marqdo"**
**purl = pg[^url]**
1. `purl` == "postgres://marqdo:marqdo@127.0.0.1:5432/marqdo"
> print text=postgres-url-ok
2. *
@@ -64,8 +64,8 @@ import sys:lib/sys.mq.md
<!-- s3 URL shape validates at open -->
*s3 = > web.storage url="s3://bucket?endpoint=http://127.0.0.1:9000"*
*sb = s3[^backend]*
**s3 = > web.storage url="s3://bucket?endpoint=http://127.0.0.1:9000"**
**sb = s3[^backend]**
1. `sb` == "s3"
> print text=s3-open-ok
2. *
+3 -3
View File
@@ -12,7 +12,7 @@ import web:ext/web/web.mq.md
NOT under the process cwd.
-->
*store = > web.db url="sqlite:entrydir-fixtures/data/entrydir.db"*
**store = > web.db url="sqlite:entrydir-fixtures/data/entrydir.db"**
`schema` =
@@ -30,8 +30,8 @@ import web:ext/web/web.mq.md
> `store`.insert table=items rows=`one`
*rows = > `store`.select table="items" limit=10*
*n = > len value=`rows`*
**rows = > `store`.select table="items" limit=10**
**n = > len value=`rows`**
1. `n` == 1
> print text=entrydir-db-ok
+1 -1
View File
@@ -6,4 +6,4 @@
|------|-----|------|
| Foot | / | |
**foot**
*foot*
+1 -1
View File
@@ -7,4 +7,4 @@
| Home | / | |
| Docs | /docs | |
**nav**
*nav*
+1 -1
View File
@@ -7,4 +7,4 @@
| Side | / | |
| Docs | https://github.com | |
**side**
*side*
+2 -2
View File
@@ -8,7 +8,7 @@
| title | text | false |
| body | text | true |
**fields**
*fields*
## seed
@@ -19,4 +19,4 @@
| 1 | Hello Marqdo | First article from a GFM table. |
| 2 | Code as docs | The page table is the program. |
**rows**
*rows*
+4 -4
View File
@@ -6,7 +6,7 @@
|------|-----|
| background | #fff |
**topnav**
*topnav*
## side_panel
@@ -16,7 +16,7 @@
|------|-----|
| background | #f5f5f4 |
**side_panel**
*side_panel*
## card_title
@@ -26,7 +26,7 @@
|------|-----|
| font-weight | 600 |
**card_title**
*card_title*
## card_body
@@ -36,4 +36,4 @@
|------|-----|
| color | #57534e |
**card_body**
*card_body*
+6 -6
View File
@@ -14,19 +14,19 @@ import json:lib/json.mq.md
| title | Title | text | true | |
| body | Body | textarea | false | |
*f = > web.form table="articles" action="insert"*
*f = > `f`.fields fields=`fields`*
**f = > web.form table="articles" action="insert"**
**f = > `f`.fields fields=`fields`**
*page = > web.page title="Compose" intro="<h1>Compose</h1>"*
*page = > `page`.compose_form id="article" form=`f`*
**page = > web.page title="Compose" intro="<h1>Compose</h1>"**
**page = > `page`.compose_form id="article" form=`f`**
*fid = > json.get value=`page` key="form_id"*
**fid = > json.get value=`page` key="form_id"**
1. `fid`
> print text=form-id-ok
2. *
> print text=form-id-fail
*html = > `page`.render*
**html = > `page`.render**
1. `html`
> print text=render-ok
2. *
+10 -10
View File
@@ -14,23 +14,23 @@ import text:lib/text.mq.md
|------|------|------|------|------|
| title | Title | text | true | |
*f = > web.form table="notes" action="insert"*
*f = > `f`.fields fields=`fields`*
**f = > web.form table="notes" action="insert"**
**f = > `f`.fields fields=`fields`**
*intro = "<div class=\"cols\"><section id=\"left\">voice</section><div id=\"qd-note-form-mount\"></div></div>"*
*page = > web.page title="Slot" intro=`intro`*
*page = > `page`.compose_form id="note" form=`f` target="#qd-note-form-mount"*
**intro = "<div class=\"cols\"><section id=\"left\">voice</section><div id=\"qd-note-form-mount\"></div></div>"**
**page = > web.page title="Slot" intro=`intro`**
**page = > `page`.compose_form id="note" form=`f` target="#qd-note-form-mount"**
*tgt = > json.get value=`page` key="form_target"*
**tgt = > json.get value=`page` key="form_target"**
1. `tgt`
> print text=target-ok
2. *
> print text=target-fail
*html = > `page`.render*
*`has_mount` = > text.contains text=`html` sub="qd-note-form-mount"*
*`has_form` = > text.contains text=`html` sub="site-form"*
*`order_ok` = > text.contains text=`html` sub="qd-note-form-mount\"><div class=\"site-form\""*
**html = > `page`.render**
**`has_mount` = > text.contains text=`html` sub="qd-note-form-mount"**
**`has_form` = > text.contains text=`html` sub="site-form"**
**`order_ok` = > text.contains text=`html` sub="qd-note-form-mount\"><div class=\"site-form\""**
1. `has_mount`
1. `has_form`
1. `order_ok`
+12 -12
View File
@@ -8,8 +8,8 @@ import json:lib/json.mq.md
# main
*store = > web.db url="sqlite:web-fixtures/data/form-smoke.db"*
*schema = > articles.schema*
**store = > web.db url="sqlite:web-fixtures/data/form-smoke.db"**
**schema = > articles.schema**
> `store`.init name=articles fields=`schema`
`fields` =
@@ -26,9 +26,9 @@ import json:lib/json.mq.md
| title | required | Title is required |
| title | max:120 | Title is too long |
*f = > web.form table="articles" action="insert"*
*f = > `f`.fields fields=`fields`*
*f = > `f`.rules rules=`rules`*
**f = > web.form table="articles" action="insert"**
**f = > `f`.fields fields=`fields`**
**f = > `f`.rules rules=`rules`**
`bad` =
@@ -36,8 +36,8 @@ import json:lib/json.mq.md
|-------|------|
| | hello |
*v = > `f`.validate data=`bad`*
*ok = > json.get value=`v` key="ok"*
**v = > `f`.validate data=`bad`**
**ok = > json.get value=`v` key="ok"**
1. `ok`
> print text=validate-should-fail
2. *
@@ -49,21 +49,21 @@ import json:lib/json.mq.md
|-------|------|
| From form | Body via submit |
*sub = > `f`.submit data=`good` db=`store`*
*sok = > json.get value=`sub` key="ok"*
**sub = > `f`.submit data=`good` db=`store`**
**sok = > json.get value=`sub` key="ok"**
1. `sok`
> print text=submit-ok
2. *
> print text=submit-fail
*rows = > `store`.select table="articles" limit=10*
*n = > len value=`rows`*
**rows = > `store`.select table="articles" limit=10**
**n = > len value=`rows`**
1. `n` >= 1
> print text=db-ok
2. *
> print text=db-fail
*html = > `f`.render id="article"*
**html = > `f`.render id="article"**
1. `html`
> print text=render-ok
2. *
+4 -4
View File
@@ -6,10 +6,10 @@ import plugin:lib/plugin.mq.md
# main
*p = "../../plugins/web/build/libweb.so"*
**p = "../../plugins/web/build/libweb.so"**
> plugin.load path=`p`
*pepper = "smoke-pepper"*
**pepper = "smoke-pepper"**
`keys` =
@@ -17,13 +17,13 @@ import plugin:lib/plugin.mq.md
|------|--------|
| 0ae9134cca7eff9d756fbf52402ee28ae0c2be22f01e53653e4fe86021479703 | read,api |
*ok = > web_api_key_check key="smoke-secret" authorization="" pepper=`pepper` keys=`keys`*
**ok = > web_api_key_check key="smoke-secret" authorization="" pepper=`pepper` keys=`keys`**
1. ok[^ok]
> print text=api-key-ok
2. *
> print text=api-key-fail
*bad = > web_api_key_check key="wrong" authorization="" pepper=`pepper` keys=`keys`*
**bad = > web_api_key_check key="wrong" authorization="" pepper=`pepper` keys=`keys`**
1. bad[^ok]
> print text=api-key-bad-ok
2. *
+3 -3
View File
@@ -6,11 +6,11 @@ import plugin:lib/plugin.mq.md
# main
*p = "../../plugins/web/build/libweb.so"*
**p = "../../plugins/web/build/libweb.so"**
> plugin.load path=`p`
*r = > web_go_ready*
**r = > web_go_ready**
> print text=`r`
*page = > web_page_new title="Go Web" intro="W-G0" shell_css="" layout="" asset_version=""*
**page = > web_page_new title="Go Web" intro="W-G0" shell_css="" layout="" asset_version=""**
> print text=`page`
+3 -3
View File
@@ -11,8 +11,8 @@ import web:ext/web/web.mq.md
Nested plugin call (`web.page`) while `app.listen` is the outer plugin frame —
must not clear GLOBAL_HOST so a second HTTP invoke still works.
*pg = > web.page title=`msg`*
*title = pg[^title]*
**pg = > web.page title=`msg`**
**title = pg[^title]**
`out` =
@@ -20,4 +20,4 @@ must not clear GLOBAL_HOST so a second HTTP invoke still works.
|----|-----|-------|
| true | `msg` | `title` |
**out**
*out*
+5 -5
View File
@@ -9,14 +9,14 @@ import demo:web-hosting-helpers.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
> sys.exit code=1
*pg = > web.page title="hosting-live"*
*app = > web.app page=`pg` host=127.0.0.1 port=18141*
*app = > `app`.proxy path="/proxy/sse" upstream="http://127.0.0.1:18142/sse" stream=True methods="POST"*
*app = > `app`.invoke path="/api/echo" fn="demo.echo" method="POST" body="json"*
**pg = > web.page title="hosting-live"**
**app = > web.app page=`pg` host=127.0.0.1 port=18141**
**app = > `app`.proxy path="/proxy/sse" upstream="http://127.0.0.1:18142/sse" stream=True methods="POST"**
**app = > `app`.invoke path="/api/echo" fn="demo.echo" method="POST" body="json"**
> `app`.listen
+5 -5
View File
@@ -10,7 +10,7 @@ import sys:lib/sys.mq.md
<!-- load web plugin so ABI primitives are registered -->
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
@@ -23,7 +23,7 @@ import sys:lib/sys.mq.md
| title | text |
| body | text |
*store = > web.db url="sqlite:web-fixtures/data/mw-live.db"*
**store = > web.db url="sqlite:web-fixtures/data/mw-live.db"**
> `store`.init name=articles fields=`schema`
> `store`.exec sql="DELETE FROM articles"
@@ -35,8 +35,8 @@ import sys:lib/sys.mq.md
> `store`.insert table=articles rows=`rows`
*pg = > web.page title="live"*
*app = > web.app page=`pg` db=`store` port=18099*
**pg = > web.page title="live"**
**app = > web.app page=`pg` db=`store` port=18099**
`cors` =
@@ -58,5 +58,5 @@ import sys:lib/sys.mq.md
| /api/posts | GET | articles | | | 10 |
| /api/publish | POST | articles | | | 10 |
*app = > `app`.configure cors=`cors` security=`sec` compress=True body_limit=1000 json=`api`*
**app = > `app`.configure cors=`cors` security=`sec` compress=True body_limit=1000 json=`api`**
> `app`.listen
+26 -26
View File
@@ -10,7 +10,7 @@ import sys:lib/sys.mq.md
<!-- load web plugin so ABI primitives are registered -->
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
@@ -46,37 +46,37 @@ import sys:lib/sys.mq.md
<!-- assemble via app.configure -->
*pg = > web.page title="mw"*
*app = > web.app page=`pg`*
*app = > `app`.configure cors=`cors` security=`sec` compress=True body_limit=1048576 json=`api`*
**pg = > web.page title="mw"**
**app = > web.app page=`pg`**
**app = > `app`.configure cors=`cors` security=`sec` compress=True body_limit=1048576 json=`api`**
*mw = app[^middleware]*
**mw = app[^middleware]**
<!-- cors -->
*cobj = mw[^cors]*
*origins = cobj[^allow_origins]*
*o0 = origins[^1]*
**cobj = mw[^cors]**
**origins = cobj[^allow_origins]**
**o0 = origins[^1]**
1. `o0` == "https://a.example"
> print text=cors-origin-ok
2. *
> print text=cors-origin-fail
*methods = cobj[^methods]*
*m1 = methods[^2]*
**methods = cobj[^methods]**
**m1 = methods[^2]**
1. `m1` == "POST"
> print text=cors-method-ok
2. *
> print text=cors-method-fail
*expose = cobj[^expose_headers]*
*e0 = expose[^1]*
**expose = cobj[^expose_headers]**
**e0 = expose[^1]**
1. `e0` == "X-Total"
> print text=cors-expose-ok
2. *
> print text=cors-expose-fail
*cred = cobj[^credentials]*
**cred = cobj[^credentials]**
1. `cred`
> print text=cors-cred-ok
2. *
@@ -84,14 +84,14 @@ import sys:lib/sys.mq.md
<!-- security -->
*secmap = mw[^security]*
*frame = secmap[^X-Frame-Options]*
**secmap = mw[^security]**
**frame = secmap[^X-Frame-Options]**
1. `frame` == "DENY"
> print text=security-frame-ok
2. *
> print text=security-frame-fail
*csp = secmap[^Content-Security-Policy]*
**csp = secmap[^Content-Security-Policy]**
1. `csp` == "default-src 'self'"
> print text=security-csp-ok
2. *
@@ -99,13 +99,13 @@ import sys:lib/sys.mq.md
<!-- compress / body_limit -->
*comp = mw[^compress]*
**comp = mw[^compress]**
1. `comp`
> print text=compress-ok
2. *
> print text=compress-fail
*bl = mw[^body_limit]*
**bl = mw[^body_limit]**
1. `bl` == 1048576
> print text=body-limit-ok
2. *
@@ -113,34 +113,34 @@ import sys:lib/sys.mq.md
<!-- json routes -->
*jmap = mw[^json_routes]*
*posts = jmap[^api/posts]*
*pok = posts[^method]*
**jmap = mw[^json_routes]**
**posts = jmap[^api/posts]**
**pok = posts[^method]**
1. `pok` == "GET"
> print text=json-get-ok
2. *
> print text=json-get-fail
*ptable = posts[^table]*
**ptable = posts[^table]**
1. `ptable` == "articles"
> print text=json-table-ok
2. *
> print text=json-table-fail
*porder = posts[^order]*
**porder = posts[^order]**
1. `porder` == "-created_at"
> print text=json-order-ok
2. *
> print text=json-order-fail
*plimit = posts[^limit]*
**plimit = posts[^limit]**
1. `plimit` == 20
> print text=json-limit-ok
2. *
> print text=json-limit-fail
*pub = jmap[^api/publish]*
*pmethod = pub[^method]*
**pub = jmap[^api/publish]**
**pmethod = pub[^method]**
1. `pmethod` == "POST"
> print text=json-post-ok
2. *
+40 -40
View File
@@ -10,7 +10,7 @@ import sys:lib/sys.mq.md
<!-- load web plugin so ABI primitives are registered -->
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
@@ -27,36 +27,36 @@ import sys:lib/sys.mq.md
<!-- session CRUD -->
*sess = > web_session_new ttl_sec=120*
*sid = sess[^id]*
**sess = > web_session_new ttl_sec=120**
**sid = sess[^id]**
1. `sid` != ""
> print text=session-new-ok
2. *
> print text=session-new-fail
*set1 = > web_session_set id=`sid` key="theme" value="dark"*
*ok1 = set1[^ok]*
**set1 = > web_session_set id=`sid` key="theme" value="dark"**
**ok1 = set1[^ok]**
1. `ok1`
> print text=session-set-ok
2. *
> print text=session-set-fail
*get1 = > web_session_get id=`sid` key="theme"*
*v1 = get1[^value]*
**get1 = > web_session_get id=`sid` key="theme"**
**v1 = get1[^value]**
1. `v1` == "dark"
> print text=session-get-ok
2. *
> print text=session-get-fail
*del1 = > web_session_del id=`sid` key="theme"*
*ok2 = del1[^ok]*
**del1 = > web_session_del id=`sid` key="theme"**
**ok2 = del1[^ok]**
1. `ok2`
> print text=session-del-ok
2. *
> print text=session-del-fail
*get2 = > web_session_get id=`sid` key="theme"*
*ok3 = get2[^ok]*
**get2 = > web_session_get id=`sid` key="theme"**
**ok3 = get2[^ok]**
1. `ok3`
> print text=session-del-confirm-fail
2. *
@@ -64,44 +64,44 @@ import sys:lib/sys.mq.md
<!-- auth login/check/logout -->
*login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120*
*lok = login[^ok]*
**login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120**
**lok = login[^ok]**
1. `lok`
> print text=auth-login-ok
2. *
> print text=auth-login-fail
*sid2 = login[^session_id]*
*check = > web_auth_check session_id=`sid2`*
*cok = check[^ok]*
**sid2 = login[^session_id]**
**check = > web_auth_check session_id=`sid2`**
**cok = check[^ok]**
1. `cok`
> print text=auth-check-ok
2. *
> print text=auth-check-fail
*badlogin = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120*
*bok = badlogin[^ok]*
**badlogin = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120**
**bok = badlogin[^ok]**
1. `bok`
> print text=auth-bad-should-fail
2. *
> print text=auth-bad-ok
*zhlogin = > web_auth_login username="站长" password="pw123" users=`users` session_ttl=120*
*zhok = zhlogin[^ok]*
**zhlogin = > web_auth_login username="站长" password="pw123" users=`users` session_ttl=120**
**zhok = zhlogin[^ok]**
1. `zhok`
> print text=auth-zh-ok
2. *
> print text=auth-zh-fail
*logout = > web_auth_logout session_id=`sid2`*
*dok = logout[^ok]*
**logout = > web_auth_logout session_id=`sid2`**
**dok = logout[^ok]**
1. `dok`
> print text=auth-logout-ok
2. *
> print text=auth-logout-fail
*check2 = > web_auth_check session_id=`sid2`*
*cok2 = check2[^ok]*
**check2 = > web_auth_check session_id=`sid2`**
**cok2 = check2[^ok]**
1. `cok2`
> print text=auth-logout-confirm-fail
2. *
@@ -109,21 +109,21 @@ import sys:lib/sys.mq.md
<!-- route ws + app auth (offline) -->
*pg = > web.page title="ws-test"*
*app = > web.app page=`pg` admin=True*
*app = > `app`.route_ws path="/live" echo=True*
*routes = app[^ws_routes]*
*has_live = routes[^/live]*
**pg = > web.page title="ws-test"**
**app = > web.app page=`pg` admin=True**
**app = > `app`.route_ws path="/live" echo=True**
**routes = app[^ws_routes]**
**has_live = routes[^/live]**
1. `has_live`
> print text=ws-route-ok
2. *
> print text=ws-route-fail
*app = > `app`.auth users=`users` session_ttl=120*
*authobj = app[^auth]*
*ausers = authobj[^users]*
*au1 = ausers[^1][^用户]*
*ou1 = users[^1][^用户]*
**app = > `app`.auth users=`users` session_ttl=120**
**authobj = app[^auth]**
**ausers = authobj[^users]**
**au1 = ausers[^1][^用户]**
**ou1 = users[^1][^用户]**
1. `au1` == `ou1`
> print text=app-auth-ok
2. *
@@ -131,17 +131,17 @@ import sys:lib/sys.mq.md
<!-- via ext/web author surface -->
*authz = > web.auth users=`users` session_ttl=120*
*login2 = > `authz`.login username="admin" password="secret"*
*lok2 = login2[^ok]*
**authz = > web.auth users=`users` session_ttl=120**
**login2 = > `authz`.login username="admin" password="secret"**
**lok2 = login2[^ok]**
1. `lok2`
> print text=ext-auth-ok
2. *
> print text=ext-auth-fail
*ws = > web.ws timeout_sec=1*
*badurl = > `ws`.connect url="ws://127.0.0.1:1" message="hi"*
*bwok = badurl[^ok]*
**ws = > web.ws timeout_sec=1**
**badurl = > `ws`.connect url="ws://127.0.0.1:1" message="hi"**
**bwok = badurl[^ok]**
1. `bwok`
> print text=ws-connect-should-fail
2. *
+6 -6
View File
@@ -7,17 +7,17 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
> sys.exit code=1
*blob = > web.storage url="file:web-fixtures/data/p3-live-blobs"*
**blob = > web.storage url="file:web-fixtures/data/p3-live-blobs"**
> `blob`.put key="uploads/hello.txt" body="etag-body" content_type="text/plain"
*pg = > web.page title="p3-live"*
*app = > web.app page=`pg` port=18131*
*app = > `app`.download path="/_media/{*key}" storage=`blob` disposition="inline"*
*app = > `app`.gallery path="/gallery" storage=`blob` prefix="uploads/" title="P3 Gallery" download_base="/_media"*
**pg = > web.page title="p3-live"**
**app = > web.app page=`pg` port=18131**
**app = > `app`.download path="/_media/{*key}" storage=`blob` disposition="inline"**
**app = > `app`.gallery path="/gallery" storage=`blob` prefix="uploads/" title="P3 Gallery" download_base="/_media"**
> `app`.listen
+21 -21
View File
@@ -8,13 +8,13 @@ import json:lib/json.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
> sys.exit code=1
*store = > web.db url="sqlite:web-fixtures/data/p3-smoke.db"*
**store = > web.db url="sqlite:web-fixtures/data/p3-smoke.db"**
> `store`.exec sql="DROP TABLE IF EXISTS comments"
> `store`.exec sql="DROP TABLE IF EXISTS posts"
@@ -47,24 +47,24 @@ import json:lib/json.mq.md
> `store`.insert table="posts" rows=`rows`
*got = > `store`.get table="posts" id=1*
*ca = got[^created_at]*
**got = > `store`.get table="posts" id=1**
**ca = got[^created_at]**
1. `ca`
> print text=audit-insert-ok
2. *
> print text=audit-insert-fail
*upd = > json.parse text={"title":"Hello P3b"}*
**upd = > json.parse text={"title":"Hello P3b"}**
> `store`.update table="posts" id=1 row=`upd`
*got2 = > `store`.get table="posts" id=1*
*ua2 = got2[^updated_at]*
**got2 = > `store`.get table="posts" id=1**
**ua2 = got2[^updated_at]**
1. `ua2`
> print text=audit-update-ok
2. *
> print text=audit-update-fail
*fk = > `store`.query sql="SELECT sql FROM sqlite_master WHERE type='table' AND name='comments'"*
*fkddl = fk[^rows][^1][^sql]*
**fk = > `store`.query sql="SELECT sql FROM sqlite_master WHERE type='table' AND name='comments'"**
**fkddl = fk[^rows][^1][^sql]**
1. `fkddl`
> print text=fk-ok
2. *
@@ -77,29 +77,29 @@ import json:lib/json.mq.md
| admin | secret | admin |
| alice | secret | author |
*login = > web_auth_login username="alice" password="secret" users=`users` session_ttl=120*
*role = login[^role]*
**login = > web_auth_login username="alice" password="secret" users=`users` session_ttl=120**
**role = login[^role]**
1. `role` == "author"
> print text=rbac-login-ok
2. *
> print text=rbac-login-fail
*pg = > web.page title="p3"*
*app = > web.app page=`pg` port=18130*
*app = > `app`.auth users=`users`*
*app = > `app`.gate path="/write*" roles="admin,author"*
*gates = app[^gates]*
*ng = > len value=`gates`*
**pg = > web.page title="p3"**
**app = > web.app page=`pg` port=18130**
**app = > `app`.auth users=`users`**
**app = > `app`.gate path="/write*" roles="admin,author"**
**gates = app[^gates]**
**ng = > len value=`gates`**
1. `ng` >= 2
> print text=rbac-gate-ok
2. *
> print text=rbac-gate-fail
*blob = > web.storage url="file:web-fixtures/data/p3-gallery"*
**blob = > web.storage url="file:web-fixtures/data/p3-gallery"**
> `blob`.put key="uploads/a.txt" body="hi" content_type="text/plain"
*app = > `app`.gallery path="/gallery" storage=`blob` prefix="uploads/" title="Media" download_base="/_media"*
*gal = app[^gallery_routes]*
*g = gal[^/gallery]*
**app = > `app`.gallery path="/gallery" storage=`blob` prefix="uploads/" title="Media" download_base="/_media"**
**gal = app[^gallery_routes]**
**g = gal[^/gallery]**
1. `g`
> print text=gallery-ok
2. *
+15 -15
View File
@@ -18,34 +18,34 @@ import json:lib/json.mq.md
| side.`side` | |
| foot.`foot` | |
*home = > web.page title="Home" intro="<h1>Home</h1>"*
*home = > `home`.compose_components components=`layout`*
**home = > web.page title="Home" intro="<h1>Home</h1>"**
**home = > `home`.compose_components components=`layout`**
*about = > web.page title="About" intro="<h1>About</h1>"*
*about = > `about`.compose_components components=`layout`*
**about = > web.page title="About" intro="<h1>About</h1>"**
**about = > `about`.compose_components components=`layout`**
*app = > web.app page=`home` host=127.0.0.1 port=18081*
*app = > `app`.route path="/about" page=`about`*
**app = > web.app page=`home` host=127.0.0.1 port=18081**
**app = > `app`.route path="/about" page=`about`**
*routes = > json.get value=`app` key="routes"*
*routed = > json.get value=`routes` key="/about"*
*route = > json.get value=`routed` key="_route"*
**routes = > json.get value=`app` key="routes"**
**routed = > json.get value=`routes` key="/about"**
**route = > json.get value=`routed` key="_route"**
1. `route` == "/about"
> print text=route-stamp-ok
2. *
> print text=route-stamp-fail
*home_html = > `home`.render*
*home_chunks = > split value=`home_html` sep="/_part/"*
*hn = > len value=`home_chunks`*
**home_html = > `home`.render**
**home_chunks = > split value=`home_html` sep="/_part/"**
**hn = > len value=`home_chunks`**
1. `hn` >= 2
> print text=home-part-ok
2. *
> print text=home-part-fail
*about_html = > `routed`.render*
*about_chunks = > split value=`about_html` sep="/about/_part/"*
*an = > len value=`about_chunks`*
**about_html = > `routed`.render**
**about_chunks = > split value=`about_html` sep="/about/_part/"**
**an = > len value=`about_chunks`**
1. `an` >= 2
> print text=route-part-ok
2. *
+18 -18
View File
@@ -8,7 +8,7 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
@@ -26,49 +26,49 @@ import sys:lib/sys.mq.md
|------|--------|-----|------|--------|
| /api/echo | POST | demo.echo | json | json |
*pg = > web.page title="proxy-invoke"*
*app = > web.app page=`pg`*
*app = > `app`.configure proxy=`proxy_tbl` invoke=`invoke_tbl`*
*app = > `app`.proxy path="/v1/stream" upstream="https://example.com/v1/chat" stream=True headers_from_env="TOKEN=X-Token"*
*app = > `app`.invoke path="/api/ping" fn="demo.ping" method="GET" body="query"*
**pg = > web.page title="proxy-invoke"**
**app = > web.app page=`pg`**
**app = > `app`.configure proxy=`proxy_tbl` invoke=`invoke_tbl`**
**app = > `app`.proxy path="/v1/stream" upstream="https://example.com/v1/chat" stream=True headers_from_env="TOKEN=X-Token"**
**app = > `app`.invoke path="/api/ping" fn="demo.ping" method="GET" body="query"**
*proutes = app[^proxy_routes]*
*chat = proutes[^proxy/chat]*
*up = chat[^upstream]*
**proutes = app[^proxy_routes]**
**chat = proutes[^proxy/chat]**
**up = chat[^upstream]**
1. `up` == "$OPENAI_BASE_URL"
> print text=proxy-table-ok
2. *
> print text=proxy-table-fail
*stream = chat[^stream]*
**stream = chat[^stream]**
1. `stream`
> print text=proxy-stream-ok
2. *
> print text=proxy-stream-fail
*hdr = chat[^headers_from_env]*
**hdr = chat[^headers_from_env]**
1. `hdr` == "OPENAI_API_KEY=Authorization"
> print text=proxy-env-ok
2. *
> print text=proxy-env-fail
*v1 = proutes[^v1/stream]*
*v1u = v1[^upstream]*
**v1 = proutes[^v1/stream]**
**v1u = v1[^upstream]**
1. `v1u` == "https://example.com/v1/chat"
> print text=proxy-method-ok
2. *
> print text=proxy-method-fail
*iroutes = app[^invoke_routes]*
*echo = iroutes[^api/echo]*
*efn = echo[^fn]*
**iroutes = app[^invoke_routes]**
**echo = iroutes[^api/echo]**
**efn = echo[^fn]**
1. `efn` == "demo.echo"
> print text=invoke-table-ok
2. *
> print text=invoke-table-fail
*ping = iroutes[^api/ping]*
*pm = ping[^method]*
**ping = iroutes[^api/ping]**
**pm = ping[^method]**
1. `pm` == "GET"
> print text=invoke-method-ok
2. *
+9 -9
View File
@@ -7,15 +7,15 @@ import json:lib/json.mq.md
# main
*home = > web.page title="Home" intro="<h1>Home</h1>"*
*about = > web.page title="About" intro="<h1>About</h1>"*
*app = > web.app page=`home` host=127.0.0.1 port=18081*
*app = > `app`.route path="/about" page=`about`*
*app = > `app`.route path="docs" page=`about`*
**home = > web.page title="Home" intro="<h1>Home</h1>"**
**about = > web.page title="About" intro="<h1>About</h1>"**
**app = > web.app page=`home` host=127.0.0.1 port=18081**
**app = > `app`.route path="/about" page=`about`**
**app = > `app`.route path="docs" page=`about`**
*routes = > json.get value=`app` key="routes"*
*about_page = > json.get value=`routes` key="/about"*
*docs_page = > json.get value=`routes` key="/docs"*
**routes = > json.get value=`app` key="routes"**
**about_page = > json.get value=`routes` key="/about"**
**docs_page = > json.get value=`routes` key="/docs"**
1. `about_page`
> print text=about-ok
@@ -27,7 +27,7 @@ import json:lib/json.mq.md
2. *
> print text=docs-fail
*html = > `about`.render*
**html = > `about`.render**
1. `html`
> print text=render-ok
2. *
+7 -7
View File
@@ -10,7 +10,7 @@ import sys:lib/sys.mq.md
<!-- load web plugin -->
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
@@ -18,8 +18,8 @@ import sys:lib/sys.mq.md
<!-- argon2 hash must be non-empty PHC string -->
*hash = > web_password_hash password="secret"*
*h = hash[^hash]*
**hash = > web_password_hash password="secret"**
**h = hash[^hash]**
1. `h` != ""
> print text=hash-ok
2. *
@@ -33,15 +33,15 @@ import sys:lib/sys.mq.md
|----|------|------|
| 1 | admin | secret |
*login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120*
*lok = login[^ok]*
**login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120**
**lok = login[^ok]**
1. `lok`
> print text=auth-login-ok
2. *
> print text=auth-login-fail
*bad = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120*
*bok = bad[^ok]*
**bad = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120**
**bok = bad[^ok]**
1. `bok`
> print text=auth-bad-should-fail
2. *
+8 -8
View File
@@ -8,8 +8,8 @@ import json:lib/json.mq.md
# main
*store = > web.db url="sqlite:web-fixtures/data/select-smoke.db"*
*schema = > articles.schema*
**store = > web.db url="sqlite:web-fixtures/data/select-smoke.db"**
**schema = > articles.schema**
> `store`.init name=articles fields=`schema`
> `store`.exec sql="DELETE FROM articles"
@@ -29,8 +29,8 @@ import json:lib/json.mq.md
|-------|------|
| Alpha | first |
*hit = > `store`.select table="articles" where=`eq` limit=50*
*n = > len value=`hit`*
**hit = > `store`.select table="articles" where=`eq` limit=50**
**n = > len value=`hit`**
1. `n` == 1
> print text=map-where-ok
2. *
@@ -42,15 +42,15 @@ import json:lib/json.mq.md
|------|------|-----|
| title | like | %Alpha% |
*like_rows = > `store`.select table="articles" where=`filt` limit=50*
*ln = > len value=`like_rows`*
**like_rows = > `store`.select table="articles" where=`filt` limit=50**
**ln = > len value=`like_rows`**
1. `ln` == 2
> print text=like-ok
2. *
> print text=like-fail
*all = > `store`.select table="articles" limit=50*
*an = > len value=`all`*
**all = > `store`.select table="articles" limit=50**
**an = > len value=`all`**
1. `an` == 3
> print text=all-ok
2. *
+16 -16
View File
@@ -13,14 +13,14 @@ import json:lib/json.mq.md
# main
*store = > web.db url="sqlite:web-fixtures/data/smoke.db"*
*fields = > articles.schema*
**store = > web.db url="sqlite:web-fixtures/data/smoke.db"**
**fields = > articles.schema**
> `store`.init name=articles fields=`fields`
*rows = > `store`.select table="articles" limit=1*
**rows = > `store`.select table="articles" limit=1**
1. `rows`
*_ = 1*
**_ = 1**
2. *
*seed = > articles.seed*
**seed = > articles.seed**
> `store`.insert table=articles rows=`seed`
`home` =
@@ -38,43 +38,43 @@ import json:lib/json.mq.md
| title | articles.`articles`.title | shell.`card_title` |
| body | articles.`articles`.body | shell.`card_body` |
*page = > web.page title="smoke" intro="<h1>smoke</h1>"*
*page = > `page`.compose_components components=`home`*
*page = > `page`.compose_main main=`index`*
*html = > `page`.render db=`store`*
**page = > web.page title="smoke" intro="<h1>smoke</h1>"**
**page = > `page`.compose_components components=`home`**
**page = > `page`.compose_main main=`index`**
**html = > `page`.render db=`store`**
1. `html`
> print text=render-ok
2. *
> print text=render-fail
*nav = > json.get value=`page` key="nav"*
**nav = > json.get value=`page` key="nav"**
1. `nav`
> print text=compose-nav-ok
2. *
> print text=compose-nav-fail
*side = > json.get value=`page` key="sidebar"*
**side = > json.get value=`page` key="sidebar"**
1. `side`
> print text=compose-side-ok
2. *
> print text=compose-side-fail
*css = > json.get value=`page` key="styles_css"*
**css = > json.get value=`page` key="styles_css"**
1. `css`
> print text=styles-ok
2. *
> print text=styles-fail
*parts = > json.get value=`page` key="parts"*
*index_part = > json.get value=`parts` key="index"*
**parts = > json.get value=`page` key="parts"**
**index_part = > json.get value=`parts` key="index"**
1. `index_part`
> print text=compose-ok
2. *
> print text=compose-fail
*got = > `store`.get table="articles" id=1*
*title = > json.get value=`got` key="title"*
**got = > `store`.get table="articles" id=1**
**title = > json.get value=`got` key="title"**
1. `title` == "Hello Marqdo"
> print text=db-ok
2. *
+7 -7
View File
@@ -7,24 +7,24 @@ import json:lib/json.mq.md
# main
*home = > web.page title="Home"*
*app = > web.app page=`home` host=127.0.0.1 port=18081*
*app = > `app`.static dir="web-fixtures/public" mount="/static"*
**home = > web.page title="Home"**
**app = > web.app page=`home` host=127.0.0.1 port=18081**
**app = > `app`.static dir="web-fixtures/public" mount="/static"**
*dir = > json.get value=`app` key="static_dir"*
**dir = > json.get value=`app` key="static_dir"**
1. `dir` == "web-fixtures/public"
> print text=dir-ok
2. *
> print text=dir-fail
*mount = > json.get value=`app` key="static_mount"*
**mount = > json.get value=`app` key="static_mount"**
1. `mount` == "/static"
> print text=mount-ok
2. *
> print text=mount-fail
*app2 = > `app`.static dir="assets" mount="/assets"*
*m2 = > json.get value=`app2` key="static_mount"*
**app2 = > `app`.static dir="assets" mount="/assets"**
**m2 = > json.get value=`app2` key="static_mount"**
1. `m2` == "/assets"
> print text=custom-ok
2. *
+7 -7
View File
@@ -8,13 +8,13 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
> sys.exit code=1
*blob = > web.storage url="file:tests/ext/web-fixtures/data/upload-live-blobs"*
**blob = > web.storage url="file:tests/ext/web-fixtures/data/upload-live-blobs"**
`types` =
@@ -23,9 +23,9 @@ import sys:lib/sys.mq.md
| text/plain | txt |
| image/png | png |
*pg = > web.page title="upload-live"*
*app = > web.app page=`pg` port=18101*
*app = > `app`.configure body_limit=1048576*
*app = > `app`.upload path="/_upload" field="file" storage=`blob` prefix="live/" max_bytes=1024 types=`types`*
*app = > `app`.download path="/_media/{*key}" storage=`blob` disposition="attachment"*
**pg = > web.page title="upload-live"**
**app = > web.app page=`pg` port=18101**
**app = > `app`.configure body_limit=1048576**
**app = > `app`.upload path="/_upload" field="file" storage=`blob` prefix="live/" max_bytes=1024 types=`types`**
**app = > `app`.download path="/_media/{*key}" storage=`blob` disposition="attachment"**
> `app`.listen
+17 -17
View File
@@ -8,7 +8,7 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
@@ -21,40 +21,40 @@ import sys:lib/sys.mq.md
| image/png | png |
| text/plain | txt |
*m = > web.media*
*ok = > `m`.validate filename="a.png" content_type="image/png" size=100 max_bytes=1000 types=`types`*
*ook = ok[^ok]*
**m = > web.media**
**ok = > `m`.validate filename="a.png" content_type="image/png" size=100 max_bytes=1000 types=`types`**
**ook = ok[^ok]**
1. `ook`
> print text=validate-ok
2. *
> print text=validate-fail
*bad = > `m`.validate filename="a.exe" content_type="application/octet-stream" size=100 max_bytes=1000 types=`types`*
*bok = bad[^ok]*
**bad = > `m`.validate filename="a.exe" content_type="application/octet-stream" size=100 max_bytes=1000 types=`types`**
**bok = bad[^ok]**
1. `bok`
> print text=reject-type-fail
2. *
> print text=reject-type-ok
*big = > `m`.validate filename="a.png" content_type="image/png" size=9000 max_bytes=1000 types=`types`*
*gok = big[^ok]*
**big = > `m`.validate filename="a.png" content_type="image/png" size=9000 max_bytes=1000 types=`types`**
**gok = big[^ok]**
1. `gok`
> print text=reject-size-fail
2. *
> print text=reject-size-ok
*blob = > web.storage url="file:tests/ext/web-fixtures/data/upload-blobs"*
*m = > web.media storage=`blob`*
*saved = > `m`.save path="tests/ext/web-fixtures/upload/sample.txt" content_type="text/plain" prefix="smoke/"*
*sok = saved[^ok]*
*skey = saved[^key]*
**blob = > web.storage url="file:tests/ext/web-fixtures/data/upload-blobs"**
**m = > web.media storage=`blob`**
**saved = > `m`.save path="tests/ext/web-fixtures/upload/sample.txt" content_type="text/plain" prefix="smoke/"**
**sok = saved[^ok]**
**skey = saved[^key]**
1. `sok`
> print text=save-ok
2. *
> print text=save-fail
*got = > `blob`.get key=`skey`*
*body = got[^body]*
**got = > `blob`.get key=`skey`**
**body = got[^body]**
1. `body` == "hello-upload"
> print text=save-roundtrip-ok
2. *
@@ -69,8 +69,8 @@ import sys:lib/sys.mq.md
| title | Title | text |
| file | File | file |
*frm = > web.form table="x" fields=`fields`*
*html = > `frm`.render id="up"*
**frm = > web.form table="x" fields=`fields`**
**html = > `frm`.render id="up"**
1. `html`
> print text=form-file-ok
2. *
+20 -20
View File
@@ -7,13 +7,13 @@ import sys:lib/sys.mq.md
# main
*p = > plugin.native_path name="web"*
**p = > plugin.native_path name="web"**
1. `p`
> plugin.load path=`p`
2. *
> sys.exit code=1
*store = > web.db url="sqlite:web-fixtures/data/w7-smoke.db"*
**store = > web.db url="sqlite:web-fixtures/data/w7-smoke.db"**
> `store`.exec sql="DROP TABLE IF EXISTS posts"
`fields` =
@@ -26,8 +26,8 @@ import sys:lib/sys.mq.md
> `store`.init name=posts fields=`fields`
*idx = > `store`.query sql="SELECT name FROM sqlite_master WHERE type='index' AND tbl_name='posts'"*
*nidx = > len value=idx[^rows]*
**idx = > `store`.query sql="SELECT name FROM sqlite_master WHERE type='index' AND tbl_name='posts'"**
**nidx = > len value=idx[^rows]**
1. `nidx` >= 1
> print text=unique-ok
2. *
@@ -40,42 +40,42 @@ import sys:lib/sys.mq.md
| / | 2026-08-28 |
| /about | 2026-08-28 |
*sm = > web_sitemap_build base="https://example.com" items=`items`*
*xml = sm[^xml]*
**sm = > web_sitemap_build base="https://example.com" items=`items`**
**xml = sm[^xml]**
1. `xml`
> print text=sitemap-ok
2. *
> print text=sitemap-fail
*pg = > web.page title="w7"*
*notfound = > web.page title="Missing"*
*app = > web.app page=`pg` port=18120*
*app = > `app`.configure cache_control="public, max-age=60" access_log=False*
*app = > `app`.redirect from="/old" to="/new" permanent=True*
*app = > `app`.error_page status=404 page=`notfound`*
*app = > `app`.sitemap path="/sitemap.xml" base="https://example.com" items=`items`*
*app = > `app`.robots sitemap="https://example.com/sitemap.xml"*
*rd = app[^redirects]*
*has = rd[^/old]*
**pg = > web.page title="w7"**
**notfound = > web.page title="Missing"**
**app = > web.app page=`pg` port=18120**
**app = > `app`.configure cache_control="public, max-age=60" access_log=False**
**app = > `app`.redirect from="/old" to="/new" permanent=True**
**app = > `app`.error_page status=404 page=`notfound`**
**app = > `app`.sitemap path="/sitemap.xml" base="https://example.com" items=`items`**
**app = > `app`.robots sitemap="https://example.com/sitemap.xml"**
**rd = app[^redirects]**
**has = rd[^/old]**
1. `has`
> print text=redirect-ok
2. *
> print text=redirect-fail
*rb = app[^robots_body]*
**rb = app[^robots_body]**
1. `rb`
> print text=robots-ok
2. *
> print text=robots-fail
*mw = app[^middleware]*
*cc = mw[^cache_control]*
**mw = app[^middleware]**
**cc = mw[^cache_control]**
1. `cc` == "public, max-age=60"
> print text=cache-control-ok
2. *
> print text=cache-control-fail
*p404 = app[^page_404]*
**p404 = app[^page_404]**
1. `p404`
> print text=error-page-ok
2. *
Loaded 100 of 324 files, more files were not shown because too many files have changed in this diff. Show more