@muzi3/herdr 0.1.1 → 0.1.2

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.
@@ -5,7 +5,9 @@
5
5
  * 每个窗口重启后恢复到原来的 session。
6
6
  *
7
7
  * 行为约定:
8
- * - 跳过 agent_status 为 "working" 的窗口(含当前发起命令的窗口本身)。
8
+ * - 跳过 agent_status 为 "working" 的窗口,以及当前发起命令的窗口自身
9
+ * (按 `HERDR_PANE_ID` 排除;敲命令时该窗口是 idle,不能只靠状态排除,
10
+ * 否则会把自己的 pi 进程也 SIGTERM 掉,循环当场中断)。
9
11
  * - 重启前弹确认框,列出将重启的窗口与数量。
10
12
  * - 通过向 pi 前台进程组发 SIGTERM 触发优雅退出(session 落盘),
11
13
  * 退出后用 `herdr pane run` 以 `pi --session <path|id>` 重新拉起。
@@ -143,7 +145,7 @@ async function relaunch(agent: PiAgent): Promise<void> {
143
145
 
144
146
  export default function (pi: ExtensionAPI) {
145
147
  pi.registerCommand("pi-hot-restart", {
146
- description: "批量重启当前 herdr 里的所有 pi 窗口(跳过 working),并恢复到原 session",
148
+ description: "批量重启当前 herdr 里的所有 pi 窗口(跳过 working 与当前窗口),并恢复到原 session",
147
149
  handler: async (_args, ctx) => {
148
150
  let agents: PiAgent[];
149
151
  try {
@@ -158,18 +160,19 @@ export default function (pi: ExtensionAPI) {
158
160
  return;
159
161
  }
160
162
 
161
- const targets = agents.filter((a) => a.agent_status !== "working");
162
- const skipped = agents.filter((a) => a.agent_status === "working");
163
+ const self = process.env.HERDR_PANE_ID;
164
+ const targets = agents.filter((a) => a.agent_status !== "working" && a.pane_id !== self);
165
+ const skipped = agents.filter((a) => a.agent_status === "working" || a.pane_id === self);
163
166
 
164
167
  if (targets.length === 0) {
165
- ctx.ui.notify(`所有 ${agents.length} 个 pi 窗口都在 working,无可重启窗口`, "info");
168
+ ctx.ui.notify(`没有可重启的 pi 窗口(共 ${agents.length} 个,其余为 working 或当前窗口)`, "info");
166
169
  return;
167
170
  }
168
171
 
169
172
  const list = targets
170
173
  .map((a) => ` - ${a.terminal_title ?? a.pane_id} (${a.cwd})`)
171
174
  .join("\n");
172
- const skipNote = skipped.length ? `\n\n将跳过 ${skipped.length} 个 working 窗口` : "";
175
+ const skipNote = skipped.length ? `\n\n将跳过 ${skipped.length} 个窗口(working 或当前窗口)` : "";
173
176
  const ok = await ctx.ui.confirm(
174
177
  "pi-hot-restart",
175
178
  `将重启 ${targets.length} 个 pi 窗口:\n${list}${skipNote}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muzi3/herdr",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Herdr for pi: the herdr operate skill (control Herdr from inside a pane), the herdr-guide skill (teach a human to set up and troubleshoot Herdr), and the herdr-agent-state extension (report agent state to Herdr).",
5
5
  "keywords": [
6
6
  "pi-package",