@ethlete/agent-rules 0.1.0-next.41 → 0.1.0-next.43
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 +15 -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 +120 -19
- package/content/skills/design-exploration/reference-flows-and-wireframes.md +6 -8
- package/content/skills/design-exploration/reference-order-and-design-system.md +1 -1
- package/content/skills/domain-modeling/ADR-FORMAT.md +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ethlete/agent-rules
|
|
2
2
|
|
|
3
|
+
## 0.1.0-next.43
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Use neutral example names in the design exploration skill instead of parts from a real product.
|
|
8
|
+
|
|
9
|
+
## 0.1.0-next.42
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- The domain-modeling ADR format names the `parts` frontmatter: an ADR with `parts` and no `built` is an open plan question on each part.
|
|
14
|
+
- 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.
|
|
15
|
+
- 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.
|
|
16
|
+
- 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.
|
|
17
|
+
|
|
3
18
|
## 0.1.0-next.41
|
|
4
19
|
|
|
5
20
|
### 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")
|
|
@@ -165,7 +165,15 @@ const foreignCheckoutsOf = (agent) => [
|
|
|
165
165
|
),
|
|
166
166
|
];
|
|
167
167
|
const createRunSession = (session, shellCommand, baseCommand) => {
|
|
168
|
-
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
|
+
);
|
|
169
177
|
if (result.status !== 0) {
|
|
170
178
|
process.stderr.write(`No agent was started: tmux could not create ${session}: ${result.stderr.trim()}\n`);
|
|
171
179
|
process.exitCode = 1;
|
|
@@ -260,7 +268,25 @@ const healedCommand = (command, agent) => {
|
|
|
260
268
|
const binary = agent.match(/^(claude|codex)/)?.[1];
|
|
261
269
|
return binary ? `${command} ${quote(binary)}` : null;
|
|
262
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)}`;
|
|
263
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
|
+
}
|
|
264
290
|
const tokens = [...command.matchAll(SHELL_WORD)];
|
|
265
291
|
const program = tokens.findIndex(([word]) => !ENV_WORD.test(word));
|
|
266
292
|
if (program < 0) return command;
|
|
@@ -272,7 +298,7 @@ const HANDOFF_ROLE = /^\/handoff\s+resume\s+(builder|doc-agent)-/;
|
|
|
272
298
|
const handoffRoleOf = (prompt) => prompt.match(HANDOFF_ROLE)?.[1] ?? null;
|
|
273
299
|
const restartRoleOf = (session, prompt) => {
|
|
274
300
|
if (role === 'none') return null;
|
|
275
|
-
const found = role ??
|
|
301
|
+
const found = role ?? handoffRoleOf(prompt) ?? roleOf(session);
|
|
276
302
|
return found === 'doc-agent' ? null : found;
|
|
277
303
|
};
|
|
278
304
|
const claudeDir = process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude');
|
|
@@ -370,7 +396,17 @@ const hasUnknownRole = (session, prompt) => {
|
|
|
370
396
|
.filter((name) => name.endsWith(`@${repoSlug}`) && name !== session && name !== DISPATCH_SESSION);
|
|
371
397
|
return peers.length > 0 && !peers.some((name) => roleOf(name) === 'builder');
|
|
372
398
|
};
|
|
399
|
+
const ROLE_ENV_WORD = /^(ETHLETE_AGENT_ROLE|CLAUDE_CODE_SILENT_TURN_REMINDER)=/;
|
|
373
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
|
+
}
|
|
374
410
|
const tokens = [...command.matchAll(SHELL_WORD)].map(([word]) => word);
|
|
375
411
|
const program = tokens.findIndex((word) => !ENV_WORD.test(word));
|
|
376
412
|
const env = program < 0 ? tokens : tokens.slice(0, program);
|
|
@@ -383,12 +419,70 @@ const commandWithRole = (command, agentRole) => {
|
|
|
383
419
|
);
|
|
384
420
|
const rule = agentRole === 'builder' && basename(programOf(kept) ?? '') === 'claude' ? builderFlags() : [];
|
|
385
421
|
return [
|
|
386
|
-
...env.filter((word) =>
|
|
422
|
+
...env.filter((word) => !ROLE_ENV_WORD.test(word)),
|
|
387
423
|
...roleEnvWords(agentRole),
|
|
388
424
|
...[...kept, ...rule].map(quote),
|
|
389
425
|
].join(' ');
|
|
390
426
|
};
|
|
391
|
-
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
|
+
};
|
|
392
486
|
const EXIT_DIALOG_JOBS = /will stop when you exit/i;
|
|
393
487
|
const EXIT_AND_STOP = /exit and stop/i;
|
|
394
488
|
const BACKGROUND_FOOTER = /\b\d+ (?:shells?|agents?)\b|↓ to manage/i;
|
|
@@ -709,7 +803,10 @@ if (command === 'send' && sender) {
|
|
|
709
803
|
);
|
|
710
804
|
if (role) tmux('set-option', '-t', own, ROLE_OPTION, role);
|
|
711
805
|
}
|
|
712
|
-
const [program, ...programArgs] =
|
|
806
|
+
const [program, ...programArgs] = [
|
|
807
|
+
...(inAgentScope() ? [] : agentScopeWords(ownSession() ?? sender)),
|
|
808
|
+
...withRole(words),
|
|
809
|
+
];
|
|
713
810
|
process.exitCode =
|
|
714
811
|
spawnSync(program, programArgs, {
|
|
715
812
|
stdio: 'inherit',
|
|
@@ -892,8 +989,11 @@ if (command === 'send' && sender) {
|
|
|
892
989
|
tmux('set-option', '-t', pane, COMMAND_OPTION, stored);
|
|
893
990
|
restartLog(`${session} stored command could not restart, healed to: ${stored}`);
|
|
894
991
|
}
|
|
895
|
-
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);
|
|
896
995
|
if (restartRole) tmux('set-option', '-t', pane, ROLE_OPTION, restartRole);
|
|
996
|
+
else if (staleRole) tmux('set-option', '-u', '-t', pane, ROLE_OPTION);
|
|
897
997
|
tmux('set-option', '-p', '-t', pane, 'remain-on-exit', 'on');
|
|
898
998
|
type('-l', sender.startsWith('codex') ? '/quit' : '/exit');
|
|
899
999
|
sleep(ENTER_DELAY_MS);
|
|
@@ -926,17 +1026,18 @@ if (command === 'send' && sender) {
|
|
|
926
1026
|
}
|
|
927
1027
|
if (!dead()) restartLog(`${session} did not exit ${RESTART_EXIT_WAIT_MS / 1000}s after the exit command, killed`);
|
|
928
1028
|
const shell = process.env.SHELL || 'sh';
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
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);
|
|
940
1041
|
tmux('set-option', '-p', '-t', pane, 'remain-on-exit', 'off');
|
|
941
1042
|
tmux('set-option', '-t', pane, COMMAND_OPTION, base);
|
|
942
1043
|
restartLog(`${session} started a new process: ${base}`);
|
|
@@ -7,12 +7,12 @@ It is `<product>/flows/<name>.json`; `position` and `label` are optional:
|
|
|
7
7
|
|
|
8
8
|
```json
|
|
9
9
|
{
|
|
10
|
-
"frames": [{ "part": "pages/
|
|
10
|
+
"frames": [{ "part": "pages/projects", "state": "empty", "position": { "x": 0, "y": 0 } }],
|
|
11
11
|
"lines": [
|
|
12
12
|
{
|
|
13
|
-
"from": { "part": "pages/
|
|
14
|
-
"to": { "part": "pages/
|
|
15
|
-
"label": "user adds a
|
|
13
|
+
"from": { "part": "pages/projects", "state": "empty" },
|
|
14
|
+
"to": { "part": "pages/project-detail", "state": "default" },
|
|
15
|
+
"label": "user adds a project"
|
|
16
16
|
}
|
|
17
17
|
]
|
|
18
18
|
}
|
|
@@ -71,8 +71,6 @@ shell `fill: true` so it is as tall as the frame, instead of a hand-written `min
|
|
|
71
71
|
every preset, not one width: give a picture a `ratio` (`'2/3'`) instead of a fixed height, and give
|
|
72
72
|
a row `stackBelow: <px>`, the width below which it stacks its children, instead of fixed widths
|
|
73
73
|
that only fit the desktop. Never use `vh`, `dvh` or `svh` in a part: a part has no viewport of its own, so the unit measures Studio's frame, not the page. A full page is a frame of a fixed size. Put titles in `heading`, never in hand-written markup. Studio lists such a page under
|
|
74
|
-
"Wireframes" with its kit-use count. A shell is a normal element named by purpose (`shell-
|
|
74
|
+
"Wireframes" with its kit-use count. A shell is a normal element named by purpose (`shell-primary`); draw a rough one with the kit, so each
|
|
75
75
|
page imports the shell instead of repeating it, and a shell pick lands in one file.
|
|
76
|
-
A dialog without its own URL is an element that a page state shows ("login open").
|
|
77
|
-
`.ethlete/design/studio-lab`: `pages/film-detail`, `elements/shell-main`, `elements/login-dialog`,
|
|
78
|
-
`flows/sign-in.json`.
|
|
76
|
+
A dialog without its own URL is an element that a page state shows ("login open").
|
|
@@ -15,7 +15,7 @@ each stage draws with what the stages before it settled (the wireframes draw wit
|
|
|
15
15
|
```ts
|
|
16
16
|
inventory: [
|
|
17
17
|
{ part: 'Search field', sdk: 'et-input' },
|
|
18
|
-
{ part: 'Match card', new: true, call: '
|
|
18
|
+
{ part: 'Match card', new: true, call: 'my-app/components/match-card' },
|
|
19
19
|
],
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -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
|
|