kryptheon 0.1.50 → 0.1.52

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/README.md CHANGED
@@ -401,6 +401,14 @@ once, and says so.
401
401
  A `.env` in the same folder is loaded automatically, and anything you type into a
402
402
  password box is replaced with an environment variable rather than written into
403
403
  the test. When there is a password, `.env` is added to an existing `.gitignore`.
404
+ Kryptheon's names are always added to the end of your `.env`, never written over
405
+ it, so your app's own values stay. Your app's own `.env.example` is never changed.
406
+
407
+ Each replay gets time by its length: 30 seconds plus 3 per step, at least 60
408
+ seconds and at most 3 minutes. A recording of more than 40 steps still runs, but
409
+ you are told when you make it that shorter ones, one task each, say more clearly
410
+ what broke. A run where every recording was skipped (a password not set yet) is
411
+ still listed under Runs, with each recording and why.
404
412
 
405
413
  ## What Kryptheon does not check
406
414
 
package/bin/kryptheon.js CHANGED
@@ -154,6 +154,7 @@ function runPlaywright(args, options) {
154
154
  cwd: USER_DIR,
155
155
  stdio: quiet ? ['inherit', 'inherit', 'pipe'] : 'inherit',
156
156
  encoding: 'utf8',
157
+ env: (options && options.env) ? Object.assign({}, process.env, options.env) : process.env,
157
158
  });
158
159
 
159
160
  if (result.error) {
@@ -183,7 +184,13 @@ function ensureBrowser() {
183
184
  console.log(' Downloading a browser to run your app in.');
184
185
  console.log(' This is about 200MB and only happens once.');
185
186
  console.log('');
186
- const status = runPlaywright(['install', 'chromium']).status;
187
+ // Playwright's install deletes every browser it thinks no other copy of
188
+ // Playwright still uses. With Kryptheon installed in a project and run by
189
+ // npx too, each install deleted the other's browser, so every run
190
+ // downloaded 200MB again (a real user's machine, 2026-10-22). Nothing is
191
+ // deleted now; the version is also pinned exactly in package.json, so
192
+ // every install of one Kryptheon wants the same browser.
193
+ const status = runPlaywright(['install', 'chromium'], { env: { PLAYWRIGHT_SKIP_BROWSER_GC: '1' } }).status;
187
194
  if (status !== 0) {
188
195
  console.error('');
189
196
  console.error(' The browser download did not finish.');
@@ -1020,22 +1027,29 @@ function reportSecrets(replacements) {
1020
1027
  // Written rather than described. Asked to make the file themselves, most
1021
1028
  // people on Windows reach for Notepad or Out-File, both of which add a byte
1022
1029
  // order mark that makes the first line unreadable.
1030
+ // Never "save .env.example as .env": an app's own .env usually exists
1031
+ // already, with its database URL and live keys in it, and saving over it
1032
+ // loses all of them (a real user's app, 2026-10-22). The names are always
1033
+ // added to .env; the example file is only a list of what is needed, and only
1034
+ // ever Kryptheon's own (writeEnvExample leaves an app's example alone).
1023
1035
  const hasEnv = fs.existsSync(path.join(USER_DIR, '.env'));
1024
1036
  const example = hasEnv ? null : secrets.writeEnvExample(USER_DIR, names);
1025
1037
  // Each account has its own name, so the owner's and a member's recordings
1026
1038
  // can both sign in (blind round 19).
1027
1039
  const whose = (item) => (item.account ? ' (' + String(item.field).toLowerCase() + ' of ' + item.account + ')' : '');
1040
+ if (hasEnv) {
1041
+ console.log(' Before this can be checked, add it to the .env in this folder. Keep');
1042
+ console.log(' everything already in it - your app needs those values:');
1043
+ } else {
1044
+ console.log(' Before this can be checked, put it in a file called .env in this folder:');
1045
+ }
1046
+ for (const item of replacements) console.log(' ' + item.envName + '=yourpassword' + whose(item));
1047
+ console.log('');
1048
+ for (const line of secrets.howToWriteEnv(names)) console.log(line);
1028
1049
  if (example) {
1029
- console.log(' A file called .env.example has been written here:');
1030
- for (const item of replacements) console.log(' ' + item.envName + '=yourpassword' + whose(item));
1031
1050
  console.log('');
1032
- console.log(' Put the real password in it and save it as .env, in this folder.');
1033
- } else {
1034
- console.log(' Before this can be checked, put it in a file called .env next to');
1035
- console.log(' your tests, like this:');
1036
- for (const item of replacements) {
1037
- console.log(' ' + item.envName + '=your ' + String(item.field).toLowerCase() + ' here' + whose(item));
1038
- }
1051
+ console.log(' The names are also listed in .env.example, without the password, for');
1052
+ console.log(' anyone else who runs these checks.');
1039
1053
  }
1040
1054
  console.log('');
1041
1055
  // Said plainly, because the alternative is signing in with a blank password
@@ -1275,6 +1289,23 @@ function reportReplayRisks(relativeFile) {
1275
1289
  return risks;
1276
1290
  }
1277
1291
 
1292
+ // A long recording still runs - it gets more time (replay.timeBudget) - but
1293
+ // one that does many things breaks for any of them, and says less about which.
1294
+ // Said once, when it is made, while recording a shorter one is still easy.
1295
+ function reportLength(relativeFile) {
1296
+ const source = readSpec(relativeFile);
1297
+ if (source === null) return 0;
1298
+ const steps = replay.readActions(source).length;
1299
+ if (steps <= replay.LONG_RECORDING) return steps;
1300
+ const secs = Math.round(replay.timeBudget(source) / 1000);
1301
+ console.log(' This recording is long: ' + steps + ' steps. Each replay gets up to ' + secs + ' seconds.');
1302
+ console.log(' It will run, but when it breaks, any one of those steps could be why.');
1303
+ console.log(' Shorter recordings - one task each, like "sign in and add a note" - are');
1304
+ console.log(' faster and say exactly what broke.');
1305
+ console.log('');
1306
+ return steps;
1307
+ }
1308
+
1278
1309
  // Everything that has to happen to whatever codegen left behind, however
1279
1310
  // the run ended. Module level so it can be exercised directly.
1280
1311
  async function finaliseRecording(outFile, context) {
@@ -1315,6 +1346,7 @@ async function finaliseRecording(outFile, context) {
1315
1346
  await offerToDropLogout(named);
1316
1347
  reportReplayRisks(named);
1317
1348
  reportFragileSelectors(named);
1349
+ reportLength(named);
1318
1350
 
1319
1351
  return { code: 0, savedAs: named };
1320
1352
  }
@@ -1882,6 +1914,26 @@ function triageSpecs() {
1882
1914
  };
1883
1915
  }
1884
1916
 
1917
+ /** Each recording the run leaves out, with the reason in a few words. */
1918
+ function skippedOf(triage) {
1919
+ const file = (name) => path.join('tests', name).split(path.sep).join('/');
1920
+ return triage.missingSecrets.map((item) => ({ file: file(item.name), why: item.names.join(', ') + ' not set in .env' }))
1921
+ .concat(triage.notRecordings.map((name) => ({ file: file(name), why: 'not a real recording' })));
1922
+ }
1923
+
1924
+ /** A run that replayed nothing, kept in the history like any other run. */
1925
+ function recordSkippedRun(skipped) {
1926
+ if (!skipped.length) return;
1927
+ const entry = { runAt: new Date().toISOString(), status: 'skipped', durationMs: 0, passed: 0, failed: 0, tests: [], skipped: skipped };
1928
+ try {
1929
+ const file = store.pathsFor(USER_DIR).history;
1930
+ fs.mkdirSync(path.dirname(file), { recursive: true });
1931
+ fs.appendFileSync(file, JSON.stringify(entry) + '\n', 'utf8');
1932
+ } catch (err) {
1933
+ // The terminal has already said everything; the history is a record of it.
1934
+ }
1935
+ }
1936
+
1885
1937
  function check(options) {
1886
1938
  const quiet = !!(options && options.quiet);
1887
1939
 
@@ -1937,8 +1989,8 @@ function check(options) {
1937
1989
 
1938
1990
  for (const item of triage.missingSecrets) {
1939
1991
  console.log('');
1940
- const example = fs.existsSync(path.join(USER_DIR, '.env.example')) ? '.env.example' : null;
1941
- for (const line of secrets.missingSecretLines(path.join('tests', item.name), item.names, { examplePath: example })) {
1992
+ const envExists = fs.existsSync(path.join(USER_DIR, '.env'));
1993
+ for (const line of secrets.missingSecretLines(path.join('tests', item.name), item.names, { envExists: envExists })) {
1942
1994
  console.log(line);
1943
1995
  }
1944
1996
  }
@@ -1966,13 +2018,19 @@ function check(options) {
1966
2018
  console.log(' Record it again: npx kryptheon record <url>');
1967
2019
  }
1968
2020
 
2021
+ // What was left out, and why: kept with the run, so the dashboard's Runs
2022
+ // page says it. A run where everything was skipped used to leave no trace
2023
+ // at all - Runs stayed empty and looked as if nothing had happened (a real
2024
+ // user's app, 2026-10-22).
2025
+ const skipped = skippedOf(triage);
1969
2026
  if (!triage.runnable.length) {
2027
+ recordSkippedRun(skipped);
1970
2028
  console.log('');
1971
2029
  console.log(' Nothing could be checked.');
1972
2030
  console.log('');
1973
2031
  if (triage.missingSecrets.length) {
1974
2032
  console.log(' Every recording here needs a password that is not set yet.');
1975
- console.log(' Create the .env file above and run this again.');
2033
+ console.log(' Add it to .env as shown above, and run this again.');
1976
2034
  } else {
1977
2035
  console.log(' None of the files in tests/ is a usable recording.');
1978
2036
  console.log(' Record one with: npx kryptheon record <url>');
@@ -1987,6 +2045,9 @@ function check(options) {
1987
2045
  // cannot produce diagnostics can never be counted as passing.
1988
2046
  const only = triage.runnable.map((name) => path.join('tests', name).split(path.sep).join('/'));
1989
2047
  if (quiet) process.env.KRYPTHEON_QUIET = '1';
2048
+ // The reporter writes this run's history line; it adds what was skipped.
2049
+ if (skipped.length) process.env.KRYPTHEON_SKIPPED = JSON.stringify(skipped);
2050
+ else delete process.env.KRYPTHEON_SKIPPED;
1990
2051
 
1991
2052
  // Debug signatures. The workers cannot print: Playwright pipes their
1992
2053
  // descriptors and hands the output to reporter stdio hooks that this
@@ -3702,6 +3763,7 @@ module.exports = {
3702
3763
  takeOutSecrets: takeOutSecrets,
3703
3764
  reportSecrets: reportSecrets,
3704
3765
  reportReplayRisks: reportReplayRisks,
3766
+ reportLength: reportLength,
3705
3767
  offerToDropLogout: offerToDropLogout,
3706
3768
  noWindowLines: noWindowLines,
3707
3769
  windowUndetectedLines: windowUndetectedLines,
@@ -1149,9 +1149,16 @@
1149
1149
  if (!state.runs.length) { box.appendChild(el('p', 'empty', 'No recorded flows have been replayed yet. Record one with npx kryptheon record, then press Run checks.')); return; }
1150
1150
  state.runs.slice(0, 30).forEach(function (r) {
1151
1151
  var row = el('div', 'line-row');
1152
- row.appendChild(el('span', 'tag ' + (r.failed ? 'ember' : 'leaf'), r.failed ? r.failed + ' broke' : 'held'));
1152
+ var skipped = r.skipped || [];
1153
+ // Every recording left out: nothing ran, and the row says why, instead
1154
+ // of the run vanishing from this page.
1155
+ var none = r.status === 'skipped' || (!r.passed && !r.failed && skipped.length);
1156
+ row.appendChild(el('span', 'tag ' + (none ? 'muted' : r.failed ? 'ember' : 'leaf'), none ? 'nothing ran' : r.failed ? r.failed + ' broke' : 'held'));
1153
1157
  var text = el('div', 'lr-text');
1154
- text.appendChild(el('div', null, (r.passed || 0) + ' held, ' + (r.failed || 0) + ' broke'));
1158
+ text.appendChild(el('div', null, none
1159
+ ? 'Skipped ' + skipped.length + (skipped.length === 1 ? ' recording' : ' recordings')
1160
+ : (r.passed || 0) + ' held, ' + (r.failed || 0) + ' broke' + (skipped.length ? ', ' + skipped.length + ' skipped' : '')));
1161
+ skipped.forEach(function (s) { text.appendChild(el('div', 'lr-sub', s.file + ' - ' + s.why)); });
1155
1162
  text.appendChild(el('div', 'lr-sub', when(r.runAt)));
1156
1163
  row.appendChild(text);
1157
1164
  if (r.failed) row.appendChild(button('sm', 'arrow', 'See the finding', function () { go('findings', 'confirmed'); }));
@@ -558,7 +558,12 @@ function buildState(root, env) {
558
558
 
559
559
  // Recorded flows: the last run's broken tests are the findings. They were
560
560
  // replayed in a real browser, so they are confirmed at runtime.
561
- const lastRun = history.length ? history[history.length - 1] : null;
561
+ // The last run that replayed something. A run where every recording was
562
+ // skipped (no password set) is listed under Runs, but it re-checked
563
+ // nothing, so it neither clears the last real run's findings nor counts as
564
+ // the flows having been replayed.
565
+ const replayed = history.filter((r) => (r.tests || []).length);
566
+ const lastRun = replayed.length ? replayed[replayed.length - 1] : null;
562
567
  if (lastRun && config.enabled.regression) {
563
568
  for (const t of lastRun.tests || []) {
564
569
  if (t.status !== 'failed' && t.status !== 'timedOut') continue;
@@ -849,7 +854,7 @@ function buildState(root, env) {
849
854
  notChecked: NOT_CHECKED,
850
855
  findings: findings,
851
856
  allFixPrompt: combinedPrompt(forAll),
852
- runs: history.slice().reverse().map((r) => ({ runAt: r.runAt, status: r.status, passed: r.passed, failed: r.failed, durationMs: r.durationMs })),
857
+ runs: history.slice().reverse().map((r) => ({ runAt: r.runAt, status: r.status, passed: r.passed, failed: r.failed, durationMs: r.durationMs, skipped: (r.skipped || []).slice(0, 20) })),
853
858
  recordings: recordings,
854
859
  steps: steps,
855
860
  // Which app this dashboard is for: its web address, kept here, and whether
package/kryptheon-edge.js CHANGED
@@ -565,9 +565,14 @@ function judgeVariant(clean, variant, plan) {
565
565
  // Back to the form with the very answer the recorded save got - "Settings
566
566
  // saved" for both - is the save going through.
567
567
  const c0 = saved[0].cleanWrite;
568
- const asSaved = redirected && c0 && ok(c0) && probe.backToForm(c0) && probe.backToForm(w0) && probe.answerShape(c0) === probe.answerShape(w0);
569
- const weak = redirected && probe.backToForm(w0) && w0.shownAfter !== true && !asSaved;
568
+ // The page it went to, opened, and the value not on it: answered as a
569
+ // save, not shown as kept. Found on the round 21 rerun: an edit answered
570
+ // "Changes saved" for a language the app never writes - said as stored.
571
+ const notShown = redirected && w0.shownAfter === false;
572
+ const asSaved = redirected && !notShown && c0 && ok(c0) && probe.backToForm(c0) && probe.backToForm(w0) && probe.answerShape(c0) === probe.answerShape(w0);
573
+ const weak = notShown || (redirected && probe.backToForm(w0) && w0.shownAfter !== true && !asSaved);
570
574
  const pageLine = redirected && w0.shownAfter === true ? ['The page it went to after saving, ' + w0.to + ', shows ' + show(plan.value) + '.']
575
+ : notShown ? ['It answered as a save (' + w0.to + '), but that page, opened, does not show ' + show(plan.value) + ' - whether it was kept is not shown.']
571
576
  : asSaved ? ['It answered as your recorded save did (' + w0.to + ') - the value was taken.']
572
577
  : weak ? ['It answered with a redirect back to the form (' + w0.to + '), which does not say whether it kept the value.'] : [];
573
578
  if (problem || toCheck) {
@@ -440,6 +440,15 @@ const test = base.test.extend({
440
440
  /* without it, a failure is said as before */
441
441
  }
442
442
 
443
+ // Time by length: a long recording gets longer than Playwright's flat 30
444
+ // seconds (kryptheon-replay.js timeBudget). Set here, before the page is
445
+ // handed to the recording, so every step runs under the new limit.
446
+ try {
447
+ testInfo.setTimeout(replay.timeBudget(fs.readFileSync(testInfo.file, 'utf8')));
448
+ } catch (e) {
449
+ /* Playwright's own limit stands */
450
+ }
451
+
443
452
  const key = baselineKey(testInfo.file, testInfo.title);
444
453
 
445
454
  // The steps this recording actually performs. Comments, blank lines and
@@ -9,6 +9,8 @@
9
9
  // Pure string work: no Playwright, no filesystem, so both the command line and
10
10
  // the reporter can use it.
11
11
 
12
+ const selectors = require('./kryptheon-selectors.js');
13
+
12
14
  // Pulls the readable name out of a recorded line, e.g.
13
15
  // page.getByRole('button', { name: 'Sign Up' }).click() -> Sign Up
14
16
  function nameInLine(line) {
@@ -143,6 +145,23 @@ function findReplayRisks(source) {
143
145
  });
144
146
  }
145
147
 
148
+ // 7. A step that finds what it clicks by a date or a time in its text.
149
+ // Found on the round 21 rerun: a calendar recording picked each session's
150
+ // card by "Oct 23, 2026, 11:28 PM"; a fresh database seeded its sessions
151
+ // from that day on, and the recording never replayed - the note it saved
152
+ // was never checked.
153
+ const dated = actions.find((a) => !a.isGoto && selectors.textMatchers(a.text).some((t) => selectors.volatileKind(t) === 'datetime'));
154
+ if (dated) {
155
+ const text = selectors.textMatchers(dated.text).find((t) => selectors.volatileKind(t) === 'datetime');
156
+ risks.push({
157
+ kind: 'picks-by-date',
158
+ line: dated.line,
159
+ step: text.slice(0, 80),
160
+ why: 'this step finds what it clicks by a date or time ("' + text.slice(0, 60) + '") - on another day that text is different, and the step cannot find it',
161
+ fix: 'record again, picking it by something that does not change with the day - a name, a label, or its place in the list',
162
+ });
163
+ }
164
+
146
165
  // 4. Steps inside an embedded frame - most often a payment provider's
147
166
  // checkout. Found on a blind test (round 18): a recording went on into
148
167
  // Razorpay's checkout (contact number, UPI QR, EMI, close); its frame
@@ -281,8 +300,27 @@ function recordingId(source) {
281
300
  return require('crypto').createHash('sha1').update(steps.join('\n')).digest('hex').slice(0, 12);
282
301
  }
283
302
 
303
+ // How long one replay of this recording may take, in milliseconds.
304
+ //
305
+ // Playwright's own limit is 30 seconds for the whole test, whatever its
306
+ // length. A correct recording of 40 steps against a live site needs more than
307
+ // that, ran out of time partway, and was reported as the app's fault (a real
308
+ // user's app, 2026-10-22). So: 30 seconds plus 3 per step, never under 60
309
+ // seconds and never over 3 minutes - past that, something really is stuck.
310
+ const BUDGET = { base: 30000, perStep: 3000, min: 60000, max: 180000 };
311
+ // Past this many steps a recording is said to be long when it is made.
312
+ const LONG_RECORDING = 40;
313
+
314
+ function timeBudget(source) {
315
+ const steps = readActions(source).length;
316
+ return Math.min(BUDGET.max, Math.max(BUDGET.min, BUDGET.base + steps * BUDGET.perStep));
317
+ }
318
+
284
319
  module.exports = {
285
320
  recordingId: recordingId,
321
+ timeBudget: timeBudget,
322
+ BUDGET: BUDGET,
323
+ LONG_RECORDING: LONG_RECORDING,
286
324
  readActions: readActions,
287
325
  findReplayRisks: findReplayRisks,
288
326
  scrubSecrets: scrubSecrets,
@@ -1029,6 +1029,14 @@ class KryptheonReporter {
1029
1029
  failed: failed,
1030
1030
  tests: this.records,
1031
1031
  };
1032
+ // Recordings the CLI left out before the run (no password set, not a real
1033
+ // recording), so the Runs page can say what was not replayed.
1034
+ try {
1035
+ const skipped = JSON.parse(process.env.KRYPTHEON_SKIPPED || '[]');
1036
+ if (Array.isArray(skipped) && skipped.length) entry.skipped = skipped;
1037
+ } catch (e) {
1038
+ // a malformed list is left out, never a reason to lose the run
1039
+ }
1032
1040
 
1033
1041
  // Append only - existing lines are never rewritten.
1034
1042
  let saved = false;
@@ -76,27 +76,44 @@ function missingSecrets(names, options) {
76
76
  }
77
77
 
78
78
  /**
79
- * How to create the file without a byte order mark.
79
+ * How to add the names to .env without a byte order mark.
80
80
  *
81
81
  * PowerShell's own `Out-File -Encoding utf8` writes one, and so does Notepad,
82
82
  * which is why this spells out a command that does not rather than leaving it
83
83
  * to whatever the person reaches for first.
84
+ *
85
+ * Always an append, never a write. The app's own .env is usually already
86
+ * there, holding its database URL and live payment keys; a command that
87
+ * replaced the file would wipe all of them for the sake of one test password
88
+ * (a real user's app, 2026-10-22). Appending also creates the file when there
89
+ * is none, so one command serves both. The leading newline keeps the first
90
+ * name off the end of a last line that has none; a blank line is harmless.
84
91
  */
85
92
  function howToWriteEnv(names, platform) {
86
- const line = names.map((name) => name + '=yourpassword').join('\\n');
87
- if ((platform || process.platform) === 'win32') {
93
+ const windows = (platform || process.platform) === 'win32';
94
+ const pairs = names.map((name) => name + '=yourpassword');
95
+ if (windows) {
96
+ // PowerShell's newline is `n inside double quotes. "\n" would be written
97
+ // as a backslash and an n, all on one line.
88
98
  return [
89
- ' In PowerShell, this writes it without a byte order mark:',
90
- ' [IO.File]::WriteAllText("$PWD\\.env", "' + line + '`n")',
99
+ ' In PowerShell, this adds it to the end of .env (it keeps what is',
100
+ ' already there, and writes no byte order mark):',
101
+ ' [IO.File]::AppendAllText("$PWD\\.env", "`n' + pairs.join('`n') + '`n")',
91
102
  '',
92
- ' Avoid Out-File and Notepad here: both add a mark that makes the first',
93
- ' line unreadable, and the password would silently come out blank.',
103
+ // Not "avoid Notepad" any more: readEnvFile drops a byte order mark, so
104
+ // editing the file in any editor afterwards is fine.
105
+ ' Then open .env and replace yourpassword with the real one.',
94
106
  ];
95
107
  }
96
- return [' For example:', " printf '" + line.replace(/\\n/g, "\\n") + "\\n' > .env"];
108
+ return [
109
+ ' This adds it to the end of .env and keeps what is already there:',
110
+ " printf '\\n" + pairs.join('\\n') + "\\n' >> .env",
111
+ '',
112
+ ' Then open .env and replace yourpassword with the real one.',
113
+ ];
97
114
  }
98
115
 
99
- /** What to tell somebody who has not created the file yet. */
116
+ /** What to tell somebody who has not set the secret yet. */
100
117
  function missingSecretLines(specName, names, options) {
101
118
  const opts = options || {};
102
119
  const many = names.length > 1;
@@ -105,13 +122,15 @@ function missingSecretLines(specName, names, options) {
105
122
  ' This recording needs a password' + (many ? ' and other secrets' : '') + ', and there is none set.',
106
123
  '',
107
124
  ];
108
- if (opts.examplePath) {
109
- lines.push(' There is a ' + opts.examplePath + ' here already. Put the real value in it');
110
- lines.push(' and save it as .env, in the same folder.');
125
+ // Never "save .env.example as .env": the example may be the app's own, and
126
+ // saving over an existing .env loses every value the app runs on.
127
+ if (opts.envExists) {
128
+ lines.push(' Add ' + (many ? 'these lines' : 'this line') + ' to the .env in this folder. Keep everything');
129
+ lines.push(' already in it - your app needs those values:');
111
130
  } else {
112
131
  lines.push(' Create a .env file in this folder containing:');
113
- for (const name of names) lines.push(' ' + name + '=yourpassword');
114
132
  }
133
+ for (const name of names) lines.push(' ' + name + '=yourpassword');
115
134
  lines.push('');
116
135
  for (const line of howToWriteEnv(names, opts.platform)) lines.push(line);
117
136
  lines.push('');
@@ -128,6 +147,11 @@ function missingSecretLines(specName, names, options) {
128
147
  * names from an earlier recording, and clobbering it would lose them. A name
129
148
  * it does not have yet is added at the end - each account now has its own
130
149
  * (blind round 19), so a second account's recording brings a second name.
150
+ *
151
+ * Only a file Kryptheon wrote is added to. Many apps ship their own
152
+ * .env.example, listing their own settings; that file is the app's, committed
153
+ * with it, and is left exactly as it is. A file is Kryptheon's when every name
154
+ * in it is one of Kryptheon's (KRYPTHEON_...).
131
155
  * Returns the file when it wrote to it, null when there was nothing to add.
132
156
  */
133
157
  function writeEnvExample(dir, names) {
@@ -137,6 +161,7 @@ function writeEnvExample(dir, names) {
137
161
  let raw = fs.readFileSync(file, 'utf8');
138
162
  if (raw.charCodeAt(0) === 0xfeff) raw = raw.slice(1);
139
163
  const there = readEnvFile(file);
164
+ if (!isOwnExample(there)) return null;
140
165
  const add = (names || []).filter((name) => !(name in there));
141
166
  if (!add.length) return null;
142
167
  fs.appendFileSync(file, (raw.length && !raw.endsWith('\n') ? '\n' : '') + add.map((name) => name + '=yourpassword').join('\n') + '\n', { encoding: 'utf8' });
@@ -150,6 +175,11 @@ function writeEnvExample(dir, names) {
150
175
  }
151
176
  }
152
177
 
178
+ /** An example file holding only Kryptheon's names (or nothing yet). */
179
+ function isOwnExample(values) {
180
+ return Object.keys(values).every((name) => /^KRYPTHEON_/.test(name));
181
+ }
182
+
153
183
  // What must never be committed from a project: the real password. The three
154
184
  // files of machine state that used to be listed here - baselines, history and
155
185
  // test-results/ - are no longer written into the project at all; they live in
@@ -197,6 +227,7 @@ module.exports = {
197
227
  missingSecretLines: missingSecretLines,
198
228
  howToWriteEnv: howToWriteEnv,
199
229
  writeEnvExample: writeEnvExample,
230
+ isOwnExample: isOwnExample,
200
231
  updateGitignore: updateGitignore,
201
232
  GITIGNORE_ENTRIES: GITIGNORE_ENTRIES,
202
233
  isSet: isSet,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kryptheon",
3
- "version": "0.1.50",
3
+ "version": "0.1.52",
4
4
  "description": "Record what you do in your app and get plain-language reports when it breaks.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "commonjs",
@@ -58,7 +58,7 @@
58
58
  "node": ">=20.6.0"
59
59
  },
60
60
  "dependencies": {
61
- "@playwright/test": "^1.62.1",
61
+ "@playwright/test": "1.62.1",
62
62
  "pg": "^8.23.0"
63
63
  },
64
64
  "scripts": {