Class: Legion::CLI::Coldstart

Inherits:
Thor
  • Object
show all
Defined in:
lib/legion/cli/coldstart_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/legion/cli/coldstart_command.rb', line 6

def self.exit_on_failure?
  true
end

Instance Method Details

#ingest(*paths) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/legion/cli/coldstart_command.rb', line 27

def ingest(*paths)
  out = formatter
  paths = [Dir.pwd] if paths.empty?

  paths.each do |path|
    unless File.exist?(path)
      out.error("Path not found: #{path}")
      next
    end

    if options[:dry_run]
      require_coldstart!
      run_local_ingest(out, path, dry_run: true)
      next
    end

    result = try_api_ingest(path)
    if result
      out.success('Ingested via running daemon (traces stored in live memory)')
      File.directory?(path) ? render_directory_result(out, result) : render_file_result(out, result)
    else
      out.warn('Daemon not running, ingesting locally (traces stored in-process only)')
      require_coldstart!
      run_local_ingest(out, path, dry_run: false)
    end
  end
end

#preview(*paths) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/legion/cli/coldstart_command.rb', line 57

def preview(*paths)
  out = formatter
  require_coldstart!
  paths = [Dir.pwd] if paths.empty?

  runner = build_runner(Legion::Extensions::Coldstart::Runners::Ingest)

  paths.each do |path|
    if File.file?(path)
      result = runner.preview_ingest(file_path: File.expand_path(path))
      render_file_result(out, result)
    elsif File.directory?(path)
      result = runner.ingest_directory(
        dir_path:     File.expand_path(path),
        pattern:      '**/{CLAUDE,MEMORY}.md',
        store_traces: false
      )
      render_directory_result(out, result)
    else
      out.error("Path not found: #{path}")
    end
  end
end

#statusObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/legion/cli/coldstart_command.rb', line 82

def status
  out = formatter
  require_coldstart!

  runner = build_runner(Legion::Extensions::Coldstart::Runners::Coldstart)
  progress = runner.coldstart_progress

  if options[:json]
    out.json(progress)
  else
    out.header('Cold Start Status')
    out.spacer
    out.detail({
                 'Firmware Loaded'   => progress[:firmware_loaded],
                 'Imprint Active'    => progress[:imprint_active],
                 'Imprint Progress'  => "#{(progress[:imprint_progress] * 100).round(1)}%",
                 'Observation Count' => progress[:observation_count],
                 'Calibration State' => progress[:calibration_state],
                 'Current Layer'     => progress[:current_layer]
               })
  end
end