feat(agent): A1 OKF reuse flywheel — list_tasks curation and plan match

Enrich list_tasks for soft_match curation; expose match/score on plan hits; add offline plan-hit gold.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-28 16:53:27 +08:00
1 parent d7be903297
commit 07ab7d52c6
7 files changed
+190 -10

No files matched your search

+1
View File
@@ -3,6 +3,7 @@
## Unreleased
### Added
- **`ext/agent` A1(OKF 复用飞轮)**: `agent_kb_list_tasks` 返回 description/aliases/status/llm_free/hits;`plan` 命中路径暴露 `match`/`score`(summary 含 match kind);soft_match 策展提示带 status/llm_free/description;view plan 卡显示 match。金样 `agent-kb-plan-hit`。路线 [ext-agent-optimize.md](doc/roadmap/ext-agent-optimize.md)。
- **`ext/web` 样式装配(`web_style` / `网页.样式装配`)**: 样式即数据表格 —— GFM 样式表(`|选择器|属性|值|`,可用 `|媒体|` 列分组进 `@media` 块)经 `样式装配` 函数转成 CSS 文本,再拼装成完整主题。替代"整段手写 CSS 字符串"的写法,贯彻 文档即代码。见 [marqdo-blog](examples/marqdo-blog/styles/theme.mq.md)。
- **网络能力调研(`doc/design/web-net-capabilities.md`)**: 盘点 `ext/web` + `plugins/web` + `lib/net` 现状,对照主流语言网络栈(FastAPI / Express / Flask / axum),给出「开发一个完整 Web 项目」所需能力的差距清单与分波次补强路线(W1–W7 + P3,**2026-08-28 已全部落地**)。
- **AI Skill + 文档(ext/web 完结复核)**: `skills/marqdo/` 与 `.cursor/skills/marqdo/` 增加 **ext/web 动态站** 专节(硬规则、API 摘要、§13 最小站点样例);`doc/design/web-net-capabilities.md` 结论/对照表与 W7+P3 实现对齐;`doc/design/ai-skill.md` 更新用途说明。
+3 -3
View File
@@ -2,7 +2,7 @@
| | |
|---|---|
| 状态 | **进行中 · A0 大部完成**(护栏 + soft + solidify 单测/金样;多轮 CONTINUE 离线金样) |
| 状态 | **进行中 · A0/A1 完成**(A1:list_tasks 策展字段;plan hit 暴露 match/score;金样 `agent-kb-plan-hit`) |
| 日期 | 2026-08-28 |
| 调研 | [agent-frameworks-and-marqdo.md](../research/agent-frameworks-and-marqdo.md) |
| 设计 | [ext-agent.md](../design/ext-agent.md) · [ext-agent-plan.md](../design/ext-agent-plan.md) · [ext-agent-parent.md](../design/ext-agent-parent.md) · [okf.md](../design/okf.md) |
@@ -24,8 +24,8 @@
| 波次 | 主题 | 验收线索 |
|------|------|----------|
| **A0** | 工作簿补丁 / 固化可靠性 | **mostly done** — 整文件 FIND 护栏;`soft` 仅 miss;decompose `n` 检查;`workbook_solidify` 单测;金样 `agent-workbook-patch-a0`(双 CONTINUE + solidify) |
| **A1** | OKF 复用飞轮(lookup / near / soft_match UX) | 二次同类 `plan` 走快路径;策展可读 |
| **A0** | 工作簿补丁 / 固化可靠性 | **done** — 整文件 FIND 护栏;`soft` 仅 miss;decompose `n` 检查;`workbook_solidify` 单测;金样 `agent-workbook-patch-a0`(双 CONTINUE + solidify) |
| **A1** | OKF 复用飞轮(lookup / near / soft_match UX) | **done** — `list_tasks` 含 description/aliases/status/llm_free/hits;`plan` 命中路径暴露 `match`/`score`;soft_match 策展行含 meta;view plan 卡显示 match;金样 `agent-kb-plan-hit`(exact hit + near soft-hit) |
| **A2** | 过程可见(stream + view 过程卡) | 对齐 [agent-streaming.md](agent-streaming.md);真相仍可写回 |
| **A3** | 上下文预算(源码/Skill 渐进披露) | 长 runbook 不爆窗,仍保持「源码即提示」 |
| **A4** | 可选:RAG/MCP 工具适配器 | 金样调用外置检索,权威仍是 `.mq.md` |
+48 -6
View File
@@ -940,24 +940,48 @@ Parse `SLUG: …` / `标识:…` after a soft-match REUSE decision.
+ `goal`
+ `tasks`
Short parent prompt: REUSE+SLUG or NEW only. Candidates may include lexical `score` (prefer higher).
Short parent prompt: REUSE+SLUG or NEW only. Candidates may include lexical `score` (prefer higher). `list_tasks` rows may also carry `description` / `status` / `llm_free`.
*esc = > json.parse text={"a":"\n\n--- goal ---\n","b":"\n\n--- candidate tasks (slug | title | score) ---\n","c":"\n\n--- how to act ---\nExact reuse miss; candidates are ranked by local n-gram score when present. Prefer higher scores. Reply with ONE protocol only:\nDECISION: REUSE\nSLUG: <exact-slug-from-list>\nor\nDECISION: NEW\nNo other prose.\n","nl":"\n","sep":" | ","sp":"score="}*
*esc = > json.parse text={"a":"\n\n--- goal ---\n","b":"\n\n--- candidate tasks (slug | title | meta) ---\n","c":"\n\n--- how to act ---\nExact reuse miss; candidates are ranked by local n-gram score when present. Prefer higher scores and llm_free=true skills. Reply with ONE protocol only:\nDECISION: REUSE\nSLUG: <exact-slug-from-list>\nor\nDECISION: NEW\nNo other prose.\n","nl":"\n","sep":" | ","sp":"score=","st":"status=","lf":"llm_free="}*
*a = > json.get value=`esc` key="a"*
*b = > json.get value=`esc` key="b"*
*c = > json.get value=`esc` key="c"*
*nl = > json.get value=`esc` key="nl"*
*sep = > json.get value=`esc` key="sep"*
*sp = > json.get value=`esc` key="sp"*
*st = > json.get value=`esc` key="st"*
*lf = > json.get value=`esc` key="lf"*
*lines = > json.parse text=[]*
- [`t`](`tasks`)
*slug = > json.get value=`t` key="slug"*
*title = > json.get value=`t` key="title"*
*row = slug + sep + title*
*score = > json.get value=`t` key="score"*
1. `score`
*row = slug + sep + title + sep + sp + score*
*row = row + sep + sp + score*
2. *
*row = slug + sep + title*
*_ = 1*
*status = > json.get value=`t` key="status"*
1. `status`
*row = row + sep + st + status*
2. *
*_ = 1*
*free = > json.get value=`t` key="llm_free"*
1. `free` == True
*row = row + sep + lf + "true"*
2. `free` == true
*row = row + sep + lf + "true"*
3. `free` == False
*row = row + sep + lf + "false"*
4. `free` == false
*row = row + sep + lf + "false"*
5. *
*_ = 1*
*desc = > json.get value=`t` key="description"*
1. `desc`
*row = row + sep + desc*
2. *
*_ = 1*
*lines = > json.append list=`lines` item=`row`*
*catalog = > join value=`lines` sep=`nl`*
*p = "Soft-match: same task intent?"*
@@ -1490,11 +1514,20 @@ Reuse lookup: exact → alias → canonicalize → optional local n-gram `near`
*out = > json.set map=`out` key="workbook" value=`path`*
*out = > json.set map=`out` key="rounds" value=1*
*out = > json.set map=`out` key="cache" value=`cache_label`*
*out = > json.set map=`out` key="match" value=`match_kind`*
*hit_score = > json.get value=`hit` key="score"*
1. `hit_score`
*out = > json.set map=`out` key="score" value=`hit_score`*
2. *
*_ = 1*
*sk = > json.get value=`hit` key="skill"*
*out = > json.set map=`out` key="skill" value=`sk`*
*st = > json.get value=`hit` key="status"*
*out = > json.set map=`out` key="skill_status" value=`st`*
*sum = "OKF llm_free skill hit; spawned resource"*
*sum = > json.parse text={"a":"OKF llm_free skill hit (","b":"); spawned resource"}*
*suma = > json.get value=`sum` key="a"*
*sumb = > json.get value=`sum` key="b"*
*sum = suma + match_kind + sumb*
*out = > json.set map=`out` key="summary" value=`sum`*
*out = > json.set map=`out` key="observation" value=`last_obs`*
*out = > json.set map=`out` key="result" value=`child_val`*
@@ -1537,11 +1570,20 @@ Reuse lookup: exact → alias → canonicalize → optional local n-gram `near`
*out = > json.set map=`out` key="workbook" value=`path`*
*out = > json.set map=`out` key="rounds" value=1*
*out = > json.set map=`out` key="cache" value=`cache_label`*
*out = > json.set map=`out` key="match" value=`match_kind`*
*hit_score = > json.get value=`hit` key="score"*
1. `hit_score`
*out = > json.set map=`out` key="score" value=`hit_score`*
2. *
*_ = 1*
*sk = > json.get value=`hit` key="skill"*
*out = > json.set map=`out` key="skill" value=`sk`*
*st = > json.get value=`hit` key="status"*
*out = > json.set map=`out` key="skill_status" value=`st`*
*sum = "OKF skill hit; spawned resource"*
*sum = > json.parse text={"a":"OKF skill hit (","b":"); spawned resource"}*
*suma = > json.get value=`sum` key="a"*
*sumb = > json.get value=`sum` key="b"*
*sum = suma + match_kind + sumb*
*out = > json.set map=`out` key="summary" value=`sum`*
*out = > json.set map=`out` key="observation" value=`last_obs`*
*out = > json.set map=`out` key="result" value=`child_val`*
+33 -1
View File
@@ -962,6 +962,7 @@ pub fn kb_list_tasks(args: &Value) -> Result<Value, String> {
.clamp(1, 200);
let root = resolve_path(kb);
let tasks_dir = root.join("concepts/tasks");
let skills_dir = root.join("concepts/skills");
let mut tasks: Vec<Value> = Vec::new();
if tasks_dir.is_dir() {
let mut ents: Vec<_> = fs::read_dir(&tasks_dir)
@@ -988,7 +989,38 @@ pub fn kb_list_tasks(args: &Value) -> Result<Value, String> {
continue;
}
let title = extract_fm_field(&src, "title").unwrap_or_else(|| slug.clone());
tasks.push(json!({ "slug": slug, "title": title }));
let description = extract_fm_field(&src, "description").unwrap_or_default();
let aliases = extract_fm_aliases(&src);
let alias_count = aliases.len() as i64;
let skill_path = skills_dir.join(format!("{slug}.md"));
let (status, llm_free, hits) = if skill_path.is_file() {
match fs::read_to_string(&skill_path) {
Ok(sk) => {
let status =
extract_fm_field(&sk, "status").unwrap_or_else(|| "stable".into());
let llm_free = extract_fm_field(&sk, "llm_free")
.map(|s| s == "true" || s == "True")
.unwrap_or(false);
let hits = extract_fm_field(&sk, "hits")
.and_then(|s| s.parse::<i64>().ok())
.unwrap_or(0);
(status, llm_free, hits)
}
Err(_) => ("unreadable".into(), false, 0),
}
} else {
("missing_skill".into(), false, 0)
};
tasks.push(json!({
"slug": slug,
"title": title,
"description": description,
"aliases": aliases,
"alias_count": alias_count,
"status": status,
"llm_free": llm_free,
"hits": hits,
}));
}
}
let count = tasks.len() as i64;
+4
View File
@@ -2306,6 +2306,7 @@ fn plan_result_card(stdout: &str, links: &LinkMode) -> String {
};
let workbook = v.get("workbook").and_then(|x| x.as_str());
let cache = v.get("cache").and_then(|x| x.as_str());
let match_kind = v.get("match").and_then(|x| x.as_str());
let rounds = v
.get("rounds")
.and_then(|x| x.as_u64())
@@ -2321,6 +2322,9 @@ fn plan_result_card(stdout: &str, links: &LinkMode) -> String {
if let Some(c) = cache {
meta.push(format!("cache={}", escape(c)));
}
if let Some(m) = match_kind {
meta.push(format!("match={}", escape(m)));
}
if let Some(r) = rounds {
meta.push(format!("rounds={r}"));
}
+87
View File
@@ -0,0 +1,87 @@
---
title: OKF plan llm_free hit + list_tasks curation (A1 offline)
description: Promote solidified workbook; plan same goal takes cache=hit; near→soft-hit; list_tasks exposes status/llm_free.
import llm:ext/ai/llm.mq.md
import agent:ext/ai/agent.mq.md
import fs:lib/fs.mq.md
import json:lib/json.mq.md
import plugin:lib/plugin.mq.md
import sys:lib/sys.mq.md
---
# main
*p = > plugin.native_path name="agent"*
1. `p`
> plugin.load path=`p`
2. *
> print text=no-agent-plugin
> 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"*
*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"*
> 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"*
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"*
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"*
1. `lf`
> print text=list-free
2. *
> print text=list-not-free
*st = > json.get value=`t0` key="status"*
> print text=`st`
*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"*
> print text=`cache`
*mk = > json.get value=`out` key="match"*
> print text=`mk`
*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`*
1. `hn` > 1
> print text=sum-exact
2. *
> print text=sum-bad
*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"*
> print text=`mk2`
*val2 = > json.get value=`out2` key="result"*
> print text=`val2`
+14
View File
@@ -2730,6 +2730,20 @@ fn ext_agent_workbook_patch_a0() {
);
}
#[test]
fn ext_agent_kb_plan_hit() {
let status = Command::new("cargo")
.args(["build", "-p", "marqdo_plugin_agent"])
.current_dir(env!("CARGO_MANIFEST_DIR"))
.status()
.expect("build agent plugin");
assert!(status.success(), "failed to build marqdo_plugin_agent");
assert_out(
"tests/ext/agent-kb-plan-hit.mq.md",
"promoted\nlist-ok\nlist-free\nstable\nlist-desc\nhit\nexact\npong\nsum-exact\nsoft-hit\nnear\npong",
);
}
#[test]
fn ext_agent_plan_observe() {
assert_out(