@ethlete/agent-rules 0.1.0-next.53 → 0.1.0-next.55

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ethlete/agent-rules
2
2
 
3
+ ## 0.1.0-next.55
4
+
5
+ ### Patch Changes
6
+
7
+ - `agent-sessions restart --process` is refused while the target pane shows running background shells or agents, and names them. Pass `--force` to stop them anyway. A plain restart still clears and leaves them running.
8
+
9
+ ## 0.1.0-next.54
10
+
11
+ ### Patch Changes
12
+
13
+ - The `codex-runs` mod counts only the Codex runs the own session started in its status line.
14
+
3
15
  ## 0.1.0-next.53
4
16
 
5
17
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-runs",
3
- "version": "0.1.0-next.53",
3
+ "version": "0.1.0-next.55",
4
4
  "description": "Codex sessions in tmux with their state, duration, and recent output",
5
5
  "types": "./types/index.d.ts"
6
6
  }
@@ -263,8 +263,8 @@ export function durationOf(run: { startedAt: number; endedAt: number | null }, n
263
263
  return minutes ? `${minutes}m${String(seconds % 60).padStart(2, '0')}s` : `${seconds}s`;
264
264
  }
265
265
 
266
- export function statusOf(runs: AgentRun[], now: number) {
267
- const running = runs.filter((run) => run.state === 'running');
266
+ export function statusOf(runs: AgentRun[], session: string, now: number) {
267
+ const running = runs.filter((run) => run.state === 'running' && run.session === session);
268
268
  if (running.length === 0) return undefined;
269
269
  const oldest = Math.min(...running.map((run) => run.startedAt));
270
270
  return `Codex: ${running.length} running, ${Math.max(0, Math.floor((now - oldest) / 60_000))}m`;
@@ -99,7 +99,7 @@ async function refreshAgentRuns($: EngineInterface, sessionId: string, now: numb
99
99
  await update($, toolRuns, () => paired.claimed);
100
100
  await update($, waitingCalls, () => open);
101
101
  }
102
- setStatus($, statusOf(next, now));
102
+ setStatus($, statusOf(next, sessionId, now));
103
103
  }
104
104
 
105
105
  async function refresh($: EngineInterface) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "e2e-progress",
3
- "version": "0.1.0-next.53",
3
+ "version": "0.1.0-next.55",
4
4
  "description": "Live Playwright e2e progress from a run log, as a status line entry and a pane",
5
5
  "types": "./types/index.d.ts"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "status-line",
3
- "version": "0.1.0-next.53",
3
+ "version": "0.1.0-next.55",
4
4
  "description": "Always-visible band with the running task, its duration, the open queue, open questions and a CI blocked mark",
5
5
  "types": "./types/index.d.ts"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usage-line",
3
- "version": "0.1.0-next.53",
3
+ "version": "0.1.0-next.55",
4
4
  "description": "Status line entry with the 5 hour and weekly usage, the reset time of the 5 hour window and the Codex limit",
5
5
  "types": "./types/index.d.ts"
6
6
  }
@@ -20,7 +20,7 @@ script, so you do not need `<skill-dir>`. The older name `npx ethlete-agents mai
20
20
  ```bash
21
21
  node <skill-dir>/agent-sessions.mjs run <name> <command...> [--role builder] [--dry-run]
22
22
  node <skill-dir>/agent-sessions.mjs up <name>[=<command>]...
23
- node <skill-dir>/agent-sessions.mjs restart <name> [--after <seconds>] [--notify <agent,...>] [--process [--config <dir>]] [--role builder|none] <prompt...>
23
+ node <skill-dir>/agent-sessions.mjs restart <name> [--after <seconds>] [--notify <agent,...>] [--process [--force] [--config <dir>]] [--role builder|none] <prompt...>
24
24
  node <skill-dir>/agent-sessions.mjs down [<name>...]
25
25
  node <skill-dir>/agent-sessions.mjs shell-install [<agent>...] [--file <path>] [--remove] [--dry-run]
26
26
  node <skill-dir>/agent-sessions.mjs shell-init [<agent>...]
@@ -58,7 +58,7 @@ Nothing runs until you start it, so a person who does not use this does nothing.
58
58
  - **Denied by permissions.** If the permission system denies your own `restart`, send one mailbox line to the grill/docs session, for example `send <you> --to <grill> 'restart denied, please /clear my pane and type: <prompt>'`. It types into your pane only when the pane is idle by the rule above.
59
59
  - **Open questions.** For a `claude` session, `restart` reads the transcript and refuses while a chat line that starts with `❓` has no later message the human typed, unless the handoff the prompt resumes (`/handoff resume <name>`) names that question verbatim under "Open for the human". The refusal lists the questions to copy there.
60
60
 
61
- `restart --process` ends the agent process instead of clearing it: it types `/exit` (`/quit` for a `codex` name) and starts the agent command again in the same tmux pane, through a login shell, with the prompt as its first message. It also stops the background shells and agents. Use it only after a change to an installed plugin, a settings file, an MCP server or `PATH`, use `--process`. The agent command is the one `run` started, without its prompt. It starts with `command`, so the shell function of the same name does not start a new session. If the exit opens the background work dialog, it selects "exit and stop tasks" and writes the stopped jobs to `restart.log` and a mailbox notice.
61
+ `restart --process` ends the agent process instead of clearing it: it types `/exit` (`/quit` for a `codex` name) and starts the agent command again in the same tmux pane, through a login shell, with the prompt as its first message. It also stops the background shells and agents, so it is refused while the pane shows any (footer count or agent panel row) and names them; `--force` stops them anyway. Use it only after a change to an installed plugin, a settings file, an MCP server or `PATH`, use `--process`. The agent command is the one `run` started, without its prompt. It starts with `command`, so the shell function of the same name does not start a new session. If the exit opens the background work dialog, it selects "exit and stop tasks" and writes the stopped jobs to `restart.log` and a mailbox notice.
62
62
 
63
63
  The new process takes the target's role, not the caller's: `--role`, else a resumed `builder-*` or `doc-agent-*` handoff's (`doc-agent-*` is none), else its own. A builder process gets `ETHLETE_AGENT_ROLE=builder` and, for `claude`, the builder system prompt once. A session with no role next to another agent session in the repo, none of them a builder, is refused unless the prompt resumes a `builder-*` or `doc-agent-*` handoff or `--role` is passed (`--role none` restarts it without a role).
64
64
 
@@ -90,10 +90,11 @@ Run: node ${script} run <name> <command...> [--role builder] [--dry-run]
90
90
  Install: node ${script} shell-install [<agent>...] [--file <path>] [--remove] [--dry-run]
91
91
  (write the shell functions into ~/.zshrc or ~/.bashrc)
92
92
  Shell: node ${script} shell-init [<agent>...] (print shell functions that wrap each agent with run; default: claude codex)
93
- Restart: node ${script} restart <name> [--after <seconds>] [--notify <agent,...>] [--process [--config <dir>]] [--role builder|none] <prompt...>
93
+ Restart: node ${script} restart <name> [--after <seconds>] [--notify <agent,...>] [--process [--force] [--config <dir>]] [--role builder|none] <prompt...>
94
94
  (type the clear command and then the prompt into the tmux session of <name>;
95
95
  a long wait on a draft and a give-up go to <name> and each --notify agent;
96
- --process ends the agent and starts it again in the same pane with the prompt;
96
+ --process ends the agent and starts it again in the same pane with the prompt,
97
+ and is refused while the pane shows background shells or agents unless --force;
97
98
  --config changes the saved CLAUDE_CONFIG_DIR for a process restart;
98
99
  it takes --role, else the role a builder-*/doc-agent-* handoff names, else keeps the role, and refuses
99
100
  a session with no role while another agent session runs in the repo;
@@ -650,6 +651,12 @@ const typeResume = (session, prompt) => {
650
651
  return false;
651
652
  };
652
653
 
654
+ const runningWorkOf = (lines) =>
655
+ lines
656
+ .slice(lastRuleIndex(lines) + 1)
657
+ .map((line) => plain(line).trim())
658
+ .filter((line) => BACKGROUND_FOOTER.test(line) || isPanelRow(line));
659
+
653
660
  const backgroundWorkOf = (lines) => {
654
661
  const footer = lines.slice(lastRuleIndex(lines) + 1).map(plain);
655
662
  return footer.find((line) => BACKGROUND_FOOTER.test(line) || isPanelRow(line))?.trim() ?? null;
@@ -1173,6 +1180,13 @@ if (command === 'stop-own') {
1173
1180
  );
1174
1181
  process.exit(1);
1175
1182
  }
1183
+ const running = force ? [] : runningWorkOf(paneLines(session));
1184
+ if (running.length) {
1185
+ restartNotice(
1186
+ `restart --process of ${session} refused, it still runs background work: ${running.join('; ')}. Wait for it, or pass --force to stop it`,
1187
+ );
1188
+ process.exit(1);
1189
+ }
1176
1190
  if (stored !== recorded) {
1177
1191
  tmux('set-option', '-t', pane, COMMAND_OPTION, stored);
1178
1192
  restartLog(`${session} stored command could not restart, healed to: ${stored}`);
@@ -1257,12 +1271,18 @@ if (command === 'stop-own') {
1257
1271
  process.exitCode = 1;
1258
1272
  }
1259
1273
  }
1274
+ } else if (newProcess && !force && runningWorkOf(paneLines(session)).length) {
1275
+ process.stderr.write(
1276
+ `Refused: ${session} runs background work that --process would stop: ${runningWorkOf(paneLines(session)).join('; ')}\nWait for it, or pass --force to stop it.\n`,
1277
+ );
1278
+ process.exitCode = 1;
1260
1279
  } else {
1261
1280
  if (own && own !== session) restartLog(`peer restart: ${own} restarted ${session}`);
1262
1281
  const delay = Number(afterSeconds ?? RESTART_AFTER_SECONDS);
1263
1282
  const forward = notify ? ['--notify', notify] : [];
1264
1283
  const mode = [
1265
1284
  ...(newProcess ? ['--process'] : []),
1285
+ ...(newProcess && force ? ['--force'] : []),
1266
1286
  ...(configOverride === undefined ? [] : ['--config', configOverride]),
1267
1287
  ...(role ? ['--role', role] : []),
1268
1288
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethlete/agent-rules",
3
- "version": "0.1.0-next.53",
3
+ "version": "0.1.0-next.55",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ethlete-io/ethdk",