@cobia/pi-onward 0.5.0 → 0.5.1

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.
package/README.md CHANGED
@@ -62,6 +62,25 @@ onward 处理两类失败:Pi 明确以错误结束,或者正常结束但没
62
62
 
63
63
  `onward.stop` 只结束本轮恢复;需要持续停用自动恢复时,使用 `/onward off`
64
64
 
65
+ ### 状态栏
66
+
67
+ 状态栏采用 `emoji onward · 失败次数` 的短格式,例如 `⏳ onward · 失败3`。数字表示本轮连续失败次数,规则、动作名和完整原因通过 `/onward status` 查看
68
+
69
+ | Emoji | 含义 |
70
+ | :--- | :--- |
71
+ | ⏳ | 等待间隔、提议等待启动或动作待执行 |
72
+ | ⏩ | 已启动续跑 |
73
+ | 🚀 | 正在执行动作 |
74
+ | 🎉 | 动作完成 |
75
+ | 📤 | 命令已分派,业务结果由目标插件报告 |
76
+ | 🔀 | 已接受接管 |
77
+ | 🛑 | 本轮恢复停止,例如规则停止、未命中规则或达到次数上限 |
78
+ | 🚫 | 恢复已取消 |
79
+ | 💥 | 动作失败,同时显示“动作失败” |
80
+ | 🎲 | 结果未知,同时显示“结果未知” |
81
+
82
+ 空闲时隐藏状态栏;终止结果保留到当前恢复状态被清除。异常提示示例:`🎲 onward 结果未知 · 失败3`
83
+
65
84
  ### 续跑消息与任务提示词
66
85
 
67
86
  `pi.message` 的 `prompt` 默认为 `继续`,可以使用以下变量,也可以与正文拼接:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobia/pi-onward",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "pi 出错或空回复时,按阶段策略恢复并调用扩展命令或具名动作",
5
5
  "keywords": [
6
6
  "pi",
@@ -415,14 +415,27 @@ export class Recovery {
415
415
  export function stateText(state: RunState, failures: number): string | undefined {
416
416
  if (state.phase === "idle") return undefined;
417
417
  const phases = {
418
- waiting: "等待",
419
- submitted: "提议已提交",
420
- retrying: "续跑中",
421
- queued: "待执行",
422
- executing: "执行中",
423
- stopped: "已停止",
418
+ waiting: "⏳",
419
+ submitted: "⏳",
420
+ retrying: "⏩",
421
+ queued: "⏳",
422
+ executing: "🚀",
423
+ stopped: "🛑",
424
424
  };
425
- return `${state.phase === "stopped" ? "🛑" : "⏩"} onward · ${phases[state.phase]} · 失败 ${failures} 次${state.hit ? ` · ${state.hit.stage.action.use}` : ""}`;
425
+ const results: Record<ActionResult["kind"], string> = {
426
+ continue: "⏩",
427
+ completed: "🎉",
428
+ dispatched: "📤",
429
+ handoff: "🔀",
430
+ stopped: "🛑",
431
+ failed: "💥",
432
+ cancelled: "🚫",
433
+ unknown: "🎲",
434
+ };
435
+ const result = state.phase === "stopped" ? state.result : undefined;
436
+ const icon = result ? results[result] : phases[state.phase];
437
+ const detail = result === "failed" ? " 动作失败" : result === "unknown" ? " 结果未知" : "";
438
+ return `${icon} onward${detail} · 失败${failures}`;
426
439
  }
427
440
  function validResult(value: unknown, definition: ActionDefinition): value is ActionResult {
428
441
  if (!isRecord(value) || typeof value.kind !== "string") return false;