start-command 0.39.1 → 0.40.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # start-command
2
2
 
3
+ ## 0.40.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 47a9dd8: Upgrade every dependency to its latest release, and let CI reject pull requests that fall behind (#253).
8
+
9
+ - **Upgrades:** `@link-foundation/sensitive-data-sanitizer` 0.12.2, `command-stream` 2.6.0, `lino-objects-codec` 0.9.3, the lint tools, the GitHub Actions, the runners (`ubuntu-26.04`, `macos-26`) and the .NET 10 SDK that clink 4.x needs.
10
+ - **Store format:** the execution store is now written in lino-objects-codec 0.9's readable format. Stores written by older releases are still read, but older releases of start cannot read a store written by this one.
11
+ - **Links database:** the store had stayed empty, because clink 4.x rejected every query it sent. It now writes one record-scoped link per property and verifies the writes. The existing `recordToLinksNotation()` helper remains available with the corrected format.
12
+ - **`--use-command-stream`:** command output is appended to the log again. command-stream 2.x returns it as snapshots.
13
+ - **Sanitizer:** start's own `Authorization` masking pass is gone, because the sanitizer now masks only the scheme and token itself. A NUL byte in a log no longer blocks the upload (`--allow-binary`).
14
+ - **Dependency fixes:** preserve Authorization placeholders, bracketed tokens and following control bytes; avoid quadratic scanning of dense credentials. Load command-stream's lightweight `core` entry for command execution.
15
+ - **CI:** `scripts/check-dependency-freshness.mjs` fails a pull request when any npm package, crate, action, CI tool, runtime, runner or translator pin is not its latest release. The one exception is a version that links an open blocking issue.
16
+
17
+ ## 0.39.2
18
+
19
+ ### Patch Changes
20
+
21
+ - 328fa0c: Sanitize `--upload-log` logs and auto-reported issue text with `@link-foundation/sensitive-data-sanitizer` (#250) instead of start-command's own rules, which removed content that is not secret (#249). Before, `Authorization:` was masked to the end of the line, which dropped the rest of one-line JSON request bodies. Every URL with a port was masked, and `sk-` matched inside words such as `disk-baseline-`. Now only credentials are masked (`--credentials-only`): values of credential-named environment variables, the gh `hosts.yml` tokens, and `Authorization` schemes with their token. The rest of the line, account details and URLs with ports stay. The log streams through the library CLI from stdin into a private `0600` copy, and invalid UTF-8 bytes are kept. Any failure blocks the upload with a value-free code such as `Log sanitization failed (ERR_BINARY); upload blocked.` `START_SENSITIVE_DATA_SANITIZER` selects another CLI, and `--no-sanitize` is unchanged.
22
+
3
23
  ## 0.39.1
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -41,7 +41,8 @@ checked examples.
41
41
 
42
42
  `-h` also prints usage. Labels persist across Docker resumes. New detached
43
43
  containers support copy-free command handoff; legacy snapshots require capacity
44
- preflight. Log uploads are private and sanitized; manual `--no-sanitize` opts out.
44
+ preflight. Log uploads are private and sanitized with the bundled
45
+ `@link-foundation/sensitive-data-sanitizer`; manual `--no-sanitize` opts out.
45
46
 
46
47
  Snapshot resumes take `--snapshot-wait`, `--snapshot-disk-wait`,
47
48
  `--remove-original-after`, `--snapshot-size-hint` and `--snapshot-prepare`, and
package/eslint.config.mjs CHANGED
@@ -80,6 +80,7 @@ export default [
80
80
  // Web-standard globals Node exposes; used by the repository-level
81
81
  // scripts/ directory, which the root config lints (issue #168).
82
82
  AbortController: 'readonly',
83
+ AbortSignal: 'readonly',
83
84
  URL: 'readonly',
84
85
  setTimeout: 'readonly',
85
86
  clearTimeout: 'readonly',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "start-command",
3
- "version": "0.39.1",
3
+ "version": "0.40.0",
4
4
  "description": "Gamification of coding, execute any command with ability to auto-report issues on GitHub",
5
5
  "main": "src/bin/cli.js",
6
6
  "exports": {
@@ -49,12 +49,12 @@
49
49
  "devDependencies": {
50
50
  "@changesets/cli": "^3.0.3",
51
51
  "@eslint/js": "^10.0.1",
52
- "eslint": "^10.3.0",
52
+ "eslint": "^10.13.0",
53
53
  "eslint-config-prettier": "^10.1.8",
54
- "eslint-plugin-prettier": "^5.5.5",
54
+ "eslint-plugin-prettier": "^5.5.7",
55
55
  "husky": "^9.1.7",
56
- "lint-staged": "^17.0.4",
57
- "prettier": "^3.8.3"
56
+ "lint-staged": "^17.6.0",
57
+ "prettier": "^3.9.10"
58
58
  },
59
59
  "lint-staged": {
60
60
  "*.{js,mjs,cjs}": [
@@ -68,12 +68,12 @@
68
68
  ]
69
69
  },
70
70
  "dependencies": {
71
- "command-stream": "^0.9.4",
72
- "lino-objects-codec": "^0.4.0"
71
+ "@link-foundation/sensitive-data-sanitizer": "^0.12.2",
72
+ "command-stream": "^2.6.0",
73
+ "lino-objects-codec": "^0.9.3"
73
74
  },
74
75
  "overrides": {
75
76
  "brace-expansion": "^5.0.12",
76
- "flatted": "^3.4.2",
77
- "js-yaml": "^4.3.2"
77
+ "flatted": "^3.4.4"
78
78
  }
79
79
  }
package/src/bin/cli.js CHANGED
@@ -814,7 +814,7 @@ async function runDirectWithCommandStream(
814
814
  sessionId
815
815
  ) {
816
816
  // Lazy load command-stream
817
- const { getCommandStream } = require('../lib/command-stream');
817
+ const { getCommandStream, outputText } = require('../lib/command-stream');
818
818
  const { $, raw } = await getCommandStream();
819
819
 
820
820
  // Get the command name (first word of the actual command to execute)
@@ -921,11 +921,13 @@ async function runDirectWithCommandStream(
921
921
  }
922
922
 
923
923
  // Collect output for log
924
- if (result.stdout) {
925
- appendLogFile(logFilePath, result.stdout);
924
+ const stdout = outputText(result.stdout);
925
+ const stderr = outputText(result.stderr);
926
+ if (stdout) {
927
+ appendLogFile(logFilePath, stdout);
926
928
  }
927
- if (result.stderr) {
928
- appendLogFile(logFilePath, result.stderr);
929
+ if (stderr) {
930
+ appendLogFile(logFilePath, stderr);
929
931
  }
930
932
  } catch (err) {
931
933
  exitCode = err.code || 1;
@@ -26,11 +26,24 @@ let commandStream = null;
26
26
  */
27
27
  async function getCommandStream() {
28
28
  if (!commandStream) {
29
- commandStream = await import('command-stream');
29
+ // Execution needs no compatibility layers, terminal renderers or REPL.
30
+ commandStream = await import('command-stream/core');
30
31
  }
31
32
  return commandStream;
32
33
  }
33
34
 
35
+ /**
36
+ * Text of a completed command's stdout or stderr. Since command-stream 2.x
37
+ * these are readable stream snapshots rather than strings, and an empty one
38
+ * is still truthy (#253).
39
+ *
40
+ * @param {unknown} output - result.stdout or result.stderr
41
+ * @returns {string}
42
+ */
43
+ function outputText(output) {
44
+ return output === undefined || output === null ? '' : String(output);
45
+ }
46
+
34
47
  /**
35
48
  * Execute a shell command synchronously and return the result
36
49
  * Uses command-stream's $ function with .sync() for blocking execution.
@@ -54,8 +67,8 @@ async function execCommand(command, options = {}) {
54
67
  const result = $cmd`${command}`.sync();
55
68
 
56
69
  return {
57
- stdout: (result.stdout || '').trim(),
58
- stderr: (result.stderr || '').trim(),
70
+ stdout: outputText(result.stdout).trim(),
71
+ stderr: outputText(result.stderr).trim(),
59
72
  code: resolveChildExitCode(result.code),
60
73
  };
61
74
  } catch (err) {
@@ -91,8 +104,8 @@ async function execCommandAsync(command, options = {}) {
91
104
  const result = await $cmd`${command}`;
92
105
 
93
106
  return {
94
- stdout: (result.stdout || '').trim(),
95
- stderr: (result.stderr || '').trim(),
107
+ stdout: outputText(result.stdout).trim(),
108
+ stderr: outputText(result.stderr).trim(),
96
109
  code: resolveChildExitCode(result.code),
97
110
  };
98
111
  } catch (err) {
@@ -250,6 +263,7 @@ async function runWithHandlers(command, handlers = {}, options = {}) {
250
263
 
251
264
  module.exports = {
252
265
  getCommandStream,
266
+ outputText,
253
267
  execCommand,
254
268
  execCommandAsync,
255
269
  commandExists,
@@ -21,7 +21,7 @@ const { executionAliases, hasUserNames } = require('./execution-identity');
21
21
  function buildChain(records, record) {
22
22
  const seen = new Set([record.uuid]);
23
23
  const chain = [record];
24
- for (let cur = record; cur.continues; ) {
24
+ for (let cur = record; cur.continues;) {
25
25
  const prev = records.find((r) => r.uuid === cur.continues);
26
26
  if (!prev || seen.has(prev.uuid)) {
27
27
  break;
@@ -30,7 +30,7 @@ function buildChain(records, record) {
30
30
  chain.unshift(prev);
31
31
  cur = prev;
32
32
  }
33
- for (let cur = record; ; ) {
33
+ for (let cur = record; ;) {
34
34
  const next = records
35
35
  .filter((r) => r.continues === cur.uuid && !seen.has(r.uuid))
36
36
  .sort((a, b) => Date.parse(b.startTime) - Date.parse(a.startTime))[0];
@@ -245,6 +245,16 @@ class ExecutionRecord {
245
245
  }
246
246
  }
247
247
 
248
+ /**
249
+ * Quote text as a clink reference: `"..."` with inner quotes doubled.
250
+ * clink 4.x rejects backslash escapes inside references.
251
+ * @param {string} text
252
+ * @returns {string}
253
+ */
254
+ function clinkReference(text) {
255
+ return `"${text.replaceAll('"', '""')}"`;
256
+ }
257
+
248
258
  /**
249
259
  * Check if clink is installed
250
260
  * @returns {boolean}
@@ -343,70 +353,69 @@ class ExecutionStore {
343
353
  }
344
354
 
345
355
  /**
346
- * Convert execution record to clink links notation format
347
- * Uses string aliases for readable IDs
356
+ * Convert a record's properties to clink links notation.
357
+ *
358
+ * The record is one link `(uuid: ExecutionRecord uuid)` plus one link per
359
+ * property, `(uuid.key: uuid "key=value")`. Property links have the record
360
+ * as their source, so two records that share a value (both `executing`) are
361
+ * still distinct links: doublets are deduplicated by (source, target), and a
362
+ * shared `(status executing)` link would carry only one record's name. The
363
+ * `key=` prefix keeps the target from being a bare number, which clink 4.x
364
+ * reads as a link address even when quoted (issue #253).
348
365
  * @param {ExecutionRecord} record
349
366
  * @returns {string}
350
367
  */
351
368
  recordToLinksNotation(record) {
352
- // Using clink's string alias feature for readable identifiers
353
- // Format: (uuid: uuid-value) (pid: pid-value) etc.
354
369
  const obj = record.toObject();
355
- const parts = [];
370
+ const links = [];
356
371
 
357
372
  for (const [key, value] of Object.entries(obj)) {
358
373
  if (value !== null && value !== undefined) {
359
- // Escape value properly for links notation
360
- const escapedValue =
374
+ const text =
361
375
  typeof value === 'object' ? JSON.stringify(value) : String(value);
362
- parts.push(`(${record.uuid}.${key}: ${key} "${escapedValue}")`);
376
+ links.push(
377
+ `(${record.uuid}.${key}: ${record.uuid} ${clinkReference(`${key}=${text}`)})`
378
+ );
363
379
  }
364
380
  }
365
381
 
366
- return parts.join(' ');
382
+ return links.join(' ');
383
+ }
384
+
385
+ /** Build the create query using the same property notation as the public helper. */
386
+ buildClinkCreateQuery(record) {
387
+ return `() ((${record.uuid}: ExecutionRecord ${record.uuid}) ${this.recordToLinksNotation(record)})`;
367
388
  }
368
389
 
369
390
  /**
370
- * Build clink query for creating/updating a record
371
- * @param {ExecutionRecord} record
391
+ * Build clink query deleting every property link of a record
392
+ * @param {string} uuid
372
393
  * @returns {string}
373
394
  */
374
- buildClinkCreateQuery(record) {
375
- const obj = record.toObject();
376
- const links = [];
377
-
378
- // Create main record link
379
- links.push(`(${record.uuid}: ExecutionRecord ${record.uuid})`);
380
-
381
- // Create property links
382
- for (const [key, value] of Object.entries(obj)) {
383
- if (value !== null && value !== undefined) {
384
- const escapedValue =
385
- typeof value === 'object' ? JSON.stringify(value) : String(value);
386
- // Using format: (uuid.property: property "value")
387
- links.push(`(${record.uuid}.${key}: ${key} "${escapedValue}")`);
388
- }
389
- }
390
-
391
- // Format: () ((links)) - creates new links
392
- return `() ((${links.join(') (')}))`;
395
+ buildClinkDeletePropertiesQuery(uuid) {
396
+ return `(($id: ${uuid} $value)) ()`;
393
397
  }
394
398
 
395
399
  /**
396
400
  * Execute clink command
397
401
  * @param {string} query
402
+ * @param {string[]} [extraArgs] - flags appended after `--db <path>`
398
403
  * @returns {{success: boolean, output: string}}
399
404
  */
400
- execClink(query) {
405
+ execClink(query, extraArgs = []) {
401
406
  try {
402
407
  // The query embeds record values verbatim; a shell string would let a
403
408
  // single quote in any of them break out of the argument
404
409
  // (CodeQL js/shell-command-constructed-from-input, issue #168).
405
- const result = execFileSync('clink', [query, '--db', this.linksDbPath], {
406
- encoding: 'utf8',
407
- timeout: 10000,
408
- stdio: ['pipe', 'pipe', 'pipe'],
409
- });
410
+ const result = execFileSync(
411
+ 'clink',
412
+ [query, '--db', this.linksDbPath, ...extraArgs],
413
+ {
414
+ encoding: 'utf8',
415
+ timeout: 10000,
416
+ stdio: ['pipe', 'pipe', 'pipe'],
417
+ }
418
+ );
410
419
  return { success: true, output: result };
411
420
  } catch (err) {
412
421
  this.log(`Clink error: ${err.message}`);
@@ -417,15 +426,22 @@ class ExecutionStore {
417
426
  /**
418
427
  * Write a record to the links database using clink
419
428
  * @param {ExecutionRecord} record
429
+ * @param {{isNew?: boolean}} [options] - isNew skips dropping old links
420
430
  * @returns {boolean}
421
431
  */
422
- writeLinksRecord(record) {
432
+ writeLinksRecord(record, { isNew = false } = {}) {
423
433
  if (!this.useLinks) {
424
434
  return false;
425
435
  }
426
436
 
427
- const query = this.buildClinkCreateQuery(record);
428
- const result = this.execClink(query);
437
+ // Replace, not merge: drop the previous property links first. clink
438
+ // reports an error when the record has no links yet, which is harmless.
439
+ if (!isNew) {
440
+ this.execClink(this.buildClinkDeletePropertiesQuery(record.uuid));
441
+ }
442
+ const result = this.execClink(this.buildClinkCreateQuery(record), [
443
+ '--auto-create-missing-references',
444
+ ]);
429
445
 
430
446
  if (result.success) {
431
447
  this.log(`Wrote record ${record.uuid} to links database`);
@@ -444,9 +460,8 @@ class ExecutionStore {
444
460
  return false;
445
461
  }
446
462
 
447
- // Delete all links with this UUID prefix
448
- const query = `(($id: ${uuid} $any)) ()`;
449
- const result = this.execClink(query);
463
+ this.execClink(this.buildClinkDeletePropertiesQuery(uuid));
464
+ const result = this.execClink(`((${uuid}: ExecutionRecord ${uuid})) ()`);
450
465
  return result.success;
451
466
  }
452
467
 
@@ -492,7 +507,7 @@ class ExecutionStore {
492
507
 
493
508
  // Also write to links database if available
494
509
  if (this.useLinks) {
495
- this.writeLinksRecord(record);
510
+ this.writeLinksRecord(record, { isNew: existingIndex < 0 });
496
511
  }
497
512
 
498
513
  return true;
@@ -810,8 +825,10 @@ class ExecutionStore {
810
825
 
811
826
  // Query links database for all ExecutionRecord links
812
827
  try {
828
+ // Without --changes clink prints nothing for a read-only match
813
829
  const queryResult = this.execClink(
814
- `((($id: ExecutionRecord $uuid)) (($id: ExecutionRecord $uuid)))`
830
+ `((($id: ExecutionRecord $uuid)) (($id: ExecutionRecord $uuid)))`,
831
+ ['--changes']
815
832
  );
816
833
 
817
834
  if (queryResult.success) {
@@ -928,6 +945,7 @@ module.exports = {
928
945
  ExecutionStatus,
929
946
  LockManager,
930
947
  isClinkInstalled,
948
+ clinkReference,
931
949
  DEFAULT_APP_FOLDER,
932
950
  LINO_DB_FILE,
933
951
  LINKS_DB_FILE,
@@ -9,7 +9,11 @@ const os = require('os');
9
9
  const fs = require('fs');
10
10
  const path = require('path');
11
11
  const { getTimestamp } = require('./isolation');
12
- const { sanitizeLogToTemp, StreamingSanitizer } = require('./log-sanitizer');
12
+ const {
13
+ SanitizationError,
14
+ sanitizeLogToTemp,
15
+ sanitizeText,
16
+ } = require('./log-sanitizer');
13
17
 
14
18
  /**
15
19
  * Handle command failure - detect repository, upload log, create issue
@@ -296,8 +300,12 @@ function uploadLog(logPath, options = {}) {
296
300
  }
297
301
 
298
302
  return null;
299
- } catch {
300
- console.log('Warning: Log preparation or upload failed; upload blocked.');
303
+ } catch (error) {
304
+ console.log(
305
+ error instanceof SanitizationError
306
+ ? `Warning: ${error.message}`
307
+ : 'Warning: Log preparation or upload failed; upload blocked.'
308
+ );
301
309
  return null;
302
310
  } finally {
303
311
  if (prepared) {
@@ -334,9 +342,7 @@ function canCreateIssue(owner, repo) {
334
342
  */
335
343
  function createIssue(repoInfo, fullCommand, exitCode, logUrl) {
336
344
  try {
337
- fullCommand = new StreamingSanitizer()
338
- .push(Buffer.from(fullCommand), true)
339
- .toString();
345
+ fullCommand = sanitizeText(fullCommand);
340
346
  const title = `Command failed with exit code ${exitCode}: ${fullCommand.substring(0, 50)}${fullCommand.length > 50 ? '...' : ''}`;
341
347
 
342
348
  // Get runtime information