tinker-agent 1.0.48 → 1.0.49

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 (2) hide show
  1. package/package.json +1 -1
  2. package/setup-agent.rb +41 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinker-agent",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "Tinker Agent Runner",
5
5
  "bin": {
6
6
  "tinker-agent": "./run-tinker-agent.rb"
package/setup-agent.rb CHANGED
@@ -219,9 +219,7 @@ def setup_skills!
219
219
  # Try local copy first (dev mode, or if copied into image)
220
220
  # Check both PWD/tinker-public/skills or PWD/skills (depending on how image was built)
221
221
  local_paths = [
222
- File.join(Dir.pwd, "tinker-public", "skills", skill, "SKILL.md"),
223
- File.join(Dir.pwd, "skills", skill, "SKILL.md"),
224
- "/tmp/skills/#{skill}/SKILL.md" # For legacy mounts
222
+ File.join(Dir.pwd, "tinker-public", "skills", skill, "SKILL.md")
225
223
  ]
226
224
 
227
225
  skill_content = nil
@@ -395,6 +393,45 @@ def setup_git_config!
395
393
  # This fixes "Permission denied (publickey)" when the repo uses git@github.com remote
396
394
  system("git config --global url.\"https://github.com/\".insteadOf \"git@github.com:\"")
397
395
  puts "✅ Git configured to force HTTPS for GitHub"
396
+
397
+ # Avoid "dubious ownership" errors in containers
398
+ system("git config --global --add safe.directory \"#{Dir.pwd}\"")
399
+ puts "✅ Git configured to trust #{Dir.pwd}"
400
+ end
401
+
402
+ def prepare_git_state!
403
+ return unless File.directory?(".git")
404
+
405
+ puts "🧹 Preparing git repository..."
406
+
407
+ # Fix permissions on .git to allow lock creation (fix for Permission denied)
408
+ if system("command -v sudo > /dev/null 2>&1")
409
+ current_user = `whoami`.strip
410
+ if current_user != "root"
411
+ # Try to take ownership of .git folder to ensure we can write locks
412
+ system("sudo chown -R #{current_user} .git")
413
+ end
414
+ end
415
+
416
+ # Remove stale index.lock if it exists
417
+ if File.exist?(".git/index.lock")
418
+ puts "🔓 Removing stale index.lock..."
419
+ first_try = system("rm -f .git/index.lock")
420
+
421
+ # If failed and sudo exists, try sudo
422
+ if File.exist?(".git/index.lock") && system("command -v sudo > /dev/null 2>&1")
423
+ system("sudo rm -f .git/index.lock")
424
+ end
425
+ end
426
+
427
+ # Reset to clean state
428
+ puts "🔄 Resetting to clean state..."
429
+ system("git add .")
430
+ if system("git reset --hard")
431
+ puts "✅ Git state reset"
432
+ else
433
+ puts "⚠️ Failed to reset git state"
434
+ end
398
435
  end
399
436
 
400
437
  def setup_git_hooks!
@@ -529,6 +566,7 @@ setup_system_prompt!
529
566
  setup_skills!
530
567
  setup_github_auth!
531
568
  setup_git_config!
569
+ prepare_git_state!
532
570
  setup_git_hooks!
533
571
  bin_dir = download_agent_bridge!
534
572
  run_agent!(bin_dir)