6 Commits

Author SHA1 Message Date
6f076969ce chore: auto release commit (2026-09-12 15:19:25)
All checks were successful
技能自动化发布 / release (push) Successful in 5s
2026-09-12 15:19:25 +08:00
37d4ebfc1c chore: auto release commit (2026-09-12 15:12:53)
All checks were successful
技能自动化发布 / release (push) Successful in 6s
2026-09-12 15:12:53 +08:00
18223d5a26 chore: auto release commit (2026-09-11 16:25:24)
All checks were successful
技能自动化发布 / release (push) Successful in 6s
2026-09-11 16:25:24 +08:00
6786a19953 chore: auto release commit (2026-09-11 15:24:58)
All checks were successful
技能自动化发布 / release (push) Successful in 6s
2026-09-11 15:24:58 +08:00
d10db1d667 chore: auto release commit (2026-09-11 15:12:31)
All checks were successful
技能自动化发布 / release (push) Successful in 8s
2026-09-11 15:12:31 +08:00
26efbf7f82 chore: auto release commit (2026-09-11 00:17:16)
All checks were successful
技能自动化发布 / release (push) Successful in 6s
2026-09-11 00:17:16 +08:00
4 changed files with 61 additions and 18 deletions

View File

@@ -258,6 +258,33 @@
"{{id}}" "{{id}}"
] ]
} }
},
{
"id": "todo-remind",
"placements": [
"agent",
"cron"
],
"executionProfile": "async",
"inputSchema": {
"type": "object",
"properties": {
"seconds": {
"type": "number",
"default": 3
}
}
},
"label": "到期提醒",
"description": "在指定时间提醒到期的待办事项。",
"entrypoint": {
"type": "cli",
"command": "remind",
"args": [
"--seconds",
"{{seconds}}"
]
}
} }
] ]
} }

View File

@@ -13,12 +13,11 @@
## 0.1 宿主入口定位 ## 0.1 宿主入口定位
| 主能力(Action id / CLI) | 对话 | 数据管理 | 定时 | 不挂理由(若不挂) |
|---------------------------|------|----------|------|--------------------| |---------------------------|------|----------|------|--------------------|
| `todo add` | 挂 | toolbar(新增按钮) | 不挂 | 定时无意义 | | `todo add` | 挂 | toolbar(新增按钮) | 不挂 | 定时无意义 |
| `todo list` | 挂 | row | 不挂 | 定时无意义 | | `todo list` | 挂 | row | 不挂 | 定时无意义 |
| `todo done` | 挂 | row + batch(标记完成) | 不挂 | 定时无意义 | | `todo done`(Action `todo-done-row`) | 挂(短 CLI 直调) | row(「完成」按钮) | 不挂 | 定时无意义;batch 批量完成暂未声明 |
| `todo delete` | 挂 | row + batch(删除) | 不挂 | 定时无意义 | | `todo delete` | 挂 | row(「删除」按钮)) + batch(删除) | 不挂 | 定时无意义 |
| `todo stats` | 挂 | toolbar(统计) | 不挂 | 定时无意义 | | `todo stats` | 挂 | toolbar(统计) | 不挂 | 定时无意义 |
| `remind` | 挂 | toolbar | 挂 | 定时扫描到期/待办项并提醒 | | `remind` | 挂 | toolbar | 挂 | 定时扫描到期/待办项并提醒 |
| `init-db` | 不挂 | 不挂 | 不挂 | 宿主安装/更新时静默调用,不对用户暴露 | | `init-db` | 不挂 | 不挂 | 不挂 | 宿主安装/更新时静默调用,不对用户暴露 |
@@ -28,7 +27,6 @@
说明: 说明:
- `todos` 表在数据管理中为**整表只读**(`readonly=1`),所有增删改必须通过技能 Action(`todo add/done/delete`)走,宿主不直写业务表。
- 数据管理页面默认展示列:`title`、`status`、`priority`、`due_at`、`created_at`;默认按 `created_at` 倒序。 - 数据管理页面默认展示列:`title`、`status`、`priority`、`due_at`、`created_at`;默认按 `created_at` 倒序。
- `status` 与 `priority` 字段在数据管理中以下拉枚举展示(pending=待办/done=完成;high=高/normal=中/low=低)。 - `status` 与 `priority` 字段在数据管理中以下拉枚举展示(pending=待办/done=完成;high=高/normal=中/low=低)。
@@ -225,3 +223,4 @@
| 日期 | 版本 | 变更人 | 变更内容 | | 日期 | 版本 | 变更人 | 变更内容 |
|------|------|--------|----------| |------|------|--------|----------|
| 2026-09-07 | v0.1.0 | - | 初版需求文档 | | 2026-09-07 | v0.1.0 | - | 初版需求文档 |
| 2026-09-11 | v0.1.1 | - | 入口定位表登记行级 Action `todo-done-row`(todos 表操作列「完成本行」,sync/direct,`$row.$pk` 预填) |

View File

@@ -69,7 +69,7 @@ async def _run_template_demo(target: Optional[str], input_id: Optional[str]) ->
def cmd_run(target: Optional[str] = None, input_id: Optional[str] = None) -> int: def cmd_run(target: Optional[str] = None, input_id: Optional[str] = None) -> int:
"""通用任务执行入口模板。复制后请实现真实业务逻辑。""" """通用任务执行入口模板。复制后请实现真实业务逻辑。"""
log = _get_task_logger() log = _get_task_logger()
task_type = "demo" task_type = "cmd_run"
with job_context(skill=SKILL_SLUG): with job_context(skill=SKILL_SLUG):
log.info( log.info(
@@ -261,33 +261,34 @@ def cmd_stats() -> int:
# ---------------- async 任务范式(demo) ---------------- # ---------------- async 任务范式(demo) ----------------
async def _run_remind_async(*, seconds: int) -> dict[str, Any]: async def _run_remind_async(*, seconds: int) -> dict[str, Any]:
"""模拟长耗时任务:每秒 emit 一次进度,最后 finish 终态。
真实平台会推送到任务中心 UI 并支持取消;本 demo 在 stdout 打印 JSON Lines。
""" """
steps = max(1, int(seconds)) 真实平台会推送到任务中心 UI 并支持取消;
for i in range(1, steps + 1): """
await interruptible_sleep(1) log = _get_task_logger()
emit(f"提醒任务进度 {i}/{steps}", skill=SKILL_SLUG, stage="remind", progress=i, total=steps) todos = todo_service.get_current_remind_todos()
# 真实业务在这里会查 todos 表挑出 due/pending 项发出提醒;demo 不做真实推送 log.info("[task]remind todos count: %s", len(todos))
for todo in todos:
todo_service.mark_done(todo.id)
log.info("[task]remind todos : %s", todo.title)
emit(f"提醒待办 {todo.title}", skill=SKILL_SLUG, stage="remind")
summary = todo_service.stats() summary = todo_service.stats()
return {"remind": True, "duration_seconds": steps, "stats": summary} return {"remind": True, "duration_seconds": len(todos), "stats": summary}
def cmd_remind(*, seconds: int = 3) -> int: def cmd_remind(*, seconds: int = 3) -> int:
"""演示 async 任务编排。CLI 入口仍走同一内核;Agent 真实调度时 """演示 async 任务编排。CLI 入口仍走同一内核;Agent 真实调度时
通过 ``run_skill_action``(executionProfile: async)触发。""" 通过 ``run_skill_action``(executionProfile: async)触发。"""
log = _get_task_logger() log = _get_task_logger()
task_type = "remind" task_type = "cron"
with job_context(skill=SKILL_SLUG): with job_context(skill=SKILL_SLUG):
log.info("task_start task_type=%s stage=remind seconds=%s", task_type, seconds) log.info("task_start task_type=%s stage=remind", task_type)
emit("开始执行提醒任务", skill=SKILL_SLUG, stage="remind") emit("开始执行提醒任务", skill=SKILL_SLUG, stage="remind")
try: try:
result = asyncio.run(_run_remind_async(seconds=seconds)) result = asyncio.run(_run_remind_async(seconds=seconds))
log.info("task_done task_type=%s status=ok", task_type) log.info("task_done task_type=%s status=ok", task_type)
finish( finish(
status="ok", status="success",
message=f"提醒任务完成,处理 {seconds} 秒", message=f"提醒任务完成",
skill=SKILL_SLUG, skill=SKILL_SLUG,
stage="remind", stage="remind",
**result, **result,

View File

@@ -157,6 +157,22 @@ def delete_todo(todo_id: int) -> bool:
finally: finally:
conn.close() conn.close()
def get_current_remind_todos() -> list[Todo]:
"""获取当前需要提醒的待办。"""
now = _now()
conn = get_conn()
try:
cur = conn.cursor()
cur.execute(
"SELECT id, title, status, priority, due_at, created_at, updated_at "
"FROM todos WHERE due_at <= ? AND status = ?",
(int(now / 60) * 60 + 59, STATUS_PENDING),
)
rows = cur.fetchall()
return [Todo(*row) for row in rows]
finally:
conn.close()
def stats() -> dict: def stats() -> dict:
"""简单统计:用于 ``todo stats`` 命令与 demo 报告。""" """简单统计:用于 ``todo stats`` 命令与 demo 报告。"""