Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
feat(agent-plugins): ov-tasks skill for structured task handoff (#5157)
Zayn Jarvisaf11ccb1d7fc
diff --git a/agent-plugins/README.md b/agent-plugins/README.mdindex 8d678bc10..06792eb1c 100644--- a/agent-plugins/README.md+++ b/agent-plugins/README.md@@ -15,6 +15,7 @@ skills/openviking-memory/SKILL.md # teaches the model the recall + persist loskills/ov-memory-troubleshoot/ # read-only extraction troubleshootingskills/ov-experience-memory/ # retrieve and apply prior task Experienceskills/openviking-skills/ # find, use, create, and share OpenViking skills+skills/ov-tasks/ # task board: pick, execute, hand off tasks stored as OV markdown filesplugin.test.mjs # node --test conformance checks```@@ -24,6 +25,8 @@ Use `ov-memory-troubleshoot` to trace backward from a memory file to its archive`openviking-skills` covers the skills stored in OpenViking itself: how to find one with `find(context_type="skill")`, read and follow its `SKILL.md`, create or replace one with the `add_skill` MCP tool, install one from Git or a local folder, share one with the account, and move local skill folders into OpenViking when you ask. This package has no session-start hook, so there is no `<available-skills>` catalog here and the skill has the model search for a skill instead.+Use `ov-tasks` to run long or multi-agent work through a task board in OpenViking: each task is one markdown file (`viking://agent/tasks/<scope>/<id>.md`, falling back to `viking://resources/tasks` on servers that reject writes under `viking://agent`) whose header and body are the handoff, so any agent with the `ov` CLI can claim, continue, and write it back. `references/loop.sh` drives unattended ticks; see [docs/design/ov-tasks.md](../docs/design/ov-tasks.md).+Zero npm dependencies; the proxy and tests run on the Node.js standard library (Node 18+ for global `fetch`).## Install@@ -31,7 +34,7 @@ Zero npm dependencies; the proxy and tests run on the Node.js standard library (1. Have an OpenViking server reachable (see the [quickstart](../docs/en/getting-started/02-quickstart.md)); default local endpoint is `http://127.0.0.1:1933`.2. Point your Agent-Plugins-conforming client at this directory (each client has its own install command or plugin directory; consult its docs). The client will:- register the `openviking` MCP server from `mcp.json` — it runs `node <plugin>/servers/mcp-proxy.mjs` over stdio;- - discover the `openviking-memory`, `ov-memory-troubleshoot`, `ov-experience-memory`, and `openviking-skills` skills from `skills/`.+ - discover the `openviking-memory`, `ov-memory-troubleshoot`, `ov-experience-memory`, `openviking-skills`, and `ov-tasks` skills from `skills/`.3. Configure credentials (next section) and start a session. The model gains `find` / `search` / `read` / `remember` / `write` / `add_skill` and the other OpenViking MCP tools. Use `search` with `mode="context"` for server-assembled context.## Why a stdio proxy instead of a `streamable-http` entrydiff --git a/agent-plugins/skills/ov-tasks/SKILL.md b/agent-plugins/skills/ov-tasks/SKILL.mdnew file mode 100644index 000000000..3e8e4ce04--- /dev/null+++ b/agent-plugins/skills/ov-tasks/SKILL.md@@ -0,0 +1,145 @@+---+name: ov-tasks+description: Pick up, execute, and hand off long-running tasks stored as structured markdown files in OpenViking (task board under viking://agent/tasks/<scope>/). Use when the user says "ov tasks", asks to create a task on the board, hand off the current work, continue a task another agent started, or run an unattended task loop. Each task file is the handoff itself - a frontmatter header (id, status, owner, scope) plus Goal, Context, Decisions, Progress, Next, Questions, Log - so any agent with the `ov` CLI can resume it.+---++# OV Tasks++A task is one markdown file in OpenViking. The file is both the ticket and+the handoff: whoever reads it can continue the work without the previous+conversation. OpenViking stores it, indexes it (`find`/`grep`), and shares+it across every agent and user of the account. There is no other state.++```text+<root>/<scope>/<id>.md the task (header + handoff body), rewritten every turn+<root>/<scope>/archive/<id>.md optional append-only history of status transitions+```++- `<root>` is `viking://agent/tasks`. Probe it once per session with+ `ov stat viking://agent/tasks` (or `ov mkdir` when it does not exist yet);+ if the server answers `PERMISSION_DENIED` (older servers block writes under+ `viking://agent` except skills), use `viking://resources/tasks` instead.+ `$OV_TASKS_ROOT`, when set, overrides the probe. The protocol is identical,+ only the root changes.+- `<scope>` is the isolation unit (a project, repo, or team). It is a plain+ directory: `ov acl` on it decides who may read or take tasks. Create one+ with `ov mkdir <root>/<scope>` and `ov mkdir <root>/<scope>/archive`+ (`write --mode create` needs the parent directory to exist).+- `<id>` is `YYYY-MM-DD-short-slug`, unique inside the scope.++Use the `ov` CLI (works from any agent that has a shell). If the OpenViking+MCP tools `list`, `read`, `write`, `grep` are registered, they are+equivalent; never fall back to raw HTTP. Prefer the CLI for writes: a+`write` that runs into the MCP client timeout has usually still landed, so+`read` the file back before writing again.++## Task file++Copy [references/task-template.md](references/task-template.md). Header:++| field | values |+|---|---|+| `id` | `YYYY-MM-DD-short-slug`, equals the file name |+| `title` | one line |+| `status` | `open` · `in_progress` · `needs_user` · `blocked` · `done` · `cancelled` |+| `owner` | agent id currently holding the task, empty when handed off |+| `scope` | the scope directory name |+| `updated` | ISO time with offset, set on every write |++Body sections, in this order: `Goal` (done criteria checklist), `Context`+(cwd/repo/branch, key files or URIs, constraints), `Decisions` (dated, with+why; user answers land here), `Progress` (verified only, with evidence),+`Next` (ordered checklist; first unchecked box is the next action),+`Questions` (concrete questions for the user; non-empty means+`status: needs_user`), `Log` (one dated line per turn, keep the last 10).++The file is the truth. If it disagrees with the live repo, trust the repo,+fix the file, and say so in `Log`.++Write the body in the task's main language: the language the user gave the+task in, or the one an existing task already uses. Header keys and status+values stay English.++## One turn++Every turn is bounded: pick, claim, one slice, verify, write back, stop.++1. **Pick.** List runnable tasks in the scope:+ ```bash+ ov grep '^status: (open|in_progress)' -u <root>/<scope> -x <root>/<scope>/archive -o json+ ```+ Take the task the user named, else an `open` one, else an+ `in_progress` one whose `updated` is older than 2 hours (stale claim).+ Skip `in_progress` tasks another agent updated recently.+2. **Claim.** `ov read` the file. Set `status: in_progress`,+ `owner: <your agent id>`, `updated: now`, add a `Log` line, write back+ (step 5). Agent id is `$OV_TASKS_AGENT` if set, else `<tool>@<host>`+ (e.g. `codex@mbp`).+3. **Slice.** Do the first unchecked item in `Next`, or more while it stays+ one coherent, verifiable piece of work. Read `Context` and `Decisions`+ first; they are the contract from earlier turns and the user.+4. **Verify.** Run the check that proves the slice (test, build, command+ output, diff). Only verified work goes into `Progress`, with its evidence.+5. **Write back.** Rewrite the whole file with the updated header and body:+ ```bash+ ov write <root>/<scope>/<id>.md --from-file ./task.md --wait+ ```+ On `CONFLICT` (path busy) wait a few seconds and retry once; on+ `ALREADY_EXISTS` when creating (`--mode create`) pick another id. Then+ choose the exit state:+ - more to do and you continue next turn → keep `in_progress`;+ - handing off (context nearly full, wrong tool, or the user asked) → clear+ `owner`, set `status: open`, make sure `Next` is precise enough for a+ cold reader;+ - a decision only the user can make → write the question in `Questions`,+ set `status: needs_user`, clear `owner`, then ask the user in the+ current session if there is one and stop;+ - waiting on something external (a PR review, another task) → `blocked`,+ name what unblocks it in `Next`;+ - all `Goal` boxes ticked with evidence → `done`.+6. **Archive (optional).** On every status change append one entry to+ `<root>/<scope>/archive/<id>.md`: the timestamp, `from -> to`, owner, and+ the current `Progress` + `Next` sections. Create it with `--mode create`+ the first time; the task file itself never moves.+ ```bash+ ov write <root>/<scope>/archive/<id>.md --append --from-file ./entry.md --wait+ ```++Creating a task is the same write with `--mode create` and `status: open`;+fill `Goal` and `Context` from the user's request and put the first concrete+step in `Next`.++Answering a `needs_user` task: record the answer in `Decisions`, clear+`Questions`, set `status: open`, write back. The next turn picks it up.++## Long-running and multi-agent++- **Unattended loop.** [references/loop.sh](references/loop.sh) runs one+ agent turn after another (`codex exec` by default, any CLI via+ `OV_TASKS_CMD`) until no runnable task is left or the tick budget is+ spent, and notifies through herdr when it stops. `needs_user` tasks are+ not runnable, so the loop drains around them and stops when only those+ remain.+ ```bash+ zsh references/loop.sh <scope> 5 /path/to/repo+ ```+- **Cross-agent handoff.** Any agent that reads the file continues it;+ Claude, Codex, or a human via `ov tui`. Nothing is tool-specific except+ the agent id in `owner`.+- **Handoff to a person.** A step only a person can do (approve a release,+ run a privileged command) is a `needs_user` gate: name the person and the+ exact action in `Questions`, clear `owner`, stop. When they report back,+ record the outcome in `Decisions` and set `status: open`.+- **Several tasks at once.** Give each subagent its own agent id and one+ task; they never share a file. Serialize tasks that touch the same files+ by listing the dependency in `Next` and setting the later one `blocked`.+- **Retrieval.** `ov find "<topic>" -u <root>` locates related tasks+ across scopes; `ov ls <root>/<scope>` shows abstracts for a quick scan.++## Rules++- Never claim a task another agent updated within the last 2 hours.+- Never write secrets, tokens, or raw logs into a task; write conclusions.+- Never mark `Progress` without evidence, never mark `done` with an+ unchecked `Goal` box.+- Do not run a second task in the same turn; write back, then pick again.diff --git a/agent-plugins/skills/ov-tasks/references/loop.sh b/agent-plugins/skills/ov-tasks/references/loop.shnew file mode 100644index 000000000..84cd8088f--- /dev/null+++ b/agent-plugins/skills/ov-tasks/references/loop.sh@@ -0,0 +1,52 @@+#!/bin/zsh+# loop.sh — run one CLI agent turn after another against an ov-tasks scope+# until no runnable task remains or the tick budget is spent.+#+# zsh loop.sh <scope> [max_ticks=5] [cwd=$PWD]+#+# env:+# OV_TASKS_ROOT task board root (default: viking://agent/tasks, falls back to+# viking://resources/tasks when the server rejects agent/tasks)+# OV_TASKS_AGENT agent id written as owner (default codex@<host>)+# OV_TASKS_CMD agent command template with {PROMPT} placeholder+# (default: codex exec, non-interactive, prompt from file)+#+# Each tick = one bounded turn of the ov-tasks skill: pick, claim, one slice,+# verify, write back. The task file in OV is the only state between ticks.+# ponytail: max_ticks is the whole quota model; add per-task budgets if a task+# ever spins.+set -uo pipefail++scope="${1:?scope}"; max_ticks="${2:-5}"; cwd="${3:-$PWD}"+# root: viking://agent/tasks when the server accepts it, else viking://resources/tasks+ov_ok() { command ov "$@" -o json 2>&1 | grep -q '^{"ok":true'; }+if [ -z "${OV_TASKS_ROOT:-}" ]; then+ if ov_ok stat viking://agent/tasks || ov_ok mkdir viking://agent/tasks; then OV_TASKS_ROOT=viking://agent/tasks+ else OV_TASKS_ROOT=viking://resources/tasks; fi+fi+: "${OV_TASKS_AGENT:=codex@$(hostname -s)}"+: "${OV_TASKS_CMD:=codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check -C ${cwd} - < {PROMPT\}}"+skill_md="${0:A:h:h}/SKILL.md"+scope_uri="${OV_TASKS_ROOT}/${scope}"++runnable() {+ command ov grep '^status: (open|in_progress)' -u "$scope_uri" -x "$scope_uri/archive" -o json 2>/dev/null \+ | python3 -c 'import sys,json; d=json.loads(next(l for l in sys.stdin if l.startswith("{"))); print(len({m["uri"] for m in d.get("result",{}).get("matches",[])}))' 2>/dev/null || echo 0+}+notify() { command -v herdr >/dev/null && herdr notification show "$1" --sound done >/dev/null 2>&1; echo "$1"; }++for tick in $(seq 1 "$max_ticks"); do+ n=$(runnable)+ if [ "$n" = 0 ]; then notify "ov-tasks ${scope}: no runnable task (needs_user/blocked/done only)"; exit 0; fi+ prompt="$(mktemp -t ov-tasks-prompt.XXXXXX.md)"+ cat > "$prompt" <<PROMPT+Read ${skill_md} and follow it exactly.+Task board root: ${OV_TASKS_ROOT} scope: ${scope} your agent id: ${OV_TASKS_AGENT}+Do exactly ONE turn: pick one runnable task in this scope, claim it, do one bounded slice, verify it, write the task file back, then stop.+If the task needs a user answer, set status: needs_user, put the concrete question in ## Questions, write back, and stop.+Do not start a second task in this turn.+PROMPT+ echo "== tick ${tick}/${max_ticks} (${n} runnable) =="+ eval "${OV_TASKS_CMD//\{PROMPT\}/$prompt}"+done+notify "ov-tasks ${scope}: tick budget ${max_ticks} spent, $(runnable) runnable left"diff --git a/agent-plugins/skills/ov-tasks/references/task-template.md b/agent-plugins/skills/ov-tasks/references/task-template.mdnew file mode 100644index 000000000..170dfdb32--- /dev/null+++ b/agent-plugins/skills/ov-tasks/references/task-template.md@@ -0,0 +1,31 @@+---+id: 2026-09-18-short-slug+title: One-line task title+status: open+owner:+scope: demo+updated: 2026-09-18T12:00:00+0800+---++## Goal+What "done" looks like, as a checklist the last agent can tick.+- [ ] acceptance criterion 1+- [ ] acceptance criterion 2++## Context+cwd / repo / branch, key files or viking:// URIs, constraints, docs that have authority.++## Decisions+- 2026-09-18: decision — why. User answers to Questions are recorded here too.++## Progress+Verified progress only, each line with its evidence (command + result, commit, PR, file path).++## Next+- [ ] ordered steps; the first unchecked box is what the next agent does++## Questions+Concrete questions the user must answer. Non-empty means `status: needs_user`.++## Log+- 2026-09-18T12:00 agent-id: createddiff --git a/docs/design/ov-tasks.md b/docs/design/ov-tasks.mdnew file mode 100644index 000000000..46ab0027d--- /dev/null+++ b/docs/design/ov-tasks.md@@ -0,0 +1,73 @@+# ov-tasks:把结构化 handoff 做成 OpenViking 上的任务板++| 项目 | 信息 |+| --- | --- |+| 状态 | 可用(skill 已落地,herdr 演练通过) |+| Skill | `agent-plugins/skills/ov-tasks/` |+| 存储 | `viking://agent/tasks/<scope>/<id>.md`;server 拒绝时兜底 `viking://resources/tasks`(见下) |+| 更新日期 | 2026-09-18 |++## 一句话++一个任务 = OV 里的一个 markdown 文件:frontmatter 头(id/status/owner/scope/updated)+ 固定七段正文(Goal/Context/Decisions/Progress/Next/Questions/Log)。文件本身就是 handoff,任何有 `ov` CLI 的 agent 读到就能继续,每轮结束整文件写回。没有其他状态。++## 与 PowerContext / LoopX 的对应++| 概念 | PowerContext | LoopX | ov-tasks |+| --- | --- | --- | --- |+| 隔离边界 | Scope(server 生成的 opaque id) | Goal + project registry | `<root>/<scope>/` 目录,`ov acl` 管权限 |+| 目标与完成边界 | Work Contract | Objective + Operating Contract | `## Goal` 验收清单 + `## Context` |+| 交接内容 | Prepared/Committed Handoff | ACTIVE_GOAL_STATE.md | 任务文件全文 |+| 待办 | — | Agent Todo / User Todo | `## Next` 清单 / `## Questions` + `status: needs_user` |+| 用户门 | Acknowledgement needs clarification | user gate | `status: needs_user`,agent 在会话内向用户提问并停下 |+| 证据 | Source / Task Outcome | evidence + Progress Ledger | `## Progress`(只写已验证条目,带证据)+ `## Log` |+| 所有权 | receiver acknowledgement | claim / lease | `owner` + `updated`;超过 2h 未更新视为可重新认领 |+| 历史 | 不可变 Revision + lineage | run history | 可选 `archive/<id>.md`,只在 status 变化时追加 |+| 长期运行 | — | quota + scheduler + kernel | `references/loop.sh`:一轮一次 agent 调用,直到无可跑任务或轮数用尽 |+| 跨 agent | 同 Scope 内继续 Handoff | peer agents + writeback | 同一文件;agent id 写在 `owner` |+| 检索 | Handoff Report | `loopx status` | `ov grep '^status: open'`、`ov find`、`ov ls` |++## 丢弃的概念与原因++| 丢弃 | 原因 |+| --- | --- |+| LoopX Kernel / Capability / Provider / Extension 分层 | OV 只负责存储与检索;执行方是任意 CLI agent。分层没有承载者,30 行 loop.sh 覆盖"一轮一 tick"。 |+| LoopX quota / 调度 / 自修复 | 用 `max_ticks` 一个数字替代。任务不会自旋,因为每轮必须写回且 needs_user 不可跑。 |+| LoopX typed claim / lease / 原子 writeback | OV write 没有 CAS。用 `owner`+`updated` 的 2h 约定替代,并在 skill 中写明。并发同一任务是已知上限。 |+| PowerContext 不可变 Revision / lineage / Acknowledgement / Task Outcome | 四个对象折叠为一个可变文件 + 可选追加式 archive。Acknowledgement = claim 时写 Log;Outcome = 最终 status + Progress。 |+| PowerContext Candidate 审核、Experience/Skill 家族 | 与 handoff 无关;经验沉淀走 OV 已有的 `remember`。 |+| PowerContext opaque scope id | OV URI 本身就是 scope 且带 ACL,不需要第二套 id。 |+| Dashboard / Lark 看板投影 | `ov ls`、`ov tui`、`ov find` 已够;需要时再做。 |+| retrieval tags 镜像 status/owner | 云端 0.4.17.3 的 write 不接受 `--tags`,需要第二次 `set-tags` 调用;frontmatter + `ov grep` 已能过滤,避免双写漂移。 |++## 存储位置:viking://agent/tasks 优先,探测失败兜底 viking://resources/tasks++| 事实 | 证据 |+| --- | --- |+| 云端 server (v0.4.17.3) 拒绝 `viking://agent/tasks` 的 mkdir/write | `PERMISSION_DENIED: viking://agent/{agent_id} is deprecated. Use viking://user/.../peers/{agent_id}` |+| main 分支 namespace 只把 `agent/skills` 视为内容目录 | `openviking/core/namespace.py:16` `_CONTENT_TYPES_BY_SCOPE["agent"] = {"skills": "skill"}`;`classify_uri("viking://agent/tasks/x.md")` 得到 `context_type=resource`,main 上无显式写保护 |+| `viking://resources/tasks` 在云端可用:create / read / append / grep / set-tags 均通过 | 本文演练 |++开源 main 已允许在 `viking://agent` 下新建目录。skill 与 loop.sh 每次先 `ov stat`/`ov mkdir viking://agent/tasks` 探测,`PERMISSION_DENIED` 才退回 `viking://resources/tasks`;`OV_TASKS_ROOT` 可强制指定。协议与 root 无关。++## `ov compile` 接入(下一步)++目标:`ov compile --from <root>/<scope> --to <root>/<scope> --skill viking://agent/skills/ov-tasks`,由 VikingBot 按 skill 执行一轮并把任务文件写回。++| 阻塞点 | 位置 |+| --- | --- |+| `--to` 只允许 resource/memory/skills 目录 | `openviking/service/compile_service.py:464` `_validate_target`(`viking://agent/tasks/<scope>` 需放行) |+| `--from` 必须是目录 | `compile_service.py:446`,单任务文件需放行文件源,或约定 from = scope 目录 + `--instruction "task <id>"` |+| Compile agent 的产物是 wiki bundle(`submit_wiki_bundle`) | 需要一个"原地改写源文件"的输出工具;改动在 VikingBot 侧 |++建议顺序:先把 `ov-tasks` 用 `ov add-skill agent-plugins/skills/ov-tasks -p viking://agent/skills` 装到 OV,再改 compile 的两处校验,最后补写回工具。++## 演练记录(2026-09-18,herdr,scope `demo`)++| 轮 | 执行者 | 动作 | 结果 |+| --- | --- | --- | --- |+| A | codex(`codex exec`) | 认领 `wc-top`,只做 Next 第一项,验证后 handoff(status open、owner 清空) | 文件写回正确;archive 记录 open→in_progress→open;脚本可运行 |+| B | claude(`claude -p`) | 读 A 的 handoff 继续,补测试和 README | status done,Goal 三项全勾且带证据;本地复跑 `pytest` 4 passed |+| C | `loop.sh demo 4` 驱动 codex | tick1 认领 `makefile`:写好 Makefile,但本机 `make` 被 Xcode license 挡住 → `needs_user` 并写明问题;tick2 认领 `report-format`:输出格式未定 → `needs_user`;tick3 无可跑任务,循环停止 | 两次 user gate 都是真实阻塞,没有假 pass;循环按预期收敛 |++演练中修的两个问题:`write --mode create` 需要 `archive/` 目录先存在(skill 已写明);`ov` 输出 JSON 前有一行 `cmd:`,loop.sh 改为只解析 JSON 行。另外 codex 侧的 OV MCP `write` 会在 15s 超时后仍写入成功,skill 已注明优先用 CLI 并回读确认。