yatfa 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.
@@ -107,7 +107,10 @@ if [ -f "/tmp/setup-agent.rb" ]; then
107
107
  ruby /tmp/setup-agent.rb
108
108
  else
109
109
  echo "Downloading latest setup-agent.rb (version: ${YATFA_VERSION})..."
110
- curl -fsSL https://objectstore.fra1.civo.com/yatfa/${YATFA_VERSION}/setup-agent.rb | ruby
110
+ curl -fsSL https://objectstore.fra1.civo.com/yatfa/${YATFA_VERSION}/setup-agent.rb -o /tmp/setup-agent.rb
111
+ # Download claw setup (non-fatal — only needed when AGENT_TYPE=claw)
112
+ curl -fsSL https://objectstore.fra1.civo.com/yatfa/${YATFA_VERSION}/setup-claw-agent.rb -o /tmp/setup-claw-agent.rb 2>/dev/null || true
113
+ ruby /tmp/setup-agent.rb
111
114
  fi
112
115
  EOF
113
116
  chmod +x /usr/local/bin/setup-agent
@@ -17,12 +17,45 @@ require_relative "../lib/yatfa_agent/agent"
17
17
  require_relative "../lib/yatfa_agent/setup"
18
18
  require_relative "../agents"
19
19
 
20
- def show_version
20
+ def current_version
21
21
  require "json"
22
22
  real_path = File.realpath(__FILE__)
23
23
  package_json_path = File.join(File.dirname(real_path), "..", "package.json")
24
- version = JSON.parse(File.read(package_json_path))["version"]
25
- puts "yatfa v#{version}"
24
+ JSON.parse(File.read(package_json_path))["version"]
25
+ end
26
+
27
+ def latest_npm_version
28
+ require "net/http"
29
+ require "json"
30
+ uri = URI("https://registry.npmjs.org/yatfa/latest")
31
+ response = Net::HTTP.get_response(uri)
32
+ return nil unless response.is_a?(Net::HTTPSuccess)
33
+ JSON.parse(response.body)["version"]
34
+ rescue StandardError
35
+ nil
36
+ end
37
+
38
+ def check_version!
39
+ local = current_version
40
+ remote = latest_npm_version
41
+ return if remote.nil? || local == remote
42
+
43
+ # Try to self-delete the outdated install so next run fetches fresh
44
+ begin
45
+ real_path = File.realpath(__FILE__)
46
+ install_dir = File.expand_path("../..", real_path) # bin/../.. → package root
47
+ FileUtils.rm_rf(install_dir)
48
+ rescue StandardError
49
+ # No permission or other issue — just warn
50
+ end
51
+
52
+ puts "⚠️ Outdated version: v#{local} (latest: v#{remote})"
53
+ puts " Re-run: npx yatfa@latest #{ARGV.join(' ')}"
54
+ exit 1
55
+ end
56
+
57
+ def show_version
58
+ puts "yatfa v#{current_version}"
26
59
  exit 0
27
60
  end
28
61
 
@@ -54,9 +87,12 @@ show_usage if ARGV.empty?
54
87
 
55
88
  command = ARGV[0].downcase
56
89
 
57
- # Handle version command
90
+ # Handle version command (skip version check — user is just asking what version they have)
58
91
  show_version if %w[version -v --version].include?(command)
59
92
 
93
+ # Check for updates before doing anything else
94
+ check_version!
95
+
60
96
  # Handle setup command
61
97
  if command == "setup"
62
98
  wizard = YatfaAgent::Setup::SetupWizard.new
@@ -207,13 +207,39 @@ module YatfaAgent
207
207
  user = detect_agent_user(container_name)
208
208
  puts " User: #{user}"
209
209
 
210
- # Wait for tmux session to be ready
211
- 10.times do
210
+ # Wait for tmux session to be ready (up to 60 seconds)
211
+ # Setup runs git clone, downloads, and config before creating the tmux session,
212
+ # which can take longer than 10 seconds on slow networks or large repos.
213
+ max_wait = 60
214
+ ready = false
215
+
216
+ print " Waiting for agent session to start"
217
+ max_wait.times do
212
218
  if system("docker", "exec", "-u", user, container_name, "tmux", "has-session", "-t", "agent", err: File::NULL, out: File::NULL)
219
+ ready = true
213
220
  break
214
221
  end
222
+ print "."
223
+ $stdout.flush
215
224
  sleep 1
216
225
  end
226
+ puts ""
227
+
228
+ unless ready
229
+ puts ""
230
+ puts "❌ Agent session not ready after #{max_wait} seconds."
231
+ puts ""
232
+ puts " The agent is still initializing inside the container."
233
+ puts " This usually happens when git clone or downloads are slow."
234
+ puts ""
235
+ puts " To check progress:"
236
+ puts " docker logs -f #{container_name}"
237
+ puts ""
238
+ puts " Once you see 'tmux new-session' in the logs, attach with:"
239
+ puts " docker exec -it -u #{user} #{container_name} tmux attach -t agent"
240
+ puts ""
241
+ exit 1
242
+ end
217
243
 
218
244
  # Attach to agent session which has the status bar
219
245
  # Must run as agent user since tmux server runs under that user
@@ -384,6 +410,12 @@ module YatfaAgent
384
410
  if local_setup_script
385
411
  puts "🔧 Using local setup-agent.rb for development"
386
412
  docker_cmd.concat(["-v", "#{File.expand_path(local_setup_script)}:/tmp/setup-agent.rb:ro"])
413
+
414
+ # Mount companion scripts that setup-agent.rb loads via require_relative
415
+ Dir.glob(File.join(File.dirname(local_setup_script), "setup-*.rb")).each do |companion|
416
+ basename = File.basename(companion)
417
+ docker_cmd.concat(["-v", "#{File.expand_path(companion)}:/tmp/#{basename}:ro"])
418
+ end
387
419
  end
388
420
  end
389
421
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yatfa",
3
- "version": "1.0.77",
3
+ "version": "1.0.79",
4
4
  "description": "YATFA - Yet Another Tool For Agents",
5
5
  "bin": "./bin/run-yatfa-agent.rb",
6
6
  "files": [