tinker-agent 1.0.15 → 1.0.17
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.
- package/package.json +1 -1
- package/setup-agent.rb +40 -19
package/package.json
CHANGED
package/setup-agent.rb
CHANGED
|
@@ -246,9 +246,6 @@ def setup_github_auth!
|
|
|
246
246
|
puts "🔐 Configuring GitHub App authentication..."
|
|
247
247
|
|
|
248
248
|
# Create helper script
|
|
249
|
-
helper_path = "/usr/local/bin/git-auth-helper"
|
|
250
|
-
|
|
251
|
-
# We embed the helper script content here
|
|
252
249
|
helper_content = <<~RUBY
|
|
253
250
|
#!/usr/bin/env ruby
|
|
254
251
|
require 'openssl'
|
|
@@ -308,27 +305,32 @@ def setup_github_auth!
|
|
|
308
305
|
puts cached_token(app_id, installation_id, key_path)
|
|
309
306
|
RUBY
|
|
310
307
|
|
|
311
|
-
#
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
else
|
|
317
|
-
helper_path = "/tmp/git-auth-helper"
|
|
318
|
-
File.write(helper_path, helper_content)
|
|
319
|
-
File.chmod(0755, helper_path)
|
|
320
|
-
end
|
|
308
|
+
# Install helper via sudo to /usr/local/bin
|
|
309
|
+
helper_path = "/usr/local/bin/git-auth-helper"
|
|
310
|
+
File.write("/tmp/git-auth-helper", helper_content)
|
|
311
|
+
system("sudo mv /tmp/git-auth-helper #{helper_path}")
|
|
312
|
+
system("sudo chmod +x #{helper_path}")
|
|
321
313
|
|
|
322
314
|
# Configure git
|
|
323
315
|
system("git config --global credential.helper '!f() { test \"$1\" = get && echo \"protocol=https\" && echo \"host=github.com\" && echo \"username=x-access-token\" && echo \"password=$(#{helper_path})\"; }; f'")
|
|
324
316
|
|
|
325
|
-
# Configure gh CLI
|
|
326
|
-
|
|
327
|
-
if
|
|
328
|
-
|
|
317
|
+
# Configure gh CLI wrapper for auto-refresh
|
|
318
|
+
real_gh_path = "/usr/bin/gh"
|
|
319
|
+
if File.exist?(real_gh_path)
|
|
320
|
+
wrapper_path = "/usr/local/bin/gh"
|
|
321
|
+
wrapper_content = <<~BASH
|
|
322
|
+
#!/bin/bash
|
|
323
|
+
# Auto-refresh GitHub token using git-auth-helper
|
|
324
|
+
export GH_TOKEN=$(#{helper_path})
|
|
325
|
+
exec #{real_gh_path} "$@"
|
|
326
|
+
BASH
|
|
327
|
+
|
|
328
|
+
File.write("/tmp/gh-wrapper", wrapper_content)
|
|
329
|
+
system("sudo mv /tmp/gh-wrapper #{wrapper_path}")
|
|
330
|
+
system("sudo chmod +x #{wrapper_path}")
|
|
331
|
+
puts "✅ GitHub App authentication configured (with auto-refresh)"
|
|
329
332
|
else
|
|
330
|
-
|
|
331
|
-
puts "✅ GitHub App authentication configured"
|
|
333
|
+
puts "⚠️ Could not find 'gh' at #{real_gh_path}, skipping wrapper"
|
|
332
334
|
end
|
|
333
335
|
|
|
334
336
|
elsif ENV["GH_TOKEN"] && !ENV["GH_TOKEN"].empty?
|
|
@@ -339,6 +341,24 @@ def setup_github_auth!
|
|
|
339
341
|
end
|
|
340
342
|
end
|
|
341
343
|
|
|
344
|
+
def setup_git_config!
|
|
345
|
+
# Configure identity if provided
|
|
346
|
+
if ENV["GIT_USER_NAME"] && !ENV["GIT_USER_NAME"].empty?
|
|
347
|
+
system("git config --global user.name \"#{ENV['GIT_USER_NAME']}\"")
|
|
348
|
+
puts "✅ Git user.name configured"
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
if ENV["GIT_USER_EMAIL"] && !ENV["GIT_USER_EMAIL"].empty?
|
|
352
|
+
system("git config --global user.email \"#{ENV['GIT_USER_EMAIL']}\"")
|
|
353
|
+
puts "✅ Git user.email configured"
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
# Force HTTPS instead of SSH to ensure our token auth works
|
|
357
|
+
# This fixes "Permission denied (publickey)" when the repo uses git@github.com remote
|
|
358
|
+
system("git config --global url.\"https://github.com/\".insteadOf \"git@github.com:\"")
|
|
359
|
+
puts "✅ Git configured to force HTTPS for GitHub"
|
|
360
|
+
end
|
|
361
|
+
|
|
342
362
|
def download_agent_bridge!
|
|
343
363
|
# Detect architecture
|
|
344
364
|
arch = `uname -m`.strip
|
|
@@ -424,5 +444,6 @@ setup_mcp_config!
|
|
|
424
444
|
setup_claude_config!
|
|
425
445
|
setup_claude_md!
|
|
426
446
|
setup_github_auth!
|
|
447
|
+
setup_git_config!
|
|
427
448
|
bin_dir = download_agent_bridge!
|
|
428
449
|
run_agent!(bin_dir)
|