Class: RubynCode::IDE::Handlers::InitializeHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyn_code/ide/handlers/initialize_handler.rb

Overview

Handles the “initialize” JSON-RPC request from the IDE extension.

Accepts workspace path, extension metadata, and client capabilities. Sets the working directory and returns server capabilities so the extension knows what features are available.

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ InitializeHandler

Returns a new instance of InitializeHandler.



12
13
14
# File 'lib/rubyn_code/ide/handlers/initialize_handler.rb', line 12

def initialize(server)
  @server = server
end

Instance Method Details

#call(params) ⇒ Object

rubocop:disable Metrics/MethodLength – builds full capability handshake response



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rubyn_code/ide/handlers/initialize_handler.rb', line 16

def call(params) # rubocop:disable Metrics/MethodLength -- builds full capability handshake response
  workspace = params['workspacePath']
  extension_version = params['extensionVersion']
  client_caps = params['capabilities'] || {}

  if workspace && Dir.exist?(workspace)
    Dir.chdir(workspace)
    @server.workspace_path = workspace
  end

  @server.extension_version = extension_version
  @server.client_capabilities = client_caps

  tool_count  = tool_count!
  skill_count = skill_count!

  {
    'serverVersion' => RubynCode::VERSION,
    'protocolVersion' => '1.0',
    'workspacePath' => Dir.pwd,
    'capabilities' => {
      'tools' => tool_count,
      'skills' => skill_count,
      'streaming' => true,
      'review' => true,
      'memory' => true,
      'teams' => true,
      'toolApproval' => true,
      'editApproval' => true
    }
  }
end