kryptheon 0.1.47 → 0.1.49

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/kryptheon-look.js CHANGED
@@ -1,259 +1,306 @@
1
- // One look at a project: what changed since the last look, which checks that
2
- // calls for, run the ones that can run, and what is new, fixed or merely
3
- // deleted. Shared by `npx kryptheon verify` and the dashboard's own watch, so
4
- // the command and the page can never tell two different stories.
5
- //
6
- // Printing is not done here; the caller decides how to say it.
7
-
8
- const fs = require('fs');
9
- const path = require('path');
10
- const store = require('./kryptheon-store.js');
11
- const changes = require('./kryptheon-changes.js');
12
- const dash = require('./kryptheon-dashboard.js');
13
-
14
- function readJson(file) {
15
- try {
16
- return JSON.parse(fs.readFileSync(file, 'utf8'));
17
- } catch (err) {
18
- return null;
19
- }
20
- }
21
-
22
- /**
23
- * Looks once. `runners` does the work that needs the caller's tools:
24
- * runners.frontend() -> { ran, why } (the code read)
25
- * runners.regression() -> exit code, or null (replaying the recordings)
26
- * `options.replay` false keeps the recordings from being replayed - the
27
- * dashboard's automatic look does that by default, because a replay while the
28
- * app is not running reports every flow broken, and that would be a lie.
29
- */
30
- function look(root, runners, options) {
31
- const opts = options || {};
32
- const paths = store.pathsFor(root);
33
- const previous = readJson(paths.snapshot);
34
- const now = changes.takeSnapshot(root, previous);
35
- const diff = changes.compare(previous, now);
36
- const before = dash.buildState(root);
37
- const enabled = dash.readConfig(paths).enabled;
38
- const available = new Set(dash.CHECKS.filter((c) => c.available).map((c) => c.id));
39
-
40
- // On a first look, every check that can run, so the next look has
41
- // something to compare against. `force` adds checks that must run whatever
42
- // changed - a re-check has to run the check that found the problem, even
43
- // when the fix was made somewhere that check would not otherwise cover.
44
- const wanted = (diff.first ? ['frontend', 'regression', 'data'] : diff.checks).slice();
45
- for (const id of opts.force || []) if (!wanted.includes(id)) wanted.push(id);
46
- const plan = wanted.map((id) => {
47
- if (!available.has(id)) return { id: id, state: 'coming soon' };
48
- if (!enabled[id]) return { id: id, state: 'switched off in the dashboard' };
49
- if (id === 'data') return { id: id, state: 'needs your database - run npx kryptheon-night' };
50
- if (id === 'regression' && !before.recordings) return { id: id, state: 'no recordings yet - npx kryptheon record <url>' };
51
- if (id === 'regression' && opts.replay === false) return { id: id, state: 'not replayed automatically - press Run now when your app is running' };
52
- return { id: id, state: 'run', run: true };
53
- });
54
-
55
- // What changed is said before anything runs: a replay can take a minute,
56
- // and the person should not sit through it without knowing why.
57
- if (typeof runners.beforeRun === 'function') runners.beforeRun(diff, now);
58
-
59
- let regressionExit = null;
60
- for (const step of plan.filter((s) => s.run)) {
61
- if (step.id === 'frontend') {
62
- const r = runners.frontend();
63
- step.state = r.ran ? 'ran' : 'could not run: ' + r.why;
64
- } else if (step.id === 'regression') {
65
- regressionExit = runners.regression();
66
- step.state = regressionExit === 0 ? 'ran - every recording held'
67
- : regressionExit === 1 ? 'ran - something broke'
68
- : 'could not run (exit ' + regressionExit + ')';
69
- }
70
- }
71
-
72
- const after = dash.buildState(root);
73
- const fresh = changes.newFindings(before.findings, after.findings);
74
- const gone = changes.goneFindings(before.findings, after.findings);
75
- // A finding whose file was deleted is gone, not fixed - the same rule as a
76
- // dropped table in the database check. Kept apart, so deleting the code a
77
- // finding points at is never mistaken for making it safe.
78
- const fileOf = (f) => path.join(root, String(f.where || '').replace(/:\d+$/, ''));
79
- const removed = gone.filter((f) => f.check !== 'data' && !fs.existsSync(fileOf(f)));
80
- const fixed = gone.filter((f) => removed.indexOf(f) === -1);
81
- const openConfirmed = after.findings.filter((f) => f.status === 'confirmed');
82
-
83
- const event = {
84
- at: now.takenAt,
85
- by: opts.by || 'verify',
86
- first: diff.first,
87
- files: diff.files,
88
- parts: diff.parts,
89
- dependencies: diff.dependencies,
90
- checks: plan.map((s) => ({ id: s.id, state: s.state })),
91
- newFindings: fresh.length,
92
- fixed: fixed.length,
93
- goneWithFile: removed.length,
94
- openConfirmed: openConfirmed.length,
95
- };
96
- let saveError = null;
97
- try {
98
- fs.mkdirSync(paths.dir, { recursive: true });
99
- fs.writeFileSync(paths.snapshot, JSON.stringify(now) + '\n', 'utf8');
100
- fs.appendFileSync(paths.changes, JSON.stringify(event) + '\n', 'utf8');
101
- } catch (err) {
102
- saveError = err.message;
103
- }
104
-
105
- return {
106
- diff: diff,
107
- snapshot: now,
108
- plan: plan,
109
- fresh: fresh,
110
- fixed: fixed,
111
- removed: removed,
112
- openConfirmed: openConfirmed,
113
- after: after,
114
- regressionExit: regressionExit,
115
- event: event,
116
- saveError: saveError,
117
- };
118
- }
119
-
120
- /**
121
- * Whether anything changed since the last look, without looking. Cheap enough
122
- * to poll: unchanged files keep their hash without being read. The signature
123
- * carries each changed file's content hash, so a file still being written
124
- * keeps changing it - which is what tells a pause from the end of a task.
125
- */
126
- function pending(root) {
127
- const paths = store.pathsFor(root);
128
- const previous = readJson(paths.snapshot);
129
- if (!previous) return { changed: false, first: true };
130
- const now = changes.takeSnapshot(root, previous);
131
- const diff = changes.compare(previous, now);
132
- const signature = JSON.stringify(diff.files.map((f) => [f.path, f.state, now.files[f.path] ? now.files[f.path].hash : null]));
133
- return { changed: diff.files.length > 0, files: diff.files.length, signature: signature };
134
- }
135
-
136
- /**
137
- * Looks by itself whenever the project changes, and waits for the change to
138
- * settle first. An AI tool writes a dozen files over half a minute; looking
139
- * after the first one would report a half-finished task as broken. So a look
140
- * happens once the changed files have stayed the same for `quietMs`.
141
- *
142
- * Recorded flows are not replayed here unless `replay` is true: an automatic
143
- * replay while the app is not running reports every flow broken.
144
- */
145
- function startWatch(root, runners, options) {
146
- const opts = options || {};
147
- const intervalMs = opts.intervalMs || 2000;
148
- const quietMs = opts.quietMs || 4000;
149
- let seen = null;
150
- let since = 0;
151
- let busy = false;
152
- const doLook = () => {
153
- busy = true;
154
- try {
155
- const result = look(root, runners, { by: 'watch', replay: opts.replay === true });
156
- if (typeof opts.onLook === 'function') opts.onLook(result);
157
- } catch (err) {
158
- if (typeof opts.onError === 'function') opts.onError(err);
159
- } finally {
160
- busy = false;
161
- }
162
- };
163
- const tick = () => {
164
- if (busy) return;
165
- const p = pending(root);
166
- // Nothing to compare against yet: this first look is the starting point.
167
- if (p.first) return doLook();
168
- if (!p.changed) {
169
- seen = null;
170
- return;
171
- }
172
- if (p.signature !== seen) {
173
- seen = p.signature;
174
- since = Date.now();
175
- return;
176
- }
177
- if (Date.now() - since >= quietMs) doLook();
178
- };
179
- const timer = setInterval(tick, intervalMs);
180
- if (timer.unref && opts.unref) timer.unref();
181
- // Now, not one interval from now: a change made in the first seconds after
182
- // the page opened would otherwise land in the starting point and never be
183
- // seen as a change at all.
184
- tick();
185
- return {
186
- tick: tick,
187
- stop() {
188
- clearInterval(timer);
189
- },
190
- };
191
- }
192
-
193
- // What a broken flow says when the app itself did not answer - which is not
194
- // evidence either way about the fix.
195
- const APP_DID_NOT_ANSWER = /could not be opened|took too long to load|net::ERR|ECONNREFUSED/i;
196
-
197
- /**
198
- * The second half of the loop: someone says a finding is fixed; prove it.
199
- *
200
- * The check that found it is run again - always, whatever else changed - and
201
- * so is every check the changes since the last look call for, so a fix that
202
- * breaks something else is caught in the same step. The verdict:
203
- *
204
- * fixed the check ran, and the finding is not there
205
- * still open the check ran, and the finding is still there
206
- * gone with its file the file it pointed at was deleted - not the same as fixed
207
- * could not confirm the check did not run, or the app did not answer
208
- *
209
- * A fix is never assumed from a changed file. Every attempt is kept.
210
- */
211
- function recheck(root, runners, id, options) {
212
- const paths = store.pathsFor(root);
213
- const target = dash.buildState(root).findings.find((f) => f.id === id);
214
- if (!target) return { found: false };
215
-
216
- const result = look(root, runners, { by: 'recheck', force: [target.check], replay: true });
217
- const own = result.plan.find((s) => s.id === target.check);
218
- const still = result.after.findings.find((f) => f.id === id);
219
- let verdict;
220
- let why = '';
221
- if (!own || !/^ran/.test(own.state)) {
222
- verdict = 'could not confirm';
223
- why = own ? own.state : 'the check that found it did not run';
224
- } else if (still && target.check === 'regression' && APP_DID_NOT_ANSWER.test(still.detail || '')) {
225
- verdict = 'could not confirm';
226
- why = 'your app did not answer while the flow was replayed - start it and re-check';
227
- } else if (still) {
228
- verdict = 'still open';
229
- why = still.detail || '';
230
- } else if (result.removed.some((f) => f.id === id)) {
231
- verdict = 'gone with its file';
232
- why = 'the file it pointed at was deleted, which is not the same as fixing it';
233
- } else {
234
- verdict = 'fixed';
235
- }
236
- // Problems that appeared with this fix. The finding itself is never one of
237
- // them: it was there before, so it cannot be new.
238
- const newProblems = result.fresh.map((f) => ({
239
- id: f.id, check: f.check, severity: f.severity, status: f.status, where: f.where, headline: f.headline,
240
- }));
241
- const attempt = {
242
- id: id,
243
- at: new Date().toISOString(),
244
- check: target.check,
245
- where: target.where,
246
- headline: target.headline,
247
- verdict: verdict,
248
- why: why,
249
- newProblems: newProblems,
250
- };
251
- try {
252
- fs.appendFileSync(paths.fixes, JSON.stringify(attempt) + '\n', 'utf8');
253
- } catch (err) {
254
- attempt.saveError = err.message;
255
- }
256
- return Object.assign({ found: true, target: target, look: result }, attempt);
257
- }
258
-
259
- module.exports = { look: look, pending: pending, startWatch: startWatch, recheck: recheck };
1
+ // One look at a project: what changed since the last look, which checks that
2
+ // calls for, run the ones that can run, and what is new, fixed or merely
3
+ // deleted. Shared by `npx kryptheon verify` and the dashboard's own watch, so
4
+ // the command and the page can never tell two different stories.
5
+ //
6
+ // Printing is not done here; the caller decides how to say it.
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const store = require('./kryptheon-store.js');
11
+ const changes = require('./kryptheon-changes.js');
12
+ const dash = require('./kryptheon-dashboard.js');
13
+
14
+ function readJson(file) {
15
+ try {
16
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
17
+ } catch (err) {
18
+ return null;
19
+ }
20
+ }
21
+
22
+ /**
23
+ * A replay the dashboard's watch left owed. The watch reads the code by
24
+ * itself but never replays the recordings - an app that is not running
25
+ * would read as broken - so the changes it looked at were never replayed.
26
+ * Walking back through the looks: the latest watch look that skipped the
27
+ * replay, unless a later look did replay. { at } or null.
28
+ */
29
+ function owedReplay(paths) {
30
+ let lines;
31
+ try {
32
+ lines = fs.readFileSync(paths.changes, 'utf8').split('\n').filter(Boolean);
33
+ } catch (err) {
34
+ return null;
35
+ }
36
+ for (let i = lines.length - 1; i >= 0; i--) {
37
+ let event;
38
+ try {
39
+ event = JSON.parse(lines[i]);
40
+ } catch (err) {
41
+ continue;
42
+ }
43
+ const replay = (event.checks || []).find((c) => c.id === 'regression');
44
+ if (replay && /^ran/.test(replay.state)) return null;
45
+ if (event.by === 'watch' && replay && /^not replayed/.test(replay.state)) return { at: event.at };
46
+ }
47
+ return null;
48
+ }
49
+
50
+ /**
51
+ * Looks once. `runners` does the work that needs the caller's tools:
52
+ * runners.frontend() -> { ran, why } (the code read)
53
+ * runners.regression() -> exit code, or null (replaying the recordings)
54
+ * `options.replay` false keeps the recordings from being replayed - the
55
+ * dashboard's automatic look does that by default, because a replay while the
56
+ * app is not running reports every flow broken, and that would be a lie.
57
+ */
58
+ function look(root, runners, options) {
59
+ const opts = options || {};
60
+ const paths = store.pathsFor(root);
61
+ const previous = readJson(paths.snapshot);
62
+ const now = changes.takeSnapshot(root, previous);
63
+ const diff = changes.compare(previous, now);
64
+ const before = dash.buildState(root);
65
+ const enabled = dash.readConfig(paths).enabled;
66
+ const available = new Set(dash.CHECKS.filter((c) => c.available).map((c) => c.id));
67
+
68
+ // On a first look, every check that can run, so the next look has
69
+ // something to compare against. `force` adds checks that must run whatever
70
+ // changed - a re-check has to run the check that found the problem, even
71
+ // when the fix was made somewhere that check would not otherwise cover.
72
+ const wanted = (diff.first ? ['frontend', 'regression', 'data'] : diff.checks).slice();
73
+ for (const id of opts.force || []) if (!wanted.includes(id)) wanted.push(id);
74
+ // verify after the dashboard's watch took the last look with the code read
75
+ // only: what it saw was never replayed, so the replay runs now - with
76
+ // nothing changed since, "nothing changed" would hide it (blind round 17).
77
+ const owed = opts.by === 'verify' && !diff.first ? owedReplay(paths) : null;
78
+ if (owed && !wanted.includes('regression')) wanted.push('regression');
79
+ const plan = wanted.map((id) => {
80
+ if (!available.has(id)) return { id: id, state: 'coming soon' };
81
+ if (!enabled[id]) return { id: id, state: 'switched off in the dashboard' };
82
+ if (id === 'data') return { id: id, state: 'needs your database - run npx kryptheon-night' };
83
+ if (id === 'regression' && !before.recordings) return { id: id, state: 'no recordings yet - npx kryptheon record <url>' };
84
+ if (id === 'regression' && opts.replay === false) return { id: id, state: 'not replayed automatically - press Run now when your app is running' };
85
+ return { id: id, state: 'run', run: true };
86
+ });
87
+
88
+ if (owed) owed.replay = (plan.find((s) => s.id === 'regression') || {}).state || null;
89
+
90
+ // What changed is said before anything runs: a replay can take a minute,
91
+ // and the person should not sit through it without knowing why.
92
+ if (typeof runners.beforeRun === 'function') runners.beforeRun(diff, now, owed);
93
+
94
+ let regressionExit = null;
95
+ for (const step of plan.filter((s) => s.run)) {
96
+ if (step.id === 'frontend') {
97
+ const r = runners.frontend();
98
+ step.state = r.ran ? 'ran' : 'could not run: ' + r.why;
99
+ } else if (step.id === 'regression') {
100
+ regressionExit = runners.regression();
101
+ step.state = regressionExit === 0 ? 'ran - every recording held'
102
+ : regressionExit === 1 ? 'ran - something broke'
103
+ : 'could not run (exit ' + regressionExit + ')';
104
+ }
105
+ }
106
+
107
+ const after = dash.buildState(root);
108
+ const fresh = changes.newFindings(before.findings, after.findings);
109
+ const gone = changes.goneFindings(before.findings, after.findings);
110
+ // A finding whose file was deleted is gone, not fixed - the same rule as a
111
+ // dropped table in the database check. Kept apart, so deleting the code a
112
+ // finding points at is never mistaken for making it safe.
113
+ const fileOf = (f) => path.join(root, String(f.where || '').replace(/:\d+$/, ''));
114
+ const removed = gone.filter((f) => f.check !== 'data' && !fs.existsSync(fileOf(f)));
115
+ const fixed = gone.filter((f) => removed.indexOf(f) === -1);
116
+ const openConfirmed = after.findings.filter((f) => f.status === 'confirmed');
117
+
118
+ const event = {
119
+ at: now.takenAt,
120
+ by: opts.by || 'verify',
121
+ first: diff.first,
122
+ files: diff.files,
123
+ parts: diff.parts,
124
+ dependencies: diff.dependencies,
125
+ checks: plan.map((s) => ({ id: s.id, state: s.state })),
126
+ newFindings: fresh.length,
127
+ fixed: fixed.length,
128
+ goneWithFile: removed.length,
129
+ openConfirmed: openConfirmed.length,
130
+ };
131
+ let saveError = null;
132
+ try {
133
+ fs.mkdirSync(paths.dir, { recursive: true });
134
+ fs.writeFileSync(paths.snapshot, JSON.stringify(now) + '\n', 'utf8');
135
+ fs.appendFileSync(paths.changes, JSON.stringify(event) + '\n', 'utf8');
136
+ } catch (err) {
137
+ saveError = err.message;
138
+ }
139
+
140
+ return {
141
+ diff: diff,
142
+ snapshot: now,
143
+ plan: plan,
144
+ fresh: fresh,
145
+ fixed: fixed,
146
+ removed: removed,
147
+ openConfirmed: openConfirmed,
148
+ after: after,
149
+ regressionExit: regressionExit,
150
+ owed: owed,
151
+ event: event,
152
+ saveError: saveError,
153
+ };
154
+ }
155
+
156
+ /**
157
+ * Whether anything changed since the last look, without looking. Cheap enough
158
+ * to poll: unchanged files keep their hash without being read. The signature
159
+ * carries each changed file's content hash, so a file still being written
160
+ * keeps changing it - which is what tells a pause from the end of a task.
161
+ */
162
+ function pending(root) {
163
+ const paths = store.pathsFor(root);
164
+ const previous = readJson(paths.snapshot);
165
+ if (!previous) return { changed: false, first: true };
166
+ const now = changes.takeSnapshot(root, previous);
167
+ const diff = changes.compare(previous, now);
168
+ const signature = JSON.stringify(diff.files.map((f) => [f.path, f.state, now.files[f.path] ? now.files[f.path].hash : null]));
169
+ return { changed: diff.files.length > 0, files: diff.files.length, signature: signature };
170
+ }
171
+
172
+ /**
173
+ * Looks by itself whenever the project changes, and waits for the change to
174
+ * settle first. An AI tool writes a dozen files over half a minute; looking
175
+ * after the first one would report a half-finished task as broken. So a look
176
+ * happens once the changed files have stayed the same for `quietMs`.
177
+ *
178
+ * Recorded flows are not replayed here unless `replay` is true: an automatic
179
+ * replay while the app is not running reports every flow broken.
180
+ */
181
+ function startWatch(root, runners, options) {
182
+ const opts = options || {};
183
+ const intervalMs = opts.intervalMs || 2000;
184
+ const quietMs = opts.quietMs || 4000;
185
+ let seen = null;
186
+ let since = 0;
187
+ let busy = false;
188
+ const doLook = () => {
189
+ busy = true;
190
+ try {
191
+ const result = look(root, runners, { by: 'watch', replay: opts.replay === true });
192
+ if (typeof opts.onLook === 'function') opts.onLook(result);
193
+ } catch (err) {
194
+ if (typeof opts.onError === 'function') opts.onError(err);
195
+ } finally {
196
+ busy = false;
197
+ }
198
+ };
199
+ const tick = () => {
200
+ if (busy) return;
201
+ const p = pending(root);
202
+ // Nothing to compare against yet: this first look is the starting point.
203
+ if (p.first) return doLook();
204
+ if (!p.changed) {
205
+ seen = null;
206
+ return;
207
+ }
208
+ if (p.signature !== seen) {
209
+ seen = p.signature;
210
+ since = Date.now();
211
+ return;
212
+ }
213
+ if (Date.now() - since >= quietMs) doLook();
214
+ };
215
+ const timer = setInterval(tick, intervalMs);
216
+ if (timer.unref && opts.unref) timer.unref();
217
+ // Now, not one interval from now: a change made in the first seconds after
218
+ // the page opened would otherwise land in the starting point and never be
219
+ // seen as a change at all.
220
+ tick();
221
+ return {
222
+ tick: tick,
223
+ stop() {
224
+ clearInterval(timer);
225
+ },
226
+ };
227
+ }
228
+
229
+ // What a broken flow says when the app itself did not answer - which is not
230
+ // evidence either way about the fix.
231
+ const APP_DID_NOT_ANSWER = /could not be opened|took too long to load|net::ERR|ECONNREFUSED/i;
232
+
233
+ /**
234
+ * The second half of the loop: someone says a finding is fixed; prove it.
235
+ *
236
+ * The check that found it is run again - always, whatever else changed - and
237
+ * so is every check the changes since the last look call for, so a fix that
238
+ * breaks something else is caught in the same step. The verdict:
239
+ *
240
+ * fixed the check ran, and the finding is not there
241
+ * still open the check ran, and the finding is still there
242
+ * gone with its file the file it pointed at was deleted - not the same as fixed
243
+ * could not confirm the check did not run, or the app did not answer
244
+ *
245
+ * A fix is never assumed from a changed file. Every attempt is kept.
246
+ */
247
+ function recheck(root, runners, id, options) {
248
+ const paths = store.pathsFor(root);
249
+ const open = dash.buildState(root).findings;
250
+ const target = open.find((f) => f.id === id);
251
+ if (!target) return { found: false };
252
+
253
+ const result = look(root, runners, { by: 'recheck', force: [target.check], replay: true });
254
+ const own = result.plan.find((s) => s.id === target.check);
255
+ const still = result.after.findings.find((f) => f.id === id);
256
+ let verdict;
257
+ let why = '';
258
+ if (!own || !/^ran/.test(own.state)) {
259
+ verdict = 'could not confirm';
260
+ why = own ? own.state : 'the check that found it did not run';
261
+ } else if (still && target.check === 'regression' && APP_DID_NOT_ANSWER.test(still.detail || '')) {
262
+ verdict = 'could not confirm';
263
+ why = 'your app did not answer while the flow was replayed - start it and re-check';
264
+ } else if (still) {
265
+ verdict = 'still open';
266
+ why = still.detail || '';
267
+ } else if (result.removed.some((f) => f.id === id)) {
268
+ verdict = 'gone with its file';
269
+ why = 'the file it pointed at was deleted, which is not the same as fixing it';
270
+ } else {
271
+ verdict = 'fixed';
272
+ }
273
+ // Problems that appeared with this fix. The finding itself is never one of
274
+ // them: it was there before, so it cannot be new.
275
+ const newProblems = result.fresh.map((f) => ({
276
+ id: f.id, check: f.check, severity: f.severity, status: f.status, where: f.where, headline: f.headline,
277
+ }));
278
+ // Other findings the same checks cleared on the way: the replay runs every
279
+ // recording, so fixing one flow can show another fixed too. Kept with this
280
+ // attempt, so a re-check of one of them says it was already fixed, and by
281
+ // which re-check - not "no open finding" (blind round 17).
282
+ const ran = new Set(result.plan.filter((s) => /^ran/.test(s.state)).map((s) => s.id));
283
+ const alsoFixed = verdict === 'fixed' || verdict === 'still open'
284
+ ? open.filter((f) => f.id !== id && ran.has(f.check) && !result.after.findings.some((x) => x.id === f.id) &&
285
+ !result.removed.some((x) => x.id === f.id)).map((f) => ({ id: f.id, where: f.where, headline: f.headline }))
286
+ : [];
287
+ const attempt = {
288
+ id: id,
289
+ at: new Date().toISOString(),
290
+ check: target.check,
291
+ where: target.where,
292
+ headline: target.headline,
293
+ verdict: verdict,
294
+ why: why,
295
+ newProblems: newProblems,
296
+ alsoFixed: alsoFixed,
297
+ };
298
+ try {
299
+ fs.appendFileSync(paths.fixes, JSON.stringify(attempt) + '\n', 'utf8');
300
+ } catch (err) {
301
+ attempt.saveError = err.message;
302
+ }
303
+ return Object.assign({ found: true, target: target, look: result }, attempt);
304
+ }
305
+
306
+ module.exports = { look: look, pending: pending, startWatch: startWatch, recheck: recheck, owedReplay: owedReplay };