@ethlete/agent-rules 0.1.0-next.40 → 0.1.0-next.42
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 +16 -0
- package/content/mods/plugins/e2e-progress/.claude-plugin/plugin.json +1 -1
- package/content/mods/plugins/status-line/.claude-plugin/plugin.json +1 -1
- package/content/skills/agent-sessions/SKILL.md +1 -1
- package/content/skills/agent-sessions/agent-sessions.mjs +179 -32
- package/content/skills/domain-modeling/ADR-FORMAT.md +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ethlete/agent-rules
|
|
2
2
|
|
|
3
|
+
## 0.1.0-next.42
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- The domain-modeling ADR format names the `parts` frontmatter: an ADR with `parts` and no `built` is an open plan question on each part.
|
|
8
|
+
- On Linux, `agent-sessions` starts the agent in its own systemd user scope that systemd-oomd avoids, so a heavy job is killed before the agent.
|
|
9
|
+
- When the checkout has `tools/scripts/own-scope-preload.mjs`, `agent-sessions` registers it through `NODE_OPTIONS` for the agent, so each nx, vitest and tsc run the agent starts leaves the avoided agent scope.
|
|
10
|
+
- Fix `agent-sessions restart --process`: a command a login shell wraps (`zsh -lic '...'`) is rewritten inside the wrapper and keeps the prompt inside it, and the new process takes the role of the target session, not a stale one.
|
|
11
|
+
|
|
12
|
+
## 0.1.0-next.41
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- `agent-sessions restart --process` starts the agent program itself when the stored command is a `run` of the script, `run` inside the pane of its own session starts the agent in place, and `run --dry-run` shows the caller `CLAUDE_CONFIG_DIR`.
|
|
17
|
+
- `agent-sessions` gives the builder flags to a `claude` that follows `env` and env assignments, as in a stored `env CLAUDE_CONFIG_DIR=... claude`.
|
|
18
|
+
|
|
3
19
|
## 0.1.0-next.40
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -60,7 +60,7 @@ Nothing runs until you start it, so a person who does not use this does nothing.
|
|
|
60
60
|
|
|
61
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.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
|
-
The new process
|
|
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
|
|
|
65
65
|
`shell-install` writes one shell function per agent into `~/.zshrc` or `~/.bashrc`, between two marker lines. A second run replaces the block, and `--remove` deletes it. Use `--file` for another startup file and `--dry-run` to preview. After a new terminal opens, typing `claude` or `codex` in a repo with this skill runs the agent through `run`. Elsewhere the function starts the plain command. Run `shell-install` only when the user asks: it changes a file the user owns. `shell-init` prints the same functions without writing a file.
|
|
66
66
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from 'node:fs';
|
|
12
12
|
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
13
13
|
import { homedir } from 'node:os';
|
|
14
|
-
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
15
15
|
|
|
16
16
|
const root = (() => {
|
|
17
17
|
try {
|
|
@@ -91,7 +91,7 @@ Restart: node ${script} restart <name> [--after <seconds>] [--notify <agent,...>
|
|
|
91
91
|
(type the clear command and then the prompt into the tmux session of <name>;
|
|
92
92
|
a long wait on a draft and a give-up go to <name> and each --notify agent;
|
|
93
93
|
--process ends the agent and starts it again in the same pane with the prompt;
|
|
94
|
-
it
|
|
94
|
+
it takes --role, else the role a builder-*/doc-agent-* handoff names, else keeps the role, and refuses
|
|
95
95
|
a session with no role while another agent session runs in the repo;
|
|
96
96
|
refuses while a ❓ question of a claude session has no later human message
|
|
97
97
|
and the resumed handoff does not name it under "Open for the human")
|
|
@@ -127,8 +127,9 @@ const ensuredClaudeTmpDir = () => {
|
|
|
127
127
|
};
|
|
128
128
|
const tempDirEnv = () => `CLAUDE_CODE_TMPDIR=${quote(ensuredClaudeTmpDir())} `;
|
|
129
129
|
const withTempDir = (command) => (/(^|\s)CLAUDE_CODE_TMPDIR=/.test(command) ? command : `${tempDirEnv()}${command}`);
|
|
130
|
+
const programOf = (words) => words.find((word) => word !== 'env' && !ENV_WORD.test(word) && !word.startsWith('-'));
|
|
130
131
|
const withRole = (words) =>
|
|
131
|
-
role === 'builder' && basename(words
|
|
132
|
+
role === 'builder' && basename(programOf(words) ?? '') === 'claude' ? [...words, ...builderFlags()] : words;
|
|
132
133
|
const roleEnvOf = (agentRole) =>
|
|
133
134
|
agentRole
|
|
134
135
|
? { ETHLETE_AGENT_ROLE: agentRole, ...(agentRole === 'builder' ? { CLAUDE_CODE_SILENT_TURN_REMINDER: '0' } : {}) }
|
|
@@ -164,7 +165,15 @@ const foreignCheckoutsOf = (agent) => [
|
|
|
164
165
|
),
|
|
165
166
|
];
|
|
166
167
|
const createRunSession = (session, shellCommand, baseCommand) => {
|
|
167
|
-
const result = tmux(
|
|
168
|
+
const result = tmux(
|
|
169
|
+
'new-session',
|
|
170
|
+
'-d',
|
|
171
|
+
'-s',
|
|
172
|
+
session,
|
|
173
|
+
'-c',
|
|
174
|
+
process.cwd(),
|
|
175
|
+
inAgentScopeCommand(shellCommand, session),
|
|
176
|
+
);
|
|
168
177
|
if (result.status !== 0) {
|
|
169
178
|
process.stderr.write(`No agent was started: tmux could not create ${session}: ${result.stderr.trim()}\n`);
|
|
170
179
|
process.exitCode = 1;
|
|
@@ -178,6 +187,10 @@ const createRunSession = (session, shellCommand, baseCommand) => {
|
|
|
178
187
|
process.exitCode = 1;
|
|
179
188
|
}
|
|
180
189
|
};
|
|
190
|
+
const ownSession = () =>
|
|
191
|
+
process.env.TMUX_PANE
|
|
192
|
+
? tmux('display-message', '-p', '-t', process.env.TMUX_PANE, '#{session_name}').stdout.trim() || null
|
|
193
|
+
: null;
|
|
181
194
|
const ONE_SHOT_FLAGS = new Set(['-p', '--print', '-v', '--version', '-h', '--help']);
|
|
182
195
|
const hasTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
183
196
|
const runsInSession = (agentArgs) => !agentArgs.some((arg) => ONE_SHOT_FLAGS.has(arg));
|
|
@@ -209,6 +222,10 @@ const configMismatch = (words) => {
|
|
|
209
222
|
const given = configDirOf(words);
|
|
210
223
|
return given !== undefined && resolve(given) !== callerConfigDir();
|
|
211
224
|
};
|
|
225
|
+
const callerConfigWords = (words) =>
|
|
226
|
+
process.env.CLAUDE_CONFIG_DIR && configDirOf(words) === undefined
|
|
227
|
+
? [`${CONFIG_WORD}${quote(process.env.CLAUDE_CONFIG_DIR)}`]
|
|
228
|
+
: [];
|
|
212
229
|
const unquoteWord = (word) => word.replace(/'([^']*)'|\\(.)/g, (_, quoted, escaped) => quoted ?? escaped);
|
|
213
230
|
const hasAgentBinary = (words) => {
|
|
214
231
|
let index = 0;
|
|
@@ -221,13 +238,55 @@ const hasAgentBinary = (words) => {
|
|
|
221
238
|
index++;
|
|
222
239
|
return index < words.length;
|
|
223
240
|
};
|
|
241
|
+
const quoteShellWord = (word) =>
|
|
242
|
+
ENV_WORD.test(word) ? word.replace(/^([^=]+=)(.*)$/s, (_, key, value) => `${key}${quote(value)}`) : quote(word);
|
|
243
|
+
const unwrappedRun = (command) => {
|
|
244
|
+
const tokens = [...command.matchAll(SHELL_WORD)].map(([word]) => word);
|
|
245
|
+
const words = tokens.map(unquoteWord);
|
|
246
|
+
const at = words.findIndex((word, index) => basename(word) === 'agent-sessions.mjs' && words[index + 1] === 'run');
|
|
247
|
+
if (at < 0) return null;
|
|
248
|
+
let rest = words.slice(at + 3);
|
|
249
|
+
let runRole = null;
|
|
250
|
+
while (rest[0]?.startsWith('--')) {
|
|
251
|
+
if (rest[0] === '--role') runRole = rest[1];
|
|
252
|
+
rest = rest.slice(rest[0] === '--role' ? 2 : 1);
|
|
253
|
+
}
|
|
254
|
+
const end = rest.findIndex((word) => /[;&|]$/.test(word));
|
|
255
|
+
const inner = end < 0 ? rest : [...rest.slice(0, end), rest[end].replace(/[;&|]+$/, '')];
|
|
256
|
+
const program = inner.findIndex((word) => !ENV_WORD.test(word));
|
|
257
|
+
if (program < 0 || !hasAgentBinary(inner)) return null;
|
|
258
|
+
const kept = [...inner.slice(0, program), ...withoutPrompt(inner.slice(program))];
|
|
259
|
+
const env = tokens.slice(0, at).filter((word) => ENV_WORD.test(word));
|
|
260
|
+
const unwrapped = [...env, ...kept.map(quoteShellWord)].join(' ');
|
|
261
|
+
return runRole ? commandWithRole(unwrapped, runRole) : unwrapped;
|
|
262
|
+
};
|
|
224
263
|
const healedCommand = (command, agent) => {
|
|
264
|
+
const unwrapped = unwrappedRun(command);
|
|
265
|
+
if (unwrapped) return unwrapped;
|
|
225
266
|
const words = [...command.matchAll(SHELL_WORD)].map(([word]) => unquoteWord(word));
|
|
226
267
|
if (hasAgentBinary(words)) return command;
|
|
227
268
|
const binary = agent.match(/^(claude|codex)/)?.[1];
|
|
228
269
|
return binary ? `${command} ${quote(binary)}` : null;
|
|
229
270
|
};
|
|
271
|
+
const SHELL_WRAP =
|
|
272
|
+
/^((?:[A-Za-z_][A-Za-z0-9_]*=(?:'[^']*'|\S*)\s+)*)'?((?:\S*\/)?(?:sh|bash|zsh|dash))'?\s+'?(-[a-z]*c)'?\s+(.+)$/s;
|
|
273
|
+
const wrapOf = (command) => {
|
|
274
|
+
const found = command.match(SHELL_WRAP);
|
|
275
|
+
if (!found) return null;
|
|
276
|
+
const [, head, shell, flag, rest] = found;
|
|
277
|
+
const single = rest.match(/^'((?:[^']|'\\'')*)'$/s);
|
|
278
|
+
const double = rest.match(/^"((?:[^"\\]|\\.)*)"$/s);
|
|
279
|
+
const inner = single ? single[1].replaceAll("'\\''", "'") : double ? double[1].replace(/\\(["\\$`])/g, '$1') : rest;
|
|
280
|
+
return { head, shell, flag, inner };
|
|
281
|
+
};
|
|
282
|
+
const rewrapped = (wrap, head, inner) => `${head}${wrap.shell} ${wrap.flag} ${quote(inner)}`;
|
|
230
283
|
const commandWithoutPrompt = (command) => {
|
|
284
|
+
const wrap = wrapOf(command);
|
|
285
|
+
if (wrap) {
|
|
286
|
+
const innerRole = wrap.inner.match(/(?:^|\s)ETHLETE_AGENT_ROLE=(\w+)/)?.[1];
|
|
287
|
+
const bare = commandWithoutPrompt(commandWithRole(wrap.inner, null));
|
|
288
|
+
return rewrapped(wrap, wrap.head, innerRole ? commandWithRole(bare, innerRole) : bare);
|
|
289
|
+
}
|
|
231
290
|
const tokens = [...command.matchAll(SHELL_WORD)];
|
|
232
291
|
const program = tokens.findIndex(([word]) => !ENV_WORD.test(word));
|
|
233
292
|
if (program < 0) return command;
|
|
@@ -239,7 +298,7 @@ const HANDOFF_ROLE = /^\/handoff\s+resume\s+(builder|doc-agent)-/;
|
|
|
239
298
|
const handoffRoleOf = (prompt) => prompt.match(HANDOFF_ROLE)?.[1] ?? null;
|
|
240
299
|
const restartRoleOf = (session, prompt) => {
|
|
241
300
|
if (role === 'none') return null;
|
|
242
|
-
const found = role ??
|
|
301
|
+
const found = role ?? handoffRoleOf(prompt) ?? roleOf(session);
|
|
243
302
|
return found === 'doc-agent' ? null : found;
|
|
244
303
|
};
|
|
245
304
|
const claudeDir = process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude');
|
|
@@ -337,7 +396,17 @@ const hasUnknownRole = (session, prompt) => {
|
|
|
337
396
|
.filter((name) => name.endsWith(`@${repoSlug}`) && name !== session && name !== DISPATCH_SESSION);
|
|
338
397
|
return peers.length > 0 && !peers.some((name) => roleOf(name) === 'builder');
|
|
339
398
|
};
|
|
399
|
+
const ROLE_ENV_WORD = /^(ETHLETE_AGENT_ROLE|CLAUDE_CODE_SILENT_TURN_REMINDER)=/;
|
|
340
400
|
const commandWithRole = (command, agentRole) => {
|
|
401
|
+
const wrap = wrapOf(command);
|
|
402
|
+
if (wrap) {
|
|
403
|
+
const head = wrap.head
|
|
404
|
+
.split(/\s+(?=[A-Za-z_][A-Za-z0-9_]*=)/)
|
|
405
|
+
.filter((word) => word && !ROLE_ENV_WORD.test(word.trim()))
|
|
406
|
+
.map((word) => `${word.trim()} `)
|
|
407
|
+
.join('');
|
|
408
|
+
return rewrapped(wrap, head, commandWithRole(wrap.inner, agentRole));
|
|
409
|
+
}
|
|
341
410
|
const tokens = [...command.matchAll(SHELL_WORD)].map(([word]) => word);
|
|
342
411
|
const program = tokens.findIndex((word) => !ENV_WORD.test(word));
|
|
343
412
|
const env = program < 0 ? tokens : tokens.slice(0, program);
|
|
@@ -348,14 +417,72 @@ const commandWithRole = (command, agentRole) => {
|
|
|
348
417
|
!(word === BUILDER_PROMPT && words[index - 1] === '--append-system-prompt') &&
|
|
349
418
|
!/^(--strict-mcp-config|--mcp-config=.*|--disallowedTools=.*)$/.test(word),
|
|
350
419
|
);
|
|
351
|
-
const rule = agentRole === 'builder' && basename(kept
|
|
420
|
+
const rule = agentRole === 'builder' && basename(programOf(kept) ?? '') === 'claude' ? builderFlags() : [];
|
|
352
421
|
return [
|
|
353
|
-
...env.filter((word) =>
|
|
422
|
+
...env.filter((word) => !ROLE_ENV_WORD.test(word)),
|
|
354
423
|
...roleEnvWords(agentRole),
|
|
355
424
|
...[...kept, ...rule].map(quote),
|
|
356
425
|
].join(' ');
|
|
357
426
|
};
|
|
358
|
-
const
|
|
427
|
+
const LEADING_ENV_WORDS = /^((?:[A-Za-z_][A-Za-z0-9_]*=\S*\s+)*)/;
|
|
428
|
+
const bypassingShellFunction = (base) => base.replace(LEADING_ENV_WORDS, '$1command ');
|
|
429
|
+
const inAgentScope = () => {
|
|
430
|
+
try {
|
|
431
|
+
return /\/agent-[^/]*\.scope$/.test(readFileSync('/proc/self/cgroup', 'utf8').trim());
|
|
432
|
+
} catch {
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
const userScopesWork = () =>
|
|
437
|
+
process.platform === 'linux' &&
|
|
438
|
+
spawnSync(
|
|
439
|
+
'busctl',
|
|
440
|
+
[
|
|
441
|
+
'--user',
|
|
442
|
+
'get-property',
|
|
443
|
+
'org.freedesktop.systemd1',
|
|
444
|
+
'/org/freedesktop/systemd1',
|
|
445
|
+
'org.freedesktop.systemd1.Manager',
|
|
446
|
+
'Version',
|
|
447
|
+
],
|
|
448
|
+
{ stdio: 'ignore', timeout: 5000 },
|
|
449
|
+
).status === 0;
|
|
450
|
+
/**
|
|
451
|
+
* Runs the agent in its own systemd user scope that systemd-oomd only picks when no other candidate is left, so a heavy
|
|
452
|
+
* job in the same tmux pane is killed first. `avoid`, not `omit`: a runaway agent must stay killable.
|
|
453
|
+
*/
|
|
454
|
+
const OWN_SCOPE_PRELOAD = 'tools/scripts/own-scope-preload.mjs';
|
|
455
|
+
// A missing preload file must not break every node process of the agent: the data: import swallows the failure.
|
|
456
|
+
// The main checkout's copy outlives a worktree.
|
|
457
|
+
const ownScopePreloadWords = () => {
|
|
458
|
+
const common = spawnSync('git', ['rev-parse', '--path-format=absolute', '--git-common-dir'], { encoding: 'utf8' });
|
|
459
|
+
if (common.status !== 0) return [];
|
|
460
|
+
const preload = join(dirname(common.stdout.trim()), OWN_SCOPE_PRELOAD);
|
|
461
|
+
if (!existsSync(preload)) return [];
|
|
462
|
+
const source = `await import(${JSON.stringify(pathToFileURL(preload).href)}).catch(() => {});`;
|
|
463
|
+
const option = `--import=data:text/javascript;base64,${Buffer.from(source).toString('base64')}`;
|
|
464
|
+
return [`--setenv=NODE_OPTIONS=${[process.env['NODE_OPTIONS'], option].filter(Boolean).join(' ')}`];
|
|
465
|
+
};
|
|
466
|
+
const agentScopeWords = (session) =>
|
|
467
|
+
userScopesWork()
|
|
468
|
+
? [
|
|
469
|
+
'systemd-run',
|
|
470
|
+
'--user',
|
|
471
|
+
'--scope',
|
|
472
|
+
'--quiet',
|
|
473
|
+
'--collect',
|
|
474
|
+
`--unit=agent-${session.replace(/[^A-Za-z0-9_-]/g, '-')}-${Date.now()}`,
|
|
475
|
+
'-p',
|
|
476
|
+
'ManagedOOMPreference=avoid',
|
|
477
|
+
...ownScopePreloadWords(),
|
|
478
|
+
'--',
|
|
479
|
+
]
|
|
480
|
+
: [];
|
|
481
|
+
const shellWord = (word) => (/^[\w@%+=:,./-]+$/.test(word) ? word : quote(word));
|
|
482
|
+
const inAgentScopeCommand = (command, session, unscoped = (plain) => plain) => {
|
|
483
|
+
const words = agentScopeWords(session);
|
|
484
|
+
return words.length ? command.replace(LEADING_ENV_WORDS, `$1${words.map(shellWord).join(' ')} `) : unscoped(command);
|
|
485
|
+
};
|
|
359
486
|
const EXIT_DIALOG_JOBS = /will stop when you exit/i;
|
|
360
487
|
const EXIT_AND_STOP = /exit and stop/i;
|
|
361
488
|
const BACKGROUND_FOOTER = /\b\d+ (?:shells?|agents?)\b|↓ to manage/i;
|
|
@@ -654,9 +781,32 @@ if (command === 'send' && sender) {
|
|
|
654
781
|
);
|
|
655
782
|
process.exitCode = 1;
|
|
656
783
|
} else if (command === 'run' && sender && words.length && dryRun) {
|
|
657
|
-
process.stdout.write(
|
|
658
|
-
|
|
659
|
-
|
|
784
|
+
process.stdout.write(
|
|
785
|
+
`${withTempDir([...callerConfigWords(words), ...roleEnvWords(role), ...withRole(words).map(quote)].join(' '))}\n`,
|
|
786
|
+
);
|
|
787
|
+
} else if (
|
|
788
|
+
command === 'run' &&
|
|
789
|
+
sender &&
|
|
790
|
+
words.length &&
|
|
791
|
+
(!runsInSession(words.slice(1)) || (process.env.TMUX && [sessionFor(sender), sender].includes(ownSession())))
|
|
792
|
+
) {
|
|
793
|
+
if (runsInSession(words.slice(1))) {
|
|
794
|
+
const own = `=${ownSession()}:`;
|
|
795
|
+
tmux(
|
|
796
|
+
'set-option',
|
|
797
|
+
'-t',
|
|
798
|
+
own,
|
|
799
|
+
COMMAND_OPTION,
|
|
800
|
+
withTempDir(
|
|
801
|
+
[...callerConfigWords(words), ...roleEnvWords(role), ...withRole(withoutPrompt(words)).map(quote)].join(' '),
|
|
802
|
+
),
|
|
803
|
+
);
|
|
804
|
+
if (role) tmux('set-option', '-t', own, ROLE_OPTION, role);
|
|
805
|
+
}
|
|
806
|
+
const [program, ...programArgs] = [
|
|
807
|
+
...(inAgentScope() ? [] : agentScopeWords(ownSession() ?? sender)),
|
|
808
|
+
...withRole(words),
|
|
809
|
+
];
|
|
660
810
|
process.exitCode =
|
|
661
811
|
spawnSync(program, programArgs, {
|
|
662
812
|
stdio: 'inherit',
|
|
@@ -669,14 +819,7 @@ if (command === 'send' && sender) {
|
|
|
669
819
|
} else if (command === 'run' && sender && words.length) {
|
|
670
820
|
ensureDispatch();
|
|
671
821
|
const session = freeSessionFor(sender);
|
|
672
|
-
const roleEnv = [
|
|
673
|
-
...(process.env.CLAUDE_CONFIG_DIR && configDirOf(words) === undefined
|
|
674
|
-
? [`${CONFIG_WORD}${quote(process.env.CLAUDE_CONFIG_DIR)}`]
|
|
675
|
-
: []),
|
|
676
|
-
...roleEnvWords(role),
|
|
677
|
-
]
|
|
678
|
-
.map((word) => `${word} `)
|
|
679
|
-
.join('');
|
|
822
|
+
const roleEnv = [...callerConfigWords(words), ...roleEnvWords(role)].map((word) => `${word} `).join('');
|
|
680
823
|
const shellCommand = withTempDir(`${roleEnv}${withRole(words).map(quote).join(' ')}`);
|
|
681
824
|
const baseCommand = withTempDir(`${roleEnv}${withRole(withoutPrompt(words)).map(quote).join(' ')}`);
|
|
682
825
|
if (process.env.TMUX) {
|
|
@@ -844,10 +987,13 @@ if (command === 'send' && sender) {
|
|
|
844
987
|
}
|
|
845
988
|
if (stored !== recorded) {
|
|
846
989
|
tmux('set-option', '-t', pane, COMMAND_OPTION, stored);
|
|
847
|
-
restartLog(`${session} stored command
|
|
990
|
+
restartLog(`${session} stored command could not restart, healed to: ${stored}`);
|
|
848
991
|
}
|
|
849
|
-
const
|
|
992
|
+
const staleRole =
|
|
993
|
+
!restartRole && (roleOf(session) !== null || role === 'none' || handoffRoleOf(words.join(' ')) === 'doc-agent');
|
|
994
|
+
const base = withTempDir(restartRole || staleRole ? commandWithRole(stored, restartRole) : stored);
|
|
850
995
|
if (restartRole) tmux('set-option', '-t', pane, ROLE_OPTION, restartRole);
|
|
996
|
+
else if (staleRole) tmux('set-option', '-u', '-t', pane, ROLE_OPTION);
|
|
851
997
|
tmux('set-option', '-p', '-t', pane, 'remain-on-exit', 'on');
|
|
852
998
|
type('-l', sender.startsWith('codex') ? '/quit' : '/exit');
|
|
853
999
|
sleep(ENTER_DELAY_MS);
|
|
@@ -880,17 +1026,18 @@ if (command === 'send' && sender) {
|
|
|
880
1026
|
}
|
|
881
1027
|
if (!dead()) restartLog(`${session} did not exit ${RESTART_EXIT_WAIT_MS / 1000}s after the exit command, killed`);
|
|
882
1028
|
const shell = process.env.SHELL || 'sh';
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1029
|
+
const baseWrap = wrapOf(base);
|
|
1030
|
+
const launch = baseWrap
|
|
1031
|
+
? inAgentScopeCommand(
|
|
1032
|
+
rewrapped(
|
|
1033
|
+
baseWrap,
|
|
1034
|
+
baseWrap.head,
|
|
1035
|
+
`${bypassingShellFunction(baseWrap.inner)} ${quote(restartPrompt(words))}`,
|
|
1036
|
+
),
|
|
1037
|
+
session,
|
|
1038
|
+
)
|
|
1039
|
+
: `${inAgentScopeCommand(base, session, bypassingShellFunction)} ${quote(restartPrompt(words))}`;
|
|
1040
|
+
tmux('respawn-pane', '-k', '-t', pane, '-c', root, shell, '-lic', launch);
|
|
894
1041
|
tmux('set-option', '-p', '-t', pane, 'remain-on-exit', 'off');
|
|
895
1042
|
tmux('set-option', '-t', pane, COMMAND_OPTION, base);
|
|
896
1043
|
restartLog(`${session} started a new process: ${base}`);
|
|
@@ -19,6 +19,7 @@ That's it. An ADR can be a single paragraph. The value is in recording _that_ a
|
|
|
19
19
|
Only include these when they add genuine value. Most ADRs won't need them.
|
|
20
20
|
|
|
21
21
|
- **Status** frontmatter (`proposed | accepted | deprecated | superseded by ADR-NNNN`): useful when decisions are revisited
|
|
22
|
+
- **Parts** frontmatter (`parts: [components/title-bar]`, Studio ADRs): an ADR with `parts` and no `built: <sha>` is a `plan-question` open point on each named part until it is built.
|
|
22
23
|
- **Considered Options**: only when the rejected alternatives are worth remembering
|
|
23
24
|
- **Consequences**: only when non-obvious downstream effects need to be called out
|
|
24
25
|
|