start-command 0.7.0 → 0.7.1

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,17 @@
1
1
  # start-command
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d5a7c66: Fix all --version detection issues
8
+ - Fix screen version detection by capturing stderr
9
+ - Show Bun version instead of Node.js version when running with Bun
10
+ - Show macOS ProductVersion instead of kernel version
11
+ - Fix argument parsing to handle `$ --version --` same as `$ --version`
12
+ - Update all scripts and examples to use Bun instead of Node.js
13
+ - Add comprehensive tests for --version flag
14
+
3
15
  ## 0.7.0
4
16
 
5
17
  ### Minor Changes
package/REQUIREMENTS.md CHANGED
@@ -76,7 +76,7 @@ The `$` command is a CLI tool that wraps any shell command and provides automati
76
76
  - Command that was executed
77
77
  - Exit code
78
78
  - Link to uploaded log
79
- - System information (OS, Node version)
79
+ - System information (OS, Bun/Node.js version)
80
80
  - Timestamp
81
81
  - Print the created issue URL to console
82
82
 
@@ -209,7 +209,8 @@ Repository not detected - automatic issue creation skipped
209
209
 
210
210
  ### Required
211
211
 
212
- - Node.js >= 14.0.0
212
+ - **Bun >= 1.0.0** (primary runtime)
213
+ - Alternatively: Node.js >= 20.0.0 (for compatibility)
213
214
  - `child_process` (built-in)
214
215
  - `os` (built-in)
215
216
  - `fs` (built-in)
@@ -0,0 +1,332 @@
1
+ # Case Study: Issue #22 - Version Detection Issues
2
+
3
+ ## Issue Overview
4
+
5
+ **Issue ID:** #22
6
+ **Title:** --version issues
7
+ **Reported By:** konard
8
+ **Created:** 2025-12-23T17:55:53Z
9
+ **Status:** Open
10
+
11
+ ## Problem Summary
12
+
13
+ The `$ --version` command exhibited multiple issues when run on macOS:
14
+
15
+ 1. **Screen version not detected** - Despite screen being installed, it showed "not installed"
16
+ 2. **Wrong runtime displayed** - Showed Node.js version instead of Bun version
17
+ 3. **Incorrect OS version format** - Showed OS Release (kernel version) instead of macOS version
18
+ 4. **Argument parsing issue** - `$ --version --` resulted in "No command provided" error
19
+
20
+ ## Timeline of Events
21
+
22
+ ### User Environment
23
+
24
+ - **System:** macOS 15.7.2 (ProductVersion)
25
+ - **Kernel:** 24.6.0 (OS Release)
26
+ - **Bun Version:** 1.2.20
27
+ - **Node.js Emulation:** v24.3.0 (provided by Bun)
28
+ - **Architecture:** arm64
29
+ - **Package:** start-command@0.7.0
30
+
31
+ ### Observed Behavior
32
+
33
+ #### Command 1: `$ --version --`
34
+
35
+ ```
36
+ Error: No command provided
37
+ Usage: $ [options] [--] <command> [args...]
38
+ ```
39
+
40
+ **Expected:** Should display version information (same as `$ --version`)
41
+ **Actual:** Treated `--` as command separator and found no command after it
42
+
43
+ #### Command 2: `$ --version`
44
+
45
+ ```
46
+ start-command version: 0.7.0
47
+
48
+ OS: darwin
49
+ OS Release: 24.6.0
50
+ Node Version: v24.3.0
51
+ Architecture: arm64
52
+
53
+ Isolation tools:
54
+ screen: not installed
55
+ tmux: not installed
56
+ docker: Docker version 28.5.1, build e180ab8
57
+ ```
58
+
59
+ **Issues Identified:**
60
+
61
+ 1. Screen shown as "not installed" despite being present
62
+ 2. "Node Version: v24.3.0" when using Bun
63
+ 3. "OS Release: 24.6.0" (kernel) instead of "15.7.2" (macOS version)
64
+
65
+ #### Verification Commands
66
+
67
+ ```bash
68
+ screen -v
69
+ # Output: Screen version 4.00.03 (FAU) 23-Oct-06
70
+
71
+ sw_vers
72
+ # Output:
73
+ # ProductName: macOS
74
+ # ProductVersion: 15.7.2
75
+ # BuildVersion: 24G325
76
+ ```
77
+
78
+ ## Root Cause Analysis
79
+
80
+ ### Issue 1: Screen Version Not Detected
81
+
82
+ **Location:** `src/bin/cli.js:84`
83
+
84
+ **Root Cause:**
85
+
86
+ - Screen outputs version to stderr, not stdout
87
+ - Current implementation uses `execSync()` with default stdio configuration
88
+ - On some systems/versions, screen sends output to stderr
89
+
90
+ **Code Analysis:**
91
+
92
+ ```javascript
93
+ const screenVersion = getToolVersion('screen', '--version');
94
+
95
+ function getToolVersion(toolName, versionFlag) {
96
+ try {
97
+ const result = execSync(`${toolName} ${versionFlag}`, {
98
+ encoding: 'utf8',
99
+ stdio: ['pipe', 'pipe', 'pipe'], // stderr is piped but not captured
100
+ timeout: 5000,
101
+ }).trim();
102
+ // ...
103
+ ```
104
+
105
+ The `execSync()` call captures stdout but the function doesn't merge stderr into the result. On macOS, screen may output to stderr.
106
+
107
+ ### Issue 2: Node.js Version Instead of Bun Version
108
+
109
+ **Location:** `src/bin/cli.js:76`
110
+
111
+ **Root Cause:**
112
+
113
+ - Code uses `process.version` which returns Node.js compatibility version in Bun
114
+ - Bun emulates Node.js v24.3.0 for compatibility
115
+ - Should use `process.versions.bun` or `Bun.version` instead
116
+
117
+ **Code Analysis:**
118
+
119
+ ```javascript
120
+ console.log(`Node Version: ${process.version}`);
121
+ ```
122
+
123
+ **Research Findings:**
124
+
125
+ - `process.version` in Bun → Returns emulated Node.js version (v24.3.0)
126
+ - `process.versions.bun` → Returns actual Bun version (1.2.20)
127
+ - `Bun.version` → Bun-specific API for version
128
+
129
+ **Sources:**
130
+
131
+ - [Bun — Detect the Version at Runtime](https://futurestud.io/tutorials/bun-detect-the-version-at-runtime)
132
+ - [Get the current Bun version - Bun](https://bun.com/docs/guides/util/version)
133
+
134
+ ### Issue 3: Incorrect macOS Version Format
135
+
136
+ **Location:** `src/bin/cli.js:75`
137
+
138
+ **Root Cause:**
139
+
140
+ - Code uses `os.release()` which returns kernel version (24.6.0)
141
+ - Should use `sw_vers -productVersion` for user-facing macOS version (15.7.2)
142
+
143
+ **Code Analysis:**
144
+
145
+ ```javascript
146
+ console.log(`OS Release: ${os.release()}`);
147
+ ```
148
+
149
+ **Kernel vs Product Version:**
150
+
151
+ - `os.release()` → 24.6.0 (Darwin kernel version)
152
+ - `sw_vers -productVersion` → 15.7.2 (macOS product version)
153
+
154
+ **Research Findings:**
155
+ The macOS `sw_vers` command provides user-facing version information:
156
+
157
+ - `sw_vers -productVersion` returns the macOS version (e.g., "15.7.2", "26.0")
158
+ - This is what users recognize as their macOS version
159
+
160
+ **Sources:**
161
+
162
+ - [sw_vers Man Page - macOS - SS64.com](https://ss64.com/mac/sw_vers.html)
163
+ - [Check macOS Latest Version · For Tahoe · 2025](https://mac.install.guide/macos/check-version)
164
+
165
+ ### Issue 4: Argument Parsing for `--version --`
166
+
167
+ **Location:** `src/bin/cli.js:52-55`
168
+
169
+ **Root Cause:**
170
+
171
+ - Version check happens before argument parsing
172
+ - Only checks for exact match: `args.length === 1 && (args[0] === '--version' || args[0] === '-v')`
173
+ - When `--version --` is passed, args = `['--version', '--']`, length is 2, fails the check
174
+ - Falls through to argument parser which treats `--` as separator
175
+
176
+ **Code Analysis:**
177
+
178
+ ```javascript
179
+ if (args.length === 1 && (args[0] === '--version' || args[0] === '-v')) {
180
+ printVersion();
181
+ process.exit(0);
182
+ }
183
+ ```
184
+
185
+ **Expected Behavior:**
186
+
187
+ - `$ --version` → Show version ✓
188
+ - `$ --version --` → Show version (should ignore trailing `--`)
189
+ - `$ --` → "No command provided" error ✓
190
+ - `$` → Show usage ✓
191
+
192
+ ## Proposed Solutions
193
+
194
+ ### Solution 1: Fix Screen Detection
195
+
196
+ Capture both stdout and stderr when detecting tool versions:
197
+
198
+ ```javascript
199
+ function getToolVersion(toolName, versionFlag) {
200
+ try {
201
+ const result = execSync(`${toolName} ${versionFlag} 2>&1`, {
202
+ encoding: 'utf8',
203
+ timeout: 5000,
204
+ }).trim();
205
+ const firstLine = result.split('\n')[0];
206
+ return firstLine;
207
+ } catch {
208
+ return null;
209
+ }
210
+ }
211
+ ```
212
+
213
+ ### Solution 2: Use Bun Version
214
+
215
+ Detect runtime and show appropriate version:
216
+
217
+ ```javascript
218
+ // Detect if running in Bun
219
+ const runtime = typeof Bun !== 'undefined' ? 'Bun' : 'Node.js';
220
+ const runtimeVersion =
221
+ typeof Bun !== 'undefined' ? Bun.version : process.version;
222
+
223
+ console.log(`${runtime} Version: ${runtimeVersion}`);
224
+ ```
225
+
226
+ ### Solution 3: Fix macOS Version Detection
227
+
228
+ Use `sw_vers -productVersion` on macOS:
229
+
230
+ ```javascript
231
+ function getOSVersion() {
232
+ if (process.platform === 'darwin') {
233
+ try {
234
+ return execSync('sw_vers -productVersion', { encoding: 'utf8' }).trim();
235
+ } catch {
236
+ return os.release();
237
+ }
238
+ }
239
+ return os.release();
240
+ }
241
+
242
+ console.log(`OS: ${process.platform}`);
243
+ console.log(`OS Version: ${getOSVersion()}`);
244
+ ```
245
+
246
+ ### Solution 4: Fix Argument Parsing
247
+
248
+ Check for `--version` flag regardless of other arguments:
249
+
250
+ ```javascript
251
+ // Check if --version is present (ignore trailing --)
252
+ const hasVersionFlag = args.includes('--version') || args.includes('-v');
253
+ const isOnlyVersionWithSeparator =
254
+ args.length === 2 &&
255
+ (args[0] === '--version' || args[0] === '-v') &&
256
+ args[1] === '--';
257
+
258
+ if ((args.length === 1 && hasVersionFlag) || isOnlyVersionWithSeparator) {
259
+ printVersion();
260
+ process.exit(0);
261
+ }
262
+ ```
263
+
264
+ ## Implementation Plan
265
+
266
+ 1. **Fix argument parsing** - Handle `--version --` case
267
+ 2. **Fix screen detection** - Capture stderr in version detection
268
+ 3. **Replace Node with Bun** - Detect runtime and show correct version
269
+ 4. **Fix OS version** - Use `sw_vers` on macOS
270
+ 5. **Update REQUIREMENTS.md** - Remove npm references, emphasize Bun-first
271
+ 6. **Add comprehensive tests** - Cover all version scenarios
272
+ 7. **Ensure CI runs tests** - Validate quality
273
+
274
+ ## Testing Strategy
275
+
276
+ ### Test Cases Required
277
+
278
+ 1. **Argument Parsing Tests:**
279
+ - `$ --version` → Shows version
280
+ - `$ -v` → Shows version
281
+ - `$ --version --` → Shows version
282
+ - `$ --` → Error: No command provided
283
+ - `$` → Shows usage
284
+
285
+ 2. **Screen Detection Tests:**
286
+ - When screen installed → Shows version
287
+ - When screen not installed → Shows "not installed"
288
+
289
+ 3. **Runtime Detection Tests:**
290
+ - Running with Bun → Shows "Bun Version: X.X.X"
291
+ - Running with Node → Shows "Node.js Version: vX.X.X"
292
+
293
+ 4. **OS Version Tests:**
294
+ - On macOS → Shows ProductVersion (15.7.2 format)
295
+ - On Linux → Shows kernel version
296
+ - On Windows → Shows kernel version
297
+
298
+ ## Documentation Updates
299
+
300
+ ### REQUIREMENTS.md Changes Needed
301
+
302
+ 1. Replace all "npm install" references with "bun install"
303
+ 2. Update "Node.js >= 14.0.0" to "Bun >= 1.0.0"
304
+ 3. Update system information to show "Bun Version" instead of "Node Version"
305
+ 4. Emphasize Bun-first approach
306
+
307
+ ## Additional Notes
308
+
309
+ - The project uses `#!/usr/bin/env bun` shebang correctly
310
+ - Package scripts still use `node --test` which should be changed to `bun test`
311
+ - All references to npm in documentation should be updated to bun
312
+ - Consider removing npm-specific features if they don't work with bun
313
+
314
+ ## Files to Modify
315
+
316
+ 1. `src/bin/cli.js` - Fix all version detection issues
317
+ 2. `src/lib/args-parser.js` - No changes needed (issue is in cli.js)
318
+ 3. `REQUIREMENTS.md` - Update to Bun-first approach
319
+ 4. `package.json` - Update test script to use bun
320
+ 5. `test/cli.test.js` - Add version detection tests
321
+ 6. New: `test/version.test.js` - Comprehensive version tests
322
+
323
+ ## Success Criteria
324
+
325
+ - ✅ `$ --version --` works same as `$ --version`
326
+ - ✅ Screen version detected correctly when installed
327
+ - ✅ Shows "Bun Version" instead of "Node Version"
328
+ - ✅ macOS shows ProductVersion not kernel version
329
+ - ✅ All tests pass locally
330
+ - ✅ CI tests pass
331
+ - ✅ REQUIREMENTS.md updated
332
+ - ✅ No npm references in documentation
@@ -0,0 +1,12 @@
1
+ {
2
+ "author": {
3
+ "id": "MDQ6VXNlcjE0MzE5MDQ=",
4
+ "is_bot": false,
5
+ "login": "konard",
6
+ "name": "Konstantin Diachenko"
7
+ },
8
+ "body": "```\nkonard@MacBook-Pro-Konstantin ~ % bun install -g start-command \nbun add v1.2.20 (6ad208bc)\n\ninstalled start-command@0.7.0 with binaries:\n - $\n\n1 package installed [2.40s]\nkonard@MacBook-Pro-Konstantin ~ % $ --version -- \nError: No command provided\nUsage: $ [options] [--] <command> [args...]\n $ <command> [args...]\n\nOptions:\n --isolated, -i <environment> Run in isolated environment (screen, tmux, docker)\n --attached, -a Run in attached mode (foreground)\n --detached, -d Run in detached mode (background)\n --session, -s <name> Session name for isolation\n --image <image> Docker image (required for docker isolation)\n --version, -v Show version information\n\nExamples:\n $ echo \"Hello World\"\n $ npm test\n $ --isolated tmux -- npm start\n $ -i screen -d npm start\n $ --isolated docker --image node:20 -- npm install\n\nFeatures:\n - Logs all output to temporary directory\n - Displays timestamps and exit codes\n - Auto-reports failures for NPM packages (when gh is available)\n - Natural language command aliases (via substitutions.lino)\n - Process isolation via screen, tmux, or docker\n\nAlias examples:\n $ install lodash npm package -> npm install lodash\n $ install 4.17.21 version of lodash npm package -> npm install lodash@4.17.21\n $ clone https://github.com/user/repo repository -> git clone https://github.com/user/repo\nkonard@MacBook-Pro-Konstantin ~ % $ --version \nstart-command version: 0.7.0\n\nOS: darwin\nOS Release: 24.6.0\nNode Version: v24.3.0\nArchitecture: arm64\n\nIsolation tools:\n screen: not installed\n tmux: not installed\n docker: Docker version 28.5.1, build e180ab8\nkonard@MacBook-Pro-Konstantin ~ % screen -v\nScreen version 4.00.03 (FAU) 23-Oct-06\nkonard@MacBook-Pro-Konstantin ~ % docker -v\nDocker version 28.5.1, build e180ab8\nkonard@MacBook-Pro-Konstantin ~ % sw_vers\nProductName:\t\tmacOS\nProductVersion:\t\t15.7.2\nBuildVersion:\t\t24G325\nkonard@MacBook-Pro-Konstantin ~ % \n```\n\nThe problems are:\n\n- `screen` tool version was not detected.\n- We use Bun, not Node.js (double check that, and also remove suggestions to install it using npm in the docs. Our tool should be Bun first and Bun only. For all scripts and shebangs we should use bun, not node. So in `--version` there should be bun version, not `node.js` version.\n- OS version detection was wrong.\n- `$ --version --` should work the same as `$ --version`, only `$ --` or `$` should result in `No command provided`.\n\nMake sure we have tests for all these (and these tests should be executed in CI, so we guarantee the quality). Also [REQUIREMENTS.md](https://github.com/link-foundation/start/blob/main/REQUIREMENTS.md) should be updated as needed.\n\nPlease download all logs and data related about the issue to this repository, make sure we compile that data to `./docs/case-studies/issue-{id}` folder, and use it to do deep case study analysis (also make sure to search online for additional facts and data), in which we will reconstruct timeline/sequence of events, find root causes of the problem, and propose possible solutions.",
9
+ "comments": [],
10
+ "createdAt": "2025-12-23T17:55:53Z",
11
+ "title": "--version issues"
12
+ }
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env bun
2
2
  /**
3
3
  * Experiment to test different approaches for running screen in attached mode
4
- * from Node.js without a TTY
4
+ * from Bun without a TTY
5
5
  */
6
6
 
7
7
  const { spawn, spawnSync, execSync } = require('child_process');
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env bun
2
2
  /**
3
3
  * Experiment to test screen's logfile capture functionality
4
4
  * to understand the root cause of issue #15
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env bun
2
2
  /**
3
3
  * Experiment to test different screen invocation modes
4
4
  * This helps understand how screen behaves in different contexts
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "start-command",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Gamification of coding, execute any command with ability to auto-report issues on GitHub",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "$": "./src/bin/cli.js"
8
8
  },
9
9
  "scripts": {
10
- "test": "node --test test/",
10
+ "test": "bun test test/",
11
11
  "lint": "eslint .",
12
12
  "lint:fix": "eslint . --fix",
13
13
  "format": "prettier --write .",
14
14
  "format:check": "prettier --check .",
15
- "check:file-size": "node scripts/check-file-size.mjs",
16
- "check": "npm run lint && npm run format:check && npm run check:file-size",
15
+ "check:file-size": "bun scripts/check-file-size.mjs",
16
+ "check": "bun run lint && bun run format:check && bun run check:file-size",
17
17
  "prepare": "husky || true",
18
18
  "changeset": "changeset",
19
- "changeset:version": "node scripts/changeset-version.mjs",
19
+ "changeset:version": "bun scripts/changeset-version.mjs",
20
20
  "changeset:publish": "changeset publish",
21
21
  "changeset:status": "changeset status --since=origin/main"
22
22
  },
package/src/bin/cli.js CHANGED
@@ -49,7 +49,14 @@ const config = {
49
49
  const args = process.argv.slice(2);
50
50
 
51
51
  // Handle --version flag
52
- if (args.length === 1 && (args[0] === '--version' || args[0] === '-v')) {
52
+ // Support: $ --version, $ -v, $ --version --
53
+ // The trailing -- should be ignored for version check
54
+ const hasVersionFlag =
55
+ args.length >= 1 && (args[0] === '--version' || args[0] === '-v');
56
+ const isVersionOnly =
57
+ args.length === 1 || (args.length === 2 && args[1] === '--');
58
+
59
+ if (hasVersionFlag && isVersionOnly) {
53
60
  printVersion();
54
61
  process.exit(0);
55
62
  }
@@ -70,10 +77,30 @@ function printVersion() {
70
77
  console.log(`start-command version: ${startCommandVersion}`);
71
78
  console.log('');
72
79
 
80
+ // Get runtime information (Bun or Node.js)
81
+ const runtime = typeof Bun !== 'undefined' ? 'Bun' : 'Node.js';
82
+ const runtimeVersion =
83
+ typeof Bun !== 'undefined' ? Bun.version : process.version;
84
+
73
85
  // Get OS information
74
86
  console.log(`OS: ${process.platform}`);
75
- console.log(`OS Release: ${os.release()}`);
76
- console.log(`Node Version: ${process.version}`);
87
+
88
+ // Get OS version (use sw_vers on macOS for user-friendly version)
89
+ let osVersion = os.release();
90
+ if (process.platform === 'darwin') {
91
+ try {
92
+ osVersion = execSync('sw_vers -productVersion', {
93
+ encoding: 'utf8',
94
+ timeout: 5000,
95
+ }).trim();
96
+ } catch {
97
+ // Fallback to kernel version if sw_vers fails
98
+ osVersion = os.release();
99
+ }
100
+ }
101
+
102
+ console.log(`OS Version: ${osVersion}`);
103
+ console.log(`${runtime} Version: ${runtimeVersion}`);
77
104
  console.log(`Architecture: ${process.arch}`);
78
105
  console.log('');
79
106
 
@@ -113,9 +140,10 @@ function printVersion() {
113
140
  */
114
141
  function getToolVersion(toolName, versionFlag) {
115
142
  try {
116
- const result = execSync(`${toolName} ${versionFlag}`, {
143
+ // Redirect stderr to stdout (2>&1) to capture version info from stderr
144
+ // Some tools like screen output version to stderr instead of stdout
145
+ const result = execSync(`${toolName} ${versionFlag} 2>&1`, {
117
146
  encoding: 'utf8',
118
- stdio: ['pipe', 'pipe', 'pipe'],
119
147
  timeout: 5000,
120
148
  }).trim();
121
149
 
@@ -149,10 +177,10 @@ function printUsage() {
149
177
  console.log('');
150
178
  console.log('Examples:');
151
179
  console.log(' $ echo "Hello World"');
152
- console.log(' $ npm test');
153
- console.log(' $ --isolated tmux -- npm start');
154
- console.log(' $ -i screen -d npm start');
155
- console.log(' $ --isolated docker --image node:20 -- npm install');
180
+ console.log(' $ bun test');
181
+ console.log(' $ --isolated tmux -- bun start');
182
+ console.log(' $ -i screen -d bun start');
183
+ console.log(' $ --isolated docker --image oven/bun:latest -- bun install');
156
184
  console.log('');
157
185
  console.log('Features:');
158
186
  console.log(' - Logs all output to temporary directory');
@@ -313,6 +341,11 @@ function runDirect(cmd) {
313
341
  let logContent = '';
314
342
  const startTime = getTimestamp();
315
343
 
344
+ // Get runtime information
345
+ const runtime = typeof Bun !== 'undefined' ? 'Bun' : 'Node.js';
346
+ const runtimeVersion =
347
+ typeof Bun !== 'undefined' ? Bun.version : process.version;
348
+
316
349
  // Log header
317
350
  logContent += `=== Start Command Log ===\n`;
318
351
  logContent += `Timestamp: ${startTime}\n`;
@@ -325,7 +358,7 @@ function runDirect(cmd) {
325
358
  }
326
359
  logContent += `Shell: ${shell}\n`;
327
360
  logContent += `Platform: ${process.platform}\n`;
328
- logContent += `Node Version: ${process.version}\n`;
361
+ logContent += `${runtime} Version: ${runtimeVersion}\n`;
329
362
  logContent += `Working Directory: ${process.cwd()}\n`;
330
363
  logContent += `${'='.repeat(50)}\n\n`;
331
364
 
@@ -474,7 +507,7 @@ function handleFailure(cmdName, fullCommand, exitCode, logPath) {
474
507
  }
475
508
  } else {
476
509
  console.log('gh-upload-log not installed - log upload skipped');
477
- console.log('Install with: npm install -g gh-upload-log');
510
+ console.log('Install with: bun install -g gh-upload-log');
478
511
  }
479
512
 
480
513
  // Check if we can create issues in this repository
@@ -745,6 +778,11 @@ function createIssue(repoInfo, fullCommand, exitCode, logUrl) {
745
778
  try {
746
779
  const title = `Command failed with exit code ${exitCode}: ${fullCommand.substring(0, 50)}${fullCommand.length > 50 ? '...' : ''}`;
747
780
 
781
+ // Get runtime information
782
+ const runtime = typeof Bun !== 'undefined' ? 'Bun' : 'Node.js';
783
+ const runtimeVersion =
784
+ typeof Bun !== 'undefined' ? Bun.version : process.version;
785
+
748
786
  let body = `## Command Execution Failure Report\n\n`;
749
787
  body += `**Command:** \`${fullCommand}\`\n\n`;
750
788
  body += `**Exit Code:** ${exitCode}\n\n`;
@@ -752,7 +790,7 @@ function createIssue(repoInfo, fullCommand, exitCode, logUrl) {
752
790
  body += `### System Information\n\n`;
753
791
  body += `- **Platform:** ${process.platform}\n`;
754
792
  body += `- **OS Release:** ${os.release()}\n`;
755
- body += `- **Node Version:** ${process.version}\n`;
793
+ body += `- **${runtime} Version:** ${runtimeVersion}\n`;
756
794
  body += `- **Architecture:** ${process.arch}\n\n`;
757
795
 
758
796
  if (logUrl) {
package/test/cli.test.js CHANGED
@@ -38,12 +38,15 @@ describe('CLI version flag', () => {
38
38
  );
39
39
  assert.ok(result.stdout.includes('OS:'), 'Should display OS');
40
40
  assert.ok(
41
- result.stdout.includes('OS Release:'),
42
- 'Should display OS Release'
41
+ result.stdout.includes('OS Version:'),
42
+ 'Should display OS Version'
43
43
  );
44
+ // Check for either Bun or Node.js version depending on runtime
45
+ const hasBunVersion = result.stdout.includes('Bun Version:');
46
+ const hasNodeVersion = result.stdout.includes('Node.js Version:');
44
47
  assert.ok(
45
- result.stdout.includes('Node Version:'),
46
- 'Should display Node Version'
48
+ hasBunVersion || hasNodeVersion,
49
+ 'Should display Bun Version or Node.js Version'
47
50
  );
48
51
  assert.ok(
49
52
  result.stdout.includes('Architecture:'),
@@ -0,0 +1,264 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Tests for --version flag behavior
4
+ * Tests for issue #22: --version issues
5
+ */
6
+
7
+ const { describe, it } = require('node:test');
8
+ const assert = require('node:assert');
9
+ const { execSync, spawnSync } = require('child_process');
10
+ const path = require('path');
11
+ const os = require('os');
12
+
13
+ // Path to the CLI
14
+ const cliPath = path.resolve(__dirname, '../src/bin/cli.js');
15
+
16
+ /**
17
+ * Helper to run the CLI command
18
+ */
19
+ function runCli(args) {
20
+ try {
21
+ // Use '--' separator to ensure args are passed to the script, not consumed by bun
22
+ // This is important for testing edge cases like passing '--' as an argument
23
+ const result = spawnSync('bun', [cliPath, '--', ...args], {
24
+ encoding: 'utf8',
25
+ timeout: 5000,
26
+ env: {
27
+ ...process.env,
28
+ START_DISABLE_AUTO_ISSUE: '1',
29
+ START_DISABLE_LOG_UPLOAD: '1',
30
+ },
31
+ });
32
+ return {
33
+ stdout: result.stdout || '',
34
+ stderr: result.stderr || '',
35
+ exitCode: result.status,
36
+ error: result.error,
37
+ };
38
+ } catch (error) {
39
+ return {
40
+ stdout: '',
41
+ stderr: error.message,
42
+ exitCode: 1,
43
+ error,
44
+ };
45
+ }
46
+ }
47
+
48
+ describe('Version Flag Tests', () => {
49
+ describe('Basic version flag', () => {
50
+ it('should show version with --version', () => {
51
+ const result = runCli(['--version']);
52
+ assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
53
+ assert.match(
54
+ result.stdout,
55
+ /start-command version:/,
56
+ 'Should show start-command version'
57
+ );
58
+ });
59
+
60
+ it('should show version with -v', () => {
61
+ const result = runCli(['-v']);
62
+ assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
63
+ assert.match(
64
+ result.stdout,
65
+ /start-command version:/,
66
+ 'Should show start-command version'
67
+ );
68
+ });
69
+
70
+ it('should show version with --version -- (trailing separator)', () => {
71
+ const result = runCli(['--version', '--']);
72
+ assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
73
+ assert.match(
74
+ result.stdout,
75
+ /start-command version:/,
76
+ 'Should show start-command version with trailing --'
77
+ );
78
+ assert.doesNotMatch(
79
+ result.stderr,
80
+ /No command provided/,
81
+ 'Should not show "No command provided" error'
82
+ );
83
+ });
84
+ });
85
+
86
+ describe('Runtime detection', () => {
87
+ it('should show Bun version when running with Bun', () => {
88
+ const result = runCli(['--version']);
89
+ assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
90
+
91
+ // When running with Bun, should show "Bun Version"
92
+ if (typeof Bun !== 'undefined') {
93
+ assert.match(
94
+ result.stdout,
95
+ /Bun Version:/,
96
+ 'Should show "Bun Version:" when running with Bun'
97
+ );
98
+ assert.doesNotMatch(
99
+ result.stdout,
100
+ /Node\.js Version:/,
101
+ 'Should not show "Node.js Version:" when running with Bun'
102
+ );
103
+ } else {
104
+ // When running with Node.js, should show "Node.js Version"
105
+ assert.match(
106
+ result.stdout,
107
+ /Node\.js Version:/,
108
+ 'Should show "Node.js Version:" when running with Node.js'
109
+ );
110
+ }
111
+ });
112
+ });
113
+
114
+ describe('OS version detection', () => {
115
+ it('should show OS information', () => {
116
+ const result = runCli(['--version']);
117
+ assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
118
+ assert.match(result.stdout, /OS:/, 'Should show OS');
119
+ assert.match(result.stdout, /OS Version:/, 'Should show OS Version');
120
+ });
121
+
122
+ it('should show macOS ProductVersion on darwin', () => {
123
+ const result = runCli(['--version']);
124
+ assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
125
+
126
+ if (process.platform === 'darwin') {
127
+ // Get the actual macOS version using sw_vers
128
+ const macOSVersion = execSync('sw_vers -productVersion', {
129
+ encoding: 'utf8',
130
+ }).trim();
131
+
132
+ // Version output should contain the ProductVersion, not the kernel version
133
+ assert.match(
134
+ result.stdout,
135
+ new RegExp(`OS Version: ${macOSVersion.replace('.', '\\.')}`),
136
+ `Should show macOS ProductVersion (${macOSVersion}), not kernel version`
137
+ );
138
+
139
+ // Should NOT show kernel version (which starts with 2x on modern macOS)
140
+ const kernelVersion = os.release();
141
+ if (kernelVersion.startsWith('2')) {
142
+ assert.doesNotMatch(
143
+ result.stdout,
144
+ new RegExp(`OS Version: ${kernelVersion.replace('.', '\\.')}`),
145
+ `Should not show kernel version (${kernelVersion})`
146
+ );
147
+ }
148
+ }
149
+ });
150
+ });
151
+
152
+ describe('Tool version detection', () => {
153
+ it('should detect screen version if installed', () => {
154
+ const result = runCli(['--version']);
155
+ assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
156
+
157
+ // Check if screen is actually installed
158
+ try {
159
+ const screenVersion = execSync('screen --version 2>&1', {
160
+ encoding: 'utf8',
161
+ timeout: 5000,
162
+ });
163
+
164
+ if (screenVersion) {
165
+ // If screen is installed, it should not show "not installed"
166
+ assert.doesNotMatch(
167
+ result.stdout,
168
+ /screen: not installed/,
169
+ 'Should not show "screen: not installed" when screen is available'
170
+ );
171
+ assert.match(
172
+ result.stdout,
173
+ /screen:/,
174
+ 'Should show screen version info'
175
+ );
176
+ }
177
+ } catch {
178
+ // Screen is not installed, should show "not installed"
179
+ assert.match(
180
+ result.stdout,
181
+ /screen: not installed/,
182
+ 'Should show "screen: not installed" when screen is unavailable'
183
+ );
184
+ }
185
+ });
186
+
187
+ it('should detect tmux version if installed', () => {
188
+ const result = runCli(['--version']);
189
+ assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
190
+
191
+ // Check if tmux is actually installed
192
+ try {
193
+ const tmuxVersion = execSync('tmux -V 2>&1', {
194
+ encoding: 'utf8',
195
+ timeout: 5000,
196
+ });
197
+
198
+ if (tmuxVersion) {
199
+ // If tmux is installed, it should not show "not installed"
200
+ assert.doesNotMatch(
201
+ result.stdout,
202
+ /tmux: not installed/,
203
+ 'Should not show "tmux: not installed" when tmux is available'
204
+ );
205
+ }
206
+ } catch {
207
+ // tmux is not installed, should show "not installed"
208
+ assert.match(
209
+ result.stdout,
210
+ /tmux: not installed/,
211
+ 'Should show "tmux: not installed" when tmux is unavailable'
212
+ );
213
+ }
214
+ });
215
+
216
+ it('should detect docker version if installed', () => {
217
+ const result = runCli(['--version']);
218
+ assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
219
+
220
+ // Check if docker is actually installed
221
+ try {
222
+ const dockerVersion = execSync('docker --version 2>&1', {
223
+ encoding: 'utf8',
224
+ timeout: 5000,
225
+ });
226
+
227
+ if (dockerVersion) {
228
+ // If docker is installed, it should not show "not installed"
229
+ assert.doesNotMatch(
230
+ result.stdout,
231
+ /docker: not installed/,
232
+ 'Should not show "docker: not installed" when docker is available'
233
+ );
234
+ }
235
+ } catch {
236
+ // docker is not installed, should show "not installed"
237
+ assert.match(
238
+ result.stdout,
239
+ /docker: not installed/,
240
+ 'Should show "docker: not installed" when docker is unavailable'
241
+ );
242
+ }
243
+ });
244
+ });
245
+
246
+ describe('Error cases', () => {
247
+ it('should error with "No command provided" for $ --', () => {
248
+ const result = runCli(['--']);
249
+ assert.strictEqual(result.exitCode, 1, 'Exit code should be 1');
250
+ const output = result.stdout + result.stderr;
251
+ assert.match(
252
+ output,
253
+ /No command provided/,
254
+ 'Should show "No command provided" error for --'
255
+ );
256
+ });
257
+
258
+ it('should error with "No command provided" for no args', () => {
259
+ const result = runCli([]);
260
+ assert.strictEqual(result.exitCode, 0, 'Should show usage and exit 0');
261
+ assert.match(result.stdout, /Usage:/, 'Should show usage message');
262
+ });
263
+ });
264
+ });