@ethlete/agent-rules 0.1.0-next.4 → 0.1.0-next.41
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/AGENTS.md +28 -0
- package/CHANGELOG.md +627 -0
- package/CLAUDE.md +1 -0
- package/README.md +406 -29
- package/THIRD-PARTY-LICENSES.md +35 -0
- package/content/defaults.json +1 -1
- package/content/git-hooks/post-checkout.sh +10 -0
- package/content/git-hooks/pre-push.sh +5 -0
- package/content/hooks/away-mode.py +287 -0
- package/content/hooks/background-design-commands.py +215 -0
- package/content/hooks/builder-chat-words.py +269 -0
- package/content/hooks/context-warning.py +836 -142
- package/content/hooks/git-safety.py +213 -0
- package/content/hooks/subagent-model-policy.py +261 -0
- package/content/mods/.claude-plugin/marketplace.json +16 -0
- package/content/mods/plugins/e2e-progress/.claude-plugin/plugin.json +6 -0
- package/content/mods/plugins/e2e-progress/hooks/hooks.json +1 -0
- package/content/mods/plugins/e2e-progress/hooks/register.tsx +442 -0
- package/content/mods/plugins/e2e-progress/tsconfig.json +3 -0
- package/content/mods/plugins/e2e-progress/types/index.d.ts +23 -0
- package/content/mods/plugins/status-line/.claude-plugin/plugin.json +6 -0
- package/content/mods/plugins/status-line/hooks/hooks.json +1 -0
- package/content/mods/plugins/status-line/hooks/line.ts +73 -0
- package/content/mods/plugins/status-line/hooks/register.tsx +141 -0
- package/content/mods/plugins/status-line/types/index.d.ts +5 -0
- package/content/output-styles/ste-clarity.md +131 -0
- package/content/rules/agent-sessions-wake-up.md +11 -0
- package/content/rules/app-styling.md +66 -0
- package/content/rules/comments.md +4 -1
- package/content/rules/lint-and-format.md +7 -5
- package/content/rules/nx-layout.md +53 -0
- package/content/rules/reactive-state.md +1 -1
- package/content/rules/styling.md +19 -10
- package/content/rules/subagent-models.md +42 -0
- package/content/skills/agent-sessions/SKILL.md +94 -0
- package/content/skills/agent-sessions/agent-sessions.mjs +1125 -0
- package/content/skills/angular-patterns/SKILL.md +31 -7
- package/content/skills/api-source/SKILL.md +156 -0
- package/content/skills/app-testing/SKILL.md +141 -0
- package/content/skills/codex-subagent/SKILL.md +90 -0
- package/content/skills/codex-subagent/codex-agent.mjs +229 -0
- package/content/skills/design-exploration/SKILL.md +190 -0
- package/content/skills/design-exploration/check-story.mjs +139 -0
- package/content/skills/design-exploration/reference-check-and-notes.md +92 -0
- package/content/skills/design-exploration/reference-flows-and-wireframes.md +78 -0
- package/content/skills/design-exploration/reference-inbox-and-mcp.md +54 -0
- package/content/skills/design-exploration/reference-order-and-design-system.md +124 -0
- package/content/skills/design-exploration/reference-products-and-sketches.md +211 -0
- package/content/skills/design-exploration/reference-shots.md +25 -0
- package/content/skills/design-exploration/shoot-template.mjs +61 -0
- package/content/skills/domain-modeling/ADR-FORMAT.md +47 -0
- package/content/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
- package/content/skills/domain-modeling/SKILL.md +80 -0
- package/content/skills/e2e-triage/SKILL.md +80 -0
- package/content/skills/figma-export/SKILL.md +191 -0
- package/content/skills/figma-export/dump-figma-layers.py +83 -0
- package/content/skills/figma-export/dump-figma-svg.py +235 -0
- package/content/skills/figma-export/measure-template.mjs +87 -0
- package/content/skills/git-commit/SKILL.md +21 -7
- package/content/skills/git-flow/SKILL.md +87 -0
- package/content/skills/grill-with-docs/SKILL.md +13 -0
- package/content/skills/grilling/SKILL.md +52 -0
- package/content/skills/handoff/SKILL.md +29 -69
- package/content/skills/handoff/save.md +187 -0
- package/content/skills/query/SKILL.md +165 -64
- package/content/skills/report/SKILL.md +26 -0
- package/content/skills/rxjs-signals/SKILL.md +33 -4
- package/content/skills/sdk-docs/SKILL.md +50 -14
- package/content/skills/sdk-local-build/SKILL.md +26 -8
- package/content/skills/sdk-local-build/sdk-local-baseline.mjs +64 -0
- package/content/skills/sdk-source/SKILL.md +37 -34
- package/content/skills/sdk-update/SKILL.md +103 -0
- package/content/skills/story-styling/SKILL.md +10 -8
- package/content/skills/styleguide/SKILL.md +13 -8
- package/content/skills/styleguide/assets.md +54 -0
- package/content/skills/styleguide/changesets.md +17 -0
- package/content/skills/styleguide/file-structure.md +73 -0
- package/content/skills/styleguide/lint-rule-lookup.md +52 -0
- package/content/skills/styleguide/storybook-structure.md +25 -0
- package/content/skills/theming/SKILL.md +56 -28
- package/content/skills/timetrack/SKILL.md +324 -0
- package/content/skills/verify-in-app/SKILL.md +107 -0
- package/content/skills/verify-in-storybook/SKILL.md +1 -1
- package/migrations/list-state-query-form.md +20 -0
- package/migrations/nx-layout.md +29 -0
- package/migrations/sdk-components-over-hand-built-ui.md +27 -0
- package/migrations/search-query-field.md +52 -0
- package/migrations.json +39 -0
- package/package.json +19 -3
- package/src/index.js +99 -32
- package/src/index.js.map +1 -1
- package/src/lib/cli-args.d.ts +9 -0
- package/src/lib/cli-args.js +48 -0
- package/src/lib/cli-args.js.map +1 -0
- package/src/lib/commitlint.d.ts +10 -0
- package/src/lib/commitlint.js +51 -0
- package/src/lib/commitlint.js.map +1 -0
- package/src/lib/config.d.ts +51 -6
- package/src/lib/config.js +127 -10
- package/src/lib/config.js.map +1 -1
- package/src/lib/filter.d.ts +2 -0
- package/src/lib/filter.js +4 -4
- package/src/lib/filter.js.map +1 -1
- package/src/lib/frontmatter.d.ts +2 -0
- package/src/lib/frontmatter.js +33 -5
- package/src/lib/frontmatter.js.map +1 -1
- package/src/lib/git-flow/build.d.ts +35 -0
- package/src/lib/git-flow/build.js +24 -0
- package/src/lib/git-flow/build.js.map +1 -0
- package/src/lib/git-flow/config.d.ts +59 -0
- package/src/lib/git-flow/config.js +50 -0
- package/src/lib/git-flow/config.js.map +1 -0
- package/src/lib/git-flow/index.d.ts +6 -0
- package/src/lib/git-flow/index.js +23 -0
- package/src/lib/git-flow/index.js.map +1 -0
- package/src/lib/git-flow/parse.d.ts +49 -0
- package/src/lib/git-flow/parse.js +300 -0
- package/src/lib/git-flow/parse.js.map +1 -0
- package/src/lib/git-flow/rename.d.ts +24 -0
- package/src/lib/git-flow/rename.js +70 -0
- package/src/lib/git-flow/rename.js.map +1 -0
- package/src/lib/git-flow/start.d.ts +49 -0
- package/src/lib/git-flow/start.js +57 -0
- package/src/lib/git-flow/start.js.map +1 -0
- package/src/lib/git-flow/validate.d.ts +34 -0
- package/src/lib/git-flow/validate.js +72 -0
- package/src/lib/git-flow/validate.js.map +1 -0
- package/src/lib/git-flow-command.d.ts +4 -0
- package/src/lib/git-flow-command.js +165 -0
- package/src/lib/git-flow-command.js.map +1 -0
- package/src/lib/git-flow-repair.d.ts +17 -0
- package/src/lib/git-flow-repair.js +165 -0
- package/src/lib/git-flow-repair.js.map +1 -0
- package/src/lib/git-flow-start.d.ts +20 -0
- package/src/lib/git-flow-start.js +140 -0
- package/src/lib/git-flow-start.js.map +1 -0
- package/src/lib/git-test-env.fixtures.d.ts +11 -0
- package/src/lib/git-test-env.fixtures.js +31 -0
- package/src/lib/git-test-env.fixtures.js.map +1 -0
- package/src/lib/git.d.ts +64 -0
- package/src/lib/git.js +131 -0
- package/src/lib/git.js.map +1 -0
- package/src/lib/gitlab.d.ts +35 -0
- package/src/lib/gitlab.js +116 -0
- package/src/lib/gitlab.js.map +1 -0
- package/src/lib/index.d.ts +2 -0
- package/src/lib/index.js +26 -11
- package/src/lib/index.js.map +1 -1
- package/src/lib/migrate.js +8 -2
- package/src/lib/migrate.js.map +1 -1
- package/src/lib/output-style-command.d.ts +3 -0
- package/src/lib/output-style-command.js +69 -0
- package/src/lib/output-style-command.js.map +1 -0
- package/src/lib/output-style.d.ts +38 -0
- package/src/lib/output-style.js +134 -0
- package/src/lib/output-style.js.map +1 -0
- package/src/lib/owned-paths.js +27 -3
- package/src/lib/owned-paths.js.map +1 -1
- package/src/lib/package-runner.d.ts +4 -0
- package/src/lib/package-runner.js +86 -0
- package/src/lib/package-runner.js.map +1 -0
- package/src/lib/peer-path.d.ts +12 -0
- package/src/lib/peer-path.js +39 -0
- package/src/lib/peer-path.js.map +1 -0
- package/src/lib/plain-text.d.ts +9 -0
- package/src/lib/plain-text.js +22 -0
- package/src/lib/plain-text.js.map +1 -0
- package/src/lib/plan.d.ts +6 -6
- package/src/lib/plan.js +168 -40
- package/src/lib/plan.js.map +1 -1
- package/src/lib/prettier.d.ts +21 -0
- package/src/lib/prettier.js +51 -0
- package/src/lib/prettier.js.map +1 -0
- package/src/lib/prompt.d.ts +8 -0
- package/src/lib/prompt.js +35 -0
- package/src/lib/prompt.js.map +1 -0
- package/src/lib/render.d.ts +26 -2
- package/src/lib/render.js +45 -10
- package/src/lib/render.js.map +1 -1
- package/src/lib/report-command.d.ts +33 -0
- package/src/lib/report-command.js +312 -0
- package/src/lib/report-command.js.map +1 -0
- package/src/lib/sessions-command.d.ts +4 -0
- package/src/lib/sessions-command.js +16 -0
- package/src/lib/sessions-command.js.map +1 -0
- package/src/lib/sync.d.ts +1 -2
- package/src/lib/sync.js +37 -17
- package/src/lib/sync.js.map +1 -1
- package/src/lib/targets/agents-skills.js +1 -1
- package/src/lib/targets/agents-skills.js.map +1 -1
- package/src/lib/targets/claude-hooks.d.ts +3 -23
- package/src/lib/targets/claude-hooks.js +22 -86
- package/src/lib/targets/claude-hooks.js.map +1 -1
- package/src/lib/targets/claude-mods.d.ts +20 -0
- package/src/lib/targets/claude-mods.js +47 -0
- package/src/lib/targets/claude-mods.js.map +1 -0
- package/src/lib/targets/claude.js +2 -3
- package/src/lib/targets/claude.js.map +1 -1
- package/src/lib/targets/codex-hooks.d.ts +12 -0
- package/src/lib/targets/codex-hooks.js +35 -0
- package/src/lib/targets/codex-hooks.js.map +1 -0
- package/src/lib/targets/codex.js +4 -4
- package/src/lib/targets/codex.js.map +1 -1
- package/src/lib/targets/copilot.js +4 -4
- package/src/lib/targets/copilot.js.map +1 -1
- package/src/lib/targets/cursor.js +3 -3
- package/src/lib/targets/cursor.js.map +1 -1
- package/src/lib/targets/git-hooks.d.ts +25 -0
- package/src/lib/targets/git-hooks.js +71 -0
- package/src/lib/targets/git-hooks.js.map +1 -0
- package/src/lib/targets/hooks-shared.d.ts +60 -0
- package/src/lib/targets/hooks-shared.js +174 -0
- package/src/lib/targets/hooks-shared.js.map +1 -0
- package/src/lib/targets/mcp.d.ts +16 -0
- package/src/lib/targets/mcp.js +72 -0
- package/src/lib/targets/mcp.js.map +1 -0
- package/src/lib/targets/shared.d.ts +1 -9
- package/src/lib/targets/shared.js +4 -8
- package/src/lib/targets/shared.js.map +1 -1
- package/src/lib/timetrack-command.d.ts +11 -0
- package/src/lib/timetrack-command.js +1262 -0
- package/src/lib/timetrack-command.js.map +1 -0
- package/src/lib/timetrack-snapshot.d.ts +66 -0
- package/src/lib/timetrack-snapshot.js +146 -0
- package/src/lib/timetrack-snapshot.js.map +1 -0
- package/src/lib/timetrack.d.ts +607 -0
- package/src/lib/timetrack.js +285 -0
- package/src/lib/timetrack.js.map +1 -0
- package/content/skills/styleguide/STYLEGUIDE.md +0 -520
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { atom, read, update } from 'claude-code';
|
|
2
|
+
import type { EngineInterface, Register, Timer } from 'claude-code';
|
|
3
|
+
|
|
4
|
+
import type { Progress } from '../types';
|
|
5
|
+
|
|
6
|
+
const PANE = 'e2e-progress';
|
|
7
|
+
const HANDOFFS = ['.claude/handoffs', '.agents/handoffs'];
|
|
8
|
+
const WORKTREES = '.claude/worktrees';
|
|
9
|
+
const TICK_MS = 5000;
|
|
10
|
+
const STALE_MS = 15_000;
|
|
11
|
+
const HIDE_AFTER_MS = 60_000;
|
|
12
|
+
const MIN_ETA_TESTS = 5;
|
|
13
|
+
const MIN_ETA_MS = 30_000;
|
|
14
|
+
const MAX_CANDIDATES = 12;
|
|
15
|
+
const STALLED_MS = 15 * 60_000;
|
|
16
|
+
const runs = atom({ plugin: 'e2e-progress', key: 'runs' } as const, []);
|
|
17
|
+
const pinnedPath = atom({ plugin: 'e2e-progress', key: 'path' } as const, null);
|
|
18
|
+
|
|
19
|
+
const count = (text: string, re: RegExp) => (text.match(re) ?? []).length;
|
|
20
|
+
const summary = (text: string, word: string) => {
|
|
21
|
+
const hit = text.match(new RegExp(`^\\s+(\\d+) ${word}\\b`, 'm'));
|
|
22
|
+
return hit ? Number(hit[1]) : undefined;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const doneOf = (p: Progress) => p.passed + p.failed + p.skipped;
|
|
26
|
+
|
|
27
|
+
const FAIL_LINE = /✘\s+\d+\s+\[[^\]]+\]\s+›\s+(\S+?):(\d+):\d+\s+›\s+(.*)$/;
|
|
28
|
+
const TEST_DECLARATION = /\btest(\.\w+)?\(/;
|
|
29
|
+
const indentOf = (line: string) => line.length - line.trimStart().length;
|
|
30
|
+
|
|
31
|
+
const titleOf = (rest: string) =>
|
|
32
|
+
(
|
|
33
|
+
rest
|
|
34
|
+
.replace(/\s+@\S+.*$/, '')
|
|
35
|
+
.replace(/\s+\([\d.]+m?s\)$/, '')
|
|
36
|
+
.split(' › ')
|
|
37
|
+
.pop() ?? ''
|
|
38
|
+
).trim();
|
|
39
|
+
|
|
40
|
+
const declaresAt = (source: string[], index: number, title: string) => {
|
|
41
|
+
if (!TEST_DECLARATION.test(source[index] ?? '')) return false;
|
|
42
|
+
const head = source.slice(index, index + 3).join('\n');
|
|
43
|
+
return head.includes(title.slice(0, 25)) || head.includes('`');
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const callsTestFail = (source: string[], index: number) => {
|
|
47
|
+
const declaration = source[index] ?? '';
|
|
48
|
+
if (/\btest\.fail\(/.test(declaration)) return true;
|
|
49
|
+
const indent = indentOf(declaration);
|
|
50
|
+
for (const line of source.slice(index + 1)) {
|
|
51
|
+
if (line.trim() !== '' && indentOf(line) <= indent && !/=>\s*\{\s*$/.test(line)) return false;
|
|
52
|
+
if (/\btest\.fail\(/.test(line)) return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const sourceCache = new Map<string, string[] | null>();
|
|
58
|
+
|
|
59
|
+
async function sourceOf($: EngineInterface, path: string) {
|
|
60
|
+
if (!sourceCache.has(path))
|
|
61
|
+
sourceCache.set(
|
|
62
|
+
path,
|
|
63
|
+
await $.fs.read(path).then(
|
|
64
|
+
(t) => t.split('\n'),
|
|
65
|
+
() => null,
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
return sourceCache.get(path) ?? null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function rootsFor($: EngineInterface, logPath: string) {
|
|
72
|
+
const at = Math.max(...HANDOFFS.map((dir) => logPath.indexOf(dir)));
|
|
73
|
+
const own = at > 0 ? logPath.slice(0, at) : '';
|
|
74
|
+
const worktrees = await $.fs.list(WORKTREES).catch(() => []);
|
|
75
|
+
const all = [own, '', ...worktrees.filter((d) => d.kind === 'dir').map((d) => `${WORKTREES}/${d.name}/`)];
|
|
76
|
+
return [...new Set(all)];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function expectedFailures($: EngineInterface, logPath: string, text: string) {
|
|
80
|
+
const expected = new Set<string>();
|
|
81
|
+
const failLines = text.split('\n').filter((line) => FAIL_LINE.test(line));
|
|
82
|
+
if (failLines.length === 0) return expected;
|
|
83
|
+
const roots = await rootsFor($, logPath);
|
|
84
|
+
for (const line of failLines) {
|
|
85
|
+
const [, file = '', lineNo = '0', rest = ''] = line.match(FAIL_LINE) ?? [];
|
|
86
|
+
const index = Number(lineNo) - 1;
|
|
87
|
+
const title = titleOf(rest);
|
|
88
|
+
for (const root of roots) {
|
|
89
|
+
const source = await sourceOf($, `${root}${file}`);
|
|
90
|
+
if (source === null || !declaresAt(source, index, title)) continue;
|
|
91
|
+
if (callsTestFail(source, index)) expected.add(line);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return expected;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const parse = (
|
|
99
|
+
path: string,
|
|
100
|
+
text: string,
|
|
101
|
+
expected: Set<string>,
|
|
102
|
+
mtimeMs: number,
|
|
103
|
+
nowMs: number,
|
|
104
|
+
last: Progress | null,
|
|
105
|
+
): Progress => {
|
|
106
|
+
const isDone = /^\s+\d+ (passed|failed|did not run)\b/m.test(text) || /^EXIT \d+/m.test(text);
|
|
107
|
+
const lines = text.split('\n');
|
|
108
|
+
const listFailures = lines
|
|
109
|
+
.filter((line) => line.includes('✘') && !expected.has(line))
|
|
110
|
+
.map((line) => line.replace(/^.*?✘\s+\d+\s+\[[^\]]+\]\s+›\s+/, '').replace(/\s+@\S+.*$/, ''));
|
|
111
|
+
const lineFailures = new Map<string, string>();
|
|
112
|
+
for (const line of lines) {
|
|
113
|
+
const hit = line.match(/^\s+(\d+)\) \[[^\]]+\] › (.*)$/);
|
|
114
|
+
if (hit?.[1] && hit[2]) lineFailures.set(hit[1], hit[2].replace(/\s+@\S+.*$/, '').replace(/\s*─+\s*$/, ''));
|
|
115
|
+
}
|
|
116
|
+
const failures = isDone && lineFailures.size > 0 ? [...lineFailures.values()] : listFailures;
|
|
117
|
+
const started = Math.max(0, ...[...text.matchAll(/^\[(\d+)\/\d+\]/gm)].map((m) => Number(m[1])));
|
|
118
|
+
const ticks = count(text, /✓/g);
|
|
119
|
+
const p = {
|
|
120
|
+
path,
|
|
121
|
+
total: Number(text.match(/Running (\d+) tests?/)?.[1] ?? 0),
|
|
122
|
+
passed: summary(text, 'passed') ?? (ticks > 0 ? ticks + expected.size : Math.max(0, started - failures.length)),
|
|
123
|
+
failed: summary(text, 'failed') ?? failures.length,
|
|
124
|
+
skipped: summary(text, 'skipped') ?? (ticks > 0 ? count(text, /^\s+-\s+\d+\s/gm) : 0),
|
|
125
|
+
flaky: summary(text, 'flaky') ?? 0,
|
|
126
|
+
didNotRun: summary(text, 'did not run') ?? 0,
|
|
127
|
+
workers: Number(text.match(/Running \d+ tests? using (\d+) workers?/)?.[1] ?? 1),
|
|
128
|
+
duration: text.match(/^\s+\d+ passed \(([^)]+)\)/m)?.[1],
|
|
129
|
+
expected: expected.size,
|
|
130
|
+
isDone,
|
|
131
|
+
failures,
|
|
132
|
+
mtimeMs,
|
|
133
|
+
firstSeenMs: nowMs,
|
|
134
|
+
firstDone: 0,
|
|
135
|
+
};
|
|
136
|
+
const isSameRun =
|
|
137
|
+
last !== null &&
|
|
138
|
+
last.path === path &&
|
|
139
|
+
!last.isDone &&
|
|
140
|
+
Number.isFinite(last.firstSeenMs) &&
|
|
141
|
+
Number.isFinite(last.firstDone) &&
|
|
142
|
+
doneOf(p) >= last.firstDone;
|
|
143
|
+
return isSameRun
|
|
144
|
+
? { ...p, firstSeenMs: last.firstSeenMs, firstDone: last.firstDone }
|
|
145
|
+
: { ...p, firstDone: doneOf(p) };
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const FAILURES_FILE_LINE = /^\[failure-reporter\] Writing failures to (.+)$/m;
|
|
149
|
+
|
|
150
|
+
type FailureRecord = { test: string; location: string; error?: string; detail?: string | null };
|
|
151
|
+
|
|
152
|
+
const recordsOf = (text: string): FailureRecord[] =>
|
|
153
|
+
text.split('\n').flatMap((line) => {
|
|
154
|
+
if (line.trim() === '') return [];
|
|
155
|
+
try {
|
|
156
|
+
const record = JSON.parse(line);
|
|
157
|
+
return typeof record?.test === 'string' && typeof record?.location === 'string' ? [record] : [];
|
|
158
|
+
} catch {
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const firstErrorLine = (error: string | undefined) =>
|
|
164
|
+
(error ?? '')
|
|
165
|
+
.split('\n')
|
|
166
|
+
.find((line) => line.trim() !== '')
|
|
167
|
+
?.replace(/^Error:\s*/, '')
|
|
168
|
+
.trim() ?? '';
|
|
169
|
+
|
|
170
|
+
const failuresOf = (records: FailureRecord[]) => {
|
|
171
|
+
const latest = new Map<string, FailureRecord>();
|
|
172
|
+
for (const record of records) latest.set(`${record.location} › ${record.test}`, record);
|
|
173
|
+
return [...latest].map(([key, record]) => {
|
|
174
|
+
const error = firstErrorLine(record.error);
|
|
175
|
+
const line = error ? `${key} — ${error}` : key;
|
|
176
|
+
return record.detail ? `${line} (${record.detail})` : line;
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
async function withRecords($: EngineInterface, p: Progress, text: string): Promise<Progress> {
|
|
181
|
+
const file = text.match(FAILURES_FILE_LINE)?.[1]?.trim();
|
|
182
|
+
if (!file) return p;
|
|
183
|
+
const records = await $.fs.read(file).then(recordsOf, () => undefined);
|
|
184
|
+
if (records === undefined) return p;
|
|
185
|
+
const failures = failuresOf(records);
|
|
186
|
+
return { ...p, failures, failed: summary(text, 'failed') ?? failures.length };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const remainingMs = (p: Progress, nowMs: number) => {
|
|
190
|
+
const doneSince = doneOf(p) - p.firstDone;
|
|
191
|
+
const elapsed = nowMs - p.firstSeenMs;
|
|
192
|
+
if (p.isDone || doneSince < MIN_ETA_TESTS || elapsed < MIN_ETA_MS) return undefined;
|
|
193
|
+
return ((p.total - doneOf(p)) / doneSince) * elapsed;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const formatEta = (ms: number | undefined) => {
|
|
197
|
+
if (ms === undefined) return '';
|
|
198
|
+
const minutes = Math.round(ms / 60_000);
|
|
199
|
+
return minutes < 1 ? ' ~<1m left' : ` ~${minutes}m left`;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
type LogFile = { path: string; mtimeMs: number };
|
|
203
|
+
|
|
204
|
+
async function logsUnder($: EngineInterface, dir: string, depth: number): Promise<LogFile[]> {
|
|
205
|
+
const entries = await $.fs.list(dir).catch(() => []);
|
|
206
|
+
const files = entries
|
|
207
|
+
.filter((f) => f.kind === 'file' && f.name.endsWith('.log'))
|
|
208
|
+
.map((f) => ({ path: `${dir}/${f.name}`, mtimeMs: f.mtimeMs }));
|
|
209
|
+
if (depth === 0) return files;
|
|
210
|
+
const nested = await Promise.all(
|
|
211
|
+
entries.filter((d) => d.kind === 'dir').map((d) => logsUnder($, `${dir}/${d.name}`, depth - 1)),
|
|
212
|
+
);
|
|
213
|
+
return [...files, ...nested.flat()];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async function baseDirs($: EngineInterface) {
|
|
217
|
+
const bases = new Set([await $.session.root()]);
|
|
218
|
+
let dir = await $.session.cwd();
|
|
219
|
+
for (let up = 0; up <= 3 && dir !== ''; up++) {
|
|
220
|
+
bases.add(dir);
|
|
221
|
+
dir = dir.slice(0, dir.lastIndexOf('/'));
|
|
222
|
+
}
|
|
223
|
+
return [...bases];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function handoffDirs($: EngineInterface) {
|
|
227
|
+
const perBase = await Promise.all(
|
|
228
|
+
(await baseDirs($)).map(async (base) => {
|
|
229
|
+
const worktrees = await $.fs.list(`${base}/${WORKTREES}`).catch(() => []);
|
|
230
|
+
const roots = [base, ...worktrees.filter((d) => d.kind === 'dir').map((d) => `${base}/${WORKTREES}/${d.name}`)];
|
|
231
|
+
return roots.flatMap((root) => HANDOFFS.map((dir) => `${root}/${dir}`));
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
return perBase.flat();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const nameOf = (path: string) => (path.split('/').pop() ?? path).replace(/\.log$/, '');
|
|
238
|
+
|
|
239
|
+
const isRunLog = (text: string) => /^Running \d+ tests?/m.test(text);
|
|
240
|
+
|
|
241
|
+
const notRunLogs = new Map<string, number>();
|
|
242
|
+
|
|
243
|
+
async function candidateLogs($: EngineInterface) {
|
|
244
|
+
const perDir = await Promise.all((await handoffDirs($)).map((dir) => logsUnder($, dir, 2)));
|
|
245
|
+
const unique = new Map(perDir.flat().map((log) => [log.path, log]));
|
|
246
|
+
return [...unique.values()].sort((a, b) => b.mtimeMs - a.mtimeMs).slice(0, MAX_CANDIDATES);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
async function newestLog($: EngineInterface) {
|
|
250
|
+
for (const log of await candidateLogs($)) {
|
|
251
|
+
if (isRunLog(await $.fs.read(log.path).catch(() => ''))) return log;
|
|
252
|
+
}
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async function pinnedLog($: EngineInterface): Promise<LogFile | undefined> {
|
|
257
|
+
const pinned = await read($, pinnedPath);
|
|
258
|
+
if (pinned === null) return undefined;
|
|
259
|
+
const stat = await $.fs.stat(pinned).catch(() => undefined);
|
|
260
|
+
const newest = await newestLog($);
|
|
261
|
+
if (newest !== undefined && newest.path !== pinned && (stat === undefined || newest.mtimeMs > stat.mtimeMs)) {
|
|
262
|
+
await update($, pinnedPath, () => null);
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
return stat === undefined ? undefined : { path: pinned, mtimeMs: stat.mtimeMs };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const isVisible = (p: Progress, nowMs: number) =>
|
|
269
|
+
p.isDone ? nowMs - p.mtimeMs <= HIDE_AFTER_MS : nowMs - p.mtimeMs <= STALLED_MS;
|
|
270
|
+
|
|
271
|
+
let isHidden = false;
|
|
272
|
+
let timer: Timer | undefined;
|
|
273
|
+
let lastTickMs = 0;
|
|
274
|
+
let shownStatus: string | undefined | null = null;
|
|
275
|
+
|
|
276
|
+
function setStatus($: EngineInterface, text: string | undefined) {
|
|
277
|
+
if (text === shownStatus) return;
|
|
278
|
+
shownStatus = text;
|
|
279
|
+
$.ui.status(text);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const statusOf = (p: Progress, nowMs: number) =>
|
|
283
|
+
`${nameOf(p.path)} w${p.workers} ${p.isDone ? `done ${p.duration ?? ''}`.trim() : `${doneOf(p)}/${p.total}`} ✓${p.passed} ✘${p.failed}` +
|
|
284
|
+
`${p.flaky ? ` ~${p.flaky}` : ''}${p.skipped ? ` -${p.skipped}` : ''}${p.didNotRun ? ` ⊘${p.didNotRun}` : ''}${formatEta(remainingMs(p, nowMs))}`;
|
|
285
|
+
|
|
286
|
+
async function tick($: EngineInterface) {
|
|
287
|
+
const nowMs = await $.clock.now();
|
|
288
|
+
const pinned = await pinnedLog($);
|
|
289
|
+
const logs = pinned ? [pinned] : await candidateLogs($);
|
|
290
|
+
const last = new Map((await read($, runs)).map((p) => [p.path, p]));
|
|
291
|
+
const next: Progress[] = [];
|
|
292
|
+
for (const log of logs) {
|
|
293
|
+
const previous = last.get(log.path);
|
|
294
|
+
if (previous?.mtimeMs === log.mtimeMs) {
|
|
295
|
+
next.push(previous);
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (notRunLogs.get(log.path) === log.mtimeMs) continue;
|
|
299
|
+
const text = await $.fs.read(log.path).catch(() => '');
|
|
300
|
+
if (!isRunLog(text)) {
|
|
301
|
+
notRunLogs.set(log.path, log.mtimeMs);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
sourceCache.clear();
|
|
305
|
+
const parsed = parse(
|
|
306
|
+
log.path,
|
|
307
|
+
text,
|
|
308
|
+
await expectedFailures($, log.path, text),
|
|
309
|
+
log.mtimeMs,
|
|
310
|
+
nowMs,
|
|
311
|
+
previous ?? null,
|
|
312
|
+
);
|
|
313
|
+
next.push(await withRecords($, parsed, text));
|
|
314
|
+
}
|
|
315
|
+
const visible = next.filter((p) => isVisible(p, nowMs)).sort((a, b) => a.path.localeCompare(b.path));
|
|
316
|
+
await update($, runs, () => visible);
|
|
317
|
+
|
|
318
|
+
if (visible.length === 0) {
|
|
319
|
+
setStatus($, undefined);
|
|
320
|
+
if (!isHidden) {
|
|
321
|
+
isHidden = true;
|
|
322
|
+
await $.ui.close({ id: PANE }).catch(() => undefined);
|
|
323
|
+
}
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
isHidden = false;
|
|
328
|
+
setStatus($, `e2e ${visible.map((p) => statusOf(p, nowMs)).join(' │ ')}`);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async function run($: EngineInterface) {
|
|
332
|
+
lastTickMs = await $.clock.now();
|
|
333
|
+
try {
|
|
334
|
+
await tick($);
|
|
335
|
+
} catch (error) {
|
|
336
|
+
setStatus($, `e2e-progress failed: ${String(error)}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function start($: EngineInterface) {
|
|
341
|
+
timer?.cancel();
|
|
342
|
+
timer = $.clock.every(TICK_MS, () => run($));
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async function revive($: EngineInterface) {
|
|
346
|
+
if ((await $.clock.now()) - lastTickMs < STALE_MS) return;
|
|
347
|
+
start($);
|
|
348
|
+
await run($);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export const register: Register = (on) => {
|
|
352
|
+
on('session.start', async ($, e, next) => {
|
|
353
|
+
await $.command.register({
|
|
354
|
+
name: 'e2e',
|
|
355
|
+
description:
|
|
356
|
+
'Show e2e run progress. Optional arg: a log path to pin; "auto" removes the pin; "off" clears the status',
|
|
357
|
+
});
|
|
358
|
+
start($);
|
|
359
|
+
return next(e);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
on('prompt.submit', async ($, e, next) => {
|
|
363
|
+
await revive($);
|
|
364
|
+
return next(e);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
on('tool.call', async ($, e, next) => {
|
|
368
|
+
await revive($);
|
|
369
|
+
return next(e);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
on('turn.complete', async ($, e, next) => {
|
|
373
|
+
await revive($);
|
|
374
|
+
return next(e);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
on('command.run', { command: 'e2e' }, async ($, e) => {
|
|
378
|
+
const arg = e.args.trim();
|
|
379
|
+
if (arg === 'off') {
|
|
380
|
+
setStatus($, undefined);
|
|
381
|
+
return { text: 'e2e status cleared until the log changes.' };
|
|
382
|
+
}
|
|
383
|
+
if (arg === 'auto') {
|
|
384
|
+
await update($, pinnedPath, () => null);
|
|
385
|
+
start($);
|
|
386
|
+
await run($);
|
|
387
|
+
return { text: `Pin removed. Watching the newest logs under ${HANDOFFS.join(' and ')}.` };
|
|
388
|
+
}
|
|
389
|
+
if (arg !== '') await update($, pinnedPath, () => arg);
|
|
390
|
+
start($);
|
|
391
|
+
await $.ui.open({ id: PANE, title: 'E2E progress' });
|
|
392
|
+
return { text: arg ? `Watching ${arg}.` : 'E2E progress pane opened.' };
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
|
|
396
|
+
const { Box, Text } = $.ui.resolve(e);
|
|
397
|
+
const shown = await read($, runs);
|
|
398
|
+
if (shown.length === 0)
|
|
399
|
+
return (
|
|
400
|
+
<Text dimColor>
|
|
401
|
+
No active run log under {HANDOFFS.join(' or ')}, also in {WORKTREES}/*.
|
|
402
|
+
</Text>
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
const nowMs = await $.clock.now();
|
|
406
|
+
const room = Math.max(1, Math.floor(((e.viewport?.rows ?? 24) - 6 * shown.length) / shown.length));
|
|
407
|
+
return (
|
|
408
|
+
<Box flexDirection="column">
|
|
409
|
+
{shown.map((p) => {
|
|
410
|
+
const done = doneOf(p);
|
|
411
|
+
return (
|
|
412
|
+
<Box flexDirection="column" marginBottom={1}>
|
|
413
|
+
<Text bold>
|
|
414
|
+
{nameOf(p.path)} <Text dimColor>· {p.workers} workers</Text>
|
|
415
|
+
</Text>
|
|
416
|
+
<Text dimColor wrap="truncate-start">
|
|
417
|
+
{p.path}
|
|
418
|
+
</Text>
|
|
419
|
+
<Text>
|
|
420
|
+
{p.isDone ? `finished in ${p.duration ?? '?'}` : `${done} / ${p.total}`}
|
|
421
|
+
{p.total > 0 && !p.isDone ? ` (${Math.round((done / p.total) * 100)}%)` : ''}
|
|
422
|
+
{formatEta(remainingMs(p, nowMs))}
|
|
423
|
+
</Text>
|
|
424
|
+
<Text>
|
|
425
|
+
<Text color="green">✓ {p.passed}</Text> <Text color="red">✘ {p.failed}</Text>{' '}
|
|
426
|
+
<Text dimColor>- {p.skipped} skipped</Text>
|
|
427
|
+
{p.didNotRun > 0 ? <Text color="yellow"> ⊘ {p.didNotRun} did not run</Text> : ''}
|
|
428
|
+
{p.flaky > 0 ? <Text color="yellow"> ~ {p.flaky} flaky</Text> : ''}
|
|
429
|
+
</Text>
|
|
430
|
+
{p.expected > 0 && <Text dimColor>{p.expected} expected failures (test.fail) counted as passed</Text>}
|
|
431
|
+
{p.failures.slice(-room).map((f) => (
|
|
432
|
+
<Text color="red" wrap="truncate-end">
|
|
433
|
+
✘ {f}
|
|
434
|
+
</Text>
|
|
435
|
+
))}
|
|
436
|
+
</Box>
|
|
437
|
+
);
|
|
438
|
+
})}
|
|
439
|
+
</Box>
|
|
440
|
+
);
|
|
441
|
+
});
|
|
442
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type Progress = {
|
|
2
|
+
path: string;
|
|
3
|
+
total: number;
|
|
4
|
+
passed: number;
|
|
5
|
+
failed: number;
|
|
6
|
+
skipped: number;
|
|
7
|
+
flaky: number;
|
|
8
|
+
didNotRun: number;
|
|
9
|
+
workers: number;
|
|
10
|
+
duration: string | undefined;
|
|
11
|
+
expected: number;
|
|
12
|
+
isDone: boolean;
|
|
13
|
+
failures: string[];
|
|
14
|
+
mtimeMs: number;
|
|
15
|
+
firstSeenMs: number;
|
|
16
|
+
firstDone: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
declare module 'claude-code' {
|
|
20
|
+
interface PluginState {
|
|
21
|
+
'e2e-progress': { runs: Progress[]; path: string | null };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "modules": ["./register.tsx"] }
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const STALE_MS = 2 * 60 * 60 * 1000;
|
|
2
|
+
const QUEUE_HEADING = /^### Warteschlange(, Rest)?\s*$/;
|
|
3
|
+
const HEADING = /^#{1,6} /;
|
|
4
|
+
const QUEUE_ITEM = /^\d+\. \*\*(?:.+ \()?[A-Z]\d+b?\)?\*\*/;
|
|
5
|
+
|
|
6
|
+
export type StatusFields = {
|
|
7
|
+
task?: string;
|
|
8
|
+
minutes?: number;
|
|
9
|
+
queue?: number;
|
|
10
|
+
questions?: number;
|
|
11
|
+
isCiRot?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const lastSlice = (content: string, mtimeMs: number) => {
|
|
15
|
+
const blocks = content.split(/^(?=#\s*slice:)/m).filter((text) => /^#\s*slice:/m.test(text));
|
|
16
|
+
const block = blocks[blocks.length - 1];
|
|
17
|
+
if (block === undefined) return undefined;
|
|
18
|
+
const name = /^#\s*slice:\s*(.+)$/m.exec(block)?.[1]?.trim();
|
|
19
|
+
const written = /^#\s*written:\s*(\S+)/m.exec(block)?.[1];
|
|
20
|
+
const writtenAt = written && !Number.isNaN(Date.parse(written)) ? Date.parse(written) : mtimeMs;
|
|
21
|
+
return name ? { name, writtenAt } : undefined;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const taskFields = (content: string, mtimeMs: number, nowMs: number): Pick<StatusFields, 'task' | 'minutes'> => {
|
|
25
|
+
const slice = lastSlice(content, mtimeMs);
|
|
26
|
+
if (slice === undefined) return {};
|
|
27
|
+
if (nowMs - slice.writtenAt > STALE_MS) return { task: 'kein Slice' };
|
|
28
|
+
return { task: slice.name, minutes: Math.max(0, Math.floor((nowMs - slice.writtenAt) / 60_000)) };
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const queueCount = (text: string) => {
|
|
32
|
+
let count = 0;
|
|
33
|
+
let isInQueue = false;
|
|
34
|
+
for (const line of text.split('\n')) {
|
|
35
|
+
if (HEADING.test(line)) isInQueue = QUEUE_HEADING.test(line);
|
|
36
|
+
else if (isInQueue && QUEUE_ITEM.test(line)) count++;
|
|
37
|
+
}
|
|
38
|
+
return count;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const questionCount = (text: string) => text.split('\n').filter((line) => line.startsWith('- ')).length;
|
|
42
|
+
|
|
43
|
+
export const planFilesOf = (configText: string) => {
|
|
44
|
+
try {
|
|
45
|
+
const files = (JSON.parse(configText) as { report?: { planFiles?: unknown } }).report?.planFiles;
|
|
46
|
+
return Array.isArray(files) && files.every((f) => typeof f === 'string') ? (files as string[]) : undefined;
|
|
47
|
+
} catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const isCiRotOf = (runJson: string) => {
|
|
53
|
+
try {
|
|
54
|
+
const [run] = JSON.parse(runJson) as { conclusion?: string; status?: string }[];
|
|
55
|
+
return run?.status === 'completed' && run.conclusion === 'failure';
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const durationOf = (minutes: number) =>
|
|
62
|
+
minutes < 60 ? `${minutes} min` : `${Math.floor(minutes / 60)} h ${minutes % 60} min`;
|
|
63
|
+
|
|
64
|
+
export const formatLine = (fields: StatusFields) => {
|
|
65
|
+
const parts = [
|
|
66
|
+
fields.task === undefined ? undefined : `▶ ${fields.task}`,
|
|
67
|
+
fields.minutes === undefined ? undefined : durationOf(fields.minutes),
|
|
68
|
+
fields.queue === undefined ? undefined : `${fields.queue} offen`,
|
|
69
|
+
fields.questions ? `❓${fields.questions}` : undefined,
|
|
70
|
+
fields.isCiRot ? '⛔ CI rot' : undefined,
|
|
71
|
+
].filter((part): part is string => part !== undefined);
|
|
72
|
+
return parts.length === 0 ? null : parts.join(' · ');
|
|
73
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { atom, update } from 'claude-code';
|
|
2
|
+
import type { EngineInterface, Register } from 'claude-code';
|
|
3
|
+
|
|
4
|
+
import { formatLine, isCiRotOf, planFilesOf, questionCount, queueCount, taskFields } from './line';
|
|
5
|
+
import type { StatusFields } from './line';
|
|
6
|
+
|
|
7
|
+
const TICK_MS = 5000;
|
|
8
|
+
const CI_EVERY_MS = 2 * 60_000;
|
|
9
|
+
const CI_TIMEOUT_MS = 15_000;
|
|
10
|
+
const ROLE_SKILLS: Record<string, boolean> = { 'doc-agent': true, 'builder-agent': false };
|
|
11
|
+
const line = atom({ plugin: 'status-line', key: 'line' } as const, null);
|
|
12
|
+
const isDocSession = atom({ plugin: 'status-line', key: 'isDocSession' } as const, false);
|
|
13
|
+
|
|
14
|
+
async function markRole($: EngineInterface, skill: string | undefined) {
|
|
15
|
+
const isDoc = skill === undefined ? undefined : ROLE_SKILLS[skill];
|
|
16
|
+
if (isDoc !== undefined) await update($, isDocSession, () => isDoc);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type Source = { mtimeMs: number; text: string };
|
|
20
|
+
|
|
21
|
+
const cache = new Map<string, Source | null>();
|
|
22
|
+
|
|
23
|
+
async function readChanged($: EngineInterface, path: string) {
|
|
24
|
+
const stat = await $.fs.stat(path).catch(() => undefined);
|
|
25
|
+
if (stat === undefined) {
|
|
26
|
+
cache.delete(path);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const cached = cache.get(path);
|
|
30
|
+
if (cached && cached.mtimeMs === stat.mtimeMs) return cached;
|
|
31
|
+
const text = await $.fs.read(path).catch(() => undefined);
|
|
32
|
+
if (text === undefined) return null;
|
|
33
|
+
const source = { mtimeMs: stat.mtimeMs, text };
|
|
34
|
+
cache.set(path, source);
|
|
35
|
+
return source;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function git($: EngineInterface, args: string[]) {
|
|
39
|
+
const result = await $.process.run(['git', ...args], { timeoutMs: 5000 }).catch(() => undefined);
|
|
40
|
+
return result?.exitCode === 0 ? result.stdout.trim() : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let isCiRot = false;
|
|
44
|
+
let lastCiMs = 0;
|
|
45
|
+
let isCiRunning = false;
|
|
46
|
+
|
|
47
|
+
async function refreshCi($: EngineInterface, nowMs: number) {
|
|
48
|
+
if (isCiRunning || nowMs - lastCiMs < CI_EVERY_MS) return;
|
|
49
|
+
isCiRunning = true;
|
|
50
|
+
lastCiMs = nowMs;
|
|
51
|
+
try {
|
|
52
|
+
const branch = await git($, ['branch', '--show-current']);
|
|
53
|
+
const result = branch
|
|
54
|
+
? await $.process.run(['gh', 'run', 'list', '--branch', branch, '-L', '1', '--json', 'conclusion,status'], {
|
|
55
|
+
timeoutMs: CI_TIMEOUT_MS,
|
|
56
|
+
})
|
|
57
|
+
: undefined;
|
|
58
|
+
isCiRot = result?.exitCode === 0 && isCiRotOf(result.stdout);
|
|
59
|
+
} catch {
|
|
60
|
+
isCiRot = false;
|
|
61
|
+
} finally {
|
|
62
|
+
isCiRunning = false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function compute($: EngineInterface, nowMs: number): Promise<StatusFields> {
|
|
67
|
+
const paths = await git($, [
|
|
68
|
+
'rev-parse',
|
|
69
|
+
'--path-format=absolute',
|
|
70
|
+
'--git-path',
|
|
71
|
+
'slice-paths',
|
|
72
|
+
'--git-common-dir',
|
|
73
|
+
'--show-toplevel',
|
|
74
|
+
]);
|
|
75
|
+
const [slicePath, commonDir, root] = paths?.split('\n') ?? [];
|
|
76
|
+
const fields: StatusFields = {};
|
|
77
|
+
|
|
78
|
+
if (slicePath) {
|
|
79
|
+
const slice = await readChanged($, slicePath);
|
|
80
|
+
if (slice) Object.assign(fields, taskFields(slice.text, slice.mtimeMs, nowMs));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (root) {
|
|
84
|
+
const config = await readChanged($, `${root}/ethlete-agents.config.json`);
|
|
85
|
+
const planFiles = config ? planFilesOf(config.text) : undefined;
|
|
86
|
+
if (planFiles) {
|
|
87
|
+
const texts = await Promise.all(planFiles.map((file) => readChanged($, `${root}/${file}`)));
|
|
88
|
+
fields.queue = texts.reduce((sum, source) => sum + (source ? queueCount(source.text) : 0), 0);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (commonDir) {
|
|
93
|
+
const questions = await readChanged($, `${commonDir}/ethlete/open-questions.md`);
|
|
94
|
+
if (questions) fields.questions = questionCount(questions.text);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fields.isCiRot = isCiRot;
|
|
98
|
+
return fields;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function tick($: EngineInterface) {
|
|
102
|
+
try {
|
|
103
|
+
if (!(await $.state.get({ plugin: 'status-line', key: 'isDocSession' } as const)).value) return;
|
|
104
|
+
const nowMs = await $.clock.now();
|
|
105
|
+
void refreshCi($, nowMs);
|
|
106
|
+
const text = formatLine(await compute($, nowMs));
|
|
107
|
+
await update($, line, () => text);
|
|
108
|
+
} catch {
|
|
109
|
+
await update($, line, () => null).catch(() => undefined);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const register: Register = (on) => {
|
|
114
|
+
on('session.start', async ($, e, next) => {
|
|
115
|
+
$.clock.every(TICK_MS, () => tick($));
|
|
116
|
+
await tick($);
|
|
117
|
+
return next(e);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
on('tool.call', { tool: 'Skill' }, async ($, e, next) => {
|
|
121
|
+
await markRole($, e.skill).catch(() => undefined);
|
|
122
|
+
return next(e);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
on('prompt.submit', async ($, e, next) => {
|
|
126
|
+
await markRole($, e.command?.name).catch(() => undefined);
|
|
127
|
+
return next(e);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
|
|
131
|
+
if (!(await $.state.get({ plugin: 'status-line', key: 'isDocSession' } as const)).value) return next(e);
|
|
132
|
+
const text = (await $.state.get({ plugin: 'status-line', key: 'line' } as const)).value;
|
|
133
|
+
if (!text) return next(e);
|
|
134
|
+
const { Box, Text } = $.ui.resolve(e);
|
|
135
|
+
return (
|
|
136
|
+
<Box>
|
|
137
|
+
<Text dimColor>{text}</Text>
|
|
138
|
+
</Box>
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
};
|