@iaforged/context-code 1.0.77 → 1.0.79

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 (121) hide show
  1. package/README.md +68 -68
  2. package/cli.js +8515 -8515
  3. package/context-bootstrap.js +27 -27
  4. package/dist/src/bootstrap/state.js +3 -0
  5. package/dist/src/bridge/bridgeMain.js +40 -40
  6. package/dist/src/cli/print.js +12 -12
  7. package/dist/src/commands/agent/agent.js +8 -0
  8. package/dist/src/commands/commit-push-pr.js +55 -55
  9. package/dist/src/commands/createMovedToPluginCommand.js +9 -9
  10. package/dist/src/commands/init-verifiers.js +238 -238
  11. package/dist/src/commands/init.js +216 -216
  12. package/dist/src/commands/install.js +2 -2
  13. package/dist/src/commands/login/login.js +24 -10
  14. package/dist/src/commands/orchestrate/index.js +1 -1
  15. package/dist/src/commands/orchestrate/orchestrate.js +110 -24
  16. package/dist/src/commands/profile/profile.js +15 -1
  17. package/dist/src/commands/provider/index.js +1 -1
  18. package/dist/src/commands/provider/provider.js +34 -1
  19. package/dist/src/commands/review.js +22 -22
  20. package/dist/src/commands/run/index.js +2 -2
  21. package/dist/src/commands/run/run.js +63 -61
  22. package/dist/src/commands/team/index.js +1 -1
  23. package/dist/src/commands/team/team.js +84 -76
  24. package/dist/src/commands/team-auto/teamAuto.js +89 -29
  25. package/dist/src/commands/terminalSetup/terminalSetup.js +24 -24
  26. package/dist/src/commands/usage/index.js +7 -0
  27. package/dist/src/commands/usage/usage.js +5 -0
  28. package/dist/src/commands/workspace/workspace.js +39 -31
  29. package/dist/src/commands.js +0 -2
  30. package/dist/src/components/ConsoleOAuthFlow.js +92 -14
  31. package/dist/src/components/ModelPicker.js +2 -0
  32. package/dist/src/components/agents/generateAgent.js +92 -92
  33. package/dist/src/components/grove/Grove.js +10 -10
  34. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/AskUserQuestionPermissionRequest.js +8 -8
  35. package/dist/src/constants/geminiOAuth.js +13 -0
  36. package/dist/src/constants/github-app.js +134 -134
  37. package/dist/src/constants/prompts.js +123 -123
  38. package/dist/src/coordinator/coordinatorMode.js +252 -252
  39. package/dist/src/hooks/useTypeahead.js +7 -7
  40. package/dist/src/ink/reconciler.js +7 -7
  41. package/dist/src/main.js +5 -5
  42. package/dist/src/memdir/findRelevantMemories.js +6 -6
  43. package/dist/src/services/MagicDocs/prompts.js +56 -56
  44. package/dist/src/services/PromptSuggestion/promptSuggestion.js +29 -29
  45. package/dist/src/services/SessionMemory/prompts.js +66 -66
  46. package/dist/src/services/api/openai.js +584 -21
  47. package/dist/src/services/limits/adapters/ollama.js +3 -3
  48. package/dist/src/services/oauth/geminiCli.js +107 -0
  49. package/dist/src/services/orchestration/execution/AgentTaskExecutor.js +5 -3
  50. package/dist/src/services/orchestration/execution/OrchestrationExecutionRuntime.js +18 -18
  51. package/dist/src/services/orchestration/global/reporting.js +2 -2
  52. package/dist/src/services/toolUseSummary/toolUseSummaryGenerator.js +9 -9
  53. package/dist/src/skills/bundled/batch.js +78 -78
  54. package/dist/src/skills/bundled/claudeApi.js +34 -34
  55. package/dist/src/skills/bundled/claudeInChrome.js +4 -4
  56. package/dist/src/skills/bundled/debug.js +36 -36
  57. package/dist/src/skills/bundled/scheduleRemoteAgents.js +151 -151
  58. package/dist/src/skills/bundled/skillify.js +132 -132
  59. package/dist/src/skills/bundled/stuck.js +53 -53
  60. package/dist/src/skills/bundled/updateConfig.js +418 -418
  61. package/dist/src/tasks/RemoteAgentTask/RemoteAgentTask.js +26 -26
  62. package/dist/src/tools/AgentTool/AgentTool.js +7 -7
  63. package/dist/src/tools/AgentTool/built-in/claudeCodeGuideAgent.js +67 -67
  64. package/dist/src/tools/AgentTool/built-in/exploreAgent.js +32 -32
  65. package/dist/src/tools/AgentTool/built-in/generalPurposeAgent.js +13 -13
  66. package/dist/src/tools/AgentTool/built-in/planAgent.js +49 -49
  67. package/dist/src/tools/AgentTool/built-in/statuslineSetup.js +129 -129
  68. package/dist/src/tools/AgentTool/built-in/verificationAgent.js +119 -119
  69. package/dist/src/tools/AgentTool/prompt.js +131 -131
  70. package/dist/src/tools/AgentTool/runAgent.js +9 -9
  71. package/dist/src/tools/BashTool/BashTool.js +10 -10
  72. package/dist/src/tools/BashTool/prompt.js +94 -94
  73. package/dist/src/tools/ConfigTool/prompt.js +29 -29
  74. package/dist/src/tools/EnterWorktreeTool/prompt.js +27 -27
  75. package/dist/src/tools/FileReadTool/prompt.js +12 -12
  76. package/dist/src/tools/PowerShellTool/prompt.js +82 -82
  77. package/dist/src/tools/RemoteTriggerTool/prompt.js +9 -9
  78. package/dist/src/tools/ScheduleCronTool/prompt.js +37 -37
  79. package/dist/src/tools/TeamCreateTool/prompt.js +110 -110
  80. package/dist/src/tools/TeamDeleteTool/prompt.js +13 -13
  81. package/dist/src/utils/advisor.js +15 -15
  82. package/dist/src/utils/api.js +2 -2
  83. package/dist/src/utils/auth.js +207 -2
  84. package/dist/src/utils/autoUpdater.js +18 -18
  85. package/dist/src/utils/bash/ShellSnapshot.js +86 -86
  86. package/dist/src/utils/bash/commands.js +61 -61
  87. package/dist/src/utils/claudeInChrome/prompt.js +53 -53
  88. package/dist/src/utils/claudeInChrome/setup.js +8 -8
  89. package/dist/src/utils/databaseMcp/server/queries.js +632 -632
  90. package/dist/src/utils/deepLink/registerProtocol.js +35 -35
  91. package/dist/src/utils/deepLink/terminalLauncher.js +12 -12
  92. package/dist/src/utils/hooks/execAgentHook.js +7 -7
  93. package/dist/src/utils/hooks/execPromptHook.js +4 -4
  94. package/dist/src/utils/hooks/skillImprovement.js +36 -36
  95. package/dist/src/utils/logoV2Utils.js +1 -1
  96. package/dist/src/utils/mcp/dateTimeParser.js +9 -9
  97. package/dist/src/utils/messages.js +191 -191
  98. package/dist/src/utils/model/model.js +18 -0
  99. package/dist/src/utils/model/modelOptions.js +51 -1
  100. package/dist/src/utils/model/modelStrings.js +5 -1
  101. package/dist/src/utils/model/modelSupportOverrides.js +3 -0
  102. package/dist/src/utils/model/providerBaseUrls.js +6 -1
  103. package/dist/src/utils/model/providerCatalog.js +64 -28
  104. package/dist/src/utils/model/providerModels.js +88 -17
  105. package/dist/src/utils/model/providerProfiles.js +8 -0
  106. package/dist/src/utils/model/providerProfilesDb.js +578 -393
  107. package/dist/src/utils/model/providerSwitch.js +12 -0
  108. package/dist/src/utils/model/providerWorkspaces.js +2 -0
  109. package/dist/src/utils/model/providers.js +65 -2
  110. package/dist/src/utils/orchestration/store/providerWorkspaceStore.js +3 -1
  111. package/dist/src/utils/orchestration/store/runStore.js +47 -47
  112. package/dist/src/utils/orchestration/store/teamStore.js +61 -61
  113. package/dist/src/utils/powershell/parser.js +253 -253
  114. package/dist/src/utils/sessionTitle.js +12 -12
  115. package/dist/src/utils/sideQuestion.js +17 -17
  116. package/dist/src/utils/status.js +1 -1
  117. package/dist/src/utils/swarm/backends/registry.js +9 -9
  118. package/dist/src/utils/telemetry/instrumentation.js +9 -9
  119. package/dist/src/utils/teleport.js +15 -15
  120. package/dist/src/utils/undercover.js +28 -28
  121. package/package.json +1 -1
@@ -59,259 +59,259 @@ function getParseTimeoutMs() {
59
59
  * elements already in the loop
60
60
  */
61
61
  // exported for testing
62
- export const PARSE_SCRIPT_BODY = `
63
- if (-not $EncodedCommand) {
64
- Write-Output '{"valid":false,"errors":[{"message":"No command provided","errorId":"NoInput"}],"statements":[],"variables":[],"hasStopParsing":false,"originalCommand":""}'
65
- exit 0
66
- }
67
-
68
- $Command = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($EncodedCommand))
69
-
70
- $tokens = $null
71
- $parseErrors = $null
72
- $ast = [System.Management.Automation.Language.Parser]::ParseInput(
73
- $Command,
74
- [ref]$tokens,
75
- [ref]$parseErrors
76
- )
77
-
78
- $allVariables = [System.Collections.ArrayList]::new()
79
-
80
- function Get-RawCommandElements {
81
- param([System.Management.Automation.Language.CommandAst]$CmdAst)
82
- $elems = [System.Collections.ArrayList]::new()
83
- foreach ($ce in $CmdAst.CommandElements) {
84
- $ceData = @{ type = $ce.GetType().Name; text = $ce.Extent.Text }
85
- if ($ce.PSObject.Properties['Value'] -and $null -ne $ce.Value -and $ce.Value -is [string]) {
86
- $ceData.value = $ce.Value
87
- }
88
- if ($ce -is [System.Management.Automation.Language.CommandExpressionAst]) {
89
- $ceData.expressionType = $ce.Expression.GetType().Name
90
- }
91
- $a=$ce.Argument;if($a){$ceData.children=@(@{type=$a.GetType().Name;text=$a.Extent.Text})}
92
- [void]$elems.Add($ceData)
93
- }
94
- return $elems
95
- }
96
-
97
- function Get-RawRedirections {
98
- param($Redirections)
99
- $result = [System.Collections.ArrayList]::new()
100
- foreach ($redir in $Redirections) {
101
- $redirData = @{ type = $redir.GetType().Name }
102
- if ($redir -is [System.Management.Automation.Language.FileRedirectionAst]) {
103
- $redirData.append = [bool]$redir.Append
104
- $redirData.fromStream = $redir.FromStream.ToString()
105
- $redirData.locationText = $redir.Location.Extent.Text
106
- }
107
- [void]$result.Add($redirData)
108
- }
109
- return $result
110
- }
111
-
112
- function Get-SecurityPatterns($A) {
113
- $p = @{}
114
- foreach ($n in $A.FindAll({ param($x)
115
- $x -is [System.Management.Automation.Language.MemberExpressionAst] -or
116
- $x -is [System.Management.Automation.Language.SubExpressionAst] -or
117
- $x -is [System.Management.Automation.Language.ArrayExpressionAst] -or
118
- $x -is [System.Management.Automation.Language.ExpandableStringExpressionAst] -or
119
- $x -is [System.Management.Automation.Language.ScriptBlockExpressionAst] -or
120
- $x -is [System.Management.Automation.Language.ParenExpressionAst]
121
- }, $true)) { switch ($n.GetType().Name) {
122
- 'InvokeMemberExpressionAst' { $p.hasMemberInvocations = $true }
123
- 'MemberExpressionAst' { $p.hasMemberInvocations = $true }
124
- 'SubExpressionAst' { $p.hasSubExpressions = $true }
125
- 'ArrayExpressionAst' { $p.hasSubExpressions = $true }
126
- 'ParenExpressionAst' { $p.hasSubExpressions = $true }
127
- 'ExpandableStringExpressionAst' { $p.hasExpandableStrings = $true }
128
- 'ScriptBlockExpressionAst' { $p.hasScriptBlocks = $true }
129
- }}
130
- if ($p.Count -gt 0) { return $p }
131
- return $null
132
- }
133
-
134
- $varExprs = $ast.FindAll({ param($node) $node -is [System.Management.Automation.Language.VariableExpressionAst] }, $true)
135
- foreach ($v in $varExprs) {
136
- [void]$allVariables.Add(@{
137
- path = $v.VariablePath.ToString()
138
- isSplatted = [bool]$v.Splatted
139
- })
140
- }
141
-
142
- $typeLiterals = [System.Collections.ArrayList]::new()
143
- foreach ($t in $ast.FindAll({ param($n)
144
- $n -is [System.Management.Automation.Language.TypeExpressionAst] -or
145
- $n -is [System.Management.Automation.Language.TypeConstraintAst]
146
- }, $true)) { [void]$typeLiterals.Add($t.TypeName.FullName) }
147
-
148
- $hasStopParsing = $false
149
- $tk = [System.Management.Automation.Language.TokenKind]
150
- foreach ($tok in $tokens) {
151
- if ($tok.Kind -eq $tk::MinusMinus) { $hasStopParsing = $true; break }
152
- if ($tok.Kind -eq $tk::Generic -and ($tok.Text -replace '[\u2013\u2014\u2015]','-') -eq '--%') {
153
- $hasStopParsing = $true; break
154
- }
155
- }
156
-
157
- $statements = [System.Collections.ArrayList]::new()
158
-
159
- function Process-BlockStatements {
160
- param($Block)
161
- if (-not $Block) { return }
162
-
163
- foreach ($stmt in $Block.Statements) {
164
- $statement = @{
165
- type = $stmt.GetType().Name
166
- text = $stmt.Extent.Text
167
- }
168
-
169
- if ($stmt -is [System.Management.Automation.Language.PipelineAst]) {
170
- $elements = [System.Collections.ArrayList]::new()
171
- foreach ($element in $stmt.PipelineElements) {
172
- $elemData = @{
173
- type = $element.GetType().Name
174
- text = $element.Extent.Text
175
- }
176
-
177
- if ($element -is [System.Management.Automation.Language.CommandAst]) {
178
- $elemData.commandElements = @(Get-RawCommandElements -CmdAst $element)
179
- $elemData.redirections = @(Get-RawRedirections -Redirections $element.Redirections)
180
- } elseif ($element -is [System.Management.Automation.Language.CommandExpressionAst]) {
181
- $elemData.expressionType = $element.Expression.GetType().Name
182
- $elemData.redirections = @(Get-RawRedirections -Redirections $element.Redirections)
183
- }
184
-
185
- [void]$elements.Add($elemData)
186
- }
187
- $statement.elements = @($elements)
188
-
189
- $allNestedCmds = $stmt.FindAll(
190
- { param($node) $node -is [System.Management.Automation.Language.CommandAst] },
191
- $true
192
- )
193
- $nestedCmds = [System.Collections.ArrayList]::new()
194
- foreach ($cmd in $allNestedCmds) {
195
- if ($cmd.Parent -eq $stmt) { continue }
196
- $nested = @{
197
- type = $cmd.GetType().Name
198
- text = $cmd.Extent.Text
199
- commandElements = @(Get-RawCommandElements -CmdAst $cmd)
200
- redirections = @(Get-RawRedirections -Redirections $cmd.Redirections)
201
- }
202
- [void]$nestedCmds.Add($nested)
203
- }
204
- if ($nestedCmds.Count -gt 0) {
205
- $statement.nestedCommands = @($nestedCmds)
206
- }
207
- $r = $stmt.FindAll({param($n) $n -is [System.Management.Automation.Language.FileRedirectionAst]}, $true)
208
- if ($r.Count -gt 0) {
209
- $rr = @(Get-RawRedirections -Redirections $r)
210
- $statement.redirections = if ($statement.redirections) { @($statement.redirections) + $rr } else { $rr }
211
- }
212
- } else {
213
- $nestedCmdAsts = $stmt.FindAll(
214
- { param($node) $node -is [System.Management.Automation.Language.CommandAst] },
215
- $true
216
- )
217
- $nested = [System.Collections.ArrayList]::new()
218
- foreach ($cmd in $nestedCmdAsts) {
219
- [void]$nested.Add(@{
220
- type = 'CommandAst'
221
- text = $cmd.Extent.Text
222
- commandElements = @(Get-RawCommandElements -CmdAst $cmd)
223
- redirections = @(Get-RawRedirections -Redirections $cmd.Redirections)
224
- })
225
- }
226
- if ($nested.Count -gt 0) {
227
- $statement.nestedCommands = @($nested)
228
- }
229
- $r = $stmt.FindAll({param($n) $n -is [System.Management.Automation.Language.FileRedirectionAst]}, $true)
230
- if ($r.Count -gt 0) { $statement.redirections = @(Get-RawRedirections -Redirections $r) }
231
- }
232
-
233
- $sp = Get-SecurityPatterns $stmt
234
- if ($sp) { $statement.securityPatterns = $sp }
235
-
236
- [void]$statements.Add($statement)
237
- }
238
-
239
- if ($Block.Traps) {
240
- foreach ($trap in $Block.Traps) {
241
- $statement = @{
242
- type = 'TrapStatementAst'
243
- text = $trap.Extent.Text
244
- }
245
- $nestedCmdAsts = $trap.FindAll(
246
- { param($node) $node -is [System.Management.Automation.Language.CommandAst] },
247
- $true
248
- )
249
- $nestedCmds = [System.Collections.ArrayList]::new()
250
- foreach ($cmd in $nestedCmdAsts) {
251
- $nested = @{
252
- type = $cmd.GetType().Name
253
- text = $cmd.Extent.Text
254
- commandElements = @(Get-RawCommandElements -CmdAst $cmd)
255
- redirections = @(Get-RawRedirections -Redirections $cmd.Redirections)
256
- }
257
- [void]$nestedCmds.Add($nested)
258
- }
259
- if ($nestedCmds.Count -gt 0) {
260
- $statement.nestedCommands = @($nestedCmds)
261
- }
262
- $r = $trap.FindAll({param($n) $n -is [System.Management.Automation.Language.FileRedirectionAst]}, $true)
263
- if ($r.Count -gt 0) { $statement.redirections = @(Get-RawRedirections -Redirections $r) }
264
- $sp = Get-SecurityPatterns $trap
265
- if ($sp) { $statement.securityPatterns = $sp }
266
- [void]$statements.Add($statement)
267
- }
268
- }
269
- }
270
-
271
- Process-BlockStatements -Block $ast.BeginBlock
272
- Process-BlockStatements -Block $ast.ProcessBlock
273
- Process-BlockStatements -Block $ast.EndBlock
274
- Process-BlockStatements -Block $ast.CleanBlock
275
- Process-BlockStatements -Block $ast.DynamicParamBlock
276
-
277
- if ($ast.ParamBlock) {
278
- $pb = $ast.ParamBlock
279
- $pn = [System.Collections.ArrayList]::new()
280
- foreach ($c in $pb.FindAll({param($n) $n -is [System.Management.Automation.Language.CommandAst]}, $true)) {
281
- [void]$pn.Add(@{type='CommandAst';text=$c.Extent.Text;commandElements=@(Get-RawCommandElements -CmdAst $c);redirections=@(Get-RawRedirections -Redirections $c.Redirections)})
282
- }
283
- $pr = $pb.FindAll({param($n) $n -is [System.Management.Automation.Language.FileRedirectionAst]}, $true)
284
- $ps = Get-SecurityPatterns $pb
285
- if ($pn.Count -gt 0 -or $pr.Count -gt 0 -or $ps) {
286
- $st = @{type='ParamBlockAst';text=$pb.Extent.Text}
287
- if ($pn.Count -gt 0) { $st.nestedCommands = @($pn) }
288
- if ($pr.Count -gt 0) { $st.redirections = @(Get-RawRedirections -Redirections $pr) }
289
- if ($ps) { $st.securityPatterns = $ps }
290
- [void]$statements.Add($st)
291
- }
292
- }
293
-
294
- $hasUsingStatements = $ast.UsingStatements -and $ast.UsingStatements.Count -gt 0
295
- $hasScriptRequirements = $ast.ScriptRequirements -ne $null
296
-
297
- $output = @{
298
- valid = ($parseErrors.Count -eq 0)
299
- errors = @($parseErrors | ForEach-Object {
300
- @{
301
- message = $_.Message
302
- errorId = $_.ErrorId
303
- }
304
- })
305
- statements = @($statements)
306
- variables = @($allVariables)
307
- hasStopParsing = $hasStopParsing
308
- originalCommand = $Command
309
- typeLiterals = @($typeLiterals)
310
- hasUsingStatements = [bool]$hasUsingStatements
311
- hasScriptRequirements = [bool]$hasScriptRequirements
312
- }
313
-
314
- $output | ConvertTo-Json -Depth 10 -Compress
62
+ export const PARSE_SCRIPT_BODY = `
63
+ if (-not $EncodedCommand) {
64
+ Write-Output '{"valid":false,"errors":[{"message":"No command provided","errorId":"NoInput"}],"statements":[],"variables":[],"hasStopParsing":false,"originalCommand":""}'
65
+ exit 0
66
+ }
67
+
68
+ $Command = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($EncodedCommand))
69
+
70
+ $tokens = $null
71
+ $parseErrors = $null
72
+ $ast = [System.Management.Automation.Language.Parser]::ParseInput(
73
+ $Command,
74
+ [ref]$tokens,
75
+ [ref]$parseErrors
76
+ )
77
+
78
+ $allVariables = [System.Collections.ArrayList]::new()
79
+
80
+ function Get-RawCommandElements {
81
+ param([System.Management.Automation.Language.CommandAst]$CmdAst)
82
+ $elems = [System.Collections.ArrayList]::new()
83
+ foreach ($ce in $CmdAst.CommandElements) {
84
+ $ceData = @{ type = $ce.GetType().Name; text = $ce.Extent.Text }
85
+ if ($ce.PSObject.Properties['Value'] -and $null -ne $ce.Value -and $ce.Value -is [string]) {
86
+ $ceData.value = $ce.Value
87
+ }
88
+ if ($ce -is [System.Management.Automation.Language.CommandExpressionAst]) {
89
+ $ceData.expressionType = $ce.Expression.GetType().Name
90
+ }
91
+ $a=$ce.Argument;if($a){$ceData.children=@(@{type=$a.GetType().Name;text=$a.Extent.Text})}
92
+ [void]$elems.Add($ceData)
93
+ }
94
+ return $elems
95
+ }
96
+
97
+ function Get-RawRedirections {
98
+ param($Redirections)
99
+ $result = [System.Collections.ArrayList]::new()
100
+ foreach ($redir in $Redirections) {
101
+ $redirData = @{ type = $redir.GetType().Name }
102
+ if ($redir -is [System.Management.Automation.Language.FileRedirectionAst]) {
103
+ $redirData.append = [bool]$redir.Append
104
+ $redirData.fromStream = $redir.FromStream.ToString()
105
+ $redirData.locationText = $redir.Location.Extent.Text
106
+ }
107
+ [void]$result.Add($redirData)
108
+ }
109
+ return $result
110
+ }
111
+
112
+ function Get-SecurityPatterns($A) {
113
+ $p = @{}
114
+ foreach ($n in $A.FindAll({ param($x)
115
+ $x -is [System.Management.Automation.Language.MemberExpressionAst] -or
116
+ $x -is [System.Management.Automation.Language.SubExpressionAst] -or
117
+ $x -is [System.Management.Automation.Language.ArrayExpressionAst] -or
118
+ $x -is [System.Management.Automation.Language.ExpandableStringExpressionAst] -or
119
+ $x -is [System.Management.Automation.Language.ScriptBlockExpressionAst] -or
120
+ $x -is [System.Management.Automation.Language.ParenExpressionAst]
121
+ }, $true)) { switch ($n.GetType().Name) {
122
+ 'InvokeMemberExpressionAst' { $p.hasMemberInvocations = $true }
123
+ 'MemberExpressionAst' { $p.hasMemberInvocations = $true }
124
+ 'SubExpressionAst' { $p.hasSubExpressions = $true }
125
+ 'ArrayExpressionAst' { $p.hasSubExpressions = $true }
126
+ 'ParenExpressionAst' { $p.hasSubExpressions = $true }
127
+ 'ExpandableStringExpressionAst' { $p.hasExpandableStrings = $true }
128
+ 'ScriptBlockExpressionAst' { $p.hasScriptBlocks = $true }
129
+ }}
130
+ if ($p.Count -gt 0) { return $p }
131
+ return $null
132
+ }
133
+
134
+ $varExprs = $ast.FindAll({ param($node) $node -is [System.Management.Automation.Language.VariableExpressionAst] }, $true)
135
+ foreach ($v in $varExprs) {
136
+ [void]$allVariables.Add(@{
137
+ path = $v.VariablePath.ToString()
138
+ isSplatted = [bool]$v.Splatted
139
+ })
140
+ }
141
+
142
+ $typeLiterals = [System.Collections.ArrayList]::new()
143
+ foreach ($t in $ast.FindAll({ param($n)
144
+ $n -is [System.Management.Automation.Language.TypeExpressionAst] -or
145
+ $n -is [System.Management.Automation.Language.TypeConstraintAst]
146
+ }, $true)) { [void]$typeLiterals.Add($t.TypeName.FullName) }
147
+
148
+ $hasStopParsing = $false
149
+ $tk = [System.Management.Automation.Language.TokenKind]
150
+ foreach ($tok in $tokens) {
151
+ if ($tok.Kind -eq $tk::MinusMinus) { $hasStopParsing = $true; break }
152
+ if ($tok.Kind -eq $tk::Generic -and ($tok.Text -replace '[\u2013\u2014\u2015]','-') -eq '--%') {
153
+ $hasStopParsing = $true; break
154
+ }
155
+ }
156
+
157
+ $statements = [System.Collections.ArrayList]::new()
158
+
159
+ function Process-BlockStatements {
160
+ param($Block)
161
+ if (-not $Block) { return }
162
+
163
+ foreach ($stmt in $Block.Statements) {
164
+ $statement = @{
165
+ type = $stmt.GetType().Name
166
+ text = $stmt.Extent.Text
167
+ }
168
+
169
+ if ($stmt -is [System.Management.Automation.Language.PipelineAst]) {
170
+ $elements = [System.Collections.ArrayList]::new()
171
+ foreach ($element in $stmt.PipelineElements) {
172
+ $elemData = @{
173
+ type = $element.GetType().Name
174
+ text = $element.Extent.Text
175
+ }
176
+
177
+ if ($element -is [System.Management.Automation.Language.CommandAst]) {
178
+ $elemData.commandElements = @(Get-RawCommandElements -CmdAst $element)
179
+ $elemData.redirections = @(Get-RawRedirections -Redirections $element.Redirections)
180
+ } elseif ($element -is [System.Management.Automation.Language.CommandExpressionAst]) {
181
+ $elemData.expressionType = $element.Expression.GetType().Name
182
+ $elemData.redirections = @(Get-RawRedirections -Redirections $element.Redirections)
183
+ }
184
+
185
+ [void]$elements.Add($elemData)
186
+ }
187
+ $statement.elements = @($elements)
188
+
189
+ $allNestedCmds = $stmt.FindAll(
190
+ { param($node) $node -is [System.Management.Automation.Language.CommandAst] },
191
+ $true
192
+ )
193
+ $nestedCmds = [System.Collections.ArrayList]::new()
194
+ foreach ($cmd in $allNestedCmds) {
195
+ if ($cmd.Parent -eq $stmt) { continue }
196
+ $nested = @{
197
+ type = $cmd.GetType().Name
198
+ text = $cmd.Extent.Text
199
+ commandElements = @(Get-RawCommandElements -CmdAst $cmd)
200
+ redirections = @(Get-RawRedirections -Redirections $cmd.Redirections)
201
+ }
202
+ [void]$nestedCmds.Add($nested)
203
+ }
204
+ if ($nestedCmds.Count -gt 0) {
205
+ $statement.nestedCommands = @($nestedCmds)
206
+ }
207
+ $r = $stmt.FindAll({param($n) $n -is [System.Management.Automation.Language.FileRedirectionAst]}, $true)
208
+ if ($r.Count -gt 0) {
209
+ $rr = @(Get-RawRedirections -Redirections $r)
210
+ $statement.redirections = if ($statement.redirections) { @($statement.redirections) + $rr } else { $rr }
211
+ }
212
+ } else {
213
+ $nestedCmdAsts = $stmt.FindAll(
214
+ { param($node) $node -is [System.Management.Automation.Language.CommandAst] },
215
+ $true
216
+ )
217
+ $nested = [System.Collections.ArrayList]::new()
218
+ foreach ($cmd in $nestedCmdAsts) {
219
+ [void]$nested.Add(@{
220
+ type = 'CommandAst'
221
+ text = $cmd.Extent.Text
222
+ commandElements = @(Get-RawCommandElements -CmdAst $cmd)
223
+ redirections = @(Get-RawRedirections -Redirections $cmd.Redirections)
224
+ })
225
+ }
226
+ if ($nested.Count -gt 0) {
227
+ $statement.nestedCommands = @($nested)
228
+ }
229
+ $r = $stmt.FindAll({param($n) $n -is [System.Management.Automation.Language.FileRedirectionAst]}, $true)
230
+ if ($r.Count -gt 0) { $statement.redirections = @(Get-RawRedirections -Redirections $r) }
231
+ }
232
+
233
+ $sp = Get-SecurityPatterns $stmt
234
+ if ($sp) { $statement.securityPatterns = $sp }
235
+
236
+ [void]$statements.Add($statement)
237
+ }
238
+
239
+ if ($Block.Traps) {
240
+ foreach ($trap in $Block.Traps) {
241
+ $statement = @{
242
+ type = 'TrapStatementAst'
243
+ text = $trap.Extent.Text
244
+ }
245
+ $nestedCmdAsts = $trap.FindAll(
246
+ { param($node) $node -is [System.Management.Automation.Language.CommandAst] },
247
+ $true
248
+ )
249
+ $nestedCmds = [System.Collections.ArrayList]::new()
250
+ foreach ($cmd in $nestedCmdAsts) {
251
+ $nested = @{
252
+ type = $cmd.GetType().Name
253
+ text = $cmd.Extent.Text
254
+ commandElements = @(Get-RawCommandElements -CmdAst $cmd)
255
+ redirections = @(Get-RawRedirections -Redirections $cmd.Redirections)
256
+ }
257
+ [void]$nestedCmds.Add($nested)
258
+ }
259
+ if ($nestedCmds.Count -gt 0) {
260
+ $statement.nestedCommands = @($nestedCmds)
261
+ }
262
+ $r = $trap.FindAll({param($n) $n -is [System.Management.Automation.Language.FileRedirectionAst]}, $true)
263
+ if ($r.Count -gt 0) { $statement.redirections = @(Get-RawRedirections -Redirections $r) }
264
+ $sp = Get-SecurityPatterns $trap
265
+ if ($sp) { $statement.securityPatterns = $sp }
266
+ [void]$statements.Add($statement)
267
+ }
268
+ }
269
+ }
270
+
271
+ Process-BlockStatements -Block $ast.BeginBlock
272
+ Process-BlockStatements -Block $ast.ProcessBlock
273
+ Process-BlockStatements -Block $ast.EndBlock
274
+ Process-BlockStatements -Block $ast.CleanBlock
275
+ Process-BlockStatements -Block $ast.DynamicParamBlock
276
+
277
+ if ($ast.ParamBlock) {
278
+ $pb = $ast.ParamBlock
279
+ $pn = [System.Collections.ArrayList]::new()
280
+ foreach ($c in $pb.FindAll({param($n) $n -is [System.Management.Automation.Language.CommandAst]}, $true)) {
281
+ [void]$pn.Add(@{type='CommandAst';text=$c.Extent.Text;commandElements=@(Get-RawCommandElements -CmdAst $c);redirections=@(Get-RawRedirections -Redirections $c.Redirections)})
282
+ }
283
+ $pr = $pb.FindAll({param($n) $n -is [System.Management.Automation.Language.FileRedirectionAst]}, $true)
284
+ $ps = Get-SecurityPatterns $pb
285
+ if ($pn.Count -gt 0 -or $pr.Count -gt 0 -or $ps) {
286
+ $st = @{type='ParamBlockAst';text=$pb.Extent.Text}
287
+ if ($pn.Count -gt 0) { $st.nestedCommands = @($pn) }
288
+ if ($pr.Count -gt 0) { $st.redirections = @(Get-RawRedirections -Redirections $pr) }
289
+ if ($ps) { $st.securityPatterns = $ps }
290
+ [void]$statements.Add($st)
291
+ }
292
+ }
293
+
294
+ $hasUsingStatements = $ast.UsingStatements -and $ast.UsingStatements.Count -gt 0
295
+ $hasScriptRequirements = $ast.ScriptRequirements -ne $null
296
+
297
+ $output = @{
298
+ valid = ($parseErrors.Count -eq 0)
299
+ errors = @($parseErrors | ForEach-Object {
300
+ @{
301
+ message = $_.Message
302
+ errorId = $_.ErrorId
303
+ }
304
+ })
305
+ statements = @($statements)
306
+ variables = @($allVariables)
307
+ hasStopParsing = $hasStopParsing
308
+ originalCommand = $Command
309
+ typeLiterals = @($typeLiterals)
310
+ hasUsingStatements = [bool]$hasUsingStatements
311
+ hasScriptRequirements = [bool]$hasScriptRequirements
312
+ }
313
+
314
+ $output | ConvertTo-Json -Depth 10 -Compress
315
315
  `;
316
316
  // ---------------------------------------------------------------------------
317
317
  // Windows CreateProcess has a 32,767 char command-line limit. The encoding
@@ -52,18 +52,18 @@ export function extractConversationText(messages) {
52
52
  ? text.slice(-MAX_CONVERSATION_TEXT)
53
53
  : text;
54
54
  }
55
- const SESSION_TITLE_PROMPT = `Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns.
56
-
57
- Return JSON with a single "title" field.
58
-
59
- Good examples:
60
- {"title": "Fix login button on mobile"}
61
- {"title": "Add OAuth authentication"}
62
- {"title": "Debug failing CI tests"}
63
- {"title": "Refactor API client error handling"}
64
-
65
- Bad (too vague): {"title": "Code changes"}
66
- Bad (too long): {"title": "Investigate and fix the issue where the login button does not respond on mobile devices"}
55
+ const SESSION_TITLE_PROMPT = `Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns.
56
+
57
+ Return JSON with a single "title" field.
58
+
59
+ Good examples:
60
+ {"title": "Fix login button on mobile"}
61
+ {"title": "Add OAuth authentication"}
62
+ {"title": "Debug failing CI tests"}
63
+ {"title": "Refactor API client error handling"}
64
+
65
+ Bad (too vague): {"title": "Code changes"}
66
+ Bad (too long): {"title": "Investigate and fix the issue where the login button does not respond on mobile devices"}
67
67
  Bad (wrong case): {"title": "Fix Login Button On Mobile"}`;
68
68
  const titleSchema = lazySchema(() => z.object({ title: z.string() }));
69
69
  /**
@@ -35,23 +35,23 @@ export function findBtwTriggerPositions(text) {
35
35
  */
36
36
  export async function runSideQuestion({ question, cacheSafeParams, }) {
37
37
  // Wrap the question with instructions to answer without tools
38
- const wrappedQuestion = `<system-reminder>This is a side question from the user. You must answer this question directly in a single response.
39
-
40
- IMPORTANT CONTEXT:
41
- - You are a separate, lightweight agent spawned to answer this one question
42
- - The main agent is NOT interrupted - it continues working independently in the background
43
- - You share the conversation context but are a completely separate instance
44
- - Do NOT reference being interrupted or what you were "previously doing" - that framing is incorrect
45
-
46
- CRITICAL CONSTRAINTS:
47
- - You have NO tools available - you cannot read files, run commands, search, or take any actions
48
- - This is a one-off response - there will be no follow-up turns
49
- - You can ONLY provide information based on what you already know from the conversation context
50
- - NEVER say things like "Let me try...", "I'll now...", "Let me check...", or promise to take any action
51
- - If you don't know the answer, say so - do not offer to look it up or investigate
52
-
53
- Simply answer the question with the information you have.</system-reminder>
54
-
38
+ const wrappedQuestion = `<system-reminder>This is a side question from the user. You must answer this question directly in a single response.
39
+
40
+ IMPORTANT CONTEXT:
41
+ - You are a separate, lightweight agent spawned to answer this one question
42
+ - The main agent is NOT interrupted - it continues working independently in the background
43
+ - You share the conversation context but are a completely separate instance
44
+ - Do NOT reference being interrupted or what you were "previously doing" - that framing is incorrect
45
+
46
+ CRITICAL CONSTRAINTS:
47
+ - You have NO tools available - you cannot read files, run commands, search, or take any actions
48
+ - This is a one-off response - there will be no follow-up turns
49
+ - You can ONLY provide information based on what you already know from the conversation context
50
+ - NEVER say things like "Let me try...", "I'll now...", "Let me check...", or promise to take any action
51
+ - If you don't know the answer, say so - do not offer to look it up or investigate
52
+
53
+ Simply answer the question with the information you have.</system-reminder>
54
+
55
55
  ${question}`;
56
56
  const agentResult = await runForkedAgent({
57
57
  promptMessages: [createUserMessage({ content: wrappedQuestion })],
@@ -353,7 +353,7 @@ export function buildAPIProviderProperties() {
353
353
  foundry: 'Microsoft Foundry',
354
354
  openai: 'OpenAI / Codex',
355
355
  openrouter: 'OpenRouter',
356
- ollama: 'Ollama Local',
356
+ ollama: 'Ollama',
357
357
  'ollama-cloud': 'Ollama Cloud',
358
358
  zai: 'Z.AI',
359
359
  minimax: 'MiniMax',
@@ -192,22 +192,22 @@ function getTmuxInstallInstructions() {
192
192
  const platform = getPlatform();
193
193
  switch (platform) {
194
194
  case 'macos':
195
- return `To use agent swarms, install tmux:
196
- brew install tmux
195
+ return `To use agent swarms, install tmux:
196
+ brew install tmux
197
197
  Then start a tmux session with: tmux new-session -s claude`;
198
198
  case 'linux':
199
199
  case 'wsl':
200
- return `To use agent swarms, install tmux:
201
- sudo apt install tmux # Ubuntu/Debian
202
- sudo dnf install tmux # Fedora/RHEL
200
+ return `To use agent swarms, install tmux:
201
+ sudo apt install tmux # Ubuntu/Debian
202
+ sudo dnf install tmux # Fedora/RHEL
203
203
  Then start a tmux session with: tmux new-session -s claude`;
204
204
  case 'windows':
205
- return `To use agent swarms, you need tmux which requires WSL (Windows Subsystem for Linux).
206
- Install WSL first, then inside WSL run:
207
- sudo apt install tmux
205
+ return `To use agent swarms, you need tmux which requires WSL (Windows Subsystem for Linux).
206
+ Install WSL first, then inside WSL run:
207
+ sudo apt install tmux
208
208
  Then start a tmux session with: tmux new-session -s claude`;
209
209
  default:
210
- return `To use agent swarms, install tmux using your system's package manager.
210
+ return `To use agent swarms, install tmux using your system's package manager.
211
211
  Then start a tmux session with: tmux new-session -s claude`;
212
212
  }
213
213
  }
@@ -490,15 +490,15 @@ export async function initializeTelemetry() {
490
490
  }
491
491
  catch (error) {
492
492
  if (error instanceof Error && error.message.includes('timeout')) {
493
- logForDebugging(`
494
- OpenTelemetry telemetry flush timed out after ${timeoutMs}ms
495
-
496
- To resolve this issue, you can:
497
- 1. Increase the timeout by setting CLAUDE_CODE_OTEL_SHUTDOWN_TIMEOUT_MS env var (e.g., 5000 for 5 seconds)
498
- 2. Check if your OpenTelemetry backend is experiencing scalability issues
499
- 3. Disable OpenTelemetry by unsetting CLAUDE_CODE_ENABLE_TELEMETRY env var
500
-
501
- Current timeout: ${timeoutMs}ms
493
+ logForDebugging(`
494
+ OpenTelemetry telemetry flush timed out after ${timeoutMs}ms
495
+
496
+ To resolve this issue, you can:
497
+ 1. Increase the timeout by setting CLAUDE_CODE_OTEL_SHUTDOWN_TIMEOUT_MS env var (e.g., 5000 for 5 seconds)
498
+ 2. Check if your OpenTelemetry backend is experiencing scalability issues
499
+ 3. Disable OpenTelemetry by unsetting CLAUDE_CODE_ENABLE_TELEMETRY env var
500
+
501
+ Current timeout: ${timeoutMs}ms
502
502
  `, { level: 'error' });
503
503
  }
504
504
  throw error;