@nightloom/isy 1.0.0
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/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/agents/claude.d.ts +6 -0
- package/dist/agents/claude.js +66 -0
- package/dist/agents/claude.js.map +1 -0
- package/dist/agents/codex-records.d.ts +34 -0
- package/dist/agents/codex-records.js +492 -0
- package/dist/agents/codex-records.js.map +1 -0
- package/dist/agents/codex.d.ts +5 -0
- package/dist/agents/codex.js +205 -0
- package/dist/agents/codex.js.map +1 -0
- package/dist/agents/index.d.ts +25 -0
- package/dist/agents/index.js +50 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/kimi-records.d.ts +24 -0
- package/dist/agents/kimi-records.js +252 -0
- package/dist/agents/kimi-records.js.map +1 -0
- package/dist/agents/kimi-wire.d.ts +8 -0
- package/dist/agents/kimi-wire.js +158 -0
- package/dist/agents/kimi-wire.js.map +1 -0
- package/dist/agents/kimi.d.ts +6 -0
- package/dist/agents/kimi.js +332 -0
- package/dist/agents/kimi.js.map +1 -0
- package/dist/agents/types.d.ts +83 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/alert.d.ts +24 -0
- package/dist/alert.js +68 -0
- package/dist/alert.js.map +1 -0
- package/dist/api.d.ts +103 -0
- package/dist/api.js +171 -0
- package/dist/api.js.map +1 -0
- package/dist/commands/analyze.d.ts +61 -0
- package/dist/commands/analyze.js +198 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/check.d.ts +55 -0
- package/dist/commands/check.js +180 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/commit.d.ts +26 -0
- package/dist/commands/commit.js +130 -0
- package/dist/commands/commit.js.map +1 -0
- package/dist/commands/health.d.ts +47 -0
- package/dist/commands/health.js +366 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.js +173 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/logout.d.ts +1 -0
- package/dist/commands/logout.js +30 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/notes.d.ts +11 -0
- package/dist/commands/notes.js +49 -0
- package/dist/commands/notes.js.map +1 -0
- package/dist/commands/scan.d.ts +47 -0
- package/dist/commands/scan.js +199 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/settings.d.ts +15 -0
- package/dist/commands/settings.js +94 -0
- package/dist/commands/settings.js.map +1 -0
- package/dist/commands/status.d.ts +61 -0
- package/dist/commands/status.js +151 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/upload.d.ts +42 -0
- package/dist/commands/upload.js +429 -0
- package/dist/commands/upload.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.js +32 -0
- package/dist/config.js.map +1 -0
- package/dist/detectors.d.ts +43 -0
- package/dist/detectors.js +1026 -0
- package/dist/detectors.js.map +1 -0
- package/dist/git.d.ts +22 -0
- package/dist/git.js +68 -0
- package/dist/git.js.map +1 -0
- package/dist/githook.d.ts +71 -0
- package/dist/githook.js +238 -0
- package/dist/githook.js.map +1 -0
- package/dist/hook.d.ts +39 -0
- package/dist/hook.js +173 -0
- package/dist/hook.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +205 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +19 -0
- package/dist/log.js +97 -0
- package/dist/log.js.map +1 -0
- package/dist/mask-paths.d.ts +75 -0
- package/dist/mask-paths.js +364 -0
- package/dist/mask-paths.js.map +1 -0
- package/dist/pairing.d.ts +60 -0
- package/dist/pairing.js +137 -0
- package/dist/pairing.js.map +1 -0
- package/dist/parser.d.ts +48 -0
- package/dist/parser.js +516 -0
- package/dist/parser.js.map +1 -0
- package/dist/paths.d.ts +41 -0
- package/dist/paths.js +181 -0
- package/dist/paths.js.map +1 -0
- package/dist/plan.d.ts +25 -0
- package/dist/plan.js +39 -0
- package/dist/plan.js.map +1 -0
- package/dist/queue.d.ts +26 -0
- package/dist/queue.js +120 -0
- package/dist/queue.js.map +1 -0
- package/dist/redact.d.ts +29 -0
- package/dist/redact.js +254 -0
- package/dist/redact.js.map +1 -0
- package/dist/spawn.d.ts +13 -0
- package/dist/spawn.js +32 -0
- package/dist/spawn.js.map +1 -0
- package/dist/stage0.d.ts +20 -0
- package/dist/stage0.js +90 -0
- package/dist/stage0.js.map +1 -0
- package/dist/state.d.ts +84 -0
- package/dist/state.js +150 -0
- package/dist/state.js.map +1 -0
- package/dist/test/analyze.test.d.ts +1 -0
- package/dist/test/analyze.test.js +408 -0
- package/dist/test/analyze.test.js.map +1 -0
- package/dist/test/check.test.d.ts +1 -0
- package/dist/test/check.test.js +193 -0
- package/dist/test/check.test.js.map +1 -0
- package/dist/test/cli.test.d.ts +1 -0
- package/dist/test/cli.test.js +132 -0
- package/dist/test/cli.test.js.map +1 -0
- package/dist/test/codex.test.d.ts +1 -0
- package/dist/test/codex.test.js +585 -0
- package/dist/test/codex.test.js.map +1 -0
- package/dist/test/commit.test.d.ts +1 -0
- package/dist/test/commit.test.js +430 -0
- package/dist/test/commit.test.js.map +1 -0
- package/dist/test/git.test.d.ts +1 -0
- package/dist/test/git.test.js +75 -0
- package/dist/test/git.test.js.map +1 -0
- package/dist/test/health.test.d.ts +1 -0
- package/dist/test/health.test.js +156 -0
- package/dist/test/health.test.js.map +1 -0
- package/dist/test/hook.test.d.ts +1 -0
- package/dist/test/hook.test.js +144 -0
- package/dist/test/hook.test.js.map +1 -0
- package/dist/test/kimi.test.d.ts +1 -0
- package/dist/test/kimi.test.js +349 -0
- package/dist/test/kimi.test.js.map +1 -0
- package/dist/test/mask-paths.test.d.ts +1 -0
- package/dist/test/mask-paths.test.js +230 -0
- package/dist/test/mask-paths.test.js.map +1 -0
- package/dist/test/notes.test.d.ts +1 -0
- package/dist/test/notes.test.js +41 -0
- package/dist/test/notes.test.js.map +1 -0
- package/dist/test/pairing.test.d.ts +1 -0
- package/dist/test/pairing.test.js +138 -0
- package/dist/test/pairing.test.js.map +1 -0
- package/dist/test/parser.test.d.ts +1 -0
- package/dist/test/parser.test.js +312 -0
- package/dist/test/parser.test.js.map +1 -0
- package/dist/test/plan.test.d.ts +1 -0
- package/dist/test/plan.test.js +34 -0
- package/dist/test/plan.test.js.map +1 -0
- package/dist/test/redact.test.d.ts +1 -0
- package/dist/test/redact.test.js +303 -0
- package/dist/test/redact.test.js.map +1 -0
- package/dist/test/settings.test.d.ts +1 -0
- package/dist/test/settings.test.js +32 -0
- package/dist/test/settings.test.js.map +1 -0
- package/dist/test/stage0.test.d.ts +1 -0
- package/dist/test/stage0.test.js +607 -0
- package/dist/test/stage0.test.js.map +1 -0
- package/dist/test/sweep.test.d.ts +1 -0
- package/dist/test/sweep.test.js +298 -0
- package/dist/test/sweep.test.js.map +1 -0
- package/dist/test/update.test.d.ts +1 -0
- package/dist/test/update.test.js +26 -0
- package/dist/test/update.test.js.map +1 -0
- package/dist/test/upload.test.d.ts +1 -0
- package/dist/test/upload.test.js +331 -0
- package/dist/test/upload.test.js.map +1 -0
- package/dist/types.d.ts +142 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/update.d.ts +17 -0
- package/dist/update.js +46 -0
- package/dist/update.js.map +1 -0
- package/package.json +60 -0
- package/src/agents/claude.ts +89 -0
- package/src/agents/codex-records.ts +533 -0
- package/src/agents/codex.ts +238 -0
- package/src/agents/index.ts +58 -0
- package/src/agents/kimi-records.ts +274 -0
- package/src/agents/kimi-wire.ts +179 -0
- package/src/agents/kimi.ts +390 -0
- package/src/agents/types.ts +92 -0
- package/src/alert.ts +68 -0
- package/src/api.ts +269 -0
- package/src/commands/analyze.ts +308 -0
- package/src/commands/check.ts +239 -0
- package/src/commands/commit.ts +179 -0
- package/src/commands/health.ts +444 -0
- package/src/commands/init.ts +186 -0
- package/src/commands/logout.ts +33 -0
- package/src/commands/notes.ts +57 -0
- package/src/commands/scan.ts +278 -0
- package/src/commands/settings.ts +107 -0
- package/src/commands/status.ts +236 -0
- package/src/commands/upload.ts +524 -0
- package/src/config.ts +33 -0
- package/src/detectors.ts +1138 -0
- package/src/git.ts +86 -0
- package/src/githook.ts +269 -0
- package/src/hook.ts +237 -0
- package/src/index.ts +229 -0
- package/src/log.ts +113 -0
- package/src/mask-paths.ts +434 -0
- package/src/pairing.ts +190 -0
- package/src/parser.ts +581 -0
- package/src/paths.ts +191 -0
- package/src/plan.ts +56 -0
- package/src/queue.ts +145 -0
- package/src/redact.ts +335 -0
- package/src/spawn.ts +33 -0
- package/src/stage0.ts +121 -0
- package/src/state.ts +208 -0
- package/src/types.ts +165 -0
- package/src/update.ts +46 -0
|
@@ -0,0 +1,1026 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { EDIT_TOOLS, LOOKUP_TOOLS, commandSegments, onAbandonedBranch, shellReadPaths, withoutHeredocs, } from "./parser.js";
|
|
4
|
+
const FAILURE_LOOKBACK_RECORDS = 10;
|
|
5
|
+
const TEST_PATH = /(^|\/)(tests?|__tests__)\//i;
|
|
6
|
+
const TEST_EXTENSION = /\.(ts|tsx|js|py|rs|go|java)$/i;
|
|
7
|
+
const ASSERTION = /\b(assert|expect|should)\b/i;
|
|
8
|
+
const TEST_BLOCK = /(\bit\s*\(|\btest\s*\(|\bdef\s+test_|#\[test\])/gi;
|
|
9
|
+
const SKIP_MARKER = /(\bskip\b|\bxfail\b|\btodo\b|\.only\b|\bt\.Skip\b|#\[ignore\]|@Disabled|pytest\.mark\.skip)/i;
|
|
10
|
+
const FAILURE_OUTPUT = /(FAILED|failed|panicked|AssertionError)/;
|
|
11
|
+
const GIT_RESET = /\bgit\s+reset\s+(--hard|--merge)\b/;
|
|
12
|
+
const GIT_STASH = /\bgit\s+stash\b(?!\s+(pop|apply|list|show))/;
|
|
13
|
+
const GIT_CHECKOUT = /\bgit\s+checkout\s+(?:--\s+)?(?<paths>[^&|;]+)/;
|
|
14
|
+
const GIT_RESTORE = /\bgit\s+restore\s+(?<paths>[^&|;]+)/;
|
|
15
|
+
function normalize(content) {
|
|
16
|
+
return content
|
|
17
|
+
.replace(/\r\n/g, "\n")
|
|
18
|
+
.split("\n")
|
|
19
|
+
.map((line) => line.replace(/\s+$/, ""))
|
|
20
|
+
.join("\n")
|
|
21
|
+
.replace(/\n+$/, "");
|
|
22
|
+
}
|
|
23
|
+
function digest(content) {
|
|
24
|
+
return createHash("sha1").update(normalize(content)).digest("hex");
|
|
25
|
+
}
|
|
26
|
+
export function isTestFile(filePath) {
|
|
27
|
+
if (TEST_PATH.test(filePath))
|
|
28
|
+
return true;
|
|
29
|
+
const name = basename(filePath);
|
|
30
|
+
if (!TEST_EXTENSION.test(name))
|
|
31
|
+
return false;
|
|
32
|
+
const tokens = name
|
|
33
|
+
.replace(TEST_EXTENSION, "")
|
|
34
|
+
.split(/[^a-zA-Z0-9]+|(?=[A-Z])/)
|
|
35
|
+
.filter((token) => token.length > 0)
|
|
36
|
+
.map((token) => token.toLowerCase());
|
|
37
|
+
return tokens.includes("test") || tokens.includes("spec");
|
|
38
|
+
}
|
|
39
|
+
function countMatches(text, pattern) {
|
|
40
|
+
return (text.match(pattern) ?? []).length;
|
|
41
|
+
}
|
|
42
|
+
function assertionLines(text) {
|
|
43
|
+
return text.split("\n").filter((line) => ASSERTION.test(line)).length;
|
|
44
|
+
}
|
|
45
|
+
export function weakensTest(oldString, newString) {
|
|
46
|
+
if (assertionLines(newString) < assertionLines(oldString)) {
|
|
47
|
+
return "assertions removed from the test";
|
|
48
|
+
}
|
|
49
|
+
if (SKIP_MARKER.test(newString) && !SKIP_MARKER.test(oldString)) {
|
|
50
|
+
return "test marked as skipped or ignored";
|
|
51
|
+
}
|
|
52
|
+
if (countMatches(newString, TEST_BLOCK) < countMatches(oldString, TEST_BLOCK)) {
|
|
53
|
+
return "a test case was deleted";
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
function failedBefore(session, recordIndex) {
|
|
58
|
+
return session.toolUses.find((use) => {
|
|
59
|
+
if (use.name !== "Bash")
|
|
60
|
+
return false;
|
|
61
|
+
if (use.recordIndex >= recordIndex)
|
|
62
|
+
return false;
|
|
63
|
+
if (use.recordIndex < recordIndex - FAILURE_LOOKBACK_RECORDS)
|
|
64
|
+
return false;
|
|
65
|
+
const result = use.result;
|
|
66
|
+
if (!result)
|
|
67
|
+
return false;
|
|
68
|
+
return (result.isError ||
|
|
69
|
+
FAILURE_OUTPUT.test(result.stdout ?? "") ||
|
|
70
|
+
FAILURE_OUTPUT.test(result.stderr ?? "") ||
|
|
71
|
+
FAILURE_OUTPUT.test(result.text));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function detectTestModifiedToPass(session) {
|
|
75
|
+
const candidates = [];
|
|
76
|
+
for (const [filePath, edits] of session.fileEdits) {
|
|
77
|
+
if (!isTestFile(filePath))
|
|
78
|
+
continue;
|
|
79
|
+
for (const edit of edits) {
|
|
80
|
+
if (edit.oldString === undefined || edit.newString === undefined)
|
|
81
|
+
continue;
|
|
82
|
+
const reason = weakensTest(edit.oldString, edit.newString);
|
|
83
|
+
if (!reason)
|
|
84
|
+
continue;
|
|
85
|
+
const failure = failedBefore(session, edit.recordIndex);
|
|
86
|
+
candidates.push({
|
|
87
|
+
category: "test_modified_to_pass",
|
|
88
|
+
sessionId: session.sessionId,
|
|
89
|
+
uuid: edit.uuid,
|
|
90
|
+
toolUseId: edit.toolUseId,
|
|
91
|
+
filePath,
|
|
92
|
+
recordIndex: edit.recordIndex,
|
|
93
|
+
startedAt: failure?.timestamp ?? edit.timestamp,
|
|
94
|
+
endedAt: edit.timestamp,
|
|
95
|
+
weight: failure ? 0.9 : 0.6,
|
|
96
|
+
detail: failure
|
|
97
|
+
? `${reason}, shortly after a failing command`
|
|
98
|
+
: reason,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// One weakening of one test file is one decision, however many separate edits
|
|
103
|
+
// it took. Codex writes a file through many small patch hunks where Claude
|
|
104
|
+
// Code writes one replacement, which is what made the fan-out visible.
|
|
105
|
+
return dedupe(candidates);
|
|
106
|
+
}
|
|
107
|
+
function applyEdit(content, oldString, newString, all) {
|
|
108
|
+
if (oldString.length === 0 || !content.includes(oldString))
|
|
109
|
+
return undefined;
|
|
110
|
+
return all ? content.replaceAll(oldString, newString) : content.replace(oldString, newString);
|
|
111
|
+
}
|
|
112
|
+
function trackContent(session) {
|
|
113
|
+
const candidates = [];
|
|
114
|
+
const states = new Map();
|
|
115
|
+
const state = (filePath) => {
|
|
116
|
+
let existing = states.get(filePath);
|
|
117
|
+
if (!existing) {
|
|
118
|
+
existing = { seen: new Map(), edited: false };
|
|
119
|
+
states.set(filePath, existing);
|
|
120
|
+
}
|
|
121
|
+
return existing;
|
|
122
|
+
};
|
|
123
|
+
const record = (file, filePath, use, isEdit) => {
|
|
124
|
+
if (file.content === undefined)
|
|
125
|
+
return;
|
|
126
|
+
const key = digest(file.content);
|
|
127
|
+
const firstSeen = file.seen.get(key);
|
|
128
|
+
const unchanged = key === file.lastKey;
|
|
129
|
+
file.lastKey = key;
|
|
130
|
+
if (!unchanged && isEdit && firstSeen !== undefined && file.edited && firstSeen < use.recordIndex) {
|
|
131
|
+
candidates.push({
|
|
132
|
+
category: "abandoned_approach",
|
|
133
|
+
sessionId: session.sessionId,
|
|
134
|
+
uuid: use.uuid,
|
|
135
|
+
toolUseId: use.id,
|
|
136
|
+
filePath,
|
|
137
|
+
recordIndex: use.recordIndex,
|
|
138
|
+
startedAt: use.timestamp,
|
|
139
|
+
endedAt: use.timestamp,
|
|
140
|
+
weight: 0.8,
|
|
141
|
+
detail: "file returned to a state it already had earlier in the session",
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (firstSeen === undefined)
|
|
146
|
+
file.seen.set(key, use.recordIndex);
|
|
147
|
+
};
|
|
148
|
+
for (const use of session.toolUses) {
|
|
149
|
+
const filePath = typeof use.input.file_path === "string" ? use.input.file_path : undefined;
|
|
150
|
+
if (!filePath)
|
|
151
|
+
continue;
|
|
152
|
+
const file = state(filePath);
|
|
153
|
+
if (use.name === "Read" && typeof use.result?.fileContent === "string") {
|
|
154
|
+
file.content = use.result.fileContent;
|
|
155
|
+
record(file, filePath, use, false);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (use.name === "Write" && typeof use.input.content === "string") {
|
|
159
|
+
file.content = use.input.content;
|
|
160
|
+
file.edited = true;
|
|
161
|
+
record(file, filePath, use, true);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (use.name === "Edit" || use.name === "MultiEdit") {
|
|
165
|
+
file.edited = true;
|
|
166
|
+
const steps = Array.isArray(use.input.edits)
|
|
167
|
+
? use.input.edits
|
|
168
|
+
: [{ old_string: use.input.old_string, new_string: use.input.new_string }];
|
|
169
|
+
for (const step of steps) {
|
|
170
|
+
if (file.content === undefined)
|
|
171
|
+
break;
|
|
172
|
+
const from = step.old_string;
|
|
173
|
+
const to = step.new_string;
|
|
174
|
+
if (typeof from !== "string" || typeof to !== "string") {
|
|
175
|
+
file.content = undefined;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
file.content = applyEdit(file.content, from, to, use.input.replace_all === true);
|
|
179
|
+
}
|
|
180
|
+
record(file, filePath, use, true);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return candidates;
|
|
184
|
+
}
|
|
185
|
+
function detectRevertPairs(session) {
|
|
186
|
+
const candidates = [];
|
|
187
|
+
for (const [filePath, edits] of session.fileEdits) {
|
|
188
|
+
for (let later = 1; later < edits.length; later += 1) {
|
|
189
|
+
const current = edits[later];
|
|
190
|
+
if (current.oldString === undefined || current.newString === undefined)
|
|
191
|
+
continue;
|
|
192
|
+
const reverted = edits.slice(0, later).some((earlier) => earlier.oldString !== undefined &&
|
|
193
|
+
earlier.newString !== undefined &&
|
|
194
|
+
earlier.oldString === current.newString &&
|
|
195
|
+
earlier.newString === current.oldString);
|
|
196
|
+
if (!reverted)
|
|
197
|
+
continue;
|
|
198
|
+
candidates.push({
|
|
199
|
+
category: "abandoned_approach",
|
|
200
|
+
sessionId: session.sessionId,
|
|
201
|
+
uuid: current.uuid,
|
|
202
|
+
toolUseId: current.toolUseId,
|
|
203
|
+
filePath,
|
|
204
|
+
recordIndex: current.recordIndex,
|
|
205
|
+
startedAt: current.timestamp,
|
|
206
|
+
endedAt: current.timestamp,
|
|
207
|
+
weight: 0.7,
|
|
208
|
+
detail: "an earlier edit to this file was undone by a later one",
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return candidates;
|
|
213
|
+
}
|
|
214
|
+
function revertTargets(command) {
|
|
215
|
+
if (GIT_RESET.test(command) || GIT_STASH.test(command)) {
|
|
216
|
+
return { everything: true, paths: [] };
|
|
217
|
+
}
|
|
218
|
+
const match = GIT_CHECKOUT.exec(command) ?? GIT_RESTORE.exec(command);
|
|
219
|
+
const raw = match?.groups?.paths;
|
|
220
|
+
if (!raw)
|
|
221
|
+
return undefined;
|
|
222
|
+
const paths = raw
|
|
223
|
+
.trim()
|
|
224
|
+
.split(/\s+/)
|
|
225
|
+
.filter((part) => part.length > 0 && !part.startsWith("-"));
|
|
226
|
+
return paths.length > 0 ? { everything: false, paths } : undefined;
|
|
227
|
+
}
|
|
228
|
+
function matchesPath(filePath, target) {
|
|
229
|
+
const cleaned = target.replace(/^\.\//, "").replace(/["']/g, "");
|
|
230
|
+
if (cleaned === "." || cleaned === "*")
|
|
231
|
+
return true;
|
|
232
|
+
return filePath.endsWith(`/${cleaned}`) || basename(filePath) === basename(cleaned);
|
|
233
|
+
}
|
|
234
|
+
const REVERT_FILES_LISTED = 5;
|
|
235
|
+
function detectGitReverts(session) {
|
|
236
|
+
const candidates = [];
|
|
237
|
+
for (const use of session.toolUses) {
|
|
238
|
+
if (use.name !== "Bash")
|
|
239
|
+
continue;
|
|
240
|
+
const command = typeof use.input.command === "string" ? use.input.command : undefined;
|
|
241
|
+
if (!command)
|
|
242
|
+
continue;
|
|
243
|
+
const targets = revertTargets(command);
|
|
244
|
+
if (!targets)
|
|
245
|
+
continue;
|
|
246
|
+
const discarded = [];
|
|
247
|
+
let startedAt;
|
|
248
|
+
for (const [filePath, edits] of session.fileEdits) {
|
|
249
|
+
const earlier = edits.filter((edit) => edit.recordIndex < use.recordIndex);
|
|
250
|
+
if (earlier.length === 0)
|
|
251
|
+
continue;
|
|
252
|
+
if (!targets.everything && !targets.paths.some((path) => matchesPath(filePath, path))) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
discarded.push(filePath);
|
|
256
|
+
const first = earlier[0]?.timestamp;
|
|
257
|
+
if (first && (!startedAt || first < startedAt))
|
|
258
|
+
startedAt = first;
|
|
259
|
+
}
|
|
260
|
+
if (discarded.length === 0)
|
|
261
|
+
continue;
|
|
262
|
+
const listed = discarded.slice(0, REVERT_FILES_LISTED).map((path) => basename(path));
|
|
263
|
+
const rest = discarded.length - listed.length;
|
|
264
|
+
candidates.push({
|
|
265
|
+
category: "abandoned_approach",
|
|
266
|
+
sessionId: session.sessionId,
|
|
267
|
+
uuid: use.uuid,
|
|
268
|
+
toolUseId: use.id,
|
|
269
|
+
filePath: discarded.length === 1 ? discarded[0] : undefined,
|
|
270
|
+
recordIndex: use.recordIndex,
|
|
271
|
+
startedAt,
|
|
272
|
+
endedAt: use.timestamp,
|
|
273
|
+
weight: 0.75,
|
|
274
|
+
detail: discarded.length === 1
|
|
275
|
+
? "edits to this file were discarded by a git command"
|
|
276
|
+
: `edits to ${discarded.length} files were discarded by a git command: ` +
|
|
277
|
+
`${listed.join(", ")}${rest > 0 ? ` and ${rest} more` : ""}`,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return candidates;
|
|
281
|
+
}
|
|
282
|
+
function detectAbandonedBranches(session) {
|
|
283
|
+
const candidates = [];
|
|
284
|
+
if (session.mainPath.size === 0)
|
|
285
|
+
return candidates;
|
|
286
|
+
for (const [filePath, edits] of session.fileEdits) {
|
|
287
|
+
for (const edit of edits) {
|
|
288
|
+
if (!onAbandonedBranch(session, edit.uuid))
|
|
289
|
+
continue;
|
|
290
|
+
candidates.push({
|
|
291
|
+
category: "abandoned_approach",
|
|
292
|
+
sessionId: session.sessionId,
|
|
293
|
+
uuid: edit.uuid,
|
|
294
|
+
toolUseId: edit.toolUseId,
|
|
295
|
+
filePath,
|
|
296
|
+
recordIndex: edit.recordIndex,
|
|
297
|
+
startedAt: edit.timestamp,
|
|
298
|
+
endedAt: edit.timestamp,
|
|
299
|
+
weight: 0.4,
|
|
300
|
+
detail: "edit sits on a conversation branch the session did not continue",
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return candidates;
|
|
305
|
+
}
|
|
306
|
+
function keepBest(candidates, key) {
|
|
307
|
+
const best = new Map();
|
|
308
|
+
for (const candidate of candidates) {
|
|
309
|
+
const existing = best.get(key(candidate));
|
|
310
|
+
if (!existing || candidate.weight > existing.weight)
|
|
311
|
+
best.set(key(candidate), candidate);
|
|
312
|
+
}
|
|
313
|
+
return [...best.values()];
|
|
314
|
+
}
|
|
315
|
+
function dedupe(candidates) {
|
|
316
|
+
const perEvent = keepBest(candidates, (candidate) => `${candidate.category}|${candidate.filePath ?? ""}|${candidate.recordIndex}`);
|
|
317
|
+
const perFile = keepBest(perEvent, (candidate) => `${candidate.category}|${candidate.filePath ?? ""}|${candidate.detail}`);
|
|
318
|
+
return perFile.sort((a, b) => a.recordIndex - b.recordIndex);
|
|
319
|
+
}
|
|
320
|
+
export function detectAbandonedApproach(session) {
|
|
321
|
+
return dedupe([
|
|
322
|
+
...trackContent(session),
|
|
323
|
+
...detectRevertPairs(session),
|
|
324
|
+
...detectGitReverts(session),
|
|
325
|
+
...detectAbandonedBranches(session),
|
|
326
|
+
]);
|
|
327
|
+
}
|
|
328
|
+
const MANIFESTS = new Set([
|
|
329
|
+
"package.json",
|
|
330
|
+
"Cargo.toml",
|
|
331
|
+
"pyproject.toml",
|
|
332
|
+
"requirements.txt",
|
|
333
|
+
"go.mod",
|
|
334
|
+
"Gemfile",
|
|
335
|
+
"composer.json",
|
|
336
|
+
"pom.xml",
|
|
337
|
+
"build.gradle",
|
|
338
|
+
]);
|
|
339
|
+
const VERSION_VALUE = /^(\*|latest|workspace:|file:|github:|npm:|link:|[\^~>=<]*\d)/;
|
|
340
|
+
const SHELL_BREAK = /^(&&|\|\||;|\||>|>>|<)$/;
|
|
341
|
+
const REDIRECTION = /^\d*[<>]|^&/;
|
|
342
|
+
const NOT_A_DEPENDENCY = new Set([
|
|
343
|
+
"version",
|
|
344
|
+
"packageManager",
|
|
345
|
+
"node",
|
|
346
|
+
"npm",
|
|
347
|
+
"pnpm",
|
|
348
|
+
"yarn",
|
|
349
|
+
"bun",
|
|
350
|
+
"php",
|
|
351
|
+
"pip",
|
|
352
|
+
"pip3",
|
|
353
|
+
"poetry",
|
|
354
|
+
"uv",
|
|
355
|
+
"cargo",
|
|
356
|
+
"go",
|
|
357
|
+
"setuptools",
|
|
358
|
+
"wheel",
|
|
359
|
+
]);
|
|
360
|
+
const VALUE_FLAGS = new Set([
|
|
361
|
+
"--features",
|
|
362
|
+
"-F",
|
|
363
|
+
"--registry",
|
|
364
|
+
"--tag",
|
|
365
|
+
"--prefix",
|
|
366
|
+
"--index-url",
|
|
367
|
+
"--extra-index-url",
|
|
368
|
+
"-i",
|
|
369
|
+
"--python",
|
|
370
|
+
"--target",
|
|
371
|
+
"--rename",
|
|
372
|
+
]);
|
|
373
|
+
const INSTALL_COMMANDS = [
|
|
374
|
+
{ pattern: /\bnpm\s+(?:install|i|add)\b/, manager: "npm" },
|
|
375
|
+
{ pattern: /\bpnpm\s+(?:add|install)\b/, manager: "pnpm" },
|
|
376
|
+
{ pattern: /\byarn\s+add\b/, manager: "yarn" },
|
|
377
|
+
{ pattern: /\bcargo\s+add\b/, manager: "cargo" },
|
|
378
|
+
{ pattern: /\bpip3?\s+install\b/, manager: "pip" },
|
|
379
|
+
{ pattern: /\bpoetry\s+add\b/, manager: "poetry" },
|
|
380
|
+
{ pattern: /\bgo\s+get\b/, manager: "go" },
|
|
381
|
+
{ pattern: /\buv\s+(?:add|pip\s+install)\b/, manager: "uv" },
|
|
382
|
+
];
|
|
383
|
+
export function packageName(specifier) {
|
|
384
|
+
return /^(?:@[^/@\s]+\/)?[^<>=~!@[\s]+/.exec(specifier)?.[0] ?? specifier;
|
|
385
|
+
}
|
|
386
|
+
export function isManifest(filePath) {
|
|
387
|
+
return MANIFESTS.has(basename(filePath));
|
|
388
|
+
}
|
|
389
|
+
function jsonDependencies(text) {
|
|
390
|
+
const names = new Set();
|
|
391
|
+
for (const match of text.matchAll(/"([@A-Za-z0-9._/-]+)"\s*:\s*"([^"]*)"/g)) {
|
|
392
|
+
const [, name, value] = match;
|
|
393
|
+
if (!name || !value)
|
|
394
|
+
continue;
|
|
395
|
+
if (NOT_A_DEPENDENCY.has(name))
|
|
396
|
+
continue;
|
|
397
|
+
if (VERSION_VALUE.test(value))
|
|
398
|
+
names.add(name);
|
|
399
|
+
}
|
|
400
|
+
return names;
|
|
401
|
+
}
|
|
402
|
+
function otherDependencies(text) {
|
|
403
|
+
const names = new Set();
|
|
404
|
+
const patterns = [
|
|
405
|
+
/^\s*([A-Za-z0-9._-]+)\s*(?:==|>=|<=|~=|!=)/gm,
|
|
406
|
+
/^\s*gem\s+["']([^"']+)["']/gm,
|
|
407
|
+
/<artifactId>([^<]+)<\/artifactId>/g,
|
|
408
|
+
/^\s*(?:require\s+)?([a-z0-9.-]+\.[a-z]{2,}\/[^\s]+)\s+v[0-9]/gm,
|
|
409
|
+
/(?:implementation|api|testImplementation)\s+["']([^"':]+:[^"':]+)/g,
|
|
410
|
+
];
|
|
411
|
+
for (const pattern of patterns) {
|
|
412
|
+
for (const match of text.matchAll(pattern)) {
|
|
413
|
+
if (match[1])
|
|
414
|
+
names.add(match[1]);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return names;
|
|
418
|
+
}
|
|
419
|
+
/** A TOML table of dependencies: Cargo's `[dev-dependencies]`, `[target.'cfg(unix)'.dependencies]`, Poetry's `[tool.poetry.group.dev.dependencies]`. */
|
|
420
|
+
const TOML_DEPENDENCY_TABLE = /(?:^|\.)(?:dev-|build-)?dependencies$/;
|
|
421
|
+
/** Cargo's one-dependency table, `[dependencies.tokio]`. */
|
|
422
|
+
const TOML_DEPENDENCY_SUBTABLE = /(?:^|\.)(?:dev-|build-)?dependencies\.([A-Za-z0-9_-]+)$/;
|
|
423
|
+
/** Tables whose every key holds a list of requirement strings: PEP 621 extras, PEP 735 groups. */
|
|
424
|
+
const TOML_REQUIREMENT_TABLES = new Set(["project.optional-dependencies", "dependency-groups"]);
|
|
425
|
+
/** Keys a TOML manifest gives a version, none of them a package. */
|
|
426
|
+
const TOML_VERSION_KEYS = new Set(["python", "version", "edition", "rust-version", "requires-python"]);
|
|
427
|
+
const TOML_HEADER = /^\s*\[\[?\s*([^\]]+?)\s*\]\]?\s*(?:#.*)?$/;
|
|
428
|
+
const TOML_ASSIGNMENT = /^\s*["']?([A-Za-z0-9._-]+)["']?\s*=\s*(.*)$/gm;
|
|
429
|
+
/** `key = [ … ]`, across lines, a `]` inside a quoted requirement (`"requests[socks]"`) included. */
|
|
430
|
+
const TOML_ARRAY = /^\s*["']?([A-Za-z0-9_-]+)["']?\s*=\s*\[((?:"[^"]*"|'[^']*'|[^\]"'])*)/gm;
|
|
431
|
+
/** Package names out of the body of a TOML array of PEP 508 requirement strings. */
|
|
432
|
+
function requirementNames(array) {
|
|
433
|
+
const names = [];
|
|
434
|
+
for (const match of array.matchAll(/"([^"]*)"|'([^']*)'/g)) {
|
|
435
|
+
// `tomli; python_version < '3.11'`: the marker is not part of the name.
|
|
436
|
+
const name = packageName((match[1] ?? match[2] ?? "").split(";")[0].trim());
|
|
437
|
+
if (/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name) && !NOT_A_DEPENDENCY.has(name))
|
|
438
|
+
names.push(name);
|
|
439
|
+
}
|
|
440
|
+
return names;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Dependencies out of `pyproject.toml` or `Cargo.toml`, read table by table. A
|
|
444
|
+
* new manifest is mostly `name = "…"`, `description = "…"` and entry points,
|
|
445
|
+
* and a guess by line shape reported every one of them as a package — two
|
|
446
|
+
* false candidates were enough to lift a session over the triage floor.
|
|
447
|
+
*
|
|
448
|
+
* An edit is often a fragment with no header in view, and its leading lines
|
|
449
|
+
* sit in a table nobody can name. There a key counts only when its value reads
|
|
450
|
+
* as a version or a table (`serde = "1.0"`, `serde = { … }`), which leaves out
|
|
451
|
+
* metadata and entry points (`dwmt = "dwmt.cli:main"`); a `dependencies`
|
|
452
|
+
* array is PEP 621's either way.
|
|
453
|
+
*/
|
|
454
|
+
function tomlDependencies(text) {
|
|
455
|
+
const names = new Set();
|
|
456
|
+
const add = (name) => {
|
|
457
|
+
if (!TOML_VERSION_KEYS.has(name) && !NOT_A_DEPENDENCY.has(name))
|
|
458
|
+
names.add(name);
|
|
459
|
+
};
|
|
460
|
+
// The lines before the first header belong to the table nobody can name.
|
|
461
|
+
const tables = [{ name: undefined, lines: [] }];
|
|
462
|
+
for (const line of text.split("\n")) {
|
|
463
|
+
const header = TOML_HEADER.exec(line);
|
|
464
|
+
if (header)
|
|
465
|
+
tables.push({ name: header[1].replace(/["'\s]/g, ""), lines: [] });
|
|
466
|
+
else
|
|
467
|
+
tables.at(-1).lines.push(line);
|
|
468
|
+
}
|
|
469
|
+
for (const table of tables) {
|
|
470
|
+
const body = table.lines.join("\n");
|
|
471
|
+
const subtable = table.name === undefined ? undefined : TOML_DEPENDENCY_SUBTABLE.exec(table.name);
|
|
472
|
+
if (subtable) {
|
|
473
|
+
add(subtable[1]);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
const everyArray = table.name !== undefined && TOML_REQUIREMENT_TABLES.has(table.name);
|
|
477
|
+
if (everyArray || table.name === undefined || table.name === "project") {
|
|
478
|
+
for (const [, key, array] of body.matchAll(TOML_ARRAY)) {
|
|
479
|
+
if (everyArray || key === "dependencies")
|
|
480
|
+
requirementNames(array).forEach(add);
|
|
481
|
+
}
|
|
482
|
+
if (everyArray)
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
const dependencyTable = table.name !== undefined && TOML_DEPENDENCY_TABLE.test(table.name);
|
|
486
|
+
if (!dependencyTable && table.name !== undefined)
|
|
487
|
+
continue;
|
|
488
|
+
for (const [, key, value] of body.matchAll(TOML_ASSIGNMENT)) {
|
|
489
|
+
const unquoted = value.replace(/^["']/, "");
|
|
490
|
+
const versionShaped = value.startsWith("{") || (/^["']/.test(value) && VERSION_VALUE.test(unquoted));
|
|
491
|
+
// Cargo's dotted form, `serde.workspace = true`, names the package first.
|
|
492
|
+
if (dependencyTable || versionShaped)
|
|
493
|
+
add(key.split(".")[0]);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return names;
|
|
497
|
+
}
|
|
498
|
+
export function addedDependencies(filePath, oldString, newString) {
|
|
499
|
+
const name = basename(filePath);
|
|
500
|
+
const extract = name === "package.json" || name === "composer.json"
|
|
501
|
+
? jsonDependencies
|
|
502
|
+
: name.endsWith(".toml")
|
|
503
|
+
? tomlDependencies
|
|
504
|
+
: (text) => new Set([...jsonDependencies(text), ...otherDependencies(text)]);
|
|
505
|
+
const before = extract(oldString);
|
|
506
|
+
return [...extract(newString)].filter((name) => !before.has(name)).sort();
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* What a package can be called anywhere ISY looks — npm, pip, go, cargo, gem —
|
|
510
|
+
* version specifier included: `openai>=1.0`, `left-pad@^1.0.0`.
|
|
511
|
+
*/
|
|
512
|
+
const PACKAGE_NAME = /^[@A-Za-z0-9][A-Za-z0-9@._/+~^<>=!*-]*$/;
|
|
513
|
+
function packagesInSegment(segment, afterIndex) {
|
|
514
|
+
const packages = [];
|
|
515
|
+
let skipNext = false;
|
|
516
|
+
for (const token of segment.slice(afterIndex).trim().split(/\s+/)) {
|
|
517
|
+
if (token.length === 0)
|
|
518
|
+
continue;
|
|
519
|
+
if (SHELL_BREAK.test(token) || REDIRECTION.test(token))
|
|
520
|
+
break;
|
|
521
|
+
if (skipNext) {
|
|
522
|
+
skipNext = false;
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
if (token === "-r" || token === "--requirement" || token === "-e" || token === "--editable") {
|
|
526
|
+
return undefined;
|
|
527
|
+
}
|
|
528
|
+
if (token.startsWith("-")) {
|
|
529
|
+
if (VALUE_FLAGS.has(token))
|
|
530
|
+
skipNext = true;
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
const cleaned = token.replace(/["']/g, "");
|
|
534
|
+
const trimmed = cleaned.replace(/[.,;:]+$/, "");
|
|
535
|
+
// A registry name, not whatever else stood in that position: a line
|
|
536
|
+
// continuation, a shell expansion whose value only the shell knows, a
|
|
537
|
+
// stray brace from prose the command happened to carry.
|
|
538
|
+
if (PACKAGE_NAME.test(trimmed) && !NOT_A_DEPENDENCY.has(packageName(trimmed))) {
|
|
539
|
+
packages.push(trimmed);
|
|
540
|
+
}
|
|
541
|
+
if (trimmed !== cleaned)
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
return packages.length > 0 ? packages : undefined;
|
|
545
|
+
}
|
|
546
|
+
export function installedPackages(command) {
|
|
547
|
+
for (const segment of commandSegments(withoutHeredocs(command))) {
|
|
548
|
+
for (const { pattern, manager } of INSTALL_COMMANDS) {
|
|
549
|
+
const match = pattern.exec(segment);
|
|
550
|
+
if (!match)
|
|
551
|
+
continue;
|
|
552
|
+
const packages = packagesInSegment(segment, match.index + match[0].length);
|
|
553
|
+
if (packages)
|
|
554
|
+
return { manager, packages };
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
return undefined;
|
|
558
|
+
}
|
|
559
|
+
export function detectExternalDependency(session) {
|
|
560
|
+
const candidates = [];
|
|
561
|
+
const reported = new Set();
|
|
562
|
+
for (const [filePath, edits] of session.fileEdits) {
|
|
563
|
+
if (!isManifest(filePath))
|
|
564
|
+
continue;
|
|
565
|
+
for (const edit of edits) {
|
|
566
|
+
const added = addedDependencies(filePath, edit.oldString ?? "", edit.newString ?? edit.content ?? "");
|
|
567
|
+
if (added.length === 0)
|
|
568
|
+
continue;
|
|
569
|
+
for (const name of added)
|
|
570
|
+
reported.add(packageName(name));
|
|
571
|
+
candidates.push({
|
|
572
|
+
category: "external_dependency",
|
|
573
|
+
sessionId: session.sessionId,
|
|
574
|
+
uuid: edit.uuid,
|
|
575
|
+
toolUseId: edit.toolUseId,
|
|
576
|
+
filePath,
|
|
577
|
+
recordIndex: edit.recordIndex,
|
|
578
|
+
startedAt: edit.timestamp,
|
|
579
|
+
endedAt: edit.timestamp,
|
|
580
|
+
weight: 0.7,
|
|
581
|
+
detail: `added to ${basename(filePath)}: ${added.join(", ")}`,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
for (const use of session.toolUses) {
|
|
586
|
+
if (use.name !== "Bash")
|
|
587
|
+
continue;
|
|
588
|
+
const command = typeof use.input.command === "string" ? use.input.command : undefined;
|
|
589
|
+
if (!command)
|
|
590
|
+
continue;
|
|
591
|
+
const installed = installedPackages(command);
|
|
592
|
+
if (!installed)
|
|
593
|
+
continue;
|
|
594
|
+
if (installed.packages.every((name) => reported.has(packageName(name))))
|
|
595
|
+
continue;
|
|
596
|
+
for (const name of installed.packages)
|
|
597
|
+
reported.add(packageName(name));
|
|
598
|
+
candidates.push({
|
|
599
|
+
category: "external_dependency",
|
|
600
|
+
sessionId: session.sessionId,
|
|
601
|
+
uuid: use.uuid,
|
|
602
|
+
toolUseId: use.id,
|
|
603
|
+
recordIndex: use.recordIndex,
|
|
604
|
+
startedAt: use.timestamp,
|
|
605
|
+
endedAt: use.timestamp,
|
|
606
|
+
weight: 0.7,
|
|
607
|
+
detail: `installed with ${installed.manager}: ${installed.packages.join(", ")}`,
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
return dedupe(candidates);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Whether two paths name the same file. Reads are recorded as the agent typed
|
|
614
|
+
* them — `src/api.ts` from a shell, `/repo/src/api.ts` from the Read tool — so
|
|
615
|
+
* a relative path matches any absolute one ending in it, and a directory
|
|
616
|
+
* matches everything under it.
|
|
617
|
+
*/
|
|
618
|
+
function samePath(known, filePath) {
|
|
619
|
+
if (known === filePath)
|
|
620
|
+
return true;
|
|
621
|
+
if (filePath.startsWith(known.endsWith("/") ? known : `${known}/`))
|
|
622
|
+
return true;
|
|
623
|
+
return !known.startsWith("/") && filePath.endsWith(`/${known}`);
|
|
624
|
+
}
|
|
625
|
+
function wasLookedUp(session, filePath) {
|
|
626
|
+
for (const known of session.filesRead) {
|
|
627
|
+
if (samePath(known, filePath))
|
|
628
|
+
return true;
|
|
629
|
+
}
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
export function detectUnverifiedAssumption(session) {
|
|
633
|
+
const candidates = [];
|
|
634
|
+
for (const [filePath, edits] of session.fileEdits) {
|
|
635
|
+
const first = edits[0];
|
|
636
|
+
if (!first)
|
|
637
|
+
continue;
|
|
638
|
+
if (first.tool !== "Edit" && first.tool !== "MultiEdit")
|
|
639
|
+
continue;
|
|
640
|
+
if (wasLookedUp(session, filePath))
|
|
641
|
+
continue;
|
|
642
|
+
candidates.push({
|
|
643
|
+
category: "unverified_assumption",
|
|
644
|
+
sessionId: session.sessionId,
|
|
645
|
+
uuid: first.uuid,
|
|
646
|
+
toolUseId: first.toolUseId,
|
|
647
|
+
filePath,
|
|
648
|
+
recordIndex: first.recordIndex,
|
|
649
|
+
startedAt: first.timestamp,
|
|
650
|
+
endedAt: edits[edits.length - 1]?.timestamp,
|
|
651
|
+
weight: 0.35,
|
|
652
|
+
detail: "file was edited without ever being read or searched in this session",
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
return candidates;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Commands that check the work: test runners, builds, type checkers, linters.
|
|
659
|
+
* The list is deliberately about *running* things — a `git status` proves the
|
|
660
|
+
* agent looked, not that anything still compiles.
|
|
661
|
+
*/
|
|
662
|
+
const VERIFY_COMMAND = /\b(?:(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:test|build|lint|typecheck|check|tsc)|node\s+--test|(?:npx\s+)?(?:jest|vitest|mocha|tsc|eslint|biome|playwright|cypress|ava|tap)|pytest|python[0-9.]*\s+-m\s+(?:pytest|unittest)|tox|ruff|mypy|pyright|cargo\s+(?:test|build|check|clippy)|go\s+(?:test|build|vet)|(?:mvn|gradle|\.\/gradlew)\s+\S*(?:test|build|check)|make\s+(?:test|check|build|lint)|dotnet\s+(?:test|build)|(?:bundle\s+exec\s+)?rspec|phpunit|swift\s+(?:test|build)|ctest|cmake\s+--build)\b/;
|
|
663
|
+
const UNVERIFIED_FILES_LISTED = 3;
|
|
664
|
+
const CODE_EXTENSION = /\.(ts|tsx|js|jsx|mjs|cjs|py|rs|go|java|rb|php|c|cc|cpp|h|hpp|cs|kt|swift|scala|sh|sql|vue|svelte)$/i;
|
|
665
|
+
/** A command that ran the project's own checks, not one that merely looked around. */
|
|
666
|
+
function verifies(use) {
|
|
667
|
+
if (use.name !== "Bash")
|
|
668
|
+
return false;
|
|
669
|
+
const command = typeof use.input.command === "string" ? use.input.command : "";
|
|
670
|
+
return VERIFY_COMMAND.test(command);
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Code that was changed and never run afterwards. Two shapes, and the second is
|
|
674
|
+
* the sharper one: a session that never verifies anything is a session working
|
|
675
|
+
* in the dark, but a session that verified, then edited again, and stopped, is
|
|
676
|
+
* one whose green result describes code that no longer exists.
|
|
677
|
+
*
|
|
678
|
+
* Only the last edit to a file matters — earlier ones were superseded by it.
|
|
679
|
+
*/
|
|
680
|
+
export function detectUnverifiedFix(session) {
|
|
681
|
+
const checks = session.toolUses.filter(verifies);
|
|
682
|
+
const lastCheck = checks[checks.length - 1]?.recordIndex ?? -1;
|
|
683
|
+
const stale = [];
|
|
684
|
+
for (const [filePath, edits] of session.fileEdits) {
|
|
685
|
+
if (!CODE_EXTENSION.test(filePath) || isTestFile(filePath))
|
|
686
|
+
continue;
|
|
687
|
+
const last = edits[edits.length - 1];
|
|
688
|
+
if (last && last.recordIndex > lastCheck)
|
|
689
|
+
stale.push(last);
|
|
690
|
+
}
|
|
691
|
+
if (stale.length === 0)
|
|
692
|
+
return [];
|
|
693
|
+
// One note per session, not one per file: "nothing was run after this" is a
|
|
694
|
+
// property of how the session ended, and a reviewer reads it once. Anchored
|
|
695
|
+
// at the last unchecked edit, which is where the session stopped looking.
|
|
696
|
+
stale.sort((a, b) => a.recordIndex - b.recordIndex);
|
|
697
|
+
const last = stale[stale.length - 1];
|
|
698
|
+
// By name, deduplicated: two paths ending in the same file read as a mistake.
|
|
699
|
+
const names = [...new Set(stale.map((edit) => basename(edit.filePath)))];
|
|
700
|
+
const listed = names.slice(0, UNVERIFIED_FILES_LISTED);
|
|
701
|
+
const rest = names.length - listed.length;
|
|
702
|
+
const files = `${listed.join(", ")}${rest > 0 ? ` and ${rest} more` : ""}`;
|
|
703
|
+
return [
|
|
704
|
+
{
|
|
705
|
+
category: "unverified_fix",
|
|
706
|
+
sessionId: session.sessionId,
|
|
707
|
+
uuid: last.uuid,
|
|
708
|
+
toolUseId: last.toolUseId,
|
|
709
|
+
filePath: stale.length === 1 ? last.filePath : undefined,
|
|
710
|
+
recordIndex: last.recordIndex,
|
|
711
|
+
startedAt: stale[0]?.timestamp,
|
|
712
|
+
endedAt: last.timestamp,
|
|
713
|
+
weight: checks.length === 0 ? 0.5 : 0.6,
|
|
714
|
+
detail: checks.length === 0
|
|
715
|
+
? `no test, build or lint command ran in the whole session: ${files}`
|
|
716
|
+
: `edited after the last test or build run, never checked again: ${files}`,
|
|
717
|
+
},
|
|
718
|
+
];
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Silencing rather than fixing. `test_modified_to_pass` covers the test-file
|
|
722
|
+
* half of this; here it is production code, where a suppression comment has no
|
|
723
|
+
* failing test to explain it and simply removes the warning from view.
|
|
724
|
+
*/
|
|
725
|
+
const SUPPRESSORS = [
|
|
726
|
+
{ pattern: /@ts-(?:ignore|nocheck|expect-error)\b/g, detail: "a TypeScript error was suppressed" },
|
|
727
|
+
{ pattern: /eslint-disable(?:-next-line|-line)?\b/g, detail: "an ESLint rule was disabled" },
|
|
728
|
+
{ pattern: /#\s*type:\s*ignore\b/g, detail: "a type error was suppressed" },
|
|
729
|
+
{ pattern: /#\s*noqa\b/g, detail: "a lint error was suppressed" },
|
|
730
|
+
{ pattern: /#\s*pylint:\s*disable\b/g, detail: "a pylint rule was disabled" },
|
|
731
|
+
{ pattern: /@SuppressWarnings\b/g, detail: "a compiler warning was suppressed" },
|
|
732
|
+
{ pattern: /#\[allow\(/g, detail: "a Rust lint was allowed" },
|
|
733
|
+
{ pattern: /except[^\n:]*:\s*(?:#[^\n]*)?\n\s*pass\b/g, detail: "an exception is caught and dropped" },
|
|
734
|
+
{ pattern: /catch\s*(?:\([^)]*\))?\s*\{\s*\}/g, detail: "an exception is caught and dropped" },
|
|
735
|
+
{ pattern: /rescue\s*(?:=>\s*\w+\s*)?\n\s*end\b/g, detail: "an exception is caught and dropped" },
|
|
736
|
+
];
|
|
737
|
+
/** `|| true` on a check, and the flags that walk past a failing hook. */
|
|
738
|
+
const SUPPRESSING_FLAG = /--no-verify\b|--ignore-errors\b|--exit-zero\b/;
|
|
739
|
+
function suppressionAdded(oldString, newString) {
|
|
740
|
+
for (const { pattern, detail } of SUPPRESSORS) {
|
|
741
|
+
// Counted, not tested: an edit that keeps one suppression and adds a second
|
|
742
|
+
// is still an addition, and the file may have arrived with one already.
|
|
743
|
+
if (countMatches(newString, pattern) > countMatches(oldString, pattern))
|
|
744
|
+
return detail;
|
|
745
|
+
}
|
|
746
|
+
return undefined;
|
|
747
|
+
}
|
|
748
|
+
export function detectErrorSuppressed(session) {
|
|
749
|
+
const candidates = [];
|
|
750
|
+
for (const [filePath, edits] of session.fileEdits) {
|
|
751
|
+
// A weakened test is the same act with its own category and its own weight.
|
|
752
|
+
if (isTestFile(filePath))
|
|
753
|
+
continue;
|
|
754
|
+
for (const edit of edits) {
|
|
755
|
+
const before = edit.oldString ?? "";
|
|
756
|
+
const after = edit.newString ?? edit.content ?? "";
|
|
757
|
+
if (after.length === 0)
|
|
758
|
+
continue;
|
|
759
|
+
const reason = suppressionAdded(before, after);
|
|
760
|
+
if (!reason)
|
|
761
|
+
continue;
|
|
762
|
+
const failure = failedBefore(session, edit.recordIndex);
|
|
763
|
+
candidates.push({
|
|
764
|
+
category: "error_suppressed",
|
|
765
|
+
sessionId: session.sessionId,
|
|
766
|
+
uuid: edit.uuid,
|
|
767
|
+
toolUseId: edit.toolUseId,
|
|
768
|
+
filePath,
|
|
769
|
+
recordIndex: edit.recordIndex,
|
|
770
|
+
startedAt: failure?.timestamp ?? edit.timestamp,
|
|
771
|
+
endedAt: edit.timestamp,
|
|
772
|
+
weight: failure ? 0.7 : 0.45,
|
|
773
|
+
detail: failure ? `${reason}, shortly after a failing command` : reason,
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
for (const use of session.toolUses) {
|
|
778
|
+
if (use.name !== "Bash")
|
|
779
|
+
continue;
|
|
780
|
+
const command = typeof use.input.command === "string" ? use.input.command : undefined;
|
|
781
|
+
if (!command)
|
|
782
|
+
continue;
|
|
783
|
+
// `|| true` only counts on a command that was checking something: on a
|
|
784
|
+
// cleanup line it is ordinary defensive shell.
|
|
785
|
+
const ignoredFailure = /\|\|\s*true\b/.test(command) && VERIFY_COMMAND.test(command);
|
|
786
|
+
if (!ignoredFailure && !SUPPRESSING_FLAG.test(command))
|
|
787
|
+
continue;
|
|
788
|
+
candidates.push({
|
|
789
|
+
category: "error_suppressed",
|
|
790
|
+
sessionId: session.sessionId,
|
|
791
|
+
uuid: use.uuid,
|
|
792
|
+
toolUseId: use.id,
|
|
793
|
+
recordIndex: use.recordIndex,
|
|
794
|
+
startedAt: use.timestamp,
|
|
795
|
+
endedAt: use.timestamp,
|
|
796
|
+
weight: 0.5,
|
|
797
|
+
detail: ignoredFailure
|
|
798
|
+
? "a check was run with its failure discarded by `|| true`"
|
|
799
|
+
: "a command was run with its safety check switched off",
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
return dedupe(candidates);
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Commands that can destroy work the diff will never account for: an uncommitted
|
|
806
|
+
* file, a colleague's commit, a table. The diff shows what exists afterwards, so
|
|
807
|
+
* this is the one category a reviewer cannot reach any other way.
|
|
808
|
+
*/
|
|
809
|
+
const DESTRUCTIVE = [
|
|
810
|
+
{ pattern: /\bDROP\s+(TABLE|DATABASE|SCHEMA)\b/i, weight: 0.8, detail: "a database object was dropped" },
|
|
811
|
+
{ pattern: /\bTRUNCATE\s+(TABLE\s+)?\w/i, weight: 0.8, detail: "a table was truncated" },
|
|
812
|
+
{ pattern: /\bDELETE\s+FROM\s+\w+\s*["']?\s*(?:;|$)/i, weight: 0.8, detail: "rows were deleted with no WHERE clause" },
|
|
813
|
+
{ pattern: /\bgit\s+push\s+[^\n;|&]*(?:--force\b(?!-with-lease)|(?:^|\s)-f\b)/, weight: 0.7, detail: "a branch was force-pushed" },
|
|
814
|
+
{ pattern: /\bgit\s+clean\s+-[a-z]*[fd]/, weight: 0.6, detail: "untracked files were deleted by git clean" },
|
|
815
|
+
{ pattern: /\bgit\s+branch\s+-D\b/, weight: 0.5, detail: "a branch was deleted unmerged" },
|
|
816
|
+
{ pattern: /\bgit\s+reset\s+--hard\b/, weight: 0.6, detail: "the working tree was reset, discarding uncommitted work" },
|
|
817
|
+
{ pattern: /\bDROP\s+INDEX\b/i, weight: 0.5, detail: "an index was dropped" },
|
|
818
|
+
];
|
|
819
|
+
/** Paths a project regenerates from source, where deletion costs a rebuild. */
|
|
820
|
+
const THROWAWAY = /(^|\/)(node_modules|dist|build|out|target|coverage|\.next|\.nuxt|\.turbo|\.cache|__pycache__|\.pytest_cache|\.venv|venv|vendor|tmp|temp)(\/|$)|^\/tmp\/|\.(log|lock|pyc|o|class)$/i;
|
|
821
|
+
/**
|
|
822
|
+
* Commands that only look at text. A `grep "DROP TABLE"` or a heredoc quoting a
|
|
823
|
+
* migration is not a migration, and the corpus is full of both.
|
|
824
|
+
*/
|
|
825
|
+
const READER = /^\s*(?:sudo\s+)?(?:cat|head|tail|less|more|bat|nl|wc|sed|awk|rg|grep|egrep|fgrep|jq|yq|xxd|od|file|stat|diff|echo|printf|git\s+(?:show|diff|log|grep))\b/;
|
|
826
|
+
/**
|
|
827
|
+
* A path this repository owns: `~/android` is the user's machine, not the work.
|
|
828
|
+
*
|
|
829
|
+
* Stage 0 only ever sees a redacted transcript — `analyze.ts` redacts before it
|
|
830
|
+
* parses, the server masks on the way out of storage — and redaction is what
|
|
831
|
+
* makes a path inside the working directory relative. So the question is
|
|
832
|
+
* the shape of the path, and there is no working directory left to compare
|
|
833
|
+
* against: `.` is all that survives of it.
|
|
834
|
+
*/
|
|
835
|
+
function insideProject(path) {
|
|
836
|
+
return !path.startsWith("~") && !path.startsWith("/");
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* `rm -rf <path>` in one command segment, minus the paths that grow back on
|
|
840
|
+
* their own. Anchored at the start of a segment on purpose: `rm -rf` inside a
|
|
841
|
+
* grep pattern or a quoted example is text, not a deletion.
|
|
842
|
+
*/
|
|
843
|
+
function removedPaths(session, segment) {
|
|
844
|
+
const match = /^\s*(?:sudo\s+)?rm\s+((?:-[a-zA-Z]+\s+)*)(.*)$/.exec(segment);
|
|
845
|
+
if (!match)
|
|
846
|
+
return [];
|
|
847
|
+
const rest = `${match[1] ?? ""}${match[2] ?? ""}`;
|
|
848
|
+
if (!/(^|\s)-[a-zA-Z]*[rR]/.test(rest))
|
|
849
|
+
return [];
|
|
850
|
+
const paths = [];
|
|
851
|
+
for (const raw of (match[2] ?? "").trim().split(/\s+/)) {
|
|
852
|
+
const path = raw.replace(/["']/g, "");
|
|
853
|
+
if (path.length === 0 || path.startsWith("-") || path.includes("$"))
|
|
854
|
+
continue;
|
|
855
|
+
if (THROWAWAY.test(path) || !insideProject(path))
|
|
856
|
+
continue;
|
|
857
|
+
paths.push(path);
|
|
858
|
+
}
|
|
859
|
+
return paths;
|
|
860
|
+
}
|
|
861
|
+
const DESTRUCTIVE_FILES_LISTED = 3;
|
|
862
|
+
/** As many files as a reviewer reads off one line before it stops being one. */
|
|
863
|
+
const STALE_FILES_LISTED = 3;
|
|
864
|
+
export function detectDestructiveCommand(session) {
|
|
865
|
+
const candidates = [];
|
|
866
|
+
for (const use of session.toolUses) {
|
|
867
|
+
if (use.name !== "Bash")
|
|
868
|
+
continue;
|
|
869
|
+
const command = typeof use.input.command === "string" ? use.input.command : undefined;
|
|
870
|
+
if (!command)
|
|
871
|
+
continue;
|
|
872
|
+
const found = [];
|
|
873
|
+
for (const segment of commandSegments(withoutHeredocs(command))) {
|
|
874
|
+
if (READER.test(segment))
|
|
875
|
+
continue;
|
|
876
|
+
const removed = removedPaths(session, segment);
|
|
877
|
+
if (removed.length > 0) {
|
|
878
|
+
const listed = removed.slice(0, DESTRUCTIVE_FILES_LISTED);
|
|
879
|
+
const rest = removed.length - listed.length;
|
|
880
|
+
found.push({
|
|
881
|
+
weight: 0.6,
|
|
882
|
+
detail: `deleted recursively: ${listed.join(", ")}${rest > 0 ? ` and ${rest} more` : ""}`,
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
for (const { pattern, weight, detail } of DESTRUCTIVE) {
|
|
886
|
+
if (pattern.test(segment))
|
|
887
|
+
found.push({ weight, detail });
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
if (found.length === 0)
|
|
891
|
+
continue;
|
|
892
|
+
// One command is one decision, however many of these patterns it matched.
|
|
893
|
+
const worst = found.reduce((a, b) => (b.weight > a.weight ? b : a));
|
|
894
|
+
const details = [...new Set(found.map(({ detail }) => detail))];
|
|
895
|
+
candidates.push({
|
|
896
|
+
category: "destructive_command",
|
|
897
|
+
sessionId: session.sessionId,
|
|
898
|
+
uuid: use.uuid,
|
|
899
|
+
toolUseId: use.id,
|
|
900
|
+
recordIndex: use.recordIndex,
|
|
901
|
+
startedAt: use.timestamp,
|
|
902
|
+
endedAt: use.timestamp,
|
|
903
|
+
weight: worst.weight,
|
|
904
|
+
detail: details.join("; "),
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
return dedupe(candidates);
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* A break long enough that the repository could have moved under the agent
|
|
911
|
+
* while it stood still: the developer went away, pulled, switched branch, or
|
|
912
|
+
* edited a file by hand. Anything shorter is the developer reading a diff
|
|
913
|
+
* before approving the next call.
|
|
914
|
+
*
|
|
915
|
+
* ponytail: one flat threshold for every CLI. If a corpus run shows approval
|
|
916
|
+
* pauses this long, raise the number rather than adding per-agent rules.
|
|
917
|
+
*/
|
|
918
|
+
const PAUSE_MS = 30 * 60_000;
|
|
919
|
+
/** The break as the note says it: `47m`, `2h05`. */
|
|
920
|
+
function breakLength(ms) {
|
|
921
|
+
const total = Math.round(ms / 60_000);
|
|
922
|
+
if (total < 60)
|
|
923
|
+
return `${total}m`;
|
|
924
|
+
return `${Math.floor(total / 60)}h${String(total % 60).padStart(2, "0")}`;
|
|
925
|
+
}
|
|
926
|
+
/** Every path this call looked at, however the agent reached it. */
|
|
927
|
+
function pathsSeen(use) {
|
|
928
|
+
if (use.name === "Bash") {
|
|
929
|
+
const command = typeof use.input.command === "string" ? use.input.command : "";
|
|
930
|
+
return shellReadPaths(command);
|
|
931
|
+
}
|
|
932
|
+
if (!LOOKUP_TOOLS.has(use.name) && !EDIT_TOOLS.has(use.name))
|
|
933
|
+
return [];
|
|
934
|
+
const paths = [];
|
|
935
|
+
for (const key of ["file_path", "notebook_path", "path"]) {
|
|
936
|
+
const value = use.input[key];
|
|
937
|
+
if (typeof value === "string" && value.length > 0)
|
|
938
|
+
paths.push(value);
|
|
939
|
+
}
|
|
940
|
+
return paths;
|
|
941
|
+
}
|
|
942
|
+
/** The last call that looked at this file, or nothing if none did. */
|
|
943
|
+
function lastLook(seen, filePath) {
|
|
944
|
+
let latest;
|
|
945
|
+
for (const [known, index] of seen) {
|
|
946
|
+
if (!samePath(known, filePath))
|
|
947
|
+
continue;
|
|
948
|
+
if (latest === undefined || index > latest)
|
|
949
|
+
latest = index;
|
|
950
|
+
}
|
|
951
|
+
return latest;
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Work resumed on what the agent knew before the break. The transcript reads as
|
|
955
|
+
* one continuous session, and the diff shows none of this: an edit written at
|
|
956
|
+
* 09:14 on what was read at 17:40 the day before is indistinguishable in the
|
|
957
|
+
* final code from one written a second after the read.
|
|
958
|
+
*
|
|
959
|
+
* What makes it a signal is the gap plus the missing re-read. An agent that
|
|
960
|
+
* comes back and reads the file again has checked; one that edits straight
|
|
961
|
+
* away is trusting a picture of the file that nothing has confirmed since.
|
|
962
|
+
*
|
|
963
|
+
* One note per session, not per break and not per file. A developer who steps
|
|
964
|
+
* away five times has one habit, not five findings, and on the real corpus this
|
|
965
|
+
* rule alone produced more candidates than every other rule together — nine in
|
|
966
|
+
* one session, 26 of 66. Weight is a flat sum against `ISY_DEEP_WEIGHT_FLOOR`,
|
|
967
|
+
* so a session bought a deep run on breaks alone. The longest break is the one
|
|
968
|
+
* printed: it is where the picture had the most time to move.
|
|
969
|
+
*/
|
|
970
|
+
export function detectStaleContext(session) {
|
|
971
|
+
const breaks = [];
|
|
972
|
+
const seen = new Map();
|
|
973
|
+
let previous;
|
|
974
|
+
let pauseIndex;
|
|
975
|
+
let pauseMs = 0;
|
|
976
|
+
let pausedAt;
|
|
977
|
+
let reported = false;
|
|
978
|
+
for (const use of session.toolUses) {
|
|
979
|
+
if (use.timestamp && previous?.timestamp) {
|
|
980
|
+
const gap = Date.parse(use.timestamp) - Date.parse(previous.timestamp);
|
|
981
|
+
if (Number.isFinite(gap) && gap >= PAUSE_MS) {
|
|
982
|
+
pauseIndex = use.recordIndex;
|
|
983
|
+
pauseMs = gap;
|
|
984
|
+
pausedAt = previous.timestamp;
|
|
985
|
+
reported = false;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
previous = use;
|
|
989
|
+
if (!reported && pauseIndex !== undefined && EDIT_TOOLS.has(use.name)) {
|
|
990
|
+
const filePath = typeof use.input.file_path === "string" ? use.input.file_path : undefined;
|
|
991
|
+
const looked = filePath === undefined ? undefined : lastLook(seen, filePath);
|
|
992
|
+
// A file nobody ever looked at is `unverified_assumption`, and saying it
|
|
993
|
+
// twice under two headings is one edit and two notes to reconcile.
|
|
994
|
+
if (filePath && looked !== undefined && looked < pauseIndex) {
|
|
995
|
+
reported = true;
|
|
996
|
+
breaks.push({ use, filePath, pauseMs, pausedAt });
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
for (const path of pathsSeen(use))
|
|
1000
|
+
seen.set(path, use.recordIndex);
|
|
1001
|
+
}
|
|
1002
|
+
const worst = breaks.reduce((a, b) => (a === undefined || b.pauseMs > a.pauseMs ? b : a), undefined);
|
|
1003
|
+
if (!worst)
|
|
1004
|
+
return [];
|
|
1005
|
+
const files = [...new Set(breaks.map(({ filePath }) => basename(filePath)))];
|
|
1006
|
+
const listed = files.slice(0, STALE_FILES_LISTED);
|
|
1007
|
+
const rest = files.length - listed.length;
|
|
1008
|
+
return [
|
|
1009
|
+
{
|
|
1010
|
+
category: "stale_context",
|
|
1011
|
+
sessionId: session.sessionId,
|
|
1012
|
+
uuid: worst.use.uuid,
|
|
1013
|
+
toolUseId: worst.use.id,
|
|
1014
|
+
filePath: worst.filePath,
|
|
1015
|
+
recordIndex: worst.use.recordIndex,
|
|
1016
|
+
startedAt: worst.pausedAt,
|
|
1017
|
+
endedAt: worst.use.timestamp,
|
|
1018
|
+
weight: 0.4,
|
|
1019
|
+
detail: `work resumed after a ${breakLength(worst.pauseMs)} break and edited ` +
|
|
1020
|
+
`${listed.join(", ")}${rest > 0 ? ` and ${rest} more` : ""} ` +
|
|
1021
|
+
`without reading ${files.length > 1 ? "them" : "it"} again` +
|
|
1022
|
+
(breaks.length > 1 ? `, and ${breaks.length} breaks in this session read that way` : ""),
|
|
1023
|
+
},
|
|
1024
|
+
];
|
|
1025
|
+
}
|
|
1026
|
+
//# sourceMappingURL=detectors.js.map
|