brainiac 0.0.30 → 0.0.31
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/bin/brainiac +59 -23
- data/lib/brainiac/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ab80207a78e9cf2150459e67eae0d37fd9768a3f6aae774209099bd2b0f7fe93
|
|
4
|
+
data.tar.gz: c0af2f5a0348fa8540d575f7124218d803dee7531a6dc68205d516108314ae63
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83451dba00ca901f85495784fcd143a5ad4fe808ea2921702805804be1bef0f26202435e6057ddfb935cbc3d3f66518eed17878ecad9123034dbd8a33bdbac28
|
|
7
|
+
data.tar.gz: 194a1c6bc7e5819cd48f3f74aeb28988e6ebcaf0681cef7ac6168497a0a487ee116ee7c78b2b7bb9a6f750743ce23c9e2d5fdc6f8cb4c6e50e4b05f2397cac55
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
brainiac (0.0.
|
|
4
|
+
brainiac (0.0.31)
|
|
5
5
|
puma (~> 7.2)
|
|
6
6
|
rackup (~> 2.3)
|
|
7
7
|
sinatra (~> 4.1)
|
|
@@ -84,7 +84,7 @@ DEPENDENCIES
|
|
|
84
84
|
CHECKSUMS
|
|
85
85
|
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
|
86
86
|
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
|
87
|
-
brainiac (0.0.
|
|
87
|
+
brainiac (0.0.31)
|
|
88
88
|
json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
|
|
89
89
|
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
|
|
90
90
|
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
data/bin/brainiac
CHANGED
|
@@ -50,6 +50,64 @@ def save_config(config)
|
|
|
50
50
|
File.write(CONFIG_FILE, JSON.pretty_generate(config))
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
# Describe the git branch state of a local plugin checkout for the `plugins` list.
|
|
54
|
+
# Returns a short human-readable string like "main", "my-branch ↑2 ↓1 *"
|
|
55
|
+
# where ↑ = ahead of upstream, ↓ = behind upstream, * = uncommitted changes.
|
|
56
|
+
# Returns nil if the path isn't a git repo (so callers can skip the annotation).
|
|
57
|
+
def plugin_branch_status(path)
|
|
58
|
+
return nil unless Dir.exist?(path)
|
|
59
|
+
|
|
60
|
+
branch, _, br_status = Open3.capture3("git", "rev-parse", "--abbrev-ref", "HEAD", chdir: path)
|
|
61
|
+
return nil unless br_status.success?
|
|
62
|
+
|
|
63
|
+
branch = branch.strip
|
|
64
|
+
branch = "(detached)" if branch.empty? || branch == "HEAD"
|
|
65
|
+
|
|
66
|
+
parts = [branch]
|
|
67
|
+
|
|
68
|
+
# Ahead/behind counts vs the upstream tracking branch (if one is set).
|
|
69
|
+
counts, _, ab_status = Open3.capture3(
|
|
70
|
+
"git", "rev-list", "--left-right", "--count", "@{upstream}...HEAD", chdir: path
|
|
71
|
+
)
|
|
72
|
+
if ab_status.success?
|
|
73
|
+
behind, ahead = counts.strip.split(/\s+/).map(&:to_i)
|
|
74
|
+
parts << "↑#{ahead}" if ahead&.positive?
|
|
75
|
+
parts << "↓#{behind}" if behind&.positive?
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Uncommitted changes (staged, unstaged, or untracked).
|
|
79
|
+
dirty, _, st_status = Open3.capture3("git", "status", "--porcelain", chdir: path)
|
|
80
|
+
parts << "*" if st_status.success? && !dirty.strip.empty?
|
|
81
|
+
|
|
82
|
+
parts.join(" ")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Format a single line for the `brainiac plugins` list. Handles both local
|
|
86
|
+
# (path-based) plugins and gem-based plugins, including branch/sync status
|
|
87
|
+
# for local checkouts.
|
|
88
|
+
def plugin_list_line(entry)
|
|
89
|
+
name = entry["name"]
|
|
90
|
+
gem_name = entry["gem"] || "brainiac-#{name}"
|
|
91
|
+
local_path = entry["path"]
|
|
92
|
+
installed_at = entry["installed_at"] ? " (#{entry["installed_at"][0..9]})" : ""
|
|
93
|
+
|
|
94
|
+
return " #{gem_plugin_status(name, gem_name)}#{installed_at}" unless local_path
|
|
95
|
+
|
|
96
|
+
return " ✗ #{name} → #{local_path} (path missing)#{installed_at}" unless Dir.exist?(local_path)
|
|
97
|
+
|
|
98
|
+
branch = plugin_branch_status(local_path)
|
|
99
|
+
branch_note = branch ? " [#{branch}]" : ""
|
|
100
|
+
" ✓ #{name} → #{local_path}#{branch_note}#{installed_at}"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Check whether a gem-based plugin is installed/loadable and return a status string.
|
|
104
|
+
def gem_plugin_status(name, gem_name)
|
|
105
|
+
spec = Gem::Specification.find_by_name(gem_name)
|
|
106
|
+
"✓ #{name} (#{gem_name} #{spec.version})"
|
|
107
|
+
rescue Gem::MissingSpecError
|
|
108
|
+
"✗ #{name} (#{gem_name} — gem not found)"
|
|
109
|
+
end
|
|
110
|
+
|
|
53
111
|
# Resolve the default agent name: env var → brainiac.json → nil.
|
|
54
112
|
def default_agent_name
|
|
55
113
|
return ENV["AI_AGENT_NAME"] if ENV["AI_AGENT_NAME"] && !ENV["AI_AGENT_NAME"].empty?
|
|
@@ -3035,29 +3093,7 @@ when "plugins"
|
|
|
3035
3093
|
puts "Installed plugins:"
|
|
3036
3094
|
plugins.each do |p|
|
|
3037
3095
|
entry = p.is_a?(Hash) ? p : { "name" => p.to_s }
|
|
3038
|
-
|
|
3039
|
-
gem_name = entry["gem"] || "brainiac-#{name}"
|
|
3040
|
-
local_path = entry["path"]
|
|
3041
|
-
installed_at = entry["installed_at"] ? " (#{entry["installed_at"][0..9]})" : ""
|
|
3042
|
-
|
|
3043
|
-
if local_path
|
|
3044
|
-
# Local plugin — check path exists
|
|
3045
|
-
if Dir.exist?(local_path)
|
|
3046
|
-
puts " ✓ #{name} → #{local_path}#{installed_at}"
|
|
3047
|
-
else
|
|
3048
|
-
puts " ✗ #{name} → #{local_path} (path missing)#{installed_at}"
|
|
3049
|
-
end
|
|
3050
|
-
else
|
|
3051
|
-
# Gem plugin — check gem is loadable
|
|
3052
|
-
version = entry["version"] || "latest"
|
|
3053
|
-
loadable = begin
|
|
3054
|
-
spec = Gem::Specification.find_by_name(gem_name)
|
|
3055
|
-
"✓ #{name} (#{gem_name} #{spec.version})"
|
|
3056
|
-
rescue Gem::MissingSpecError
|
|
3057
|
-
"✗ #{name} (#{gem_name} — gem not found)"
|
|
3058
|
-
end
|
|
3059
|
-
puts " #{loadable}#{installed_at}"
|
|
3060
|
-
end
|
|
3096
|
+
puts plugin_list_line(entry)
|
|
3061
3097
|
end
|
|
3062
3098
|
end
|
|
3063
3099
|
else
|
data/lib/brainiac/version.rb
CHANGED