kryptheon 0.1.51 → 0.1.53

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,