@downcity/plugins 1.0.147 → 1.0.149

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/bin/asr/Plugin.js +8 -8
  2. package/bin/asr/Plugin.js.map +1 -1
  3. package/bin/auth/types/AuthPlugin.js +3 -3
  4. package/bin/auth/types/AuthPlugin.js.map +1 -1
  5. package/bin/chat/PROMPT.direct.d.ts +1 -1
  6. package/bin/chat/PROMPT.direct.d.ts.map +1 -1
  7. package/bin/chat/PROMPT.direct.js +1 -1
  8. package/bin/chat/PROMPT.direct.js.map +1 -1
  9. package/bin/chat/channels/feishu/PROMPT.direct.d.ts +1 -1
  10. package/bin/chat/channels/feishu/PROMPT.direct.d.ts.map +1 -1
  11. package/bin/chat/channels/feishu/PROMPT.direct.js +1 -1
  12. package/bin/chat/channels/feishu/PROMPT.direct.js.map +1 -1
  13. package/bin/chat/channels/qq/PROMPT.direct.d.ts +1 -1
  14. package/bin/chat/channels/qq/PROMPT.direct.d.ts.map +1 -1
  15. package/bin/chat/channels/qq/PROMPT.direct.js +1 -1
  16. package/bin/chat/channels/qq/PROMPT.direct.js.map +1 -1
  17. package/bin/chat/runtime/ChatAuthorizationRuntime.js +5 -5
  18. package/bin/chat/runtime/ChatAuthorizationRuntime.js.map +1 -1
  19. package/bin/chat/runtime/ChatPluginActionRegistry.js +61 -61
  20. package/bin/chat/runtime/ChatPluginActionRegistry.js.map +1 -1
  21. package/bin/contact/Action.js +48 -48
  22. package/bin/contact/Action.js.map +1 -1
  23. package/bin/contact/PROMPT.d.ts +1 -1
  24. package/bin/contact/PROMPT.d.ts.map +1 -1
  25. package/bin/contact/PROMPT.js +1 -1
  26. package/bin/contact/PROMPT.js.map +1 -1
  27. package/bin/image/ImagePlugin.js +21 -21
  28. package/bin/image/ImagePlugin.js.map +1 -1
  29. package/bin/memory/MemoryPlugin.js +50 -50
  30. package/bin/memory/MemoryPlugin.js.map +1 -1
  31. package/bin/skill/PROMPT.d.ts +1 -1
  32. package/bin/skill/PROMPT.d.ts.map +1 -1
  33. package/bin/skill/PROMPT.js +1 -1
  34. package/bin/skill/PROMPT.js.map +1 -1
  35. package/bin/skill/Plugin.js +23 -23
  36. package/bin/skill/Plugin.js.map +1 -1
  37. package/bin/task/Action.js +1 -1
  38. package/bin/task/Action.js.map +1 -1
  39. package/bin/task/PROMPT.d.ts +1 -1
  40. package/bin/task/PROMPT.d.ts.map +1 -1
  41. package/bin/task/PROMPT.js +1 -1
  42. package/bin/task/PROMPT.js.map +1 -1
  43. package/bin/task/runtime/Runner.js +2 -2
  44. package/bin/task/runtime/Runner.js.map +1 -1
  45. package/bin/task/runtime/TaskPluginActionRegistry.js +73 -73
  46. package/bin/task/runtime/TaskPluginActionRegistry.js.map +1 -1
  47. package/bin/task/runtime/TaskRunnerProgress.js +1 -1
  48. package/bin/task/runtime/TaskRunnerProgress.js.map +1 -1
  49. package/bin/task/runtime/TaskRunnerScript.js +3 -3
  50. package/bin/task/runtime/TaskRunnerScript.js.map +1 -1
  51. package/bin/tts/Plugin.js +7 -7
  52. package/bin/tts/Plugin.js.map +1 -1
  53. package/bin/web/PROMPT.d.ts +1 -1
  54. package/bin/web/PROMPT.d.ts.map +1 -1
  55. package/bin/web/PROMPT.js +1 -1
  56. package/bin/web/PROMPT.js.map +1 -1
  57. package/bin/web/Plugin.js +8 -8
  58. package/bin/web/Plugin.js.map +1 -1
  59. package/bin/workboard/Plugin.js +2 -2
  60. package/bin/workboard/Plugin.js.map +1 -1
  61. package/bin/workboard/runtime/Normalizer.js +1 -1
  62. package/bin/workboard/runtime/Normalizer.js.map +1 -1
  63. package/package.json +3 -3
  64. package/src/asr/Plugin.ts +8 -8
  65. package/src/auth/types/AuthPlugin.ts +3 -3
  66. package/src/chat/PROMPT.direct.ts +1 -1
  67. package/src/chat/PROMPT.direct.ts.txt +32 -32
  68. package/src/chat/channels/feishu/PROMPT.direct.ts +1 -1
  69. package/src/chat/channels/feishu/PROMPT.direct.ts.txt +2 -2
  70. package/src/chat/channels/qq/PROMPT.direct.ts +1 -1
  71. package/src/chat/channels/qq/PROMPT.direct.ts.txt +11 -9
  72. package/src/chat/runtime/ChatAuthorizationRuntime.ts +5 -5
  73. package/src/chat/runtime/ChatPluginActionRegistry.ts +61 -61
  74. package/src/contact/Action.ts +48 -48
  75. package/src/contact/PROMPT.ts +1 -1
  76. package/src/contact/PROMPT.ts.txt +22 -22
  77. package/src/image/ImagePlugin.ts +21 -21
  78. package/src/memory/MemoryPlugin.ts +50 -50
  79. package/src/skill/PROMPT.ts +1 -1
  80. package/src/skill/PROMPT.ts.txt +5 -6
  81. package/src/skill/Plugin.ts +23 -23
  82. package/src/task/Action.ts +1 -1
  83. package/src/task/PROMPT.ts +1 -1
  84. package/src/task/PROMPT.ts.txt +159 -159
  85. package/src/task/runtime/Runner.ts +2 -2
  86. package/src/task/runtime/TaskPluginActionRegistry.ts +73 -73
  87. package/src/task/runtime/TaskRunnerProgress.ts +1 -1
  88. package/src/task/runtime/TaskRunnerScript.ts +3 -3
  89. package/src/tts/Plugin.ts +7 -7
  90. package/src/web/PROMPT.ts +1 -1
  91. package/src/web/PROMPT.ts.txt +31 -31
  92. package/src/web/Plugin.ts +8 -8
  93. package/src/workboard/Plugin.ts +2 -2
  94. package/src/workboard/runtime/Normalizer.ts +1 -1
@@ -4,6 +4,6 @@
4
4
  */
5
5
 
6
6
  // Source: src/task/PROMPT.ts.txt
7
- const TEXT_MODULE_CONTENT = "# Task Plugin\n\n你可以通过 `task` plugin 管理任务定义、执行、调度与状态控制。\n\n## 任务模型\n\n每个任务定义在 `./.downcity/task/<title>/task.md`,包含:\n- frontmatter(结构化字段)\n- body(任务正文)\n\nfrontmatter 核心字段:\n- `title`:任务唯一标识(唯一)\n- `description`:任务描述\n- `when`:触发条件,支持:`@manual` / cron / `time:<ISO8601-with-timezone>`\n- `sessionId`:任务执行会话\n- `status`:`enabled|paused|disabled`\n- `kind`:`agent|script`(默认 `agent`)\n\n执行时会产生 run 目录:\n- `./.downcity/task/<title>/<timestamp>/`\n\n常见产物:\n- `input.md`\n- `output.md`(本次任务的最终输出正文)\n- `result.md`(执行摘要)\n- `run.json`\n- `run-progress.json`\n- `dialogue.md` / `dialogue.json`(agent 多轮)\n- `error.md`(失败时)\n\n## 执行类型(kind)\n\n1. `kind=agent`\n- 将正文交给 agent 执行\n- 默认单轮完成;仅当 frontmatter 显式设置 `review: true` 时启用模拟用户多轮复核\n- 适合研究、分析、报告生成\n\n2. `kind=script`\n- 将正文当作 shell 脚本执行\n- 正文不能为空,必须是可执行脚本\n\n## 可用 action\n\n- `list`\n- `create`\n- `run`\n- `delete`\n- `update`\n- `status`\n- `enable`\n- `disable`\n\n## Action 调用示例\n\n- `plugin_call({ plugin: \"task\", action: \"list\", payload: { status } })`\n- `plugin_call({ plugin: \"task\", action: \"create\", payload: { title, description, sessionId, when, kind, status } })`\n- `plugin_call({ plugin: \"task\", action: \"run\", payload: { title, reason } })`\n- `plugin_call({ plugin: \"task\", action: \"update\", payload: { title, description, when, status, sessionId } })`\n- `plugin_call({ plugin: \"task\", action: \"delete\", payload: { title } })`\n\n## 关键约束\n\n- `title` 唯一;create 去重仅按 `title` 精确匹配。\n- `when=time:...` 触发后会自动置为 `paused`,并回退为 `when=@manual`。\n- `run` 为异步受理:立即返回 `accepted=true`、`message`、`executionId`;调用方应把它视为“任务已进入后台执行,结果会自动通过 chat plugin runtime 发送,当前流程无需阻塞等待”。\n- 如果 `run` 返回 `accepted=true`:\n - 不要手动把 task 产出再转发给用户。\n - 不要主动读取 run 目录、`run-progress.json`、`output.md` 做轮询。\n - 只有当用户明确要求排查、查看产物或确认执行细节时,才进入 run 目录检查。\n- agent 任务默认只要求产生有效输出;仅当任务正文明确要求外发时,才应发送到外部 channel。\n\n## 如何设计 task 正文\n\n### agent task 推荐结构\n\n建议正文至少包含这些标题:\n\n```md\n# 任务目标\n\n- 这次任务要交付什么最终结果\n\n# 背景与输入\n\n- 数据来源、范围、约束、参考材料\n\n# 执行步骤\n\n1. 先做什么\n2. 再做什么\n3. 关键中间产物落在哪里\n\n# 输出要求\n\n- 最终结果用什么格式返回\n- 是否需要表格 / JSON / Markdown\n- 不要包含什么内容\n\n# 触发与状态建议\n\n- 这个任务为什么适合 `@manual` / cron / `time:...`\n- 当前应该是 `paused` 还是 `enabled`\n\n# 注意事项\n\n- 风险、边界、不要做什么\n```\n\n### agent task 正文编写约束\n\n- task 正文必须像一份“交付合同”,让另一个执行器拿到后可以直接执行,不依赖当前聊天语境补全含义。\n- `# 任务目标` 必须写清楚最终要交付什么,不要只写“看一下”“研究一下”“处理一下”这类模糊目标。\n- `# 背景与输入` 必须写清来源、范围、对象、时间、限制条件;不要假设执行器还能看到原始聊天上下文。\n- `# 执行步骤` 应描述任务流程,不应描述 task 管理动作;不要写“先检查有没有同名任务”“再创建任务”“然后触发任务”。\n- `# 输出要求` 必须清楚声明最终成品的格式、结构、语气、长度,以及“不要输出什么”。\n- 要明确写出:**最后一条 assistant 返回会被直接写入 `output.md` 并发送给用户**;因此最终回答必须直接等于成品内容。\n- 内容生成类任务(如日报、提醒、晨读、摘要、报告)必须明确要求“最终输出直接是成品正文”,不要让执行器输出过程说明。\n- 如果任务要把结果发给用户,正文应要求“输出可直接发送的正文内容”,而不是要求执行器解释自己已经发送了什么。\n- 除非确有需要,不要在正文中要求执行器复述 task title、sessionId、执行时间、状态等元信息。\n- 正文中的约束要可执行、可判断,尽量避免“适当”“尽量”“看情况”这类弱约束词。\n- 不要把创建 task、更新 task、查看 task 状态、确认 task 是否存在等管理动作写进正文;这些属于 task plugin 的职责,不属于 task 正文交付物。\n\n### agent task 正文禁止写法\n\n- 不要把正文写成聊天回复口吻,例如:\n - “我来为你……”\n - “首先让我……”\n - “我先检查一下……”\n - “我看到已经有一个同名任务……”\n- 不要把正文写成任务管理说明,例如:\n - “如果任务已存在则更新,否则创建”\n - “先 list 再 run”\n - “完成后告诉用户任务已启动”\n- 不要把正文写成状态汇报模板,例如:\n - “任务状态总结”\n - “已发送 / 已完成 / 已更新”\n - “当前任务配置如下”\n- 不要只描述动作,不描述成品,例如:\n - “去搜集一些资料”\n - “生成一个内容看看”\n - “做完后反馈结果”\n- 不要把正文写成依赖当前上下文的指代,例如:\n - “按上面说的做”\n - “继续刚才那个”\n - “把这个发出去”\n\n### 如何判断正文写得对不对\n\n- 如果把 task 正文单独复制出来给另一个 agent,它仍然能理解任务目标、输入、步骤和交付物,说明正文合格。\n- 如果最终输出章节删掉后,正文只剩“去做一下”式描述,说明正文不合格。\n- 如果正文更像“创建/更新任务的操作说明”,而不是“任务执行说明”,说明分层错了,必须重写。\n- 如果正文天然会诱导执行器输出过程汇报,而不是最终成品,说明 `# 输出要求` 写得不够强,必须补充禁止项。\n\n### script task 推荐结构\n\n- 正文必须是纯 shell 脚本,不要混入解释性自然语言。\n- 开头尽量写注释说明脚本目的、输入依赖、失败条件。\n- 输出保持稳定,便于直接作为最终结果发送给用户。\n- 如需生成文件,写到 run 目录或明确的项目路径。\n\n### 输出设计原则\n\n- task 完成后,系统会自动把**最终结果正文**通过 chat plugin runtime 的 `send` 发回 `sessionId` 绑定的 chat。\n- 当前实现采用最简规则:**最后一条 assistant 返回**会被直接视为最终结果正文,并写入 `output.md`。\n- 因此正文里的“输出要求”要面向最终用户阅读,不要只写给开发者看。\n- 对于面向用户的 agent task,正文应要求“最后一条 assistant 返回直接输出最终交付物本身”,不要让执行器在最后回答里输出自己如何创建、检查、更新、触发或发送任务。\n- 如果任务是内容生成类(例如日报、提醒、晨读、摘要),最后输出应直接是那段内容本身,不要附带“我来为你处理”“任务已发送”“任务状态总结”等过程汇报。\n- 默认不要在正文里再次要求执行器发送 chat 消息;系统会处理最终结果回传。\n- 只有在“跨会话发送”“额外抄送”“多渠道通知”这类场景下,才显式要求执行器调用 chat plugin action。\n\n### `when` / `status` 怎么选\n\n- task 创建默认就是 `status=enabled`;如果还在试任务、容易失败、需要人工确认,再显式切到 `paused`。\n- 已经验证稳定、需要自动运行:直接使用 cron + `status=enabled`。\n- 明确只执行一次:使用 `time:<带时区 ISO 时间>`;执行后系统会自动回退到 `@manual` + `paused`。\n- 如果用户只是“先存起来以后再跑”,不要直接启用调度。\n\n## 正文模板\n\n### agent 模板\n\n```md\n# 任务目标\n\n- 产出一份可直接发给用户的最终结果。\n\n# 背景与输入\n\n- 在这里补充上下文、文件、链接、范围和假设。\n\n# 执行步骤\n\n1. 理解任务目标与完成标准。\n2. 收集必要信息并执行任务。\n3. 把关键中间产物写入 run 目录。\n4. 输出最终结果正文。\n\n# 输出要求\n\n- 最后一条 assistant 返回直接作为最终结果,不要附带冗长日志。\n- 最后一条 assistant 返回直接输出交付物本身,不要输出任务管理过程、发送过程或状态汇报。\n- 不要使用“我来为你…… / 首先让我…… / 已发送……”这类元话术。\n- 默认不要再次调用 chat plugin 的发送 action。\n\n# 触发与状态建议\n\n- 默认创建后立即启用;如果只是先保存草稿或等待人工确认,再改成 `paused`。\n\n# 注意事项\n\n- 仅在明确需要跨会话或额外通知时,才调用 chat plugin 的发送 action。\n```\n\n### script 模板\n\n```bash\n# 任务目标:一句话说明脚本要做什么\n# 输入依赖:列出环境变量、文件、命令依赖\n# 失败条件:列出应该 exit 1 的情况\n\nset -euo pipefail\n\n# 1. 准备输入\n\n# 2. 执行主逻辑\n\n# 3. 输出最终结果(这段输出会被直接发送给用户)\n```\n\n## 建议\n\n- 先 `list`,再 `create`/`update`。\n- 简单内容生成任务优先保持默认单轮;只有确实需要“先生成、再复核、再修订”时再设置 `review: true`。\n- script 任务正文保持纯脚本,不要混入冗余自然语言。\n- 如果用户只是先存起来以后再跑,创建后显式设成 `paused`;否则保持默认启用。\n- task 正文要写“最终结果长什么样”,不要只写“去做一下看看”。\n- 对内容生成任务,要明确写“最后一条 assistant 返回只能是成品正文”,避免执行器把过程说明误当成最终结果。\n";
7
+ const TEXT_MODULE_CONTENT = "# Task Plugin\n\nYou can use the `task` plugin to manage task definitions, execution, scheduling, and status control.\n\n## Task Model\n\nEach task is defined in `./.downcity/task/<title>/task.md` and contains:\n- frontmatter for structured fields\n- body for the task instructions\n\nCore frontmatter fields:\n- `title`: unique task identifier\n- `description`: task description\n- `when`: trigger condition, supporting `@manual`, cron, or `time:<ISO8601-with-timezone>`\n- `sessionId`: task execution session\n- `status`: `enabled|paused|disabled`\n- `kind`: `agent|script`, defaulting to `agent`\n\nEach execution creates a run directory:\n- `./.downcity/task/<title>/<timestamp>/`\n\nCommon artifacts:\n- `input.md`\n- `output.md`: final output body for this run\n- `result.md`: execution summary\n- `run.json`\n- `run-progress.json`\n- `dialogue.md` / `dialogue.json`: multi-turn agent dialogue\n- `error.md`: failure details\n\n## Execution Kinds\n\n1. `kind=agent`\n- Sends the task body to an agent for execution.\n- Completes in a single turn by default. Simulated multi-turn review is enabled only when frontmatter explicitly sets `review: true`.\n- Suitable for research, analysis, and report generation.\n\n2. `kind=script`\n- Treats the body as a shell script.\n- The body must be non-empty and executable as a script.\n\n## Available Actions\n\n- `list`\n- `create`\n- `run`\n- `delete`\n- `update`\n- `status`\n- `enable`\n- `disable`\n\n## Action Examples\n\n- `plugin_call({ plugin: \"task\", action: \"list\", payload: { status } })`\n- `plugin_call({ plugin: \"task\", action: \"create\", payload: { title, description, sessionId, when, kind, status } })`\n- `plugin_call({ plugin: \"task\", action: \"run\", payload: { title, reason } })`\n- `plugin_call({ plugin: \"task\", action: \"update\", payload: { title, description, when, status, sessionId } })`\n- `plugin_call({ plugin: \"task\", action: \"delete\", payload: { title } })`\n\n## Key Constraints\n\n- `title` is unique. `create` deduplicates only by exact `title`.\n- After `when=time:...` triggers, the task is automatically set to `paused` and falls back to `when=@manual`.\n- `run` is accepted asynchronously. It returns `accepted=true`, `message`, and `executionId` immediately. Treat this as \"the task has entered background execution; the result will be sent automatically through the chat plugin runtime, and the current flow does not need to block.\"\n- If `run` returns `accepted=true`:\n - Do not manually forward task output to the user again.\n - Do not actively poll the run directory, `run-progress.json`, or `output.md`.\n - Inspect the run directory only when the user explicitly asks to debug, view artifacts, or confirm execution details.\n- Agent tasks only need to produce valid output by default. They should send to an external channel only when the task body explicitly requires it.\n\n## Designing The Task Body\n\n### Recommended Agent Task Structure\n\nThe body should include at least these headings:\n\n```md\n# Task Goal\n\n- What final result this task must deliver.\n\n# Background And Input\n\n- Data sources, scope, constraints, and reference materials.\n\n# Execution Steps\n\n1. What to do first.\n2. What to do next.\n3. Where key intermediate artifacts should be written.\n\n# Output Requirements\n\n- What format the final result must use.\n- Whether a table, JSON, or Markdown is required.\n- What content must not be included.\n\n# Trigger And Status Recommendation\n\n- Why this task is suitable for `@manual`, cron, or `time:...`.\n- Whether it should currently be `paused` or `enabled`.\n\n# Notes\n\n- Risks, boundaries, and things not to do.\n```\n\n### Agent Task Body Writing Constraints\n\n- The task body must read like a delivery contract, so another executor can run it directly without relying on the current chat context.\n- `# Task Goal` must clearly state the final deliverable. Do not write vague goals such as \"take a look\", \"research this\", or \"handle this\".\n- `# Background And Input` must specify sources, scope, objects, time range, and constraints. Do not assume the executor can see the original chat context.\n- `# Execution Steps` should describe the task workflow, not task-management actions. Do not write \"first check whether a task with the same name exists\", \"then create a task\", or \"then trigger the task\".\n- `# Output Requirements` must clearly specify the final artifact's format, structure, tone, length, and excluded content.\n- Explicitly state that the final assistant message will be written directly to `output.md` and sent to the user. Therefore, the final answer must be exactly the deliverable content.\n- Content-generation tasks such as daily reports, reminders, morning briefings, summaries, and reports must explicitly require \"the final output is the deliverable body itself\". Do not let the executor output process notes.\n- If the task result should be sent to the user, the body should require \"output send-ready message content\" instead of asking the executor to explain what it has sent.\n- Unless truly needed, do not ask the executor to repeat the task title, sessionId, execution time, status, or other metadata in the body.\n- Constraints in the body must be executable and checkable. Avoid weak phrases such as \"appropriately\", \"as much as possible\", or \"depending on the situation\".\n- Do not put task creation, task update, task status lookup, or same-title existence checks into the body. Those belong to the task plugin, not to the task deliverable.\n\n### Forbidden Agent Task Body Patterns\n\n- Do not write the body in chat-reply style, for example:\n - \"I will help you...\"\n - \"First, let me...\"\n - \"I will check first...\"\n - \"I see there is already a task with the same name...\"\n- Do not write the body as task-management instructions, for example:\n - \"If the task exists, update it; otherwise create it.\"\n - \"First list, then run.\"\n - \"Tell the user that the task has started when done.\"\n- Do not write the body as a status-report template, for example:\n - \"Task status summary\"\n - \"Sent / completed / updated\"\n - \"Current task configuration\"\n- Do not describe only actions without describing the deliverable, for example:\n - \"Go collect some materials.\"\n - \"Generate some content and see.\"\n - \"Report back after finishing.\"\n- Do not use references that depend on the current context, for example:\n - \"Do what was said above.\"\n - \"Continue the previous one.\"\n - \"Send this out.\"\n\n### How To Judge Whether The Body Is Good\n\n- If you can copy the task body alone to another agent and it can still understand the goal, input, steps, and deliverable, the body is valid.\n- If deleting the output section leaves only \"go do something\" style instructions, the body is invalid.\n- If the body looks more like instructions for creating or updating a task than instructions for executing the task, the layering is wrong and the body must be rewritten.\n- If the body naturally encourages the executor to output process notes instead of the final artifact, the `# Output Requirements` section is not strong enough and must add explicit prohibitions.\n\n### Recommended Script Task Structure\n\n- The body must be a pure shell script. Do not mix in explanatory natural language.\n- Start with comments that describe the script's purpose, input dependencies, and failure conditions when possible.\n- Keep output stable so it can be sent directly as the final result.\n- If files need to be generated, write them to the run directory or to an explicit project path.\n\n### Output Design Principles\n\n- When a task completes, the system automatically sends the final result body back to the chat bound to `sessionId` through the chat plugin runtime's `send`.\n- The current implementation uses the simplest rule: the final assistant message is treated directly as the final result body and written to `output.md`.\n- Therefore, the \"Output Requirements\" section must be written for the final user, not only for developers.\n- For user-facing agent tasks, the body should require \"the final assistant message directly outputs the deliverable itself\". Do not let the executor explain how it created, checked, updated, triggered, or sent the task.\n- For content-generation tasks such as daily reports, reminders, morning briefings, and summaries, the final output should be exactly that content. It should not include process language such as \"I will handle this\", \"task sent\", or \"task status summary\".\n- By default, do not ask the executor to call chat plugin send actions again. The system handles final-result delivery.\n- Explicitly require chat plugin actions only for cross-conversation sending, additional CCs, multi-channel notifications, or similar cases.\n\n### Choosing `when` And `status`\n\n- A task is created as `status=enabled` by default. Set `paused` explicitly only when it is still a draft, likely to fail, or needs human confirmation.\n- For verified stable tasks that need automatic execution, use cron with `status=enabled`.\n- For a clear one-time execution, use `time:<ISO time with timezone>`. After execution, the system automatically falls back to `@manual` and `paused`.\n- If the user only wants to save it for later, do not enable scheduling directly.\n\n## Body Templates\n\n### Agent Template\n\n```md\n# Task Goal\n\n- Produce a final result that can be sent directly to the user.\n\n# Background And Input\n\n- Add context, files, links, scope, and assumptions here.\n\n# Execution Steps\n\n1. Understand the task goal and completion criteria.\n2. Collect necessary information and execute the task.\n3. Write key intermediate artifacts to the run directory.\n4. Output the final result body.\n\n# Output Requirements\n\n- The final assistant message is the final result. Do not include long logs.\n- The final assistant message must output the deliverable itself. Do not output task-management process, sending process, or status reports.\n- Do not use meta language such as \"I will help you...\", \"First, let me...\", or \"sent\".\n- By default, do not call the chat plugin send action again.\n\n# Trigger And Status Recommendation\n\n- Enable by default after creation. If this is only a draft or waiting for human confirmation, set it to `paused`.\n\n# Notes\n\n- Call chat plugin send actions only when cross-conversation or additional notifications are explicitly needed.\n```\n\n### Script Template\n\n```bash\n# Task goal: state in one sentence what the script should do\n# Input dependencies: list environment variables, files, and command dependencies\n# Failure conditions: list cases that should exit 1\n\nset -euo pipefail\n\n# 1. Prepare input\n\n# 2. Execute main logic\n\n# 3. Output final result. This output will be sent directly to the user.\n```\n\n## Recommendations\n\n- Run `list` before `create` or `update`.\n- Keep simple content-generation tasks single-turn by default. Set `review: true` only when you truly need \"draft, review, revise\".\n- Keep script task bodies as pure scripts, without redundant natural-language explanation.\n- If the user only wants to save something for later, create it as `paused`; otherwise keep the default enabled state.\n- The task body must describe what the final result should look like, not only say \"go do this and see\".\n- For content-generation tasks, explicitly require \"the final assistant message can only be the finished content body\" so the executor does not mistake process notes for the final result.\n";
8
8
 
9
9
  export default TEXT_MODULE_CONTENT;
@@ -1,45 +1,45 @@
1
1
  # Task Plugin
2
2
 
3
- 你可以通过 `task` plugin 管理任务定义、执行、调度与状态控制。
3
+ You can use the `task` plugin to manage task definitions, execution, scheduling, and status control.
4
4
 
5
- ## 任务模型
5
+ ## Task Model
6
6
 
7
- 每个任务定义在 `./.downcity/task/<title>/task.md`,包含:
8
- - frontmatter(结构化字段)
9
- - body(任务正文)
7
+ Each task is defined in `./.downcity/task/<title>/task.md` and contains:
8
+ - frontmatter for structured fields
9
+ - body for the task instructions
10
10
 
11
- frontmatter 核心字段:
12
- - `title`:任务唯一标识(唯一)
13
- - `description`:任务描述
14
- - `when`:触发条件,支持:`@manual` / cron / `time:<ISO8601-with-timezone>`
15
- - `sessionId`:任务执行会话
16
- - `status`:`enabled|paused|disabled`
17
- - `kind`:`agent|script`(默认 `agent`)
11
+ Core frontmatter fields:
12
+ - `title`: unique task identifier
13
+ - `description`: task description
14
+ - `when`: trigger condition, supporting `@manual`, cron, or `time:<ISO8601-with-timezone>`
15
+ - `sessionId`: task execution session
16
+ - `status`: `enabled|paused|disabled`
17
+ - `kind`: `agent|script`, defaulting to `agent`
18
18
 
19
- 执行时会产生 run 目录:
19
+ Each execution creates a run directory:
20
20
  - `./.downcity/task/<title>/<timestamp>/`
21
21
 
22
- 常见产物:
22
+ Common artifacts:
23
23
  - `input.md`
24
- - `output.md`(本次任务的最终输出正文)
25
- - `result.md`(执行摘要)
24
+ - `output.md`: final output body for this run
25
+ - `result.md`: execution summary
26
26
  - `run.json`
27
27
  - `run-progress.json`
28
- - `dialogue.md` / `dialogue.json`(agent 多轮)
29
- - `error.md`(失败时)
28
+ - `dialogue.md` / `dialogue.json`: multi-turn agent dialogue
29
+ - `error.md`: failure details
30
30
 
31
- ## 执行类型(kind)
31
+ ## Execution Kinds
32
32
 
33
33
  1. `kind=agent`
34
- - 将正文交给 agent 执行
35
- - 默认单轮完成;仅当 frontmatter 显式设置 `review: true` 时启用模拟用户多轮复核
36
- - 适合研究、分析、报告生成
34
+ - Sends the task body to an agent for execution.
35
+ - Completes in a single turn by default. Simulated multi-turn review is enabled only when frontmatter explicitly sets `review: true`.
36
+ - Suitable for research, analysis, and report generation.
37
37
 
38
38
  2. `kind=script`
39
- - 将正文当作 shell 脚本执行
40
- - 正文不能为空,必须是可执行脚本
39
+ - Treats the body as a shell script.
40
+ - The body must be non-empty and executable as a script.
41
41
 
42
- ## 可用 action
42
+ ## Available Actions
43
43
 
44
44
  - `list`
45
45
  - `create`
@@ -50,7 +50,7 @@ frontmatter 核心字段:
50
50
  - `enable`
51
51
  - `disable`
52
52
 
53
- ## Action 调用示例
53
+ ## Action Examples
54
54
 
55
55
  - `plugin_call({ plugin: "task", action: "list", payload: { status } })`
56
56
  - `plugin_call({ plugin: "task", action: "create", payload: { title, description, sessionId, when, kind, status } })`
@@ -58,180 +58,180 @@ frontmatter 核心字段:
58
58
  - `plugin_call({ plugin: "task", action: "update", payload: { title, description, when, status, sessionId } })`
59
59
  - `plugin_call({ plugin: "task", action: "delete", payload: { title } })`
60
60
 
61
- ## 关键约束
61
+ ## Key Constraints
62
62
 
63
- - `title` 唯一;create 去重仅按 `title` 精确匹配。
64
- - `when=time:...` 触发后会自动置为 `paused`,并回退为 `when=@manual`。
65
- - `run` 为异步受理:立即返回 `accepted=true`、`message`、`executionId`;调用方应把它视为“任务已进入后台执行,结果会自动通过 chat plugin runtime 发送,当前流程无需阻塞等待”。
66
- - 如果 `run` 返回 `accepted=true`:
67
- - 不要手动把 task 产出再转发给用户。
68
- - 不要主动读取 run 目录、`run-progress.json`、`output.md` 做轮询。
69
- - 只有当用户明确要求排查、查看产物或确认执行细节时,才进入 run 目录检查。
70
- - agent 任务默认只要求产生有效输出;仅当任务正文明确要求外发时,才应发送到外部 channel
63
+ - `title` is unique. `create` deduplicates only by exact `title`.
64
+ - After `when=time:...` triggers, the task is automatically set to `paused` and falls back to `when=@manual`.
65
+ - `run` is accepted asynchronously. It returns `accepted=true`, `message`, and `executionId` immediately. Treat this as "the task has entered background execution; the result will be sent automatically through the chat plugin runtime, and the current flow does not need to block."
66
+ - If `run` returns `accepted=true`:
67
+ - Do not manually forward task output to the user again.
68
+ - Do not actively poll the run directory, `run-progress.json`, or `output.md`.
69
+ - Inspect the run directory only when the user explicitly asks to debug, view artifacts, or confirm execution details.
70
+ - Agent tasks only need to produce valid output by default. They should send to an external channel only when the task body explicitly requires it.
71
71
 
72
- ## 如何设计 task 正文
72
+ ## Designing The Task Body
73
73
 
74
- ### agent task 推荐结构
74
+ ### Recommended Agent Task Structure
75
75
 
76
- 建议正文至少包含这些标题:
76
+ The body should include at least these headings:
77
77
 
78
78
  ```md
79
- # 任务目标
79
+ # Task Goal
80
80
 
81
- - 这次任务要交付什么最终结果
81
+ - What final result this task must deliver.
82
82
 
83
- # 背景与输入
83
+ # Background And Input
84
84
 
85
- - 数据来源、范围、约束、参考材料
85
+ - Data sources, scope, constraints, and reference materials.
86
86
 
87
- # 执行步骤
87
+ # Execution Steps
88
88
 
89
- 1. 先做什么
90
- 2. 再做什么
91
- 3. 关键中间产物落在哪里
89
+ 1. What to do first.
90
+ 2. What to do next.
91
+ 3. Where key intermediate artifacts should be written.
92
92
 
93
- # 输出要求
93
+ # Output Requirements
94
94
 
95
- - 最终结果用什么格式返回
96
- - 是否需要表格 / JSON / Markdown
97
- - 不要包含什么内容
95
+ - What format the final result must use.
96
+ - Whether a table, JSON, or Markdown is required.
97
+ - What content must not be included.
98
98
 
99
- # 触发与状态建议
99
+ # Trigger And Status Recommendation
100
100
 
101
- - 这个任务为什么适合 `@manual` / cron / `time:...`
102
- - 当前应该是 `paused` 还是 `enabled`
101
+ - Why this task is suitable for `@manual`, cron, or `time:...`.
102
+ - Whether it should currently be `paused` or `enabled`.
103
103
 
104
- # 注意事项
104
+ # Notes
105
105
 
106
- - 风险、边界、不要做什么
106
+ - Risks, boundaries, and things not to do.
107
107
  ```
108
108
 
109
- ### agent task 正文编写约束
110
-
111
- - task 正文必须像一份“交付合同”,让另一个执行器拿到后可以直接执行,不依赖当前聊天语境补全含义。
112
- - `# 任务目标` 必须写清楚最终要交付什么,不要只写“看一下”“研究一下”“处理一下”这类模糊目标。
113
- - `# 背景与输入` 必须写清来源、范围、对象、时间、限制条件;不要假设执行器还能看到原始聊天上下文。
114
- - `# 执行步骤` 应描述任务流程,不应描述 task 管理动作;不要写“先检查有没有同名任务”“再创建任务”“然后触发任务”。
115
- - `# 输出要求` 必须清楚声明最终成品的格式、结构、语气、长度,以及“不要输出什么”。
116
- - 要明确写出:**最后一条 assistant 返回会被直接写入 `output.md` 并发送给用户**;因此最终回答必须直接等于成品内容。
117
- - 内容生成类任务(如日报、提醒、晨读、摘要、报告)必须明确要求“最终输出直接是成品正文”,不要让执行器输出过程说明。
118
- - 如果任务要把结果发给用户,正文应要求“输出可直接发送的正文内容”,而不是要求执行器解释自己已经发送了什么。
119
- - 除非确有需要,不要在正文中要求执行器复述 task titlesessionId、执行时间、状态等元信息。
120
- - 正文中的约束要可执行、可判断,尽量避免“适当”“尽量”“看情况”这类弱约束词。
121
- - 不要把创建 task、更新 task、查看 task 状态、确认 task 是否存在等管理动作写进正文;这些属于 task plugin 的职责,不属于 task 正文交付物。
122
-
123
- ### agent task 正文禁止写法
124
-
125
- - 不要把正文写成聊天回复口吻,例如:
126
- - “我来为你……”
127
- - “首先让我……”
128
- - “我先检查一下……”
129
- - “我看到已经有一个同名任务……”
130
- - 不要把正文写成任务管理说明,例如:
131
- - “如果任务已存在则更新,否则创建”
132
- - “先 list run
133
- - “完成后告诉用户任务已启动”
134
- - 不要把正文写成状态汇报模板,例如:
135
- - “任务状态总结”
136
- - “已发送 / 已完成 / 已更新”
137
- - “当前任务配置如下”
138
- - 不要只描述动作,不描述成品,例如:
139
- - “去搜集一些资料”
140
- - “生成一个内容看看”
141
- - “做完后反馈结果”
142
- - 不要把正文写成依赖当前上下文的指代,例如:
143
- - “按上面说的做”
144
- - “继续刚才那个”
145
- - “把这个发出去”
146
-
147
- ### 如何判断正文写得对不对
148
-
149
- - 如果把 task 正文单独复制出来给另一个 agent,它仍然能理解任务目标、输入、步骤和交付物,说明正文合格。
150
- - 如果最终输出章节删掉后,正文只剩“去做一下”式描述,说明正文不合格。
151
- - 如果正文更像“创建/更新任务的操作说明”,而不是“任务执行说明”,说明分层错了,必须重写。
152
- - 如果正文天然会诱导执行器输出过程汇报,而不是最终成品,说明 `# 输出要求` 写得不够强,必须补充禁止项。
153
-
154
- ### script task 推荐结构
155
-
156
- - 正文必须是纯 shell 脚本,不要混入解释性自然语言。
157
- - 开头尽量写注释说明脚本目的、输入依赖、失败条件。
158
- - 输出保持稳定,便于直接作为最终结果发送给用户。
159
- - 如需生成文件,写到 run 目录或明确的项目路径。
160
-
161
- ### 输出设计原则
162
-
163
- - task 完成后,系统会自动把**最终结果正文**通过 chat plugin runtime `send` 发回 `sessionId` 绑定的 chat
164
- - 当前实现采用最简规则:**最后一条 assistant 返回**会被直接视为最终结果正文,并写入 `output.md`。
165
- - 因此正文里的“输出要求”要面向最终用户阅读,不要只写给开发者看。
166
- - 对于面向用户的 agent task,正文应要求“最后一条 assistant 返回直接输出最终交付物本身”,不要让执行器在最后回答里输出自己如何创建、检查、更新、触发或发送任务。
167
- - 如果任务是内容生成类(例如日报、提醒、晨读、摘要),最后输出应直接是那段内容本身,不要附带“我来为你处理”“任务已发送”“任务状态总结”等过程汇报。
168
- - 默认不要在正文里再次要求执行器发送 chat 消息;系统会处理最终结果回传。
169
- - 只有在“跨会话发送”“额外抄送”“多渠道通知”这类场景下,才显式要求执行器调用 chat plugin action。
170
-
171
- ### `when` / `status` 怎么选
172
-
173
- - task 创建默认就是 `status=enabled`;如果还在试任务、容易失败、需要人工确认,再显式切到 `paused`。
174
- - 已经验证稳定、需要自动运行:直接使用 cron + `status=enabled`。
175
- - 明确只执行一次:使用 `time:<带时区 ISO 时间>`;执行后系统会自动回退到 `@manual` + `paused`。
176
- - 如果用户只是“先存起来以后再跑”,不要直接启用调度。
177
-
178
- ## 正文模板
179
-
180
- ### agent 模板
109
+ ### Agent Task Body Writing Constraints
110
+
111
+ - The task body must read like a delivery contract, so another executor can run it directly without relying on the current chat context.
112
+ - `# Task Goal` must clearly state the final deliverable. Do not write vague goals such as "take a look", "research this", or "handle this".
113
+ - `# Background And Input` must specify sources, scope, objects, time range, and constraints. Do not assume the executor can see the original chat context.
114
+ - `# Execution Steps` should describe the task workflow, not task-management actions. Do not write "first check whether a task with the same name exists", "then create a task", or "then trigger the task".
115
+ - `# Output Requirements` must clearly specify the final artifact's format, structure, tone, length, and excluded content.
116
+ - Explicitly state that the final assistant message will be written directly to `output.md` and sent to the user. Therefore, the final answer must be exactly the deliverable content.
117
+ - Content-generation tasks such as daily reports, reminders, morning briefings, summaries, and reports must explicitly require "the final output is the deliverable body itself". Do not let the executor output process notes.
118
+ - If the task result should be sent to the user, the body should require "output send-ready message content" instead of asking the executor to explain what it has sent.
119
+ - Unless truly needed, do not ask the executor to repeat the task title, sessionId, execution time, status, or other metadata in the body.
120
+ - Constraints in the body must be executable and checkable. Avoid weak phrases such as "appropriately", "as much as possible", or "depending on the situation".
121
+ - Do not put task creation, task update, task status lookup, or same-title existence checks into the body. Those belong to the task plugin, not to the task deliverable.
122
+
123
+ ### Forbidden Agent Task Body Patterns
124
+
125
+ - Do not write the body in chat-reply style, for example:
126
+ - "I will help you..."
127
+ - "First, let me..."
128
+ - "I will check first..."
129
+ - "I see there is already a task with the same name..."
130
+ - Do not write the body as task-management instructions, for example:
131
+ - "If the task exists, update it; otherwise create it."
132
+ - "First list, then run."
133
+ - "Tell the user that the task has started when done."
134
+ - Do not write the body as a status-report template, for example:
135
+ - "Task status summary"
136
+ - "Sent / completed / updated"
137
+ - "Current task configuration"
138
+ - Do not describe only actions without describing the deliverable, for example:
139
+ - "Go collect some materials."
140
+ - "Generate some content and see."
141
+ - "Report back after finishing."
142
+ - Do not use references that depend on the current context, for example:
143
+ - "Do what was said above."
144
+ - "Continue the previous one."
145
+ - "Send this out."
146
+
147
+ ### How To Judge Whether The Body Is Good
148
+
149
+ - If you can copy the task body alone to another agent and it can still understand the goal, input, steps, and deliverable, the body is valid.
150
+ - If deleting the output section leaves only "go do something" style instructions, the body is invalid.
151
+ - If the body looks more like instructions for creating or updating a task than instructions for executing the task, the layering is wrong and the body must be rewritten.
152
+ - If the body naturally encourages the executor to output process notes instead of the final artifact, the `# Output Requirements` section is not strong enough and must add explicit prohibitions.
153
+
154
+ ### Recommended Script Task Structure
155
+
156
+ - The body must be a pure shell script. Do not mix in explanatory natural language.
157
+ - Start with comments that describe the script's purpose, input dependencies, and failure conditions when possible.
158
+ - Keep output stable so it can be sent directly as the final result.
159
+ - If files need to be generated, write them to the run directory or to an explicit project path.
160
+
161
+ ### Output Design Principles
162
+
163
+ - When a task completes, the system automatically sends the final result body back to the chat bound to `sessionId` through the chat plugin runtime's `send`.
164
+ - The current implementation uses the simplest rule: the final assistant message is treated directly as the final result body and written to `output.md`.
165
+ - Therefore, the "Output Requirements" section must be written for the final user, not only for developers.
166
+ - For user-facing agent tasks, the body should require "the final assistant message directly outputs the deliverable itself". Do not let the executor explain how it created, checked, updated, triggered, or sent the task.
167
+ - For content-generation tasks such as daily reports, reminders, morning briefings, and summaries, the final output should be exactly that content. It should not include process language such as "I will handle this", "task sent", or "task status summary".
168
+ - By default, do not ask the executor to call chat plugin send actions again. The system handles final-result delivery.
169
+ - Explicitly require chat plugin actions only for cross-conversation sending, additional CCs, multi-channel notifications, or similar cases.
170
+
171
+ ### Choosing `when` And `status`
172
+
173
+ - A task is created as `status=enabled` by default. Set `paused` explicitly only when it is still a draft, likely to fail, or needs human confirmation.
174
+ - For verified stable tasks that need automatic execution, use cron with `status=enabled`.
175
+ - For a clear one-time execution, use `time:<ISO time with timezone>`. After execution, the system automatically falls back to `@manual` and `paused`.
176
+ - If the user only wants to save it for later, do not enable scheduling directly.
177
+
178
+ ## Body Templates
179
+
180
+ ### Agent Template
181
181
 
182
182
  ```md
183
- # 任务目标
183
+ # Task Goal
184
184
 
185
- - 产出一份可直接发给用户的最终结果。
185
+ - Produce a final result that can be sent directly to the user.
186
186
 
187
- # 背景与输入
187
+ # Background And Input
188
188
 
189
- - 在这里补充上下文、文件、链接、范围和假设。
189
+ - Add context, files, links, scope, and assumptions here.
190
190
 
191
- # 执行步骤
191
+ # Execution Steps
192
192
 
193
- 1. 理解任务目标与完成标准。
194
- 2. 收集必要信息并执行任务。
195
- 3. 把关键中间产物写入 run 目录。
196
- 4. 输出最终结果正文。
193
+ 1. Understand the task goal and completion criteria.
194
+ 2. Collect necessary information and execute the task.
195
+ 3. Write key intermediate artifacts to the run directory.
196
+ 4. Output the final result body.
197
197
 
198
- # 输出要求
198
+ # Output Requirements
199
199
 
200
- - 最后一条 assistant 返回直接作为最终结果,不要附带冗长日志。
201
- - 最后一条 assistant 返回直接输出交付物本身,不要输出任务管理过程、发送过程或状态汇报。
202
- - 不要使用“我来为你…… / 首先让我…… / 已发送……”这类元话术。
203
- - 默认不要再次调用 chat plugin 的发送 action
200
+ - The final assistant message is the final result. Do not include long logs.
201
+ - The final assistant message must output the deliverable itself. Do not output task-management process, sending process, or status reports.
202
+ - Do not use meta language such as "I will help you...", "First, let me...", or "sent".
203
+ - By default, do not call the chat plugin send action again.
204
204
 
205
- # 触发与状态建议
205
+ # Trigger And Status Recommendation
206
206
 
207
- - 默认创建后立即启用;如果只是先保存草稿或等待人工确认,再改成 `paused`。
207
+ - Enable by default after creation. If this is only a draft or waiting for human confirmation, set it to `paused`.
208
208
 
209
- # 注意事项
209
+ # Notes
210
210
 
211
- - 仅在明确需要跨会话或额外通知时,才调用 chat plugin 的发送 action。
211
+ - Call chat plugin send actions only when cross-conversation or additional notifications are explicitly needed.
212
212
  ```
213
213
 
214
- ### script 模板
214
+ ### Script Template
215
215
 
216
216
  ```bash
217
- # 任务目标:一句话说明脚本要做什么
218
- # 输入依赖:列出环境变量、文件、命令依赖
219
- # 失败条件:列出应该 exit 1 的情况
217
+ # Task goal: state in one sentence what the script should do
218
+ # Input dependencies: list environment variables, files, and command dependencies
219
+ # Failure conditions: list cases that should exit 1
220
220
 
221
221
  set -euo pipefail
222
222
 
223
- # 1. 准备输入
223
+ # 1. Prepare input
224
224
 
225
- # 2. 执行主逻辑
225
+ # 2. Execute main logic
226
226
 
227
- # 3. 输出最终结果(这段输出会被直接发送给用户)
227
+ # 3. Output final result. This output will be sent directly to the user.
228
228
  ```
229
229
 
230
- ## 建议
230
+ ## Recommendations
231
231
 
232
- - `list`,再 `create`/`update`。
233
- - 简单内容生成任务优先保持默认单轮;只有确实需要“先生成、再复核、再修订”时再设置 `review: true`。
234
- - script 任务正文保持纯脚本,不要混入冗余自然语言。
235
- - 如果用户只是先存起来以后再跑,创建后显式设成 `paused`;否则保持默认启用。
236
- - task 正文要写“最终结果长什么样”,不要只写“去做一下看看”。
237
- - 对内容生成任务,要明确写“最后一条 assistant 返回只能是成品正文”,避免执行器把过程说明误当成最终结果。
232
+ - Run `list` before `create` or `update`.
233
+ - Keep simple content-generation tasks single-turn by default. Set `review: true` only when you truly need "draft, review, revise".
234
+ - Keep script task bodies as pure scripts, without redundant natural-language explanation.
235
+ - If the user only wants to save something for later, create it as `paused`; otherwise keep the default enabled state.
236
+ - The task body must describe what the final result should look like, not only say "go do this and see".
237
+ - For content-generation tasks, explicitly require "the final assistant message can only be the finished content body" so the executor does not mistake process notes for the final result.
@@ -142,7 +142,7 @@ export async function runTaskNow(params: {
142
142
  await runProgress.update({
143
143
  status: "running",
144
144
  phase: "preparing",
145
- message: "执行输入已写入,准备开始任务执行",
145
+ message: "Execution input has been written; preparing to start task execution.",
146
146
  ...(taskKind === "agent" ? { maxRounds: maxDialogueRounds } : {}),
147
147
  });
148
148
 
@@ -444,7 +444,7 @@ export async function runTaskNow(params: {
444
444
  await runProgress.update({
445
445
  status: "running",
446
446
  phase: "writing_artifacts",
447
- message: "正在写入 output/result/run 元数据",
447
+ message: "Writing output/result/run metadata.",
448
448
  ...(taskKind === "agent" ? { maxRounds: maxDialogueRounds } : { maxRounds: 1 }),
449
449
  ...(dialogueRounds > 0 ? { round: dialogueRounds } : {}),
450
450
  });