@iaforged/context-code 1.0.63 → 1.0.65

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 (2000) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +633 -9
  3. package/context-bootstrap.js +28 -28
  4. package/package.json +169 -170
  5. package/dist/src/QueryEngine.js +0 -928
  6. package/dist/src/Task.js +0 -49
  7. package/dist/src/Tool.js +0 -56
  8. package/dist/src/assistant/AssistantSessionChooser.js +0 -16
  9. package/dist/src/assistant/index.js +0 -16
  10. package/dist/src/assistant/sessionDiscovery.js +0 -16
  11. package/dist/src/assistant/sessionHistory.js +0 -47
  12. package/dist/src/bootstrap/state.js +0 -1165
  13. package/dist/src/bridge/bridgeApi.js +0 -304
  14. package/dist/src/bridge/bridgeConfig.js +0 -39
  15. package/dist/src/bridge/bridgeDebug.js +0 -73
  16. package/dist/src/bridge/bridgeEnabled.js +0 -187
  17. package/dist/src/bridge/bridgeMain.js +0 -2289
  18. package/dist/src/bridge/bridgeMessaging.js +0 -353
  19. package/dist/src/bridge/bridgePermissionCallbacks.js +0 -10
  20. package/dist/src/bridge/bridgePointer.js +0 -175
  21. package/dist/src/bridge/bridgeStatusUtil.js +0 -105
  22. package/dist/src/bridge/bridgeUI.js +0 -412
  23. package/dist/src/bridge/capacityWake.js +0 -35
  24. package/dist/src/bridge/codeSessionApi.js +0 -111
  25. package/dist/src/bridge/createSession.js +0 -273
  26. package/dist/src/bridge/debugUtils.js +0 -115
  27. package/dist/src/bridge/envLessBridgeConfig.js +0 -121
  28. package/dist/src/bridge/flushGate.js +0 -65
  29. package/dist/src/bridge/inboundAttachments.js +0 -152
  30. package/dist/src/bridge/inboundMessages.js +0 -63
  31. package/dist/src/bridge/initReplBridge.js +0 -428
  32. package/dist/src/bridge/jwtUtils.js +0 -185
  33. package/dist/src/bridge/pollConfig.js +0 -85
  34. package/dist/src/bridge/pollConfigDefaults.js +0 -62
  35. package/dist/src/bridge/remoteBridgeCore.js +0 -712
  36. package/dist/src/bridge/replBridge.js +0 -1720
  37. package/dist/src/bridge/replBridgeHandle.js +0 -30
  38. package/dist/src/bridge/replBridgeTransport.js +0 -236
  39. package/dist/src/bridge/sessionIdCompat.js +0 -56
  40. package/dist/src/bridge/sessionRunner.js +0 -421
  41. package/dist/src/bridge/trustedDevice.js +0 -172
  42. package/dist/src/bridge/types.js +0 -9
  43. package/dist/src/bridge/workSecret.js +0 -99
  44. package/dist/src/buddy/CompanionSprite.js +0 -349
  45. package/dist/src/buddy/companion.js +0 -107
  46. package/dist/src/buddy/prompt.js +0 -33
  47. package/dist/src/buddy/sprites.js +0 -488
  48. package/dist/src/buddy/types.js +0 -90
  49. package/dist/src/buddy/useBuddyNotification.js +0 -90
  50. package/dist/src/cli/bg.js +0 -16
  51. package/dist/src/cli/exit.js +0 -30
  52. package/dist/src/cli/handlers/agents.js +0 -55
  53. package/dist/src/cli/handlers/ant.js +0 -16
  54. package/dist/src/cli/handlers/auth.js +0 -312
  55. package/dist/src/cli/handlers/autoMode.js +0 -128
  56. package/dist/src/cli/handlers/mcp.js +0 -334
  57. package/dist/src/cli/handlers/plugins.js +0 -634
  58. package/dist/src/cli/handlers/projects_bridge.js +0 -40
  59. package/dist/src/cli/handlers/templateJobs.js +0 -16
  60. package/dist/src/cli/handlers/util.js +0 -76
  61. package/dist/src/cli/ndjsonSafeStringify.js +0 -27
  62. package/dist/src/cli/print.js +0 -4225
  63. package/dist/src/cli/remoteIO.js +0 -208
  64. package/dist/src/cli/rollback.js +0 -16
  65. package/dist/src/cli/structuredIO.js +0 -644
  66. package/dist/src/cli/transports/HybridTransport.js +0 -233
  67. package/dist/src/cli/transports/SSETransport.js +0 -538
  68. package/dist/src/cli/transports/SerialBatchEventUploader.js +0 -224
  69. package/dist/src/cli/transports/Transport.js +0 -1
  70. package/dist/src/cli/transports/WebSocketTransport.js +0 -613
  71. package/dist/src/cli/transports/WorkerStateUploader.js +0 -88
  72. package/dist/src/cli/transports/ccrClient.js +0 -711
  73. package/dist/src/cli/transports/transportUtils.js +0 -39
  74. package/dist/src/cli/up.js +0 -16
  75. package/dist/src/cli/update.js +0 -315
  76. package/dist/src/commands/add-dir/add-dir.js +0 -121
  77. package/dist/src/commands/add-dir/index.js +0 -8
  78. package/dist/src/commands/add-dir/validation.js +0 -76
  79. package/dist/src/commands/advisor.js +0 -88
  80. package/dist/src/commands/agents/agents.js +0 -9
  81. package/dist/src/commands/agents/index.js +0 -7
  82. package/dist/src/commands/ant-trace/index.js +0 -1
  83. package/dist/src/commands/assistant/assistant.js +0 -16
  84. package/dist/src/commands/autofix-pr/index.js +0 -1
  85. package/dist/src/commands/backfill-sessions/index.js +0 -1
  86. package/dist/src/commands/branch/branch.js +0 -205
  87. package/dist/src/commands/branch/index.js +0 -11
  88. package/dist/src/commands/break-cache/index.js +0 -1
  89. package/dist/src/commands/bridge/bridge.js +0 -512
  90. package/dist/src/commands/bridge/index.js +0 -22
  91. package/dist/src/commands/bridge-kick.js +0 -179
  92. package/dist/src/commands/brief.js +0 -94
  93. package/dist/src/commands/btw/btw.js +0 -234
  94. package/dist/src/commands/btw/index.js +0 -9
  95. package/dist/src/commands/bughunter/index.js +0 -1
  96. package/dist/src/commands/chrome/chrome.js +0 -291
  97. package/dist/src/commands/chrome/index.js +0 -10
  98. package/dist/src/commands/clear/caches.js +0 -116
  99. package/dist/src/commands/clear/clear.js +0 -5
  100. package/dist/src/commands/clear/conversation.js +0 -191
  101. package/dist/src/commands/clear/index.js +0 -9
  102. package/dist/src/commands/color/color.js +0 -58
  103. package/dist/src/commands/color/index.js +0 -9
  104. package/dist/src/commands/commit-push-pr.js +0 -137
  105. package/dist/src/commands/commit.js +0 -80
  106. package/dist/src/commands/compact/compact.js +0 -196
  107. package/dist/src/commands/compact/index.js +0 -11
  108. package/dist/src/commands/config/config.js +0 -5
  109. package/dist/src/commands/config/index.js +0 -8
  110. package/dist/src/commands/context/context-noninteractive.js +0 -221
  111. package/dist/src/commands/context/context.js +0 -46
  112. package/dist/src/commands/context/index.js +0 -21
  113. package/dist/src/commands/copy/copy.js +0 -366
  114. package/dist/src/commands/copy/index.js +0 -7
  115. package/dist/src/commands/cost/cost.js +0 -21
  116. package/dist/src/commands/cost/index.js +0 -16
  117. package/dist/src/commands/createMovedToPluginCommand.js +0 -33
  118. package/dist/src/commands/ctx_viz/index.js +0 -1
  119. package/dist/src/commands/debug-tool-call/index.js +0 -1
  120. package/dist/src/commands/desktop/desktop.js +0 -5
  121. package/dist/src/commands/desktop/index.js +0 -22
  122. package/dist/src/commands/diff/diff.js +0 -5
  123. package/dist/src/commands/diff/index.js +0 -6
  124. package/dist/src/commands/doctor/doctor.js +0 -5
  125. package/dist/src/commands/doctor/index.js +0 -9
  126. package/dist/src/commands/effort/effort.js +0 -166
  127. package/dist/src/commands/effort/index.js +0 -11
  128. package/dist/src/commands/env/index.js +0 -1
  129. package/dist/src/commands/exit/exit.js +0 -31
  130. package/dist/src/commands/exit/index.js +0 -9
  131. package/dist/src/commands/export/export.js +0 -86
  132. package/dist/src/commands/export/index.js +0 -8
  133. package/dist/src/commands/extra-usage/extra-usage-core.js +0 -99
  134. package/dist/src/commands/extra-usage/extra-usage-noninteractive.js +0 -13
  135. package/dist/src/commands/extra-usage/extra-usage.js +0 -14
  136. package/dist/src/commands/extra-usage/index.js +0 -27
  137. package/dist/src/commands/fast/fast.js +0 -275
  138. package/dist/src/commands/fast/index.js +0 -20
  139. package/dist/src/commands/feedback/feedback.js +0 -10
  140. package/dist/src/commands/feedback/index.js +0 -20
  141. package/dist/src/commands/files/files.js +0 -11
  142. package/dist/src/commands/files/index.js +0 -9
  143. package/dist/src/commands/good-claude/index.js +0 -1
  144. package/dist/src/commands/heapdump/heapdump.js +0 -14
  145. package/dist/src/commands/heapdump/index.js +0 -9
  146. package/dist/src/commands/help/help.js +0 -5
  147. package/dist/src/commands/help/index.js +0 -7
  148. package/dist/src/commands/hooks/hooks.js +0 -11
  149. package/dist/src/commands/hooks/index.js +0 -8
  150. package/dist/src/commands/ide/ide.js +0 -615
  151. package/dist/src/commands/ide/index.js +0 -8
  152. package/dist/src/commands/init-verifiers.js +0 -258
  153. package/dist/src/commands/init.js +0 -249
  154. package/dist/src/commands/insights.js +0 -2555
  155. package/dist/src/commands/install-github-app/ApiKeyStep.js +0 -230
  156. package/dist/src/commands/install-github-app/CheckExistingSecretStep.js +0 -194
  157. package/dist/src/commands/install-github-app/CheckGitHubStep.js +0 -15
  158. package/dist/src/commands/install-github-app/ChooseRepoStep.js +0 -211
  159. package/dist/src/commands/install-github-app/CreatingStep.js +0 -52
  160. package/dist/src/commands/install-github-app/ErrorStep.js +0 -83
  161. package/dist/src/commands/install-github-app/ExistingWorkflowStep.js +0 -104
  162. package/dist/src/commands/install-github-app/InstallAppStep.js +0 -96
  163. package/dist/src/commands/install-github-app/OAuthFlowStep.js +0 -190
  164. package/dist/src/commands/install-github-app/SuccessStep.js +0 -93
  165. package/dist/src/commands/install-github-app/WarningsStep.js +0 -70
  166. package/dist/src/commands/install-github-app/index.js +0 -10
  167. package/dist/src/commands/install-github-app/install-github-app.js +0 -593
  168. package/dist/src/commands/install-github-app/setupGitHubActions.js +0 -227
  169. package/dist/src/commands/install-slack-app/index.js +0 -9
  170. package/dist/src/commands/install-slack-app/install-slack-app.js +0 -25
  171. package/dist/src/commands/install.js +0 -118
  172. package/dist/src/commands/issue/index.js +0 -1
  173. package/dist/src/commands/keybindings/index.js +0 -10
  174. package/dist/src/commands/keybindings/keybindings.js +0 -47
  175. package/dist/src/commands/login/index.js +0 -11
  176. package/dist/src/commands/login/login.js +0 -99
  177. package/dist/src/commands/login-openai/index.js +0 -7
  178. package/dist/src/commands/login-openai/login-openai.js +0 -54
  179. package/dist/src/commands/logout/index.js +0 -8
  180. package/dist/src/commands/logout/logout.js +0 -72
  181. package/dist/src/commands/mcp/addCommand.js +0 -183
  182. package/dist/src/commands/mcp/index.js +0 -9
  183. package/dist/src/commands/mcp/mcp.js +0 -78
  184. package/dist/src/commands/mcp/xaaIdpCommand.js +0 -193
  185. package/dist/src/commands/memory/index.js +0 -7
  186. package/dist/src/commands/memory/memory.js +0 -71
  187. package/dist/src/commands/mobile/index.js +0 -8
  188. package/dist/src/commands/mobile/mobile.js +0 -278
  189. package/dist/src/commands/mock-limits/index.js +0 -1
  190. package/dist/src/commands/model/index.js +0 -14
  191. package/dist/src/commands/model/model.js +0 -297
  192. package/dist/src/commands/oauth-refresh/index.js +0 -1
  193. package/dist/src/commands/onboarding/index.js +0 -1
  194. package/dist/src/commands/output-style/index.js +0 -8
  195. package/dist/src/commands/output-style/output-style.js +0 -6
  196. package/dist/src/commands/passes/index.js +0 -17
  197. package/dist/src/commands/passes/passes.js +0 -22
  198. package/dist/src/commands/perf-issue/index.js +0 -1
  199. package/dist/src/commands/permissions/index.js +0 -8
  200. package/dist/src/commands/permissions/permissions.js +0 -8
  201. package/dist/src/commands/plan/index.js +0 -8
  202. package/dist/src/commands/plan/plan.js +0 -115
  203. package/dist/src/commands/plugin/AddMarketplace.js +0 -95
  204. package/dist/src/commands/plugin/BrowseMarketplace.js +0 -576
  205. package/dist/src/commands/plugin/DiscoverPlugins.js +0 -613
  206. package/dist/src/commands/plugin/ManageMarketplaces.js +0 -582
  207. package/dist/src/commands/plugin/ManagePlugins.js +0 -1783
  208. package/dist/src/commands/plugin/PluginErrors.js +0 -124
  209. package/dist/src/commands/plugin/PluginOptionsDialog.js +0 -367
  210. package/dist/src/commands/plugin/PluginOptionsFlow.js +0 -97
  211. package/dist/src/commands/plugin/PluginSettings.js +0 -1042
  212. package/dist/src/commands/plugin/PluginTrustWarning.js +0 -34
  213. package/dist/src/commands/plugin/UnifiedInstalledCell.js +0 -615
  214. package/dist/src/commands/plugin/ValidatePlugin.js +0 -95
  215. package/dist/src/commands/plugin/index.js +0 -10
  216. package/dist/src/commands/plugin/parseArgs.js +0 -71
  217. package/dist/src/commands/plugin/plugin.js +0 -5
  218. package/dist/src/commands/plugin/pluginDetailsHelpers.js +0 -89
  219. package/dist/src/commands/plugin/usePagination.js +0 -89
  220. package/dist/src/commands/pr_comments/index.js +0 -49
  221. package/dist/src/commands/privacy-settings/index.js +0 -11
  222. package/dist/src/commands/privacy-settings/privacy-settings.js +0 -54
  223. package/dist/src/commands/profile/index.js +0 -9
  224. package/dist/src/commands/profile/profile.js +0 -426
  225. package/dist/src/commands/provider/index.js +0 -8
  226. package/dist/src/commands/provider/provider.js +0 -349
  227. package/dist/src/commands/rate-limit-options/index.js +0 -15
  228. package/dist/src/commands/rate-limit-options/rate-limit-options.js +0 -213
  229. package/dist/src/commands/release-notes/index.js +0 -8
  230. package/dist/src/commands/release-notes/release-notes.js +0 -38
  231. package/dist/src/commands/reload-plugins/index.js +0 -11
  232. package/dist/src/commands/reload-plugins/reload-plugins.js +0 -52
  233. package/dist/src/commands/remote-env/index.js +0 -12
  234. package/dist/src/commands/remote-env/remote-env.js +0 -5
  235. package/dist/src/commands/remote-setup/api.js +0 -155
  236. package/dist/src/commands/remote-setup/index.js +0 -15
  237. package/dist/src/commands/remote-setup/remote-setup.js +0 -149
  238. package/dist/src/commands/rename/generateSessionName.js +0 -58
  239. package/dist/src/commands/rename/index.js +0 -9
  240. package/dist/src/commands/rename/rename.js +0 -52
  241. package/dist/src/commands/reset-limits/index.js +0 -4
  242. package/dist/src/commands/resume/index.js +0 -9
  243. package/dist/src/commands/resume/resume.js +0 -239
  244. package/dist/src/commands/review/UltrareviewOverageDialog.js +0 -97
  245. package/dist/src/commands/review/reviewRemote.js +0 -259
  246. package/dist/src/commands/review/ultrareviewCommand.js +0 -57
  247. package/dist/src/commands/review/ultrareviewEnabled.js +0 -10
  248. package/dist/src/commands/review.js +0 -50
  249. package/dist/src/commands/rewind/index.js +0 -10
  250. package/dist/src/commands/rewind/rewind.js +0 -7
  251. package/dist/src/commands/sandbox-toggle/index.js +0 -41
  252. package/dist/src/commands/sandbox-toggle/sandbox-toggle.js +0 -72
  253. package/dist/src/commands/security-review.js +0 -231
  254. package/dist/src/commands/session/index.js +0 -13
  255. package/dist/src/commands/session/session.js +0 -142
  256. package/dist/src/commands/share/index.js +0 -1
  257. package/dist/src/commands/skills/index.js +0 -7
  258. package/dist/src/commands/skills/skills.js +0 -5
  259. package/dist/src/commands/stats/index.js +0 -7
  260. package/dist/src/commands/stats/stats.js +0 -5
  261. package/dist/src/commands/status/index.js +0 -8
  262. package/dist/src/commands/status/status.js +0 -5
  263. package/dist/src/commands/statusline.js +0 -22
  264. package/dist/src/commands/stickers/index.js +0 -8
  265. package/dist/src/commands/stickers/stickers.js +0 -14
  266. package/dist/src/commands/summary/index.js +0 -1
  267. package/dist/src/commands/tag/index.js +0 -9
  268. package/dist/src/commands/tag/tag.js +0 -215
  269. package/dist/src/commands/tasks/index.js +0 -8
  270. package/dist/src/commands/tasks/tasks.js +0 -5
  271. package/dist/src/commands/telegram/index.js +0 -9
  272. package/dist/src/commands/telegram/telegram.js +0 -118
  273. package/dist/src/commands/teleport/index.js +0 -1
  274. package/dist/src/commands/terminalSetup/index.js +0 -18
  275. package/dist/src/commands/terminalSetup/terminalSetup.js +0 -491
  276. package/dist/src/commands/theme/index.js +0 -7
  277. package/dist/src/commands/theme/theme.js +0 -50
  278. package/dist/src/commands/thinkback/index.js +0 -9
  279. package/dist/src/commands/thinkback/thinkback.js +0 -527
  280. package/dist/src/commands/thinkback-play/index.js +0 -13
  281. package/dist/src/commands/thinkback-play/thinkback-play.js +0 -34
  282. package/dist/src/commands/ultraplan.js +0 -418
  283. package/dist/src/commands/upgrade/index.js +0 -12
  284. package/dist/src/commands/upgrade/upgrade.js +0 -37
  285. package/dist/src/commands/usage/index.js +0 -7
  286. package/dist/src/commands/usage/usage.js +0 -5
  287. package/dist/src/commands/version.js +0 -18
  288. package/dist/src/commands/vim/index.js +0 -8
  289. package/dist/src/commands/vim/vim.js +0 -25
  290. package/dist/src/commands/voice/index.js +0 -14
  291. package/dist/src/commands/voice/voice.js +0 -130
  292. package/dist/src/commands/whatsapp/index.js +0 -9
  293. package/dist/src/commands/whatsapp/whatsapp.js +0 -326
  294. package/dist/src/commands.js +0 -646
  295. package/dist/src/components/AgentProgressLine.js +0 -111
  296. package/dist/src/components/App.js +0 -45
  297. package/dist/src/components/ApproveApiKey.js +0 -124
  298. package/dist/src/components/AutoModeOptInDialog.js +0 -140
  299. package/dist/src/components/AutoUpdater.js +0 -157
  300. package/dist/src/components/AutoUpdaterWrapper.js +0 -78
  301. package/dist/src/components/AwsAuthStatusBox.js +0 -88
  302. package/dist/src/components/BaseTextInput.js +0 -105
  303. package/dist/src/components/BashModeProgress.js +0 -48
  304. package/dist/src/components/BridgeDialog.js +0 -414
  305. package/dist/src/components/BypassPermissionsModeDialog.js +0 -87
  306. package/dist/src/components/ChannelDowngradeDialog.js +0 -100
  307. package/dist/src/components/ClaudeCodeHint/PluginHintMenu.js +0 -37
  308. package/dist/src/components/ClaudeInChromeOnboarding.js +0 -126
  309. package/dist/src/components/ClaudeMdExternalIncludesDialog.js +0 -137
  310. package/dist/src/components/ClickableImageRef.js +0 -64
  311. package/dist/src/components/CompactSummary.js +0 -119
  312. package/dist/src/components/ConfigurableShortcutHint.js +0 -34
  313. package/dist/src/components/ConsoleOAuthFlow.js +0 -756
  314. package/dist/src/components/ContextSuggestions.js +0 -43
  315. package/dist/src/components/ContextVisualization.js +0 -483
  316. package/dist/src/components/CoordinatorAgentStatus.js +0 -261
  317. package/dist/src/components/CostThresholdDialog.js +0 -48
  318. package/dist/src/components/CtrlOToExpand.js +0 -50
  319. package/dist/src/components/CustomSelect/SelectMulti.js +0 -149
  320. package/dist/src/components/CustomSelect/index.js +0 -2
  321. package/dist/src/components/CustomSelect/option-map.js +0 -32
  322. package/dist/src/components/CustomSelect/select-input-option.js +0 -426
  323. package/dist/src/components/CustomSelect/select-option.js +0 -23
  324. package/dist/src/components/CustomSelect/select.js +0 -518
  325. package/dist/src/components/CustomSelect/use-multi-select-state.js +0 -214
  326. package/dist/src/components/CustomSelect/use-select-input.js +0 -170
  327. package/dist/src/components/CustomSelect/use-select-navigation.js +0 -366
  328. package/dist/src/components/CustomSelect/use-select-state.js +0 -22
  329. package/dist/src/components/DesktopHandoff.js +0 -195
  330. package/dist/src/components/DesktopUpsell/DesktopUpsellStartup.js +0 -173
  331. package/dist/src/components/DevBar.js +0 -50
  332. package/dist/src/components/DevChannelsDialog.js +0 -103
  333. package/dist/src/components/DiagnosticsDisplay.js +0 -91
  334. package/dist/src/components/EffortCallout.js +0 -264
  335. package/dist/src/components/EffortIndicator.js +0 -29
  336. package/dist/src/components/ExitFlow.js +0 -40
  337. package/dist/src/components/ExportDialog.js +0 -101
  338. package/dist/src/components/FallbackToolUseErrorMessage.js +0 -115
  339. package/dist/src/components/FallbackToolUseRejectedMessage.js +0 -16
  340. package/dist/src/components/FastIcon.js +0 -42
  341. package/dist/src/components/Feedback.js +0 -439
  342. package/dist/src/components/FeedbackSurvey/FeedbackSurvey.js +0 -150
  343. package/dist/src/components/FeedbackSurvey/FeedbackSurveyView.js +0 -103
  344. package/dist/src/components/FeedbackSurvey/TranscriptSharePrompt.js +0 -83
  345. package/dist/src/components/FeedbackSurvey/submitTranscriptShare.js +0 -75
  346. package/dist/src/components/FeedbackSurvey/useDebouncedDigitInput.js +0 -51
  347. package/dist/src/components/FeedbackSurvey/useFeedbackSurvey.js +0 -258
  348. package/dist/src/components/FeedbackSurvey/useMemorySurvey.js +0 -191
  349. package/dist/src/components/FeedbackSurvey/usePostCompactSurvey.js +0 -202
  350. package/dist/src/components/FeedbackSurvey/useSurveyState.js +0 -80
  351. package/dist/src/components/FileEditToolDiff.js +0 -166
  352. package/dist/src/components/FileEditToolUpdatedMessage.js +0 -111
  353. package/dist/src/components/FileEditToolUseRejectedMessage.js +0 -157
  354. package/dist/src/components/FilePathLink.js +0 -34
  355. package/dist/src/components/FullscreenLayout.js +0 -578
  356. package/dist/src/components/GlobalSearchDialog.js +0 -339
  357. package/dist/src/components/HelpV2/Commands.js +0 -65
  358. package/dist/src/components/HelpV2/General.js +0 -24
  359. package/dist/src/components/HelpV2/HelpV2.js +0 -186
  360. package/dist/src/components/HighlightedCode/Fallback.js +0 -193
  361. package/dist/src/components/HighlightedCode.js +0 -184
  362. package/dist/src/components/HistorySearchDialog.js +0 -92
  363. package/dist/src/components/IdeAutoConnectDialog.js +0 -153
  364. package/dist/src/components/IdeOnboardingDialog.js +0 -174
  365. package/dist/src/components/IdeStatusIndicator.js +0 -49
  366. package/dist/src/components/IdleReturnDialog.js +0 -116
  367. package/dist/src/components/InterruptedByUser.js +0 -15
  368. package/dist/src/components/InvalidConfigDialog.js +0 -134
  369. package/dist/src/components/InvalidSettingsDialog.js +0 -84
  370. package/dist/src/components/KeybindingWarnings.js +0 -54
  371. package/dist/src/components/LanguagePicker.js +0 -84
  372. package/dist/src/components/LogSelector.js +0 -1579
  373. package/dist/src/components/LogoV2/AnimatedAsterisk.js +0 -42
  374. package/dist/src/components/LogoV2/AnimatedClawd.js +0 -111
  375. package/dist/src/components/LogoV2/ChannelsNotice.js +0 -258
  376. package/dist/src/components/LogoV2/Clawd.js +0 -5
  377. package/dist/src/components/LogoV2/CondensedLogo.js +0 -159
  378. package/dist/src/components/LogoV2/EmergencyTip.js +0 -47
  379. package/dist/src/components/LogoV2/Feed.js +0 -84
  380. package/dist/src/components/LogoV2/FeedColumn.js +0 -55
  381. package/dist/src/components/LogoV2/GuestPassesUpsell.js +0 -71
  382. package/dist/src/components/LogoV2/LogoV2.js +0 -565
  383. package/dist/src/components/LogoV2/Opus1mMergeNotice.js +0 -56
  384. package/dist/src/components/LogoV2/OverageCreditUpsell.js +0 -160
  385. package/dist/src/components/LogoV2/VoiceModeNotice.js +0 -70
  386. package/dist/src/components/LogoV2/WelcomeV2.js +0 -461
  387. package/dist/src/components/LogoV2/feedConfigs.js +0 -78
  388. package/dist/src/components/LspRecommendation/LspRecommendationMenu.js +0 -46
  389. package/dist/src/components/MCPServerApprovalDialog.js +0 -113
  390. package/dist/src/components/MCPServerDesktopImportDialog.js +0 -206
  391. package/dist/src/components/MCPServerDialogCopy.js +0 -15
  392. package/dist/src/components/MCPServerMultiselectDialog.js +0 -133
  393. package/dist/src/components/ManagedSettingsSecurityDialog/ManagedSettingsSecurityDialog.js +0 -149
  394. package/dist/src/components/ManagedSettingsSecurityDialog/utils.js +0 -105
  395. package/dist/src/components/Markdown.js +0 -217
  396. package/dist/src/components/MarkdownTable.js +0 -279
  397. package/dist/src/components/MemoryUsageIndicator.js +0 -27
  398. package/dist/src/components/Message.js +0 -566
  399. package/dist/src/components/MessageModel.js +0 -36
  400. package/dist/src/components/MessageResponse.js +0 -73
  401. package/dist/src/components/MessageRow.js +0 -346
  402. package/dist/src/components/MessageSelector.js +0 -743
  403. package/dist/src/components/MessageTimestamp.js +0 -57
  404. package/dist/src/components/Messages.js +0 -637
  405. package/dist/src/components/ModelPicker.js +0 -484
  406. package/dist/src/components/NativeAutoUpdater.js +0 -153
  407. package/dist/src/components/NotebookEditToolUseRejectedMessage.js +0 -83
  408. package/dist/src/components/OffscreenFreeze.js +0 -35
  409. package/dist/src/components/Onboarding.js +0 -174
  410. package/dist/src/components/OutputStylePicker.js +0 -102
  411. package/dist/src/components/PackageManagerAutoUpdater.js +0 -100
  412. package/dist/src/components/Passes/Passes.js +0 -113
  413. package/dist/src/components/PrBadge.js +0 -90
  414. package/dist/src/components/PressEnterToContinue.js +0 -15
  415. package/dist/src/components/PromptInput/HistorySearchInput.js +0 -44
  416. package/dist/src/components/PromptInput/IssueFlagBanner.js +0 -8
  417. package/dist/src/components/PromptInput/Notifications.js +0 -221
  418. package/dist/src/components/PromptInput/PromptInput.js +0 -1998
  419. package/dist/src/components/PromptInput/PromptInputFooter.js +0 -84
  420. package/dist/src/components/PromptInput/PromptInputFooterLeftSide.js +0 -409
  421. package/dist/src/components/PromptInput/PromptInputFooterSuggestions.js +0 -280
  422. package/dist/src/components/PromptInput/PromptInputHelpMenu.js +0 -379
  423. package/dist/src/components/PromptInput/PromptInputModeIndicator.js +0 -72
  424. package/dist/src/components/PromptInput/PromptInputQueuedCommands.js +0 -105
  425. package/dist/src/components/PromptInput/PromptInputStashNotice.js +0 -20
  426. package/dist/src/components/PromptInput/SandboxPromptFooterHint.js +0 -65
  427. package/dist/src/components/PromptInput/ShimmeredInput.js +0 -132
  428. package/dist/src/components/PromptInput/VoiceIndicator.js +0 -136
  429. package/dist/src/components/PromptInput/inputModes.js +0 -24
  430. package/dist/src/components/PromptInput/inputPaste.js +0 -62
  431. package/dist/src/components/PromptInput/useMaybeTruncateInput.js +0 -33
  432. package/dist/src/components/PromptInput/usePromptInputPlaceholder.js +0 -55
  433. package/dist/src/components/PromptInput/useShowFastIconHint.js +0 -23
  434. package/dist/src/components/PromptInput/useSwarmBanner.js +0 -112
  435. package/dist/src/components/PromptInput/utils.js +0 -50
  436. package/dist/src/components/QuickOpenDialog.js +0 -243
  437. package/dist/src/components/RemoteCallout.js +0 -53
  438. package/dist/src/components/RemoteEnvironmentDialog.js +0 -345
  439. package/dist/src/components/ResumeTask.js +0 -173
  440. package/dist/src/components/SandboxViolationExpandedView.js +0 -102
  441. package/dist/src/components/ScrollKeybindingHandler.js +0 -982
  442. package/dist/src/components/SearchBox.js +0 -55
  443. package/dist/src/components/SentryErrorBoundary.js +0 -16
  444. package/dist/src/components/SessionBackgroundHint.js +0 -104
  445. package/dist/src/components/SessionPreview.js +0 -200
  446. package/dist/src/components/Settings/Config.js +0 -1628
  447. package/dist/src/components/Settings/Settings.js +0 -129
  448. package/dist/src/components/Settings/Status.js +0 -230
  449. package/dist/src/components/Settings/Usage.js +0 -341
  450. package/dist/src/components/ShowInIDEPrompt.js +0 -151
  451. package/dist/src/components/SkillImprovementSurvey.js +0 -130
  452. package/dist/src/components/Spinner/FlashingChar.js +0 -51
  453. package/dist/src/components/Spinner/GlimmerMessage.js +0 -328
  454. package/dist/src/components/Spinner/ShimmerChar.js +0 -22
  455. package/dist/src/components/Spinner/SpinnerAnimationRow.js +0 -169
  456. package/dist/src/components/Spinner/SpinnerGlyph.js +0 -69
  457. package/dist/src/components/Spinner/TeammateSpinnerLine.js +0 -170
  458. package/dist/src/components/Spinner/TeammateSpinnerTree.js +0 -268
  459. package/dist/src/components/Spinner/index.js +0 -11
  460. package/dist/src/components/Spinner/teammateSelectHint.js +0 -1
  461. package/dist/src/components/Spinner/useShimmerAnimation.js +0 -22
  462. package/dist/src/components/Spinner/useStalledAnimation.js +0 -63
  463. package/dist/src/components/Spinner/utils.js +0 -77
  464. package/dist/src/components/Spinner.js +0 -470
  465. package/dist/src/components/Stats.js +0 -1000
  466. package/dist/src/components/StatusLine.js +0 -285
  467. package/dist/src/components/StatusNotices.js +0 -50
  468. package/dist/src/components/StructuredDiff/Fallback.js +0 -335
  469. package/dist/src/components/StructuredDiff/colorDiff.js +0 -26
  470. package/dist/src/components/StructuredDiff.js +0 -152
  471. package/dist/src/components/StructuredDiffList.js +0 -8
  472. package/dist/src/components/TagTabs.js +0 -100
  473. package/dist/src/components/TaskListV2.js +0 -333
  474. package/dist/src/components/TeammateViewHeader.js +0 -87
  475. package/dist/src/components/TeleportError.js +0 -191
  476. package/dist/src/components/TeleportProgress.js +0 -130
  477. package/dist/src/components/TeleportRepoMismatchDialog.js +0 -98
  478. package/dist/src/components/TeleportResumeWrapper.js +0 -158
  479. package/dist/src/components/TeleportStash.js +0 -82
  480. package/dist/src/components/TextInput.js +0 -108
  481. package/dist/src/components/ThemePicker.js +0 -330
  482. package/dist/src/components/ThinkingToggle.js +0 -153
  483. package/dist/src/components/TokenWarning.js +0 -172
  484. package/dist/src/components/ToolUseLoader.js +0 -34
  485. package/dist/src/components/TrustDialog/TrustDialog.js +0 -301
  486. package/dist/src/components/TrustDialog/utils.js +0 -199
  487. package/dist/src/components/ValidationErrorsList.js +0 -146
  488. package/dist/src/components/VimTextInput.js +0 -136
  489. package/dist/src/components/VirtualMessageList.js +0 -892
  490. package/dist/src/components/WorkflowMultiselectDialog.js +0 -118
  491. package/dist/src/components/WorktreeExitDialog.js +0 -222
  492. package/dist/src/components/agents/AgentDetail.js +0 -226
  493. package/dist/src/components/agents/AgentEditor.js +0 -146
  494. package/dist/src/components/agents/AgentNavigationFooter.js +0 -21
  495. package/dist/src/components/agents/AgentsList.js +0 -436
  496. package/dist/src/components/agents/AgentsMenu.js +0 -848
  497. package/dist/src/components/agents/ColorPicker.js +0 -110
  498. package/dist/src/components/agents/ModelSelector.js +0 -62
  499. package/dist/src/components/agents/SnapshotUpdateDialog.js +0 -16
  500. package/dist/src/components/agents/ToolSelector.js +0 -557
  501. package/dist/src/components/agents/agentFileUtils.js +0 -179
  502. package/dist/src/components/agents/generateAgent.js +0 -161
  503. package/dist/src/components/agents/new-agent-creation/CreateAgentWizard.js +0 -88
  504. package/dist/src/components/agents/new-agent-creation/wizard-steps/ColorStep.js +0 -80
  505. package/dist/src/components/agents/new-agent-creation/wizard-steps/ConfirmStep.js +0 -386
  506. package/dist/src/components/agents/new-agent-creation/wizard-steps/ConfirmStepWrapper.js +0 -63
  507. package/dist/src/components/agents/new-agent-creation/wizard-steps/DescriptionStep.js +0 -126
  508. package/dist/src/components/agents/new-agent-creation/wizard-steps/GenerateStep.js +0 -118
  509. package/dist/src/components/agents/new-agent-creation/wizard-steps/LocationStep.js +0 -79
  510. package/dist/src/components/agents/new-agent-creation/wizard-steps/MemoryStep.js +0 -107
  511. package/dist/src/components/agents/new-agent-creation/wizard-steps/MethodStep.js +0 -79
  512. package/dist/src/components/agents/new-agent-creation/wizard-steps/ModelStep.js +0 -48
  513. package/dist/src/components/agents/new-agent-creation/wizard-steps/PromptStep.js +0 -131
  514. package/dist/src/components/agents/new-agent-creation/wizard-steps/ToolsStep.js +0 -51
  515. package/dist/src/components/agents/new-agent-creation/wizard-steps/TypeStep.js +0 -100
  516. package/dist/src/components/agents/types.js +0 -4
  517. package/dist/src/components/agents/utils.js +0 -14
  518. package/dist/src/components/agents/validateAgent.js +0 -79
  519. package/dist/src/components/design-system/Byline.js +0 -72
  520. package/dist/src/components/design-system/Dialog.js +0 -116
  521. package/dist/src/components/design-system/Divider.js +0 -109
  522. package/dist/src/components/design-system/FuzzyPicker.js +0 -187
  523. package/dist/src/components/design-system/KeyboardShortcutHint.js +0 -67
  524. package/dist/src/components/design-system/ListItem.js +0 -183
  525. package/dist/src/components/design-system/LoadingState.js +0 -68
  526. package/dist/src/components/design-system/Pane.js +0 -68
  527. package/dist/src/components/design-system/ProgressBar.js +0 -62
  528. package/dist/src/components/design-system/Ratchet.js +0 -71
  529. package/dist/src/components/design-system/StatusIcon.js +0 -69
  530. package/dist/src/components/design-system/Tabs.js +0 -269
  531. package/dist/src/components/design-system/ThemeProvider.js +0 -137
  532. package/dist/src/components/design-system/ThemedBox.js +0 -125
  533. package/dist/src/components/design-system/ThemedText.js +0 -60
  534. package/dist/src/components/design-system/color.js +0 -22
  535. package/dist/src/components/diff/DiffDetailView.js +0 -284
  536. package/dist/src/components/diff/DiffDialog.js +0 -387
  537. package/dist/src/components/diff/DiffFileList.js +0 -291
  538. package/dist/src/components/grove/Grove.js +0 -483
  539. package/dist/src/components/hooks/HooksConfigMenu.js +0 -570
  540. package/dist/src/components/hooks/PromptDialog.js +0 -81
  541. package/dist/src/components/hooks/SelectEventMode.js +0 -117
  542. package/dist/src/components/hooks/SelectHookMode.js +0 -93
  543. package/dist/src/components/hooks/SelectMatcherMode.js +0 -124
  544. package/dist/src/components/hooks/ViewHookMode.js +0 -197
  545. package/dist/src/components/mcp/CapabilitiesSection.js +0 -55
  546. package/dist/src/components/mcp/ElicitationDialog.js +0 -945
  547. package/dist/src/components/mcp/MCPAgentServerMenu.js +0 -95
  548. package/dist/src/components/mcp/MCPListPanel.js +0 -504
  549. package/dist/src/components/mcp/MCPReconnect.js +0 -168
  550. package/dist/src/components/mcp/MCPRemoteServerMenu.js +0 -460
  551. package/dist/src/components/mcp/MCPSettings.js +0 -414
  552. package/dist/src/components/mcp/MCPStdioServerMenu.js +0 -95
  553. package/dist/src/components/mcp/MCPToolDetailView.js +0 -219
  554. package/dist/src/components/mcp/MCPToolListView.js +0 -136
  555. package/dist/src/components/mcp/McpParsingWarnings.js +0 -211
  556. package/dist/src/components/mcp/index.js +0 -8
  557. package/dist/src/components/mcp/types.js +0 -3
  558. package/dist/src/components/mcp/utils/reconnectHelpers.js +0 -35
  559. package/dist/src/components/memory/MemoryFileSelector.js +0 -455
  560. package/dist/src/components/memory/MemoryUpdateNotification.js +0 -42
  561. package/dist/src/components/messageActions.js +0 -418
  562. package/dist/src/components/messages/AdvisorMessage.js +0 -151
  563. package/dist/src/components/messages/AssistantRedactedThinkingMessage.js +0 -27
  564. package/dist/src/components/messages/AssistantTextMessage.js +0 -274
  565. package/dist/src/components/messages/AssistantThinkingMessage.js +0 -69
  566. package/dist/src/components/messages/AssistantToolUseMessage.js +0 -323
  567. package/dist/src/components/messages/AttachmentMessage.js +0 -418
  568. package/dist/src/components/messages/CollapsedReadSearchContent.js +0 -362
  569. package/dist/src/components/messages/CompactBoundaryMessage.js +0 -18
  570. package/dist/src/components/messages/GroupedToolUseContent.js +0 -37
  571. package/dist/src/components/messages/HighlightedThinkingText.js +0 -164
  572. package/dist/src/components/messages/HookProgressMessage.js +0 -110
  573. package/dist/src/components/messages/PlanApprovalMessage.js +0 -212
  574. package/dist/src/components/messages/RateLimitMessage.js +0 -149
  575. package/dist/src/components/messages/ShutdownMessage.js +0 -123
  576. package/dist/src/components/messages/SystemAPIErrorMessage.js +0 -135
  577. package/dist/src/components/messages/SystemTextMessage.js +0 -843
  578. package/dist/src/components/messages/TaskAssignmentMessage.js +0 -71
  579. package/dist/src/components/messages/UserAgentNotificationMessage.js +0 -77
  580. package/dist/src/components/messages/UserBashInputMessage.js +0 -51
  581. package/dist/src/components/messages/UserBashOutputMessage.js +0 -54
  582. package/dist/src/components/messages/UserChannelMessage.js +0 -129
  583. package/dist/src/components/messages/UserCommandMessage.js +0 -106
  584. package/dist/src/components/messages/UserImageMessage.js +0 -53
  585. package/dist/src/components/messages/UserLocalCommandOutputMessage.js +0 -169
  586. package/dist/src/components/messages/UserMemoryInputMessage.js +0 -72
  587. package/dist/src/components/messages/UserPlanMessage.js +0 -37
  588. package/dist/src/components/messages/UserPromptMessage.js +0 -63
  589. package/dist/src/components/messages/UserResourceUpdateMessage.js +0 -101
  590. package/dist/src/components/messages/UserTeammateMessage.js +0 -156
  591. package/dist/src/components/messages/UserTextMessage.js +0 -271
  592. package/dist/src/components/messages/UserToolResultMessage/RejectedPlanMessage.js +0 -27
  593. package/dist/src/components/messages/UserToolResultMessage/RejectedToolUseMessage.js +0 -16
  594. package/dist/src/components/messages/UserToolResultMessage/UserToolCanceledMessage.js +0 -16
  595. package/dist/src/components/messages/UserToolResultMessage/UserToolErrorMessage.js +0 -91
  596. package/dist/src/components/messages/UserToolResultMessage/UserToolRejectMessage.js +0 -73
  597. package/dist/src/components/messages/UserToolResultMessage/UserToolResultMessage.js +0 -83
  598. package/dist/src/components/messages/UserToolResultMessage/UserToolSuccessMessage.js +0 -58
  599. package/dist/src/components/messages/UserToolResultMessage/utils.js +0 -43
  600. package/dist/src/components/messages/nullRenderingAttachments.js +0 -58
  601. package/dist/src/components/messages/teamMemCollapsed.js +0 -142
  602. package/dist/src/components/messages/teamMemSaved.js +0 -17
  603. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/AskUserQuestionPermissionRequest.js +0 -654
  604. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/PreviewBox.js +0 -219
  605. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/PreviewQuestionView.js +0 -227
  606. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/QuestionNavigationBar.js +0 -174
  607. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/QuestionView.js +0 -444
  608. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/SubmitQuestionsView.js +0 -136
  609. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/use-multiple-choice-state.js +0 -100
  610. package/dist/src/components/permissions/BashPermissionRequest/BashPermissionRequest.js +0 -404
  611. package/dist/src/components/permissions/BashPermissionRequest/bashToolUseOptions.js +0 -110
  612. package/dist/src/components/permissions/ComputerUseApproval/ComputerUseApproval.js +0 -448
  613. package/dist/src/components/permissions/EnterPlanModePermissionRequest/EnterPlanModePermissionRequest.js +0 -125
  614. package/dist/src/components/permissions/ExitPlanModePermissionRequest/ExitPlanModePermissionRequest.js +0 -650
  615. package/dist/src/components/permissions/FallbackPermissionRequest.js +0 -348
  616. package/dist/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js +0 -184
  617. package/dist/src/components/permissions/FilePermissionDialog/FilePermissionDialog.js +0 -108
  618. package/dist/src/components/permissions/FilePermissionDialog/ideDiffConfig.js +0 -13
  619. package/dist/src/components/permissions/FilePermissionDialog/permissionOptions.js +0 -136
  620. package/dist/src/components/permissions/FilePermissionDialog/useFilePermissionDialog.js +0 -131
  621. package/dist/src/components/permissions/FilePermissionDialog/usePermissionHandler.js +0 -86
  622. package/dist/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js +0 -163
  623. package/dist/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js +0 -78
  624. package/dist/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +0 -112
  625. package/dist/src/components/permissions/NotebookEditPermissionRequest/NotebookEditPermissionRequest.js +0 -163
  626. package/dist/src/components/permissions/NotebookEditPermissionRequest/NotebookEditToolDiff.js +0 -217
  627. package/dist/src/components/permissions/PermissionDecisionDebugInfo.js +0 -466
  628. package/dist/src/components/permissions/PermissionDialog.js +0 -54
  629. package/dist/src/components/permissions/PermissionExplanation.js +0 -269
  630. package/dist/src/components/permissions/PermissionPrompt.js +0 -316
  631. package/dist/src/components/permissions/PermissionRequest.js +0 -160
  632. package/dist/src/components/permissions/PermissionRequestTitle.js +0 -57
  633. package/dist/src/components/permissions/PermissionRuleExplanation.js +0 -109
  634. package/dist/src/components/permissions/PowerShellPermissionRequest/PowerShellPermissionRequest.js +0 -178
  635. package/dist/src/components/permissions/PowerShellPermissionRequest/powershellToolUseOptions.js +0 -73
  636. package/dist/src/components/permissions/SandboxPermissionRequest.js +0 -161
  637. package/dist/src/components/permissions/SedEditPermissionRequest/SedEditPermissionRequest.js +0 -228
  638. package/dist/src/components/permissions/SkillPermissionRequest/SkillPermissionRequest.js +0 -384
  639. package/dist/src/components/permissions/WebFetchPermissionRequest/WebFetchPermissionRequest.js +0 -258
  640. package/dist/src/components/permissions/WorkerBadge.js +0 -43
  641. package/dist/src/components/permissions/WorkerPendingPermission.js +0 -106
  642. package/dist/src/components/permissions/hooks.js +0 -163
  643. package/dist/src/components/permissions/rules/AddPermissionRules.js +0 -170
  644. package/dist/src/components/permissions/rules/AddWorkspaceDirectory.js +0 -334
  645. package/dist/src/components/permissions/rules/PermissionRuleDescription.js +0 -77
  646. package/dist/src/components/permissions/rules/PermissionRuleInput.js +0 -135
  647. package/dist/src/components/permissions/rules/PermissionRuleList.js +0 -1189
  648. package/dist/src/components/permissions/rules/RecentDenialsTab.js +0 -204
  649. package/dist/src/components/permissions/rules/RemoveWorkspaceDirectory.js +0 -102
  650. package/dist/src/components/permissions/rules/WorkspaceTab.js +0 -132
  651. package/dist/src/components/permissions/shellPermissionHelpers.js +0 -111
  652. package/dist/src/components/permissions/useShellPermissionFeedback.js +0 -108
  653. package/dist/src/components/permissions/utils.js +0 -14
  654. package/dist/src/components/sandbox/SandboxConfigTab.js +0 -47
  655. package/dist/src/components/sandbox/SandboxDependenciesTab.js +0 -122
  656. package/dist/src/components/sandbox/SandboxDoctorSection.js +0 -46
  657. package/dist/src/components/sandbox/SandboxOverridesTab.js +0 -192
  658. package/dist/src/components/sandbox/SandboxSettings.js +0 -296
  659. package/dist/src/components/shell/ExpandShellOutputContext.js +0 -33
  660. package/dist/src/components/shell/OutputLine.js +0 -110
  661. package/dist/src/components/shell/ShellProgressMessage.js +0 -143
  662. package/dist/src/components/shell/ShellTimeDisplay.js +0 -71
  663. package/dist/src/components/skills/SkillsMenu.js +0 -238
  664. package/dist/src/components/tasks/AsyncAgentDetailDialog.js +0 -234
  665. package/dist/src/components/tasks/BackgroundTask.js +0 -363
  666. package/dist/src/components/tasks/BackgroundTaskStatus.js +0 -419
  667. package/dist/src/components/tasks/BackgroundTasksDialog.js +0 -496
  668. package/dist/src/components/tasks/DreamDetailDialog.js +0 -250
  669. package/dist/src/components/tasks/InProcessTeammateDetailDialog.js +0 -274
  670. package/dist/src/components/tasks/RemoteSessionDetailDialog.js +0 -868
  671. package/dist/src/components/tasks/RemoteSessionProgress.js +0 -249
  672. package/dist/src/components/tasks/ShellDetailDialog.js +0 -403
  673. package/dist/src/components/tasks/ShellProgress.js +0 -76
  674. package/dist/src/components/tasks/renderToolActivity.js +0 -28
  675. package/dist/src/components/tasks/taskStatusUtils.js +0 -94
  676. package/dist/src/components/teams/TeamStatus.js +0 -76
  677. package/dist/src/components/teams/TeamsDialog.js +0 -672
  678. package/dist/src/components/ui/OrderedList.js +0 -66
  679. package/dist/src/components/ui/OrderedListItem.js +0 -41
  680. package/dist/src/components/ui/TreeSelect.js +0 -300
  681. package/dist/src/components/wizard/WizardDialogLayout.js +0 -47
  682. package/dist/src/components/wizard/WizardNavigationFooter.js +0 -10
  683. package/dist/src/components/wizard/WizardProvider.js +0 -217
  684. package/dist/src/components/wizard/index.js +0 -4
  685. package/dist/src/components/wizard/useWizard.js +0 -9
  686. package/dist/src/constants/apiLimits.js +0 -81
  687. package/dist/src/constants/betas.js +0 -45
  688. package/dist/src/constants/common.js +0 -29
  689. package/dist/src/constants/cyberRiskInstruction.js +0 -24
  690. package/dist/src/constants/errorIds.js +0 -14
  691. package/dist/src/constants/figures.js +0 -38
  692. package/dist/src/constants/files.js +0 -150
  693. package/dist/src/constants/github-app.js +0 -139
  694. package/dist/src/constants/keys.js +0 -10
  695. package/dist/src/constants/messages.js +0 -1
  696. package/dist/src/constants/oauth.js +0 -221
  697. package/dist/src/constants/outputStyles.js +0 -162
  698. package/dist/src/constants/product.js +0 -56
  699. package/dist/src/constants/prompts.js +0 -752
  700. package/dist/src/constants/spinnerVerbs.js +0 -202
  701. package/dist/src/constants/system.js +0 -77
  702. package/dist/src/constants/systemPromptSections.js +0 -39
  703. package/dist/src/constants/toolLimits.js +0 -50
  704. package/dist/src/constants/tools.js +0 -103
  705. package/dist/src/constants/turnCompletionVerbs.js +0 -12
  706. package/dist/src/constants/xml.js +0 -73
  707. package/dist/src/context/QueuedMessageContext.js +0 -51
  708. package/dist/src/context/fpsMetrics.js +0 -22
  709. package/dist/src/context/mailbox.js +0 -35
  710. package/dist/src/context/modalContext.js +0 -34
  711. package/dist/src/context/notifications.js +0 -199
  712. package/dist/src/context/overlayContext.js +0 -149
  713. package/dist/src/context/promptOverlayContext.js +0 -118
  714. package/dist/src/context/stats.js +0 -207
  715. package/dist/src/context/voice.js +0 -74
  716. package/dist/src/context.js +0 -146
  717. package/dist/src/coordinator/coordinatorMode.js +0 -345
  718. package/dist/src/cost-tracker.js +0 -208
  719. package/dist/src/costHook.js +0 -17
  720. package/dist/src/daemon/main.js +0 -16
  721. package/dist/src/daemon/workerRegistry.js +0 -16
  722. package/dist/src/dialogLaunchers.js +0 -68
  723. package/dist/src/entrypoints/agentSdkTypes.js +0 -202
  724. package/dist/src/entrypoints/cli.js +0 -237
  725. package/dist/src/entrypoints/init.js +0 -265
  726. package/dist/src/entrypoints/mcp.js +0 -142
  727. package/dist/src/entrypoints/sandboxTypes.js +0 -112
  728. package/dist/src/entrypoints/sdk/controlSchemas.js +0 -452
  729. package/dist/src/entrypoints/sdk/controlTypes.js +0 -1
  730. package/dist/src/entrypoints/sdk/coreSchemas.js +0 -1331
  731. package/dist/src/entrypoints/sdk/coreTypes.generated.js +0 -1
  732. package/dist/src/entrypoints/sdk/coreTypes.js +0 -49
  733. package/dist/src/entrypoints/sdk/runtimeTypes.js +0 -1
  734. package/dist/src/entrypoints/sdk/toolTypes.js +0 -1
  735. package/dist/src/environment-runner/main.js +0 -16
  736. package/dist/src/history.js +0 -386
  737. package/dist/src/hooks/fileSuggestions.js +0 -635
  738. package/dist/src/hooks/notifs/useAutoModeUnavailableNotification.js +0 -47
  739. package/dist/src/hooks/notifs/useCanSwitchToExistingSubscription.js +0 -57
  740. package/dist/src/hooks/notifs/useDeprecationWarningNotification.js +0 -43
  741. package/dist/src/hooks/notifs/useFastModeNotification.js +0 -164
  742. package/dist/src/hooks/notifs/useIDEStatusIndicator.js +0 -174
  743. package/dist/src/hooks/notifs/useInstallMessages.js +0 -27
  744. package/dist/src/hooks/notifs/useLspInitializationNotification.js +0 -144
  745. package/dist/src/hooks/notifs/useMcpConnectivityStatus.js +0 -80
  746. package/dist/src/hooks/notifs/useModelMigrationNotifications.js +0 -53
  747. package/dist/src/hooks/notifs/useNpmDeprecationNotification.js +0 -24
  748. package/dist/src/hooks/notifs/usePluginAutoupdateNotification.js +0 -82
  749. package/dist/src/hooks/notifs/usePluginInstallationStatus.js +0 -127
  750. package/dist/src/hooks/notifs/useRateLimitWarningNotification.js +0 -118
  751. package/dist/src/hooks/notifs/useSettingsErrors.js +0 -64
  752. package/dist/src/hooks/notifs/useStartupNotification.js +0 -33
  753. package/dist/src/hooks/notifs/useTeammateShutdownNotification.js +0 -64
  754. package/dist/src/hooks/renderPlaceholder.js +0 -26
  755. package/dist/src/hooks/toolPermission/PermissionContext.js +0 -211
  756. package/dist/src/hooks/toolPermission/handlers/coordinatorHandler.js +0 -44
  757. package/dist/src/hooks/toolPermission/handlers/interactiveHandler.js +0 -397
  758. package/dist/src/hooks/toolPermission/handlers/swarmWorkerHandler.js +0 -108
  759. package/dist/src/hooks/toolPermission/permissionLogging.js +0 -145
  760. package/dist/src/hooks/unifiedSuggestions.js +0 -130
  761. package/dist/src/hooks/useAfterFirstRender.js +0 -12
  762. package/dist/src/hooks/useApiKeyVerification.js +0 -63
  763. package/dist/src/hooks/useArrowKeyHistory.js +0 -203
  764. package/dist/src/hooks/useAssistantHistory.js +0 -194
  765. package/dist/src/hooks/useAwaySummary.js +0 -105
  766. package/dist/src/hooks/useBackgroundTaskNavigation.js +0 -204
  767. package/dist/src/hooks/useBlink.js +0 -28
  768. package/dist/src/hooks/useCanUseTool.js +0 -192
  769. package/dist/src/hooks/useCancelRequest.js +0 -195
  770. package/dist/src/hooks/useChromeExtensionNotification.js +0 -49
  771. package/dist/src/hooks/useClaudeCodeHintRecommendation.js +0 -117
  772. package/dist/src/hooks/useClipboardImageHint.js +0 -59
  773. package/dist/src/hooks/useCommandKeybindings.js +0 -87
  774. package/dist/src/hooks/useCommandQueue.js +0 -10
  775. package/dist/src/hooks/useCopyOnSelect.js +0 -88
  776. package/dist/src/hooks/useDeferredHookMessages.js +0 -43
  777. package/dist/src/hooks/useDiffData.js +0 -69
  778. package/dist/src/hooks/useDiffInIDE.js +0 -252
  779. package/dist/src/hooks/useDirectConnect.js +0 -150
  780. package/dist/src/hooks/useDoublePress.js +0 -44
  781. package/dist/src/hooks/useDynamicConfig.js +0 -17
  782. package/dist/src/hooks/useElapsedTime.js +0 -25
  783. package/dist/src/hooks/useExitOnCtrlCD.js +0 -57
  784. package/dist/src/hooks/useExitOnCtrlCDWithKeybindings.js +0 -17
  785. package/dist/src/hooks/useFileHistorySnapshotInit.js +0 -14
  786. package/dist/src/hooks/useGlobalKeybindings.js +0 -215
  787. package/dist/src/hooks/useHistorySearch.js +0 -241
  788. package/dist/src/hooks/useIDEIntegration.js +0 -56
  789. package/dist/src/hooks/useIdeAtMentioned.js +0 -51
  790. package/dist/src/hooks/useIdeConnectionStatus.js +0 -21
  791. package/dist/src/hooks/useIdeLogging.js +0 -29
  792. package/dist/src/hooks/useIdeSelection.js +0 -106
  793. package/dist/src/hooks/useInboxPoller.js +0 -709
  794. package/dist/src/hooks/useInputBuffer.js +0 -73
  795. package/dist/src/hooks/useIssueFlagBanner.js +0 -115
  796. package/dist/src/hooks/useLogMessages.js +0 -98
  797. package/dist/src/hooks/useLspPluginRecommendation.js +0 -176
  798. package/dist/src/hooks/useMailboxBridge.js +0 -15
  799. package/dist/src/hooks/useMainLoopModel.js +0 -25
  800. package/dist/src/hooks/useManagePlugins.js +0 -261
  801. package/dist/src/hooks/useMemoryUsage.js +0 -28
  802. package/dist/src/hooks/useMergedClients.js +0 -11
  803. package/dist/src/hooks/useMergedCommands.js +0 -10
  804. package/dist/src/hooks/useMergedTools.js +0 -32
  805. package/dist/src/hooks/useMinDisplayTime.js +0 -26
  806. package/dist/src/hooks/useNotifyAfterTimeout.js +0 -51
  807. package/dist/src/hooks/useOfficialMarketplaceNotification.js +0 -46
  808. package/dist/src/hooks/usePasteHandler.js +0 -188
  809. package/dist/src/hooks/usePluginRecommendationBase.js +0 -101
  810. package/dist/src/hooks/usePrStatus.js +0 -91
  811. package/dist/src/hooks/usePromptSuggestion.js +0 -128
  812. package/dist/src/hooks/usePromptsFromClaudeInChrome.js +0 -66
  813. package/dist/src/hooks/useQueueProcessor.js +0 -46
  814. package/dist/src/hooks/useRemoteSession.js +0 -431
  815. package/dist/src/hooks/useReplBridge.js +0 -717
  816. package/dist/src/hooks/useSSHSession.js +0 -167
  817. package/dist/src/hooks/useScheduledTasks.js +0 -104
  818. package/dist/src/hooks/useSearchInput.js +0 -302
  819. package/dist/src/hooks/useSessionBackgrounding.js +0 -132
  820. package/dist/src/hooks/useSettings.js +0 -10
  821. package/dist/src/hooks/useSettingsChange.js +0 -13
  822. package/dist/src/hooks/useSkillImprovementSurvey.js +0 -69
  823. package/dist/src/hooks/useSkillsChange.js +0 -51
  824. package/dist/src/hooks/useSwarmInitialization.js +0 -67
  825. package/dist/src/hooks/useSwarmPermissionPoller.js +0 -215
  826. package/dist/src/hooks/useTaskListWatcher.js +0 -157
  827. package/dist/src/hooks/useTasksV2.js +0 -220
  828. package/dist/src/hooks/useTeammateViewAutoExit.js +0 -55
  829. package/dist/src/hooks/useTelegramMirror.js +0 -47
  830. package/dist/src/hooks/useTeleportResume.js +0 -81
  831. package/dist/src/hooks/useTerminalSize.js +0 -9
  832. package/dist/src/hooks/useTextInput.js +0 -397
  833. package/dist/src/hooks/useTimeout.js +0 -10
  834. package/dist/src/hooks/useTurnDiffs.js +0 -160
  835. package/dist/src/hooks/useTypeahead.js +0 -1392
  836. package/dist/src/hooks/useUpdateNotification.js +0 -22
  837. package/dist/src/hooks/useVimInput.js +0 -232
  838. package/dist/src/hooks/useVirtualScroll.js +0 -627
  839. package/dist/src/hooks/useVoice.js +0 -954
  840. package/dist/src/hooks/useVoiceEnabled.js +0 -21
  841. package/dist/src/hooks/useVoiceIntegration.js +0 -631
  842. package/dist/src/hooks/useWhatsAppMirror.js +0 -46
  843. package/dist/src/index.js +0 -18
  844. package/dist/src/ink/Ansi.js +0 -269
  845. package/dist/src/ink/bidi.js +0 -117
  846. package/dist/src/ink/clearTerminal.js +0 -58
  847. package/dist/src/ink/colorize.js +0 -198
  848. package/dist/src/ink/components/AlternateScreen.js +0 -74
  849. package/dist/src/ink/components/App.js +0 -558
  850. package/dist/src/ink/components/AppContext.js +0 -11
  851. package/dist/src/ink/components/Box.js +0 -153
  852. package/dist/src/ink/components/Button.js +0 -166
  853. package/dist/src/ink/components/ClockContext.js +0 -108
  854. package/dist/src/ink/components/CursorDeclarationContext.js +0 -3
  855. package/dist/src/ink/components/ErrorOverview.js +0 -49
  856. package/dist/src/ink/components/Link.js +0 -33
  857. package/dist/src/ink/components/Newline.js +0 -29
  858. package/dist/src/ink/components/NoSelect.js +0 -56
  859. package/dist/src/ink/components/RawAnsi.js +0 -45
  860. package/dist/src/ink/components/ScrollBox.js +0 -170
  861. package/dist/src/ink/components/Spacer.js +0 -19
  862. package/dist/src/ink/components/StdinContext.js +0 -16
  863. package/dist/src/ink/components/TerminalFocusContext.js +0 -45
  864. package/dist/src/ink/components/TerminalSizeContext.js +0 -3
  865. package/dist/src/ink/components/Text.js +0 -194
  866. package/dist/src/ink/constants.js +0 -2
  867. package/dist/src/ink/devtools.js +0 -16
  868. package/dist/src/ink/dom.js +0 -298
  869. package/dist/src/ink/events/click-event.js +0 -36
  870. package/dist/src/ink/events/dispatcher.js +0 -172
  871. package/dist/src/ink/events/emitter.js +0 -31
  872. package/dist/src/ink/events/event-handlers.js +0 -30
  873. package/dist/src/ink/events/event.js +0 -9
  874. package/dist/src/ink/events/focus-event.js +0 -16
  875. package/dist/src/ink/events/input-event.js +0 -161
  876. package/dist/src/ink/events/keyboard-event.js +0 -45
  877. package/dist/src/ink/events/terminal-event.js +0 -78
  878. package/dist/src/ink/events/terminal-focus-event.js +0 -15
  879. package/dist/src/ink/focus.js +0 -158
  880. package/dist/src/ink/frame.js +0 -30
  881. package/dist/src/ink/get-max-width.js +0 -23
  882. package/dist/src/ink/hit-test.js +0 -113
  883. package/dist/src/ink/hooks/use-animation-frame.js +0 -48
  884. package/dist/src/ink/hooks/use-app.js +0 -7
  885. package/dist/src/ink/hooks/use-declared-cursor.js +0 -60
  886. package/dist/src/ink/hooks/use-input.js +0 -70
  887. package/dist/src/ink/hooks/use-interval.js +0 -54
  888. package/dist/src/ink/hooks/use-search-highlight.js +0 -32
  889. package/dist/src/ink/hooks/use-selection.js +0 -60
  890. package/dist/src/ink/hooks/use-stdin.js +0 -7
  891. package/dist/src/ink/hooks/use-tab-status.js +0 -57
  892. package/dist/src/ink/hooks/use-terminal-focus.js +0 -15
  893. package/dist/src/ink/hooks/use-terminal-title.js +0 -29
  894. package/dist/src/ink/hooks/use-terminal-viewport.js +0 -77
  895. package/dist/src/ink/ink.js +0 -1644
  896. package/dist/src/ink/instances.js +0 -7
  897. package/dist/src/ink/layout/engine.js +0 -4
  898. package/dist/src/ink/layout/geometry.js +0 -61
  899. package/dist/src/ink/layout/node.js +0 -62
  900. package/dist/src/ink/layout/yoga.js +0 -237
  901. package/dist/src/ink/line-width-cache.js +0 -19
  902. package/dist/src/ink/log-update.js +0 -583
  903. package/dist/src/ink/measure-element.js +0 -8
  904. package/dist/src/ink/measure-text.js +0 -35
  905. package/dist/src/ink/node-cache.js +0 -30
  906. package/dist/src/ink/optimizer.js +0 -81
  907. package/dist/src/ink/output.js +0 -556
  908. package/dist/src/ink/parse-keypress.js +0 -695
  909. package/dist/src/ink/reconciler.js +0 -384
  910. package/dist/src/ink/render-border.js +0 -134
  911. package/dist/src/ink/render-node-to-output.js +0 -1216
  912. package/dist/src/ink/render-to-screen.js +0 -171
  913. package/dist/src/ink/renderer.js +0 -129
  914. package/dist/src/ink/root.js +0 -80
  915. package/dist/src/ink/screen.js +0 -1132
  916. package/dist/src/ink/searchHighlight.js +0 -78
  917. package/dist/src/ink/selection.js +0 -792
  918. package/dist/src/ink/squash-text-nodes.js +0 -56
  919. package/dist/src/ink/stringWidth.js +0 -200
  920. package/dist/src/ink/styles.js +0 -299
  921. package/dist/src/ink/supports-hyperlinks.js +0 -40
  922. package/dist/src/ink/tabstops.js +0 -39
  923. package/dist/src/ink/terminal-focus-state.js +0 -35
  924. package/dist/src/ink/terminal-querier.js +0 -173
  925. package/dist/src/ink/terminal.js +0 -208
  926. package/dist/src/ink/termio/ansi.js +0 -70
  927. package/dist/src/ink/termio/csi.js +0 -260
  928. package/dist/src/ink/termio/dec.js +0 -53
  929. package/dist/src/ink/termio/esc.js +0 -55
  930. package/dist/src/ink/termio/osc.js +0 -432
  931. package/dist/src/ink/termio/parser.js +0 -356
  932. package/dist/src/ink/termio/sgr.js +0 -292
  933. package/dist/src/ink/termio/tokenize.js +0 -264
  934. package/dist/src/ink/termio/types.js +0 -55
  935. package/dist/src/ink/termio.js +0 -24
  936. package/dist/src/ink/useTerminalNotification.js +0 -57
  937. package/dist/src/ink/warn.js +0 -10
  938. package/dist/src/ink/widest-line.js +0 -14
  939. package/dist/src/ink/wrap-text.js +0 -54
  940. package/dist/src/ink/wrapAnsi.js +0 -6
  941. package/dist/src/ink.js +0 -50
  942. package/dist/src/interactiveHelpers.js +0 -317
  943. package/dist/src/keybindings/KeybindingContext.js +0 -184
  944. package/dist/src/keybindings/KeybindingProviderSetup.js +0 -259
  945. package/dist/src/keybindings/defaultBindings.js +0 -333
  946. package/dist/src/keybindings/loadUserBindings.js +0 -393
  947. package/dist/src/keybindings/match.js +0 -111
  948. package/dist/src/keybindings/parser.js +0 -184
  949. package/dist/src/keybindings/reservedShortcuts.js +0 -109
  950. package/dist/src/keybindings/resolver.js +0 -182
  951. package/dist/src/keybindings/schema.js +0 -205
  952. package/dist/src/keybindings/shortcutFormat.js +0 -48
  953. package/dist/src/keybindings/template.js +0 -40
  954. package/dist/src/keybindings/useKeybinding.js +0 -161
  955. package/dist/src/keybindings/useShortcutDisplay.js +0 -43
  956. package/dist/src/keybindings/validate.js +0 -395
  957. package/dist/src/main.js +0 -4073
  958. package/dist/src/memdir/findRelevantMemories.js +0 -101
  959. package/dist/src/memdir/memdir.js +0 -408
  960. package/dist/src/memdir/memoryAge.js +0 -52
  961. package/dist/src/memdir/memoryScan.js +0 -65
  962. package/dist/src/memdir/memoryTypes.js +0 -260
  963. package/dist/src/memdir/paths.js +0 -236
  964. package/dist/src/memdir/teamMemPaths.js +0 -261
  965. package/dist/src/memdir/teamMemPrompts.js +0 -82
  966. package/dist/src/migrations/migrateAutoUpdatesToSettings.js +0 -47
  967. package/dist/src/migrations/migrateBypassPermissionsAcceptedToSettings.js +0 -32
  968. package/dist/src/migrations/migrateEnableAllProjectMcpServersToSettings.js +0 -83
  969. package/dist/src/migrations/migrateFennecToOpus.js +0 -39
  970. package/dist/src/migrations/migrateLegacyOpusToCurrent.js +0 -44
  971. package/dist/src/migrations/migrateOpusToOpus1m.js +0 -31
  972. package/dist/src/migrations/migrateReplBridgeEnabledToRemoteControlAtStartup.js +0 -23
  973. package/dist/src/migrations/migrateSonnet1mToSonnet45.js +0 -38
  974. package/dist/src/migrations/migrateSonnet45ToSonnet46.js +0 -48
  975. package/dist/src/migrations/resetAutoModeOptInForDefaultOffer.js +0 -47
  976. package/dist/src/migrations/resetProToOpusDefault.js +0 -46
  977. package/dist/src/mirrors/shared.js +0 -186
  978. package/dist/src/moreright/useMoreRight.js +0 -13
  979. package/dist/src/native-ts/color-diff/index.js +0 -821
  980. package/dist/src/native-ts/file-index/index.js +0 -328
  981. package/dist/src/native-ts/yoga-layout/enums.js +0 -101
  982. package/dist/src/native-ts/yoga-layout/index.js +0 -2113
  983. package/dist/src/outputStyles/loadOutputStylesDir.js +0 -71
  984. package/dist/src/plugins/builtinPlugins.js +0 -132
  985. package/dist/src/plugins/bundled/index.js +0 -22
  986. package/dist/src/projectOnboardingState.js +0 -61
  987. package/dist/src/query/config.js +0 -17
  988. package/dist/src/query/deps.js +0 -12
  989. package/dist/src/query/stopHooks.js +0 -334
  990. package/dist/src/query/tokenBudget.js +0 -49
  991. package/dist/src/query.js +0 -1330
  992. package/dist/src/recovery/bunBundleShim.js +0 -11
  993. package/dist/src/remote/RemoteSessionManager.js +0 -195
  994. package/dist/src/remote/SessionsWebSocket.js +0 -305
  995. package/dist/src/remote/remotePermissionBridge.js +0 -70
  996. package/dist/src/remote/sdkMessageAdapter.js +0 -227
  997. package/dist/src/replLauncher.js +0 -6
  998. package/dist/src/schemas/hooks.js +0 -174
  999. package/dist/src/screens/Doctor.js +0 -580
  1000. package/dist/src/screens/REPL.js +0 -4434
  1001. package/dist/src/screens/ResumeConversation.js +0 -341
  1002. package/dist/src/self-hosted-runner/main.js +0 -16
  1003. package/dist/src/server/backends/dangerousBackend.js +0 -16
  1004. package/dist/src/server/connectHeadless.js +0 -16
  1005. package/dist/src/server/createDirectConnectSession.js +0 -62
  1006. package/dist/src/server/directConnectManager.js +0 -153
  1007. package/dist/src/server/lockfile.js +0 -16
  1008. package/dist/src/server/parseConnectUrl.js +0 -16
  1009. package/dist/src/server/server.js +0 -16
  1010. package/dist/src/server/serverBanner.js +0 -16
  1011. package/dist/src/server/serverLog.js +0 -16
  1012. package/dist/src/server/sessionManager.js +0 -16
  1013. package/dist/src/server/types.js +0 -7
  1014. package/dist/src/services/AgentSummary/agentSummary.js +0 -147
  1015. package/dist/src/services/MagicDocs/magicDocs.js +0 -193
  1016. package/dist/src/services/MagicDocs/prompts.js +0 -110
  1017. package/dist/src/services/PromptSuggestion/promptSuggestion.js +0 -402
  1018. package/dist/src/services/PromptSuggestion/speculation.js +0 -643
  1019. package/dist/src/services/SessionMemory/prompts.js +0 -254
  1020. package/dist/src/services/SessionMemory/sessionMemory.js +0 -358
  1021. package/dist/src/services/SessionMemory/sessionMemoryUtils.js +0 -157
  1022. package/dist/src/services/analytics/config.js +0 -33
  1023. package/dist/src/services/analytics/datadog.js +0 -259
  1024. package/dist/src/services/analytics/firstPartyEventLogger.js +0 -342
  1025. package/dist/src/services/analytics/firstPartyEventLoggingExporter.js +0 -594
  1026. package/dist/src/services/analytics/growthbook.js +0 -952
  1027. package/dist/src/services/analytics/index.js +0 -114
  1028. package/dist/src/services/analytics/metadata.js +0 -698
  1029. package/dist/src/services/analytics/sink.js +0 -95
  1030. package/dist/src/services/analytics/sinkKillswitch.js +0 -19
  1031. package/dist/src/services/api/adminRequests.js +0 -57
  1032. package/dist/src/services/api/bootstrap.js +0 -149
  1033. package/dist/src/services/api/claude.js +0 -2461
  1034. package/dist/src/services/api/client.js +0 -325
  1035. package/dist/src/services/api/dumpPrompts.js +0 -174
  1036. package/dist/src/services/api/emptyUsage.js +0 -20
  1037. package/dist/src/services/api/errorUtils.js +0 -203
  1038. package/dist/src/services/api/errors.js +0 -934
  1039. package/dist/src/services/api/filesApi.js +0 -523
  1040. package/dist/src/services/api/firstTokenDate.js +0 -49
  1041. package/dist/src/services/api/grove.js +0 -272
  1042. package/dist/src/services/api/index.js +0 -23
  1043. package/dist/src/services/api/logging.js +0 -484
  1044. package/dist/src/services/api/metricsOptOut.js +0 -127
  1045. package/dist/src/services/api/openai.js +0 -1187
  1046. package/dist/src/services/api/openrouter.js +0 -30
  1047. package/dist/src/services/api/overageCreditGrant.js +0 -123
  1048. package/dist/src/services/api/promptCacheBreakDetection.js +0 -510
  1049. package/dist/src/services/api/referral.js +0 -219
  1050. package/dist/src/services/api/sessionIngress.js +0 -358
  1051. package/dist/src/services/api/ultrareviewQuota.js +0 -29
  1052. package/dist/src/services/api/usage.js +0 -31
  1053. package/dist/src/services/api/withRetry.js +0 -599
  1054. package/dist/src/services/autoDream/autoDream.js +0 -244
  1055. package/dist/src/services/autoDream/config.js +0 -17
  1056. package/dist/src/services/autoDream/consolidationLock.js +0 -122
  1057. package/dist/src/services/autoDream/consolidationPrompt.js +0 -56
  1058. package/dist/src/services/awaySummary.js +0 -61
  1059. package/dist/src/services/claudeAiLimits.js +0 -331
  1060. package/dist/src/services/claudeAiLimitsHook.js +0 -15
  1061. package/dist/src/services/compact/apiMicrocompact.js +0 -97
  1062. package/dist/src/services/compact/autoCompact.js +0 -236
  1063. package/dist/src/services/compact/cachedMicrocompact.js +0 -16
  1064. package/dist/src/services/compact/compact.js +0 -1258
  1065. package/dist/src/services/compact/compactWarningHook.js +0 -12
  1066. package/dist/src/services/compact/compactWarningState.js +0 -15
  1067. package/dist/src/services/compact/grouping.js +0 -58
  1068. package/dist/src/services/compact/microCompact.js +0 -414
  1069. package/dist/src/services/compact/postCompactCleanup.js +0 -72
  1070. package/dist/src/services/compact/prompt.js +0 -327
  1071. package/dist/src/services/compact/sessionMemoryCompact.js +0 -467
  1072. package/dist/src/services/compact/timeBasedMCConfig.js +0 -11
  1073. package/dist/src/services/diagnosticTracking.js +0 -282
  1074. package/dist/src/services/extractMemories/extractMemories.js +0 -444
  1075. package/dist/src/services/extractMemories/prompts.js +0 -129
  1076. package/dist/src/services/internalLogging.js +0 -68
  1077. package/dist/src/services/lsp/LSPClient.js +0 -306
  1078. package/dist/src/services/lsp/LSPDiagnosticRegistry.js +0 -277
  1079. package/dist/src/services/lsp/LSPServerInstance.js +0 -390
  1080. package/dist/src/services/lsp/LSPServerManager.js +0 -305
  1081. package/dist/src/services/lsp/config.js +0 -57
  1082. package/dist/src/services/lsp/manager.js +0 -246
  1083. package/dist/src/services/lsp/passiveFeedback.js +0 -226
  1084. package/dist/src/services/mcp/InProcessTransport.js +0 -54
  1085. package/dist/src/services/mcp/MCPConnectionManager.js +0 -50
  1086. package/dist/src/services/mcp/SdkControlTransport.js +0 -115
  1087. package/dist/src/services/mcp/auth.js +0 -1882
  1088. package/dist/src/services/mcp/channelAllowlist.js +0 -57
  1089. package/dist/src/services/mcp/channelNotification.js +0 -236
  1090. package/dist/src/services/mcp/channelPermissions.js +0 -192
  1091. package/dist/src/services/mcp/claudeai.js +0 -123
  1092. package/dist/src/services/mcp/client.js +0 -2480
  1093. package/dist/src/services/mcp/config.js +0 -1277
  1094. package/dist/src/services/mcp/elicitationHandler.js +0 -192
  1095. package/dist/src/services/mcp/envExpansion.js +0 -30
  1096. package/dist/src/services/mcp/headersHelper.js +0 -94
  1097. package/dist/src/services/mcp/mcpStringUtils.js +0 -85
  1098. package/dist/src/services/mcp/normalization.js +0 -21
  1099. package/dist/src/services/mcp/oauthPort.js +0 -69
  1100. package/dist/src/services/mcp/officialRegistry.js +0 -54
  1101. package/dist/src/services/mcp/types.js +0 -94
  1102. package/dist/src/services/mcp/useManageMCPConnections.js +0 -820
  1103. package/dist/src/services/mcp/utils.js +0 -433
  1104. package/dist/src/services/mcp/vscodeSdkMcp.js +0 -69
  1105. package/dist/src/services/mcp/xaa.js +0 -342
  1106. package/dist/src/services/mcp/xaaIdpLogin.js +0 -377
  1107. package/dist/src/services/mcpServerApproval.js +0 -29
  1108. package/dist/src/services/mockRateLimits.js +0 -666
  1109. package/dist/src/services/notifier.js +0 -114
  1110. package/dist/src/services/oauth/auth-code-listener.js +0 -236
  1111. package/dist/src/services/oauth/client.js +0 -545
  1112. package/dist/src/services/oauth/crypto.js +0 -19
  1113. package/dist/src/services/oauth/getOauthProfile.js +0 -48
  1114. package/dist/src/services/oauth/index.js +0 -152
  1115. package/dist/src/services/oauth/types.js +0 -1
  1116. package/dist/src/services/plugins/PluginInstallationManager.js +0 -139
  1117. package/dist/src/services/plugins/pluginCliCommands.js +0 -230
  1118. package/dist/src/services/plugins/pluginOperations.js +0 -826
  1119. package/dist/src/services/policyLimits/index.js +0 -547
  1120. package/dist/src/services/policyLimits/types.js +0 -9
  1121. package/dist/src/services/preventSleep.js +0 -143
  1122. package/dist/src/services/rateLimitMessages.js +0 -271
  1123. package/dist/src/services/rateLimitMocking.js +0 -91
  1124. package/dist/src/services/remoteManagedSettings/index.js +0 -534
  1125. package/dist/src/services/remoteManagedSettings/securityCheck.js +0 -59
  1126. package/dist/src/services/remoteManagedSettings/syncCache.js +0 -90
  1127. package/dist/src/services/remoteManagedSettings/syncCacheState.js +0 -89
  1128. package/dist/src/services/remoteManagedSettings/types.js +0 -12
  1129. package/dist/src/services/settingsSync/index.js +0 -478
  1130. package/dist/src/services/settingsSync/types.js +0 -35
  1131. package/dist/src/services/teamMemorySync/index.js +0 -976
  1132. package/dist/src/services/teamMemorySync/secretScanner.js +0 -275
  1133. package/dist/src/services/teamMemorySync/teamMemSecretGuard.js +0 -35
  1134. package/dist/src/services/teamMemorySync/types.js +0 -47
  1135. package/dist/src/services/teamMemorySync/watcher.js +0 -326
  1136. package/dist/src/services/tips/tipHistory.js +0 -17
  1137. package/dist/src/services/tips/tipRegistry.js +0 -589
  1138. package/dist/src/services/tips/tipScheduler.js +0 -40
  1139. package/dist/src/services/tokenEstimation.js +0 -365
  1140. package/dist/src/services/toolUseSummary/toolUseSummaryGenerator.js +0 -87
  1141. package/dist/src/services/tools/StreamingToolExecutor.js +0 -413
  1142. package/dist/src/services/tools/toolExecution.js +0 -1218
  1143. package/dist/src/services/tools/toolHooks.js +0 -454
  1144. package/dist/src/services/tools/toolOrchestration.js +0 -110
  1145. package/dist/src/services/vcr.js +0 -291
  1146. package/dist/src/services/voice.js +0 -394
  1147. package/dist/src/services/voiceKeyterms.js +0 -94
  1148. package/dist/src/services/voiceStreamSTT.js +0 -406
  1149. package/dist/src/setup.js +0 -349
  1150. package/dist/src/skills/bundled/batch.js +0 -114
  1151. package/dist/src/skills/bundled/claudeApi.js +0 -145
  1152. package/dist/src/skills/bundled/claudeApiContent.js +0 -14
  1153. package/dist/src/skills/bundled/claudeInChrome.js +0 -27
  1154. package/dist/src/skills/bundled/debug.js +0 -99
  1155. package/dist/src/skills/bundled/index.js +0 -5
  1156. package/dist/src/skills/bundled/keybindings.js +0 -292
  1157. package/dist/src/skills/bundled/loop.js +0 -81
  1158. package/dist/src/skills/bundled/loremIpsum.js +0 -266
  1159. package/dist/src/skills/bundled/remember.js +0 -75
  1160. package/dist/src/skills/bundled/scheduleRemoteAgents.js +0 -373
  1161. package/dist/src/skills/bundled/simplify.js +0 -66
  1162. package/dist/src/skills/bundled/skillify.js +0 -184
  1163. package/dist/src/skills/bundled/stuck.js +0 -75
  1164. package/dist/src/skills/bundled/updateConfig.js +0 -463
  1165. package/dist/src/skills/bundled/verify.js +0 -25
  1166. package/dist/src/skills/bundled/verifyContent.js +0 -7
  1167. package/dist/src/skills/bundledSkills.js +0 -159
  1168. package/dist/src/skills/loadSkillsDir.js +0 -736
  1169. package/dist/src/skills/mcpSkillBuilders.js +0 -10
  1170. package/dist/src/ssh/createSSHSession.js +0 -16
  1171. package/dist/src/state/AppState.js +0 -184
  1172. package/dist/src/state/AppStateStore.js +0 -119
  1173. package/dist/src/state/onChangeAppState.js +0 -132
  1174. package/dist/src/state/selectors.js +0 -51
  1175. package/dist/src/state/store.js +0 -21
  1176. package/dist/src/state/teammateViewHelpers.js +0 -124
  1177. package/dist/src/tasks/DreamTask/DreamTask.js +0 -99
  1178. package/dist/src/tasks/InProcessTeammateTask/InProcessTeammateTask.js +0 -116
  1179. package/dist/src/tasks/InProcessTeammateTask/types.js +0 -35
  1180. package/dist/src/tasks/LocalAgentTask/LocalAgentTask.js +0 -507
  1181. package/dist/src/tasks/LocalMainSessionTask.js +0 -338
  1182. package/dist/src/tasks/LocalShellTask/LocalShellTask.js +0 -475
  1183. package/dist/src/tasks/LocalShellTask/guards.js +0 -9
  1184. package/dist/src/tasks/LocalShellTask/killShellTasks.js +0 -59
  1185. package/dist/src/tasks/RemoteAgentTask/RemoteAgentTask.js +0 -742
  1186. package/dist/src/tasks/pillLabel.js +0 -69
  1187. package/dist/src/tasks/stopTask.js +0 -67
  1188. package/dist/src/tasks/types.js +0 -18
  1189. package/dist/src/tasks.js +0 -39
  1190. package/dist/src/telegram/bridge.js +0 -334
  1191. package/dist/src/telegram/config.js +0 -57
  1192. package/dist/src/telegram/mirror.js +0 -91
  1193. package/dist/src/tools/AgentTool/AgentTool.js +0 -1222
  1194. package/dist/src/tools/AgentTool/UI.js +0 -592
  1195. package/dist/src/tools/AgentTool/agentColorManager.js +0 -43
  1196. package/dist/src/tools/AgentTool/agentDisplay.js +0 -72
  1197. package/dist/src/tools/AgentTool/agentMemory.js +0 -125
  1198. package/dist/src/tools/AgentTool/agentMemorySnapshot.js +0 -136
  1199. package/dist/src/tools/AgentTool/agentToolUtils.js +0 -456
  1200. package/dist/src/tools/AgentTool/built-in/claudeCodeGuideAgent.js +0 -175
  1201. package/dist/src/tools/AgentTool/built-in/exploreAgent.js +0 -76
  1202. package/dist/src/tools/AgentTool/built-in/generalPurposeAgent.js +0 -28
  1203. package/dist/src/tools/AgentTool/built-in/planAgent.js +0 -87
  1204. package/dist/src/tools/AgentTool/built-in/statuslineSetup.js +0 -140
  1205. package/dist/src/tools/AgentTool/built-in/verificationAgent.js +0 -146
  1206. package/dist/src/tools/AgentTool/builtInAgents.js +0 -58
  1207. package/dist/src/tools/AgentTool/constants.js +0 -11
  1208. package/dist/src/tools/AgentTool/forkSubagent.js +0 -177
  1209. package/dist/src/tools/AgentTool/loadAgentsDir.js +0 -497
  1210. package/dist/src/tools/AgentTool/prompt.js +0 -260
  1211. package/dist/src/tools/AgentTool/resumeAgent.js +0 -182
  1212. package/dist/src/tools/AgentTool/runAgent.js +0 -629
  1213. package/dist/src/tools/AskUserQuestionTool/AskUserQuestionTool.js +0 -237
  1214. package/dist/src/tools/AskUserQuestionTool/prompt.js +0 -38
  1215. package/dist/src/tools/BashTool/BashTool.js +0 -1008
  1216. package/dist/src/tools/BashTool/BashToolResultMessage.js +0 -168
  1217. package/dist/src/tools/BashTool/UI.js +0 -133
  1218. package/dist/src/tools/BashTool/bashCommandHelpers.js +0 -184
  1219. package/dist/src/tools/BashTool/bashPermissions.js +0 -2023
  1220. package/dist/src/tools/BashTool/bashSecurity.js +0 -2267
  1221. package/dist/src/tools/BashTool/commandSemantics.js +0 -105
  1222. package/dist/src/tools/BashTool/commentLabel.js +0 -14
  1223. package/dist/src/tools/BashTool/destructiveCommandWarning.js +0 -88
  1224. package/dist/src/tools/BashTool/modeValidation.js +0 -86
  1225. package/dist/src/tools/BashTool/pathValidation.js +0 -1080
  1226. package/dist/src/tools/BashTool/prompt.js +0 -333
  1227. package/dist/src/tools/BashTool/readOnlyValidation.js +0 -1794
  1228. package/dist/src/tools/BashTool/sedEditParser.js +0 -282
  1229. package/dist/src/tools/BashTool/sedValidation.js +0 -580
  1230. package/dist/src/tools/BashTool/shouldUseSandbox.js +0 -125
  1231. package/dist/src/tools/BashTool/toolName.js +0 -2
  1232. package/dist/src/tools/BashTool/utils.js +0 -180
  1233. package/dist/src/tools/BriefTool/BriefTool.js +0 -172
  1234. package/dist/src/tools/BriefTool/UI.js +0 -66
  1235. package/dist/src/tools/BriefTool/attachments.js +0 -86
  1236. package/dist/src/tools/BriefTool/prompt.js +0 -19
  1237. package/dist/src/tools/BriefTool/upload.js +0 -136
  1238. package/dist/src/tools/ConfigTool/ConfigTool.js +0 -398
  1239. package/dist/src/tools/ConfigTool/UI.js +0 -24
  1240. package/dist/src/tools/ConfigTool/constants.js +0 -1
  1241. package/dist/src/tools/ConfigTool/prompt.js +0 -82
  1242. package/dist/src/tools/ConfigTool/supportedSettings.js +0 -180
  1243. package/dist/src/tools/EnterPlanModeTool/EnterPlanModeTool.js +0 -98
  1244. package/dist/src/tools/EnterPlanModeTool/UI.js +0 -13
  1245. package/dist/src/tools/EnterPlanModeTool/constants.js +0 -1
  1246. package/dist/src/tools/EnterPlanModeTool/prompt.js +0 -164
  1247. package/dist/src/tools/EnterWorktreeTool/EnterWorktreeTool.js +0 -104
  1248. package/dist/src/tools/EnterWorktreeTool/UI.js +0 -8
  1249. package/dist/src/tools/EnterWorktreeTool/constants.js +0 -1
  1250. package/dist/src/tools/EnterWorktreeTool/prompt.js +0 -30
  1251. package/dist/src/tools/ExitPlanModeTool/ExitPlanModeV2Tool.js +0 -385
  1252. package/dist/src/tools/ExitPlanModeTool/UI.js +0 -31
  1253. package/dist/src/tools/ExitPlanModeTool/constants.js +0 -2
  1254. package/dist/src/tools/ExitPlanModeTool/prompt.js +0 -27
  1255. package/dist/src/tools/ExitWorktreeTool/ExitWorktreeTool.js +0 -257
  1256. package/dist/src/tools/ExitWorktreeTool/UI.js +0 -9
  1257. package/dist/src/tools/ExitWorktreeTool/constants.js +0 -1
  1258. package/dist/src/tools/ExitWorktreeTool/prompt.js +0 -32
  1259. package/dist/src/tools/FileEditTool/FileEditTool.js +0 -480
  1260. package/dist/src/tools/FileEditTool/UI.js +0 -201
  1261. package/dist/src/tools/FileEditTool/constants.js +0 -7
  1262. package/dist/src/tools/FileEditTool/prompt.js +0 -24
  1263. package/dist/src/tools/FileEditTool/types.js +0 -50
  1264. package/dist/src/tools/FileEditTool/utils.js +0 -579
  1265. package/dist/src/tools/FileReadTool/FileReadTool.js +0 -889
  1266. package/dist/src/tools/FileReadTool/UI.js +0 -125
  1267. package/dist/src/tools/FileReadTool/imageProcessor.js +0 -46
  1268. package/dist/src/tools/FileReadTool/limits.js +0 -70
  1269. package/dist/src/tools/FileReadTool/prompt.js +0 -31
  1270. package/dist/src/tools/FileWriteTool/FileWriteTool.js +0 -341
  1271. package/dist/src/tools/FileWriteTool/UI.js +0 -338
  1272. package/dist/src/tools/FileWriteTool/prompt.js +0 -15
  1273. package/dist/src/tools/GlobTool/GlobTool.js +0 -161
  1274. package/dist/src/tools/GlobTool/UI.js +0 -39
  1275. package/dist/src/tools/GlobTool/prompt.js +0 -6
  1276. package/dist/src/tools/GrepTool/GrepTool.js +0 -439
  1277. package/dist/src/tools/GrepTool/UI.js +0 -154
  1278. package/dist/src/tools/GrepTool/prompt.js +0 -16
  1279. package/dist/src/tools/LSPTool/LSPTool.js +0 -660
  1280. package/dist/src/tools/LSPTool/UI.js +0 -204
  1281. package/dist/src/tools/LSPTool/formatters.js +0 -445
  1282. package/dist/src/tools/LSPTool/prompt.js +0 -20
  1283. package/dist/src/tools/LSPTool/schemas.js +0 -197
  1284. package/dist/src/tools/LSPTool/symbolContext.js +0 -75
  1285. package/dist/src/tools/ListMcpResourcesTool/ListMcpResourcesTool.js +0 -100
  1286. package/dist/src/tools/ListMcpResourcesTool/UI.js +0 -16
  1287. package/dist/src/tools/ListMcpResourcesTool/prompt.js +0 -18
  1288. package/dist/src/tools/MCPTool/MCPTool.js +0 -60
  1289. package/dist/src/tools/MCPTool/UI.js +0 -342
  1290. package/dist/src/tools/MCPTool/classifyForCollapse.js +0 -597
  1291. package/dist/src/tools/MCPTool/prompt.js +0 -3
  1292. package/dist/src/tools/McpAuthTool/McpAuthTool.js +0 -162
  1293. package/dist/src/tools/NotebookEditTool/NotebookEditTool.js +0 -421
  1294. package/dist/src/tools/NotebookEditTool/UI.js +0 -40
  1295. package/dist/src/tools/NotebookEditTool/constants.js +0 -2
  1296. package/dist/src/tools/NotebookEditTool/prompt.js +0 -2
  1297. package/dist/src/tools/PowerShellTool/PowerShellTool.js +0 -899
  1298. package/dist/src/tools/PowerShellTool/UI.js +0 -57
  1299. package/dist/src/tools/PowerShellTool/clmTypes.js +0 -207
  1300. package/dist/src/tools/PowerShellTool/commandSemantics.js +0 -115
  1301. package/dist/src/tools/PowerShellTool/commonParameters.js +0 -27
  1302. package/dist/src/tools/PowerShellTool/destructiveCommandWarning.js +0 -92
  1303. package/dist/src/tools/PowerShellTool/gitSafety.js +0 -185
  1304. package/dist/src/tools/PowerShellTool/modeValidation.js +0 -357
  1305. package/dist/src/tools/PowerShellTool/pathValidation.js +0 -1712
  1306. package/dist/src/tools/PowerShellTool/powershellPermissions.js +0 -1351
  1307. package/dist/src/tools/PowerShellTool/powershellSecurity.js +0 -942
  1308. package/dist/src/tools/PowerShellTool/prompt.js +0 -132
  1309. package/dist/src/tools/PowerShellTool/readOnlyValidation.js +0 -1633
  1310. package/dist/src/tools/PowerShellTool/toolName.js +0 -2
  1311. package/dist/src/tools/REPLTool/constants.js +0 -43
  1312. package/dist/src/tools/REPLTool/primitiveTools.js +0 -36
  1313. package/dist/src/tools/ReadMcpResourceTool/ReadMcpResourceTool.js +0 -112
  1314. package/dist/src/tools/ReadMcpResourceTool/UI.js +0 -23
  1315. package/dist/src/tools/ReadMcpResourceTool/prompt.js +0 -15
  1316. package/dist/src/tools/RemoteTriggerTool/RemoteTriggerTool.js +0 -142
  1317. package/dist/src/tools/RemoteTriggerTool/UI.js +0 -11
  1318. package/dist/src/tools/RemoteTriggerTool/prompt.js +0 -12
  1319. package/dist/src/tools/ScheduleCronTool/CronCreateTool.js +0 -120
  1320. package/dist/src/tools/ScheduleCronTool/CronDeleteTool.js +0 -74
  1321. package/dist/src/tools/ScheduleCronTool/CronListTool.js +0 -77
  1322. package/dist/src/tools/ScheduleCronTool/UI.js +0 -28
  1323. package/dist/src/tools/ScheduleCronTool/prompt.js +0 -115
  1324. package/dist/src/tools/SendMessageTool/SendMessageTool.js +0 -675
  1325. package/dist/src/tools/SendMessageTool/UI.js +0 -23
  1326. package/dist/src/tools/SendMessageTool/constants.js +0 -1
  1327. package/dist/src/tools/SendMessageTool/prompt.js +0 -47
  1328. package/dist/src/tools/SkillTool/SkillTool.js +0 -827
  1329. package/dist/src/tools/SkillTool/UI.js +0 -60
  1330. package/dist/src/tools/SkillTool/constants.js +0 -1
  1331. package/dist/src/tools/SkillTool/prompt.js +0 -184
  1332. package/dist/src/tools/SleepTool/prompt.js +0 -14
  1333. package/dist/src/tools/SyntheticOutputTool/SyntheticOutputTool.js +0 -138
  1334. package/dist/src/tools/TaskCreateTool/TaskCreateTool.js +0 -104
  1335. package/dist/src/tools/TaskCreateTool/constants.js +0 -1
  1336. package/dist/src/tools/TaskCreateTool/prompt.js +0 -52
  1337. package/dist/src/tools/TaskGetTool/TaskGetTool.js +0 -106
  1338. package/dist/src/tools/TaskGetTool/constants.js +0 -1
  1339. package/dist/src/tools/TaskGetTool/prompt.js +0 -23
  1340. package/dist/src/tools/TaskListTool/TaskListTool.js +0 -89
  1341. package/dist/src/tools/TaskListTool/constants.js +0 -1
  1342. package/dist/src/tools/TaskListTool/prompt.js +0 -44
  1343. package/dist/src/tools/TaskOutputTool/TaskOutputTool.js +0 -535
  1344. package/dist/src/tools/TaskOutputTool/constants.js +0 -1
  1345. package/dist/src/tools/TaskStopTool/TaskStopTool.js +0 -110
  1346. package/dist/src/tools/TaskStopTool/UI.js +0 -30
  1347. package/dist/src/tools/TaskStopTool/prompt.js +0 -7
  1348. package/dist/src/tools/TaskUpdateTool/TaskUpdateTool.js +0 -301
  1349. package/dist/src/tools/TaskUpdateTool/constants.js +0 -1
  1350. package/dist/src/tools/TaskUpdateTool/prompt.js +0 -76
  1351. package/dist/src/tools/TeamCreateTool/TeamCreateTool.js +0 -177
  1352. package/dist/src/tools/TeamCreateTool/UI.js +0 -4
  1353. package/dist/src/tools/TeamCreateTool/constants.js +0 -1
  1354. package/dist/src/tools/TeamCreateTool/prompt.js +0 -113
  1355. package/dist/src/tools/TeamDeleteTool/TeamDeleteTool.js +0 -102
  1356. package/dist/src/tools/TeamDeleteTool/UI.js +0 -13
  1357. package/dist/src/tools/TeamDeleteTool/constants.js +0 -1
  1358. package/dist/src/tools/TeamDeleteTool/prompt.js +0 -16
  1359. package/dist/src/tools/TodoWriteTool/TodoWriteTool.js +0 -99
  1360. package/dist/src/tools/TodoWriteTool/constants.js +0 -1
  1361. package/dist/src/tools/TodoWriteTool/prompt.js +0 -181
  1362. package/dist/src/tools/ToolSearchTool/ToolSearchTool.js +0 -357
  1363. package/dist/src/tools/ToolSearchTool/constants.js +0 -1
  1364. package/dist/src/tools/ToolSearchTool/prompt.js +0 -99
  1365. package/dist/src/tools/TungstenTool/TungstenLiveMonitor.js +0 -7
  1366. package/dist/src/tools/TungstenTool/TungstenTool.js +0 -3
  1367. package/dist/src/tools/WebFetchTool/UI.js +0 -30
  1368. package/dist/src/tools/WebFetchTool/WebFetchTool.js +0 -246
  1369. package/dist/src/tools/WebFetchTool/preapproved.js +0 -155
  1370. package/dist/src/tools/WebFetchTool/prompt.js +0 -39
  1371. package/dist/src/tools/WebFetchTool/utils.js +0 -381
  1372. package/dist/src/tools/WebSearchTool/UI.js +0 -66
  1373. package/dist/src/tools/WebSearchTool/WebSearchTool.js +0 -352
  1374. package/dist/src/tools/WebSearchTool/prompt.js +0 -32
  1375. package/dist/src/tools/WorkflowTool/constants.js +0 -2
  1376. package/dist/src/tools/shared/gitOperationTracking.js +0 -220
  1377. package/dist/src/tools/shared/spawnMultiAgent.js +0 -805
  1378. package/dist/src/tools/testing/TestingPermissionTool.js +0 -72
  1379. package/dist/src/tools/utils.js +0 -24
  1380. package/dist/src/tools.js +0 -332
  1381. package/dist/src/types/command.js +0 -10
  1382. package/dist/src/types/connectorText.js +0 -2
  1383. package/dist/src/types/generated/events_mono/claude_code/v1/claude_code_internal_event.js +0 -673
  1384. package/dist/src/types/generated/events_mono/common/v1/auth.js +0 -49
  1385. package/dist/src/types/generated/events_mono/growthbook/v1/growthbook_experiment_event.js +0 -147
  1386. package/dist/src/types/generated/google/protobuf/timestamp.js +0 -38
  1387. package/dist/src/types/hooks.js +0 -153
  1388. package/dist/src/types/ids.js +0 -27
  1389. package/dist/src/types/logs.js +0 -11
  1390. package/dist/src/types/message.js +0 -1
  1391. package/dist/src/types/permissions.js +0 -25
  1392. package/dist/src/types/plugin.js +0 -72
  1393. package/dist/src/types/textInputTypes.js +0 -20
  1394. package/dist/src/types/utils.js +0 -5
  1395. package/dist/src/upstreamproxy/relay.js +0 -346
  1396. package/dist/src/upstreamproxy/upstreamproxy.js +0 -236
  1397. package/dist/src/utils/CircularBuffer.js +0 -75
  1398. package/dist/src/utils/Cursor.js +0 -1229
  1399. package/dist/src/utils/QueryGuard.js +0 -115
  1400. package/dist/src/utils/Shell.js +0 -374
  1401. package/dist/src/utils/ShellCommand.js +0 -338
  1402. package/dist/src/utils/abortController.js +0 -74
  1403. package/dist/src/utils/activityManager.js +0 -127
  1404. package/dist/src/utils/advisor.js +0 -77
  1405. package/dist/src/utils/agentContext.js +0 -91
  1406. package/dist/src/utils/agentId.js +0 -83
  1407. package/dist/src/utils/agentSwarmsEnabled.js +0 -37
  1408. package/dist/src/utils/agenticSessionSearch.js +0 -255
  1409. package/dist/src/utils/analyzeContext.js +0 -848
  1410. package/dist/src/utils/ansiToPng.js +0 -259
  1411. package/dist/src/utils/ansiToSvg.js +0 -207
  1412. package/dist/src/utils/api.js +0 -555
  1413. package/dist/src/utils/apiPreconnect.js +0 -62
  1414. package/dist/src/utils/appleTerminalBackup.js +0 -95
  1415. package/dist/src/utils/argumentSubstitution.js +0 -114
  1416. package/dist/src/utils/array.js +0 -12
  1417. package/dist/src/utils/asciicast.js +0 -200
  1418. package/dist/src/utils/attachments.js +0 -2514
  1419. package/dist/src/utils/attribution.js +0 -308
  1420. package/dist/src/utils/attributionHooks.js +0 -16
  1421. package/dist/src/utils/attributionTrailer.js +0 -16
  1422. package/dist/src/utils/auth.js +0 -2020
  1423. package/dist/src/utils/authFileDescriptor.js +0 -152
  1424. package/dist/src/utils/authPortable.js +0 -14
  1425. package/dist/src/utils/autoModeDenials.js +0 -15
  1426. package/dist/src/utils/autoRunIssue.js +0 -112
  1427. package/dist/src/utils/autoUpdater.js +0 -461
  1428. package/dist/src/utils/aws.js +0 -44
  1429. package/dist/src/utils/awsAuthStatusManager.js +0 -66
  1430. package/dist/src/utils/background/remote/preconditions.js +0 -175
  1431. package/dist/src/utils/background/remote/remoteSession.js +0 -53
  1432. package/dist/src/utils/backgroundHousekeeping.js +0 -66
  1433. package/dist/src/utils/bash/ParsedCommand.js +0 -241
  1434. package/dist/src/utils/bash/ShellSnapshot.js +0 -489
  1435. package/dist/src/utils/bash/ast.js +0 -2590
  1436. package/dist/src/utils/bash/bashParser.js +0 -4355
  1437. package/dist/src/utils/bash/bashPipeCommand.js +0 -249
  1438. package/dist/src/utils/bash/commands.js +0 -1131
  1439. package/dist/src/utils/bash/heredoc.js +0 -647
  1440. package/dist/src/utils/bash/parser.js +0 -195
  1441. package/dist/src/utils/bash/prefix.js +0 -154
  1442. package/dist/src/utils/bash/registry.js +0 -23
  1443. package/dist/src/utils/bash/shellCompletion.js +0 -196
  1444. package/dist/src/utils/bash/shellPrefix.js +0 -25
  1445. package/dist/src/utils/bash/shellQuote.js +0 -253
  1446. package/dist/src/utils/bash/shellQuoting.js +0 -106
  1447. package/dist/src/utils/bash/specs/alias.js +0 -11
  1448. package/dist/src/utils/bash/specs/index.js +0 -16
  1449. package/dist/src/utils/bash/specs/nohup.js +0 -10
  1450. package/dist/src/utils/bash/specs/pyright.js +0 -88
  1451. package/dist/src/utils/bash/specs/sleep.js +0 -10
  1452. package/dist/src/utils/bash/specs/srun.js +0 -28
  1453. package/dist/src/utils/bash/specs/time.js +0 -10
  1454. package/dist/src/utils/bash/specs/timeout.js +0 -17
  1455. package/dist/src/utils/bash/treeSitterAnalysis.js +0 -407
  1456. package/dist/src/utils/betas.js +0 -332
  1457. package/dist/src/utils/billing.js +0 -54
  1458. package/dist/src/utils/binaryCheck.js +0 -40
  1459. package/dist/src/utils/browser.js +0 -58
  1460. package/dist/src/utils/bufferedWriter.js +0 -77
  1461. package/dist/src/utils/bundledMode.js +0 -19
  1462. package/dist/src/utils/caCerts.js +0 -93
  1463. package/dist/src/utils/caCertsConfig.js +0 -77
  1464. package/dist/src/utils/cachePaths.js +0 -28
  1465. package/dist/src/utils/ccshareResume.js +0 -16
  1466. package/dist/src/utils/classifierApprovals.js +0 -66
  1467. package/dist/src/utils/classifierApprovalsHook.js +0 -10
  1468. package/dist/src/utils/claudeCodeHints.js +0 -142
  1469. package/dist/src/utils/claudeDesktop.js +0 -108
  1470. package/dist/src/utils/claudeInChrome/chromeNativeHost.js +0 -416
  1471. package/dist/src/utils/claudeInChrome/common.js +0 -466
  1472. package/dist/src/utils/claudeInChrome/mcpServer.js +0 -237
  1473. package/dist/src/utils/claudeInChrome/prompt.js +0 -79
  1474. package/dist/src/utils/claudeInChrome/setup.js +0 -320
  1475. package/dist/src/utils/claudeInChrome/setupPortable.js +0 -172
  1476. package/dist/src/utils/claudeInChrome/toolRendering.js +0 -234
  1477. package/dist/src/utils/claudemd.js +0 -1054
  1478. package/dist/src/utils/cleanup.js +0 -514
  1479. package/dist/src/utils/cleanupRegistry.js +0 -22
  1480. package/dist/src/utils/cliArgs.js +0 -53
  1481. package/dist/src/utils/cliHighlight.js +0 -45
  1482. package/dist/src/utils/codeIndexing.js +0 -149
  1483. package/dist/src/utils/collapseBackgroundBashNotifications.js +0 -70
  1484. package/dist/src/utils/collapseHookSummaries.js +0 -48
  1485. package/dist/src/utils/collapseReadSearch.js +0 -871
  1486. package/dist/src/utils/collapseTeammateShutdowns.js +0 -44
  1487. package/dist/src/utils/combinedAbortSignal.js +0 -40
  1488. package/dist/src/utils/commandLifecycle.js +0 -7
  1489. package/dist/src/utils/commitAttribution.js +0 -720
  1490. package/dist/src/utils/completionCache.js +0 -138
  1491. package/dist/src/utils/computerUse/appNames.js +0 -170
  1492. package/dist/src/utils/computerUse/cleanup.js +0 -66
  1493. package/dist/src/utils/computerUse/common.js +0 -56
  1494. package/dist/src/utils/computerUse/computerUseLock.js +0 -183
  1495. package/dist/src/utils/computerUse/drainRunLoop.js +0 -71
  1496. package/dist/src/utils/computerUse/escHotkey.js +0 -53
  1497. package/dist/src/utils/computerUse/executor.js +0 -480
  1498. package/dist/src/utils/computerUse/gates.js +0 -55
  1499. package/dist/src/utils/computerUse/hostAdapter.js +0 -62
  1500. package/dist/src/utils/computerUse/inputLoader.js +0 -27
  1501. package/dist/src/utils/computerUse/mcpServer.js +0 -84
  1502. package/dist/src/utils/computerUse/setup.js +0 -42
  1503. package/dist/src/utils/computerUse/swiftLoader.js +0 -20
  1504. package/dist/src/utils/computerUse/toolRendering.js +0 -100
  1505. package/dist/src/utils/computerUse/wrapper.js +0 -318
  1506. package/dist/src/utils/concurrentSessions.js +0 -179
  1507. package/dist/src/utils/config.js +0 -1084
  1508. package/dist/src/utils/configConstants.js +0 -18
  1509. package/dist/src/utils/contentArray.js +0 -45
  1510. package/dist/src/utils/context.js +0 -185
  1511. package/dist/src/utils/contextAnalysis.js +0 -171
  1512. package/dist/src/utils/contextSuggestions.js +0 -158
  1513. package/dist/src/utils/controlMessageCompat.js +0 -31
  1514. package/dist/src/utils/conversationRecovery.js +0 -436
  1515. package/dist/src/utils/cron.js +0 -260
  1516. package/dist/src/utils/cronJitterConfig.js +0 -62
  1517. package/dist/src/utils/cronScheduler.js +0 -388
  1518. package/dist/src/utils/cronTasks.js +0 -328
  1519. package/dist/src/utils/cronTasksLock.js +0 -159
  1520. package/dist/src/utils/crossProjectResume.js +0 -46
  1521. package/dist/src/utils/crypto.js +0 -13
  1522. package/dist/src/utils/cwd.js +0 -29
  1523. package/dist/src/utils/databaseMcp/common.js +0 -48
  1524. package/dist/src/utils/databaseMcp/mcpServer.js +0 -2
  1525. package/dist/src/utils/databaseMcp/server/connection.js +0 -243
  1526. package/dist/src/utils/databaseMcp/server/index.js +0 -1442
  1527. package/dist/src/utils/databaseMcp/server/queries.js +0 -683
  1528. package/dist/src/utils/databaseMcp/server/types.js +0 -7
  1529. package/dist/src/utils/databaseMcp/setup.js +0 -28
  1530. package/dist/src/utils/debug.js +0 -220
  1531. package/dist/src/utils/debugFilter.js +0 -125
  1532. package/dist/src/utils/deepLink/banner.js +0 -103
  1533. package/dist/src/utils/deepLink/parseDeepLink.js +0 -138
  1534. package/dist/src/utils/deepLink/protocolHandler.js +0 -119
  1535. package/dist/src/utils/deepLink/registerProtocol.js +0 -291
  1536. package/dist/src/utils/deepLink/terminalLauncher.js +0 -455
  1537. package/dist/src/utils/deepLink/terminalPreference.js +0 -51
  1538. package/dist/src/utils/desktopDeepLink.js +0 -208
  1539. package/dist/src/utils/detectRepository.js +0 -157
  1540. package/dist/src/utils/diagLogs.js +0 -74
  1541. package/dist/src/utils/diff.js +0 -108
  1542. package/dist/src/utils/directMemberMessage.js +0 -34
  1543. package/dist/src/utils/displayTags.js +0 -46
  1544. package/dist/src/utils/doctorContextWarnings.js +0 -179
  1545. package/dist/src/utils/doctorDiagnostic.js +0 -495
  1546. package/dist/src/utils/dxt/helpers.js +0 -64
  1547. package/dist/src/utils/dxt/zip.js +0 -167
  1548. package/dist/src/utils/earlyInput.js +0 -166
  1549. package/dist/src/utils/editor.js +0 -163
  1550. package/dist/src/utils/effort.js +0 -278
  1551. package/dist/src/utils/embeddedTools.js +0 -26
  1552. package/dist/src/utils/env.js +0 -358
  1553. package/dist/src/utils/envDynamic.js +0 -130
  1554. package/dist/src/utils/envUtils.js +0 -154
  1555. package/dist/src/utils/envValidation.js +0 -26
  1556. package/dist/src/utils/errorLogSink.js +0 -197
  1557. package/dist/src/utils/errors.js +0 -207
  1558. package/dist/src/utils/eventLoopStallDetector.js +0 -16
  1559. package/dist/src/utils/exampleCommands.js +0 -165
  1560. package/dist/src/utils/execFileNoThrow.js +0 -93
  1561. package/dist/src/utils/execFileNoThrowPortable.js +0 -111
  1562. package/dist/src/utils/execSyncWrapper.js +0 -68
  1563. package/dist/src/utils/exportRenderer.js +0 -71
  1564. package/dist/src/utils/extraUsage.js +0 -19
  1565. package/dist/src/utils/fastMode.js +0 -393
  1566. package/dist/src/utils/file.js +0 -467
  1567. package/dist/src/utils/fileHistory.js +0 -851
  1568. package/dist/src/utils/fileOperationAnalytics.js +0 -45
  1569. package/dist/src/utils/filePersistence/filePersistence.js +0 -212
  1570. package/dist/src/utils/filePersistence/outputsScanner.js +0 -104
  1571. package/dist/src/utils/filePersistence/types.js +0 -5
  1572. package/dist/src/utils/fileRead.js +0 -81
  1573. package/dist/src/utils/fileReadCache.js +0 -78
  1574. package/dist/src/utils/fileStateCache.js +0 -99
  1575. package/dist/src/utils/findExecutable.js +0 -13
  1576. package/dist/src/utils/fingerprint.js +0 -59
  1577. package/dist/src/utils/forkedAgent.js +0 -410
  1578. package/dist/src/utils/format.js +0 -238
  1579. package/dist/src/utils/formatBriefTimestamp.js +0 -72
  1580. package/dist/src/utils/fpsTracker.js +0 -34
  1581. package/dist/src/utils/frontmatterParser.js +0 -260
  1582. package/dist/src/utils/fsOperations.js +0 -834
  1583. package/dist/src/utils/fullscreen.js +0 -194
  1584. package/dist/src/utils/generatedFiles.js +0 -122
  1585. package/dist/src/utils/generators.js +0 -67
  1586. package/dist/src/utils/genericProcessUtils.js +0 -155
  1587. package/dist/src/utils/getWorktreePaths.js +0 -56
  1588. package/dist/src/utils/getWorktreePathsPortable.js +0 -23
  1589. package/dist/src/utils/ghPrStatus.js +0 -71
  1590. package/dist/src/utils/git/gitConfigParser.js +0 -226
  1591. package/dist/src/utils/git/gitFilesystem.js +0 -606
  1592. package/dist/src/utils/git/gitignore.js +0 -84
  1593. package/dist/src/utils/git.js +0 -725
  1594. package/dist/src/utils/gitDiff.js +0 -395
  1595. package/dist/src/utils/gitSettings.js +0 -18
  1596. package/dist/src/utils/github/ghAuthStatus.js +0 -23
  1597. package/dist/src/utils/githubRepoPathMapping.js +0 -135
  1598. package/dist/src/utils/glob.js +0 -90
  1599. package/dist/src/utils/gracefulShutdown.js +0 -447
  1600. package/dist/src/utils/groupToolUses.js +0 -126
  1601. package/dist/src/utils/handlePromptSubmit.js +0 -398
  1602. package/dist/src/utils/hash.js +0 -46
  1603. package/dist/src/utils/headlessProfiler.js +0 -147
  1604. package/dist/src/utils/heapDumpService.js +0 -202
  1605. package/dist/src/utils/heatmap.js +0 -151
  1606. package/dist/src/utils/highlightMatch.js +0 -28
  1607. package/dist/src/utils/hooks/AsyncHookRegistry.js +0 -187
  1608. package/dist/src/utils/hooks/apiQueryHookHelper.js +0 -77
  1609. package/dist/src/utils/hooks/execAgentHook.js +0 -257
  1610. package/dist/src/utils/hooks/execHttpHook.js +0 -184
  1611. package/dist/src/utils/hooks/execPromptHook.js +0 -171
  1612. package/dist/src/utils/hooks/fileChangedWatcher.js +0 -161
  1613. package/dist/src/utils/hooks/hookEvents.js +0 -111
  1614. package/dist/src/utils/hooks/hookHelpers.js +0 -60
  1615. package/dist/src/utils/hooks/hooksConfigManager.js +0 -323
  1616. package/dist/src/utils/hooks/hooksConfigSnapshot.js +0 -114
  1617. package/dist/src/utils/hooks/hooksSettings.js +0 -204
  1618. package/dist/src/utils/hooks/postSamplingHooks.js +0 -39
  1619. package/dist/src/utils/hooks/registerFrontmatterHooks.js +0 -47
  1620. package/dist/src/utils/hooks/registerSkillHooks.js +0 -40
  1621. package/dist/src/utils/hooks/sessionHooks.js +0 -252
  1622. package/dist/src/utils/hooks/skillImprovement.js +0 -211
  1623. package/dist/src/utils/hooks/ssrfGuard.js +0 -258
  1624. package/dist/src/utils/hooks.js +0 -3668
  1625. package/dist/src/utils/horizontalScroll.js +0 -108
  1626. package/dist/src/utils/http.js +0 -121
  1627. package/dist/src/utils/hyperlink.js +0 -28
  1628. package/dist/src/utils/iTermBackup.js +0 -48
  1629. package/dist/src/utils/ide.js +0 -1198
  1630. package/dist/src/utils/idePathConversion.js +0 -66
  1631. package/dist/src/utils/idleTimeout.js +0 -44
  1632. package/dist/src/utils/imagePaste.js +0 -329
  1633. package/dist/src/utils/imageResizer.js +0 -664
  1634. package/dist/src/utils/imageStore.js +0 -150
  1635. package/dist/src/utils/imageValidation.js +0 -92
  1636. package/dist/src/utils/immediateCommand.js +0 -12
  1637. package/dist/src/utils/inProcessTeammateHelpers.js +0 -71
  1638. package/dist/src/utils/ink.js +0 -20
  1639. package/dist/src/utils/intl.js +0 -83
  1640. package/dist/src/utils/jetbrains.js +0 -152
  1641. package/dist/src/utils/json.js +0 -295
  1642. package/dist/src/utils/jsonRead.js +0 -14
  1643. package/dist/src/utils/keyboardShortcuts.js +0 -11
  1644. package/dist/src/utils/lazySchema.js +0 -8
  1645. package/dist/src/utils/listSessionsImpl.js +0 -332
  1646. package/dist/src/utils/localInstaller.js +0 -131
  1647. package/dist/src/utils/lockfile.js +0 -22
  1648. package/dist/src/utils/log.js +0 -280
  1649. package/dist/src/utils/logoV2Utils.js +0 -288
  1650. package/dist/src/utils/mailbox.js +0 -50
  1651. package/dist/src/utils/managedEnv.js +0 -160
  1652. package/dist/src/utils/managedEnvConstants.js +0 -187
  1653. package/dist/src/utils/markdown.js +0 -300
  1654. package/dist/src/utils/markdownConfigLoader.js +0 -480
  1655. package/dist/src/utils/mcp/dateTimeParser.js +0 -102
  1656. package/dist/src/utils/mcp/elicitationValidation.js +0 -259
  1657. package/dist/src/utils/mcpInstructionsDelta.js +0 -97
  1658. package/dist/src/utils/mcpOutputStorage.js +0 -159
  1659. package/dist/src/utils/mcpValidation.js +0 -165
  1660. package/dist/src/utils/mcpWebSocketTransport.js +0 -180
  1661. package/dist/src/utils/memoize.js +0 -205
  1662. package/dist/src/utils/memory/types.js +0 -9
  1663. package/dist/src/utils/memory/versions.js +0 -7
  1664. package/dist/src/utils/memoryFileDetection.js +0 -247
  1665. package/dist/src/utils/messagePredicates.js +0 -6
  1666. package/dist/src/utils/messageQueueManager.js +0 -430
  1667. package/dist/src/utils/messages/mappers.js +0 -240
  1668. package/dist/src/utils/messages/systemInit.js +0 -74
  1669. package/dist/src/utils/messages.js +0 -4273
  1670. package/dist/src/utils/model/agent.js +0 -128
  1671. package/dist/src/utils/model/aliases.js +0 -21
  1672. package/dist/src/utils/model/antModels.js +0 -25
  1673. package/dist/src/utils/model/bedrock.js +0 -220
  1674. package/dist/src/utils/model/check1mAccess.js +0 -64
  1675. package/dist/src/utils/model/configs.js +0 -93
  1676. package/dist/src/utils/model/contextWindowUpgradeCheck.js +0 -41
  1677. package/dist/src/utils/model/deprecation.js +0 -72
  1678. package/dist/src/utils/model/model.js +0 -635
  1679. package/dist/src/utils/model/modelAllowlist.js +0 -148
  1680. package/dist/src/utils/model/modelCapabilities.js +0 -107
  1681. package/dist/src/utils/model/modelOptions.js +0 -627
  1682. package/dist/src/utils/model/modelStrings.js +0 -144
  1683. package/dist/src/utils/model/modelSupportOverrides.js +0 -40
  1684. package/dist/src/utils/model/openrouter.js +0 -51
  1685. package/dist/src/utils/model/providerBaseUrls.js +0 -77
  1686. package/dist/src/utils/model/providerCatalog.js +0 -81
  1687. package/dist/src/utils/model/providerModels.js +0 -334
  1688. package/dist/src/utils/model/providerProfiles.js +0 -392
  1689. package/dist/src/utils/model/providerProfilesDb.js +0 -556
  1690. package/dist/src/utils/model/providerSwitch.js +0 -68
  1691. package/dist/src/utils/model/providers.js +0 -199
  1692. package/dist/src/utils/model/validateModel.js +0 -257
  1693. package/dist/src/utils/modelCost.js +0 -160
  1694. package/dist/src/utils/modifiers.js +0 -35
  1695. package/dist/src/utils/mtls.js +0 -134
  1696. package/dist/src/utils/nativeInstaller/download.js +0 -370
  1697. package/dist/src/utils/nativeInstaller/index.js +0 -8
  1698. package/dist/src/utils/nativeInstaller/installer.js +0 -1396
  1699. package/dist/src/utils/nativeInstaller/packageManagers.js +0 -258
  1700. package/dist/src/utils/nativeInstaller/pidLock.js +0 -347
  1701. package/dist/src/utils/notebook.js +0 -176
  1702. package/dist/src/utils/objectGroupBy.js +0 -15
  1703. package/dist/src/utils/pasteStore.js +0 -93
  1704. package/dist/src/utils/path.js +0 -140
  1705. package/dist/src/utils/pdf.js +0 -236
  1706. package/dist/src/utils/pdfUtils.js +0 -61
  1707. package/dist/src/utils/peerAddress.js +0 -20
  1708. package/dist/src/utils/permissions/PermissionMode.js +0 -95
  1709. package/dist/src/utils/permissions/PermissionPromptToolResultSchema.js +0 -85
  1710. package/dist/src/utils/permissions/PermissionResult.js +0 -11
  1711. package/dist/src/utils/permissions/PermissionRule.js +0 -19
  1712. package/dist/src/utils/permissions/PermissionUpdate.js +0 -268
  1713. package/dist/src/utils/permissions/PermissionUpdateSchema.js +0 -61
  1714. package/dist/src/utils/permissions/autoModeState.js +0 -34
  1715. package/dist/src/utils/permissions/bashClassifier.js +0 -30
  1716. package/dist/src/utils/permissions/bypassPermissionsKillswitch.js +0 -115
  1717. package/dist/src/utils/permissions/classifierDecision.js +0 -88
  1718. package/dist/src/utils/permissions/classifierShared.js +0 -28
  1719. package/dist/src/utils/permissions/dangerousPatterns.js +0 -78
  1720. package/dist/src/utils/permissions/denialTracking.js +0 -34
  1721. package/dist/src/utils/permissions/filesystem.js +0 -1411
  1722. package/dist/src/utils/permissions/getNextPermissionMode.js +0 -74
  1723. package/dist/src/utils/permissions/pathValidation.js +0 -351
  1724. package/dist/src/utils/permissions/permissionExplainer.js +0 -188
  1725. package/dist/src/utils/permissions/permissionRuleParser.js +0 -177
  1726. package/dist/src/utils/permissions/permissionSetup.js +0 -1164
  1727. package/dist/src/utils/permissions/permissions.js +0 -1065
  1728. package/dist/src/utils/permissions/permissionsLoader.js +0 -217
  1729. package/dist/src/utils/permissions/shadowedRuleDetection.js +0 -149
  1730. package/dist/src/utils/permissions/shellRuleMatching.js +0 -174
  1731. package/dist/src/utils/permissions/yoloClassifier.js +0 -1195
  1732. package/dist/src/utils/planModeV2.js +0 -75
  1733. package/dist/src/utils/plans.js +0 -334
  1734. package/dist/src/utils/platform.js +0 -122
  1735. package/dist/src/utils/plugins/addDirPluginSettings.js +0 -53
  1736. package/dist/src/utils/plugins/cacheUtils.js +0 -174
  1737. package/dist/src/utils/plugins/dependencyResolver.js +0 -244
  1738. package/dist/src/utils/plugins/fetchTelemetry.js +0 -108
  1739. package/dist/src/utils/plugins/gitAvailability.js +0 -65
  1740. package/dist/src/utils/plugins/headlessPluginInstall.js +0 -136
  1741. package/dist/src/utils/plugins/hintRecommendation.js +0 -136
  1742. package/dist/src/utils/plugins/installCounts.js +0 -218
  1743. package/dist/src/utils/plugins/installedPluginsManager.js +0 -1003
  1744. package/dist/src/utils/plugins/loadPluginAgents.js +0 -219
  1745. package/dist/src/utils/plugins/loadPluginCommands.js +0 -595
  1746. package/dist/src/utils/plugins/loadPluginHooks.js +0 -239
  1747. package/dist/src/utils/plugins/loadPluginOutputStyles.js +0 -112
  1748. package/dist/src/utils/plugins/lspPluginIntegration.js +0 -293
  1749. package/dist/src/utils/plugins/lspRecommendation.js +0 -278
  1750. package/dist/src/utils/plugins/managedPlugins.js +0 -26
  1751. package/dist/src/utils/plugins/marketplaceHelpers.js +0 -470
  1752. package/dist/src/utils/plugins/marketplaceManager.js +0 -1939
  1753. package/dist/src/utils/plugins/mcpPluginIntegration.js +0 -465
  1754. package/dist/src/utils/plugins/mcpbHandler.js +0 -708
  1755. package/dist/src/utils/plugins/officialMarketplace.js +0 -21
  1756. package/dist/src/utils/plugins/officialMarketplaceGcs.js +0 -195
  1757. package/dist/src/utils/plugins/officialMarketplaceStartupCheck.js +0 -338
  1758. package/dist/src/utils/plugins/orphanedPluginFilter.js +0 -96
  1759. package/dist/src/utils/plugins/parseMarketplaceInput.js +0 -143
  1760. package/dist/src/utils/plugins/performStartupChecks.js +0 -66
  1761. package/dist/src/utils/plugins/pluginAutoupdate.js +0 -210
  1762. package/dist/src/utils/plugins/pluginBlocklist.js +0 -93
  1763. package/dist/src/utils/plugins/pluginDirectories.js +0 -170
  1764. package/dist/src/utils/plugins/pluginFlagging.js +0 -173
  1765. package/dist/src/utils/plugins/pluginIdentifier.js +0 -78
  1766. package/dist/src/utils/plugins/pluginInstallationHelpers.js +0 -400
  1767. package/dist/src/utils/plugins/pluginLoader.js +0 -2426
  1768. package/dist/src/utils/plugins/pluginOptionsStorage.js +0 -311
  1769. package/dist/src/utils/plugins/pluginPolicy.js +0 -18
  1770. package/dist/src/utils/plugins/pluginStartupCheck.js +0 -261
  1771. package/dist/src/utils/plugins/pluginVersioning.js +0 -128
  1772. package/dist/src/utils/plugins/reconciler.js +0 -181
  1773. package/dist/src/utils/plugins/refresh.js +0 -162
  1774. package/dist/src/utils/plugins/schemas.js +0 -1283
  1775. package/dist/src/utils/plugins/validatePlugin.js +0 -765
  1776. package/dist/src/utils/plugins/walkPluginMarkdown.js +0 -49
  1777. package/dist/src/utils/plugins/zipCache.js +0 -346
  1778. package/dist/src/utils/plugins/zipCacheAdapters.js +0 -133
  1779. package/dist/src/utils/postCommitAttribution.js +0 -16
  1780. package/dist/src/utils/powershell/dangerousCmdlets.js +0 -174
  1781. package/dist/src/utils/powershell/parser.js +0 -1357
  1782. package/dist/src/utils/powershell/staticPrefix.js +0 -277
  1783. package/dist/src/utils/preflightChecks.js +0 -147
  1784. package/dist/src/utils/privacyLevel.js +0 -49
  1785. package/dist/src/utils/process.js +0 -56
  1786. package/dist/src/utils/processUserInput/processBashCommand.js +0 -119
  1787. package/dist/src/utils/processUserInput/processSlashCommand.js +0 -845
  1788. package/dist/src/utils/processUserInput/processTextPrompt.js +0 -68
  1789. package/dist/src/utils/processUserInput/processUserInput.js +0 -326
  1790. package/dist/src/utils/profilerBase.js +0 -29
  1791. package/dist/src/utils/promptCategory.js +0 -39
  1792. package/dist/src/utils/promptEditor.js +0 -151
  1793. package/dist/src/utils/promptShellExecution.js +0 -119
  1794. package/dist/src/utils/proxy.js +0 -347
  1795. package/dist/src/utils/queryContext.js +0 -110
  1796. package/dist/src/utils/queryHelpers.js +0 -436
  1797. package/dist/src/utils/queryProfiler.js +0 -242
  1798. package/dist/src/utils/queueProcessor.js +0 -70
  1799. package/dist/src/utils/readEditContext.js +0 -176
  1800. package/dist/src/utils/readFileInRange.js +0 -278
  1801. package/dist/src/utils/releaseNotes.js +0 -304
  1802. package/dist/src/utils/renderOptions.js +0 -67
  1803. package/dist/src/utils/ripgrep.js +0 -540
  1804. package/dist/src/utils/sandbox/sandbox-adapter.js +0 -749
  1805. package/dist/src/utils/sandbox/sandbox-ui-utils.js +0 -11
  1806. package/dist/src/utils/sanitization.js +0 -72
  1807. package/dist/src/utils/screenshotClipboard.js +0 -89
  1808. package/dist/src/utils/sdkEventQueue.js +0 -49
  1809. package/dist/src/utils/sdkHeapDumpMonitor.js +0 -16
  1810. package/dist/src/utils/secureStorage/fallbackStorage.js +0 -59
  1811. package/dist/src/utils/secureStorage/index.js +0 -14
  1812. package/dist/src/utils/secureStorage/keychainPrefetch.js +0 -91
  1813. package/dist/src/utils/secureStorage/macOsKeychainHelpers.js +0 -91
  1814. package/dist/src/utils/secureStorage/macOsKeychainStorage.js +0 -192
  1815. package/dist/src/utils/secureStorage/plainTextStorage.js +0 -81
  1816. package/dist/src/utils/secureStorage/secureStoreDefs.js +0 -1
  1817. package/dist/src/utils/secureStorage/sqliteStorage.js +0 -217
  1818. package/dist/src/utils/secureStorage/types.js +0 -1
  1819. package/dist/src/utils/semanticBoolean.js +0 -23
  1820. package/dist/src/utils/semanticNumber.js +0 -34
  1821. package/dist/src/utils/semver.js +0 -53
  1822. package/dist/src/utils/sequential.js +0 -43
  1823. package/dist/src/utils/sessionActivity.js +0 -120
  1824. package/dist/src/utils/sessionDataUploader.js +0 -16
  1825. package/dist/src/utils/sessionEnvVars.js +0 -18
  1826. package/dist/src/utils/sessionEnvironment.js +0 -131
  1827. package/dist/src/utils/sessionFileAccessHooks.js +0 -207
  1828. package/dist/src/utils/sessionIngressAuth.js +0 -113
  1829. package/dist/src/utils/sessionRestore.js +0 -359
  1830. package/dist/src/utils/sessionStart.js +0 -165
  1831. package/dist/src/utils/sessionState.js +0 -76
  1832. package/dist/src/utils/sessionStorage.js +0 -4162
  1833. package/dist/src/utils/sessionStoragePortable.js +0 -665
  1834. package/dist/src/utils/sessionTitle.js +0 -120
  1835. package/dist/src/utils/sessionUrl.js +0 -50
  1836. package/dist/src/utils/set.js +0 -50
  1837. package/dist/src/utils/settings/allErrors.js +0 -29
  1838. package/dist/src/utils/settings/applySettingsChange.js +0 -65
  1839. package/dist/src/utils/settings/changeDetector.js +0 -409
  1840. package/dist/src/utils/settings/constants.js +0 -166
  1841. package/dist/src/utils/settings/internalWrites.js +0 -33
  1842. package/dist/src/utils/settings/managedPath.js +0 -29
  1843. package/dist/src/utils/settings/mdm/constants.js +0 -62
  1844. package/dist/src/utils/settings/mdm/rawRead.js +0 -97
  1845. package/dist/src/utils/settings/mdm/settings.js +0 -254
  1846. package/dist/src/utils/settings/permissionValidation.js +0 -224
  1847. package/dist/src/utils/settings/pluginOnlyPolicy.js +0 -53
  1848. package/dist/src/utils/settings/schemaOutput.js +0 -7
  1849. package/dist/src/utils/settings/settings.js +0 -791
  1850. package/dist/src/utils/settings/settingsCache.js +0 -47
  1851. package/dist/src/utils/settings/toolValidationConfig.js +0 -76
  1852. package/dist/src/utils/settings/types.js +0 -846
  1853. package/dist/src/utils/settings/validateEditTool.js +0 -34
  1854. package/dist/src/utils/settings/validation.js +0 -192
  1855. package/dist/src/utils/settings/validationTips.js +0 -111
  1856. package/dist/src/utils/shell/bashProvider.js +0 -202
  1857. package/dist/src/utils/shell/outputLimits.js +0 -7
  1858. package/dist/src/utils/shell/powershellDetection.js +0 -96
  1859. package/dist/src/utils/shell/powershellProvider.js +0 -104
  1860. package/dist/src/utils/shell/prefix.js +0 -246
  1861. package/dist/src/utils/shell/readOnlyCommandValidation.js +0 -1776
  1862. package/dist/src/utils/shell/resolveDefaultShell.js +0 -13
  1863. package/dist/src/utils/shell/shellProvider.js +0 -2
  1864. package/dist/src/utils/shell/shellToolUtils.js +0 -21
  1865. package/dist/src/utils/shell/specPrefix.js +0 -198
  1866. package/dist/src/utils/shellConfig.js +0 -136
  1867. package/dist/src/utils/sideQuery.js +0 -195
  1868. package/dist/src/utils/sideQuestion.js +0 -121
  1869. package/dist/src/utils/signal.js +0 -34
  1870. package/dist/src/utils/sinks.js +0 -15
  1871. package/dist/src/utils/skills/skillChangeDetector.js +0 -264
  1872. package/dist/src/utils/slashCommandParsing.js +0 -46
  1873. package/dist/src/utils/sleep.js +0 -72
  1874. package/dist/src/utils/sliceAnsi.js +0 -74
  1875. package/dist/src/utils/slowOperations.js +0 -323
  1876. package/dist/src/utils/standaloneAgent.js +0 -20
  1877. package/dist/src/utils/startupProfiler.js +0 -158
  1878. package/dist/src/utils/staticRender.js +0 -103
  1879. package/dist/src/utils/stats.js +0 -802
  1880. package/dist/src/utils/statsCache.js +0 -330
  1881. package/dist/src/utils/status.js +0 -544
  1882. package/dist/src/utils/statusNoticeDefinitions.js +0 -112
  1883. package/dist/src/utils/statusNoticeHelpers.js +0 -15
  1884. package/dist/src/utils/stream.js +0 -73
  1885. package/dist/src/utils/streamJsonStdoutGuard.js +0 -107
  1886. package/dist/src/utils/streamlinedTransform.js +0 -162
  1887. package/dist/src/utils/stringUtils.js +0 -202
  1888. package/dist/src/utils/subprocessEnv.js +0 -87
  1889. package/dist/src/utils/suggestions/commandSuggestions.js +0 -458
  1890. package/dist/src/utils/suggestions/directoryCompletion.js +0 -191
  1891. package/dist/src/utils/suggestions/shellHistoryCompletion.js +0 -95
  1892. package/dist/src/utils/suggestions/skillUsageTracking.js +0 -50
  1893. package/dist/src/utils/suggestions/slackChannelSuggestions.js +0 -169
  1894. package/dist/src/utils/swarm/It2SetupPrompt.js +0 -386
  1895. package/dist/src/utils/swarm/backends/ITermBackend.js +0 -276
  1896. package/dist/src/utils/swarm/backends/InProcessBackend.js +0 -237
  1897. package/dist/src/utils/swarm/backends/PaneBackendExecutor.js +0 -250
  1898. package/dist/src/utils/swarm/backends/TmuxBackend.js +0 -574
  1899. package/dist/src/utils/swarm/backends/detection.js +0 -112
  1900. package/dist/src/utils/swarm/backends/it2Setup.js +0 -185
  1901. package/dist/src/utils/swarm/backends/registry.js +0 -369
  1902. package/dist/src/utils/swarm/backends/teammateModeSnapshot.js +0 -68
  1903. package/dist/src/utils/swarm/backends/types.js +0 -9
  1904. package/dist/src/utils/swarm/constants.js +0 -29
  1905. package/dist/src/utils/swarm/inProcessRunner.js +0 -1021
  1906. package/dist/src/utils/swarm/leaderPermissionBridge.js +0 -31
  1907. package/dist/src/utils/swarm/permissionSync.js +0 -667
  1908. package/dist/src/utils/swarm/reconnection.js +0 -82
  1909. package/dist/src/utils/swarm/spawnInProcess.js +0 -218
  1910. package/dist/src/utils/swarm/spawnUtils.js +0 -123
  1911. package/dist/src/utils/swarm/teamHelpers.js +0 -484
  1912. package/dist/src/utils/swarm/teammateInit.js +0 -87
  1913. package/dist/src/utils/swarm/teammateLayoutManager.js +0 -82
  1914. package/dist/src/utils/swarm/teammateModel.js +0 -9
  1915. package/dist/src/utils/swarm/teammatePromptAddendum.js +0 -17
  1916. package/dist/src/utils/systemDirectories.js +0 -51
  1917. package/dist/src/utils/systemPrompt.js +0 -90
  1918. package/dist/src/utils/systemPromptType.js +0 -9
  1919. package/dist/src/utils/systemTheme.js +0 -108
  1920. package/dist/src/utils/systemThemeWatcher.js +0 -16
  1921. package/dist/src/utils/taggedId.js +0 -49
  1922. package/dist/src/utils/task/TaskOutput.js +0 -320
  1923. package/dist/src/utils/task/diskOutput.js +0 -387
  1924. package/dist/src/utils/task/framework.js +0 -236
  1925. package/dist/src/utils/task/outputFormatting.js +0 -24
  1926. package/dist/src/utils/task/sdkProgress.js +0 -24
  1927. package/dist/src/utils/tasks.js +0 -672
  1928. package/dist/src/utils/teamDiscovery.js +0 -48
  1929. package/dist/src/utils/teamMemoryOps.js +0 -67
  1930. package/dist/src/utils/teammate.js +0 -237
  1931. package/dist/src/utils/teammateContext.js +0 -56
  1932. package/dist/src/utils/teammateMailbox.js +0 -793
  1933. package/dist/src/utils/telemetry/betaSessionTracing.js +0 -371
  1934. package/dist/src/utils/telemetry/bigqueryExporter.js +0 -178
  1935. package/dist/src/utils/telemetry/events.js +0 -57
  1936. package/dist/src/utils/telemetry/instrumentation.js +0 -617
  1937. package/dist/src/utils/telemetry/logger.js +0 -25
  1938. package/dist/src/utils/telemetry/perfettoTracing.js +0 -882
  1939. package/dist/src/utils/telemetry/pluginTelemetry.js +0 -157
  1940. package/dist/src/utils/telemetry/sessionTracing.js +0 -693
  1941. package/dist/src/utils/telemetry/skillLoadedEvent.js +0 -26
  1942. package/dist/src/utils/telemetryAttributes.js +0 -57
  1943. package/dist/src/utils/teleport/api.js +0 -299
  1944. package/dist/src/utils/teleport/environmentSelection.js +0 -55
  1945. package/dist/src/utils/teleport/environments.js +0 -84
  1946. package/dist/src/utils/teleport/gitBundle.js +0 -192
  1947. package/dist/src/utils/teleport.js +0 -1041
  1948. package/dist/src/utils/tempfile.js +0 -26
  1949. package/dist/src/utils/terminal.js +0 -105
  1950. package/dist/src/utils/terminalPanel.js +0 -155
  1951. package/dist/src/utils/textHighlighting.js +0 -113
  1952. package/dist/src/utils/theme.js +0 -525
  1953. package/dist/src/utils/thinking.js +0 -130
  1954. package/dist/src/utils/timeouts.js +0 -35
  1955. package/dist/src/utils/tmuxSocket.js +0 -373
  1956. package/dist/src/utils/todo/types.js +0 -9
  1957. package/dist/src/utils/tokenBudget.js +0 -62
  1958. package/dist/src/utils/tokens.js +0 -223
  1959. package/dist/src/utils/toolErrors.js +0 -101
  1960. package/dist/src/utils/toolPool.js +0 -63
  1961. package/dist/src/utils/toolResultStorage.js +0 -769
  1962. package/dist/src/utils/toolSchemaCache.js +0 -7
  1963. package/dist/src/utils/toolSearch.js +0 -551
  1964. package/dist/src/utils/transcriptSearch.js +0 -200
  1965. package/dist/src/utils/treeify.js +0 -111
  1966. package/dist/src/utils/truncate.js +0 -164
  1967. package/dist/src/utils/udsClient.js +0 -16
  1968. package/dist/src/utils/udsMessaging.js +0 -16
  1969. package/dist/src/utils/ultraplan/ccrSession.js +0 -264
  1970. package/dist/src/utils/ultraplan/keyword.js +0 -122
  1971. package/dist/src/utils/ultraplan/prompt.txt +0 -1
  1972. package/dist/src/utils/unaryLogging.js +0 -16
  1973. package/dist/src/utils/undercover.js +0 -89
  1974. package/dist/src/utils/user.js +0 -138
  1975. package/dist/src/utils/userAgent.js +0 -13
  1976. package/dist/src/utils/userPromptKeywords.js +0 -21
  1977. package/dist/src/utils/uuid.js +0 -22
  1978. package/dist/src/utils/warningHandler.js +0 -97
  1979. package/dist/src/utils/which.js +0 -75
  1980. package/dist/src/utils/windowsPaths.js +0 -146
  1981. package/dist/src/utils/withResolvers.js +0 -13
  1982. package/dist/src/utils/words.js +0 -793
  1983. package/dist/src/utils/workloadContext.js +0 -42
  1984. package/dist/src/utils/worktree.js +0 -1142
  1985. package/dist/src/utils/worktreeModeEnabled.js +0 -11
  1986. package/dist/src/utils/xdg.js +0 -52
  1987. package/dist/src/utils/xml.js +0 -15
  1988. package/dist/src/utils/yaml.js +0 -16
  1989. package/dist/src/utils/zodToJsonSchema.js +0 -19
  1990. package/dist/src/vim/motions.js +0 -73
  1991. package/dist/src/vim/operators.js +0 -401
  1992. package/dist/src/vim/textObjects.js +0 -153
  1993. package/dist/src/vim/transitions.js +0 -340
  1994. package/dist/src/vim/types.js +0 -93
  1995. package/dist/src/voice/voiceModeEnabled.js +0 -48
  1996. package/dist/src/whatsapp/bridge.js +0 -267
  1997. package/dist/src/whatsapp/config.js +0 -128
  1998. package/dist/src/whatsapp/markdown.js +0 -37
  1999. package/dist/src/whatsapp/mirror.js +0 -74
  2000. package/dist/src/whatsapp/session.js +0 -142
@@ -1,4355 +0,0 @@
1
- /**
2
- * Pure-TypeScript bash parser producing tree-sitter-bash-compatible ASTs.
3
- *
4
- * Downstream code in parser.ts, ast.ts, prefix.ts, ParsedCommand.ts walks this
5
- * by field name. startIndex/endIndex are UTF-8 BYTE offsets (not JS string
6
- * indices).
7
- *
8
- * Grammar reference: tree-sitter-bash. Validated against a 3449-input golden
9
- * corpus generated from the WASM parser.
10
- */
11
- /**
12
- * 50ms wall-clock cap — bails out on pathological/adversarial input.
13
- * Pass `Infinity` via `parse(src, Infinity)` to disable (e.g. correctness
14
- * tests, where CI jitter would otherwise cause spurious null returns).
15
- */
16
- const PARSE_TIMEOUT_MS = 50;
17
- /** Node budget cap — bails out before OOM on deeply nested input. */
18
- const MAX_NODES = 50_000;
19
- const MODULE = { parse: parseSource };
20
- const READY = Promise.resolve();
21
- /** No-op: pure-TS parser needs no async init. Kept for API compatibility. */
22
- export function ensureParserInitialized() {
23
- return READY;
24
- }
25
- /** Always succeeds — pure-TS needs no init. */
26
- export function getParserModule() {
27
- return MODULE;
28
- }
29
- const SPECIAL_VARS = new Set(['?', '$', '@', '*', '#', '-', '!', '_']);
30
- const DECL_KEYWORDS = new Set([
31
- 'export',
32
- 'declare',
33
- 'typeset',
34
- 'readonly',
35
- 'local',
36
- ]);
37
- export const SHELL_KEYWORDS = new Set([
38
- 'if',
39
- 'then',
40
- 'elif',
41
- 'else',
42
- 'fi',
43
- 'while',
44
- 'until',
45
- 'for',
46
- 'in',
47
- 'do',
48
- 'done',
49
- 'case',
50
- 'esac',
51
- 'function',
52
- 'select',
53
- ]);
54
- function makeLexer(src) {
55
- return {
56
- src,
57
- len: src.length,
58
- i: 0,
59
- b: 0,
60
- heredocs: [],
61
- byteTable: null,
62
- };
63
- }
64
- /** Advance one JS char, updating byte offset for UTF-8. */
65
- function advance(L) {
66
- const c = L.src.charCodeAt(L.i);
67
- L.i++;
68
- if (c < 0x80) {
69
- L.b++;
70
- }
71
- else if (c < 0x800) {
72
- L.b += 2;
73
- }
74
- else if (c >= 0xd800 && c <= 0xdbff) {
75
- // High surrogate — next char completes the pair, total 4 UTF-8 bytes
76
- L.b += 4;
77
- L.i++;
78
- }
79
- else {
80
- L.b += 3;
81
- }
82
- }
83
- function peek(L, off = 0) {
84
- return L.i + off < L.len ? L.src[L.i + off] : '';
85
- }
86
- function byteAt(L, charIdx) {
87
- // Fast path: ASCII-only prefix means char idx == byte idx
88
- if (L.byteTable)
89
- return L.byteTable[charIdx];
90
- // Build table on first non-trivial lookup
91
- const t = new Uint32Array(L.len + 1);
92
- let b = 0;
93
- let i = 0;
94
- while (i < L.len) {
95
- t[i] = b;
96
- const c = L.src.charCodeAt(i);
97
- if (c < 0x80) {
98
- b++;
99
- i++;
100
- }
101
- else if (c < 0x800) {
102
- b += 2;
103
- i++;
104
- }
105
- else if (c >= 0xd800 && c <= 0xdbff) {
106
- t[i + 1] = b + 2;
107
- b += 4;
108
- i += 2;
109
- }
110
- else {
111
- b += 3;
112
- i++;
113
- }
114
- }
115
- t[L.len] = b;
116
- L.byteTable = t;
117
- return t[charIdx];
118
- }
119
- function isWordChar(c) {
120
- // Bash word chars: alphanumeric + various punctuation that doesn't start operators
121
- return ((c >= 'a' && c <= 'z') ||
122
- (c >= 'A' && c <= 'Z') ||
123
- (c >= '0' && c <= '9') ||
124
- c === '_' ||
125
- c === '/' ||
126
- c === '.' ||
127
- c === '-' ||
128
- c === '+' ||
129
- c === ':' ||
130
- c === '@' ||
131
- c === '%' ||
132
- c === ',' ||
133
- c === '~' ||
134
- c === '^' ||
135
- c === '?' ||
136
- c === '*' ||
137
- c === '!' ||
138
- c === '=' ||
139
- c === '[' ||
140
- c === ']');
141
- }
142
- function isWordStart(c) {
143
- return isWordChar(c) || c === '\\';
144
- }
145
- function isIdentStart(c) {
146
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c === '_';
147
- }
148
- function isIdentChar(c) {
149
- return isIdentStart(c) || (c >= '0' && c <= '9');
150
- }
151
- function isDigit(c) {
152
- return c >= '0' && c <= '9';
153
- }
154
- function isHexDigit(c) {
155
- return isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
156
- }
157
- function isBaseDigit(c) {
158
- // Bash BASE#DIGITS: digits, letters, @ and _ (up to base 64)
159
- return isIdentChar(c) || c === '@';
160
- }
161
- /**
162
- * Unquoted heredoc delimiter chars. Bash accepts most non-metacharacters —
163
- * not just identifiers. Stop at whitespace, redirects, pipe/list operators,
164
- * and structural tokens. Allows !, -, ., +, etc. (e.g. <<!HEREDOC!).
165
- */
166
- function isHeredocDelimChar(c) {
167
- return (c !== '' &&
168
- c !== ' ' &&
169
- c !== '\t' &&
170
- c !== '\n' &&
171
- c !== '<' &&
172
- c !== '>' &&
173
- c !== '|' &&
174
- c !== '&' &&
175
- c !== ';' &&
176
- c !== '(' &&
177
- c !== ')' &&
178
- c !== "'" &&
179
- c !== '"' &&
180
- c !== '`' &&
181
- c !== '\\');
182
- }
183
- function skipBlanks(L) {
184
- while (L.i < L.len) {
185
- const c = L.src[L.i];
186
- if (c === ' ' || c === '\t' || c === '\r') {
187
- // \r is whitespace per tree-sitter-bash extras /\s/ — handles CRLF inputs
188
- advance(L);
189
- }
190
- else if (c === '\\') {
191
- const nx = L.src[L.i + 1];
192
- if (nx === '\n' || (nx === '\r' && L.src[L.i + 2] === '\n')) {
193
- // Line continuation — tree-sitter extras: /\\\r?\n/
194
- advance(L);
195
- advance(L);
196
- if (nx === '\r')
197
- advance(L);
198
- }
199
- else if (nx === ' ' || nx === '\t') {
200
- // \<space> or \<tab> — tree-sitter's _whitespace is /\\?[ \t\v]+/
201
- advance(L);
202
- advance(L);
203
- }
204
- else {
205
- break;
206
- }
207
- }
208
- else {
209
- break;
210
- }
211
- }
212
- }
213
- /**
214
- * Scan next token. Context-sensitive: `cmd` mode treats [ as operator (test
215
- * command start), `arg` mode treats [ as word char (glob/subscript).
216
- */
217
- function nextToken(L, ctx = 'arg') {
218
- skipBlanks(L);
219
- const start = L.b;
220
- if (L.i >= L.len)
221
- return { type: 'EOF', value: '', start, end: start };
222
- const c = L.src[L.i];
223
- const c1 = peek(L, 1);
224
- const c2 = peek(L, 2);
225
- if (c === '\n') {
226
- advance(L);
227
- return { type: 'NEWLINE', value: '\n', start, end: L.b };
228
- }
229
- if (c === '#') {
230
- const si = L.i;
231
- while (L.i < L.len && L.src[L.i] !== '\n')
232
- advance(L);
233
- return {
234
- type: 'COMMENT',
235
- value: L.src.slice(si, L.i),
236
- start,
237
- end: L.b,
238
- };
239
- }
240
- // Multi-char operators (longest match first)
241
- if (c === '&' && c1 === '&') {
242
- advance(L);
243
- advance(L);
244
- return { type: 'OP', value: '&&', start, end: L.b };
245
- }
246
- if (c === '|' && c1 === '|') {
247
- advance(L);
248
- advance(L);
249
- return { type: 'OP', value: '||', start, end: L.b };
250
- }
251
- if (c === '|' && c1 === '&') {
252
- advance(L);
253
- advance(L);
254
- return { type: 'OP', value: '|&', start, end: L.b };
255
- }
256
- if (c === ';' && c1 === ';' && c2 === '&') {
257
- advance(L);
258
- advance(L);
259
- advance(L);
260
- return { type: 'OP', value: ';;&', start, end: L.b };
261
- }
262
- if (c === ';' && c1 === ';') {
263
- advance(L);
264
- advance(L);
265
- return { type: 'OP', value: ';;', start, end: L.b };
266
- }
267
- if (c === ';' && c1 === '&') {
268
- advance(L);
269
- advance(L);
270
- return { type: 'OP', value: ';&', start, end: L.b };
271
- }
272
- if (c === '>' && c1 === '>') {
273
- advance(L);
274
- advance(L);
275
- return { type: 'OP', value: '>>', start, end: L.b };
276
- }
277
- if (c === '>' && c1 === '&' && c2 === '-') {
278
- advance(L);
279
- advance(L);
280
- advance(L);
281
- return { type: 'OP', value: '>&-', start, end: L.b };
282
- }
283
- if (c === '>' && c1 === '&') {
284
- advance(L);
285
- advance(L);
286
- return { type: 'OP', value: '>&', start, end: L.b };
287
- }
288
- if (c === '>' && c1 === '|') {
289
- advance(L);
290
- advance(L);
291
- return { type: 'OP', value: '>|', start, end: L.b };
292
- }
293
- if (c === '&' && c1 === '>' && c2 === '>') {
294
- advance(L);
295
- advance(L);
296
- advance(L);
297
- return { type: 'OP', value: '&>>', start, end: L.b };
298
- }
299
- if (c === '&' && c1 === '>') {
300
- advance(L);
301
- advance(L);
302
- return { type: 'OP', value: '&>', start, end: L.b };
303
- }
304
- if (c === '<' && c1 === '<' && c2 === '<') {
305
- advance(L);
306
- advance(L);
307
- advance(L);
308
- return { type: 'OP', value: '<<<', start, end: L.b };
309
- }
310
- if (c === '<' && c1 === '<' && c2 === '-') {
311
- advance(L);
312
- advance(L);
313
- advance(L);
314
- return { type: 'OP', value: '<<-', start, end: L.b };
315
- }
316
- if (c === '<' && c1 === '<') {
317
- advance(L);
318
- advance(L);
319
- return { type: 'OP', value: '<<', start, end: L.b };
320
- }
321
- if (c === '<' && c1 === '&' && c2 === '-') {
322
- advance(L);
323
- advance(L);
324
- advance(L);
325
- return { type: 'OP', value: '<&-', start, end: L.b };
326
- }
327
- if (c === '<' && c1 === '&') {
328
- advance(L);
329
- advance(L);
330
- return { type: 'OP', value: '<&', start, end: L.b };
331
- }
332
- if (c === '<' && c1 === '(') {
333
- advance(L);
334
- advance(L);
335
- return { type: 'LT_PAREN', value: '<(', start, end: L.b };
336
- }
337
- if (c === '>' && c1 === '(') {
338
- advance(L);
339
- advance(L);
340
- return { type: 'GT_PAREN', value: '>(', start, end: L.b };
341
- }
342
- if (c === '(' && c1 === '(') {
343
- advance(L);
344
- advance(L);
345
- return { type: 'OP', value: '((', start, end: L.b };
346
- }
347
- if (c === ')' && c1 === ')') {
348
- advance(L);
349
- advance(L);
350
- return { type: 'OP', value: '))', start, end: L.b };
351
- }
352
- if (c === '|' || c === '&' || c === ';' || c === '>' || c === '<') {
353
- advance(L);
354
- return { type: 'OP', value: c, start, end: L.b };
355
- }
356
- if (c === '(' || c === ')') {
357
- advance(L);
358
- return { type: 'OP', value: c, start, end: L.b };
359
- }
360
- // In cmd position, [ [[ { start test/group; in arg position they're word chars
361
- if (ctx === 'cmd') {
362
- if (c === '[' && c1 === '[') {
363
- advance(L);
364
- advance(L);
365
- return { type: 'OP', value: '[[', start, end: L.b };
366
- }
367
- if (c === '[') {
368
- advance(L);
369
- return { type: 'OP', value: '[', start, end: L.b };
370
- }
371
- if (c === '{' && (c1 === ' ' || c1 === '\t' || c1 === '\n')) {
372
- advance(L);
373
- return { type: 'OP', value: '{', start, end: L.b };
374
- }
375
- if (c === '}') {
376
- advance(L);
377
- return { type: 'OP', value: '}', start, end: L.b };
378
- }
379
- if (c === '!' && (c1 === ' ' || c1 === '\t')) {
380
- advance(L);
381
- return { type: 'OP', value: '!', start, end: L.b };
382
- }
383
- }
384
- if (c === '"') {
385
- advance(L);
386
- return { type: 'DQUOTE', value: '"', start, end: L.b };
387
- }
388
- if (c === "'") {
389
- const si = L.i;
390
- advance(L);
391
- while (L.i < L.len && L.src[L.i] !== "'")
392
- advance(L);
393
- if (L.i < L.len)
394
- advance(L);
395
- return {
396
- type: 'SQUOTE',
397
- value: L.src.slice(si, L.i),
398
- start,
399
- end: L.b,
400
- };
401
- }
402
- if (c === '$') {
403
- if (c1 === '(' && c2 === '(') {
404
- advance(L);
405
- advance(L);
406
- advance(L);
407
- return { type: 'DOLLAR_DPAREN', value: '$((', start, end: L.b };
408
- }
409
- if (c1 === '(') {
410
- advance(L);
411
- advance(L);
412
- return { type: 'DOLLAR_PAREN', value: '$(', start, end: L.b };
413
- }
414
- if (c1 === '{') {
415
- advance(L);
416
- advance(L);
417
- return { type: 'DOLLAR_BRACE', value: '${', start, end: L.b };
418
- }
419
- if (c1 === "'") {
420
- // ANSI-C string $'...'
421
- const si = L.i;
422
- advance(L);
423
- advance(L);
424
- while (L.i < L.len && L.src[L.i] !== "'") {
425
- if (L.src[L.i] === '\\' && L.i + 1 < L.len)
426
- advance(L);
427
- advance(L);
428
- }
429
- if (L.i < L.len)
430
- advance(L);
431
- return {
432
- type: 'ANSI_C',
433
- value: L.src.slice(si, L.i),
434
- start,
435
- end: L.b,
436
- };
437
- }
438
- advance(L);
439
- return { type: 'DOLLAR', value: '$', start, end: L.b };
440
- }
441
- if (c === '`') {
442
- advance(L);
443
- return { type: 'BACKTICK', value: '`', start, end: L.b };
444
- }
445
- // File descriptor before redirect: digit+ immediately followed by > or <
446
- if (isDigit(c)) {
447
- let j = L.i;
448
- while (j < L.len && isDigit(L.src[j]))
449
- j++;
450
- const after = j < L.len ? L.src[j] : '';
451
- if (after === '>' || after === '<') {
452
- const si = L.i;
453
- while (L.i < j)
454
- advance(L);
455
- return {
456
- type: 'WORD',
457
- value: L.src.slice(si, L.i),
458
- start,
459
- end: L.b,
460
- };
461
- }
462
- }
463
- // Word / number
464
- if (isWordStart(c) || c === '{' || c === '}') {
465
- const si = L.i;
466
- while (L.i < L.len) {
467
- const ch = L.src[L.i];
468
- if (ch === '\\') {
469
- if (L.i + 1 >= L.len) {
470
- // Trailing `\` at EOF — tree-sitter excludes it from the word and
471
- // emits a sibling ERROR. Stop here so the word ends before `\`.
472
- break;
473
- }
474
- // Escape next char (including \n for line continuation mid-word)
475
- if (L.src[L.i + 1] === '\n') {
476
- advance(L);
477
- advance(L);
478
- continue;
479
- }
480
- advance(L);
481
- advance(L);
482
- continue;
483
- }
484
- if (!isWordChar(ch) && ch !== '{' && ch !== '}') {
485
- break;
486
- }
487
- advance(L);
488
- }
489
- if (L.i > si) {
490
- const v = L.src.slice(si, L.i);
491
- // Number: optional sign then digits only
492
- if (/^-?\d+$/.test(v)) {
493
- return { type: 'NUMBER', value: v, start, end: L.b };
494
- }
495
- return { type: 'WORD', value: v, start, end: L.b };
496
- }
497
- // Empty word (lone `\` at EOF) — fall through to single-char consumer
498
- }
499
- // Unknown char — consume as single-char word
500
- advance(L);
501
- return { type: 'WORD', value: c, start, end: L.b };
502
- }
503
- function parseSource(source, timeoutMs) {
504
- const L = makeLexer(source);
505
- const srcBytes = byteLengthUtf8(source);
506
- const P = {
507
- L,
508
- src: source,
509
- srcBytes,
510
- isAscii: srcBytes === source.length,
511
- nodeCount: 0,
512
- deadline: performance.now() + (timeoutMs ?? PARSE_TIMEOUT_MS),
513
- aborted: false,
514
- inBacktick: 0,
515
- stopToken: null,
516
- };
517
- try {
518
- const program = parseProgram(P);
519
- if (P.aborted)
520
- return null;
521
- return program;
522
- }
523
- catch {
524
- return null;
525
- }
526
- }
527
- function byteLengthUtf8(s) {
528
- let b = 0;
529
- for (let i = 0; i < s.length; i++) {
530
- const c = s.charCodeAt(i);
531
- if (c < 0x80)
532
- b++;
533
- else if (c < 0x800)
534
- b += 2;
535
- else if (c >= 0xd800 && c <= 0xdbff) {
536
- b += 4;
537
- i++;
538
- }
539
- else
540
- b += 3;
541
- }
542
- return b;
543
- }
544
- function checkBudget(P) {
545
- P.nodeCount++;
546
- if (P.nodeCount > MAX_NODES) {
547
- P.aborted = true;
548
- throw new Error('budget');
549
- }
550
- if ((P.nodeCount & 0x7f) === 0 && performance.now() > P.deadline) {
551
- P.aborted = true;
552
- throw new Error('timeout');
553
- }
554
- }
555
- /** Build a node. Slices text from source by byte range via char-index lookup. */
556
- function mk(P, type, start, end, children) {
557
- checkBudget(P);
558
- return {
559
- type,
560
- text: sliceBytes(P, start, end),
561
- startIndex: start,
562
- endIndex: end,
563
- children,
564
- };
565
- }
566
- function sliceBytes(P, startByte, endByte) {
567
- if (P.isAscii)
568
- return P.src.slice(startByte, endByte);
569
- // Find char indices for byte offsets. Build byte table if needed.
570
- const L = P.L;
571
- if (!L.byteTable)
572
- byteAt(L, 0);
573
- const t = L.byteTable;
574
- // Binary search for char index where byte offset matches
575
- let lo = 0;
576
- let hi = P.src.length;
577
- while (lo < hi) {
578
- const m = (lo + hi) >>> 1;
579
- if (t[m] < startByte)
580
- lo = m + 1;
581
- else
582
- hi = m;
583
- }
584
- const sc = lo;
585
- lo = sc;
586
- hi = P.src.length;
587
- while (lo < hi) {
588
- const m = (lo + hi) >>> 1;
589
- if (t[m] < endByte)
590
- lo = m + 1;
591
- else
592
- hi = m;
593
- }
594
- return P.src.slice(sc, lo);
595
- }
596
- function leaf(P, type, tok) {
597
- return mk(P, type, tok.start, tok.end, []);
598
- }
599
- function parseProgram(P) {
600
- const children = [];
601
- // Skip leading whitespace & newlines — program start is first content byte
602
- skipBlanks(P.L);
603
- while (true) {
604
- const save = saveLex(P.L);
605
- const t = nextToken(P.L, 'cmd');
606
- if (t.type === 'NEWLINE') {
607
- skipBlanks(P.L);
608
- continue;
609
- }
610
- restoreLex(P.L, save);
611
- break;
612
- }
613
- const progStart = P.L.b;
614
- while (P.L.i < P.L.len) {
615
- const save = saveLex(P.L);
616
- const t = nextToken(P.L, 'cmd');
617
- if (t.type === 'EOF')
618
- break;
619
- if (t.type === 'NEWLINE')
620
- continue;
621
- if (t.type === 'COMMENT') {
622
- children.push(leaf(P, 'comment', t));
623
- continue;
624
- }
625
- restoreLex(P.L, save);
626
- const stmts = parseStatements(P, null);
627
- for (const s of stmts)
628
- children.push(s);
629
- if (stmts.length === 0) {
630
- // Couldn't parse — emit ERROR and skip one token
631
- const errTok = nextToken(P.L, 'cmd');
632
- if (errTok.type === 'EOF')
633
- break;
634
- // Stray `;;` at program level (e.g., `var=;;` outside case) — tree-sitter
635
- // silently elides. Keep leading `;` as ERROR (security: paste artifact).
636
- if (errTok.type === 'OP' &&
637
- errTok.value === ';;' &&
638
- children.length > 0) {
639
- continue;
640
- }
641
- children.push(mk(P, 'ERROR', errTok.start, errTok.end, []));
642
- }
643
- }
644
- // tree-sitter includes trailing whitespace in program extent
645
- const progEnd = children.length > 0 ? P.srcBytes : progStart;
646
- return mk(P, 'program', progStart, progEnd, children);
647
- }
648
- function saveLex(L) {
649
- return L.b * 0x10000 + L.i;
650
- }
651
- function restoreLex(L, s) {
652
- L.i = s & 0xffff;
653
- L.b = s >>> 16;
654
- }
655
- /**
656
- * Parse a sequence of statements separated by ; & newline. Returns a flat list
657
- * where ; and & are sibling leaves (NOT wrapped in 'list' — only && || get
658
- * that). Stops at terminator or EOF.
659
- */
660
- function parseStatements(P, terminator) {
661
- const out = [];
662
- while (true) {
663
- skipBlanks(P.L);
664
- const save = saveLex(P.L);
665
- const t = nextToken(P.L, 'cmd');
666
- if (t.type === 'EOF') {
667
- restoreLex(P.L, save);
668
- break;
669
- }
670
- if (t.type === 'NEWLINE') {
671
- // Process pending heredocs
672
- if (P.L.heredocs.length > 0) {
673
- scanHeredocBodies(P);
674
- }
675
- continue;
676
- }
677
- if (t.type === 'COMMENT') {
678
- out.push(leaf(P, 'comment', t));
679
- continue;
680
- }
681
- if (terminator && t.type === 'OP' && t.value === terminator) {
682
- restoreLex(P.L, save);
683
- break;
684
- }
685
- if (t.type === 'OP' &&
686
- (t.value === ')' ||
687
- t.value === '}' ||
688
- t.value === ';;' ||
689
- t.value === ';&' ||
690
- t.value === ';;&' ||
691
- t.value === '))' ||
692
- t.value === ']]' ||
693
- t.value === ']')) {
694
- restoreLex(P.L, save);
695
- break;
696
- }
697
- if (t.type === 'BACKTICK' && P.inBacktick > 0) {
698
- restoreLex(P.L, save);
699
- break;
700
- }
701
- if (t.type === 'WORD' &&
702
- (t.value === 'then' ||
703
- t.value === 'elif' ||
704
- t.value === 'else' ||
705
- t.value === 'fi' ||
706
- t.value === 'do' ||
707
- t.value === 'done' ||
708
- t.value === 'esac')) {
709
- restoreLex(P.L, save);
710
- break;
711
- }
712
- restoreLex(P.L, save);
713
- const stmt = parseAndOr(P);
714
- if (!stmt)
715
- break;
716
- out.push(stmt);
717
- // Look for separator
718
- skipBlanks(P.L);
719
- const save2 = saveLex(P.L);
720
- const sep = nextToken(P.L, 'cmd');
721
- if (sep.type === 'OP' && (sep.value === ';' || sep.value === '&')) {
722
- // Check if terminator follows — if so, emit separator but stop
723
- const save3 = saveLex(P.L);
724
- const after = nextToken(P.L, 'cmd');
725
- restoreLex(P.L, save3);
726
- out.push(leaf(P, sep.value, sep));
727
- if (after.type === 'EOF' ||
728
- (after.type === 'OP' &&
729
- (after.value === ')' ||
730
- after.value === '}' ||
731
- after.value === ';;' ||
732
- after.value === ';&' ||
733
- after.value === ';;&')) ||
734
- (after.type === 'WORD' &&
735
- (after.value === 'then' ||
736
- after.value === 'elif' ||
737
- after.value === 'else' ||
738
- after.value === 'fi' ||
739
- after.value === 'do' ||
740
- after.value === 'done' ||
741
- after.value === 'esac'))) {
742
- // Trailing separator — don't include it at program level unless
743
- // there's content after. But at inner levels we keep it.
744
- continue;
745
- }
746
- }
747
- else if (sep.type === 'NEWLINE') {
748
- if (P.L.heredocs.length > 0) {
749
- scanHeredocBodies(P);
750
- }
751
- continue;
752
- }
753
- else {
754
- restoreLex(P.L, save2);
755
- }
756
- }
757
- // Trim trailing separator if at program level
758
- return out;
759
- }
760
- /**
761
- * Parse pipeline chains joined by && ||. Left-associative nesting.
762
- * tree-sitter quirk: trailing redirect on the last pipeline wraps the ENTIRE
763
- * list in a redirected_statement — `a > x && b > y` becomes
764
- * redirected_statement(list(redirected_statement(a,>x), &&, b), >y).
765
- */
766
- function parseAndOr(P) {
767
- let left = parsePipeline(P);
768
- if (!left)
769
- return null;
770
- while (true) {
771
- const save = saveLex(P.L);
772
- const t = nextToken(P.L, 'cmd');
773
- if (t.type === 'OP' && (t.value === '&&' || t.value === '||')) {
774
- const op = leaf(P, t.value, t);
775
- skipNewlines(P);
776
- const right = parsePipeline(P);
777
- if (!right) {
778
- left = mk(P, 'list', left.startIndex, op.endIndex, [left, op]);
779
- break;
780
- }
781
- // If right is a redirected_statement, hoist its redirects to wrap the list.
782
- if (right.type === 'redirected_statement' && right.children.length >= 2) {
783
- const inner = right.children[0];
784
- const redirs = right.children.slice(1);
785
- const listNode = mk(P, 'list', left.startIndex, inner.endIndex, [
786
- left,
787
- op,
788
- inner,
789
- ]);
790
- const lastR = redirs[redirs.length - 1];
791
- left = mk(P, 'redirected_statement', listNode.startIndex, lastR.endIndex, [listNode, ...redirs]);
792
- }
793
- else {
794
- left = mk(P, 'list', left.startIndex, right.endIndex, [left, op, right]);
795
- }
796
- }
797
- else {
798
- restoreLex(P.L, save);
799
- break;
800
- }
801
- }
802
- return left;
803
- }
804
- function skipNewlines(P) {
805
- while (true) {
806
- const save = saveLex(P.L);
807
- const t = nextToken(P.L, 'cmd');
808
- if (t.type !== 'NEWLINE') {
809
- restoreLex(P.L, save);
810
- break;
811
- }
812
- }
813
- }
814
- /**
815
- * Parse commands joined by | or |&. Flat children with operator leaves.
816
- * tree-sitter quirk: `a | b 2>nul | c` hoists the redirect on `b` to wrap
817
- * the preceding pipeline fragment — pipeline(redirected_statement(
818
- * pipeline(a,|,b), 2>nul), |, c).
819
- */
820
- function parsePipeline(P) {
821
- let first = parseCommand(P);
822
- if (!first)
823
- return null;
824
- const parts = [first];
825
- while (true) {
826
- const save = saveLex(P.L);
827
- const t = nextToken(P.L, 'cmd');
828
- if (t.type === 'OP' && (t.value === '|' || t.value === '|&')) {
829
- const op = leaf(P, t.value, t);
830
- skipNewlines(P);
831
- const next = parseCommand(P);
832
- if (!next) {
833
- parts.push(op);
834
- break;
835
- }
836
- // Hoist trailing redirect on `next` to wrap current pipeline fragment
837
- if (next.type === 'redirected_statement' &&
838
- next.children.length >= 2 &&
839
- parts.length >= 1) {
840
- const inner = next.children[0];
841
- const redirs = next.children.slice(1);
842
- // Wrap existing parts + op + inner as a pipeline
843
- const pipeKids = [...parts, op, inner];
844
- const pipeNode = mk(P, 'pipeline', pipeKids[0].startIndex, inner.endIndex, pipeKids);
845
- const lastR = redirs[redirs.length - 1];
846
- const wrapped = mk(P, 'redirected_statement', pipeNode.startIndex, lastR.endIndex, [pipeNode, ...redirs]);
847
- parts.length = 0;
848
- parts.push(wrapped);
849
- first = wrapped;
850
- continue;
851
- }
852
- parts.push(op, next);
853
- }
854
- else {
855
- restoreLex(P.L, save);
856
- break;
857
- }
858
- }
859
- if (parts.length === 1)
860
- return parts[0];
861
- const last = parts[parts.length - 1];
862
- return mk(P, 'pipeline', parts[0].startIndex, last.endIndex, parts);
863
- }
864
- /** Parse a single command: simple, compound, or control structure. */
865
- function parseCommand(P) {
866
- skipBlanks(P.L);
867
- const save = saveLex(P.L);
868
- const t = nextToken(P.L, 'cmd');
869
- if (t.type === 'EOF') {
870
- restoreLex(P.L, save);
871
- return null;
872
- }
873
- // Negation — tree-sitter wraps just the command, redirects go outside.
874
- // `! cmd > out` → redirected_statement(negated_command(!, cmd), >out)
875
- if (t.type === 'OP' && t.value === '!') {
876
- const bang = leaf(P, '!', t);
877
- const inner = parseCommand(P);
878
- if (!inner) {
879
- restoreLex(P.L, save);
880
- return null;
881
- }
882
- // If inner is a redirected_statement, hoist redirects outside negation
883
- if (inner.type === 'redirected_statement' && inner.children.length >= 2) {
884
- const cmd = inner.children[0];
885
- const redirs = inner.children.slice(1);
886
- const neg = mk(P, 'negated_command', bang.startIndex, cmd.endIndex, [
887
- bang,
888
- cmd,
889
- ]);
890
- const lastR = redirs[redirs.length - 1];
891
- return mk(P, 'redirected_statement', neg.startIndex, lastR.endIndex, [
892
- neg,
893
- ...redirs,
894
- ]);
895
- }
896
- return mk(P, 'negated_command', bang.startIndex, inner.endIndex, [
897
- bang,
898
- inner,
899
- ]);
900
- }
901
- if (t.type === 'OP' && t.value === '(') {
902
- const open = leaf(P, '(', t);
903
- const body = parseStatements(P, ')');
904
- const closeTok = nextToken(P.L, 'cmd');
905
- const close = closeTok.type === 'OP' && closeTok.value === ')'
906
- ? leaf(P, ')', closeTok)
907
- : mk(P, ')', open.endIndex, open.endIndex, []);
908
- const node = mk(P, 'subshell', open.startIndex, close.endIndex, [
909
- open,
910
- ...body,
911
- close,
912
- ]);
913
- return maybeRedirect(P, node);
914
- }
915
- if (t.type === 'OP' && t.value === '((') {
916
- const open = leaf(P, '((', t);
917
- const exprs = parseArithCommaList(P, '))', 'var');
918
- const closeTok = nextToken(P.L, 'cmd');
919
- const close = closeTok.value === '))'
920
- ? leaf(P, '))', closeTok)
921
- : mk(P, '))', open.endIndex, open.endIndex, []);
922
- return mk(P, 'compound_statement', open.startIndex, close.endIndex, [
923
- open,
924
- ...exprs,
925
- close,
926
- ]);
927
- }
928
- if (t.type === 'OP' && t.value === '{') {
929
- const open = leaf(P, '{', t);
930
- const body = parseStatements(P, '}');
931
- const closeTok = nextToken(P.L, 'cmd');
932
- const close = closeTok.type === 'OP' && closeTok.value === '}'
933
- ? leaf(P, '}', closeTok)
934
- : mk(P, '}', open.endIndex, open.endIndex, []);
935
- const node = mk(P, 'compound_statement', open.startIndex, close.endIndex, [
936
- open,
937
- ...body,
938
- close,
939
- ]);
940
- return maybeRedirect(P, node);
941
- }
942
- if (t.type === 'OP' && (t.value === '[' || t.value === '[[')) {
943
- const open = leaf(P, t.value, t);
944
- const closer = t.value === '[' ? ']' : ']]';
945
- // Grammar: `[` can contain choice(_expression, redirected_statement).
946
- // Try _expression first; if we don't reach `]`, backtrack and parse as
947
- // redirected_statement (handles `[ ! cmd -v go &>/dev/null ]`).
948
- const exprSave = saveLex(P.L);
949
- let expr = parseTestExpr(P, closer);
950
- skipBlanks(P.L);
951
- if (t.value === '[' && peek(P.L) !== ']') {
952
- // Expression parse didn't reach `]` — try as redirected_statement.
953
- // Thread `]` stop-token so parseSimpleCommand doesn't eat it as arg.
954
- restoreLex(P.L, exprSave);
955
- const prevStop = P.stopToken;
956
- P.stopToken = ']';
957
- const rstmt = parseCommand(P);
958
- P.stopToken = prevStop;
959
- if (rstmt && rstmt.type === 'redirected_statement') {
960
- expr = rstmt;
961
- }
962
- else {
963
- // Neither worked — restore and keep the expression result
964
- restoreLex(P.L, exprSave);
965
- expr = parseTestExpr(P, closer);
966
- }
967
- skipBlanks(P.L);
968
- }
969
- const closeTok = nextToken(P.L, 'arg');
970
- let close;
971
- if (closeTok.value === closer) {
972
- close = leaf(P, closer, closeTok);
973
- }
974
- else {
975
- close = mk(P, closer, open.endIndex, open.endIndex, []);
976
- }
977
- const kids = expr ? [open, expr, close] : [open, close];
978
- return mk(P, 'test_command', open.startIndex, close.endIndex, kids);
979
- }
980
- if (t.type === 'WORD') {
981
- if (t.value === 'if')
982
- return maybeRedirect(P, parseIf(P, t), true);
983
- if (t.value === 'while' || t.value === 'until')
984
- return maybeRedirect(P, parseWhile(P, t), true);
985
- if (t.value === 'for')
986
- return maybeRedirect(P, parseFor(P, t), true);
987
- if (t.value === 'select')
988
- return maybeRedirect(P, parseFor(P, t), true);
989
- if (t.value === 'case')
990
- return maybeRedirect(P, parseCase(P, t), true);
991
- if (t.value === 'function')
992
- return parseFunction(P, t);
993
- if (DECL_KEYWORDS.has(t.value))
994
- return maybeRedirect(P, parseDeclaration(P, t));
995
- if (t.value === 'unset' || t.value === 'unsetenv') {
996
- return maybeRedirect(P, parseUnset(P, t));
997
- }
998
- }
999
- restoreLex(P.L, save);
1000
- return parseSimpleCommand(P);
1001
- }
1002
- /**
1003
- * Parse a simple command: [assignment]* word [arg|redirect]*
1004
- * Returns variable_assignment if only one assignment and no command.
1005
- */
1006
- function parseSimpleCommand(P) {
1007
- const start = P.L.b;
1008
- const assignments = [];
1009
- const preRedirects = [];
1010
- while (true) {
1011
- skipBlanks(P.L);
1012
- const a = tryParseAssignment(P);
1013
- if (a) {
1014
- assignments.push(a);
1015
- continue;
1016
- }
1017
- const r = tryParseRedirect(P);
1018
- if (r) {
1019
- preRedirects.push(r);
1020
- continue;
1021
- }
1022
- break;
1023
- }
1024
- skipBlanks(P.L);
1025
- const save = saveLex(P.L);
1026
- const nameTok = nextToken(P.L, 'cmd');
1027
- if (nameTok.type === 'EOF' ||
1028
- nameTok.type === 'NEWLINE' ||
1029
- nameTok.type === 'COMMENT' ||
1030
- (nameTok.type === 'OP' &&
1031
- nameTok.value !== '{' &&
1032
- nameTok.value !== '[' &&
1033
- nameTok.value !== '[[') ||
1034
- (nameTok.type === 'WORD' &&
1035
- SHELL_KEYWORDS.has(nameTok.value) &&
1036
- nameTok.value !== 'in')) {
1037
- restoreLex(P.L, save);
1038
- // No command — standalone assignment(s) or redirect
1039
- if (assignments.length === 1 && preRedirects.length === 0) {
1040
- return assignments[0];
1041
- }
1042
- if (preRedirects.length > 0 && assignments.length === 0) {
1043
- // Bare redirect → redirected_statement with just file_redirect children
1044
- const last = preRedirects[preRedirects.length - 1];
1045
- return mk(P, 'redirected_statement', preRedirects[0].startIndex, last.endIndex, preRedirects);
1046
- }
1047
- if (assignments.length > 1 && preRedirects.length === 0) {
1048
- // `A=1 B=2` with no command → variable_assignments (plural)
1049
- const last = assignments[assignments.length - 1];
1050
- return mk(P, 'variable_assignments', assignments[0].startIndex, last.endIndex, assignments);
1051
- }
1052
- if (assignments.length > 0 || preRedirects.length > 0) {
1053
- const all = [...assignments, ...preRedirects];
1054
- const last = all[all.length - 1];
1055
- return mk(P, 'command', start, last.endIndex, all);
1056
- }
1057
- return null;
1058
- }
1059
- restoreLex(P.L, save);
1060
- // Check for function definition: name() { ... }
1061
- const fnSave = saveLex(P.L);
1062
- const nm = parseWord(P, 'cmd');
1063
- if (nm && nm.type === 'word') {
1064
- skipBlanks(P.L);
1065
- if (peek(P.L) === '(' && peek(P.L, 1) === ')') {
1066
- const oTok = nextToken(P.L, 'cmd');
1067
- const cTok = nextToken(P.L, 'cmd');
1068
- const oParen = leaf(P, '(', oTok);
1069
- const cParen = leaf(P, ')', cTok);
1070
- skipBlanks(P.L);
1071
- skipNewlines(P);
1072
- const body = parseCommand(P);
1073
- if (body) {
1074
- // If body is redirected_statement(compound_statement, file_redirect...),
1075
- // hoist redirects to function_definition level per tree-sitter grammar
1076
- let bodyKids = [body];
1077
- if (body.type === 'redirected_statement' &&
1078
- body.children.length >= 2 &&
1079
- body.children[0].type === 'compound_statement') {
1080
- bodyKids = body.children;
1081
- }
1082
- const last = bodyKids[bodyKids.length - 1];
1083
- return mk(P, 'function_definition', nm.startIndex, last.endIndex, [
1084
- nm,
1085
- oParen,
1086
- cParen,
1087
- ...bodyKids,
1088
- ]);
1089
- }
1090
- }
1091
- }
1092
- restoreLex(P.L, fnSave);
1093
- const nameArg = parseWord(P, 'cmd');
1094
- if (!nameArg) {
1095
- if (assignments.length === 1)
1096
- return assignments[0];
1097
- return null;
1098
- }
1099
- const cmdName = mk(P, 'command_name', nameArg.startIndex, nameArg.endIndex, [
1100
- nameArg,
1101
- ]);
1102
- const args = [];
1103
- const redirects = [];
1104
- let heredocRedirect = null;
1105
- while (true) {
1106
- skipBlanks(P.L);
1107
- // Post-command redirects are greedy (repeat1 $._literal) — once a redirect
1108
- // appears after command_name, subsequent literals attach to it per grammar's
1109
- // prec.left. `grep 2>/dev/null -q foo` → file_redirect eats `-q foo`.
1110
- // Args parsed BEFORE the first redirect still go to command (cat a b > out).
1111
- const r = tryParseRedirect(P, true);
1112
- if (r) {
1113
- if (r.type === 'heredoc_redirect') {
1114
- heredocRedirect = r;
1115
- }
1116
- else if (r.type === 'herestring_redirect') {
1117
- args.push(r);
1118
- }
1119
- else {
1120
- redirects.push(r);
1121
- }
1122
- continue;
1123
- }
1124
- // Once a file_redirect has been seen, command args are done — grammar's
1125
- // command rule doesn't allow file_redirect in its post-name choice, so
1126
- // anything after belongs to redirected_statement's file_redirect children.
1127
- if (redirects.length > 0)
1128
- break;
1129
- // `[` test_command backtrack — stop at `]` so outer handler can consume it
1130
- if (P.stopToken === ']' && peek(P.L) === ']')
1131
- break;
1132
- const save2 = saveLex(P.L);
1133
- const pk = nextToken(P.L, 'arg');
1134
- if (pk.type === 'EOF' ||
1135
- pk.type === 'NEWLINE' ||
1136
- pk.type === 'COMMENT' ||
1137
- (pk.type === 'OP' &&
1138
- (pk.value === '|' ||
1139
- pk.value === '|&' ||
1140
- pk.value === '&&' ||
1141
- pk.value === '||' ||
1142
- pk.value === ';' ||
1143
- pk.value === ';;' ||
1144
- pk.value === ';&' ||
1145
- pk.value === ';;&' ||
1146
- pk.value === '&' ||
1147
- pk.value === ')' ||
1148
- pk.value === '}' ||
1149
- pk.value === '))'))) {
1150
- restoreLex(P.L, save2);
1151
- break;
1152
- }
1153
- restoreLex(P.L, save2);
1154
- const arg = parseWord(P, 'arg');
1155
- if (!arg) {
1156
- // Lone `(` in arg position — tree-sitter parses this as subshell arg
1157
- // e.g., `echo =(cmd)` → command has ERROR(=), subshell(cmd) as args
1158
- if (peek(P.L) === '(') {
1159
- const oTok = nextToken(P.L, 'cmd');
1160
- const open = leaf(P, '(', oTok);
1161
- const body = parseStatements(P, ')');
1162
- const cTok = nextToken(P.L, 'cmd');
1163
- const close = cTok.type === 'OP' && cTok.value === ')'
1164
- ? leaf(P, ')', cTok)
1165
- : mk(P, ')', open.endIndex, open.endIndex, []);
1166
- args.push(mk(P, 'subshell', open.startIndex, close.endIndex, [
1167
- open,
1168
- ...body,
1169
- close,
1170
- ]));
1171
- continue;
1172
- }
1173
- break;
1174
- }
1175
- // Lone `=` in arg position is a parse error in bash — tree-sitter wraps
1176
- // it in ERROR for recovery. Happens in `echo =(cmd)` (zsh process-sub).
1177
- if (arg.type === 'word' && arg.text === '=') {
1178
- args.push(mk(P, 'ERROR', arg.startIndex, arg.endIndex, [arg]));
1179
- continue;
1180
- }
1181
- // Word immediately followed by `(` (no whitespace) is a parse error —
1182
- // bash doesn't allow glob-then-subshell adjacency. tree-sitter wraps the
1183
- // word in ERROR. Catches zsh glob qualifiers like `*.(e:'cmd':)`.
1184
- if ((arg.type === 'word' || arg.type === 'concatenation') &&
1185
- peek(P.L) === '(' &&
1186
- P.L.b === arg.endIndex) {
1187
- args.push(mk(P, 'ERROR', arg.startIndex, arg.endIndex, [arg]));
1188
- continue;
1189
- }
1190
- args.push(arg);
1191
- }
1192
- // preRedirects (e.g., `2>&1 cat`, `<<<str cmd`) go INSIDE the command node
1193
- // before command_name per tree-sitter grammar, not in redirected_statement
1194
- const cmdChildren = [...assignments, ...preRedirects, cmdName, ...args];
1195
- const cmdEnd = cmdChildren.length > 0
1196
- ? cmdChildren[cmdChildren.length - 1].endIndex
1197
- : cmdName.endIndex;
1198
- const cmdStart = cmdChildren[0].startIndex;
1199
- const cmd = mk(P, 'command', cmdStart, cmdEnd, cmdChildren);
1200
- if (heredocRedirect) {
1201
- // Scan heredoc body now
1202
- scanHeredocBodies(P);
1203
- const hd = P.L.heredocs.shift();
1204
- if (hd && heredocRedirect.children.length >= 2) {
1205
- const bodyNode = mk(P, 'heredoc_body', hd.bodyStart, hd.bodyEnd, hd.quoted ? [] : parseHeredocBodyContent(P, hd.bodyStart, hd.bodyEnd));
1206
- const endNode = mk(P, 'heredoc_end', hd.endStart, hd.endEnd, []);
1207
- heredocRedirect.children.push(bodyNode, endNode);
1208
- heredocRedirect.endIndex = hd.endEnd;
1209
- heredocRedirect.text = sliceBytes(P, heredocRedirect.startIndex, hd.endEnd);
1210
- }
1211
- const allR = [...preRedirects, heredocRedirect, ...redirects];
1212
- const rStart = preRedirects.length > 0
1213
- ? Math.min(cmd.startIndex, preRedirects[0].startIndex)
1214
- : cmd.startIndex;
1215
- return mk(P, 'redirected_statement', rStart, heredocRedirect.endIndex, [
1216
- cmd,
1217
- ...allR,
1218
- ]);
1219
- }
1220
- if (redirects.length > 0) {
1221
- const last = redirects[redirects.length - 1];
1222
- return mk(P, 'redirected_statement', cmd.startIndex, last.endIndex, [
1223
- cmd,
1224
- ...redirects,
1225
- ]);
1226
- }
1227
- return cmd;
1228
- }
1229
- function maybeRedirect(P, node, allowHerestring = false) {
1230
- const redirects = [];
1231
- while (true) {
1232
- skipBlanks(P.L);
1233
- const save = saveLex(P.L);
1234
- const r = tryParseRedirect(P);
1235
- if (!r)
1236
- break;
1237
- if (r.type === 'herestring_redirect' && !allowHerestring) {
1238
- restoreLex(P.L, save);
1239
- break;
1240
- }
1241
- redirects.push(r);
1242
- }
1243
- if (redirects.length === 0)
1244
- return node;
1245
- const last = redirects[redirects.length - 1];
1246
- return mk(P, 'redirected_statement', node.startIndex, last.endIndex, [
1247
- node,
1248
- ...redirects,
1249
- ]);
1250
- }
1251
- function tryParseAssignment(P) {
1252
- const save = saveLex(P.L);
1253
- skipBlanks(P.L);
1254
- const startB = P.L.b;
1255
- // Must start with identifier
1256
- if (!isIdentStart(peek(P.L))) {
1257
- restoreLex(P.L, save);
1258
- return null;
1259
- }
1260
- while (isIdentChar(peek(P.L)))
1261
- advance(P.L);
1262
- const nameEnd = P.L.b;
1263
- // Optional subscript
1264
- let subEnd = nameEnd;
1265
- if (peek(P.L) === '[') {
1266
- advance(P.L);
1267
- let depth = 1;
1268
- while (P.L.i < P.L.len && depth > 0) {
1269
- const c = peek(P.L);
1270
- if (c === '[')
1271
- depth++;
1272
- else if (c === ']')
1273
- depth--;
1274
- advance(P.L);
1275
- }
1276
- subEnd = P.L.b;
1277
- }
1278
- const c = peek(P.L);
1279
- const c1 = peek(P.L, 1);
1280
- let op;
1281
- if (c === '=' && c1 !== '=') {
1282
- op = '=';
1283
- }
1284
- else if (c === '+' && c1 === '=') {
1285
- op = '+=';
1286
- }
1287
- else {
1288
- restoreLex(P.L, save);
1289
- return null;
1290
- }
1291
- const nameNode = mk(P, 'variable_name', startB, nameEnd, []);
1292
- // Subscript handling: wrap in subscript node if present
1293
- let lhs = nameNode;
1294
- if (subEnd > nameEnd) {
1295
- const brOpen = mk(P, '[', nameEnd, nameEnd + 1, []);
1296
- const idx = parseSubscriptIndex(P, nameEnd + 1, subEnd - 1);
1297
- const brClose = mk(P, ']', subEnd - 1, subEnd, []);
1298
- lhs = mk(P, 'subscript', startB, subEnd, [nameNode, brOpen, idx, brClose]);
1299
- }
1300
- const opStart = P.L.b;
1301
- advance(P.L);
1302
- if (op === '+=')
1303
- advance(P.L);
1304
- const opEnd = P.L.b;
1305
- const opNode = mk(P, op, opStart, opEnd, []);
1306
- let val = null;
1307
- if (peek(P.L) === '(') {
1308
- // Array
1309
- const aoTok = nextToken(P.L, 'cmd');
1310
- const aOpen = leaf(P, '(', aoTok);
1311
- const elems = [aOpen];
1312
- while (true) {
1313
- skipBlanks(P.L);
1314
- if (peek(P.L) === ')')
1315
- break;
1316
- const e = parseWord(P, 'arg');
1317
- if (!e)
1318
- break;
1319
- elems.push(e);
1320
- }
1321
- const acTok = nextToken(P.L, 'cmd');
1322
- const aClose = acTok.value === ')'
1323
- ? leaf(P, ')', acTok)
1324
- : mk(P, ')', aOpen.endIndex, aOpen.endIndex, []);
1325
- elems.push(aClose);
1326
- val = mk(P, 'array', aOpen.startIndex, aClose.endIndex, elems);
1327
- }
1328
- else {
1329
- const c2 = peek(P.L);
1330
- if (c2 &&
1331
- c2 !== ' ' &&
1332
- c2 !== '\t' &&
1333
- c2 !== '\n' &&
1334
- c2 !== ';' &&
1335
- c2 !== '&' &&
1336
- c2 !== '|' &&
1337
- c2 !== ')' &&
1338
- c2 !== '}') {
1339
- val = parseWord(P, 'arg');
1340
- }
1341
- }
1342
- const kids = val ? [lhs, opNode, val] : [lhs, opNode];
1343
- const end = val ? val.endIndex : opEnd;
1344
- return mk(P, 'variable_assignment', startB, end, kids);
1345
- }
1346
- /**
1347
- * Parse subscript index content. Parsed arithmetically per tree-sitter grammar:
1348
- * `${a[1+2]}` → binary_expression; `${a[++i]}` → unary_expression(word);
1349
- * `${a[(($n+1))]}` → compound_statement(binary_expression). Falls back to
1350
- * simple patterns (@, *) as word.
1351
- */
1352
- function parseSubscriptIndexInline(P) {
1353
- skipBlanks(P.L);
1354
- const c = peek(P.L);
1355
- // @ or * alone → word (associative array all-keys)
1356
- if ((c === '@' || c === '*') && peek(P.L, 1) === ']') {
1357
- const s = P.L.b;
1358
- advance(P.L);
1359
- return mk(P, 'word', s, P.L.b, []);
1360
- }
1361
- // ((expr)) → compound_statement wrapping the inner arithmetic
1362
- if (c === '(' && peek(P.L, 1) === '(') {
1363
- const oStart = P.L.b;
1364
- advance(P.L);
1365
- advance(P.L);
1366
- const open = mk(P, '((', oStart, P.L.b, []);
1367
- const inner = parseArithExpr(P, '))', 'var');
1368
- skipBlanks(P.L);
1369
- let close;
1370
- if (peek(P.L) === ')' && peek(P.L, 1) === ')') {
1371
- const cs = P.L.b;
1372
- advance(P.L);
1373
- advance(P.L);
1374
- close = mk(P, '))', cs, P.L.b, []);
1375
- }
1376
- else {
1377
- close = mk(P, '))', P.L.b, P.L.b, []);
1378
- }
1379
- const kids = inner ? [open, inner, close] : [open, close];
1380
- return mk(P, 'compound_statement', open.startIndex, close.endIndex, kids);
1381
- }
1382
- // Arithmetic — but bare identifiers in subscript use 'word' mode per
1383
- // tree-sitter (${words[++counter]} → unary_expression(word)).
1384
- return parseArithExpr(P, ']', 'word');
1385
- }
1386
- /** Legacy byte-range subscript index parser — kept for callers that pre-scan. */
1387
- function parseSubscriptIndex(P, startB, endB) {
1388
- const text = sliceBytes(P, startB, endB);
1389
- if (/^\d+$/.test(text))
1390
- return mk(P, 'number', startB, endB, []);
1391
- const m = /^\$([a-zA-Z_]\w*)$/.exec(text);
1392
- if (m) {
1393
- const dollar = mk(P, '$', startB, startB + 1, []);
1394
- const vn = mk(P, 'variable_name', startB + 1, endB, []);
1395
- return mk(P, 'simple_expansion', startB, endB, [dollar, vn]);
1396
- }
1397
- if (text.length === 2 && text[0] === '$' && SPECIAL_VARS.has(text[1])) {
1398
- const dollar = mk(P, '$', startB, startB + 1, []);
1399
- const vn = mk(P, 'special_variable_name', startB + 1, endB, []);
1400
- return mk(P, 'simple_expansion', startB, endB, [dollar, vn]);
1401
- }
1402
- return mk(P, 'word', startB, endB, []);
1403
- }
1404
- /**
1405
- * Can the current position start a redirect destination literal?
1406
- * Returns false at redirect ops, terminators, or file-descriptor-prefixed ops
1407
- * so file_redirect's repeat1($._literal) stops at the right boundary.
1408
- */
1409
- function isRedirectLiteralStart(P) {
1410
- const c = peek(P.L);
1411
- if (c === '' || c === '\n')
1412
- return false;
1413
- // Shell terminators and operators
1414
- if (c === '|' || c === '&' || c === ';' || c === '(' || c === ')')
1415
- return false;
1416
- // Redirect operators (< > with any suffix; <( >( handled by caller)
1417
- if (c === '<' || c === '>') {
1418
- // <( >( are process substitutions — those ARE literals
1419
- return peek(P.L, 1) === '(';
1420
- }
1421
- // N< N> file descriptor prefix — starts a new redirect, not a literal
1422
- if (isDigit(c)) {
1423
- let j = P.L.i;
1424
- while (j < P.L.len && isDigit(P.L.src[j]))
1425
- j++;
1426
- const after = j < P.L.len ? P.L.src[j] : '';
1427
- if (after === '>' || after === '<')
1428
- return false;
1429
- }
1430
- // `}` only terminates if we're in a context where it's a closer — but
1431
- // file_redirect sees `}` as word char (e.g., `>$HOME}` is valid path char).
1432
- // Actually `}` at top level terminates compound_statement — need to stop.
1433
- if (c === '}')
1434
- return false;
1435
- // Test command closer — when parseSimpleCommand is called from `[` context,
1436
- // `]` must terminate so parseCommand can return and `[` handler consume it.
1437
- if (P.stopToken === ']' && c === ']')
1438
- return false;
1439
- return true;
1440
- }
1441
- /**
1442
- * Parse a redirect operator + destination(s).
1443
- * @param greedy When true, file_redirect consumes repeat1($._literal) per
1444
- * grammar's prec.left — `cmd >f a b c` attaches `a b c` to the redirect.
1445
- * When false (preRedirect context), takes only 1 destination because
1446
- * command's dynamic precedence beats redirected_statement's prec(-1).
1447
- */
1448
- function tryParseRedirect(P, greedy = false) {
1449
- const save = saveLex(P.L);
1450
- skipBlanks(P.L);
1451
- // File descriptor prefix?
1452
- let fd = null;
1453
- if (isDigit(peek(P.L))) {
1454
- const startB = P.L.b;
1455
- let j = P.L.i;
1456
- while (j < P.L.len && isDigit(P.L.src[j]))
1457
- j++;
1458
- const after = j < P.L.len ? P.L.src[j] : '';
1459
- if (after === '>' || after === '<') {
1460
- while (P.L.i < j)
1461
- advance(P.L);
1462
- fd = mk(P, 'file_descriptor', startB, P.L.b, []);
1463
- }
1464
- }
1465
- const t = nextToken(P.L, 'arg');
1466
- if (t.type !== 'OP') {
1467
- restoreLex(P.L, save);
1468
- return null;
1469
- }
1470
- const v = t.value;
1471
- if (v === '<<<') {
1472
- const op = leaf(P, '<<<', t);
1473
- skipBlanks(P.L);
1474
- const target = parseWord(P, 'arg');
1475
- const end = target ? target.endIndex : op.endIndex;
1476
- const kids = target ? [op, target] : [op];
1477
- return mk(P, 'herestring_redirect', fd ? fd.startIndex : op.startIndex, end, fd ? [fd, ...kids] : kids);
1478
- }
1479
- if (v === '<<' || v === '<<-') {
1480
- const op = leaf(P, v, t);
1481
- // Heredoc start — delimiter word (may be quoted)
1482
- skipBlanks(P.L);
1483
- const dStart = P.L.b;
1484
- let quoted = false;
1485
- let delim = '';
1486
- const dc = peek(P.L);
1487
- if (dc === "'" || dc === '"') {
1488
- quoted = true;
1489
- advance(P.L);
1490
- while (P.L.i < P.L.len && peek(P.L) !== dc) {
1491
- delim += peek(P.L);
1492
- advance(P.L);
1493
- }
1494
- if (P.L.i < P.L.len)
1495
- advance(P.L);
1496
- }
1497
- else if (dc === '\\') {
1498
- // Backslash-escaped delimiter: \X — exactly one escaped char, body is
1499
- // quoted (literal). Covers <<\EOF <<\' <<\\ etc.
1500
- quoted = true;
1501
- advance(P.L);
1502
- if (P.L.i < P.L.len && peek(P.L) !== '\n') {
1503
- delim += peek(P.L);
1504
- advance(P.L);
1505
- }
1506
- // May be followed by more ident chars (e.g. <<\EOF → delim "EOF")
1507
- while (P.L.i < P.L.len && isIdentChar(peek(P.L))) {
1508
- delim += peek(P.L);
1509
- advance(P.L);
1510
- }
1511
- }
1512
- else {
1513
- // Unquoted delimiter: bash accepts most non-metacharacters (not just
1514
- // identifiers). Allow !, -, ., etc. — stop at shell metachars.
1515
- while (P.L.i < P.L.len && isHeredocDelimChar(peek(P.L))) {
1516
- delim += peek(P.L);
1517
- advance(P.L);
1518
- }
1519
- }
1520
- const dEnd = P.L.b;
1521
- const startNode = mk(P, 'heredoc_start', dStart, dEnd, []);
1522
- // Register pending heredoc — body scanned at next newline
1523
- P.L.heredocs.push({
1524
- delim,
1525
- stripTabs: v === '<<-',
1526
- quoted,
1527
- bodyStart: 0,
1528
- bodyEnd: 0,
1529
- endStart: 0,
1530
- endEnd: 0,
1531
- });
1532
- const kids = fd ? [fd, op, startNode] : [op, startNode];
1533
- const startIdx = fd ? fd.startIndex : op.startIndex;
1534
- // SECURITY: tree-sitter nests any pipeline/list/file_redirect appearing
1535
- // between heredoc_start and the newline as a CHILD of heredoc_redirect.
1536
- // `ls <<'EOF' | rm -rf /tmp/evil` must not silently drop the rm. Parse
1537
- // trailing words and file_redirects properly (ast.ts walkHeredocRedirect
1538
- // fails closed on any unrecognized child via tooComplex). Pipeline / list
1539
- // operators (| && || ;) are structurally complex — emit ERROR so the same
1540
- // fail-closed path rejects them.
1541
- while (true) {
1542
- skipBlanks(P.L);
1543
- const tc = peek(P.L);
1544
- if (tc === '\n' || tc === '' || P.L.i >= P.L.len)
1545
- break;
1546
- // File redirect after delimiter: cat <<EOF > out.txt
1547
- if (tc === '>' || tc === '<' || isDigit(tc)) {
1548
- const rSave = saveLex(P.L);
1549
- const r = tryParseRedirect(P);
1550
- if (r && r.type === 'file_redirect') {
1551
- kids.push(r);
1552
- continue;
1553
- }
1554
- restoreLex(P.L, rSave);
1555
- }
1556
- // Pipeline after heredoc_start: `one <<EOF | grep two` — tree-sitter
1557
- // nests the pipeline as a child of heredoc_redirect. ast.ts
1558
- // walkHeredocRedirect fails closed on pipeline/command via tooComplex.
1559
- if (tc === '|' && peek(P.L, 1) !== '|') {
1560
- advance(P.L);
1561
- skipBlanks(P.L);
1562
- const pipeCmds = [];
1563
- while (true) {
1564
- const cmd = parseCommand(P);
1565
- if (!cmd)
1566
- break;
1567
- pipeCmds.push(cmd);
1568
- skipBlanks(P.L);
1569
- if (peek(P.L) === '|' && peek(P.L, 1) !== '|') {
1570
- const ps = P.L.b;
1571
- advance(P.L);
1572
- pipeCmds.push(mk(P, '|', ps, P.L.b, []));
1573
- skipBlanks(P.L);
1574
- continue;
1575
- }
1576
- break;
1577
- }
1578
- if (pipeCmds.length > 0) {
1579
- const pl = pipeCmds[pipeCmds.length - 1];
1580
- // tree-sitter always wraps in pipeline after `|`, even single command
1581
- kids.push(mk(P, 'pipeline', pipeCmds[0].startIndex, pl.endIndex, pipeCmds));
1582
- }
1583
- continue;
1584
- }
1585
- // && / || after heredoc_start: `cat <<-EOF || die "..."` — tree-sitter
1586
- // nests just the RHS command (not a list) as a child of heredoc_redirect.
1587
- if ((tc === '&' && peek(P.L, 1) === '&') ||
1588
- (tc === '|' && peek(P.L, 1) === '|')) {
1589
- advance(P.L);
1590
- advance(P.L);
1591
- skipBlanks(P.L);
1592
- const rhs = parseCommand(P);
1593
- if (rhs)
1594
- kids.push(rhs);
1595
- continue;
1596
- }
1597
- // Terminator / unhandled metachar — consume rest of line as ERROR so
1598
- // ast.ts rejects it. Covers ; & ( )
1599
- if (tc === '&' || tc === ';' || tc === '(' || tc === ')') {
1600
- const eStart = P.L.b;
1601
- while (P.L.i < P.L.len && peek(P.L) !== '\n')
1602
- advance(P.L);
1603
- kids.push(mk(P, 'ERROR', eStart, P.L.b, []));
1604
- break;
1605
- }
1606
- // Trailing word argument: newins <<-EOF - org.freedesktop.service
1607
- const w = parseWord(P, 'arg');
1608
- if (w) {
1609
- kids.push(w);
1610
- continue;
1611
- }
1612
- // Unrecognized — consume rest of line as ERROR
1613
- const eStart = P.L.b;
1614
- while (P.L.i < P.L.len && peek(P.L) !== '\n')
1615
- advance(P.L);
1616
- if (P.L.b > eStart)
1617
- kids.push(mk(P, 'ERROR', eStart, P.L.b, []));
1618
- break;
1619
- }
1620
- return mk(P, 'heredoc_redirect', startIdx, P.L.b, kids);
1621
- }
1622
- // Close-fd variants: `<&-` `>&-` have OPTIONAL destination (0 or 1)
1623
- if (v === '<&-' || v === '>&-') {
1624
- const op = leaf(P, v, t);
1625
- const kids = [];
1626
- if (fd)
1627
- kids.push(fd);
1628
- kids.push(op);
1629
- // Optional single destination — only consume if next is a literal
1630
- skipBlanks(P.L);
1631
- const dSave = saveLex(P.L);
1632
- const dest = isRedirectLiteralStart(P) ? parseWord(P, 'arg') : null;
1633
- if (dest) {
1634
- kids.push(dest);
1635
- }
1636
- else {
1637
- restoreLex(P.L, dSave);
1638
- }
1639
- const startIdx = fd ? fd.startIndex : op.startIndex;
1640
- const end = dest ? dest.endIndex : op.endIndex;
1641
- return mk(P, 'file_redirect', startIdx, end, kids);
1642
- }
1643
- if (v === '>' ||
1644
- v === '>>' ||
1645
- v === '>&' ||
1646
- v === '>|' ||
1647
- v === '&>' ||
1648
- v === '&>>' ||
1649
- v === '<' ||
1650
- v === '<&') {
1651
- const op = leaf(P, v, t);
1652
- const kids = [];
1653
- if (fd)
1654
- kids.push(fd);
1655
- kids.push(op);
1656
- // Grammar: destination is repeat1($._literal) — greedily consume literals
1657
- // until a non-literal (redirect op, terminator, etc). tree-sitter's
1658
- // prec.left makes `cmd >f a b c` attach `a b c` to the file_redirect,
1659
- // NOT to the command. Structural quirk but required for corpus parity.
1660
- // In preRedirect context (greedy=false), take only 1 literal because
1661
- // command's dynamic precedence beats redirected_statement's prec(-1).
1662
- let end = op.endIndex;
1663
- let taken = 0;
1664
- while (true) {
1665
- skipBlanks(P.L);
1666
- if (!isRedirectLiteralStart(P))
1667
- break;
1668
- if (!greedy && taken >= 1)
1669
- break;
1670
- const tc = peek(P.L);
1671
- const tc1 = peek(P.L, 1);
1672
- let target = null;
1673
- if ((tc === '<' || tc === '>') && tc1 === '(') {
1674
- target = parseProcessSub(P);
1675
- }
1676
- else {
1677
- target = parseWord(P, 'arg');
1678
- }
1679
- if (!target)
1680
- break;
1681
- kids.push(target);
1682
- end = target.endIndex;
1683
- taken++;
1684
- }
1685
- const startIdx = fd ? fd.startIndex : op.startIndex;
1686
- return mk(P, 'file_redirect', startIdx, end, kids);
1687
- }
1688
- restoreLex(P.L, save);
1689
- return null;
1690
- }
1691
- function parseProcessSub(P) {
1692
- const c = peek(P.L);
1693
- if ((c !== '<' && c !== '>') || peek(P.L, 1) !== '(')
1694
- return null;
1695
- const start = P.L.b;
1696
- advance(P.L);
1697
- advance(P.L);
1698
- const open = mk(P, c + '(', start, P.L.b, []);
1699
- const body = parseStatements(P, ')');
1700
- skipBlanks(P.L);
1701
- let close;
1702
- if (peek(P.L) === ')') {
1703
- const cs = P.L.b;
1704
- advance(P.L);
1705
- close = mk(P, ')', cs, P.L.b, []);
1706
- }
1707
- else {
1708
- close = mk(P, ')', P.L.b, P.L.b, []);
1709
- }
1710
- return mk(P, 'process_substitution', start, close.endIndex, [
1711
- open,
1712
- ...body,
1713
- close,
1714
- ]);
1715
- }
1716
- function scanHeredocBodies(P) {
1717
- // Skip to newline if not already there
1718
- while (P.L.i < P.L.len && P.L.src[P.L.i] !== '\n')
1719
- advance(P.L);
1720
- if (P.L.i < P.L.len)
1721
- advance(P.L);
1722
- for (const hd of P.L.heredocs) {
1723
- hd.bodyStart = P.L.b;
1724
- const delimLen = hd.delim.length;
1725
- while (P.L.i < P.L.len) {
1726
- const lineStart = P.L.i;
1727
- const lineStartB = P.L.b;
1728
- // Skip leading tabs if <<-
1729
- let checkI = lineStart;
1730
- if (hd.stripTabs) {
1731
- while (checkI < P.L.len && P.L.src[checkI] === '\t')
1732
- checkI++;
1733
- }
1734
- // Check if this line is the delimiter
1735
- if (P.L.src.startsWith(hd.delim, checkI) &&
1736
- (checkI + delimLen >= P.L.len ||
1737
- P.L.src[checkI + delimLen] === '\n' ||
1738
- P.L.src[checkI + delimLen] === '\r')) {
1739
- hd.bodyEnd = lineStartB;
1740
- // Advance past tabs
1741
- while (P.L.i < checkI)
1742
- advance(P.L);
1743
- hd.endStart = P.L.b;
1744
- // Advance past delimiter
1745
- for (let k = 0; k < delimLen; k++)
1746
- advance(P.L);
1747
- hd.endEnd = P.L.b;
1748
- // Skip trailing newline
1749
- if (P.L.i < P.L.len && P.L.src[P.L.i] === '\n')
1750
- advance(P.L);
1751
- return;
1752
- }
1753
- // Consume line
1754
- while (P.L.i < P.L.len && P.L.src[P.L.i] !== '\n')
1755
- advance(P.L);
1756
- if (P.L.i < P.L.len)
1757
- advance(P.L);
1758
- }
1759
- // Unterminated
1760
- hd.bodyEnd = P.L.b;
1761
- hd.endStart = P.L.b;
1762
- hd.endEnd = P.L.b;
1763
- }
1764
- }
1765
- function parseHeredocBodyContent(P, start, end) {
1766
- // Parse expansions inside an unquoted heredoc body.
1767
- const saved = saveLex(P.L);
1768
- // Position lexer at body start
1769
- restoreLexToByte(P, start);
1770
- const out = [];
1771
- let contentStart = P.L.b;
1772
- // tree-sitter-bash's heredoc_body rule hides the initial text segment
1773
- // (_heredoc_body_beginning) — only content AFTER the first expansion is
1774
- // emitted as heredoc_content. Track whether we've seen an expansion yet.
1775
- let sawExpansion = false;
1776
- while (P.L.b < end) {
1777
- const c = peek(P.L);
1778
- // Backslash escapes suppress expansion: \$ \` stay literal in heredoc.
1779
- if (c === '\\') {
1780
- const nxt = peek(P.L, 1);
1781
- if (nxt === '$' || nxt === '`' || nxt === '\\') {
1782
- advance(P.L);
1783
- advance(P.L);
1784
- continue;
1785
- }
1786
- advance(P.L);
1787
- continue;
1788
- }
1789
- if (c === '$' || c === '`') {
1790
- const preB = P.L.b;
1791
- const exp = parseDollarLike(P);
1792
- // Bare `$` followed by non-name (e.g. `$'` in a regex) returns a lone
1793
- // '$' leaf, not an expansion — treat as literal content, don't split.
1794
- if (exp &&
1795
- (exp.type === 'simple_expansion' ||
1796
- exp.type === 'expansion' ||
1797
- exp.type === 'command_substitution' ||
1798
- exp.type === 'arithmetic_expansion')) {
1799
- if (sawExpansion && preB > contentStart) {
1800
- out.push(mk(P, 'heredoc_content', contentStart, preB, []));
1801
- }
1802
- out.push(exp);
1803
- contentStart = P.L.b;
1804
- sawExpansion = true;
1805
- }
1806
- continue;
1807
- }
1808
- advance(P.L);
1809
- }
1810
- // Only emit heredoc_content children if there were expansions — otherwise
1811
- // the heredoc_body is a leaf node (tree-sitter convention).
1812
- if (sawExpansion) {
1813
- out.push(mk(P, 'heredoc_content', contentStart, end, []));
1814
- }
1815
- restoreLex(P.L, saved);
1816
- return out;
1817
- }
1818
- function restoreLexToByte(P, targetByte) {
1819
- if (!P.L.byteTable)
1820
- byteAt(P.L, 0);
1821
- const t = P.L.byteTable;
1822
- let lo = 0;
1823
- let hi = P.src.length;
1824
- while (lo < hi) {
1825
- const m = (lo + hi) >>> 1;
1826
- if (t[m] < targetByte)
1827
- lo = m + 1;
1828
- else
1829
- hi = m;
1830
- }
1831
- P.L.i = lo;
1832
- P.L.b = targetByte;
1833
- }
1834
- /**
1835
- * Parse a word-position element: bare word, string, expansion, or concatenation
1836
- * thereof. Returns a single node; if multiple adjacent fragments, wraps in
1837
- * concatenation.
1838
- */
1839
- function parseWord(P, _ctx) {
1840
- skipBlanks(P.L);
1841
- const parts = [];
1842
- while (P.L.i < P.L.len) {
1843
- const c = peek(P.L);
1844
- if (c === ' ' ||
1845
- c === '\t' ||
1846
- c === '\n' ||
1847
- c === '\r' ||
1848
- c === '' ||
1849
- c === '|' ||
1850
- c === '&' ||
1851
- c === ';' ||
1852
- c === '(' ||
1853
- c === ')') {
1854
- break;
1855
- }
1856
- // < > are redirect operators unless <( >( (process substitution)
1857
- if (c === '<' || c === '>') {
1858
- if (peek(P.L, 1) === '(') {
1859
- const ps = parseProcessSub(P);
1860
- if (ps)
1861
- parts.push(ps);
1862
- continue;
1863
- }
1864
- break;
1865
- }
1866
- if (c === '"') {
1867
- parts.push(parseDoubleQuoted(P));
1868
- continue;
1869
- }
1870
- if (c === "'") {
1871
- const tok = nextToken(P.L, 'arg');
1872
- parts.push(leaf(P, 'raw_string', tok));
1873
- continue;
1874
- }
1875
- if (c === '$') {
1876
- const c1 = peek(P.L, 1);
1877
- if (c1 === "'") {
1878
- const tok = nextToken(P.L, 'arg');
1879
- parts.push(leaf(P, 'ansi_c_string', tok));
1880
- continue;
1881
- }
1882
- if (c1 === '"') {
1883
- // Translated string: emit $ leaf + string node
1884
- const dTok = {
1885
- type: 'DOLLAR',
1886
- value: '$',
1887
- start: P.L.b,
1888
- end: P.L.b + 1,
1889
- };
1890
- advance(P.L);
1891
- parts.push(leaf(P, '$', dTok));
1892
- parts.push(parseDoubleQuoted(P));
1893
- continue;
1894
- }
1895
- if (c1 === '`') {
1896
- // `$` followed by backtick — tree-sitter elides the $ entirely
1897
- // and emits just (command_substitution). Consume $ and let next
1898
- // iteration handle the backtick.
1899
- advance(P.L);
1900
- continue;
1901
- }
1902
- const exp = parseDollarLike(P);
1903
- if (exp)
1904
- parts.push(exp);
1905
- continue;
1906
- }
1907
- if (c === '`') {
1908
- if (P.inBacktick > 0)
1909
- break;
1910
- const bt = parseBacktick(P);
1911
- if (bt)
1912
- parts.push(bt);
1913
- continue;
1914
- }
1915
- // Brace expression {1..5} or {a,b,c} — only if looks like one
1916
- if (c === '{') {
1917
- const be = tryParseBraceExpr(P);
1918
- if (be) {
1919
- parts.push(be);
1920
- continue;
1921
- }
1922
- // SECURITY: if `{` is immediately followed by a command terminator
1923
- // (; | & newline or EOF), it's a standalone word — don't slurp the
1924
- // rest of the line via tryParseBraceLikeCat. `echo {;touch /tmp/evil`
1925
- // must split on `;` so the security walker sees `touch`.
1926
- const nc = peek(P.L, 1);
1927
- if (nc === ';' ||
1928
- nc === '|' ||
1929
- nc === '&' ||
1930
- nc === '\n' ||
1931
- nc === '' ||
1932
- nc === ')' ||
1933
- nc === ' ' ||
1934
- nc === '\t') {
1935
- const bStart = P.L.b;
1936
- advance(P.L);
1937
- parts.push(mk(P, 'word', bStart, P.L.b, []));
1938
- continue;
1939
- }
1940
- // Otherwise treat { and } as word fragments
1941
- const cat = tryParseBraceLikeCat(P);
1942
- if (cat) {
1943
- for (const p of cat)
1944
- parts.push(p);
1945
- continue;
1946
- }
1947
- }
1948
- // Standalone `}` in arg position is a word (e.g., `echo }foo`).
1949
- // parseBareWord breaks on `}` so handle it here.
1950
- if (c === '}') {
1951
- const bStart = P.L.b;
1952
- advance(P.L);
1953
- parts.push(mk(P, 'word', bStart, P.L.b, []));
1954
- continue;
1955
- }
1956
- // `[` and `]` are single-char word fragments (tree-sitter splits at
1957
- // brackets: `[:lower:]` → `[` `:lower:` `]`, `{o[k]}` → 6 words).
1958
- if (c === '[' || c === ']') {
1959
- const bStart = P.L.b;
1960
- advance(P.L);
1961
- parts.push(mk(P, 'word', bStart, P.L.b, []));
1962
- continue;
1963
- }
1964
- // Bare word fragment
1965
- const frag = parseBareWord(P);
1966
- if (!frag)
1967
- break;
1968
- // `NN#${...}` or `NN#$(...)` → (number (expansion|command_substitution)).
1969
- // Grammar: number can be seq(/-?(0x)?[0-9]+#/, choice(expansion, cmd_sub)).
1970
- // `10#${cmd}` must NOT be concatenation — it's a single number node with
1971
- // the expansion as child. Detect here: frag ends with `#`, next is $ {/(.
1972
- if (frag.type === 'word' &&
1973
- /^-?(0x)?[0-9]+#$/.test(frag.text) &&
1974
- peek(P.L) === '$' &&
1975
- (peek(P.L, 1) === '{' || peek(P.L, 1) === '(')) {
1976
- const exp = parseDollarLike(P);
1977
- if (exp) {
1978
- // Prefix `NN#` is an anonymous pattern in grammar — only the
1979
- // expansion/cmd_sub is a named child.
1980
- parts.push(mk(P, 'number', frag.startIndex, exp.endIndex, [exp]));
1981
- continue;
1982
- }
1983
- }
1984
- parts.push(frag);
1985
- }
1986
- if (parts.length === 0)
1987
- return null;
1988
- if (parts.length === 1)
1989
- return parts[0];
1990
- // Concatenation
1991
- const first = parts[0];
1992
- const last = parts[parts.length - 1];
1993
- return mk(P, 'concatenation', first.startIndex, last.endIndex, parts);
1994
- }
1995
- function parseBareWord(P) {
1996
- const start = P.L.b;
1997
- const startI = P.L.i;
1998
- while (P.L.i < P.L.len) {
1999
- const c = peek(P.L);
2000
- if (c === '\\') {
2001
- if (P.L.i + 1 >= P.L.len) {
2002
- // Trailing unpaired `\` at true EOF — tree-sitter emits word WITHOUT
2003
- // the `\` plus a sibling ERROR node. Stop here; caller emits ERROR.
2004
- break;
2005
- }
2006
- const nx = P.L.src[P.L.i + 1];
2007
- if (nx === '\n' || (nx === '\r' && P.L.src[P.L.i + 2] === '\n')) {
2008
- // Line continuation BREAKS the word (tree-sitter quirk) — handles \r?\n
2009
- break;
2010
- }
2011
- advance(P.L);
2012
- advance(P.L);
2013
- continue;
2014
- }
2015
- if (c === ' ' ||
2016
- c === '\t' ||
2017
- c === '\n' ||
2018
- c === '\r' ||
2019
- c === '' ||
2020
- c === '|' ||
2021
- c === '&' ||
2022
- c === ';' ||
2023
- c === '(' ||
2024
- c === ')' ||
2025
- c === '<' ||
2026
- c === '>' ||
2027
- c === '"' ||
2028
- c === "'" ||
2029
- c === '$' ||
2030
- c === '`' ||
2031
- c === '{' ||
2032
- c === '}' ||
2033
- c === '[' ||
2034
- c === ']') {
2035
- break;
2036
- }
2037
- advance(P.L);
2038
- }
2039
- if (P.L.b === start)
2040
- return null;
2041
- const text = P.src.slice(startI, P.L.i);
2042
- const type = /^-?\d+$/.test(text) ? 'number' : 'word';
2043
- return mk(P, type, start, P.L.b, []);
2044
- }
2045
- function tryParseBraceExpr(P) {
2046
- // {N..M} where N, M are numbers or single chars
2047
- const save = saveLex(P.L);
2048
- if (peek(P.L) !== '{')
2049
- return null;
2050
- const oStart = P.L.b;
2051
- advance(P.L);
2052
- const oEnd = P.L.b;
2053
- // First part
2054
- const p1Start = P.L.b;
2055
- while (isDigit(peek(P.L)) || isIdentStart(peek(P.L)))
2056
- advance(P.L);
2057
- const p1End = P.L.b;
2058
- if (p1End === p1Start || peek(P.L) !== '.' || peek(P.L, 1) !== '.') {
2059
- restoreLex(P.L, save);
2060
- return null;
2061
- }
2062
- const dotStart = P.L.b;
2063
- advance(P.L);
2064
- advance(P.L);
2065
- const dotEnd = P.L.b;
2066
- const p2Start = P.L.b;
2067
- while (isDigit(peek(P.L)) || isIdentStart(peek(P.L)))
2068
- advance(P.L);
2069
- const p2End = P.L.b;
2070
- if (p2End === p2Start || peek(P.L) !== '}') {
2071
- restoreLex(P.L, save);
2072
- return null;
2073
- }
2074
- const cStart = P.L.b;
2075
- advance(P.L);
2076
- const cEnd = P.L.b;
2077
- const p1Text = sliceBytes(P, p1Start, p1End);
2078
- const p2Text = sliceBytes(P, p2Start, p2End);
2079
- const p1IsNum = /^\d+$/.test(p1Text);
2080
- const p2IsNum = /^\d+$/.test(p2Text);
2081
- // Valid brace expression: both numbers OR both single chars. Mixed = reject.
2082
- if (p1IsNum !== p2IsNum) {
2083
- restoreLex(P.L, save);
2084
- return null;
2085
- }
2086
- if (!p1IsNum && (p1Text.length !== 1 || p2Text.length !== 1)) {
2087
- restoreLex(P.L, save);
2088
- return null;
2089
- }
2090
- const p1Type = p1IsNum ? 'number' : 'word';
2091
- const p2Type = p2IsNum ? 'number' : 'word';
2092
- return mk(P, 'brace_expression', oStart, cEnd, [
2093
- mk(P, '{', oStart, oEnd, []),
2094
- mk(P, p1Type, p1Start, p1End, []),
2095
- mk(P, '..', dotStart, dotEnd, []),
2096
- mk(P, p2Type, p2Start, p2End, []),
2097
- mk(P, '}', cStart, cEnd, []),
2098
- ]);
2099
- }
2100
- function tryParseBraceLikeCat(P) {
2101
- // {a,b,c} or {} → split into word fragments like tree-sitter does
2102
- if (peek(P.L) !== '{')
2103
- return null;
2104
- const oStart = P.L.b;
2105
- advance(P.L);
2106
- const oEnd = P.L.b;
2107
- const inner = [mk(P, 'word', oStart, oEnd, [])];
2108
- while (P.L.i < P.L.len) {
2109
- const bc = peek(P.L);
2110
- // SECURITY: stop at command terminators so `{foo;rm x` splits correctly.
2111
- if (bc === '}' ||
2112
- bc === '\n' ||
2113
- bc === ';' ||
2114
- bc === '|' ||
2115
- bc === '&' ||
2116
- bc === ' ' ||
2117
- bc === '\t' ||
2118
- bc === '<' ||
2119
- bc === '>' ||
2120
- bc === '(' ||
2121
- bc === ')') {
2122
- break;
2123
- }
2124
- // `[` and `]` are single-char words: {o[k]} → { o [ k ] }
2125
- if (bc === '[' || bc === ']') {
2126
- const bStart = P.L.b;
2127
- advance(P.L);
2128
- inner.push(mk(P, 'word', bStart, P.L.b, []));
2129
- continue;
2130
- }
2131
- const midStart = P.L.b;
2132
- while (P.L.i < P.L.len) {
2133
- const mc = peek(P.L);
2134
- if (mc === '}' ||
2135
- mc === '\n' ||
2136
- mc === ';' ||
2137
- mc === '|' ||
2138
- mc === '&' ||
2139
- mc === ' ' ||
2140
- mc === '\t' ||
2141
- mc === '<' ||
2142
- mc === '>' ||
2143
- mc === '(' ||
2144
- mc === ')' ||
2145
- mc === '[' ||
2146
- mc === ']') {
2147
- break;
2148
- }
2149
- advance(P.L);
2150
- }
2151
- const midEnd = P.L.b;
2152
- if (midEnd > midStart) {
2153
- const midText = sliceBytes(P, midStart, midEnd);
2154
- const midType = /^-?\d+$/.test(midText) ? 'number' : 'word';
2155
- inner.push(mk(P, midType, midStart, midEnd, []));
2156
- }
2157
- else {
2158
- break;
2159
- }
2160
- }
2161
- if (peek(P.L) === '}') {
2162
- const cStart = P.L.b;
2163
- advance(P.L);
2164
- inner.push(mk(P, 'word', cStart, P.L.b, []));
2165
- }
2166
- return inner;
2167
- }
2168
- function parseDoubleQuoted(P) {
2169
- const qStart = P.L.b;
2170
- advance(P.L);
2171
- const qEnd = P.L.b;
2172
- const openQ = mk(P, '"', qStart, qEnd, []);
2173
- const parts = [openQ];
2174
- let contentStart = P.L.b;
2175
- let contentStartI = P.L.i;
2176
- const flushContent = () => {
2177
- if (P.L.b > contentStart) {
2178
- // Tree-sitter's extras rule /\s/ has higher precedence than
2179
- // string_content (prec -1), so whitespace-only segments are elided.
2180
- // `" ${x} "` → (string (expansion)) not (string (string_content)(expansion)(string_content)).
2181
- // Note: this intentionally diverges from preserving all content — cc
2182
- // tests relying on whitespace-only string_content need updating
2183
- // (CCReconcile).
2184
- const txt = P.src.slice(contentStartI, P.L.i);
2185
- if (!/^[ \t]+$/.test(txt)) {
2186
- parts.push(mk(P, 'string_content', contentStart, P.L.b, []));
2187
- }
2188
- }
2189
- };
2190
- while (P.L.i < P.L.len) {
2191
- const c = peek(P.L);
2192
- if (c === '"')
2193
- break;
2194
- if (c === '\\' && P.L.i + 1 < P.L.len) {
2195
- advance(P.L);
2196
- advance(P.L);
2197
- continue;
2198
- }
2199
- if (c === '\n') {
2200
- // Split string_content at newline
2201
- flushContent();
2202
- advance(P.L);
2203
- contentStart = P.L.b;
2204
- contentStartI = P.L.i;
2205
- continue;
2206
- }
2207
- if (c === '$') {
2208
- const c1 = peek(P.L, 1);
2209
- if (c1 === '(' ||
2210
- c1 === '{' ||
2211
- isIdentStart(c1) ||
2212
- SPECIAL_VARS.has(c1) ||
2213
- isDigit(c1)) {
2214
- flushContent();
2215
- const exp = parseDollarLike(P);
2216
- if (exp)
2217
- parts.push(exp);
2218
- contentStart = P.L.b;
2219
- contentStartI = P.L.i;
2220
- continue;
2221
- }
2222
- // Bare $ not at end-of-string: tree-sitter emits it as an anonymous
2223
- // '$' token, which splits string_content. $ immediately before the
2224
- // closing " is absorbed into the preceding string_content.
2225
- if (c1 !== '"' && c1 !== '') {
2226
- flushContent();
2227
- const dS = P.L.b;
2228
- advance(P.L);
2229
- parts.push(mk(P, '$', dS, P.L.b, []));
2230
- contentStart = P.L.b;
2231
- contentStartI = P.L.i;
2232
- continue;
2233
- }
2234
- }
2235
- if (c === '`') {
2236
- flushContent();
2237
- const bt = parseBacktick(P);
2238
- if (bt)
2239
- parts.push(bt);
2240
- contentStart = P.L.b;
2241
- contentStartI = P.L.i;
2242
- continue;
2243
- }
2244
- advance(P.L);
2245
- }
2246
- flushContent();
2247
- let close;
2248
- if (peek(P.L) === '"') {
2249
- const cStart = P.L.b;
2250
- advance(P.L);
2251
- close = mk(P, '"', cStart, P.L.b, []);
2252
- }
2253
- else {
2254
- close = mk(P, '"', P.L.b, P.L.b, []);
2255
- }
2256
- parts.push(close);
2257
- return mk(P, 'string', qStart, close.endIndex, parts);
2258
- }
2259
- function parseDollarLike(P) {
2260
- const c1 = peek(P.L, 1);
2261
- const dStart = P.L.b;
2262
- if (c1 === '(' && peek(P.L, 2) === '(') {
2263
- // $(( arithmetic ))
2264
- advance(P.L);
2265
- advance(P.L);
2266
- advance(P.L);
2267
- const open = mk(P, '$((', dStart, P.L.b, []);
2268
- const exprs = parseArithCommaList(P, '))', 'var');
2269
- skipBlanks(P.L);
2270
- let close;
2271
- if (peek(P.L) === ')' && peek(P.L, 1) === ')') {
2272
- const cStart = P.L.b;
2273
- advance(P.L);
2274
- advance(P.L);
2275
- close = mk(P, '))', cStart, P.L.b, []);
2276
- }
2277
- else {
2278
- close = mk(P, '))', P.L.b, P.L.b, []);
2279
- }
2280
- return mk(P, 'arithmetic_expansion', dStart, close.endIndex, [
2281
- open,
2282
- ...exprs,
2283
- close,
2284
- ]);
2285
- }
2286
- if (c1 === '[') {
2287
- // $[ arithmetic ] — legacy bash syntax, same as $((...))
2288
- advance(P.L);
2289
- advance(P.L);
2290
- const open = mk(P, '$[', dStart, P.L.b, []);
2291
- const exprs = parseArithCommaList(P, ']', 'var');
2292
- skipBlanks(P.L);
2293
- let close;
2294
- if (peek(P.L) === ']') {
2295
- const cStart = P.L.b;
2296
- advance(P.L);
2297
- close = mk(P, ']', cStart, P.L.b, []);
2298
- }
2299
- else {
2300
- close = mk(P, ']', P.L.b, P.L.b, []);
2301
- }
2302
- return mk(P, 'arithmetic_expansion', dStart, close.endIndex, [
2303
- open,
2304
- ...exprs,
2305
- close,
2306
- ]);
2307
- }
2308
- if (c1 === '(') {
2309
- advance(P.L);
2310
- advance(P.L);
2311
- const open = mk(P, '$(', dStart, P.L.b, []);
2312
- let body = parseStatements(P, ')');
2313
- skipBlanks(P.L);
2314
- let close;
2315
- if (peek(P.L) === ')') {
2316
- const cStart = P.L.b;
2317
- advance(P.L);
2318
- close = mk(P, ')', cStart, P.L.b, []);
2319
- }
2320
- else {
2321
- close = mk(P, ')', P.L.b, P.L.b, []);
2322
- }
2323
- // $(< file) shorthand: unwrap redirected_statement → bare file_redirect
2324
- // tree-sitter emits (command_substitution (file_redirect (word))) directly
2325
- if (body.length === 1 &&
2326
- body[0].type === 'redirected_statement' &&
2327
- body[0].children.length === 1 &&
2328
- body[0].children[0].type === 'file_redirect') {
2329
- body = body[0].children;
2330
- }
2331
- return mk(P, 'command_substitution', dStart, close.endIndex, [
2332
- open,
2333
- ...body,
2334
- close,
2335
- ]);
2336
- }
2337
- if (c1 === '{') {
2338
- advance(P.L);
2339
- advance(P.L);
2340
- const open = mk(P, '${', dStart, P.L.b, []);
2341
- const inner = parseExpansionBody(P);
2342
- let close;
2343
- if (peek(P.L) === '}') {
2344
- const cStart = P.L.b;
2345
- advance(P.L);
2346
- close = mk(P, '}', cStart, P.L.b, []);
2347
- }
2348
- else {
2349
- close = mk(P, '}', P.L.b, P.L.b, []);
2350
- }
2351
- return mk(P, 'expansion', dStart, close.endIndex, [open, ...inner, close]);
2352
- }
2353
- // Simple expansion $VAR or $? $$ $@ etc
2354
- advance(P.L);
2355
- const dEnd = P.L.b;
2356
- const dollar = mk(P, '$', dStart, dEnd, []);
2357
- const nc = peek(P.L);
2358
- // $_ is special_variable_name only when not followed by more ident chars
2359
- if (nc === '_' && !isIdentChar(peek(P.L, 1))) {
2360
- const vStart = P.L.b;
2361
- advance(P.L);
2362
- const vn = mk(P, 'special_variable_name', vStart, P.L.b, []);
2363
- return mk(P, 'simple_expansion', dStart, P.L.b, [dollar, vn]);
2364
- }
2365
- if (isIdentStart(nc)) {
2366
- const vStart = P.L.b;
2367
- while (isIdentChar(peek(P.L)))
2368
- advance(P.L);
2369
- const vn = mk(P, 'variable_name', vStart, P.L.b, []);
2370
- return mk(P, 'simple_expansion', dStart, P.L.b, [dollar, vn]);
2371
- }
2372
- if (isDigit(nc)) {
2373
- const vStart = P.L.b;
2374
- advance(P.L);
2375
- const vn = mk(P, 'variable_name', vStart, P.L.b, []);
2376
- return mk(P, 'simple_expansion', dStart, P.L.b, [dollar, vn]);
2377
- }
2378
- if (SPECIAL_VARS.has(nc)) {
2379
- const vStart = P.L.b;
2380
- advance(P.L);
2381
- const vn = mk(P, 'special_variable_name', vStart, P.L.b, []);
2382
- return mk(P, 'simple_expansion', dStart, P.L.b, [dollar, vn]);
2383
- }
2384
- // Bare $ — just a $ leaf (tree-sitter treats trailing $ as literal)
2385
- return dollar;
2386
- }
2387
- function parseExpansionBody(P) {
2388
- const out = [];
2389
- skipBlanks(P.L);
2390
- // Bizarre cases: ${#!} ${!#} ${!##} ${!# } ${!## } all emit empty (expansion)
2391
- // — both # and ! become anonymous nodes when only combined with each other
2392
- // and optional trailing space before }. Note ${!##/} does NOT match (has
2393
- // content after), so it parses normally as (special_variable_name)(regex).
2394
- {
2395
- const c0 = peek(P.L);
2396
- const c1 = peek(P.L, 1);
2397
- if (c0 === '#' && c1 === '!' && peek(P.L, 2) === '}') {
2398
- advance(P.L);
2399
- advance(P.L);
2400
- return out;
2401
- }
2402
- if (c0 === '!' && c1 === '#') {
2403
- // ${!#} ${!##} with optional trailing space then }
2404
- let j = 2;
2405
- if (peek(P.L, j) === '#')
2406
- j++;
2407
- if (peek(P.L, j) === ' ')
2408
- j++;
2409
- if (peek(P.L, j) === '}') {
2410
- while (j-- > 0)
2411
- advance(P.L);
2412
- return out;
2413
- }
2414
- }
2415
- }
2416
- // Optional # prefix for length
2417
- if (peek(P.L) === '#') {
2418
- const s = P.L.b;
2419
- advance(P.L);
2420
- out.push(mk(P, '#', s, P.L.b, []));
2421
- }
2422
- // Optional ! prefix for indirect expansion: ${!varname} ${!prefix*} ${!prefix@}
2423
- // Only when followed by an identifier — ${!} alone is special var $!
2424
- // Also = ~ prefixes (zsh-style ${=var} ${~var})
2425
- const pc = peek(P.L);
2426
- if ((pc === '!' || pc === '=' || pc === '~') &&
2427
- (isIdentStart(peek(P.L, 1)) || isDigit(peek(P.L, 1)))) {
2428
- const s = P.L.b;
2429
- advance(P.L);
2430
- out.push(mk(P, pc, s, P.L.b, []));
2431
- }
2432
- skipBlanks(P.L);
2433
- // Variable name
2434
- if (isIdentStart(peek(P.L))) {
2435
- const s = P.L.b;
2436
- while (isIdentChar(peek(P.L)))
2437
- advance(P.L);
2438
- out.push(mk(P, 'variable_name', s, P.L.b, []));
2439
- }
2440
- else if (isDigit(peek(P.L))) {
2441
- const s = P.L.b;
2442
- while (isDigit(peek(P.L)))
2443
- advance(P.L);
2444
- out.push(mk(P, 'variable_name', s, P.L.b, []));
2445
- }
2446
- else if (SPECIAL_VARS.has(peek(P.L))) {
2447
- const s = P.L.b;
2448
- advance(P.L);
2449
- out.push(mk(P, 'special_variable_name', s, P.L.b, []));
2450
- }
2451
- // Optional subscript [idx] — parsed arithmetically
2452
- if (peek(P.L) === '[') {
2453
- const varNode = out[out.length - 1];
2454
- const brOpen = P.L.b;
2455
- advance(P.L);
2456
- const brOpenNode = mk(P, '[', brOpen, P.L.b, []);
2457
- const idx = parseSubscriptIndexInline(P);
2458
- skipBlanks(P.L);
2459
- const brClose = P.L.b;
2460
- if (peek(P.L) === ']')
2461
- advance(P.L);
2462
- const brCloseNode = mk(P, ']', brClose, P.L.b, []);
2463
- if (varNode) {
2464
- const kids = idx
2465
- ? [varNode, brOpenNode, idx, brCloseNode]
2466
- : [varNode, brOpenNode, brCloseNode];
2467
- out[out.length - 1] = mk(P, 'subscript', varNode.startIndex, P.L.b, kids);
2468
- }
2469
- }
2470
- skipBlanks(P.L);
2471
- // Trailing * or @ for indirect expansion (${!prefix*} ${!prefix@}) or
2472
- // @operator for parameter transformation (${var@U} ${var@Q}) — anonymous
2473
- const tc = peek(P.L);
2474
- if ((tc === '*' || tc === '@') && peek(P.L, 1) === '}') {
2475
- const s = P.L.b;
2476
- advance(P.L);
2477
- out.push(mk(P, tc, s, P.L.b, []));
2478
- return out;
2479
- }
2480
- if (tc === '@' && isIdentStart(peek(P.L, 1))) {
2481
- // ${var@U} transformation — @ is anonymous, consume op char(s)
2482
- const s = P.L.b;
2483
- advance(P.L);
2484
- out.push(mk(P, '@', s, P.L.b, []));
2485
- while (isIdentChar(peek(P.L)))
2486
- advance(P.L);
2487
- return out;
2488
- }
2489
- // Operator :- := :? :+ - = ? + # ## % %% / // ^ ^^ , ,, etc.
2490
- const c = peek(P.L);
2491
- // Bare `:` substring operator ${var:off:len} — offset and length parsed
2492
- // arithmetically. Must come BEFORE the generic operator handling so `(` after
2493
- // `:` goes to parenthesized_expression not the array path. `:-` `:=` `:?`
2494
- // `:+` (no space) remain default-value operators; `: -1` (with space before
2495
- // -1) is substring with negative offset.
2496
- if (c === ':') {
2497
- const c1 = peek(P.L, 1);
2498
- // `:\n` or `:}` — empty substring expansion, emits nothing (variable_name only)
2499
- if (c1 === '\n' || c1 === '}') {
2500
- advance(P.L);
2501
- while (peek(P.L) === '\n')
2502
- advance(P.L);
2503
- return out;
2504
- }
2505
- if (c1 !== '-' && c1 !== '=' && c1 !== '?' && c1 !== '+') {
2506
- advance(P.L);
2507
- skipBlanks(P.L);
2508
- // Offset — arithmetic. `-N` at top level is a single number node per
2509
- // tree-sitter; inside parens it's unary_expression(number).
2510
- const offC = peek(P.L);
2511
- let off;
2512
- if (offC === '-' && isDigit(peek(P.L, 1))) {
2513
- const ns = P.L.b;
2514
- advance(P.L);
2515
- while (isDigit(peek(P.L)))
2516
- advance(P.L);
2517
- off = mk(P, 'number', ns, P.L.b, []);
2518
- }
2519
- else {
2520
- off = parseArithExpr(P, ':}', 'var');
2521
- }
2522
- if (off)
2523
- out.push(off);
2524
- skipBlanks(P.L);
2525
- if (peek(P.L) === ':') {
2526
- advance(P.L);
2527
- skipBlanks(P.L);
2528
- const lenC = peek(P.L);
2529
- let len;
2530
- if (lenC === '-' && isDigit(peek(P.L, 1))) {
2531
- const ns = P.L.b;
2532
- advance(P.L);
2533
- while (isDigit(peek(P.L)))
2534
- advance(P.L);
2535
- len = mk(P, 'number', ns, P.L.b, []);
2536
- }
2537
- else {
2538
- len = parseArithExpr(P, '}', 'var');
2539
- }
2540
- if (len)
2541
- out.push(len);
2542
- }
2543
- return out;
2544
- }
2545
- }
2546
- if (c === ':' ||
2547
- c === '#' ||
2548
- c === '%' ||
2549
- c === '/' ||
2550
- c === '^' ||
2551
- c === ',' ||
2552
- c === '-' ||
2553
- c === '=' ||
2554
- c === '?' ||
2555
- c === '+') {
2556
- const s = P.L.b;
2557
- const c1 = peek(P.L, 1);
2558
- let op = c;
2559
- if (c === ':' && (c1 === '-' || c1 === '=' || c1 === '?' || c1 === '+')) {
2560
- advance(P.L);
2561
- advance(P.L);
2562
- op = c + c1;
2563
- }
2564
- else if ((c === '#' || c === '%' || c === '/' || c === '^' || c === ',') &&
2565
- c1 === c) {
2566
- // Doubled operators: ## %% // ^^ ,,
2567
- advance(P.L);
2568
- advance(P.L);
2569
- op = c + c;
2570
- }
2571
- else {
2572
- advance(P.L);
2573
- }
2574
- out.push(mk(P, op, s, P.L.b, []));
2575
- // Rest is the default/replacement — parse as word or regex until }
2576
- // Pattern-matching operators (# ## % %% / // ^ ^^ , ,,) emit regex;
2577
- // value-substitution operators (:- := :? :+ - = ? + :) emit word.
2578
- // `/` and `//` split at next `/` into (regex)+(word) for pat/repl.
2579
- const isPattern = op === '#' ||
2580
- op === '##' ||
2581
- op === '%' ||
2582
- op === '%%' ||
2583
- op === '/' ||
2584
- op === '//' ||
2585
- op === '^' ||
2586
- op === '^^' ||
2587
- op === ',' ||
2588
- op === ',,';
2589
- if (op === '/' || op === '//') {
2590
- // Optional /# or /% anchor prefix — anonymous node
2591
- const ac = peek(P.L);
2592
- if (ac === '#' || ac === '%') {
2593
- const aStart = P.L.b;
2594
- advance(P.L);
2595
- out.push(mk(P, ac, aStart, P.L.b, []));
2596
- }
2597
- // Pattern: per grammar _expansion_regex_replacement, pattern is
2598
- // choice(regex, string, cmd_sub, seq(string, regex)). If it STARTS
2599
- // with ", emit (string) and any trailing chars become (regex).
2600
- // `${v//"${old}"/}` → (string(expansion)); `${v//"${c}"\//}` →
2601
- // (string)(regex).
2602
- if (peek(P.L) === '"') {
2603
- out.push(parseDoubleQuoted(P));
2604
- const tail = parseExpansionRest(P, 'regex', true);
2605
- if (tail)
2606
- out.push(tail);
2607
- }
2608
- else {
2609
- const regex = parseExpansionRest(P, 'regex', true);
2610
- if (regex)
2611
- out.push(regex);
2612
- }
2613
- if (peek(P.L) === '/') {
2614
- const sepStart = P.L.b;
2615
- advance(P.L);
2616
- out.push(mk(P, '/', sepStart, P.L.b, []));
2617
- // Replacement: per grammar, choice includes `seq(cmd_sub, word)`
2618
- // which emits TWO siblings (not concatenation). Also `(` at start
2619
- // of replacement is a regular word char, NOT array — unlike `:-`
2620
- // default-value context. `${v/(/(Gentoo ${x}, }` replacement
2621
- // `(Gentoo ${x}, ` is (concatenation (word)(expansion)(word)).
2622
- const repl = parseExpansionRest(P, 'replword', false);
2623
- if (repl) {
2624
- // seq(cmd_sub, word) special case → siblings. Detected when
2625
- // replacement is a concatenation of exactly 2 parts with first
2626
- // being command_substitution.
2627
- if (repl.type === 'concatenation' &&
2628
- repl.children.length === 2 &&
2629
- repl.children[0].type === 'command_substitution') {
2630
- out.push(repl.children[0]);
2631
- out.push(repl.children[1]);
2632
- }
2633
- else {
2634
- out.push(repl);
2635
- }
2636
- }
2637
- }
2638
- }
2639
- else if (op === '#' || op === '##' || op === '%' || op === '%%') {
2640
- // Pattern-removal: per grammar _expansion_regex, pattern is
2641
- // repeat(choice(regex, string, raw_string, ')')). Each quote/string
2642
- // is a SIBLING, not absorbed into one regex. `${f%'str'*}` →
2643
- // (raw_string)(regex); `${f/'str'*}` (slash) stays single regex.
2644
- for (const p of parseExpansionRegexSegmented(P))
2645
- out.push(p);
2646
- }
2647
- else {
2648
- const rest = parseExpansionRest(P, isPattern ? 'regex' : 'word', false);
2649
- if (rest)
2650
- out.push(rest);
2651
- }
2652
- }
2653
- return out;
2654
- }
2655
- function parseExpansionRest(P, nodeType, stopAtSlash) {
2656
- // Don't skipBlanks — `${var:- }` space IS the word. Stop at } or newline
2657
- // (`${var:\n}` emits no word). stopAtSlash=true stops at `/` for pat/repl
2658
- // split in ${var/pat/repl}. nodeType 'replword' is word-mode for the
2659
- // replacement in `/` `//` — same as 'word' but `(` is NOT array.
2660
- const start = P.L.b;
2661
- // Value-substitution RHS starting with `(` parses as array: ${var:-(x)} →
2662
- // (expansion (variable_name) (array (word))). Only for 'word' context (not
2663
- // pattern-matching operators which emit regex, and not 'replword' where `(`
2664
- // is a regular char per grammar `_expansion_regex_replacement`).
2665
- if (nodeType === 'word' && peek(P.L) === '(') {
2666
- advance(P.L);
2667
- const open = mk(P, '(', start, P.L.b, []);
2668
- const elems = [open];
2669
- while (P.L.i < P.L.len) {
2670
- skipBlanks(P.L);
2671
- const c = peek(P.L);
2672
- if (c === ')' || c === '}' || c === '\n' || c === '')
2673
- break;
2674
- const wStart = P.L.b;
2675
- while (P.L.i < P.L.len) {
2676
- const wc = peek(P.L);
2677
- if (wc === ')' ||
2678
- wc === '}' ||
2679
- wc === ' ' ||
2680
- wc === '\t' ||
2681
- wc === '\n' ||
2682
- wc === '') {
2683
- break;
2684
- }
2685
- advance(P.L);
2686
- }
2687
- if (P.L.b > wStart)
2688
- elems.push(mk(P, 'word', wStart, P.L.b, []));
2689
- else
2690
- break;
2691
- }
2692
- if (peek(P.L) === ')') {
2693
- const cStart = P.L.b;
2694
- advance(P.L);
2695
- elems.push(mk(P, ')', cStart, P.L.b, []));
2696
- }
2697
- while (peek(P.L) === '\n')
2698
- advance(P.L);
2699
- return mk(P, 'array', start, P.L.b, elems);
2700
- }
2701
- // REGEX mode: flat single-span scan. Quotes are opaque (skipped past so
2702
- // `/` inside them doesn't break stopAtSlash), but NOT emitted as separate
2703
- // nodes — the entire range becomes one regex node.
2704
- if (nodeType === 'regex') {
2705
- let braceDepth = 0;
2706
- while (P.L.i < P.L.len) {
2707
- const c = peek(P.L);
2708
- if (c === '\n')
2709
- break;
2710
- if (braceDepth === 0) {
2711
- if (c === '}')
2712
- break;
2713
- if (stopAtSlash && c === '/')
2714
- break;
2715
- }
2716
- if (c === '\\' && P.L.i + 1 < P.L.len) {
2717
- advance(P.L);
2718
- advance(P.L);
2719
- continue;
2720
- }
2721
- if (c === '"' || c === "'") {
2722
- advance(P.L);
2723
- while (P.L.i < P.L.len && peek(P.L) !== c) {
2724
- if (peek(P.L) === '\\' && P.L.i + 1 < P.L.len)
2725
- advance(P.L);
2726
- advance(P.L);
2727
- }
2728
- if (peek(P.L) === c)
2729
- advance(P.L);
2730
- continue;
2731
- }
2732
- // Skip past nested ${...} $(...) $[...] so their } / don't terminate us
2733
- if (c === '$') {
2734
- const c1 = peek(P.L, 1);
2735
- if (c1 === '{') {
2736
- let d = 0;
2737
- advance(P.L);
2738
- advance(P.L);
2739
- d++;
2740
- while (P.L.i < P.L.len && d > 0) {
2741
- const nc = peek(P.L);
2742
- if (nc === '{')
2743
- d++;
2744
- else if (nc === '}')
2745
- d--;
2746
- advance(P.L);
2747
- }
2748
- continue;
2749
- }
2750
- if (c1 === '(') {
2751
- let d = 0;
2752
- advance(P.L);
2753
- advance(P.L);
2754
- d++;
2755
- while (P.L.i < P.L.len && d > 0) {
2756
- const nc = peek(P.L);
2757
- if (nc === '(')
2758
- d++;
2759
- else if (nc === ')')
2760
- d--;
2761
- advance(P.L);
2762
- }
2763
- continue;
2764
- }
2765
- }
2766
- if (c === '{')
2767
- braceDepth++;
2768
- else if (c === '}' && braceDepth > 0)
2769
- braceDepth--;
2770
- advance(P.L);
2771
- }
2772
- const end = P.L.b;
2773
- while (peek(P.L) === '\n')
2774
- advance(P.L);
2775
- if (end === start)
2776
- return null;
2777
- return mk(P, 'regex', start, end, []);
2778
- }
2779
- // WORD mode: segmenting parser — recognize nested ${...}, $(...), $'...',
2780
- // "...", '...', $ident, <(...)/>(...); bare chars accumulate into word
2781
- // segments. Multiple parts → wrapped in concatenation.
2782
- const parts = [];
2783
- let segStart = P.L.b;
2784
- let braceDepth = 0;
2785
- const flushSeg = () => {
2786
- if (P.L.b > segStart) {
2787
- parts.push(mk(P, 'word', segStart, P.L.b, []));
2788
- }
2789
- };
2790
- while (P.L.i < P.L.len) {
2791
- const c = peek(P.L);
2792
- if (c === '\n')
2793
- break;
2794
- if (braceDepth === 0) {
2795
- if (c === '}')
2796
- break;
2797
- if (stopAtSlash && c === '/')
2798
- break;
2799
- }
2800
- if (c === '\\' && P.L.i + 1 < P.L.len) {
2801
- advance(P.L);
2802
- advance(P.L);
2803
- continue;
2804
- }
2805
- const c1 = peek(P.L, 1);
2806
- if (c === '$') {
2807
- if (c1 === '{' || c1 === '(' || c1 === '[') {
2808
- flushSeg();
2809
- const exp = parseDollarLike(P);
2810
- if (exp)
2811
- parts.push(exp);
2812
- segStart = P.L.b;
2813
- continue;
2814
- }
2815
- if (c1 === "'") {
2816
- // $'...' ANSI-C string
2817
- flushSeg();
2818
- const aStart = P.L.b;
2819
- advance(P.L);
2820
- advance(P.L);
2821
- while (P.L.i < P.L.len && peek(P.L) !== "'") {
2822
- if (peek(P.L) === '\\' && P.L.i + 1 < P.L.len)
2823
- advance(P.L);
2824
- advance(P.L);
2825
- }
2826
- if (peek(P.L) === "'")
2827
- advance(P.L);
2828
- parts.push(mk(P, 'ansi_c_string', aStart, P.L.b, []));
2829
- segStart = P.L.b;
2830
- continue;
2831
- }
2832
- if (isIdentStart(c1) || isDigit(c1) || SPECIAL_VARS.has(c1)) {
2833
- flushSeg();
2834
- const exp = parseDollarLike(P);
2835
- if (exp)
2836
- parts.push(exp);
2837
- segStart = P.L.b;
2838
- continue;
2839
- }
2840
- }
2841
- if (c === '"') {
2842
- flushSeg();
2843
- parts.push(parseDoubleQuoted(P));
2844
- segStart = P.L.b;
2845
- continue;
2846
- }
2847
- if (c === "'") {
2848
- flushSeg();
2849
- const rStart = P.L.b;
2850
- advance(P.L);
2851
- while (P.L.i < P.L.len && peek(P.L) !== "'")
2852
- advance(P.L);
2853
- if (peek(P.L) === "'")
2854
- advance(P.L);
2855
- parts.push(mk(P, 'raw_string', rStart, P.L.b, []));
2856
- segStart = P.L.b;
2857
- continue;
2858
- }
2859
- if ((c === '<' || c === '>') && c1 === '(') {
2860
- flushSeg();
2861
- const ps = parseProcessSub(P);
2862
- if (ps)
2863
- parts.push(ps);
2864
- segStart = P.L.b;
2865
- continue;
2866
- }
2867
- if (c === '`') {
2868
- flushSeg();
2869
- const bt = parseBacktick(P);
2870
- if (bt)
2871
- parts.push(bt);
2872
- segStart = P.L.b;
2873
- continue;
2874
- }
2875
- // Brace tracking so nested {a,b} brace-expansion chars don't prematurely
2876
- // terminate (rare, but the `?` in `${cond}? (` should be treated as word).
2877
- if (c === '{')
2878
- braceDepth++;
2879
- else if (c === '}' && braceDepth > 0)
2880
- braceDepth--;
2881
- advance(P.L);
2882
- }
2883
- flushSeg();
2884
- // Consume trailing newlines before } so caller sees }
2885
- while (peek(P.L) === '\n')
2886
- advance(P.L);
2887
- // Tree-sitter skips leading whitespace (extras) in expansion RHS when
2888
- // there's content after: `${2+ ${2}}` → just (expansion). But `${v:- }`
2889
- // (space-only RHS) keeps the space as (word). So drop leading whitespace-
2890
- // only word segment if it's NOT the only part.
2891
- if (parts.length > 1 &&
2892
- parts[0].type === 'word' &&
2893
- /^[ \t]+$/.test(parts[0].text)) {
2894
- parts.shift();
2895
- }
2896
- if (parts.length === 0)
2897
- return null;
2898
- if (parts.length === 1)
2899
- return parts[0];
2900
- // Multiple parts: wrap in concatenation (word mode keeps concat wrapping;
2901
- // regex mode also concats per tree-sitter for mixed quote+glob patterns).
2902
- const last = parts[parts.length - 1];
2903
- return mk(P, 'concatenation', parts[0].startIndex, last.endIndex, parts);
2904
- }
2905
- // Pattern for # ## % %% operators — per grammar _expansion_regex:
2906
- // repeat(choice(regex, string, raw_string, ')', /\s+/→regex)). Each quote
2907
- // becomes a SIBLING node, not absorbed. `${f%'str'*}` → (raw_string)(regex).
2908
- function parseExpansionRegexSegmented(P) {
2909
- const out = [];
2910
- let segStart = P.L.b;
2911
- const flushRegex = () => {
2912
- if (P.L.b > segStart)
2913
- out.push(mk(P, 'regex', segStart, P.L.b, []));
2914
- };
2915
- while (P.L.i < P.L.len) {
2916
- const c = peek(P.L);
2917
- if (c === '}' || c === '\n')
2918
- break;
2919
- if (c === '\\' && P.L.i + 1 < P.L.len) {
2920
- advance(P.L);
2921
- advance(P.L);
2922
- continue;
2923
- }
2924
- if (c === '"') {
2925
- flushRegex();
2926
- out.push(parseDoubleQuoted(P));
2927
- segStart = P.L.b;
2928
- continue;
2929
- }
2930
- if (c === "'") {
2931
- flushRegex();
2932
- const rStart = P.L.b;
2933
- advance(P.L);
2934
- while (P.L.i < P.L.len && peek(P.L) !== "'")
2935
- advance(P.L);
2936
- if (peek(P.L) === "'")
2937
- advance(P.L);
2938
- out.push(mk(P, 'raw_string', rStart, P.L.b, []));
2939
- segStart = P.L.b;
2940
- continue;
2941
- }
2942
- // Nested ${...} $(...) — opaque scan so their } doesn't terminate us
2943
- if (c === '$') {
2944
- const c1 = peek(P.L, 1);
2945
- if (c1 === '{') {
2946
- let d = 1;
2947
- advance(P.L);
2948
- advance(P.L);
2949
- while (P.L.i < P.L.len && d > 0) {
2950
- const nc = peek(P.L);
2951
- if (nc === '{')
2952
- d++;
2953
- else if (nc === '}')
2954
- d--;
2955
- advance(P.L);
2956
- }
2957
- continue;
2958
- }
2959
- if (c1 === '(') {
2960
- let d = 1;
2961
- advance(P.L);
2962
- advance(P.L);
2963
- while (P.L.i < P.L.len && d > 0) {
2964
- const nc = peek(P.L);
2965
- if (nc === '(')
2966
- d++;
2967
- else if (nc === ')')
2968
- d--;
2969
- advance(P.L);
2970
- }
2971
- continue;
2972
- }
2973
- }
2974
- advance(P.L);
2975
- }
2976
- flushRegex();
2977
- while (peek(P.L) === '\n')
2978
- advance(P.L);
2979
- return out;
2980
- }
2981
- function parseBacktick(P) {
2982
- const start = P.L.b;
2983
- advance(P.L);
2984
- const open = mk(P, '`', start, P.L.b, []);
2985
- P.inBacktick++;
2986
- // Parse statements inline — stop at closing backtick
2987
- const body = [];
2988
- while (true) {
2989
- skipBlanks(P.L);
2990
- if (peek(P.L) === '`' || peek(P.L) === '')
2991
- break;
2992
- const save = saveLex(P.L);
2993
- const t = nextToken(P.L, 'cmd');
2994
- if (t.type === 'EOF' || t.type === 'BACKTICK') {
2995
- restoreLex(P.L, save);
2996
- break;
2997
- }
2998
- if (t.type === 'NEWLINE')
2999
- continue;
3000
- restoreLex(P.L, save);
3001
- const stmt = parseAndOr(P);
3002
- if (!stmt)
3003
- break;
3004
- body.push(stmt);
3005
- skipBlanks(P.L);
3006
- if (peek(P.L) === '`')
3007
- break;
3008
- const save2 = saveLex(P.L);
3009
- const sep = nextToken(P.L, 'cmd');
3010
- if (sep.type === 'OP' && (sep.value === ';' || sep.value === '&')) {
3011
- body.push(leaf(P, sep.value, sep));
3012
- }
3013
- else if (sep.type !== 'NEWLINE') {
3014
- restoreLex(P.L, save2);
3015
- }
3016
- }
3017
- P.inBacktick--;
3018
- let close;
3019
- if (peek(P.L) === '`') {
3020
- const cStart = P.L.b;
3021
- advance(P.L);
3022
- close = mk(P, '`', cStart, P.L.b, []);
3023
- }
3024
- else {
3025
- close = mk(P, '`', P.L.b, P.L.b, []);
3026
- }
3027
- // Empty backticks (whitespace/newline only) are elided entirely by
3028
- // tree-sitter — used as a line-continuation hack: "foo"`<newline>`"bar"
3029
- // → (concatenation (string) (string)) with no command_substitution.
3030
- if (body.length === 0)
3031
- return null;
3032
- return mk(P, 'command_substitution', start, close.endIndex, [
3033
- open,
3034
- ...body,
3035
- close,
3036
- ]);
3037
- }
3038
- function parseIf(P, ifTok) {
3039
- const ifKw = leaf(P, 'if', ifTok);
3040
- const kids = [ifKw];
3041
- const cond = parseStatements(P, null);
3042
- kids.push(...cond);
3043
- consumeKeyword(P, 'then', kids);
3044
- const body = parseStatements(P, null);
3045
- kids.push(...body);
3046
- while (true) {
3047
- const save = saveLex(P.L);
3048
- const t = nextToken(P.L, 'cmd');
3049
- if (t.type === 'WORD' && t.value === 'elif') {
3050
- const eKw = leaf(P, 'elif', t);
3051
- const eCond = parseStatements(P, null);
3052
- const eKids = [eKw, ...eCond];
3053
- consumeKeyword(P, 'then', eKids);
3054
- const eBody = parseStatements(P, null);
3055
- eKids.push(...eBody);
3056
- const last = eKids[eKids.length - 1];
3057
- kids.push(mk(P, 'elif_clause', eKw.startIndex, last.endIndex, eKids));
3058
- }
3059
- else if (t.type === 'WORD' && t.value === 'else') {
3060
- const elKw = leaf(P, 'else', t);
3061
- const elBody = parseStatements(P, null);
3062
- const last = elBody.length > 0 ? elBody[elBody.length - 1] : elKw;
3063
- kids.push(mk(P, 'else_clause', elKw.startIndex, last.endIndex, [elKw, ...elBody]));
3064
- }
3065
- else {
3066
- restoreLex(P.L, save);
3067
- break;
3068
- }
3069
- }
3070
- consumeKeyword(P, 'fi', kids);
3071
- const last = kids[kids.length - 1];
3072
- return mk(P, 'if_statement', ifKw.startIndex, last.endIndex, kids);
3073
- }
3074
- function parseWhile(P, kwTok) {
3075
- const kw = leaf(P, kwTok.value, kwTok);
3076
- const kids = [kw];
3077
- const cond = parseStatements(P, null);
3078
- kids.push(...cond);
3079
- const dg = parseDoGroup(P);
3080
- if (dg)
3081
- kids.push(dg);
3082
- const last = kids[kids.length - 1];
3083
- return mk(P, 'while_statement', kw.startIndex, last.endIndex, kids);
3084
- }
3085
- function parseFor(P, forTok) {
3086
- const forKw = leaf(P, forTok.value, forTok);
3087
- skipBlanks(P.L);
3088
- // C-style for (( ; ; )) — only for `for`, not `select`
3089
- if (forTok.value === 'for' && peek(P.L) === '(' && peek(P.L, 1) === '(') {
3090
- const oStart = P.L.b;
3091
- advance(P.L);
3092
- advance(P.L);
3093
- const open = mk(P, '((', oStart, P.L.b, []);
3094
- const kids = [forKw, open];
3095
- // init; cond; update — all three use 'assign' mode so `c = expr` emits
3096
- // variable_assignment, while bare idents (c in `c<=5`) → word. Each
3097
- // clause may be a comma-separated list.
3098
- for (let k = 0; k < 3; k++) {
3099
- skipBlanks(P.L);
3100
- const es = parseArithCommaList(P, k < 2 ? ';' : '))', 'assign');
3101
- kids.push(...es);
3102
- if (k < 2) {
3103
- if (peek(P.L) === ';') {
3104
- const s = P.L.b;
3105
- advance(P.L);
3106
- kids.push(mk(P, ';', s, P.L.b, []));
3107
- }
3108
- }
3109
- }
3110
- skipBlanks(P.L);
3111
- if (peek(P.L) === ')' && peek(P.L, 1) === ')') {
3112
- const cStart = P.L.b;
3113
- advance(P.L);
3114
- advance(P.L);
3115
- kids.push(mk(P, '))', cStart, P.L.b, []));
3116
- }
3117
- // Optional ; or newline
3118
- const save = saveLex(P.L);
3119
- const sep = nextToken(P.L, 'cmd');
3120
- if (sep.type === 'OP' && sep.value === ';') {
3121
- kids.push(leaf(P, ';', sep));
3122
- }
3123
- else if (sep.type !== 'NEWLINE') {
3124
- restoreLex(P.L, save);
3125
- }
3126
- const dg = parseDoGroup(P);
3127
- if (dg) {
3128
- kids.push(dg);
3129
- }
3130
- else {
3131
- // C-style for can also use `{ ... }` body instead of `do ... done`
3132
- skipNewlines(P);
3133
- skipBlanks(P.L);
3134
- if (peek(P.L) === '{') {
3135
- const bOpen = P.L.b;
3136
- advance(P.L);
3137
- const brace = mk(P, '{', bOpen, P.L.b, []);
3138
- const body = parseStatements(P, '}');
3139
- let bClose;
3140
- if (peek(P.L) === '}') {
3141
- const cs = P.L.b;
3142
- advance(P.L);
3143
- bClose = mk(P, '}', cs, P.L.b, []);
3144
- }
3145
- else {
3146
- bClose = mk(P, '}', P.L.b, P.L.b, []);
3147
- }
3148
- kids.push(mk(P, 'compound_statement', brace.startIndex, bClose.endIndex, [
3149
- brace,
3150
- ...body,
3151
- bClose,
3152
- ]));
3153
- }
3154
- }
3155
- const last = kids[kids.length - 1];
3156
- return mk(P, 'c_style_for_statement', forKw.startIndex, last.endIndex, kids);
3157
- }
3158
- // Regular for VAR in words; do ... done
3159
- const kids = [forKw];
3160
- const varTok = nextToken(P.L, 'arg');
3161
- kids.push(mk(P, 'variable_name', varTok.start, varTok.end, []));
3162
- skipBlanks(P.L);
3163
- const save = saveLex(P.L);
3164
- const inTok = nextToken(P.L, 'arg');
3165
- if (inTok.type === 'WORD' && inTok.value === 'in') {
3166
- kids.push(leaf(P, 'in', inTok));
3167
- while (true) {
3168
- skipBlanks(P.L);
3169
- const c = peek(P.L);
3170
- if (c === ';' || c === '\n' || c === '')
3171
- break;
3172
- const w = parseWord(P, 'arg');
3173
- if (!w)
3174
- break;
3175
- kids.push(w);
3176
- }
3177
- }
3178
- else {
3179
- restoreLex(P.L, save);
3180
- }
3181
- // Separator
3182
- const save2 = saveLex(P.L);
3183
- const sep = nextToken(P.L, 'cmd');
3184
- if (sep.type === 'OP' && sep.value === ';') {
3185
- kids.push(leaf(P, ';', sep));
3186
- }
3187
- else if (sep.type !== 'NEWLINE') {
3188
- restoreLex(P.L, save2);
3189
- }
3190
- const dg = parseDoGroup(P);
3191
- if (dg)
3192
- kids.push(dg);
3193
- const last = kids[kids.length - 1];
3194
- return mk(P, 'for_statement', forKw.startIndex, last.endIndex, kids);
3195
- }
3196
- function parseDoGroup(P) {
3197
- skipNewlines(P);
3198
- const save = saveLex(P.L);
3199
- const doTok = nextToken(P.L, 'cmd');
3200
- if (doTok.type !== 'WORD' || doTok.value !== 'do') {
3201
- restoreLex(P.L, save);
3202
- return null;
3203
- }
3204
- const doKw = leaf(P, 'do', doTok);
3205
- const body = parseStatements(P, null);
3206
- const kids = [doKw, ...body];
3207
- consumeKeyword(P, 'done', kids);
3208
- const last = kids[kids.length - 1];
3209
- return mk(P, 'do_group', doKw.startIndex, last.endIndex, kids);
3210
- }
3211
- function parseCase(P, caseTok) {
3212
- const caseKw = leaf(P, 'case', caseTok);
3213
- const kids = [caseKw];
3214
- skipBlanks(P.L);
3215
- const word = parseWord(P, 'arg');
3216
- if (word)
3217
- kids.push(word);
3218
- skipBlanks(P.L);
3219
- consumeKeyword(P, 'in', kids);
3220
- skipNewlines(P);
3221
- while (true) {
3222
- skipBlanks(P.L);
3223
- skipNewlines(P);
3224
- const save = saveLex(P.L);
3225
- const t = nextToken(P.L, 'arg');
3226
- if (t.type === 'WORD' && t.value === 'esac') {
3227
- kids.push(leaf(P, 'esac', t));
3228
- break;
3229
- }
3230
- if (t.type === 'EOF')
3231
- break;
3232
- restoreLex(P.L, save);
3233
- const item = parseCaseItem(P);
3234
- if (!item)
3235
- break;
3236
- kids.push(item);
3237
- }
3238
- const last = kids[kids.length - 1];
3239
- return mk(P, 'case_statement', caseKw.startIndex, last.endIndex, kids);
3240
- }
3241
- function parseCaseItem(P) {
3242
- skipBlanks(P.L);
3243
- const start = P.L.b;
3244
- const kids = [];
3245
- // Optional leading '(' before pattern — bash allows (pattern) syntax
3246
- if (peek(P.L) === '(') {
3247
- const s = P.L.b;
3248
- advance(P.L);
3249
- kids.push(mk(P, '(', s, P.L.b, []));
3250
- }
3251
- // Pattern(s)
3252
- let isFirstAlt = true;
3253
- while (true) {
3254
- skipBlanks(P.L);
3255
- const c = peek(P.L);
3256
- if (c === ')' || c === '')
3257
- break;
3258
- const pats = parseCasePattern(P);
3259
- if (pats.length === 0)
3260
- break;
3261
- // tree-sitter quirk: first alternative with quotes is inlined as flat
3262
- // siblings; subsequent alternatives are wrapped in (concatenation) with
3263
- // `word` instead of `extglob_pattern` for bare segments.
3264
- if (!isFirstAlt && pats.length > 1) {
3265
- const rewritten = pats.map(p => p.type === 'extglob_pattern'
3266
- ? mk(P, 'word', p.startIndex, p.endIndex, [])
3267
- : p);
3268
- const first = rewritten[0];
3269
- const last = rewritten[rewritten.length - 1];
3270
- kids.push(mk(P, 'concatenation', first.startIndex, last.endIndex, rewritten));
3271
- }
3272
- else {
3273
- kids.push(...pats);
3274
- }
3275
- isFirstAlt = false;
3276
- skipBlanks(P.L);
3277
- // \<newline> line continuation between alternatives
3278
- if (peek(P.L) === '\\' && peek(P.L, 1) === '\n') {
3279
- advance(P.L);
3280
- advance(P.L);
3281
- skipBlanks(P.L);
3282
- }
3283
- if (peek(P.L) === '|') {
3284
- const s = P.L.b;
3285
- advance(P.L);
3286
- kids.push(mk(P, '|', s, P.L.b, []));
3287
- // \<newline> after | is also a line continuation
3288
- if (peek(P.L) === '\\' && peek(P.L, 1) === '\n') {
3289
- advance(P.L);
3290
- advance(P.L);
3291
- }
3292
- }
3293
- else {
3294
- break;
3295
- }
3296
- }
3297
- if (peek(P.L) === ')') {
3298
- const s = P.L.b;
3299
- advance(P.L);
3300
- kids.push(mk(P, ')', s, P.L.b, []));
3301
- }
3302
- const body = parseStatements(P, null);
3303
- kids.push(...body);
3304
- const save = saveLex(P.L);
3305
- const term = nextToken(P.L, 'cmd');
3306
- if (term.type === 'OP' &&
3307
- (term.value === ';;' || term.value === ';&' || term.value === ';;&')) {
3308
- kids.push(leaf(P, term.value, term));
3309
- }
3310
- else {
3311
- restoreLex(P.L, save);
3312
- }
3313
- if (kids.length === 0)
3314
- return null;
3315
- // tree-sitter quirk: case_item with EMPTY body and a single pattern matching
3316
- // extglob-operator-char-prefix (no actual glob metachars) downgrades to word.
3317
- // `-o) owner=$2 ;;` (has body) → extglob_pattern; `-g) ;;` (empty) → word.
3318
- if (body.length === 0) {
3319
- for (let i = 0; i < kids.length; i++) {
3320
- const k = kids[i];
3321
- if (k.type !== 'extglob_pattern')
3322
- continue;
3323
- const text = sliceBytes(P, k.startIndex, k.endIndex);
3324
- if (/^[-+?*@!][a-zA-Z]/.test(text) && !/[*?(]/.test(text)) {
3325
- kids[i] = mk(P, 'word', k.startIndex, k.endIndex, []);
3326
- }
3327
- }
3328
- }
3329
- const last = kids[kids.length - 1];
3330
- return mk(P, 'case_item', start, last.endIndex, kids);
3331
- }
3332
- function parseCasePattern(P) {
3333
- skipBlanks(P.L);
3334
- const save = saveLex(P.L);
3335
- const start = P.L.b;
3336
- const startI = P.L.i;
3337
- let parenDepth = 0;
3338
- let hasDollar = false;
3339
- let hasBracketOutsideParen = false;
3340
- let hasQuote = false;
3341
- while (P.L.i < P.L.len) {
3342
- const c = peek(P.L);
3343
- if (c === '\\' && P.L.i + 1 < P.L.len) {
3344
- // Escaped char — consume both (handles `bar\ baz` as single pattern)
3345
- // \<newline> is a line continuation; eat it but stay in pattern.
3346
- advance(P.L);
3347
- advance(P.L);
3348
- continue;
3349
- }
3350
- if (c === '"' || c === "'") {
3351
- hasQuote = true;
3352
- // Skip past the quoted segment so its content (spaces, |, etc.) doesn't
3353
- // break the peek-ahead scan.
3354
- advance(P.L);
3355
- while (P.L.i < P.L.len && peek(P.L) !== c) {
3356
- if (peek(P.L) === '\\' && P.L.i + 1 < P.L.len)
3357
- advance(P.L);
3358
- advance(P.L);
3359
- }
3360
- if (peek(P.L) === c)
3361
- advance(P.L);
3362
- continue;
3363
- }
3364
- // Paren counting: any ( inside pattern opens a scope; don't break at ) or |
3365
- // until balanced. Handles extglob *(a|b) and nested shapes *([0-9])([0-9]).
3366
- if (c === '(') {
3367
- parenDepth++;
3368
- advance(P.L);
3369
- continue;
3370
- }
3371
- if (parenDepth > 0) {
3372
- if (c === ')') {
3373
- parenDepth--;
3374
- advance(P.L);
3375
- continue;
3376
- }
3377
- if (c === '\n')
3378
- break;
3379
- advance(P.L);
3380
- continue;
3381
- }
3382
- if (c === ')' || c === '|' || c === ' ' || c === '\t' || c === '\n')
3383
- break;
3384
- if (c === '$')
3385
- hasDollar = true;
3386
- if (c === '[')
3387
- hasBracketOutsideParen = true;
3388
- advance(P.L);
3389
- }
3390
- if (P.L.b === start)
3391
- return [];
3392
- const text = P.src.slice(startI, P.L.i);
3393
- const hasExtglobParen = /[*?+@!]\(/.test(text);
3394
- // Quoted segments in pattern: tree-sitter splits at quote boundaries into
3395
- // multiple sibling nodes. `*"foo"*` → (extglob_pattern)(string)(extglob_pattern).
3396
- // Re-scan with a segmenting pass.
3397
- if (hasQuote && !hasExtglobParen) {
3398
- restoreLex(P.L, save);
3399
- return parseCasePatternSegmented(P);
3400
- }
3401
- // tree-sitter splits patterns with [ or $ into concatenation via word parsing
3402
- // UNLESS pattern has extglob parens (those override and emit extglob_pattern).
3403
- // `*.[1357]` → concat(word word number word); `${PN}.pot` → concat(expansion word);
3404
- // but `*([0-9])` → extglob_pattern (has extglob paren).
3405
- if (!hasExtglobParen && (hasDollar || hasBracketOutsideParen)) {
3406
- restoreLex(P.L, save);
3407
- const w = parseWord(P, 'arg');
3408
- return w ? [w] : [];
3409
- }
3410
- // Patterns starting with extglob operator chars (+ - ? * @ !) followed by
3411
- // identifier chars are extglob_pattern per tree-sitter, even without parens
3412
- // or glob metachars. `-o)` → extglob_pattern; plain `foo)` → word.
3413
- const type = hasExtglobParen || /[*?]/.test(text) || /^[-+?*@!][a-zA-Z]/.test(text)
3414
- ? 'extglob_pattern'
3415
- : 'word';
3416
- return [mk(P, type, start, P.L.b, [])];
3417
- }
3418
- // Segmented scan for case patterns containing quotes: `*"foo"*` →
3419
- // [extglob_pattern, string, extglob_pattern]. Bare segments → extglob_pattern
3420
- // if they have */?, else word. Stops at ) | space tab newline outside quotes.
3421
- function parseCasePatternSegmented(P) {
3422
- const parts = [];
3423
- let segStart = P.L.b;
3424
- let segStartI = P.L.i;
3425
- const flushSeg = () => {
3426
- if (P.L.i > segStartI) {
3427
- const t = P.src.slice(segStartI, P.L.i);
3428
- const type = /[*?]/.test(t) ? 'extglob_pattern' : 'word';
3429
- parts.push(mk(P, type, segStart, P.L.b, []));
3430
- }
3431
- };
3432
- while (P.L.i < P.L.len) {
3433
- const c = peek(P.L);
3434
- if (c === '\\' && P.L.i + 1 < P.L.len) {
3435
- advance(P.L);
3436
- advance(P.L);
3437
- continue;
3438
- }
3439
- if (c === '"') {
3440
- flushSeg();
3441
- parts.push(parseDoubleQuoted(P));
3442
- segStart = P.L.b;
3443
- segStartI = P.L.i;
3444
- continue;
3445
- }
3446
- if (c === "'") {
3447
- flushSeg();
3448
- const tok = nextToken(P.L, 'arg');
3449
- parts.push(leaf(P, 'raw_string', tok));
3450
- segStart = P.L.b;
3451
- segStartI = P.L.i;
3452
- continue;
3453
- }
3454
- if (c === ')' || c === '|' || c === ' ' || c === '\t' || c === '\n')
3455
- break;
3456
- advance(P.L);
3457
- }
3458
- flushSeg();
3459
- return parts;
3460
- }
3461
- function parseFunction(P, fnTok) {
3462
- const fnKw = leaf(P, 'function', fnTok);
3463
- skipBlanks(P.L);
3464
- const nameTok = nextToken(P.L, 'arg');
3465
- const name = mk(P, 'word', nameTok.start, nameTok.end, []);
3466
- const kids = [fnKw, name];
3467
- skipBlanks(P.L);
3468
- if (peek(P.L) === '(' && peek(P.L, 1) === ')') {
3469
- const o = nextToken(P.L, 'cmd');
3470
- const c = nextToken(P.L, 'cmd');
3471
- kids.push(leaf(P, '(', o));
3472
- kids.push(leaf(P, ')', c));
3473
- }
3474
- skipBlanks(P.L);
3475
- skipNewlines(P);
3476
- const body = parseCommand(P);
3477
- if (body) {
3478
- // Hoist redirects from redirected_statement(compound_statement, ...) to
3479
- // function_definition level per tree-sitter grammar
3480
- if (body.type === 'redirected_statement' &&
3481
- body.children.length >= 2 &&
3482
- body.children[0].type === 'compound_statement') {
3483
- kids.push(...body.children);
3484
- }
3485
- else {
3486
- kids.push(body);
3487
- }
3488
- }
3489
- const last = kids[kids.length - 1];
3490
- return mk(P, 'function_definition', fnKw.startIndex, last.endIndex, kids);
3491
- }
3492
- function parseDeclaration(P, kwTok) {
3493
- const kw = leaf(P, kwTok.value, kwTok);
3494
- const kids = [kw];
3495
- while (true) {
3496
- skipBlanks(P.L);
3497
- const c = peek(P.L);
3498
- if (c === '' ||
3499
- c === '\n' ||
3500
- c === ';' ||
3501
- c === '&' ||
3502
- c === '|' ||
3503
- c === ')' ||
3504
- c === '<' ||
3505
- c === '>') {
3506
- break;
3507
- }
3508
- const a = tryParseAssignment(P);
3509
- if (a) {
3510
- kids.push(a);
3511
- continue;
3512
- }
3513
- // Quoted string or concatenation: `export "FOO=bar"`, `export 'X'`
3514
- if (c === '"' || c === "'" || c === '$') {
3515
- const w = parseWord(P, 'arg');
3516
- if (w) {
3517
- kids.push(w);
3518
- continue;
3519
- }
3520
- break;
3521
- }
3522
- // Flag like -a or bare variable name
3523
- const save = saveLex(P.L);
3524
- const tok = nextToken(P.L, 'arg');
3525
- if (tok.type === 'WORD' || tok.type === 'NUMBER') {
3526
- if (tok.value.startsWith('-')) {
3527
- kids.push(leaf(P, 'word', tok));
3528
- }
3529
- else if (isIdentStart(tok.value[0] ?? '')) {
3530
- kids.push(mk(P, 'variable_name', tok.start, tok.end, []));
3531
- }
3532
- else {
3533
- kids.push(leaf(P, 'word', tok));
3534
- }
3535
- }
3536
- else {
3537
- restoreLex(P.L, save);
3538
- break;
3539
- }
3540
- }
3541
- const last = kids[kids.length - 1];
3542
- return mk(P, 'declaration_command', kw.startIndex, last.endIndex, kids);
3543
- }
3544
- function parseUnset(P, kwTok) {
3545
- const kw = leaf(P, 'unset', kwTok);
3546
- const kids = [kw];
3547
- while (true) {
3548
- skipBlanks(P.L);
3549
- const c = peek(P.L);
3550
- if (c === '' ||
3551
- c === '\n' ||
3552
- c === ';' ||
3553
- c === '&' ||
3554
- c === '|' ||
3555
- c === ')' ||
3556
- c === '<' ||
3557
- c === '>') {
3558
- break;
3559
- }
3560
- // SECURITY: use parseWord (not raw nextToken) so quoted strings like
3561
- // `unset 'a[$(id)]'` emit a raw_string child that ast.ts can reject.
3562
- // Previously `break` silently dropped non-WORD args — hiding the
3563
- // arithmetic-subscript code-exec vector from the security walker.
3564
- const arg = parseWord(P, 'arg');
3565
- if (!arg)
3566
- break;
3567
- if (arg.type === 'word') {
3568
- if (arg.text.startsWith('-')) {
3569
- kids.push(arg);
3570
- }
3571
- else {
3572
- kids.push(mk(P, 'variable_name', arg.startIndex, arg.endIndex, []));
3573
- }
3574
- }
3575
- else {
3576
- kids.push(arg);
3577
- }
3578
- }
3579
- const last = kids[kids.length - 1];
3580
- return mk(P, 'unset_command', kw.startIndex, last.endIndex, kids);
3581
- }
3582
- function consumeKeyword(P, name, kids) {
3583
- skipNewlines(P);
3584
- const save = saveLex(P.L);
3585
- const t = nextToken(P.L, 'cmd');
3586
- if (t.type === 'WORD' && t.value === name) {
3587
- kids.push(leaf(P, name, t));
3588
- }
3589
- else {
3590
- restoreLex(P.L, save);
3591
- }
3592
- }
3593
- // ───────────────────── Test & Arithmetic Expressions ─────────────────────
3594
- function parseTestExpr(P, closer) {
3595
- return parseTestOr(P, closer);
3596
- }
3597
- function parseTestOr(P, closer) {
3598
- let left = parseTestAnd(P, closer);
3599
- if (!left)
3600
- return null;
3601
- while (true) {
3602
- skipBlanks(P.L);
3603
- const save = saveLex(P.L);
3604
- if (peek(P.L) === '|' && peek(P.L, 1) === '|') {
3605
- const s = P.L.b;
3606
- advance(P.L);
3607
- advance(P.L);
3608
- const op = mk(P, '||', s, P.L.b, []);
3609
- const right = parseTestAnd(P, closer);
3610
- if (!right) {
3611
- restoreLex(P.L, save);
3612
- break;
3613
- }
3614
- left = mk(P, 'binary_expression', left.startIndex, right.endIndex, [
3615
- left,
3616
- op,
3617
- right,
3618
- ]);
3619
- }
3620
- else {
3621
- break;
3622
- }
3623
- }
3624
- return left;
3625
- }
3626
- function parseTestAnd(P, closer) {
3627
- let left = parseTestUnary(P, closer);
3628
- if (!left)
3629
- return null;
3630
- while (true) {
3631
- skipBlanks(P.L);
3632
- if (peek(P.L) === '&' && peek(P.L, 1) === '&') {
3633
- const s = P.L.b;
3634
- advance(P.L);
3635
- advance(P.L);
3636
- const op = mk(P, '&&', s, P.L.b, []);
3637
- const right = parseTestUnary(P, closer);
3638
- if (!right)
3639
- break;
3640
- left = mk(P, 'binary_expression', left.startIndex, right.endIndex, [
3641
- left,
3642
- op,
3643
- right,
3644
- ]);
3645
- }
3646
- else {
3647
- break;
3648
- }
3649
- }
3650
- return left;
3651
- }
3652
- function parseTestUnary(P, closer) {
3653
- skipBlanks(P.L);
3654
- const c = peek(P.L);
3655
- if (c === '(') {
3656
- const s = P.L.b;
3657
- advance(P.L);
3658
- const open = mk(P, '(', s, P.L.b, []);
3659
- const inner = parseTestOr(P, closer);
3660
- skipBlanks(P.L);
3661
- let close;
3662
- if (peek(P.L) === ')') {
3663
- const cs = P.L.b;
3664
- advance(P.L);
3665
- close = mk(P, ')', cs, P.L.b, []);
3666
- }
3667
- else {
3668
- close = mk(P, ')', P.L.b, P.L.b, []);
3669
- }
3670
- const kids = inner ? [open, inner, close] : [open, close];
3671
- return mk(P, 'parenthesized_expression', open.startIndex, close.endIndex, kids);
3672
- }
3673
- return parseTestBinary(P, closer);
3674
- }
3675
- /**
3676
- * Parse `!`-negated or test-operator (`-f`) or parenthesized primary — but NOT
3677
- * a binary comparison. Used as LHS of binary_expression so `! x =~ y` binds
3678
- * `!` to `x` only, not the whole `x =~ y`.
3679
- */
3680
- function parseTestNegatablePrimary(P, closer) {
3681
- skipBlanks(P.L);
3682
- const c = peek(P.L);
3683
- if (c === '!') {
3684
- const s = P.L.b;
3685
- advance(P.L);
3686
- const bang = mk(P, '!', s, P.L.b, []);
3687
- const inner = parseTestNegatablePrimary(P, closer);
3688
- if (!inner)
3689
- return bang;
3690
- return mk(P, 'unary_expression', bang.startIndex, inner.endIndex, [
3691
- bang,
3692
- inner,
3693
- ]);
3694
- }
3695
- if (c === '-' && isIdentStart(peek(P.L, 1))) {
3696
- const s = P.L.b;
3697
- advance(P.L);
3698
- while (isIdentChar(peek(P.L)))
3699
- advance(P.L);
3700
- const op = mk(P, 'test_operator', s, P.L.b, []);
3701
- skipBlanks(P.L);
3702
- const arg = parseTestPrimary(P, closer);
3703
- if (!arg)
3704
- return op;
3705
- return mk(P, 'unary_expression', op.startIndex, arg.endIndex, [op, arg]);
3706
- }
3707
- return parseTestPrimary(P, closer);
3708
- }
3709
- function parseTestBinary(P, closer) {
3710
- skipBlanks(P.L);
3711
- // `!` in test context binds tighter than =~/==.
3712
- // `[[ ! "x" =~ y ]]` → (binary_expression (unary_expression (string)) (regex))
3713
- // `[[ ! -f x ]]` → (unary_expression ! (unary_expression (test_operator) (word)))
3714
- const left = parseTestNegatablePrimary(P, closer);
3715
- if (!left)
3716
- return null;
3717
- skipBlanks(P.L);
3718
- // Binary comparison: == != =~ -eq -lt etc.
3719
- const c = peek(P.L);
3720
- const c1 = peek(P.L, 1);
3721
- let op = null;
3722
- const os = P.L.b;
3723
- if (c === '=' && c1 === '=') {
3724
- advance(P.L);
3725
- advance(P.L);
3726
- op = mk(P, '==', os, P.L.b, []);
3727
- }
3728
- else if (c === '!' && c1 === '=') {
3729
- advance(P.L);
3730
- advance(P.L);
3731
- op = mk(P, '!=', os, P.L.b, []);
3732
- }
3733
- else if (c === '=' && c1 === '~') {
3734
- advance(P.L);
3735
- advance(P.L);
3736
- op = mk(P, '=~', os, P.L.b, []);
3737
- }
3738
- else if (c === '=' && c1 !== '=') {
3739
- advance(P.L);
3740
- op = mk(P, '=', os, P.L.b, []);
3741
- }
3742
- else if (c === '<' && c1 !== '<') {
3743
- advance(P.L);
3744
- op = mk(P, '<', os, P.L.b, []);
3745
- }
3746
- else if (c === '>' && c1 !== '>') {
3747
- advance(P.L);
3748
- op = mk(P, '>', os, P.L.b, []);
3749
- }
3750
- else if (c === '-' && isIdentStart(c1)) {
3751
- advance(P.L);
3752
- while (isIdentChar(peek(P.L)))
3753
- advance(P.L);
3754
- op = mk(P, 'test_operator', os, P.L.b, []);
3755
- }
3756
- if (!op)
3757
- return left;
3758
- skipBlanks(P.L);
3759
- // In [[ ]], RHS of ==/!=/=/=~ gets special pattern parsing: paren counting
3760
- // so @(a|b|c) doesn't break on |, and segments become extglob_pattern/regex.
3761
- if (closer === ']]') {
3762
- const opText = op.type;
3763
- if (opText === '=~') {
3764
- skipBlanks(P.L);
3765
- // If the ENTIRE RHS is a quoted string, emit string/raw_string not
3766
- // regex: `[[ "$x" =~ "$y" ]]` → (binary_expression (string) (string)).
3767
- // If there's content after the quote (`' boop '(.*)$`), the whole RHS
3768
- // stays a single (regex). Peek past the quote to check.
3769
- const rc = peek(P.L);
3770
- let rhs = null;
3771
- if (rc === '"' || rc === "'") {
3772
- const save = saveLex(P.L);
3773
- const quoted = rc === '"'
3774
- ? parseDoubleQuoted(P)
3775
- : leaf(P, 'raw_string', nextToken(P.L, 'arg'));
3776
- // Check if RHS ends here: only whitespace then ]] or &&/|| or newline
3777
- let j = P.L.i;
3778
- while (j < P.L.len && (P.src[j] === ' ' || P.src[j] === '\t'))
3779
- j++;
3780
- const nc = P.src[j] ?? '';
3781
- const nc1 = P.src[j + 1] ?? '';
3782
- if ((nc === ']' && nc1 === ']') ||
3783
- (nc === '&' && nc1 === '&') ||
3784
- (nc === '|' && nc1 === '|') ||
3785
- nc === '\n' ||
3786
- nc === '') {
3787
- rhs = quoted;
3788
- }
3789
- else {
3790
- restoreLex(P.L, save);
3791
- }
3792
- }
3793
- if (!rhs)
3794
- rhs = parseTestRegexRhs(P);
3795
- if (!rhs)
3796
- return left;
3797
- return mk(P, 'binary_expression', left.startIndex, rhs.endIndex, [
3798
- left,
3799
- op,
3800
- rhs,
3801
- ]);
3802
- }
3803
- // Single `=` emits (regex) per tree-sitter; `==` and `!=` emit extglob_pattern
3804
- if (opText === '=') {
3805
- const rhs = parseTestRegexRhs(P);
3806
- if (!rhs)
3807
- return left;
3808
- return mk(P, 'binary_expression', left.startIndex, rhs.endIndex, [
3809
- left,
3810
- op,
3811
- rhs,
3812
- ]);
3813
- }
3814
- if (opText === '==' || opText === '!=') {
3815
- const parts = parseTestExtglobRhs(P);
3816
- if (parts.length === 0)
3817
- return left;
3818
- const last = parts[parts.length - 1];
3819
- return mk(P, 'binary_expression', left.startIndex, last.endIndex, [
3820
- left,
3821
- op,
3822
- ...parts,
3823
- ]);
3824
- }
3825
- }
3826
- const right = parseTestPrimary(P, closer);
3827
- if (!right)
3828
- return left;
3829
- return mk(P, 'binary_expression', left.startIndex, right.endIndex, [
3830
- left,
3831
- op,
3832
- right,
3833
- ]);
3834
- }
3835
- // RHS of =~ in [[ ]] — scan as single (regex) node with paren/bracket counting
3836
- // so | ( ) inside the regex don't break parsing. Stop at ]] or ws+&&/||.
3837
- function parseTestRegexRhs(P) {
3838
- skipBlanks(P.L);
3839
- const start = P.L.b;
3840
- let parenDepth = 0;
3841
- let bracketDepth = 0;
3842
- while (P.L.i < P.L.len) {
3843
- const c = peek(P.L);
3844
- if (c === '\\' && P.L.i + 1 < P.L.len) {
3845
- advance(P.L);
3846
- advance(P.L);
3847
- continue;
3848
- }
3849
- if (c === '\n')
3850
- break;
3851
- if (parenDepth === 0 && bracketDepth === 0) {
3852
- if (c === ']' && peek(P.L, 1) === ']')
3853
- break;
3854
- if (c === ' ' || c === '\t') {
3855
- // Peek past blanks for ]] or &&/||
3856
- let j = P.L.i;
3857
- while (j < P.L.len && (P.L.src[j] === ' ' || P.L.src[j] === '\t'))
3858
- j++;
3859
- const nc = P.L.src[j] ?? '';
3860
- const nc1 = P.L.src[j + 1] ?? '';
3861
- if ((nc === ']' && nc1 === ']') ||
3862
- (nc === '&' && nc1 === '&') ||
3863
- (nc === '|' && nc1 === '|')) {
3864
- break;
3865
- }
3866
- advance(P.L);
3867
- continue;
3868
- }
3869
- }
3870
- if (c === '(')
3871
- parenDepth++;
3872
- else if (c === ')' && parenDepth > 0)
3873
- parenDepth--;
3874
- else if (c === '[')
3875
- bracketDepth++;
3876
- else if (c === ']' && bracketDepth > 0)
3877
- bracketDepth--;
3878
- advance(P.L);
3879
- }
3880
- if (P.L.b === start)
3881
- return null;
3882
- return mk(P, 'regex', start, P.L.b, []);
3883
- }
3884
- // RHS of ==/!=/= in [[ ]] — returns array of parts. Bare text → extglob_pattern
3885
- // (with paren counting for @(a|b)); $(...)/${}/quoted → proper node types.
3886
- // Multiple parts become flat children of binary_expression per tree-sitter.
3887
- function parseTestExtglobRhs(P) {
3888
- skipBlanks(P.L);
3889
- const parts = [];
3890
- let segStart = P.L.b;
3891
- let segStartI = P.L.i;
3892
- let parenDepth = 0;
3893
- const flushSeg = () => {
3894
- if (P.L.i > segStartI) {
3895
- const text = P.src.slice(segStartI, P.L.i);
3896
- // Pure number stays number; everything else is extglob_pattern
3897
- const type = /^\d+$/.test(text) ? 'number' : 'extglob_pattern';
3898
- parts.push(mk(P, type, segStart, P.L.b, []));
3899
- }
3900
- };
3901
- while (P.L.i < P.L.len) {
3902
- const c = peek(P.L);
3903
- if (c === '\\' && P.L.i + 1 < P.L.len) {
3904
- advance(P.L);
3905
- advance(P.L);
3906
- continue;
3907
- }
3908
- if (c === '\n')
3909
- break;
3910
- if (parenDepth === 0) {
3911
- if (c === ']' && peek(P.L, 1) === ']')
3912
- break;
3913
- if (c === ' ' || c === '\t') {
3914
- let j = P.L.i;
3915
- while (j < P.L.len && (P.L.src[j] === ' ' || P.L.src[j] === '\t'))
3916
- j++;
3917
- const nc = P.L.src[j] ?? '';
3918
- const nc1 = P.L.src[j + 1] ?? '';
3919
- if ((nc === ']' && nc1 === ']') ||
3920
- (nc === '&' && nc1 === '&') ||
3921
- (nc === '|' && nc1 === '|')) {
3922
- break;
3923
- }
3924
- advance(P.L);
3925
- continue;
3926
- }
3927
- }
3928
- // $ " ' must be parsed even inside @( ) extglob parens — parseDollarLike
3929
- // consumes matching ) so parenDepth stays consistent.
3930
- if (c === '$') {
3931
- const c1 = peek(P.L, 1);
3932
- if (c1 === '(' ||
3933
- c1 === '{' ||
3934
- isIdentStart(c1) ||
3935
- SPECIAL_VARS.has(c1)) {
3936
- flushSeg();
3937
- const exp = parseDollarLike(P);
3938
- if (exp)
3939
- parts.push(exp);
3940
- segStart = P.L.b;
3941
- segStartI = P.L.i;
3942
- continue;
3943
- }
3944
- }
3945
- if (c === '"') {
3946
- flushSeg();
3947
- parts.push(parseDoubleQuoted(P));
3948
- segStart = P.L.b;
3949
- segStartI = P.L.i;
3950
- continue;
3951
- }
3952
- if (c === "'") {
3953
- flushSeg();
3954
- const tok = nextToken(P.L, 'arg');
3955
- parts.push(leaf(P, 'raw_string', tok));
3956
- segStart = P.L.b;
3957
- segStartI = P.L.i;
3958
- continue;
3959
- }
3960
- if (c === '(')
3961
- parenDepth++;
3962
- else if (c === ')' && parenDepth > 0)
3963
- parenDepth--;
3964
- advance(P.L);
3965
- }
3966
- flushSeg();
3967
- return parts;
3968
- }
3969
- function parseTestPrimary(P, closer) {
3970
- skipBlanks(P.L);
3971
- // Stop at closer
3972
- if (closer === ']' && peek(P.L) === ']')
3973
- return null;
3974
- if (closer === ']]' && peek(P.L) === ']' && peek(P.L, 1) === ']')
3975
- return null;
3976
- return parseWord(P, 'arg');
3977
- }
3978
- /** Operator precedence table (higher = tighter binding). */
3979
- const ARITH_PREC = {
3980
- '=': 2,
3981
- '+=': 2,
3982
- '-=': 2,
3983
- '*=': 2,
3984
- '/=': 2,
3985
- '%=': 2,
3986
- '<<=': 2,
3987
- '>>=': 2,
3988
- '&=': 2,
3989
- '^=': 2,
3990
- '|=': 2,
3991
- '||': 4,
3992
- '&&': 5,
3993
- '|': 6,
3994
- '^': 7,
3995
- '&': 8,
3996
- '==': 9,
3997
- '!=': 9,
3998
- '<': 10,
3999
- '>': 10,
4000
- '<=': 10,
4001
- '>=': 10,
4002
- '<<': 11,
4003
- '>>': 11,
4004
- '+': 12,
4005
- '-': 12,
4006
- '*': 13,
4007
- '/': 13,
4008
- '%': 13,
4009
- '**': 14,
4010
- };
4011
- /** Right-associative operators (assignment and exponent). */
4012
- const ARITH_RIGHT_ASSOC = new Set([
4013
- '=',
4014
- '+=',
4015
- '-=',
4016
- '*=',
4017
- '/=',
4018
- '%=',
4019
- '<<=',
4020
- '>>=',
4021
- '&=',
4022
- '^=',
4023
- '|=',
4024
- '**',
4025
- ]);
4026
- function parseArithExpr(P, stop, mode = 'var') {
4027
- return parseArithTernary(P, stop, mode);
4028
- }
4029
- /** Top-level: comma-separated list. arithmetic_expansion emits multiple children. */
4030
- function parseArithCommaList(P, stop, mode = 'var') {
4031
- const out = [];
4032
- while (true) {
4033
- const e = parseArithTernary(P, stop, mode);
4034
- if (e)
4035
- out.push(e);
4036
- skipBlanks(P.L);
4037
- if (peek(P.L) === ',' && !isArithStop(P, stop)) {
4038
- advance(P.L);
4039
- continue;
4040
- }
4041
- break;
4042
- }
4043
- return out;
4044
- }
4045
- function parseArithTernary(P, stop, mode) {
4046
- const cond = parseArithBinary(P, stop, 0, mode);
4047
- if (!cond)
4048
- return null;
4049
- skipBlanks(P.L);
4050
- if (peek(P.L) === '?') {
4051
- const qs = P.L.b;
4052
- advance(P.L);
4053
- const q = mk(P, '?', qs, P.L.b, []);
4054
- const t = parseArithBinary(P, ':', 0, mode);
4055
- skipBlanks(P.L);
4056
- let colon;
4057
- if (peek(P.L) === ':') {
4058
- const cs = P.L.b;
4059
- advance(P.L);
4060
- colon = mk(P, ':', cs, P.L.b, []);
4061
- }
4062
- else {
4063
- colon = mk(P, ':', P.L.b, P.L.b, []);
4064
- }
4065
- const f = parseArithTernary(P, stop, mode);
4066
- const last = f ?? colon;
4067
- const kids = [cond, q];
4068
- if (t)
4069
- kids.push(t);
4070
- kids.push(colon);
4071
- if (f)
4072
- kids.push(f);
4073
- return mk(P, 'ternary_expression', cond.startIndex, last.endIndex, kids);
4074
- }
4075
- return cond;
4076
- }
4077
- /** Scan next arithmetic binary operator; returns [text, length] or null. */
4078
- function scanArithOp(P) {
4079
- const c = peek(P.L);
4080
- const c1 = peek(P.L, 1);
4081
- const c2 = peek(P.L, 2);
4082
- // 3-char: <<= >>=
4083
- if (c === '<' && c1 === '<' && c2 === '=')
4084
- return ['<<=', 3];
4085
- if (c === '>' && c1 === '>' && c2 === '=')
4086
- return ['>>=', 3];
4087
- // 2-char
4088
- if (c === '*' && c1 === '*')
4089
- return ['**', 2];
4090
- if (c === '<' && c1 === '<')
4091
- return ['<<', 2];
4092
- if (c === '>' && c1 === '>')
4093
- return ['>>', 2];
4094
- if (c === '=' && c1 === '=')
4095
- return ['==', 2];
4096
- if (c === '!' && c1 === '=')
4097
- return ['!=', 2];
4098
- if (c === '<' && c1 === '=')
4099
- return ['<=', 2];
4100
- if (c === '>' && c1 === '=')
4101
- return ['>=', 2];
4102
- if (c === '&' && c1 === '&')
4103
- return ['&&', 2];
4104
- if (c === '|' && c1 === '|')
4105
- return ['||', 2];
4106
- if (c === '+' && c1 === '=')
4107
- return ['+=', 2];
4108
- if (c === '-' && c1 === '=')
4109
- return ['-=', 2];
4110
- if (c === '*' && c1 === '=')
4111
- return ['*=', 2];
4112
- if (c === '/' && c1 === '=')
4113
- return ['/=', 2];
4114
- if (c === '%' && c1 === '=')
4115
- return ['%=', 2];
4116
- if (c === '&' && c1 === '=')
4117
- return ['&=', 2];
4118
- if (c === '^' && c1 === '=')
4119
- return ['^=', 2];
4120
- if (c === '|' && c1 === '=')
4121
- return ['|=', 2];
4122
- // 1-char — but NOT ++ -- (those are pre/postfix)
4123
- if (c === '+' && c1 !== '+')
4124
- return ['+', 1];
4125
- if (c === '-' && c1 !== '-')
4126
- return ['-', 1];
4127
- if (c === '*')
4128
- return ['*', 1];
4129
- if (c === '/')
4130
- return ['/', 1];
4131
- if (c === '%')
4132
- return ['%', 1];
4133
- if (c === '<')
4134
- return ['<', 1];
4135
- if (c === '>')
4136
- return ['>', 1];
4137
- if (c === '&')
4138
- return ['&', 1];
4139
- if (c === '|')
4140
- return ['|', 1];
4141
- if (c === '^')
4142
- return ['^', 1];
4143
- if (c === '=')
4144
- return ['=', 1];
4145
- return null;
4146
- }
4147
- /** Precedence-climbing binary expression parser. */
4148
- function parseArithBinary(P, stop, minPrec, mode) {
4149
- let left = parseArithUnary(P, stop, mode);
4150
- if (!left)
4151
- return null;
4152
- while (true) {
4153
- skipBlanks(P.L);
4154
- if (isArithStop(P, stop))
4155
- break;
4156
- if (peek(P.L) === ',')
4157
- break;
4158
- const opInfo = scanArithOp(P);
4159
- if (!opInfo)
4160
- break;
4161
- const [opText, opLen] = opInfo;
4162
- const prec = ARITH_PREC[opText];
4163
- if (prec === undefined || prec < minPrec)
4164
- break;
4165
- const os = P.L.b;
4166
- for (let k = 0; k < opLen; k++)
4167
- advance(P.L);
4168
- const op = mk(P, opText, os, P.L.b, []);
4169
- const nextMin = ARITH_RIGHT_ASSOC.has(opText) ? prec : prec + 1;
4170
- const right = parseArithBinary(P, stop, nextMin, mode);
4171
- if (!right)
4172
- break;
4173
- left = mk(P, 'binary_expression', left.startIndex, right.endIndex, [
4174
- left,
4175
- op,
4176
- right,
4177
- ]);
4178
- }
4179
- return left;
4180
- }
4181
- function parseArithUnary(P, stop, mode) {
4182
- skipBlanks(P.L);
4183
- if (isArithStop(P, stop))
4184
- return null;
4185
- const c = peek(P.L);
4186
- const c1 = peek(P.L, 1);
4187
- // Prefix ++ --
4188
- if ((c === '+' && c1 === '+') || (c === '-' && c1 === '-')) {
4189
- const s = P.L.b;
4190
- advance(P.L);
4191
- advance(P.L);
4192
- const op = mk(P, c + c1, s, P.L.b, []);
4193
- const inner = parseArithUnary(P, stop, mode);
4194
- if (!inner)
4195
- return op;
4196
- return mk(P, 'unary_expression', op.startIndex, inner.endIndex, [op, inner]);
4197
- }
4198
- if (c === '-' || c === '+' || c === '!' || c === '~') {
4199
- // In 'word'/'assign' mode (c-style for head), `-N` is a single number
4200
- // literal per tree-sitter, not unary_expression. 'var' mode uses unary.
4201
- if (mode !== 'var' && c === '-' && isDigit(c1)) {
4202
- const s = P.L.b;
4203
- advance(P.L);
4204
- while (isDigit(peek(P.L)))
4205
- advance(P.L);
4206
- return mk(P, 'number', s, P.L.b, []);
4207
- }
4208
- const s = P.L.b;
4209
- advance(P.L);
4210
- const op = mk(P, c, s, P.L.b, []);
4211
- const inner = parseArithUnary(P, stop, mode);
4212
- if (!inner)
4213
- return op;
4214
- return mk(P, 'unary_expression', op.startIndex, inner.endIndex, [op, inner]);
4215
- }
4216
- return parseArithPostfix(P, stop, mode);
4217
- }
4218
- function parseArithPostfix(P, stop, mode) {
4219
- const prim = parseArithPrimary(P, stop, mode);
4220
- if (!prim)
4221
- return null;
4222
- const c = peek(P.L);
4223
- const c1 = peek(P.L, 1);
4224
- if ((c === '+' && c1 === '+') || (c === '-' && c1 === '-')) {
4225
- const s = P.L.b;
4226
- advance(P.L);
4227
- advance(P.L);
4228
- const op = mk(P, c + c1, s, P.L.b, []);
4229
- return mk(P, 'postfix_expression', prim.startIndex, op.endIndex, [prim, op]);
4230
- }
4231
- return prim;
4232
- }
4233
- function parseArithPrimary(P, stop, mode) {
4234
- skipBlanks(P.L);
4235
- if (isArithStop(P, stop))
4236
- return null;
4237
- const c = peek(P.L);
4238
- if (c === '(') {
4239
- const s = P.L.b;
4240
- advance(P.L);
4241
- const open = mk(P, '(', s, P.L.b, []);
4242
- // Parenthesized expression may contain comma-separated exprs
4243
- const inners = parseArithCommaList(P, ')', mode);
4244
- skipBlanks(P.L);
4245
- let close;
4246
- if (peek(P.L) === ')') {
4247
- const cs = P.L.b;
4248
- advance(P.L);
4249
- close = mk(P, ')', cs, P.L.b, []);
4250
- }
4251
- else {
4252
- close = mk(P, ')', P.L.b, P.L.b, []);
4253
- }
4254
- return mk(P, 'parenthesized_expression', open.startIndex, close.endIndex, [
4255
- open,
4256
- ...inners,
4257
- close,
4258
- ]);
4259
- }
4260
- if (c === '"') {
4261
- return parseDoubleQuoted(P);
4262
- }
4263
- if (c === '$') {
4264
- return parseDollarLike(P);
4265
- }
4266
- if (isDigit(c)) {
4267
- const s = P.L.b;
4268
- while (isDigit(peek(P.L)))
4269
- advance(P.L);
4270
- // Hex: 0x1f
4271
- if (P.L.b - s === 1 &&
4272
- c === '0' &&
4273
- (peek(P.L) === 'x' || peek(P.L) === 'X')) {
4274
- advance(P.L);
4275
- while (isHexDigit(peek(P.L)))
4276
- advance(P.L);
4277
- }
4278
- // Base notation: BASE#DIGITS e.g. 2#1010, 16#ff
4279
- else if (peek(P.L) === '#') {
4280
- advance(P.L);
4281
- while (isBaseDigit(peek(P.L)))
4282
- advance(P.L);
4283
- }
4284
- return mk(P, 'number', s, P.L.b, []);
4285
- }
4286
- if (isIdentStart(c)) {
4287
- const s = P.L.b;
4288
- while (isIdentChar(peek(P.L)))
4289
- advance(P.L);
4290
- const nc = peek(P.L);
4291
- // Assignment in 'assign' mode (c-style for init): emit variable_assignment
4292
- // so chained `a = b = c = 1` nests correctly. Other modes treat `=` as a
4293
- // binary_expression operator via the precedence table.
4294
- if (mode === 'assign') {
4295
- skipBlanks(P.L);
4296
- const ac = peek(P.L);
4297
- const ac1 = peek(P.L, 1);
4298
- if (ac === '=' && ac1 !== '=') {
4299
- const vn = mk(P, 'variable_name', s, P.L.b, []);
4300
- const es = P.L.b;
4301
- advance(P.L);
4302
- const eq = mk(P, '=', es, P.L.b, []);
4303
- // RHS may itself be another assignment (chained)
4304
- const val = parseArithTernary(P, stop, mode);
4305
- const end = val ? val.endIndex : eq.endIndex;
4306
- const kids = val ? [vn, eq, val] : [vn, eq];
4307
- return mk(P, 'variable_assignment', s, end, kids);
4308
- }
4309
- }
4310
- // Subscript
4311
- if (nc === '[') {
4312
- const vn = mk(P, 'variable_name', s, P.L.b, []);
4313
- const brS = P.L.b;
4314
- advance(P.L);
4315
- const brOpen = mk(P, '[', brS, P.L.b, []);
4316
- const idx = parseArithTernary(P, ']', 'var') ?? parseDollarLike(P);
4317
- skipBlanks(P.L);
4318
- let brClose;
4319
- if (peek(P.L) === ']') {
4320
- const cs = P.L.b;
4321
- advance(P.L);
4322
- brClose = mk(P, ']', cs, P.L.b, []);
4323
- }
4324
- else {
4325
- brClose = mk(P, ']', P.L.b, P.L.b, []);
4326
- }
4327
- const kids = idx ? [vn, brOpen, idx, brClose] : [vn, brOpen, brClose];
4328
- return mk(P, 'subscript', s, brClose.endIndex, kids);
4329
- }
4330
- // Bare identifier: variable_name in 'var' mode, word in 'word'/'assign' mode.
4331
- // 'assign' mode falls through to word when no `=` follows (c-style for
4332
- // cond/update clauses: `c<=5` → binary_expression(word, number)).
4333
- const identType = mode === 'var' ? 'variable_name' : 'word';
4334
- return mk(P, identType, s, P.L.b, []);
4335
- }
4336
- return null;
4337
- }
4338
- function isArithStop(P, stop) {
4339
- const c = peek(P.L);
4340
- if (stop === '))')
4341
- return c === ')' && peek(P.L, 1) === ')';
4342
- if (stop === ')')
4343
- return c === ')';
4344
- if (stop === ';')
4345
- return c === ';';
4346
- if (stop === ':')
4347
- return c === ':';
4348
- if (stop === ']')
4349
- return c === ']';
4350
- if (stop === '}')
4351
- return c === '}';
4352
- if (stop === ':}')
4353
- return c === ':' || c === '}';
4354
- return c === '' || c === '\n';
4355
- }