diffbroker 0.17.0 → 0.17.1
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/lib/diffbroker/service_installer.rb +13 -1
- data/lib/diffbroker/version.rb +1 -1
- data/plugin/.claude-plugin/plugin.json +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: aadb0ca6d980e54bb60cfebac6989a09743a26b980263431c82d71f6f36b4cd1
|
|
4
|
+
data.tar.gz: ba0393f8a4c2a06427e848cc1ded4e839238f9d4039815025b40cbee2a560333
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8382f66ce1144835f96907edbf49f16c2e8e05287934bedd832c34e36dc69fb351ec626c924c39279b5653dfeccf23241390439491d418c6fb103ccc4c58a05
|
|
7
|
+
data.tar.gz: de18274bdd29606965514e7a4392ba3377b7fc9b9bd1baa27e8f4c9ec7169861caad8b9f32bc0f12f97815586e76aa75e5e592a5ef141cec4c3a85efc9570164
|
|
@@ -12,6 +12,10 @@ module Diffbroker
|
|
|
12
12
|
class Unavailable < Error; end
|
|
13
13
|
|
|
14
14
|
SETTLE_ATTEMPTS = 20
|
|
15
|
+
# A login the service cannot read from the Keychain: `claude setup-token` gives a year-long token that only an
|
|
16
|
+
# environment variable carries, and a service starts without the user's shell, so it is copied into the definition
|
|
17
|
+
# (which is then readable by its owner only).
|
|
18
|
+
SECRET_ENV = %w[CLAUDE_CODE_OAUTH_TOKEN].freeze
|
|
15
19
|
EXE = File.join(Diffbroker::ROOT, "exe", "diffbroker")
|
|
16
20
|
|
|
17
21
|
# What the service and the "Start companion" app run. RubyGems' own wrapper activates the newest installed diffbroker
|
|
@@ -86,6 +90,7 @@ module Diffbroker
|
|
|
86
90
|
FileUtils.mkdir_p(File.dirname(path))
|
|
87
91
|
FileUtils.mkdir_p(File.join(@home, "Library", "Logs")) if @platform == "macos"
|
|
88
92
|
File.write(path, @platform == "macos" ? plist : unit)
|
|
93
|
+
File.chmod(0o600, path)
|
|
89
94
|
path
|
|
90
95
|
end
|
|
91
96
|
|
|
@@ -159,7 +164,7 @@ module Diffbroker
|
|
|
159
164
|
def plist
|
|
160
165
|
arguments = [ @ruby, @exe, "start" ].map { " <string>#{xml(_1)}</string>" }.join("\n")
|
|
161
166
|
environment = { "PATH" => @env["PATH"].to_s, "SHELL" => @env["SHELL"] || "/bin/zsh", "LANG" => @env["LANG"] || "en_US.UTF-8" }
|
|
162
|
-
.map { |key, value| " <key>#{key}</key>\n <string>#{xml(value)}</string>" }.join("\n")
|
|
167
|
+
.merge(secret_environment).map { |key, value| " <key>#{key}</key>\n <string>#{xml(value)}</string>" }.join("\n")
|
|
163
168
|
log = xml(File.join(@home, "Library", "Logs", "diffbroker.log"))
|
|
164
169
|
<<~XML
|
|
165
170
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -207,6 +212,7 @@ module Diffbroker
|
|
|
207
212
|
RestartSec=5
|
|
208
213
|
Environment="PATH=#{@env["PATH"]}"
|
|
209
214
|
Environment="SHELL=#{@env["SHELL"] || "/bin/bash"}"
|
|
215
|
+
#{secret_environment.map { |key, value| %(Environment="#{key}=#{unit_escape(value)}") }.join("\n ")}
|
|
210
216
|
|
|
211
217
|
[Install]
|
|
212
218
|
WantedBy=default.target
|
|
@@ -215,6 +221,12 @@ module Diffbroker
|
|
|
215
221
|
|
|
216
222
|
private
|
|
217
223
|
|
|
224
|
+
# The variables of SECRET_ENV that this process has, empty ones left out.
|
|
225
|
+
def secret_environment = SECRET_ENV.to_h { [ _1, @env[_1].to_s.strip ] }.reject { |_, value| value.empty? }
|
|
226
|
+
|
|
227
|
+
# systemd expands % specifiers and reads quotes and backslashes inside Environment="…".
|
|
228
|
+
def unit_escape(value) = value.gsub(/[\\"%]/) { |char| char == "%" ? "%%" : "\\#{char}" }
|
|
229
|
+
|
|
218
230
|
def target = "gui/#{@uid}/#{LABEL}"
|
|
219
231
|
|
|
220
232
|
# kickstart fails once the job was booted out (`stop!`): load it again, RunAtLoad starts it.
|
data/lib/diffbroker/version.rb
CHANGED