@agentuity/cli 0.1.40 → 0.1.42

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.
Files changed (250) hide show
  1. package/bin/cli.ts +0 -2
  2. package/dist/agent-detection.d.ts.map +1 -1
  3. package/dist/agent-detection.js +11 -3
  4. package/dist/agent-detection.js.map +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +9 -5
  7. package/dist/cli.js.map +1 -1
  8. package/dist/cmd/ai/index.d.ts.map +1 -1
  9. package/dist/cmd/ai/index.js +1 -8
  10. package/dist/cmd/ai/index.js.map +1 -1
  11. package/dist/cmd/ai/prompt/version.js +1 -1
  12. package/dist/cmd/ai/prompt/version.js.map +1 -1
  13. package/dist/cmd/auth/api.d.ts.map +1 -1
  14. package/dist/cmd/auth/api.js +4 -1
  15. package/dist/cmd/auth/api.js.map +1 -1
  16. package/dist/cmd/auth/org/index.d.ts.map +1 -1
  17. package/dist/cmd/auth/org/index.js +8 -2
  18. package/dist/cmd/auth/org/index.js.map +1 -1
  19. package/dist/cmd/auth/ssh/api.js +2 -2
  20. package/dist/cmd/auth/ssh/api.js.map +1 -1
  21. package/dist/cmd/build/ast.d.ts.map +1 -1
  22. package/dist/cmd/build/ast.js +14 -13
  23. package/dist/cmd/build/ast.js.map +1 -1
  24. package/dist/cmd/build/entry-generator.d.ts.map +1 -1
  25. package/dist/cmd/build/entry-generator.js +19 -0
  26. package/dist/cmd/build/entry-generator.js.map +1 -1
  27. package/dist/cmd/build/patch/index.d.ts.map +1 -1
  28. package/dist/cmd/build/patch/index.js +3 -0
  29. package/dist/cmd/build/patch/index.js.map +1 -1
  30. package/dist/cmd/build/vite/index.d.ts +1 -0
  31. package/dist/cmd/build/vite/index.d.ts.map +1 -1
  32. package/dist/cmd/build/vite/index.js +1 -0
  33. package/dist/cmd/build/vite/index.js.map +1 -1
  34. package/dist/cmd/build/vite/public-asset-path-plugin.d.ts +34 -0
  35. package/dist/cmd/build/vite/public-asset-path-plugin.d.ts.map +1 -0
  36. package/dist/cmd/build/vite/public-asset-path-plugin.js +107 -0
  37. package/dist/cmd/build/vite/public-asset-path-plugin.js.map +1 -0
  38. package/dist/cmd/build/vite/registry-generator.d.ts.map +1 -1
  39. package/dist/cmd/build/vite/registry-generator.js +14 -5
  40. package/dist/cmd/build/vite/registry-generator.js.map +1 -1
  41. package/dist/cmd/build/vite/route-discovery.js +1 -1
  42. package/dist/cmd/build/vite/route-discovery.js.map +1 -1
  43. package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
  44. package/dist/cmd/build/vite/vite-asset-server-config.js +11 -2
  45. package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
  46. package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
  47. package/dist/cmd/build/vite/vite-builder.js +3 -0
  48. package/dist/cmd/build/vite/vite-builder.js.map +1 -1
  49. package/dist/cmd/canary/index.d.ts.map +1 -1
  50. package/dist/cmd/canary/index.js +9 -1
  51. package/dist/cmd/canary/index.js.map +1 -1
  52. package/dist/cmd/cloud/db/create.d.ts.map +1 -1
  53. package/dist/cmd/cloud/db/create.js +2 -2
  54. package/dist/cmd/cloud/db/create.js.map +1 -1
  55. package/dist/cmd/cloud/db/delete.d.ts.map +1 -1
  56. package/dist/cmd/cloud/db/delete.js +2 -2
  57. package/dist/cmd/cloud/db/delete.js.map +1 -1
  58. package/dist/cmd/cloud/deploy-fork.d.ts.map +1 -1
  59. package/dist/cmd/cloud/deploy-fork.js +68 -0
  60. package/dist/cmd/cloud/deploy-fork.js.map +1 -1
  61. package/dist/cmd/cloud/env/import.d.ts.map +1 -1
  62. package/dist/cmd/cloud/env/import.js +4 -1
  63. package/dist/cmd/cloud/env/import.js.map +1 -1
  64. package/dist/cmd/cloud/env/list.d.ts.map +1 -1
  65. package/dist/cmd/cloud/env/list.js +4 -1
  66. package/dist/cmd/cloud/env/list.js.map +1 -1
  67. package/dist/cmd/cloud/env/push.d.ts.map +1 -1
  68. package/dist/cmd/cloud/env/push.js +4 -1
  69. package/dist/cmd/cloud/env/push.js.map +1 -1
  70. package/dist/cmd/cloud/region/index.js +1 -1
  71. package/dist/cmd/cloud/region/index.js.map +1 -1
  72. package/dist/cmd/cloud/sandbox/snapshot/build.d.ts.map +1 -1
  73. package/dist/cmd/cloud/sandbox/snapshot/build.js +22 -10
  74. package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
  75. package/dist/cmd/cloud/sandbox/snapshot/get.d.ts.map +1 -1
  76. package/dist/cmd/cloud/sandbox/snapshot/get.js +12 -2
  77. package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
  78. package/dist/cmd/cloud/storage/create.d.ts.map +1 -1
  79. package/dist/cmd/cloud/storage/create.js +2 -2
  80. package/dist/cmd/cloud/storage/create.js.map +1 -1
  81. package/dist/cmd/cloud/storage/delete.d.ts.map +1 -1
  82. package/dist/cmd/cloud/storage/delete.js +2 -2
  83. package/dist/cmd/cloud/storage/delete.js.map +1 -1
  84. package/dist/cmd/cloud/stream/get.js +7 -7
  85. package/dist/cmd/cloud/stream/get.js.map +1 -1
  86. package/dist/cmd/cloud/stream/list.d.ts.map +1 -1
  87. package/dist/cmd/cloud/stream/list.js +9 -6
  88. package/dist/cmd/cloud/stream/list.js.map +1 -1
  89. package/dist/cmd/dev/download.d.ts.map +1 -1
  90. package/dist/cmd/dev/download.js +9 -2
  91. package/dist/cmd/dev/download.js.map +1 -1
  92. package/dist/cmd/dev/index.js +1 -1
  93. package/dist/cmd/dev/index.js.map +1 -1
  94. package/dist/cmd/git/account/add.d.ts.map +1 -1
  95. package/dist/cmd/git/account/add.js +4 -3
  96. package/dist/cmd/git/account/add.js.map +1 -1
  97. package/dist/cmd/git/link.js +2 -2
  98. package/dist/cmd/git/link.js.map +1 -1
  99. package/dist/cmd/git/list.d.ts.map +1 -1
  100. package/dist/cmd/git/list.js +3 -2
  101. package/dist/cmd/git/list.js.map +1 -1
  102. package/dist/cmd/project/auth/init.js +1 -1
  103. package/dist/cmd/project/auth/init.js.map +1 -1
  104. package/dist/cmd/project/auth/shared.d.ts.map +1 -1
  105. package/dist/cmd/project/auth/shared.js +8 -3
  106. package/dist/cmd/project/auth/shared.js.map +1 -1
  107. package/dist/cmd/project/delete.d.ts.map +1 -1
  108. package/dist/cmd/project/delete.js +3 -2
  109. package/dist/cmd/project/delete.js.map +1 -1
  110. package/dist/cmd/project/reconcile.d.ts.map +1 -1
  111. package/dist/cmd/project/reconcile.js +9 -5
  112. package/dist/cmd/project/reconcile.js.map +1 -1
  113. package/dist/cmd/project/template-flow.d.ts.map +1 -1
  114. package/dist/cmd/project/template-flow.js +15 -5
  115. package/dist/cmd/project/template-flow.js.map +1 -1
  116. package/dist/config.d.ts.map +1 -1
  117. package/dist/config.js +3 -2
  118. package/dist/config.js.map +1 -1
  119. package/dist/domain.d.ts.map +1 -1
  120. package/dist/domain.js +4 -3
  121. package/dist/domain.js.map +1 -1
  122. package/dist/internal-logger.d.ts.map +1 -1
  123. package/dist/internal-logger.js +3 -2
  124. package/dist/internal-logger.js.map +1 -1
  125. package/dist/repl.d.ts.map +1 -1
  126. package/dist/repl.js +31 -14
  127. package/dist/repl.js.map +1 -1
  128. package/dist/schema-parser.d.ts.map +1 -1
  129. package/dist/schema-parser.js +4 -1
  130. package/dist/schema-parser.js.map +1 -1
  131. package/dist/sound.d.ts.map +1 -1
  132. package/dist/sound.js +2 -1
  133. package/dist/sound.js.map +1 -1
  134. package/dist/steps.d.ts.map +1 -1
  135. package/dist/steps.js +13 -6
  136. package/dist/steps.js.map +1 -1
  137. package/dist/terminal.js +2 -0
  138. package/dist/terminal.js.map +1 -1
  139. package/dist/tsc-output-parser.d.ts +3 -0
  140. package/dist/tsc-output-parser.d.ts.map +1 -1
  141. package/dist/tsc-output-parser.js +32 -9
  142. package/dist/tsc-output-parser.js.map +1 -1
  143. package/dist/tui/prompt.d.ts.map +1 -1
  144. package/dist/tui/prompt.js +6 -2
  145. package/dist/tui/prompt.js.map +1 -1
  146. package/dist/tui.d.ts.map +1 -1
  147. package/dist/tui.js +26 -15
  148. package/dist/tui.js.map +1 -1
  149. package/dist/typescript-errors.d.ts.map +1 -1
  150. package/dist/typescript-errors.js +5 -2
  151. package/dist/typescript-errors.js.map +1 -1
  152. package/dist/utils/date.d.ts.map +1 -1
  153. package/dist/utils/date.js +5 -1
  154. package/dist/utils/date.js.map +1 -1
  155. package/dist/utils/deps.d.ts.map +1 -1
  156. package/dist/utils/deps.js +5 -3
  157. package/dist/utils/deps.js.map +1 -1
  158. package/dist/utils/detectSubagent.js +1 -1
  159. package/dist/utils/detectSubagent.js.map +1 -1
  160. package/package.json +6 -6
  161. package/src/agent-detection.ts +12 -3
  162. package/src/cli.ts +9 -5
  163. package/src/cmd/ai/index.ts +1 -8
  164. package/src/cmd/ai/prompt/version.ts +1 -1
  165. package/src/cmd/auth/api.ts +4 -1
  166. package/src/cmd/auth/org/index.ts +8 -2
  167. package/src/cmd/auth/ssh/api.ts +2 -2
  168. package/src/cmd/build/ast.ts +14 -13
  169. package/src/cmd/build/entry-generator.ts +19 -0
  170. package/src/cmd/build/patch/index.ts +3 -0
  171. package/src/cmd/build/vite/index.ts +1 -0
  172. package/src/cmd/build/vite/public-asset-path-plugin.ts +137 -0
  173. package/src/cmd/build/vite/registry-generator.ts +14 -5
  174. package/src/cmd/build/vite/route-discovery.ts +1 -1
  175. package/src/cmd/build/vite/vite-asset-server-config.ts +13 -4
  176. package/src/cmd/build/vite/vite-builder.ts +3 -0
  177. package/src/cmd/canary/index.ts +9 -1
  178. package/src/cmd/cloud/db/create.ts +16 -17
  179. package/src/cmd/cloud/db/delete.ts +19 -20
  180. package/src/cmd/cloud/deploy-fork.ts +75 -0
  181. package/src/cmd/cloud/env/import.ts +6 -3
  182. package/src/cmd/cloud/env/list.ts +11 -9
  183. package/src/cmd/cloud/env/push.ts +6 -3
  184. package/src/cmd/cloud/region/index.ts +3 -3
  185. package/src/cmd/cloud/sandbox/snapshot/build.ts +42 -33
  186. package/src/cmd/cloud/sandbox/snapshot/get.ts +21 -15
  187. package/src/cmd/cloud/storage/create.ts +16 -17
  188. package/src/cmd/cloud/storage/delete.ts +19 -20
  189. package/src/cmd/cloud/stream/get.ts +7 -7
  190. package/src/cmd/cloud/stream/list.ts +9 -6
  191. package/src/cmd/dev/download.ts +10 -2
  192. package/src/cmd/dev/index.ts +4 -4
  193. package/src/cmd/git/account/add.ts +5 -4
  194. package/src/cmd/git/link.ts +2 -2
  195. package/src/cmd/git/list.ts +7 -6
  196. package/src/cmd/project/auth/init.ts +6 -6
  197. package/src/cmd/project/auth/shared.ts +8 -3
  198. package/src/cmd/project/delete.ts +3 -2
  199. package/src/cmd/project/reconcile.ts +9 -5
  200. package/src/cmd/project/template-flow.ts +15 -5
  201. package/src/config.ts +3 -2
  202. package/src/domain.ts +4 -3
  203. package/src/internal-logger.ts +3 -2
  204. package/src/repl.ts +27 -14
  205. package/src/schema-parser.ts +4 -1
  206. package/src/sound.ts +2 -1
  207. package/src/steps.ts +11 -6
  208. package/src/terminal.ts +2 -1
  209. package/src/tsc-output-parser.ts +61 -38
  210. package/src/tui/prompt.ts +6 -2
  211. package/src/tui.ts +26 -17
  212. package/src/typescript-errors.ts +5 -2
  213. package/src/utils/date.ts +5 -1
  214. package/src/utils/deps.ts +5 -3
  215. package/src/utils/detectSubagent.ts +1 -1
  216. package/dist/cmd/ai/cadence/index.d.ts +0 -3
  217. package/dist/cmd/ai/cadence/index.d.ts.map +0 -1
  218. package/dist/cmd/ai/cadence/index.js +0 -35
  219. package/dist/cmd/ai/cadence/index.js.map +0 -1
  220. package/dist/cmd/ai/cadence/list.d.ts +0 -3
  221. package/dist/cmd/ai/cadence/list.d.ts.map +0 -1
  222. package/dist/cmd/ai/cadence/list.js +0 -167
  223. package/dist/cmd/ai/cadence/list.js.map +0 -1
  224. package/dist/cmd/ai/cadence/pause.d.ts +0 -3
  225. package/dist/cmd/ai/cadence/pause.d.ts.map +0 -1
  226. package/dist/cmd/ai/cadence/pause.js +0 -103
  227. package/dist/cmd/ai/cadence/pause.js.map +0 -1
  228. package/dist/cmd/ai/cadence/resume.d.ts +0 -3
  229. package/dist/cmd/ai/cadence/resume.d.ts.map +0 -1
  230. package/dist/cmd/ai/cadence/resume.js +0 -106
  231. package/dist/cmd/ai/cadence/resume.js.map +0 -1
  232. package/dist/cmd/ai/cadence/status.d.ts +0 -3
  233. package/dist/cmd/ai/cadence/status.d.ts.map +0 -1
  234. package/dist/cmd/ai/cadence/status.js +0 -129
  235. package/dist/cmd/ai/cadence/status.js.map +0 -1
  236. package/dist/cmd/ai/cadence/stop.d.ts +0 -3
  237. package/dist/cmd/ai/cadence/stop.d.ts.map +0 -1
  238. package/dist/cmd/ai/cadence/stop.js +0 -107
  239. package/dist/cmd/ai/cadence/stop.js.map +0 -1
  240. package/dist/cmd/ai/cadence/util.d.ts +0 -44
  241. package/dist/cmd/ai/cadence/util.d.ts.map +0 -1
  242. package/dist/cmd/ai/cadence/util.js +0 -52
  243. package/dist/cmd/ai/cadence/util.js.map +0 -1
  244. package/src/cmd/ai/cadence/index.ts +0 -36
  245. package/src/cmd/ai/cadence/list.ts +0 -183
  246. package/src/cmd/ai/cadence/pause.ts +0 -119
  247. package/src/cmd/ai/cadence/resume.ts +0 -124
  248. package/src/cmd/ai/cadence/status.ts +0 -141
  249. package/src/cmd/ai/cadence/stop.ts +0 -124
  250. package/src/cmd/ai/cadence/util.ts +0 -86
@@ -434,12 +434,13 @@ export function getLatestLogSession(): string | null {
434
434
  const entries = readdirSync(logsDir, { withFileTypes: true });
435
435
  const dirs = entries.filter((e) => e.isDirectory()).map((e) => e.name);
436
436
 
437
- if (dirs.length === 0) {
437
+ const firstDir = dirs[0];
438
+ if (!firstDir) {
438
439
  return null;
439
440
  }
440
441
 
441
442
  // Return the first directory (should be the only one due to cleanup)
442
- return join(logsDir, dirs[0]);
443
+ return join(logsDir, firstDir);
443
444
  } catch {
444
445
  return null;
445
446
  }
package/src/repl.ts CHANGED
@@ -184,6 +184,7 @@ function parseCommandLine(line: string): ParsedCommand {
184
184
  // Parse remaining tokens into args and options
185
185
  for (let i = 1; i < tokens.length; i++) {
186
186
  const token = tokens[i];
187
+ if (token === undefined) continue;
187
188
 
188
189
  if (token.startsWith('--')) {
189
190
  // Long option: --name=value or --flag
@@ -194,8 +195,9 @@ function parseCommandLine(line: string): ParsedCommand {
194
195
  options[name.slice(0, eqIndex)] = name.slice(eqIndex + 1);
195
196
  } else {
196
197
  // Check if next token is a value
197
- if (i + 1 < tokens.length && !tokens[i + 1].startsWith('-')) {
198
- options[name] = tokens[i + 1];
198
+ const nextToken = tokens[i + 1];
199
+ if (i + 1 < tokens.length && nextToken !== undefined && !nextToken.startsWith('-')) {
200
+ options[name] = nextToken;
199
201
  i++;
200
202
  } else {
201
203
  options[name] = true;
@@ -206,8 +208,9 @@ function parseCommandLine(line: string): ParsedCommand {
206
208
  const name = token.slice(1);
207
209
 
208
210
  // Check if next token is a value
209
- if (i + 1 < tokens.length && !tokens[i + 1].startsWith('-')) {
210
- options[name] = tokens[i + 1];
211
+ const nextToken = tokens[i + 1];
212
+ if (i + 1 < tokens.length && nextToken !== undefined && !nextToken.startsWith('-')) {
213
+ options[name] = nextToken;
211
214
  i++;
212
215
  } else {
213
216
  options[name] = true;
@@ -603,7 +606,7 @@ function getAutocompleteMatches(
603
606
  if (!buffer.trim()) return [];
604
607
 
605
608
  const tokens = buffer.trim().split(/\s+/);
606
- const firstToken = tokens[0].toLowerCase();
609
+ const firstToken = tokens[0]?.toLowerCase() ?? '';
607
610
 
608
611
  // If we're typing the first word (no trailing space), suggest commands
609
612
  if (tokens.length === 1 && buffer === buffer.trimEnd()) {
@@ -623,7 +626,7 @@ function getAutocompleteMatches(
623
626
  if (tokens.length === 2 && buffer === buffer.trimEnd() && commandMap) {
624
627
  const cmd = commandMap.get(firstToken);
625
628
  if (cmd?.subcommands) {
626
- const subToken = tokens[1].toLowerCase();
629
+ const subToken = tokens[1]?.toLowerCase() ?? '';
627
630
  return cmd.subcommands
628
631
  .filter((sub) => sub.name.startsWith(subToken) && sub.name !== subToken)
629
632
  .map((sub) => sub.name);
@@ -647,8 +650,10 @@ function getAutocompleteSuggestion(
647
650
  if (matches.length === 0) return '';
648
651
 
649
652
  const selectedMatch = matches[cycleIndex % matches.length];
653
+ if (selectedMatch === undefined) return '';
654
+
650
655
  const tokens = buffer.trim().split(/\s+/);
651
- const firstToken = tokens[0].toLowerCase();
656
+ const firstToken = tokens[0]?.toLowerCase() ?? '';
652
657
 
653
658
  // Typing first word (command name)
654
659
  if (tokens.length === 1 && buffer === buffer.trimEnd()) {
@@ -675,7 +680,7 @@ function getAutocompleteSuggestion(
675
680
  // Typing subcommand name
676
681
  if (tokens.length === 2 && buffer === buffer.trimEnd()) {
677
682
  const cmd = commandMap.get(firstToken);
678
- const subToken = tokens[1];
683
+ const subToken = tokens[1] ?? '';
679
684
  const subcommand = cmd?.subcommands?.find((sub) => sub.name === selectedMatch);
680
685
 
681
686
  let suggestion = selectedMatch.slice(subToken.length);
@@ -791,7 +796,7 @@ class ActivityIndicator {
791
796
  }
792
797
 
793
798
  private draw() {
794
- const frame = this.frames[this.currentFrame];
799
+ const frame = this.frames[this.currentFrame] ?? this.frames[0] ?? '⠋';
795
800
  // Clear line, draw spinner, stay on same line
796
801
  process.stdout.write('\r\x1b[K'); // Clear line from cursor
797
802
  process.stdout.write(`${tui.muted(frame)} ${tui.muted(this.message)}...`);
@@ -855,6 +860,7 @@ async function showCommandPicker(
855
860
  // Draw commands
856
861
  for (let i = 0; i < commands.length; i++) {
857
862
  const cmd = commands[i];
863
+ if (cmd === undefined) continue;
858
864
  const isSelected = i === selectedIndex;
859
865
  const prefix = isSelected ? '▶ ' : ' ';
860
866
  const style = isSelected ? '\x1b[7m' : ''; // Reverse video for selected
@@ -913,7 +919,11 @@ async function showCommandPicker(
913
919
  const selected = commands[selectedIndex];
914
920
  cleanup();
915
921
  clearPicker();
916
- resolve(selected.name + (selected.argHint ? ' ' : ''));
922
+ if (selected) {
923
+ resolve(selected.name + (selected.argHint ? ' ' : ''));
924
+ } else {
925
+ resolve(null);
926
+ }
917
927
  return;
918
928
  }
919
929
 
@@ -957,6 +967,7 @@ function applySyntaxHighlighting(buffer: string, commands: string[]): string {
957
967
 
958
968
  for (let i = 0; i < tokens.length; i++) {
959
969
  const token = tokens[i];
970
+ if (token === undefined) continue;
960
971
 
961
972
  // Skip whitespace
962
973
  if (/^\s+$/.test(token)) {
@@ -1018,7 +1029,8 @@ async function readLine(
1018
1029
 
1019
1030
  const searchHistory = (query: string, startFrom: number): number => {
1020
1031
  for (let i = startFrom - 1; i >= 0; i--) {
1021
- if (history[i].toLowerCase().includes(query.toLowerCase())) {
1032
+ const historyEntry = history[i];
1033
+ if (historyEntry !== undefined && historyEntry.toLowerCase().includes(query.toLowerCase())) {
1022
1034
  return i;
1023
1035
  }
1024
1036
  }
@@ -1057,7 +1069,8 @@ async function readLine(
1057
1069
  }
1058
1070
  const linePrompt = currentLineIndex === 0 ? prompt : '... ';
1059
1071
  process.stdout.write('\r');
1060
- process.stdout.write(linePrompt + lines[currentLineIndex].slice(0, cursorPos));
1072
+ const currentLine = lines[currentLineIndex] ?? '';
1073
+ process.stdout.write(linePrompt + currentLine.slice(0, cursorPos));
1061
1074
  } else {
1062
1075
  // Single-line mode (original behavior)
1063
1076
  process.stdout.write('\r\x1b[K');
@@ -1282,7 +1295,7 @@ async function readLine(
1282
1295
  lines.push('');
1283
1296
  currentLineIndex++;
1284
1297
  cursorPos = 0;
1285
- buffer = lines[currentLineIndex];
1298
+ buffer = lines[currentLineIndex] ?? '';
1286
1299
  process.stdout.write('\n');
1287
1300
  process.stdout.write('... ');
1288
1301
  return;
@@ -1293,7 +1306,7 @@ async function readLine(
1293
1306
  if (searchMode) {
1294
1307
  // Accept search result
1295
1308
  if (searchResultIndex >= 0) {
1296
- buffer = history[searchResultIndex];
1309
+ buffer = history[searchResultIndex] ?? '';
1297
1310
  }
1298
1311
  searchMode = false;
1299
1312
  process.stdout.write('\n');
@@ -373,7 +373,10 @@ export function buildValidationInput(
373
373
  if (schemas.args) {
374
374
  const parsed = parseArgsSchema(schemas.args);
375
375
  for (let i = 0; i < parsed.names.length; i++) {
376
- result.args[parsed.names[i]] = rawArgs[i];
376
+ const name = parsed.names[i];
377
+ if (name !== undefined) {
378
+ result.args[name] = rawArgs[i];
379
+ }
377
380
  }
378
381
  }
379
382
 
package/src/sound.ts CHANGED
@@ -17,7 +17,8 @@ export function playSound(): void {
17
17
  return;
18
18
  }
19
19
 
20
- if (process.stdout.isTTY && Bun.which(command[0])) {
20
+ const executable = command[0];
21
+ if (process.stdout.isTTY && executable && Bun.which(executable)) {
21
22
  try {
22
23
  Bun.spawn(command, {
23
24
  stdio: ['ignore', 'ignore', 'ignore'],
package/src/steps.ts CHANGED
@@ -177,6 +177,7 @@ function renderAllSteps(
177
177
 
178
178
  for (let i = 0; i < state.length; i++) {
179
179
  const step = state[i];
180
+ if (step === undefined) continue;
180
181
  const isRunning = i === runningStepIndex;
181
182
  const stepSpinner = isRunning && spinner ? spinner : undefined;
182
183
 
@@ -384,9 +385,10 @@ async function runStepsTUI(steps: Step[]): Promise<void> {
384
385
  const forceRerender = (skipMove = false) => {
385
386
  if (currentStepIndex < 0 || currentStepIndex >= state.length) return;
386
387
 
387
- const colorKey = SPINNER_COLORS[currentFrameIndex % SPINNER_COLORS.length];
388
+ const colorKey = SPINNER_COLORS[currentFrameIndex % SPINNER_COLORS.length] ?? 'cyan';
388
389
  const color = getColor(colorKey);
389
- const spinner = `${color}${COLORS.bold}${FRAMES[currentFrameIndex % FRAMES.length]}${COLORS.reset}`;
390
+ const frame = FRAMES[currentFrameIndex % FRAMES.length] ?? FRAMES[0] ?? '◐';
391
+ const spinner = `${color}${COLORS.bold}${frame}${COLORS.reset}`;
390
392
  const rendered = renderAllSteps(state, currentStepIndex, spinner);
391
393
 
392
394
  // Optionally move up, then to column 0
@@ -421,15 +423,17 @@ async function runStepsTUI(steps: Step[]): Promise<void> {
421
423
 
422
424
  const step = steps[stepIndex];
423
425
  const stepState = state[stepIndex];
426
+ if (step === undefined || stepState === undefined) continue;
424
427
  stepState.status = 'running';
425
428
 
426
429
  // Start spinner animation
427
430
  activeInterval = setInterval(() => {
428
431
  if (isPaused) return;
429
432
 
430
- const colorKey = SPINNER_COLORS[currentFrameIndex % SPINNER_COLORS.length];
433
+ const colorKey = SPINNER_COLORS[currentFrameIndex % SPINNER_COLORS.length] ?? 'cyan';
431
434
  const color = getColor(colorKey);
432
- const spinner = `${color}${COLORS.bold}${FRAMES[currentFrameIndex % FRAMES.length]}${COLORS.reset}`;
435
+ const frame = FRAMES[currentFrameIndex % FRAMES.length] ?? FRAMES[0] ?? '◐';
436
+ const spinner = `${color}${COLORS.bold}${frame}${COLORS.reset}`;
433
437
 
434
438
  // Render all steps from state
435
439
  const rendered = renderAllSteps(state, currentStepIndex, spinner);
@@ -453,9 +457,10 @@ async function runStepsTUI(steps: Step[]): Promise<void> {
453
457
  stepState.progress = Math.min(100, Math.max(0, progress));
454
458
 
455
459
  // Render all steps from state
456
- const colorKey = SPINNER_COLORS[currentFrameIndex % SPINNER_COLORS.length];
460
+ const colorKey = SPINNER_COLORS[currentFrameIndex % SPINNER_COLORS.length] ?? 'cyan';
457
461
  const color = getColor(colorKey);
458
- const spinner = `${color}${COLORS.bold}${FRAMES[currentFrameIndex % FRAMES.length]}${COLORS.reset}`;
462
+ const frame = FRAMES[currentFrameIndex % FRAMES.length] ?? FRAMES[0] ?? '◐';
463
+ const spinner = `${color}${COLORS.bold}${frame}${COLORS.reset}`;
459
464
  const rendered = renderAllSteps(state, currentStepIndex, spinner);
460
465
 
461
466
  // Move to start, clear, render
package/src/terminal.ts CHANGED
@@ -99,7 +99,8 @@ async function queryTerminalBackground(): Promise<RGBColor | null> {
99
99
 
100
100
  // Parse RGB values - they can be different bit depths
101
101
  // Normalize to 8-bit (0-255) by taking the most significant bits
102
- const parseColorValue = (hex: string): number => {
102
+ const parseColorValue = (hex: string | undefined): number => {
103
+ if (!hex) return 0;
103
104
  if (hex.length === 4) {
104
105
  // 16-bit: RRRR -> take first 2 chars
105
106
  return parseInt(hex.slice(0, 2), 16);
@@ -1,3 +1,5 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
1
3
  /**
2
4
  * TSC Output Parser
3
5
  *
@@ -12,6 +14,9 @@
12
14
  *
13
15
  * Generated by PEG.js v. 0.10.0 (ts-pegjs plugin v. 0.2.7)
14
16
  * https://pegjs.org/ https://github.com/metadevpro/ts-pegjs
17
+ *
18
+ * NOTE: This file is auto-generated. Do not edit manually.
19
+ * TypeScript and ESLint checks are disabled for this file.
15
20
  */
16
21
 
17
22
  export interface GrammarPath {
@@ -158,8 +163,10 @@ class SyntaxError extends Error {
158
163
 
159
164
  if (descriptions.length > 0) {
160
165
  for (i = 1, j = 1; i < descriptions.length; i++) {
161
- if (descriptions[i - 1] !== descriptions[i]) {
162
- descriptions[j] = descriptions[i];
166
+ const prevDesc = descriptions[i - 1];
167
+ const currDesc = descriptions[i];
168
+ if (prevDesc !== currDesc && currDesc !== undefined) {
169
+ descriptions[j] = currDesc;
163
170
  j++;
164
171
  }
165
172
  }
@@ -168,14 +175,14 @@ class SyntaxError extends Error {
168
175
 
169
176
  switch (descriptions.length) {
170
177
  case 1:
171
- return descriptions[0];
178
+ return descriptions[0] ?? '';
172
179
  case 2:
173
- return descriptions[0] + ' or ' + descriptions[1];
180
+ return (descriptions[0] ?? '') + ' or ' + (descriptions[1] ?? '');
174
181
  default:
175
182
  return (
176
183
  descriptions.slice(0, -1).join(', ') +
177
184
  ', or ' +
178
- descriptions[descriptions.length - 1]
185
+ (descriptions[descriptions.length - 1] ?? '')
179
186
  );
180
187
  }
181
188
  }
@@ -187,11 +194,11 @@ class SyntaxError extends Error {
187
194
  return 'Expected ' + describeExpected(expected) + ' but ' + describeFound(found) + ' found.';
188
195
  }
189
196
 
190
- public message: string;
197
+ public override message: string;
191
198
  public expected: Expectation[];
192
199
  public found: string | null;
193
200
  public location: IFileRange;
194
- public name: string;
201
+ public override name: string;
195
202
 
196
203
  constructor(
197
204
  message: string,
@@ -342,7 +349,10 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
342
349
  if (!(options.startRule in peg$startRuleFunctions)) {
343
350
  throw new Error('Can\'t start parsing from rule "' + options.startRule + '".');
344
351
  }
345
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
352
+ const startFn = peg$startRuleFunctions[options.startRule];
353
+ if (startFn) {
354
+ peg$startRuleFunction = startFn;
355
+ }
346
356
  }
347
357
 
348
358
  function peg$literalExpectation(text1: string, ignoreCase: boolean): ILiteralExpectation {
@@ -363,7 +373,7 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
363
373
 
364
374
  function peg$computePosDetails(pos: number) {
365
375
  let details = peg$posDetailsCache[pos];
366
- let p;
376
+ let p: number;
367
377
 
368
378
  if (details) {
369
379
  return details;
@@ -373,10 +383,10 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
373
383
  p--;
374
384
  }
375
385
 
376
- details = peg$posDetailsCache[p];
386
+ const cachedDetails = peg$posDetailsCache[p];
377
387
  details = {
378
- line: details.line,
379
- column: details.column,
388
+ line: cachedDetails?.line ?? 1,
389
+ column: cachedDetails?.column ?? 1,
380
390
  };
381
391
 
382
392
  while (p < pos) {
@@ -440,10 +450,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
440
450
  }
441
451
 
442
452
  function peg$parseMain(): unknown {
443
- let s0, s1, s2, s3;
453
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
454
+ let s0: any, s1: any, s2: any, s3: any;
444
455
 
445
456
  const key = peg$currPos * 13 + 0;
446
- const cached: ICached = peg$resultsCache[key];
457
+ const cached: ICached | undefined = peg$resultsCache[key];
447
458
 
448
459
  if (cached) {
449
460
  peg$currPos = cached.nextPos;
@@ -484,10 +495,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
484
495
  }
485
496
 
486
497
  function peg$parseItem(): unknown {
487
- let s0, s1, s2, s3, s4, s5, s6, s7, s8;
498
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
499
+ let s0: any, s1: any, s2: any, s3: any, s4: any, s5: any, s6: any, s7: any, s8: any;
488
500
 
489
501
  const key = peg$currPos * 13 + 1;
490
- const cached: ICached = peg$resultsCache[key];
502
+ const cached: ICached | undefined = peg$resultsCache[key];
491
503
 
492
504
  if (cached) {
493
505
  peg$currPos = cached.nextPos;
@@ -569,10 +581,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
569
581
  }
570
582
 
571
583
  function peg$parseMessage(): unknown {
572
- let s0, s1, s2, s3;
584
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
585
+ let s0: any, s1: any, s2: any, s3: any;
573
586
 
574
587
  const key = peg$currPos * 13 + 2;
575
- const cached: ICached = peg$resultsCache[key];
588
+ const cached: ICached | undefined = peg$resultsCache[key];
576
589
 
577
590
  if (cached) {
578
591
  peg$currPos = cached.nextPos;
@@ -607,10 +620,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
607
620
  }
608
621
 
609
622
  function peg$parseMessageExtraLine(): unknown {
610
- let s0, s1, s2;
623
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
624
+ let s0: any, s1: any, s2: any;
611
625
 
612
626
  const key = peg$currPos * 13 + 3;
613
- const cached: ICached = peg$resultsCache[key];
627
+ const cached: ICached | undefined = peg$resultsCache[key];
614
628
 
615
629
  if (cached) {
616
630
  peg$currPos = cached.nextPos;
@@ -640,10 +654,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
640
654
  }
641
655
 
642
656
  function peg$parseMessageExtraLineStart(): unknown {
643
- let s0, s1;
657
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
658
+ let s0: any, s1: any;
644
659
 
645
660
  const key = peg$currPos * 13 + 4;
646
- const cached: ICached = peg$resultsCache[key];
661
+ const cached: ICached | undefined = peg$resultsCache[key];
647
662
 
648
663
  if (cached) {
649
664
  peg$currPos = cached.nextPos;
@@ -672,10 +687,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
672
687
  }
673
688
 
674
689
  function peg$parseTsError(): unknown {
675
- let s0, s1, s2, s3;
690
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
691
+ let s0: any, s1: any, s2: any, s3: any;
676
692
 
677
693
  const key = peg$currPos * 13 + 5;
678
- const cached: ICached = peg$resultsCache[key];
694
+ const cached: ICached | undefined = peg$resultsCache[key];
679
695
 
680
696
  if (cached) {
681
697
  peg$currPos = cached.nextPos;
@@ -719,10 +735,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
719
735
  }
720
736
 
721
737
  function peg$parseTsErrorType(): unknown {
722
- let s0, s1;
738
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
739
+ let s0: any, s1: any;
723
740
 
724
741
  const key = peg$currPos * 13 + 6;
725
- const cached: ICached = peg$resultsCache[key];
742
+ const cached: ICached | undefined = peg$resultsCache[key];
726
743
 
727
744
  if (cached) {
728
745
  peg$currPos = cached.nextPos;
@@ -762,10 +779,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
762
779
  }
763
780
 
764
781
  function peg$parseCursor(): unknown {
765
- let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
782
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
783
+ let s0: any, s1: any, s2: any, s3: any, s4: any, s5: any, s6: any, s7: any, s8: any, s9: any;
766
784
 
767
785
  const key = peg$currPos * 13 + 7;
768
- const cached: ICached = peg$resultsCache[key];
786
+ const cached: ICached | undefined = peg$resultsCache[key];
769
787
 
770
788
  if (cached) {
771
789
  peg$currPos = cached.nextPos;
@@ -861,10 +879,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
861
879
  }
862
880
 
863
881
  function peg$parsePath(): unknown {
864
- let s0, s1, s2;
882
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
883
+ let s0: any, s1: any, s2: any;
865
884
 
866
885
  const key = peg$currPos * 13 + 8;
867
- const cached: ICached = peg$resultsCache[key];
886
+ const cached: ICached | undefined = peg$resultsCache[key];
868
887
 
869
888
  if (cached) {
870
889
  peg$currPos = cached.nextPos;
@@ -910,10 +929,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
910
929
  }
911
930
 
912
931
  function peg$parseTextLine(): unknown {
913
- let s0, s1, s2, s3;
932
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
933
+ let s0: any, s1: any, s2: any, s3: any;
914
934
 
915
935
  const key = peg$currPos * 13 + 9;
916
- const cached: ICached = peg$resultsCache[key];
936
+ const cached: ICached | undefined = peg$resultsCache[key];
917
937
 
918
938
  if (cached) {
919
939
  peg$currPos = cached.nextPos;
@@ -973,10 +993,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
973
993
  }
974
994
 
975
995
  function peg$parseAnyCharExceptNewLine(): unknown {
976
- let s0;
996
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
997
+ let s0: any;
977
998
 
978
999
  const key = peg$currPos * 13 + 10;
979
- const cached: ICached = peg$resultsCache[key];
1000
+ const cached: ICached | undefined = peg$resultsCache[key];
980
1001
 
981
1002
  if (cached) {
982
1003
  peg$currPos = cached.nextPos;
@@ -999,10 +1020,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
999
1020
  }
1000
1021
 
1001
1022
  function peg$parseInteger(): unknown {
1002
- let s0, s1, s2;
1023
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1024
+ let s0: any, s1: any, s2: any;
1003
1025
 
1004
1026
  const key = peg$currPos * 13 + 11;
1005
- const cached: ICached = peg$resultsCache[key];
1027
+ const cached: ICached | undefined = peg$resultsCache[key];
1006
1028
 
1007
1029
  if (cached) {
1008
1030
  peg$currPos = cached.nextPos;
@@ -1048,10 +1070,11 @@ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
1048
1070
  }
1049
1071
 
1050
1072
  function peg$parse_(): unknown {
1051
- let s0, s1, s2;
1073
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1074
+ let s0: any, s1: any, s2: any;
1052
1075
 
1053
1076
  const key = peg$currPos * 13 + 12;
1054
- const cached: ICached = peg$resultsCache[key];
1077
+ const cached: ICached | undefined = peg$resultsCache[key];
1055
1078
 
1056
1079
  if (cached) {
1057
1080
  peg$currPos = cached.nextPos;
package/src/tui/prompt.ts CHANGED
@@ -347,6 +347,10 @@ export class PromptFlow {
347
347
  } else if (key.name === 'return') {
348
348
  cleanup();
349
349
  const selected = choices[selectedIndex];
350
+ if (!selected) {
351
+ reject(new Error('No selection available'));
352
+ return;
353
+ }
350
354
 
351
355
  // Clear all lines (message + all choices)
352
356
  const totalLines = choices.length + 1;
@@ -462,8 +466,8 @@ export class PromptFlow {
462
466
 
463
467
  // Sort indices to get consistent order for both values and labels
464
468
  const sortedIndices = Array.from(selected).sort((a, b) => a - b);
465
- const values = sortedIndices.map((i) => choices[i].value);
466
- const labels = sortedIndices.map((i) => choices[i].label);
469
+ const values = sortedIndices.map((i) => choices[i]?.value).filter((v) => v !== undefined);
470
+ const labels = sortedIndices.map((i) => choices[i]?.label).filter((l) => l !== undefined);
467
471
 
468
472
  // Clear all lines (message + all choices)
469
473
  const totalLines = choices.length + 1;
package/src/tui.ts CHANGED
@@ -485,7 +485,9 @@ export function truncateToWidth(str: string, maxWidth: number, ellipsis = '...')
485
485
  const targetWidth = maxWidth - ellipsis.length;
486
486
 
487
487
  for (let i = 0; i < segments.length; i++) {
488
- const segment = segments[i].segment;
488
+ const seg = segments[i];
489
+ if (!seg) continue;
490
+ const segment = seg.segment;
489
491
  const segmentWidth = Bun.stringWidth(segment);
490
492
 
491
493
  if (currentWidth + segmentWidth > targetWidth) {
@@ -493,7 +495,7 @@ export function truncateToWidth(str: string, maxWidth: number, ellipsis = '...')
493
495
  }
494
496
 
495
497
  currentWidth += segmentWidth;
496
- cutIndex = segments[i].index + segment.length;
498
+ cutIndex = seg.index + segment.length;
497
499
  }
498
500
 
499
501
  // Now reconstruct with ANSI codes preserved
@@ -1027,8 +1029,9 @@ export function wrapText(text: string, maxWidth: number): string[] {
1027
1029
  // ensure each wrapped line ends with reset (only for this paragraph's lines)
1028
1030
  if (leadingCodes && hasReset) {
1029
1031
  for (let i = paragraphStart; i < allLines.length; i++) {
1030
- if (!endsWithReset(allLines[i])) {
1031
- allLines[i] += getColor('reset');
1032
+ const line = allLines[i];
1033
+ if (line !== undefined && !endsWithReset(line)) {
1034
+ allLines[i] = line + getColor('reset');
1032
1035
  }
1033
1036
  }
1034
1037
  }
@@ -1252,9 +1255,9 @@ export async function spinner<T>(
1252
1255
  process.stderr.write(`\x1b[${linesRendered}A`);
1253
1256
  }
1254
1257
 
1255
- const colorDef = spinnerColors[frameIndex % spinnerColors.length];
1256
- const color = colorDef[currentColorScheme];
1257
- const frame = `${color}${bold}${frames[frameIndex % frames.length]}${reset}`;
1258
+ const colorDef = spinnerColors[frameIndex % spinnerColors.length] ?? spinnerColors[0];
1259
+ const color = colorDef?.[currentColorScheme] ?? '';
1260
+ const frame = `${color}${bold}${frames[frameIndex % frames.length] ?? ''}${reset}`;
1258
1261
 
1259
1262
  // Add progress indicator or countdown timer if available
1260
1263
  let indicator = '';
@@ -1780,7 +1783,7 @@ export async function selectOrganization(
1780
1783
  }
1781
1784
 
1782
1785
  // Auto-select if only one org (regardless of TTY mode)
1783
- if (orgs.length === 1) {
1786
+ if (orgs.length === 1 && orgs[0]) {
1784
1787
  return orgs[0].id;
1785
1788
  }
1786
1789
 
@@ -1798,11 +1801,14 @@ export async function selectOrganization(
1798
1801
  if (isNonInteractive) {
1799
1802
  // In non-interactive mode with multiple orgs, auto-select first org
1800
1803
  // This allows scripts and CI/CD to work without explicit org selection
1801
- warning(
1802
- `Multiple organizations found. Auto-selecting first org: ${orgs[0].name}. ` +
1803
- `Set AGENTUITY_CLOUD_ORG_ID or use --org-id to specify a different org.`
1804
- );
1805
- return orgs[0].id;
1804
+ const firstOrg = orgs[0];
1805
+ if (firstOrg) {
1806
+ warning(
1807
+ `Multiple organizations found. Auto-selecting first org: ${firstOrg.name}. ` +
1808
+ `Set AGENTUITY_CLOUD_ORG_ID or use --org-id to specify a different org.`
1809
+ );
1810
+ return firstOrg.id;
1811
+ }
1806
1812
  }
1807
1813
 
1808
1814
  // Interactive mode with no saved preference - prompt user
@@ -1888,8 +1894,9 @@ export async function showProfileList(
1888
1894
  // If non-interactive, return initial or first
1889
1895
  if (!process.stdin.isTTY) {
1890
1896
  if (initial) return initial;
1891
- if (profiles.length === 1) {
1892
- return profiles[0].name;
1897
+ const firstProfile = profiles[0];
1898
+ if (profiles.length === 1 && firstProfile) {
1899
+ return firstProfile.name;
1893
1900
  }
1894
1901
  fatal(
1895
1902
  'Profile selection required but cannot prompt in non-interactive environment. ' +
@@ -2017,6 +2024,7 @@ function renderVerticalTable<T extends Record<string, unknown>>(
2017
2024
 
2018
2025
  for (let i = 0; i < data.length; i++) {
2019
2026
  const row = data[i];
2027
+ if (!row) continue;
2020
2028
 
2021
2029
  for (const colName of columnNames) {
2022
2030
  const value = row[colName];
@@ -2071,10 +2079,11 @@ export function table<T extends Record<string, unknown>>(
2071
2079
  colAligns = columnConfigs.map((col) => col.alignment || 'left');
2072
2080
  } else {
2073
2081
  // Simple mode: determine column names from data or columns parameter
2082
+ const firstRow = data[0];
2074
2083
  columnNames = columns
2075
2084
  ? (columns as (keyof T)[]).map((c) => String(c))
2076
- : data.length > 0
2077
- ? Object.keys(data[0])
2085
+ : data.length > 0 && firstRow
2086
+ ? Object.keys(firstRow)
2078
2087
  : [];
2079
2088
  colAligns = columnNames.map(() => 'left' as const);
2080
2089
  }
@@ -129,9 +129,12 @@ async function getSourceContext(
129
129
  }
130
130
 
131
131
  const currentOriginal = lines[lineNumber - 1];
132
+ if (currentOriginal === undefined) {
133
+ return null;
134
+ }
132
135
  const current = expandTabs(currentOriginal);
133
- const beforeRaw = lineNumber > 1 ? lines[lineNumber - 2] : null;
134
- const afterRaw = lineNumber < lines.length ? lines[lineNumber] : null;
136
+ const beforeRaw = lineNumber > 1 ? (lines[lineNumber - 2] ?? null) : null;
137
+ const afterRaw = lineNumber < lines.length ? (lines[lineNumber] ?? null) : null;
135
138
  const before = beforeRaw !== null && beforeRaw.trim() !== '' ? expandTabs(beforeRaw) : null;
136
139
  const after = afterRaw !== null && afterRaw.trim() !== '' ? expandTabs(afterRaw) : null;
137
140