Top Level Namespace
Defined Under Namespace
Modules: Wokku
Constant Summary collapse
- CONFIG_DIR =
Wokku::Config::DEFAULT_DIR
- CONFIG_FILE =
File.join(CONFIG_DIR, "config.json")
- VERSION =
Wokku::VERSION
- MCP_SERVER_NAME =
Wokku MCP commands — install / switch / logout the Wokku MCP server in Claude Code so the user’s CLI token gets passed to the plugin. Shells out to ‘claude mcp` (Claude Code CLI) so we don’t need to know Claude Code’s exact config-file layout — it changes between versions.
"wokku"- DEFAULT_API_URL =
"https://wokku.cloud/api/v1"
Instance Method Summary collapse
-
#api(method, path, body = nil) ⇒ Object
Top-level helper shims used by command blocks (preserved for compatibility with the existing register-DSL pattern).
- #api_token ⇒ Object
- #api_url ⇒ Object
- #claude_cli_available? ⇒ Boolean
-
#find_domain(app_id, hostname) ⇒ Object
Look up a domain row by hostname so users can pass the name they know rather than an internal id.
- #install_mcp_entry! ⇒ Object
- #load_config ⇒ Object
- #puts_json(data) ⇒ Object
- #register(name, desc, &block) ⇒ Object
- #require_claude_cli! ⇒ Object
- #require_logged_in! ⇒ Object
-
#resolve_server(explicit: nil) ⇒ Object
Resolve which server to target for a deploy/create.
- #save_config(data) ⇒ Object
- #table(rows, headers: nil) ⇒ Object
Instance Method Details
#api(method, path, body = nil) ⇒ Object
Top-level helper shims used by command blocks (preserved for compatibility with the existing register-DSL pattern).
76 77 78 79 80 81 |
# File 'lib/wokku.rb', line 76 def api(method, path, body = nil) Wokku.api_client.request(method, path, body) rescue Wokku::ApiClient::NotAuthenticated, Wokku::ApiClient::Timeout, Wokku::ApiClient::Unreachable, Wokku::ApiClient::Error => e abort e. end |
#claude_cli_available? ⇒ Boolean
10 11 12 |
# File 'lib/wokku/commands/mcp.rb', line 10 def claude_cli_available? system("command -v claude >/dev/null 2>&1") end |
#find_domain(app_id, hostname) ⇒ Object
Look up a domain row by hostname so users can pass the name they know rather than an internal id. Returns nil when not found or when the API returns a non-array (error envelope).
10 11 12 13 14 |
# File 'lib/wokku/helpers.rb', line 10 def find_domain(app_id, hostname) list = api(:get, "/apps/#{app_id}/domains") return nil unless list.is_a?(Array) list.find { |d| d["hostname"] == hostname } end |
#install_mcp_entry! ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wokku/commands/mcp.rb', line 29 def install_mcp_entry! url = Wokku::Config.api_url token = Wokku::Config.api_token # Idempotent — silently no-ops if the entry doesn't exist yet. system("claude mcp remove #{Shellwords.escape(MCP_SERVER_NAME)} > /dev/null 2>&1") ok = system( "claude", "mcp", "add", MCP_SERVER_NAME, "--env", "WOKKU_API_URL=#{url}", "--env", "WOKKU_API_TOKEN=#{token}", "--", "npx", "-y", "@johannesdwicahyo/wokku-plugin" ) ok or abort "claude mcp add failed — check `claude mcp list` and retry." end |
#puts_json(data) ⇒ Object
88 |
# File 'lib/wokku.rb', line 88 def puts_json(data) = Wokku::Output.puts_json(data) |
#register(name, desc, &block) ⇒ Object
89 |
# File 'lib/wokku.rb', line 89 def register(name, desc, &block) = Wokku::Registry.register(name, desc, &block) |
#require_claude_cli! ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/wokku/commands/mcp.rb', line 14 def require_claude_cli! return if claude_cli_available? abort <<~MSG The `claude` CLI is not installed. Wokku MCP commands shell out to it to write your Claude Code config. Install Claude Code (https://claude.com/claude-code) and retry. MSG end |
#require_logged_in! ⇒ Object
24 25 26 27 |
# File 'lib/wokku/commands/mcp.rb', line 24 def require_logged_in! return if Wokku::Config.api_token abort "Not logged in. Run: wokku auth:login" end |
#resolve_server(explicit: nil) ⇒ Object
Resolve which server to target for a deploy/create. Walks the precedence chain: explicit flag → env → config → auto-pick if only one server → abort with helpful error. Returns the server name or UUID (whatever was explicitly passed/configured).
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wokku/helpers.rb', line 20 def resolve_server(explicit: nil) return explicit if explicit env = ENV["WOKKU_DEFAULT_SERVER"] return env if env && !env.empty? cfg_default = Wokku::Config.load["default_server"] return cfg_default if cfg_default servers = api(:get, "/servers") unless servers.is_a?(Array) abort "Unexpected response from /servers: #{servers.inspect[0..200]}" end abort "No servers available. Contact wokku.cloud support." if servers.empty? return servers.first["name"] if servers.size == 1 names = servers.map { |s| s["name"] }.join(", ") abort "Multiple servers available (#{names}). Pass --server NAME or set a default: wokku servers:default NAME" end |