@ethlete/agent-rules 0.1.0-next.6 → 0.1.0-next.60

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.
Files changed (220) hide show
  1. package/AGENTS.md +28 -0
  2. package/CHANGELOG.md +841 -0
  3. package/CLAUDE.md +1 -0
  4. package/README.md +244 -36
  5. package/THIRD-PARTY-LICENSES.md +35 -0
  6. package/content/defaults.json +1 -1
  7. package/content/hooks/away-mode.py +410 -0
  8. package/content/hooks/background-commands.py +177 -0
  9. package/content/hooks/builder-idle-check.py +529 -0
  10. package/content/hooks/context-warning.py +666 -134
  11. package/content/hooks/git-safety.py +213 -0
  12. package/content/hooks/human-wait-check.py +167 -0
  13. package/content/hooks/subagent-model-policy.py +261 -0
  14. package/content/mods/.claude-plugin/marketplace.json +26 -0
  15. package/content/mods/plugins/codex-runs/.claude-plugin/plugin.json +6 -0
  16. package/content/mods/plugins/codex-runs/hooks/agent-runs.ts +310 -0
  17. package/content/mods/plugins/codex-runs/hooks/hooks.json +1 -0
  18. package/content/mods/plugins/codex-runs/hooks/progress.ts +130 -0
  19. package/content/mods/plugins/codex-runs/hooks/register.tsx +283 -0
  20. package/content/mods/plugins/codex-runs/tests/pane.test.ts +21 -0
  21. package/content/mods/plugins/codex-runs/tsconfig.json +4 -0
  22. package/content/mods/plugins/codex-runs/types/index.d.ts +37 -0
  23. package/content/mods/plugins/e2e-progress/.claude-plugin/plugin.json +6 -0
  24. package/content/mods/plugins/e2e-progress/hooks/hooks.json +1 -0
  25. package/content/mods/plugins/e2e-progress/hooks/progress.ts +205 -0
  26. package/content/mods/plugins/e2e-progress/hooks/register.tsx +498 -0
  27. package/content/mods/plugins/e2e-progress/tsconfig.json +3 -0
  28. package/content/mods/plugins/e2e-progress/types/index.d.ts +27 -0
  29. package/content/mods/plugins/status-line/.claude-plugin/plugin.json +6 -0
  30. package/content/mods/plugins/status-line/hooks/hooks.json +1 -0
  31. package/content/mods/plugins/status-line/hooks/line.ts +74 -0
  32. package/content/mods/plugins/status-line/hooks/register.tsx +141 -0
  33. package/content/mods/plugins/status-line/types/index.d.ts +5 -0
  34. package/content/mods/plugins/usage-line/.claude-plugin/plugin.json +6 -0
  35. package/content/mods/plugins/usage-line/hooks/codex.ts +52 -0
  36. package/content/mods/plugins/usage-line/hooks/format.ts +24 -0
  37. package/content/mods/plugins/usage-line/hooks/hooks.json +1 -0
  38. package/content/mods/plugins/usage-line/hooks/rate-limits.ts +23 -0
  39. package/content/mods/plugins/usage-line/hooks/register.tsx +83 -0
  40. package/content/mods/plugins/usage-line/tsconfig.json +4 -0
  41. package/content/mods/plugins/usage-line/types/index.d.ts +5 -0
  42. package/content/output-styles/ste-clarity.md +131 -0
  43. package/content/rules/agent-sessions-wake-up.md +11 -0
  44. package/content/rules/app-styling.md +66 -0
  45. package/content/rules/comments.md +4 -1
  46. package/content/rules/lint-and-format.md +7 -5
  47. package/content/rules/nx-layout.md +53 -0
  48. package/content/rules/reactive-state.md +1 -1
  49. package/content/rules/styling.md +19 -10
  50. package/content/rules/subagent-models.md +42 -0
  51. package/content/rules/waiting-on-the-human.md +17 -0
  52. package/content/skills/agent-sessions/SKILL.md +101 -0
  53. package/content/skills/agent-sessions/agent-sessions.mjs +1462 -0
  54. package/content/skills/angular-patterns/SKILL.md +31 -7
  55. package/content/skills/api-source/SKILL.md +156 -0
  56. package/content/skills/app-testing/SKILL.md +141 -0
  57. package/content/skills/codex-subagent/SKILL.md +102 -0
  58. package/content/skills/codex-subagent/codex-agent.mjs +260 -0
  59. package/content/skills/codex-subagent/codex-limit.mjs +106 -0
  60. package/content/skills/design-exploration/SKILL.md +121 -0
  61. package/content/skills/design-exploration/check-story.mjs +139 -0
  62. package/content/skills/design-exploration/reference-shots.md +15 -0
  63. package/content/skills/design-exploration/shoot-template.mjs +61 -0
  64. package/content/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  65. package/content/skills/domain-modeling/SKILL.md +71 -0
  66. package/content/skills/e2e-triage/SKILL.md +80 -0
  67. package/content/skills/figma-export/SKILL.md +16 -18
  68. package/content/skills/git-commit/SKILL.md +21 -7
  69. package/content/skills/git-flow/SKILL.md +9 -5
  70. package/content/skills/grill-with-docs/SKILL.md +13 -0
  71. package/content/skills/grilling/SKILL.md +52 -0
  72. package/content/skills/handoff/SKILL.md +30 -72
  73. package/content/skills/handoff/save.md +189 -0
  74. package/content/skills/query/SKILL.md +165 -74
  75. package/content/skills/report/SKILL.md +26 -0
  76. package/content/skills/rxjs-signals/SKILL.md +33 -4
  77. package/content/skills/sdk-docs/SKILL.md +50 -14
  78. package/content/skills/sdk-local-build/SKILL.md +26 -8
  79. package/content/skills/sdk-local-build/sdk-local-baseline.mjs +64 -0
  80. package/content/skills/sdk-source/SKILL.md +37 -34
  81. package/content/skills/sdk-update/SKILL.md +103 -0
  82. package/content/skills/story-styling/SKILL.md +12 -10
  83. package/content/skills/styleguide/SKILL.md +13 -8
  84. package/content/skills/styleguide/assets.md +54 -0
  85. package/content/skills/styleguide/changesets.md +17 -0
  86. package/content/skills/styleguide/file-structure.md +73 -0
  87. package/content/skills/styleguide/lint-rule-lookup.md +52 -0
  88. package/content/skills/styleguide/storybook-structure.md +25 -0
  89. package/content/skills/theming/SKILL.md +76 -49
  90. package/content/skills/verify-in-app/SKILL.md +107 -0
  91. package/content/skills/verify-in-storybook/SKILL.md +1 -1
  92. package/content/skills/verify-on-apple-devices/SKILL.md +100 -0
  93. package/content/skills/verify-on-apple-devices/apple-remote.sh +421 -0
  94. package/content/skills/verify-on-apple-devices/sim-edge-back.m +159 -0
  95. package/migrations/list-state-query-form.md +20 -0
  96. package/migrations/nx-layout.md +29 -0
  97. package/migrations/sdk-components-over-hand-built-ui.md +27 -0
  98. package/migrations/search-query-field.md +52 -0
  99. package/migrations/studio-claude-plugin.md +27 -0
  100. package/migrations.json +47 -0
  101. package/package.json +8 -3
  102. package/src/index.js +84 -28
  103. package/src/index.js.map +1 -1
  104. package/src/lib/cli-args.d.ts +9 -0
  105. package/src/lib/cli-args.js +48 -0
  106. package/src/lib/cli-args.js.map +1 -0
  107. package/src/lib/commitlint.d.ts +10 -0
  108. package/src/lib/commitlint.js +51 -0
  109. package/src/lib/commitlint.js.map +1 -0
  110. package/src/lib/config.d.ts +53 -22
  111. package/src/lib/config.js +128 -12
  112. package/src/lib/config.js.map +1 -1
  113. package/src/lib/filter.d.ts +3 -0
  114. package/src/lib/filter.js +7 -5
  115. package/src/lib/filter.js.map +1 -1
  116. package/src/lib/frontmatter.d.ts +2 -0
  117. package/src/lib/frontmatter.js +33 -5
  118. package/src/lib/frontmatter.js.map +1 -1
  119. package/src/lib/git-flow/config.js +1 -1
  120. package/src/lib/git-flow/config.js.map +1 -1
  121. package/src/lib/git-flow/index.d.ts +1 -0
  122. package/src/lib/git-flow/index.js +20 -6
  123. package/src/lib/git-flow/index.js.map +1 -1
  124. package/src/lib/git-flow/parse.js +38 -12
  125. package/src/lib/git-flow/parse.js.map +1 -1
  126. package/src/lib/git-flow/rename.d.ts +24 -0
  127. package/src/lib/git-flow/rename.js +70 -0
  128. package/src/lib/git-flow/rename.js.map +1 -0
  129. package/src/lib/git-flow/start.d.ts +27 -0
  130. package/src/lib/git-flow/start.js +34 -1
  131. package/src/lib/git-flow/start.js.map +1 -1
  132. package/src/lib/git-flow-command.js +10 -2
  133. package/src/lib/git-flow-command.js.map +1 -1
  134. package/src/lib/git-flow-repair.d.ts +1 -1
  135. package/src/lib/git-flow-repair.js +30 -15
  136. package/src/lib/git-flow-repair.js.map +1 -1
  137. package/src/lib/git-flow-start.d.ts +1 -1
  138. package/src/lib/git-flow-start.js +25 -32
  139. package/src/lib/git-flow-start.js.map +1 -1
  140. package/src/lib/git.d.ts +37 -0
  141. package/src/lib/git.js +85 -3
  142. package/src/lib/git.js.map +1 -1
  143. package/src/lib/gitlab.js +24 -6
  144. package/src/lib/gitlab.js.map +1 -1
  145. package/src/lib/index.d.ts +2 -0
  146. package/src/lib/index.js +26 -11
  147. package/src/lib/index.js.map +1 -1
  148. package/src/lib/migrate.js +8 -2
  149. package/src/lib/migrate.js.map +1 -1
  150. package/src/lib/output-style-command.d.ts +3 -0
  151. package/src/lib/output-style-command.js +69 -0
  152. package/src/lib/output-style-command.js.map +1 -0
  153. package/src/lib/output-style.d.ts +38 -0
  154. package/src/lib/output-style.js +134 -0
  155. package/src/lib/output-style.js.map +1 -0
  156. package/src/lib/owned-paths.js +8 -2
  157. package/src/lib/owned-paths.js.map +1 -1
  158. package/src/lib/package-runner.d.ts +4 -0
  159. package/src/lib/package-runner.js +86 -0
  160. package/src/lib/package-runner.js.map +1 -0
  161. package/src/lib/plain-text.d.ts +9 -0
  162. package/src/lib/plain-text.js +22 -0
  163. package/src/lib/plain-text.js.map +1 -0
  164. package/src/lib/plan.d.ts +6 -6
  165. package/src/lib/plan.js +153 -40
  166. package/src/lib/plan.js.map +1 -1
  167. package/src/lib/prettier.d.ts +21 -0
  168. package/src/lib/prettier.js +51 -0
  169. package/src/lib/prettier.js.map +1 -0
  170. package/src/lib/prompt.js +10 -2
  171. package/src/lib/prompt.js.map +1 -1
  172. package/src/lib/render.d.ts +14 -1
  173. package/src/lib/render.js +23 -5
  174. package/src/lib/render.js.map +1 -1
  175. package/src/lib/report-command.d.ts +34 -0
  176. package/src/lib/report-command.js +322 -0
  177. package/src/lib/report-command.js.map +1 -0
  178. package/src/lib/sessions-command.d.ts +4 -0
  179. package/src/lib/sessions-command.js +16 -0
  180. package/src/lib/sessions-command.js.map +1 -0
  181. package/src/lib/sync.d.ts +1 -2
  182. package/src/lib/sync.js +37 -17
  183. package/src/lib/sync.js.map +1 -1
  184. package/src/lib/targets/agents-skills.js +1 -1
  185. package/src/lib/targets/agents-skills.js.map +1 -1
  186. package/src/lib/targets/claude-hooks.d.ts +5 -0
  187. package/src/lib/targets/claude-hooks.js +27 -4
  188. package/src/lib/targets/claude-hooks.js.map +1 -1
  189. package/src/lib/targets/claude-mods.d.ts +20 -0
  190. package/src/lib/targets/claude-mods.js +47 -0
  191. package/src/lib/targets/claude-mods.js.map +1 -0
  192. package/src/lib/targets/claude.js +2 -3
  193. package/src/lib/targets/claude.js.map +1 -1
  194. package/src/lib/targets/codex-hooks.js +4 -2
  195. package/src/lib/targets/codex-hooks.js.map +1 -1
  196. package/src/lib/targets/codex.js +4 -4
  197. package/src/lib/targets/codex.js.map +1 -1
  198. package/src/lib/targets/copilot.js +4 -4
  199. package/src/lib/targets/copilot.js.map +1 -1
  200. package/src/lib/targets/cursor.js +3 -3
  201. package/src/lib/targets/cursor.js.map +1 -1
  202. package/src/lib/targets/git-hooks.d.ts +1 -1
  203. package/src/lib/targets/git-hooks.js +6 -5
  204. package/src/lib/targets/git-hooks.js.map +1 -1
  205. package/src/lib/targets/hooks-shared.d.ts +34 -5
  206. package/src/lib/targets/hooks-shared.js +132 -36
  207. package/src/lib/targets/hooks-shared.js.map +1 -1
  208. package/src/lib/targets/mcp.d.ts +25 -0
  209. package/src/lib/targets/mcp.js +114 -0
  210. package/src/lib/targets/mcp.js.map +1 -0
  211. package/src/lib/targets/shared.d.ts +1 -9
  212. package/src/lib/targets/shared.js +4 -8
  213. package/src/lib/targets/shared.js.map +1 -1
  214. package/src/lib/timetrack.d.ts +16 -0
  215. package/src/lib/timetrack.js +149 -0
  216. package/src/lib/timetrack.js.map +1 -0
  217. package/content/skills/styleguide/STYLEGUIDE.md +0 -520
  218. package/src/lib/jira.d.ts +0 -28
  219. package/src/lib/jira.js +0 -83
  220. package/src/lib/jira.js.map +0 -1
@@ -0,0 +1,283 @@
1
+ import { atom, read, update } from 'claude-code';
2
+ import type { EngineInterface, Register, Timer } from 'claude-code';
3
+
4
+ import {
5
+ agentRunOf,
6
+ claimRuns,
7
+ durationOf as agentDurationOf,
8
+ finishNotices,
9
+ isCodexAgentCommand,
10
+ isRunNamed,
11
+ parseRunIndex,
12
+ parseTrace,
13
+ shortIdOf,
14
+ statusOf,
15
+ } from './agent-runs';
16
+ import type { AgentRun, Trace } from './agent-runs';
17
+ import { discoverRuns, durationOf } from './progress';
18
+ import type { CodexRun } from './progress';
19
+
20
+ const PANE = 'codex-runs';
21
+ const POLL_MS = 3000;
22
+ const PROCESS_TIMEOUT_MS = 2000;
23
+ const KEEP_AGENT_RUNS_MS = 6 * 60 * 60_000;
24
+ const MAX_AGENT_RUNS = 20;
25
+ const MAX_TRACE_BYTES = 4 * 1024 * 1024;
26
+ const runs = atom({ plugin: 'codex-runs', key: 'runs' } as const, []);
27
+ const selected = atom({ plugin: 'codex-runs', key: 'selected' } as const, null);
28
+ const agentRuns = atom({ plugin: 'codex-runs', key: 'agentRuns' } as const, []);
29
+ const toolRuns = atom({ plugin: 'codex-runs', key: 'toolRuns' } as const, {});
30
+ const waitingCalls = atom({ plugin: 'codex-runs', key: 'waitingCalls' } as const, []);
31
+
32
+ let timer: Timer | undefined;
33
+ let pending: Promise<void> | undefined;
34
+ let shownStatus: string | undefined | null = null;
35
+ const traces = new Map<string, { size: number; mtimeMs: number; trace: Trace }>();
36
+
37
+ async function logDirs($: EngineInterface) {
38
+ const tmp = (await $.env.get('TMPDIR'))?.replace(/\/$/, '');
39
+ return [...new Set([tmp ? `${tmp}/codex-agent` : '', '/tmp/codex-agent'].filter(Boolean))];
40
+ }
41
+
42
+ async function traceOf($: EngineInterface, path: string, size: number, mtimeMs: number) {
43
+ const cached = traces.get(path);
44
+ if (cached && cached.size === size && cached.mtimeMs === mtimeMs) return cached.trace;
45
+ const offset = Math.max(0, size - MAX_TRACE_BYTES);
46
+ const text = await $.fs.read(path, { offset, length: size - offset }).catch(() => '');
47
+ const trace = parseTrace(offset > 0 ? text.slice(text.indexOf('\n') + 1) : text);
48
+ traces.set(path, { size, mtimeMs, trace });
49
+ return trace;
50
+ }
51
+
52
+ async function isAlive($: EngineInterface, pid: number) {
53
+ if (!pid) return null;
54
+ const result = await $.process.run(['kill', '-0', String(pid)], { timeoutMs: PROCESS_TIMEOUT_MS }).catch(() => null);
55
+ return result ? result.exitCode === 0 : null;
56
+ }
57
+
58
+ async function scanAgentRuns($: EngineInterface, now: number) {
59
+ const found: AgentRun[] = [];
60
+ for (const dir of await logDirs($)) {
61
+ const entries = await $.fs.list(dir).catch(() => []);
62
+ const indexes = new Set(entries.filter((entry) => entry.name.endsWith('.run.json')).map((entry) => entry.name));
63
+ for (const entry of entries) {
64
+ if (entry.kind !== 'file' || !entry.name.endsWith('.jsonl')) continue;
65
+ const id = entry.name.slice(0, -'.jsonl'.length);
66
+ const hasIndex = indexes.has(`${id}.run.json`);
67
+ if (!hasIndex && now - entry.mtimeMs > KEEP_AGENT_RUNS_MS) continue;
68
+ const index = hasIndex ? parseRunIndex(await $.fs.read(`${dir}/${id}.run.json`).catch(() => '')) : null;
69
+ if (index?.endedAt && now - index.endedAt > KEEP_AGENT_RUNS_MS) continue;
70
+ const log = `${dir}/${entry.name}`;
71
+ const trace = await traceOf($, log, entry.size, entry.mtimeMs);
72
+ const alive = index && index.endedAt === undefined ? await isAlive($, index.pid) : null;
73
+ found.push(agentRunOf({ id, log, index, trace, logChangedAt: entry.mtimeMs, isAlive: alive, now }));
74
+ }
75
+ }
76
+ return found
77
+ .filter((run) => run.state === 'running' || now - (run.endedAt ?? now) <= KEEP_AGENT_RUNS_MS)
78
+ .sort((a, b) => b.startedAt - a.startedAt)
79
+ .slice(0, MAX_AGENT_RUNS);
80
+ }
81
+
82
+ function setStatus($: EngineInterface, text: string | undefined) {
83
+ if (text === shownStatus) return;
84
+ shownStatus = text;
85
+ $.ui.status(text);
86
+ }
87
+
88
+ async function refreshAgentRuns($: EngineInterface, sessionId: string, now: number) {
89
+ const [previous, claimed, waiting] = await Promise.all([
90
+ read($, agentRuns),
91
+ read($, toolRuns),
92
+ read($, waitingCalls),
93
+ ]);
94
+ const next = await scanAgentRuns($, now);
95
+ if (JSON.stringify(next) !== JSON.stringify(previous)) await update($, agentRuns, () => next);
96
+ for (const text of finishNotices(previous, next, sessionId, now)) $.ui.toast(text);
97
+ if (waiting.length > 0) {
98
+ const paired = claimRuns(waiting, claimed, next, sessionId);
99
+ const open = paired.waiting.filter((call) => now - call.at < 60_000);
100
+ await update($, toolRuns, () => paired.claimed);
101
+ await update($, waitingCalls, () => open);
102
+ }
103
+ setStatus($, statusOf(next, sessionId, now));
104
+ }
105
+
106
+ async function refresh($: EngineInterface) {
107
+ const [sessionId, root, now, previous] = await Promise.all([
108
+ $.session.id(),
109
+ $.session.root(),
110
+ $.clock.now(),
111
+ read($, runs),
112
+ ]);
113
+ const checkout = await $.process
114
+ .run(['git', 'rev-parse', '--show-toplevel'], { cwd: root, timeoutMs: PROCESS_TIMEOUT_MS })
115
+ .catch(() => null);
116
+ const next = await discoverRuns({
117
+ tmux: (args) =>
118
+ $.process
119
+ .run(['tmux', ...args], { timeoutMs: PROCESS_TIMEOUT_MS })
120
+ .catch(() => ({ exitCode: null, stdout: '', stderr: '' })),
121
+ scope: { sessionId, root: checkout?.exitCode === 0 ? checkout.stdout.trimEnd() : root },
122
+ previous,
123
+ now,
124
+ });
125
+ if ((await $.session.id()) !== sessionId) return;
126
+ await update($, runs, () => next);
127
+ await refreshAgentRuns($, sessionId, now);
128
+ }
129
+
130
+ function poll($: EngineInterface) {
131
+ pending ??= refresh($)
132
+ .catch(() => undefined)
133
+ .finally(() => {
134
+ pending = undefined;
135
+ });
136
+ return pending;
137
+ }
138
+
139
+ async function runsForSession($: EngineInterface) {
140
+ const [sessionId, shown] = await Promise.all([$.session.id(), read($, runs)]);
141
+ return shown.filter((run) => !run.owner || run.owner === sessionId);
142
+ }
143
+
144
+ function selectedRunId({ id, agents, terminals }: { id: string | null; agents: AgentRun[]; terminals: CodexRun[] }) {
145
+ if (agents.some((run) => run.id === id) || terminals.some((run) => run.id === id)) return id;
146
+ return (agents.find((run) => run.state === 'running') ?? agents[0] ?? terminals[0])?.id ?? null;
147
+ }
148
+
149
+ export const register: Register = (on) => {
150
+ on('session.start', async ($, e, next) => {
151
+ await $.command.register({
152
+ name: PANE,
153
+ description: 'List Codex runs. Pass a run name to show its last output lines.',
154
+ });
155
+ timer?.cancel();
156
+ timer = $.clock.every(POLL_MS, () => poll($));
157
+ await poll($);
158
+ return next(e);
159
+ });
160
+
161
+ on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
162
+ if (isCodexAgentCommand(e.command)) {
163
+ const at = await $.clock.now();
164
+ await update($, waitingCalls, (calls) => [...calls, { toolUseId: e.tool_use_id, at }]);
165
+ }
166
+ return next(e);
167
+ });
168
+
169
+ on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
170
+ const input = e.props.input as { command?: unknown } | undefined;
171
+ if (e.props.tool !== 'Bash' || !isCodexAgentCommand(input?.command)) return next(e);
172
+ const [row, claimed, shown, now] = await Promise.all([
173
+ next(e),
174
+ read($, toolRuns),
175
+ read($, agentRuns),
176
+ $.clock.now(),
177
+ ]);
178
+ const run = shown.find((run) => run.id === claimed[e.props.tool_use_id]);
179
+ if (!run) return row;
180
+ const { Box, Text } = $.ui.resolve(e);
181
+ const detail = run.state === 'failed' ? run.error : run.progress;
182
+ return (
183
+ <Box flexDirection="column">
184
+ {row}
185
+ <Text dimColor wrap="truncate-end">
186
+ {` ⎿ codex ${run.state} · ${agentDurationOf(run, now)} · ${detail} · /codex-runs ${shortIdOf(run.id)}`}
187
+ </Text>
188
+ </Box>
189
+ );
190
+ });
191
+
192
+ on('command.run', { command: PANE }, async ($, e) => {
193
+ await poll($);
194
+ const name = e.args.trim();
195
+ const agentRun = name ? (await read($, agentRuns)).find((run) => isRunNamed(run, name)) : undefined;
196
+ const run =
197
+ name && !agentRun
198
+ ? (await runsForSession($)).find((run) => run.name === name || run.name.startsWith(`${name}@`))
199
+ : undefined;
200
+ if (name && !run && !agentRun) return { text: `No visible Codex run named ${name}.` };
201
+
202
+ await update($, selected, () => agentRun?.id ?? run?.id ?? null);
203
+ await $.ui.open({ id: PANE, title: 'Codex', focus: true, closeOnEscape: true });
204
+ if (agentRun) return { text: `Showing the trace of the Codex run ${name}.` };
205
+ return { text: run ? `Showing recent output for ${run.name}.` : 'Codex pane opened.' };
206
+ });
207
+
208
+ on('ui.key', { component: 'Pane', requestId: PANE }, async ($, e, next) => {
209
+ if ((e.key !== 'up' && e.key !== 'down') || e.ctrl || e.shift || e.meta) return next(e);
210
+
211
+ const [agents, terminals] = await Promise.all([read($, agentRuns), runsForSession($)]);
212
+ const visible = [...agents, ...terminals];
213
+ if (visible.length === 0) return next(e);
214
+
215
+ const step = e.key === 'up' ? -1 : 1;
216
+ await update($, selected, (id) => {
217
+ const activeId = selectedRunId({ id, agents, terminals });
218
+ const index = visible.findIndex((run) => run.id === activeId);
219
+ return visible[index + step]?.id ?? activeId;
220
+ });
221
+ return {};
222
+ });
223
+
224
+ on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
225
+ const { Box, Text } = $.ui.resolve(e);
226
+ const [shown, agents, selectedId, sessionId, now] = await Promise.all([
227
+ runsForSession($),
228
+ read($, agentRuns),
229
+ read($, selected),
230
+ $.session.id(),
231
+ $.clock.now(),
232
+ ]);
233
+ if (shown.length === 0 && agents.length === 0) return <Text dimColor>No Codex runs found.</Text>;
234
+
235
+ const activeId = selectedRunId({ id: selectedId, agents, terminals: shown });
236
+ const run = shown.find((run) => run.id === activeId);
237
+ const traced = agents.find((agent) => agent.id === activeId);
238
+ return (
239
+ <Box flexDirection="column">
240
+ {agents.map((agent) => (
241
+ <Text key={agent.id} wrap="truncate-end" bold={agent.id === traced?.id}>
242
+ {`${shortIdOf(agent.id)} ${agent.state} · ${agentDurationOf(agent, now)} · ${agent.label}`}
243
+ {agent.session && agent.session !== sessionId ? ' · other session' : ''}
244
+ {` · ${agent.prompt || agent.progress}`}
245
+ </Text>
246
+ ))}
247
+ {shown.map((run) => (
248
+ <Text key={run.id} wrap="truncate-end" bold={run.id === activeId}>
249
+ {run.name} · {run.state} · {durationOf(run, now)}
250
+ </Text>
251
+ ))}
252
+ {traced && (
253
+ <Box flexDirection="column" marginTop={1}>
254
+ <Text bold wrap="truncate-end">
255
+ {`${shortIdOf(traced.id)} trace · ${traced.progress}`}
256
+ </Text>
257
+ {traced.error && <Text color="red">{traced.error}</Text>}
258
+ {traced.trace.length === 0 && <Text dimColor>No trace yet.</Text>}
259
+ {traced.trace.slice(-20).map((line, index) => (
260
+ <Text key={String(index)} wrap="truncate-end" dimColor={line.kind === 'command'}>
261
+ {line.kind === 'command' ? `$ ${line.text}` : line.kind === 'files' ? `~ ${line.text}` : line.text}
262
+ </Text>
263
+ ))}
264
+ <Text dimColor wrap="truncate-end">
265
+ {traced.log}
266
+ </Text>
267
+ </Box>
268
+ )}
269
+ {run && (
270
+ <Box flexDirection="column" marginTop={1}>
271
+ <Text bold>{run.name} output</Text>
272
+ {run.tail.length === 0 && <Text dimColor>No captured output.</Text>}
273
+ {run.tail.map((line, index) => (
274
+ <Text key={String(index)} wrap="truncate-end">
275
+ {line}
276
+ </Text>
277
+ ))}
278
+ </Box>
279
+ )}
280
+ </Box>
281
+ );
282
+ });
283
+ };
@@ -0,0 +1,21 @@
1
+ import { expect, test } from 'claude-code/testing';
2
+
3
+ const pane = 'codex-runs';
4
+ const command = {
5
+ command: pane,
6
+ args: '',
7
+ origin: { kind: 'composer' },
8
+ presentation: { isFullscreen: false, columns: 100 },
9
+ } as const;
10
+
11
+ test('opens the Codex pane with keyboard focus and Escape dismissal', async ($, on) => {
12
+ const opened: unknown[] = [];
13
+ on('ui.open', { id: pane }, (_$, event) => {
14
+ opened.push(event);
15
+ return { value: { isPlaced: true } };
16
+ });
17
+
18
+ await $.command.run(command);
19
+ expect(opened).toHaveLength(1);
20
+ expect(opened[0]).toMatchObject({ focus: true, closeOnEscape: true });
21
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../e2e-progress/.claude-plugin/types/tsconfig.json",
3
+ "include": ["hooks", "types"]
4
+ }
@@ -0,0 +1,37 @@
1
+ export type CodexRun = {
2
+ id: string;
3
+ name: string;
4
+ cwd: string;
5
+ owner: string;
6
+ startedAt: number;
7
+ endedAt: number | null;
8
+ state: 'running' | 'waiting for input' | 'ended';
9
+ tail: string[];
10
+ };
11
+
12
+ export type AgentRun = {
13
+ id: string;
14
+ log: string;
15
+ session: string;
16
+ cwd: string;
17
+ label: string;
18
+ prompt: string;
19
+ startedAt: number;
20
+ endedAt: number | null;
21
+ state: 'running' | 'done' | 'failed';
22
+ error: string;
23
+ progress: string;
24
+ trace: { kind: 'command' | 'files' | 'message' | 'error'; text: string }[];
25
+ };
26
+
27
+ declare module 'claude-code' {
28
+ interface PluginState {
29
+ 'codex-runs': {
30
+ runs: CodexRun[];
31
+ selected: string | null;
32
+ agentRuns: AgentRun[];
33
+ toolRuns: Record<string, string>;
34
+ waitingCalls: { toolUseId: string; at: number }[];
35
+ };
36
+ }
37
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "e2e-progress",
3
+ "version": "0.1.0-next.60",
4
+ "description": "Live Playwright e2e progress from a run log, as a status line entry and a pane",
5
+ "types": "./types/index.d.ts"
6
+ }
@@ -0,0 +1 @@
1
+ { "modules": ["./register.tsx"] }
@@ -0,0 +1,205 @@
1
+ import type { Progress } from '../types';
2
+
3
+ export const count = (text: string, re: RegExp) => (text.match(re) ?? []).length;
4
+ export const summary = (text: string, word: string) => {
5
+ const hit = text.match(new RegExp(`^\\s+(\\d+) ${word}\\b`, 'm'));
6
+ return hit ? Number(hit[1]) : undefined;
7
+ };
8
+
9
+ export const doneOf = (p: Progress) => p.passed + p.failed + p.skipped;
10
+
11
+ const FAIL_LISTED = /(?:✘|^\s+x)\s+\d+\s+\[/;
12
+ export const FAIL_LINE = /(?:✘|^\s+x)\s+\d+\s+\[[^\]]+\]\s+›\s+(\S+?):(\d+):\d+\s+›\s+(.*)$/;
13
+
14
+ export const parse = (
15
+ path: string,
16
+ text: string,
17
+ expected: Set<string>,
18
+ mtimeMs: number,
19
+ nowMs: number,
20
+ last: Progress | null,
21
+ ): Progress => {
22
+ const isDone = /^\s+\d+ (passed|failed|did not run)\b/m.test(text) || /^EXIT \d+/m.test(text);
23
+ const lines = text.split('\n');
24
+ const listFailures = lines
25
+ .filter((line) => FAIL_LISTED.test(line) && !expected.has(line))
26
+ .map((line) => line.replace(/^(?:.*?✘|\s+x)\s+\d+\s+\[[^\]]+\]\s+›\s+/, '').replace(/\s+@\S+.*$/, ''));
27
+ const lineFailures = new Map<string, string>();
28
+ for (const line of lines) {
29
+ const hit = line.match(/^\s+(\d+)\) \[[^\]]+\] › (.*)$/);
30
+ if (hit?.[1] && hit[2]) lineFailures.set(hit[1], hit[2].replace(/\s+@\S+.*$/, '').replace(/\s*─+\s*$/, ''));
31
+ }
32
+ const failures = isDone && lineFailures.size > 0 ? [...lineFailures.values()] : listFailures;
33
+ const started = Math.max(0, ...[...text.matchAll(/^\[(\d+)\/\d+\]/gm)].map((m) => Number(m[1])));
34
+ const ticks = count(text, /✓/g) + count(text, /^\s+ok\s+\d+\s+\[/gm);
35
+ const p = {
36
+ path,
37
+ kind: 'e2e' as const,
38
+ total: Number(text.match(/Running (\d+) tests?/)?.[1] ?? 0),
39
+ passed: summary(text, 'passed') ?? (ticks > 0 ? ticks + expected.size : Math.max(0, started - failures.length)),
40
+ failed: summary(text, 'failed') ?? failures.length,
41
+ skipped: summary(text, 'skipped') ?? (ticks > 0 ? count(text, /^\s+-\s+\d+\s/gm) : 0),
42
+ flaky: summary(text, 'flaky') ?? 0,
43
+ didNotRun: summary(text, 'did not run') ?? 0,
44
+ workers: Number(text.match(/Running \d+ tests? using (\d+) workers?/)?.[1] ?? 1),
45
+ duration: text.match(/^\s+\d+ passed \(([^)]+)\)/m)?.[1],
46
+ expected: expected.size,
47
+ isDone,
48
+ failures,
49
+ mtimeMs,
50
+ firstSeenMs: nowMs,
51
+ firstDone: 0,
52
+ };
53
+ const isSameRun =
54
+ last !== null &&
55
+ last.path === path &&
56
+ !last.isDone &&
57
+ Number.isFinite(last.firstSeenMs) &&
58
+ Number.isFinite(last.firstDone) &&
59
+ doneOf(p) >= last.firstDone;
60
+ return isSameRun
61
+ ? { ...p, firstSeenMs: last.firstSeenMs, firstDone: last.firstDone }
62
+ : { ...p, firstDone: doneOf(p) };
63
+ };
64
+
65
+ const ANSI = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, 'g');
66
+ const numberAfter = (text: string, re: RegExp) => {
67
+ const hit = text.match(re);
68
+ return hit ? Number(hit[1]) : undefined;
69
+ };
70
+ const sumOf = (text: string, re: RegExp) => [...text.matchAll(re)].reduce((n, m) => n + Number(m[1]), 0);
71
+
72
+ export const parseUnit = (path: string, raw: string, mtimeMs: number, nowMs: number, isEnded: boolean): Progress => {
73
+ const text = raw.replace(ANSI, '');
74
+ const vitest = text.match(/^\s*Tests\s+(.*)\((\d+)\)\s*$/m);
75
+ const nodeTotal = numberAfter(text, /^[ℹ#] tests (\d+)/m);
76
+ const passed = vitest
77
+ ? (numberAfter(vitest[1] ?? '', /(\d+) passed/) ?? 0)
78
+ : (numberAfter(text, /^[ℹ#] pass (\d+)/m) ??
79
+ sumOf(text, /^\s*✓ .*\((\d+) tests?\)/gm) + count(text, /^(?:✔ .*\([\d.]+m?s\)$|ok \d+ )/gm));
80
+ const failed = vitest
81
+ ? (numberAfter(vitest[1] ?? '', /(\d+) failed/) ?? 0)
82
+ : (numberAfter(text, /^[ℹ#] fail (\d+)/m) ?? count(text, /^(?:✖ .*\([\d.]+m?s\)$|not ok \d+ |\s*FAIL\s)/gm));
83
+ const skipped = vitest
84
+ ? (numberAfter(vitest[1] ?? '', /(\d+) skipped/) ?? 0)
85
+ : (numberAfter(text, /^[ℹ#] skipped (\d+)/m) ?? 0);
86
+ const failures = [
87
+ ...new Set(
88
+ [...text.matchAll(/^(?:✖ (?!failing tests)|not ok \d+ - |\s*FAIL\s+)(.+?)(?: \([\d.]+m?s\))?$/gm)].map((m) =>
89
+ (m[1] ?? '').trim(),
90
+ ),
91
+ ),
92
+ ];
93
+ const total = vitest ? Number(vitest[2]) : (nodeTotal ?? 0);
94
+ return {
95
+ path,
96
+ kind: 'unit',
97
+ total,
98
+ passed,
99
+ failed,
100
+ skipped,
101
+ flaky: 0,
102
+ didNotRun: 0,
103
+ workers: 1,
104
+ duration: text.match(/^\s*Duration\s+(\S+)/m)?.[1],
105
+ expected: 0,
106
+ isDone: isEnded || vitest !== null || nodeTotal !== undefined,
107
+ failures,
108
+ mtimeMs,
109
+ firstSeenMs: nowMs,
110
+ firstDone: 0,
111
+ };
112
+ };
113
+
114
+ export const REGISTRY = '/tmp/ethlete-runs';
115
+ export const HIDE_AFTER_MS = 60_000;
116
+
117
+ type RegistryFileSystem = {
118
+ list(path: string): Promise<{ name: string; kind: string }[]>;
119
+ read(path: string): Promise<string>;
120
+ stat(path: string): Promise<{ mtimeMs: number }>;
121
+ };
122
+
123
+ type RegistryEntry = {
124
+ log: string;
125
+ machine: string;
126
+ label: string;
127
+ pid: number;
128
+ cwd?: string;
129
+ sessionId?: string;
130
+ endedAt?: number;
131
+ };
132
+ export type RegistryRun = { entry: RegistryEntry; mtimeMs: number };
133
+
134
+ type RegistryScope = { nowMs: number; projectRoot: string; sessionId: string };
135
+
136
+ export async function registryRuns(
137
+ fs: RegistryFileSystem,
138
+ { nowMs, projectRoot, sessionId }: RegistryScope,
139
+ ): Promise<RegistryRun[]> {
140
+ const root = projectRoot.replace(/\/+$/, '');
141
+ const files = await fs.list(REGISTRY).catch(() => []);
142
+ const found = await Promise.all(
143
+ files
144
+ .filter((f) => f.kind === 'file' && f.name.endsWith('.json'))
145
+ .map(async (f): Promise<RegistryRun | undefined> => {
146
+ const entry = await fs.read(`${REGISTRY}/${f.name}`).then(
147
+ (t) => JSON.parse(t) as RegistryEntry,
148
+ () => undefined,
149
+ );
150
+ if (!entry?.log || typeof entry.cwd !== 'string' || entry.sessionId !== sessionId) return undefined;
151
+ if (entry.cwd !== root && !entry.cwd.startsWith(`${root}/`)) return undefined;
152
+ if (entry.endedAt === undefined && !(await fs.stat(`/proc/${entry.pid}`).catch(() => undefined)))
153
+ return undefined;
154
+ if (entry.endedAt !== undefined && nowMs - entry.endedAt > HIDE_AFTER_MS) return undefined;
155
+ const stat = await fs.stat(entry.log).catch(() => undefined);
156
+ return { entry, mtimeMs: stat?.mtimeMs ?? 0 };
157
+ }),
158
+ );
159
+ return found.filter((r) => r !== undefined);
160
+ }
161
+
162
+ export const SETUP_MAX_MS = 10 * 60_000;
163
+
164
+ export const worktreeRoots = (porcelain: string) =>
165
+ porcelain
166
+ .split('\n')
167
+ .filter((line) => line.startsWith('worktree '))
168
+ .map((line) => line.slice('worktree '.length).trim());
169
+
170
+ const ownerOf = (path: string, roots: string[]) =>
171
+ roots.filter((root) => path === root || path.startsWith(`${root}/`)).sort((a, b) => b.length - a.length)[0];
172
+
173
+ export const setupRuns = (
174
+ logs: { path: string; mtimeMs: number }[],
175
+ roots: string[],
176
+ playwrightCwds: string[],
177
+ nowMs: number,
178
+ ): Progress[] => {
179
+ const live = new Set(playwrightCwds.map((cwd) => ownerOf(cwd, roots)));
180
+ const newest = new Map<string, { path: string; mtimeMs: number }>();
181
+ for (const log of logs) {
182
+ const root = ownerOf(log.path, roots);
183
+ if (root === undefined || !live.has(root) || nowMs - log.mtimeMs > SETUP_MAX_MS) continue;
184
+ if (log.mtimeMs > (newest.get(root)?.mtimeMs ?? -1)) newest.set(root, log);
185
+ }
186
+ return [...newest.values()].map(({ path, mtimeMs }) => ({
187
+ path,
188
+ kind: 'e2e' as const,
189
+ total: 0,
190
+ passed: 0,
191
+ failed: 0,
192
+ skipped: 0,
193
+ flaky: 0,
194
+ didNotRun: 0,
195
+ workers: 1,
196
+ duration: undefined,
197
+ expected: 0,
198
+ isDone: false,
199
+ isSetup: true,
200
+ failures: [],
201
+ mtimeMs,
202
+ firstSeenMs: nowMs,
203
+ firstDone: 0,
204
+ }));
205
+ };